Various Fixes part two (#705)

* Various Fixes

* Various Fixes
This commit is contained in:
Christopher Martin 2017-01-20 21:03:36 -08:00 committed by GitHub
parent 102ea0c3c0
commit 885c59ef17
10 changed files with 35 additions and 32 deletions

View file

@ -1160,7 +1160,7 @@ public class GeneralMethods {
}
public static boolean isAdjacentToThreeOrMoreSources(Block block) {
if ((TempBlock.isTempBlock(block) && !PhaseChange.getFrozenBlocksAsTempBlock().contains(TempBlock.get(block))) || block.equals(null)) {
if (block.equals(null) || (TempBlock.isTempBlock(block) && WaterAbility.isBendableWaterTempBlock(block))) {
return false;
}
int sources = 0;

View file

@ -14,6 +14,7 @@ import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.util.Collision;
import com.projectkorra.projectkorra.firebending.HeatControl;
import com.projectkorra.projectkorra.util.BlockSource;
import com.projectkorra.projectkorra.util.ParticleEffect;
import com.projectkorra.projectkorra.util.ParticleEffect.ParticleData;
@ -85,6 +86,14 @@ public abstract class WaterAbility extends ElementalAbility {
ParticleEffect.BLOCK_CRACK.display(particleData, 1F, 1F, 1F, 0.1F, 10, collision.getLocationFirst(), 50);
}
}
public static boolean isBendableWaterTempBlock(Block block) { // Will need to be done for earth as well.
return isBendableWaterTempBlock(TempBlock.get(block));
}
public static boolean isBendableWaterTempBlock(TempBlock tempBlock) {
return PhaseChange.getFrozenBlocksAsTempBlock().contains(tempBlock) || HeatControl.getMeltedBlocks().contains(tempBlock);
}
public boolean isIcebendable(Block block) {
return isIcebendable(block.getType());
@ -131,7 +140,7 @@ public abstract class WaterAbility extends ElementalAbility {
continue;
}
if (isIcebendable(player, block.getType(), false)) {
if (TempBlock.isTempBlock(block) && !PhaseChange.getFrozenBlocksAsTempBlock().contains(TempBlock.get(block))) {
if (TempBlock.isTempBlock(block) && !isBendableWaterTempBlock(block)) {
continue;
}
return block;
@ -175,7 +184,7 @@ public abstract class WaterAbility extends ElementalAbility {
if (GeneralMethods.isRegionProtectedFromBuild(player, "PlantDisc", location)) {
continue;
} else if (isPlantbendable(player, block.getType(), onlyLeaves)) {
if (TempBlock.isTempBlock(block) && !PhaseChange.getFrozenBlocksAsTempBlock().contains(TempBlock.get(block))) {
if (TempBlock.isTempBlock(block) && !isBendableWaterTempBlock(block)) {
continue;
}
return block;
@ -213,7 +222,7 @@ public abstract class WaterAbility extends ElementalAbility {
if ((!isTransparent(player, block) && !isIce(block) && !isPlant(block)) || GeneralMethods.isRegionProtectedFromBuild(player, "WaterManipulation", location)) {
continue;
} else if (isWaterbendable(player, null, block) && (!isPlant(block) || plantbending)) {
if (TempBlock.isTempBlock(block) && !PhaseChange.getFrozenBlocksAsTempBlock().contains(TempBlock.get(block))) {
if (TempBlock.isTempBlock(block) && !isBendableWaterTempBlock(block)) {
continue;
}
return block;
@ -270,8 +279,7 @@ public abstract class WaterAbility extends ElementalAbility {
if (bPlayer == null || !isWaterbendable(block.getType()) || GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation())) {
return false;
}
if (TempBlock.isTempBlock(block) && !PhaseChange.getFrozenBlocksAsTempBlock().contains(TempBlock.get(block))) {
if (TempBlock.isTempBlock(block) && !isBendableWaterTempBlock(block)) {
return false;
} else if (isWater(block) && block.getData() == full) {
return true;

View file

@ -2,6 +2,7 @@ package com.projectkorra.projectkorra.firebending;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -460,5 +461,10 @@ public class HeatControl extends FireAbility {
}
return null;
}
public static Collection<TempBlock> getMeltedBlocks() {
return MELTED_BLOCKS.values();
}
}

View file

@ -5,7 +5,6 @@ import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.EarthAbility;
import com.projectkorra.projectkorra.ability.WaterAbility;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.waterbending.ice.PhaseChange;
import org.bukkit.Location;
import org.bukkit.Material;
@ -164,7 +163,7 @@ public class BlockSource {
public static Block getSourceBlock(Player player, double range, BlockSourceType sourceType, ClickType clickType) {
BlockSourceInformation info = getValidBlockSourceInformation(player, range, sourceType, clickType);
if (info != null) {
if (TempBlock.isTempBlock(info.getBlock()) && !PhaseChange.getFrozenBlocksAsTempBlock().contains(TempBlock.get(info.getBlock()))) {
if (TempBlock.isTempBlock(info.getBlock()) && !WaterAbility.isBendableWaterTempBlock(info.getBlock())) {
return null;
}
return info.getBlock();
@ -268,7 +267,7 @@ public class BlockSource {
sourceBlock = getSourceBlock(player, range, BlockSourceType.SNOW, clickType);
}
if (sourceBlock != null && !sourceBlock.getType().equals(Material.AIR) && (WaterAbility.isWater(sourceBlock) || WaterAbility.isPlant(sourceBlock) || WaterAbility.isSnow(sourceBlock) || WaterAbility.isIce(sourceBlock))) {
if (TempBlock.isTempBlock(sourceBlock) && !PhaseChange.getFrozenBlocksAsTempBlock().contains(TempBlock.get(sourceBlock))) {
if (TempBlock.isTempBlock(sourceBlock) && !WaterAbility.isBendableWaterTempBlock(sourceBlock)) {
return null;
}
return sourceBlock;

View file

@ -90,19 +90,18 @@ public class SurgeWall extends WaterAbility {
Block block = eyeLoc.add(eyeLoc.getDirection().normalize()).getBlock();
if (isTransparent(player, block) && isTransparent(player, eyeLoc.getBlock())) {
block.setType(Material.WATER);
block.setData(FULL);
TempBlock tempBlock = new TempBlock(block, Material.STATIONARY_WATER, (byte) 0);
wave = new SurgeWave(player);
wave.setCanHitSelf(false);
wave.moveWater();
if (!wave.isProgressing()) {
block.setType(Material.AIR);
wave.remove();
} else {
WaterReturn.emptyWaterBottle(player);
}
tempBlock.revertBlock();
}
}
}
@ -182,9 +181,6 @@ public class SurgeWall extends WaterAbility {
if (isPlant(sourceBlock) || isSnow(sourceBlock)) {
new PlantRegrowth(player, sourceBlock);
}
if (!GeneralMethods.isAdjacentToThreeOrMoreSources(sourceBlock)) {
sourceBlock.setType(Material.AIR);
}
addWater(sourceBlock);
}
@ -307,7 +303,6 @@ public class SurgeWall extends WaterAbility {
if (location.distanceSquared(targetDestination) < 1) {
removeWater(sourceBlock);
;
forming = true;
}
}
@ -388,17 +383,17 @@ public class SurgeWall extends WaterAbility {
Location eyeLoc = player.getEyeLocation();
Block block = eyeLoc.add(eyeLoc.getDirection().normalize()).getBlock();
if (isTransparent(player, block) && isTransparent(player, eyeLoc.getBlock())) {
block.setType(Material.WATER);
block.setData(FULL);
TempBlock tempBlock = new TempBlock(block, Material.STATIONARY_WATER, (byte) 0);
wall = new SurgeWall(player);
wall.moveWater();
if (!wall.progressing) {
block.setType(Material.AIR);
tempBlock.revertBlock();
wall.remove();
} else {
WaterReturn.emptyWaterBottle(player);
}
tempBlock.revertBlock();
return;
}
}

View file

@ -213,9 +213,6 @@ public class SurgeWave extends WaterAbility {
if (isPlant(sourceBlock) || isSnow(sourceBlock)) {
new PlantRegrowth(player, sourceBlock);
}
if (!GeneralMethods.isAdjacentToThreeOrMoreSources(sourceBlock)) {
sourceBlock.setType(Material.AIR);
}
addWater(sourceBlock);
}
}

View file

@ -433,7 +433,7 @@ public class WaterManipulation extends WaterAbility {
return false;
} else if (SurgeWave.isBlockWave(block)) {
return false;
} else if (TempBlock.isTempBlock(block) && !PhaseChange.getFrozenBlocksAsTempBlock().contains(TempBlock.get(block))) {
} else if (TempBlock.isTempBlock(block) && !WaterAbility.isBendableWaterTempBlock(block)) {
return false;
}
return true;

View file

@ -3,6 +3,7 @@ package com.projectkorra.projectkorra.waterbending.ice;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.ability.IceAbility;
import com.projectkorra.projectkorra.ability.WaterAbility;
import com.projectkorra.projectkorra.util.DamageHandler;
import com.projectkorra.projectkorra.util.TempBlock;
import com.projectkorra.projectkorra.util.TempPotionEffect;
@ -20,7 +21,6 @@ import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Random;
@ -79,7 +79,7 @@ public class IceSpikePillar extends IceAbility {
Block tempTestingBlock = closestEntity.getLocation().getBlock().getRelative(BlockFace.DOWN, 1);
this.source_block = tempTestingBlock;
} else {
this.source_block = player.getTargetBlock((HashSet<Material>) null, (int) range);
this.source_block = WaterAbility.getIceSourceBlock(player, range);
}
origin = source_block.getLocation();
location = origin.clone();
@ -156,10 +156,6 @@ public class IceSpikePillar extends IceAbility {
return false;
}
if (TempBlock.isTempBlock(source_block)) {
return false;
}
Block b;
for (int i = 1; i <= height; i++) {
b = source_block.getWorld().getBlockAt(location.clone().add(direction.clone().multiply(i)));

View file

@ -152,8 +152,6 @@ public class WaterArms extends WaterAbility {
fullSource = false;
}
ParticleEffect.LARGE_SMOKE.display(getWaterSourceBlock(player, sourceGrabRange, canUsePlantSource).getLocation().clone().add(0.5, 0.5, 0.5), 0, 0, 0, 0F, 4);
new PlantRegrowth(player, sourceBlock);
sourceBlock.setType(Material.AIR);
return true;
} else if (WaterReturn.hasWaterBottle(player)) {
WaterReturn.emptyWaterBottle(player);

View file

@ -221,7 +221,11 @@ public class WaterArmsSpear extends WaterAbility {
public static void thaw(Block block) {
if (canThaw(block)) {
getIceBlocks().remove(block);
block.setType(Material.AIR);
if (TempBlock.isTempBlock(block)) {
TempBlock.get(block).revertBlock();
} else {
block.setType(Material.AIR);
}
}
}