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) { 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; return false;
} }
int sources = 0; int sources = 0;

View file

@ -14,6 +14,7 @@ import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.ability.util.Collision;
import com.projectkorra.projectkorra.firebending.HeatControl;
import com.projectkorra.projectkorra.util.BlockSource; import com.projectkorra.projectkorra.util.BlockSource;
import com.projectkorra.projectkorra.util.ParticleEffect; import com.projectkorra.projectkorra.util.ParticleEffect;
import com.projectkorra.projectkorra.util.ParticleEffect.ParticleData; 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); 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) { public boolean isIcebendable(Block block) {
return isIcebendable(block.getType()); return isIcebendable(block.getType());
@ -131,7 +140,7 @@ public abstract class WaterAbility extends ElementalAbility {
continue; continue;
} }
if (isIcebendable(player, block.getType(), false)) { if (isIcebendable(player, block.getType(), false)) {
if (TempBlock.isTempBlock(block) && !PhaseChange.getFrozenBlocksAsTempBlock().contains(TempBlock.get(block))) { if (TempBlock.isTempBlock(block) && !isBendableWaterTempBlock(block)) {
continue; continue;
} }
return block; return block;
@ -175,7 +184,7 @@ public abstract class WaterAbility extends ElementalAbility {
if (GeneralMethods.isRegionProtectedFromBuild(player, "PlantDisc", location)) { if (GeneralMethods.isRegionProtectedFromBuild(player, "PlantDisc", location)) {
continue; continue;
} else if (isPlantbendable(player, block.getType(), onlyLeaves)) { } else if (isPlantbendable(player, block.getType(), onlyLeaves)) {
if (TempBlock.isTempBlock(block) && !PhaseChange.getFrozenBlocksAsTempBlock().contains(TempBlock.get(block))) { if (TempBlock.isTempBlock(block) && !isBendableWaterTempBlock(block)) {
continue; continue;
} }
return block; 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)) { if ((!isTransparent(player, block) && !isIce(block) && !isPlant(block)) || GeneralMethods.isRegionProtectedFromBuild(player, "WaterManipulation", location)) {
continue; continue;
} else if (isWaterbendable(player, null, block) && (!isPlant(block) || plantbending)) { } 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; continue;
} }
return block; return block;
@ -270,8 +279,7 @@ public abstract class WaterAbility extends ElementalAbility {
if (bPlayer == null || !isWaterbendable(block.getType()) || GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation())) { if (bPlayer == null || !isWaterbendable(block.getType()) || GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation())) {
return false; return false;
} }
if (TempBlock.isTempBlock(block) && !isBendableWaterTempBlock(block)) {
if (TempBlock.isTempBlock(block) && !PhaseChange.getFrozenBlocksAsTempBlock().contains(TempBlock.get(block))) {
return false; return false;
} else if (isWater(block) && block.getData() == full) { } else if (isWater(block) && block.getData() == full) {
return true; return true;

View file

@ -2,6 +2,7 @@ package com.projectkorra.projectkorra.firebending;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -460,5 +461,10 @@ public class HeatControl extends FireAbility {
} }
return null; 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.EarthAbility;
import com.projectkorra.projectkorra.ability.WaterAbility; import com.projectkorra.projectkorra.ability.WaterAbility;
import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.waterbending.ice.PhaseChange;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -164,7 +163,7 @@ public class BlockSource {
public static Block getSourceBlock(Player player, double range, BlockSourceType sourceType, ClickType clickType) { public static Block getSourceBlock(Player player, double range, BlockSourceType sourceType, ClickType clickType) {
BlockSourceInformation info = getValidBlockSourceInformation(player, range, sourceType, clickType); BlockSourceInformation info = getValidBlockSourceInformation(player, range, sourceType, clickType);
if (info != null) { 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 null;
} }
return info.getBlock(); return info.getBlock();
@ -268,7 +267,7 @@ public class BlockSource {
sourceBlock = getSourceBlock(player, range, BlockSourceType.SNOW, clickType); 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 (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 null;
} }
return sourceBlock; return sourceBlock;

View file

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

View file

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

View file

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

View file

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

View file

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