mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-11 11:40:40 +00:00
Format EarthSmash File
This commit is contained in:
parent
6bf6dd4868
commit
636add6e4b
1 changed files with 246 additions and 258 deletions
|
@ -116,19 +116,16 @@ public class EarthSmash {
|
|||
grabbedSmash.player = player;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(type == ClickType.LEFT_CLICK && player.isSneaking()) {
|
||||
} else if (type == ClickType.LEFT_CLICK && player.isSneaking()) {
|
||||
for (EarthSmash smash : instances) {
|
||||
if (smash.state == State.GRABBED && smash.player == player) {
|
||||
smash.state = State.SHOT;
|
||||
smash.destination = player.getEyeLocation().clone().add
|
||||
(player.getEyeLocation().getDirection().normalize().multiply(smash.shootRange));
|
||||
smash.destination = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().normalize().multiply(smash.shootRange));
|
||||
smash.loc.getWorld().playEffect(smash.loc, Effect.GHAST_SHOOT, 0, 10);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if(type == ClickType.RIGHT_CLICK && player.isSneaking()) {
|
||||
} else if (type == ClickType.RIGHT_CLICK && player.isSneaking()) {
|
||||
EarthSmash grabbedSmash = aimingAtSmashCheck(player, State.GRABBED);
|
||||
if (grabbedSmash != null) {
|
||||
player.teleport(grabbedSmash.loc.clone().add(0, 2, 0));
|
||||
|
@ -137,8 +134,7 @@ public class EarthSmash {
|
|||
grabbedSmash.flightStart = System.currentTimeMillis();
|
||||
}
|
||||
return;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
instances.add(this);
|
||||
|
@ -155,15 +151,13 @@ public class EarthSmash {
|
|||
remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(state == State.START) {
|
||||
} else if (state == State.START) {
|
||||
String ability = GeneralMethods.getBoundAbility(player);
|
||||
if (ability == null || !ability.equalsIgnoreCase("EarthSmash") || bplayer.isOnCooldown("EarthSmash")) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(state == State.START || state == State.FLYING || state == State.GRABBED) {
|
||||
} else if (state == State.START || state == State.FLYING || state == State.GRABBED) {
|
||||
if (!GeneralMethods.canBend(player.getName(), "EarthSmash")) {
|
||||
remove();
|
||||
return;
|
||||
|
@ -181,31 +175,25 @@ public class EarthSmash {
|
|||
bplayer.addCooldown("EarthSmash", cooldown);
|
||||
loc = origin.getLocation();
|
||||
state = State.LIFTING;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(System.currentTimeMillis() - time > chargeTime) {
|
||||
Location tempLoc = player.getEyeLocation().add(player.getEyeLocation()
|
||||
.getDirection().normalize().multiply(1.2));
|
||||
} else if (System.currentTimeMillis() - time > chargeTime) {
|
||||
Location tempLoc = player.getEyeLocation().add(player.getEyeLocation().getDirection().normalize().multiply(1.2));
|
||||
tempLoc.add(0, 0.3, 0);
|
||||
ParticleEffect.SMOKE.display(tempLoc, 0.3F, 0.1F, 0.3F, 0, 4);
|
||||
}
|
||||
}
|
||||
else if(state == State.LIFTING) {
|
||||
} else if (state == State.LIFTING) {
|
||||
if (System.currentTimeMillis() - delay >= LIFT_ANIMATION_COOLDOWN) {
|
||||
delay = System.currentTimeMillis();
|
||||
animateLift();
|
||||
}
|
||||
}
|
||||
else if(state == State.GRABBED) {
|
||||
} else if (state == State.GRABBED) {
|
||||
if (player.isSneaking()) {
|
||||
revert();
|
||||
Location oldLoc = loc.clone();
|
||||
loc = player.getEyeLocation().add(
|
||||
player.getEyeLocation().getDirection().normalize().multiply(grabbedRange));
|
||||
loc = player.getEyeLocation().add(player.getEyeLocation().getDirection().normalize().multiply(grabbedRange));
|
||||
|
||||
//Check to make sure the new location is available to move to
|
||||
for (Block block : getBlocks())
|
||||
|
@ -217,13 +205,11 @@ public class EarthSmash {
|
|||
AirMethods.removeAirSpouts(loc, 2, player);
|
||||
draw();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
state = State.LIFTED;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(state == State.SHOT) {
|
||||
} else if (state == State.SHOT) {
|
||||
if (System.currentTimeMillis() - delay >= SHOOTING_ANIMATION_COOLDOWN) {
|
||||
delay = System.currentTimeMillis();
|
||||
if (GeneralMethods.isRegionProtectedFromBuild(player, "EarthSmash", loc)) {
|
||||
|
@ -239,8 +225,7 @@ public class EarthSmash {
|
|||
// If an earthsmash runs into too many blocks we should remove it
|
||||
int badBlocksFound = 0;
|
||||
for (Block block : getBlocks())
|
||||
if(block.getType() != Material.AIR &&
|
||||
(!EarthMethods.isTransparentToEarthbending(player, block) || block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER))
|
||||
if (block.getType() != Material.AIR && (!EarthMethods.isTransparentToEarthbending(player, block) || block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER))
|
||||
badBlocksFound++;
|
||||
|
||||
if (badBlocksFound > MAX_BLOCKS_TO_PASS_THROUGH) {
|
||||
|
@ -254,22 +239,18 @@ public class EarthSmash {
|
|||
smashToSmashCollisionDetection();
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if(state == State.FLYING) {
|
||||
} else if (state == State.FLYING) {
|
||||
if (!player.isSneaking()) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
else if(System.currentTimeMillis() - delay >= FLYING_ANIMATION_COOLDOWN)
|
||||
{
|
||||
} else if (System.currentTimeMillis() - delay >= FLYING_ANIMATION_COOLDOWN) {
|
||||
delay = System.currentTimeMillis();
|
||||
if (GeneralMethods.isRegionProtectedFromBuild(player, "EarthSmash", loc)) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
revert();
|
||||
destination = player.getEyeLocation().clone().add
|
||||
(player.getEyeLocation().getDirection().normalize().multiply(shootRange));
|
||||
destination = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().normalize().multiply(shootRange));
|
||||
Vector direction = GeneralMethods.getDirection(loc, destination).normalize();
|
||||
|
||||
List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(loc.clone().add(0, 2, 0), FLIGHT_DETECTION_RADIUS);
|
||||
|
@ -297,13 +278,13 @@ public class EarthSmash {
|
|||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void animateLift()
|
||||
{
|
||||
public void animateLift() {
|
||||
/**
|
||||
* Begins animating the EarthSmash from the ground. The lift animation consists
|
||||
* of 3 steps, and each one has to design the shape in the ground that removes the
|
||||
* earthbendable material. We also need to make sure that there is a clear path for
|
||||
* the EarthSmash to rise, and that there is enough earthbendable material for it to be created.
|
||||
* Begins animating the EarthSmash from the ground. The lift animation
|
||||
* consists of 3 steps, and each one has to design the shape in the
|
||||
* ground that removes the earthbendable material. We also need to make
|
||||
* sure that there is a clear path for the EarthSmash to rise, and that
|
||||
* there is enough earthbendable material for it to be created.
|
||||
*/
|
||||
if (animCounter < 4) {
|
||||
revert();
|
||||
|
@ -361,8 +342,9 @@ public class EarthSmash {
|
|||
|
||||
}
|
||||
/*
|
||||
* We needed to calculate all of the blocks based on the location being 1 above the initial
|
||||
* bending block, however we want to animate it starting from the original bending block.
|
||||
* We needed to calculate all of the blocks based on the
|
||||
* location being 1 above the initial bending block, however we
|
||||
* want to animate it starting from the original bending block.
|
||||
* We must readjust the location back to what it originally was.
|
||||
*/
|
||||
loc.add(0, -1, 0);
|
||||
|
@ -376,8 +358,7 @@ public class EarthSmash {
|
|||
}
|
||||
loc.getWorld().playEffect(loc, Effect.GHAST_SHOOT, 0, 7);
|
||||
draw();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
state = State.LIFTED;
|
||||
}
|
||||
animCounter++;
|
||||
|
@ -414,20 +395,19 @@ public class EarthSmash {
|
|||
public void checkRemainingBlocks() {
|
||||
/**
|
||||
* Checks to see which of the blocks are still attached to the
|
||||
* EarthSmash, remember that blocks can be broken or used in other abilities
|
||||
* so we need to double check and remove any that are not still attached.
|
||||
* EarthSmash, remember that blocks can be broken or used in other
|
||||
* abilities so we need to double check and remove any that are not
|
||||
* still attached.
|
||||
*
|
||||
* Also when we remove the blocks from instances, movedearth, or tempair
|
||||
* we should do it on a delay because tempair takes a couple seconds before
|
||||
* the block shows up in that map.
|
||||
* we should do it on a delay because tempair takes a couple seconds
|
||||
* before the block shows up in that map.
|
||||
*/
|
||||
for (int i = 0; i < currentBlocks.size(); i++) {
|
||||
BlockRepresenter brep = currentBlocks.get(i);
|
||||
final Block block = loc.clone().add(brep.getX(), brep.getY(), brep.getZ()).getBlock();
|
||||
// Check for grass because sometimes the dirt turns into grass.
|
||||
if(block.getType() != brep.getType()
|
||||
&& (block.getType() != Material.GRASS)
|
||||
&& (block.getType() != Material.COBBLESTONE)) {
|
||||
if (block.getType() != brep.getType() && (block.getType() != Material.GRASS) && (block.getType() != Material.COBBLESTONE)) {
|
||||
currentBlocks.remove(i);
|
||||
i--;
|
||||
}
|
||||
|
@ -442,8 +422,9 @@ public class EarthSmash {
|
|||
|
||||
public List<Block> getBlocks() {
|
||||
/**
|
||||
* Gets the blocks surrounding the EarthSmash's loc.
|
||||
* This method ignores the blocks that should be Air, and only returns the ones that are dirt.
|
||||
* Gets the blocks surrounding the EarthSmash's loc. This method ignores
|
||||
* the blocks that should be Air, and only returns the ones that are
|
||||
* dirt.
|
||||
*/
|
||||
List<Block> blocks = new ArrayList<Block>();
|
||||
for (int x = -1; x <= 1; x++)
|
||||
|
@ -457,8 +438,8 @@ public class EarthSmash {
|
|||
|
||||
public List<Block> getBlocksIncludingInner() {
|
||||
/**
|
||||
* Gets the blocks surrounding the EarthSmash's loc.
|
||||
* This method returns all the blocks surrounding the loc, including dirt and air.
|
||||
* Gets the blocks surrounding the EarthSmash's loc. This method returns
|
||||
* all the blocks surrounding the loc, including dirt and air.
|
||||
*/
|
||||
List<Block> blocks = new ArrayList<Block>();
|
||||
for (int x = -1; x <= 1; x++)
|
||||
|
@ -471,12 +452,15 @@ public class EarthSmash {
|
|||
|
||||
public static Material selectMaterial(Material mat) {
|
||||
/**
|
||||
* Switches the Sand Material and Gravel to SandStone and stone respectively,
|
||||
* since gravel and sand cannot be bent due to gravity.
|
||||
* Switches the Sand Material and Gravel to SandStone and stone
|
||||
* respectively, since gravel and sand cannot be bent due to gravity.
|
||||
*/
|
||||
if(mat == Material.SAND) return Material.SANDSTONE;
|
||||
else if(mat == Material.GRAVEL) return Material.STONE;
|
||||
else return mat;
|
||||
if (mat == Material.SAND)
|
||||
return Material.SANDSTONE;
|
||||
else if (mat == Material.GRAVEL)
|
||||
return Material.STONE;
|
||||
else
|
||||
return mat;
|
||||
}
|
||||
|
||||
public Material selectMaterialForRepresenter(Material mat) {
|
||||
|
@ -493,8 +477,9 @@ public class EarthSmash {
|
|||
|
||||
private EarthSmash aimingAtSmashCheck(Player player, State reqState) {
|
||||
/**
|
||||
* Determines if a player is trying to grab an EarthSmash.
|
||||
* A player is trying to grab an EarthSmash if they are staring at it and holding shift.
|
||||
* Determines if a player is trying to grab an EarthSmash. A player is
|
||||
* trying to grab an EarthSmash if they are staring at it and holding
|
||||
* shift.
|
||||
*/
|
||||
if (!ALLOW_GRAB)
|
||||
return null;
|
||||
|
@ -503,8 +488,7 @@ public class EarthSmash {
|
|||
for (EarthSmash smash : instances) {
|
||||
if (reqState == null || smash.state == reqState)
|
||||
for (Block block : blocks)
|
||||
if(block.getLocation().getWorld() == smash.loc.getWorld() &&
|
||||
block.getLocation().distanceSquared(smash.loc) <= Math.pow(GRAB_DETECTION_RADIUS, 2))
|
||||
if (block.getLocation().getWorld() == smash.loc.getWorld() && block.getLocation().distanceSquared(smash.loc) <= Math.pow(GRAB_DETECTION_RADIUS, 2))
|
||||
return smash;
|
||||
}
|
||||
return null;
|
||||
|
@ -512,14 +496,13 @@ public class EarthSmash {
|
|||
|
||||
public void shootingCollisionDetection() {
|
||||
/**
|
||||
* This method handles any collision between an EarthSmash and the surrounding entities,
|
||||
* the method only applies to earthsmashes that have already been shot.
|
||||
* This method handles any collision between an EarthSmash and the
|
||||
* surrounding entities, the method only applies to earthsmashes that
|
||||
* have already been shot.
|
||||
*/
|
||||
List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(loc, FLIGHT_DETECTION_RADIUS);
|
||||
for (Entity entity : entities)
|
||||
if(entity instanceof LivingEntity
|
||||
&& entity != player
|
||||
&& !affectedEntities.contains(entity)) {
|
||||
if (entity instanceof LivingEntity && entity != player && !affectedEntities.contains(entity)) {
|
||||
affectedEntities.add(entity);
|
||||
double damage = currentBlocks.size() / 13 * this.damage;
|
||||
GeneralMethods.damageEntity(player, entity, damage);
|
||||
|
@ -527,11 +510,13 @@ public class EarthSmash {
|
|||
entity.setVelocity(travelVec.setY(knockup).normalize().multiply(knockback));
|
||||
}
|
||||
}
|
||||
|
||||
public void smashToSmashCollisionDetection() {
|
||||
/**
|
||||
* EarthSmash to EarthSmash collision can only happen when one of the Smashes have
|
||||
* been shot by a player. If we find out that one of them have collided then we want to return
|
||||
* since a smash can only remove 1 at a time.
|
||||
* EarthSmash to EarthSmash collision can only happen when one of the
|
||||
* Smashes have been shot by a player. If we find out that one of them
|
||||
* have collided then we want to return since a smash can only remove 1
|
||||
* at a time.
|
||||
*/
|
||||
for (int i = 0; i < instances.size(); i++) {
|
||||
EarthSmash smash = instances.get(i);
|
||||
|
@ -548,8 +533,9 @@ public class EarthSmash {
|
|||
|
||||
private static EarthSmash flyingInSmashCheck(Player player) {
|
||||
/**
|
||||
* Determines whether or not a player is trying to fly ontop of an EarthSmash.
|
||||
* A player is considered "flying" if they are standing ontop of the earthsmash and holding shift.
|
||||
* Determines whether or not a player is trying to fly ontop of an
|
||||
* EarthSmash. A player is considered "flying" if they are standing
|
||||
* ontop of the earthsmash and holding shift.
|
||||
*/
|
||||
if (!ALLOW_FLIGHT)
|
||||
return null;
|
||||
|
@ -557,8 +543,7 @@ public class EarthSmash {
|
|||
for (EarthSmash smash : instances) {
|
||||
//Check to see if the player is standing on top of the smash.
|
||||
if (smash.state == State.LIFTED) {
|
||||
if(smash.loc.getWorld().equals(player.getWorld())
|
||||
&& smash.loc.clone().add(0,2,0).distanceSquared(player.getLocation()) <= Math.pow(FLIGHT_DETECTION_RADIUS, 2)) {
|
||||
if (smash.loc.getWorld().equals(player.getWorld()) && smash.loc.clone().add(0, 2, 0).distanceSquared(player.getLocation()) <= Math.pow(FLIGHT_DETECTION_RADIUS, 2)) {
|
||||
return smash;
|
||||
}
|
||||
}
|
||||
|
@ -588,15 +573,17 @@ public class EarthSmash {
|
|||
|
||||
public class BlockRepresenter {
|
||||
/**
|
||||
* A BlockRepresenter is used to keep track of each of
|
||||
* the individual types of blocks that are attached to an EarthSmash.
|
||||
* Without the representer then an EarthSmash can only be made up of 1 material
|
||||
* at a time. For example, an ESmash that is entirely dirt, coalore, or sandstone.
|
||||
* Using the representer will allow all the materials to be mixed together.
|
||||
* A BlockRepresenter is used to keep track of each of the individual
|
||||
* types of blocks that are attached to an EarthSmash. Without the
|
||||
* representer then an EarthSmash can only be made up of 1 material at a
|
||||
* time. For example, an ESmash that is entirely dirt, coalore, or
|
||||
* sandstone. Using the representer will allow all the materials to be
|
||||
* mixed together.
|
||||
*/
|
||||
private int x, y, z;
|
||||
private Material type;
|
||||
private byte data;
|
||||
|
||||
public BlockRepresenter(int x, int y, int z, Material type, byte data) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
@ -604,6 +591,7 @@ public class EarthSmash {
|
|||
this.type = type;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue