mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-01-03 13:38:20 +00:00
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:
parent
8884f01e1a
commit
0b2833d9b6
6 changed files with 98 additions and 75 deletions
|
@ -223,6 +223,8 @@ public class PKListener implements Listener {
|
|||
EarthAbility.removeRevertIndex(block);
|
||||
} else if (TempBlock.isTempBlock(block)) {
|
||||
TempBlock.revertBlock(block, Material.AIR);
|
||||
} else if (EarthPassive.isPassiveSand(block)) {
|
||||
EarthPassive.revertSand(block);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -941,6 +941,8 @@ public class ConfigManager {
|
|||
config.addDefault("Abilities.Water.WaterCombo.IceBullet.AnimationSpeed", 1);
|
||||
config.addDefault("Abilities.Water.WaterCombo.IceBullet.ShootTime", 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.DensityShift.Enabled", true);
|
||||
|
|
|
@ -414,7 +414,7 @@ public class HeatControl extends FireAbility {
|
|||
|
||||
@Override
|
||||
public boolean isHarmlessAbility() {
|
||||
return false;
|
||||
return this.heatControlType.equals(HeatControlType.COOK);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
@ -45,9 +46,11 @@ public class WaterSpoutWave extends WaterAbility {
|
|||
private boolean moving;
|
||||
private boolean plant;
|
||||
private boolean collidable;
|
||||
private boolean revertIceSphere;
|
||||
private int progressCounter;
|
||||
private long time;
|
||||
private long cooldown;
|
||||
private long revertSphereTime;
|
||||
private double selectRange;
|
||||
private double speed;
|
||||
private double chargeTime;
|
||||
|
@ -83,6 +86,8 @@ public class WaterSpoutWave extends WaterAbility {
|
|||
this.chargeTime = getConfig().getLong("Abilities.Water.WaterSpout.Wave.ChargeTime");
|
||||
this.flightTime = getConfig().getLong("Abilities.Water.WaterSpout.Wave.FlightTime");
|
||||
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.affectedEntities = new ArrayList<>();
|
||||
this.tasks = new ArrayList<>();
|
||||
|
@ -386,6 +391,9 @@ public class WaterSpoutWave extends WaterAbility {
|
|||
if (!FROZEN_BLOCKS.containsKey(block)) {
|
||||
TempBlock tblock = new TempBlock(block, Material.ICE, (byte) 1);
|
||||
FROZEN_BLOCKS.put(block, tblock);
|
||||
if (revertIceSphere) {
|
||||
tblock.setRevertTime(revertSphereTime + (new Random().nextInt(1000) - 500));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -433,6 +441,20 @@ public class WaterSpoutWave extends WaterAbility {
|
|||
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) {
|
||||
return FROZEN_BLOCKS.containsKey(block);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.projectkorra.projectkorra.GeneralMethods;
|
|||
import com.projectkorra.projectkorra.ability.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.IceAbility;
|
||||
import com.projectkorra.projectkorra.util.DamageHandler;
|
||||
import com.projectkorra.projectkorra.util.TempBlock;
|
||||
import com.projectkorra.projectkorra.util.TempPotionEffect;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
@ -18,15 +19,15 @@ import org.bukkit.potion.PotionEffectType;
|
|||
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;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class IceSpikePillar extends IceAbility {
|
||||
|
||||
private static final Map<Block, Block> ALREADY_DONE_BLOCKS = new ConcurrentHashMap<>();
|
||||
private static final Map<Block, Integer> BASE_BLOCKS = new ConcurrentHashMap<>();
|
||||
/**The list of blocks IceSpike uses*/
|
||||
private Map<Block, TempBlock> ice_blocks = new HashMap<Block, TempBlock>();
|
||||
|
||||
private int height;
|
||||
private int progress;
|
||||
|
@ -41,14 +42,14 @@ public class IceSpikePillar extends IceAbility {
|
|||
private double damage;
|
||||
private double range;
|
||||
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 location;
|
||||
private Vector thrownForce;
|
||||
private Vector direction;
|
||||
private ConcurrentHashMap<Block, Block> affectedBlocks;
|
||||
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) {
|
||||
super(player);
|
||||
|
@ -76,19 +77,17 @@ public class IceSpikePillar extends IceAbility {
|
|||
|
||||
if (closestEntity != null) {
|
||||
Block tempTestingBlock = closestEntity.getLocation().getBlock().getRelative(BlockFace.DOWN, 1);
|
||||
this.block = tempTestingBlock;
|
||||
this.source_block = tempTestingBlock;
|
||||
} 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();
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
loadAffectedBlocks();
|
||||
|
||||
if (height != 0) {
|
||||
if (canInstantiate()) {
|
||||
start();
|
||||
|
@ -108,11 +107,9 @@ public class IceSpikePillar extends IceAbility {
|
|||
this.damage = damage;
|
||||
this.thrownForce = throwing;
|
||||
this.location = origin.clone();
|
||||
this.block = location.getBlock();
|
||||
this.source_block = location.getBlock();
|
||||
|
||||
loadAffectedBlocks();
|
||||
|
||||
if (isIcebendable(block)) {
|
||||
if (isIcebendable(source_block)) {
|
||||
if (canInstantiate()) {
|
||||
start();
|
||||
time = System.currentTimeMillis() - interval;
|
||||
|
@ -131,46 +128,46 @@ public class IceSpikePillar extends IceAbility {
|
|||
this.cooldown = getConfig().getLong("Abilities.Water.IceSpike.Cooldown");
|
||||
this.height = getConfig().getInt("Abilities.Water.IceSpike.Height");
|
||||
this.thrownForce = new Vector(0, getConfig().getDouble("Abilities.Water.IceSpike.Push"), 0);
|
||||
this.affectedBlocks = new ConcurrentHashMap<>();
|
||||
this.damaged = new ArrayList<>();
|
||||
|
||||
this.interval = (long) (1000. / speed);
|
||||
}
|
||||
|
||||
private void loadAffectedBlocks() {
|
||||
affectedBlocks.clear();
|
||||
Block thisBlock;
|
||||
for (int i = 1; i <= height; i++) {
|
||||
thisBlock = block.getWorld().getBlockAt(location.clone().add(direction.clone().multiply(i)));
|
||||
affectedBlocks.put(thisBlock, thisBlock);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean blockInAffectedBlocks(Block block) {
|
||||
return affectedBlocks.containsKey(block);
|
||||
}
|
||||
|
||||
public static boolean blockInAllAffectedBlocks(Block block) {
|
||||
/**
|
||||
* Reverts the block if it's part of IceSpike
|
||||
* @param block The Block
|
||||
* @return If the block was removed or not
|
||||
*/
|
||||
public static boolean revertBlock(Block block) {
|
||||
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 false;
|
||||
}
|
||||
|
||||
public static void revertBlock(Block block) {
|
||||
for (IceSpikePillar iceSpike : getAbilities(IceSpikePillar.class)) {
|
||||
iceSpike.affectedBlocks.remove(block);
|
||||
}
|
||||
}
|
||||
|
||||
/**Checks to see if this move can start. Checks things like if there is enough space to form, if the source isn't
|
||||
* a TempBlock, etc.*/
|
||||
private boolean canInstantiate() {
|
||||
if (!isIcebendable(block.getType())) {
|
||||
if (!isIcebendable(source_block.getType())) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -185,9 +182,9 @@ public class IceSpikePillar extends IceAbility {
|
|||
risePillar();
|
||||
removeTimestamp = System.currentTimeMillis();
|
||||
} else {
|
||||
//If it's time to remove
|
||||
if (removeTimestamp != 0 && removeTimestamp + removeTimer <= System.currentTimeMillis()) {
|
||||
BASE_BLOCKS.put(location.clone().add(direction.clone().multiply(-1 * (height))).getBlock(), (height - 1));
|
||||
if (!revertblocks()) {
|
||||
if (!sinkPillar()) {
|
||||
remove();
|
||||
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() {
|
||||
progress++;
|
||||
Block affectedBlock = location.clone().add(direction).getBlock();
|
||||
|
@ -212,15 +213,13 @@ public class IceSpikePillar extends IceAbility {
|
|||
}
|
||||
}
|
||||
|
||||
affectedBlock.setType(Material.ICE);
|
||||
if (!inField || new Random().nextInt((int) ((height + 1) * 1.5)) == 0) {
|
||||
playIcebendingSound(block.getLocation());
|
||||
}
|
||||
loadAffectedBlocks();
|
||||
TempBlock b = new TempBlock(affectedBlock, Material.ICE, (byte)0);
|
||||
ice_blocks.put(affectedBlock, b);
|
||||
|
||||
if (location.distanceSquared(origin) >= height * height) {
|
||||
return false;
|
||||
if (!inField || new Random().nextInt((int) ((height + 1) * 1.5)) == 0) {
|
||||
playIcebendingSound(source_block.getLocation());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -242,24 +241,20 @@ public class IceSpikePillar extends IceAbility {
|
|||
AirAbility.breakBreathbendingHold(entity);
|
||||
}
|
||||
|
||||
public static boolean blockIsBase(Block block) {
|
||||
return block != null ? BASE_BLOCKS.containsKey(block) : null;
|
||||
}
|
||||
|
||||
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);
|
||||
/**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);
|
||||
|
||||
if (blockIsBase(location.getBlock())) {
|
||||
if (source_block == location.getBlock()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -384,11 +379,11 @@ public class IceSpikePillar extends IceAbility {
|
|||
}
|
||||
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
return source_block;
|
||||
}
|
||||
|
||||
public void setBlock(Block block) {
|
||||
this.block = block;
|
||||
this.source_block = block;
|
||||
}
|
||||
|
||||
public Location getOrigin() {
|
||||
|
@ -424,12 +419,12 @@ public class IceSpikePillar extends IceAbility {
|
|||
this.direction = direction;
|
||||
}
|
||||
|
||||
public static Map<Block, Block> getAlreadyDoneBlocks() {
|
||||
return ALREADY_DONE_BLOCKS;
|
||||
public Map<Block, TempBlock> getIceBlocks() {
|
||||
return ice_blocks;
|
||||
}
|
||||
|
||||
public static Map<Block, Integer> getBaseBlocks() {
|
||||
return BASE_BLOCKS;
|
||||
public Block getBaseBlock() {
|
||||
return base_block;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.projectkorra.projectkorra.waterbending.util;
|
|||
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.waterbending.Torrent;
|
||||
import com.projectkorra.projectkorra.waterbending.WaterSpoutWave;
|
||||
import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArms;
|
||||
|
||||
public class WaterbendingManager implements Runnable {
|
||||
|
@ -17,6 +18,7 @@ public class WaterbendingManager implements Runnable {
|
|||
//WaterPassive.handlePassive(); # Fast Swim is now managed in FastSwim.java
|
||||
Torrent.progressAllCleanup();
|
||||
WaterArms.progressAllCleanup();
|
||||
WaterSpoutWave.progressAllCleanup();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue