IceSpike + Water Fixes (#701)

* IceSpike + Water Fixes

• Fixed IceSpike not using TempBlocks
• Fixed IceWave not automatically thawing the ice that freezes people
• Fixed EarthPassive (Soft landing) dropping sand blocks when the sand
is broken
• Made HeatControl a harmless ability if it's the Cook ability

* Change isHarmless to use equals() rather than ==
This commit is contained in:
StrangeOne101 2017-01-19 11:42:08 +13:00 committed by Christopher Martin
parent 8884f01e1a
commit 0b2833d9b6
6 changed files with 98 additions and 75 deletions

View file

@ -223,6 +223,8 @@ public class PKListener implements Listener {
EarthAbility.removeRevertIndex(block); EarthAbility.removeRevertIndex(block);
} else if (TempBlock.isTempBlock(block)) { } else if (TempBlock.isTempBlock(block)) {
TempBlock.revertBlock(block, Material.AIR); TempBlock.revertBlock(block, Material.AIR);
} else if (EarthPassive.isPassiveSand(block)) {
EarthPassive.revertSand(block);
} }
} }

View file

@ -941,6 +941,8 @@ public class ConfigManager {
config.addDefault("Abilities.Water.WaterCombo.IceBullet.AnimationSpeed", 1); config.addDefault("Abilities.Water.WaterCombo.IceBullet.AnimationSpeed", 1);
config.addDefault("Abilities.Water.WaterCombo.IceBullet.ShootTime", 10000); config.addDefault("Abilities.Water.WaterCombo.IceBullet.ShootTime", 10000);
config.addDefault("Abilities.Water.WaterCombo.IceBullet.Cooldown", 10000); config.addDefault("Abilities.Water.WaterCombo.IceBullet.Cooldown", 10000);
config.addDefault("Abilities.Water.WaterCombo.IceWave.RevertSphere", true);
config.addDefault("Abilities.Water.WaterCombo.IceWave.RevertSphereTime", 30000L);
config.addDefault("Abilities.Earth.Passive.Duration", 2500); config.addDefault("Abilities.Earth.Passive.Duration", 2500);
config.addDefault("Abilities.Earth.Passive.DensityShift.Enabled", true); config.addDefault("Abilities.Earth.Passive.DensityShift.Enabled", true);

View file

@ -414,7 +414,7 @@ public class HeatControl extends FireAbility {
@Override @Override
public boolean isHarmlessAbility() { public boolean isHarmlessAbility() {
return false; return this.heatControlType.equals(HeatControlType.COOK);
} }
@Override @Override

View file

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Location; import org.bukkit.Location;
@ -45,9 +46,11 @@ public class WaterSpoutWave extends WaterAbility {
private boolean moving; private boolean moving;
private boolean plant; private boolean plant;
private boolean collidable; private boolean collidable;
private boolean revertIceSphere;
private int progressCounter; private int progressCounter;
private long time; private long time;
private long cooldown; private long cooldown;
private long revertSphereTime;
private double selectRange; private double selectRange;
private double speed; private double speed;
private double chargeTime; private double chargeTime;
@ -83,6 +86,8 @@ public class WaterSpoutWave extends WaterAbility {
this.chargeTime = getConfig().getLong("Abilities.Water.WaterSpout.Wave.ChargeTime"); this.chargeTime = getConfig().getLong("Abilities.Water.WaterSpout.Wave.ChargeTime");
this.flightTime = getConfig().getLong("Abilities.Water.WaterSpout.Wave.FlightTime"); this.flightTime = getConfig().getLong("Abilities.Water.WaterSpout.Wave.FlightTime");
this.cooldown = getConfig().getLong("Abilities.Water.WaterSpout.Wave.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Water.WaterSpout.Wave.Cooldown");
this.revertSphereTime = getConfig().getLong("Abilities.Water.WaterCombo.IceWave.RevertSphereTime");
this.revertIceSphere = getConfig().getBoolean("Abilities.Water.WaterCombo.IceWave.RevertSphere");
this.affectedBlocks = new ConcurrentHashMap<>(); this.affectedBlocks = new ConcurrentHashMap<>();
this.affectedEntities = new ArrayList<>(); this.affectedEntities = new ArrayList<>();
this.tasks = new ArrayList<>(); this.tasks = new ArrayList<>();
@ -386,6 +391,9 @@ public class WaterSpoutWave extends WaterAbility {
if (!FROZEN_BLOCKS.containsKey(block)) { if (!FROZEN_BLOCKS.containsKey(block)) {
TempBlock tblock = new TempBlock(block, Material.ICE, (byte) 1); TempBlock tblock = new TempBlock(block, Material.ICE, (byte) 1);
FROZEN_BLOCKS.put(block, tblock); FROZEN_BLOCKS.put(block, tblock);
if (revertIceSphere) {
tblock.setRevertTime(revertSphereTime + (new Random().nextInt(1000) - 500));
}
} }
} }
} }
@ -432,6 +440,20 @@ public class WaterSpoutWave extends WaterAbility {
} }
return false; return false;
} }
public static void progressAllCleanup() {
for (Block block : FROZEN_BLOCKS.keySet()) {
TempBlock tb = FROZEN_BLOCKS.get(block);
if (block.getType() != Material.ICE) {
FROZEN_BLOCKS.remove(block);
continue;
}
if (tb == null || !TempBlock.isTempBlock(block)) {
FROZEN_BLOCKS.remove(block);
continue;
}
}
}
public static boolean canThaw(Block block) { public static boolean canThaw(Block block) {
return FROZEN_BLOCKS.containsKey(block); return FROZEN_BLOCKS.containsKey(block);

View file

@ -4,6 +4,7 @@ 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.util.DamageHandler; import com.projectkorra.projectkorra.util.DamageHandler;
import com.projectkorra.projectkorra.util.TempBlock;
import com.projectkorra.projectkorra.util.TempPotionEffect; import com.projectkorra.projectkorra.util.TempPotionEffect;
import org.bukkit.Location; import org.bukkit.Location;
@ -18,16 +19,16 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
public class IceSpikePillar extends IceAbility { public class IceSpikePillar extends IceAbility {
private static final Map<Block, Block> ALREADY_DONE_BLOCKS = new ConcurrentHashMap<>(); /**The list of blocks IceSpike uses*/
private static final Map<Block, Integer> BASE_BLOCKS = new ConcurrentHashMap<>(); private Map<Block, TempBlock> ice_blocks = new HashMap<Block, TempBlock>();
private int height; private int height;
private int progress; private int progress;
private int slowPower; private int slowPower;
@ -41,14 +42,14 @@ public class IceSpikePillar extends IceAbility {
private double damage; private double damage;
private double range; private double range;
private double speed; private double speed;
private Block block; private Block source_block; //The block clicked on
private Block base_block; //The block at the bottom of the pillar
private Location origin; private Location origin;
private Location location; private Location location;
private Vector thrownForce; private Vector thrownForce;
private Vector direction; private Vector direction;
private ConcurrentHashMap<Block, Block> affectedBlocks;
private ArrayList<LivingEntity> damaged; private ArrayList<LivingEntity> damaged;
protected boolean inField = false; protected boolean inField = false; //If it's part of a field or not.
public IceSpikePillar(Player player) { public IceSpikePillar(Player player) {
super(player); super(player);
@ -76,19 +77,17 @@ public class IceSpikePillar extends IceAbility {
if (closestEntity != null) { if (closestEntity != null) {
Block tempTestingBlock = closestEntity.getLocation().getBlock().getRelative(BlockFace.DOWN, 1); Block tempTestingBlock = closestEntity.getLocation().getBlock().getRelative(BlockFace.DOWN, 1);
this.block = tempTestingBlock; this.source_block = tempTestingBlock;
} else { } else {
this.block = player.getTargetBlock((HashSet<Material>) null, (int) range); this.source_block = player.getTargetBlock((HashSet<Material>) null, (int) range);
} }
origin = block.getLocation(); origin = source_block.getLocation();
location = origin.clone(); location = origin.clone();
} }
catch (IllegalStateException e) { catch (IllegalStateException e) {
return; return;
} }
loadAffectedBlocks();
if (height != 0) { if (height != 0) {
if (canInstantiate()) { if (canInstantiate()) {
start(); start();
@ -108,11 +107,9 @@ public class IceSpikePillar extends IceAbility {
this.damage = damage; this.damage = damage;
this.thrownForce = throwing; this.thrownForce = throwing;
this.location = origin.clone(); this.location = origin.clone();
this.block = location.getBlock(); this.source_block = location.getBlock();
loadAffectedBlocks(); if (isIcebendable(source_block)) {
if (isIcebendable(block)) {
if (canInstantiate()) { if (canInstantiate()) {
start(); start();
time = System.currentTimeMillis() - interval; time = System.currentTimeMillis() - interval;
@ -131,46 +128,46 @@ public class IceSpikePillar extends IceAbility {
this.cooldown = getConfig().getLong("Abilities.Water.IceSpike.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Water.IceSpike.Cooldown");
this.height = getConfig().getInt("Abilities.Water.IceSpike.Height"); this.height = getConfig().getInt("Abilities.Water.IceSpike.Height");
this.thrownForce = new Vector(0, getConfig().getDouble("Abilities.Water.IceSpike.Push"), 0); this.thrownForce = new Vector(0, getConfig().getDouble("Abilities.Water.IceSpike.Push"), 0);
this.affectedBlocks = new ConcurrentHashMap<>();
this.damaged = new ArrayList<>(); this.damaged = new ArrayList<>();
this.interval = (long) (1000. / speed); this.interval = (long) (1000. / speed);
} }
private void loadAffectedBlocks() { /**
affectedBlocks.clear(); * Reverts the block if it's part of IceSpike
Block thisBlock; * @param block The Block
for (int i = 1; i <= height; i++) { * @return If the block was removed or not
thisBlock = block.getWorld().getBlockAt(location.clone().add(direction.clone().multiply(i))); */
affectedBlocks.put(thisBlock, thisBlock); public static boolean revertBlock(Block block) {
}
}
private boolean blockInAffectedBlocks(Block block) {
return affectedBlocks.containsKey(block);
}
public static boolean blockInAllAffectedBlocks(Block block) {
for (IceSpikePillar iceSpike : getAbilities(IceSpikePillar.class)) { for (IceSpikePillar iceSpike : getAbilities(IceSpikePillar.class)) {
if (iceSpike.blockInAffectedBlocks(block)) { if (iceSpike.ice_blocks.containsKey(block)) {
iceSpike.ice_blocks.get(block).revertBlock();
iceSpike.ice_blocks.remove(block);
return true; return true;
} }
} }
return false; return false;
} }
public static void revertBlock(Block block) { /**Checks to see if this move can start. Checks things like if there is enough space to form, if the source isn't
for (IceSpikePillar iceSpike : getAbilities(IceSpikePillar.class)) { * a TempBlock, etc.*/
iceSpike.affectedBlocks.remove(block);
}
}
private boolean canInstantiate() { private boolean canInstantiate() {
if (!isIcebendable(block.getType())) { if (!isIcebendable(source_block.getType())) {
return false; return false;
} }
for (Block block : affectedBlocks.keySet()) {
if (blockInAllAffectedBlocks(block) || ALREADY_DONE_BLOCKS.containsKey(block) || block.getType() != Material.AIR || (block.getX() == player.getEyeLocation().getBlock().getX() && block.getZ() == player.getEyeLocation().getBlock().getZ())) { 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)));
if (b.getType() != Material.AIR) {
return false;
}
if (b.getX() == player.getEyeLocation().getBlock().getX() && b.getZ() == player.getEyeLocation().getBlock().getZ()) {
return false; return false;
} }
} }
@ -185,9 +182,9 @@ public class IceSpikePillar extends IceAbility {
risePillar(); risePillar();
removeTimestamp = System.currentTimeMillis(); removeTimestamp = System.currentTimeMillis();
} else { } else {
//If it's time to remove
if (removeTimestamp != 0 && removeTimestamp + removeTimer <= System.currentTimeMillis()) { if (removeTimestamp != 0 && removeTimestamp + removeTimer <= System.currentTimeMillis()) {
BASE_BLOCKS.put(location.clone().add(direction.clone().multiply(-1 * (height))).getBlock(), (height - 1)); if (!sinkPillar()) {
if (!revertblocks()) {
remove(); remove();
return; return;
} }
@ -196,6 +193,10 @@ public class IceSpikePillar extends IceAbility {
} }
} }
/**
* Makes the pillar rise by 1 block.
*
* @return If the block was placed successfully.*/
private boolean risePillar() { private boolean risePillar() {
progress++; progress++;
Block affectedBlock = location.clone().add(direction).getBlock(); Block affectedBlock = location.clone().add(direction).getBlock();
@ -211,16 +212,14 @@ public class IceSpikePillar extends IceAbility {
affect(le); affect(le);
} }
} }
TempBlock b = new TempBlock(affectedBlock, Material.ICE, (byte)0);
ice_blocks.put(affectedBlock, b);
affectedBlock.setType(Material.ICE);
if (!inField || new Random().nextInt((int) ((height + 1) * 1.5)) == 0) { if (!inField || new Random().nextInt((int) ((height + 1) * 1.5)) == 0) {
playIcebendingSound(block.getLocation()); playIcebendingSound(source_block.getLocation());
}
loadAffectedBlocks();
if (location.distanceSquared(origin) >= height * height) {
return false;
} }
return true; return true;
} }
@ -241,24 +240,20 @@ public class IceSpikePillar extends IceAbility {
} }
AirAbility.breakBreathbendingHold(entity); AirAbility.breakBreathbendingHold(entity);
} }
/**The reverse of risePillar(). Makes the pillar sink
*
* @return If the move should continue progressing.*/
public boolean sinkPillar() {
Vector direction = this.direction.clone().multiply(-1);
if (ice_blocks.containsKey(location.getBlock())) {
ice_blocks.get(location.getBlock()).revertBlock();
ice_blocks.remove(location.getBlock());
location.add(direction);
public static boolean blockIsBase(Block block) { if (source_block == location.getBlock()) {
return block != null ? BASE_BLOCKS.containsKey(block) : null; return false;
} }
public static void removeBlockBase(Block block) {
if (block != null) {
BASE_BLOCKS.remove(block);
}
}
public boolean revertblocks() {
Vector direction = new Vector(0, -1, 0);
location.getBlock().setType(Material.AIR);
location.add(direction);
if (blockIsBase(location.getBlock())) {
return false;
} }
return true; return true;
} }
@ -384,11 +379,11 @@ public class IceSpikePillar extends IceAbility {
} }
public Block getBlock() { public Block getBlock() {
return block; return source_block;
} }
public void setBlock(Block block) { public void setBlock(Block block) {
this.block = block; this.source_block = block;
} }
public Location getOrigin() { public Location getOrigin() {
@ -424,12 +419,12 @@ public class IceSpikePillar extends IceAbility {
this.direction = direction; this.direction = direction;
} }
public static Map<Block, Block> getAlreadyDoneBlocks() { public Map<Block, TempBlock> getIceBlocks() {
return ALREADY_DONE_BLOCKS; return ice_blocks;
} }
public static Map<Block, Integer> getBaseBlocks() { public Block getBaseBlock() {
return BASE_BLOCKS; return base_block;
} }
} }

View file

@ -2,6 +2,7 @@ package com.projectkorra.projectkorra.waterbending.util;
import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.waterbending.Torrent; import com.projectkorra.projectkorra.waterbending.Torrent;
import com.projectkorra.projectkorra.waterbending.WaterSpoutWave;
import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArms; import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArms;
public class WaterbendingManager implements Runnable { public class WaterbendingManager implements Runnable {
@ -17,6 +18,7 @@ public class WaterbendingManager implements Runnable {
//WaterPassive.handlePassive(); # Fast Swim is now managed in FastSwim.java //WaterPassive.handlePassive(); # Fast Swim is now managed in FastSwim.java
Torrent.progressAllCleanup(); Torrent.progressAllCleanup();
WaterArms.progressAllCleanup(); WaterArms.progressAllCleanup();
WaterSpoutWave.progressAllCleanup();
} }
} }