mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-11 19:50:37 +00:00
Merge pull request #213 from nathank33/master
Efficiency Improvements, EarthSmash Fix, Fire Revert Fix
This commit is contained in:
commit
9102fd7fc2
5 changed files with 319 additions and 327 deletions
|
@ -21,16 +21,15 @@ public abstract class CoreAbility implements Ability {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ConcurrentHashMap that stores all Ability instances under UUID key. To
|
* ConcurrentHashMap that stores all Ability instances under UUID key. To
|
||||||
* access this hashmap use either {@link #getInstance()} from the ability
|
* access this HashMap use either {@link #getInstance()} from the ability
|
||||||
* instance or {@link #getInstance(StockAbility)} from the outside.
|
* instance or {@link #getInstance(StockAbility)} from the outside.
|
||||||
*/
|
*/
|
||||||
//private static ConcurrentHashMap<StockAbility, ConcurrentHashMap<UUID, CoreAbility>> instances = new ConcurrentHashMap<>();
|
private static final ConcurrentHashMap<Integer, CoreAbility> instances = new ConcurrentHashMap<>();
|
||||||
//private static ConcurrentHashMap<UUID, ConcurrentHashMap<Integer, CoreAbility>> instances = new ConcurrentHashMap<>();
|
private static final ConcurrentHashMap<StockAbility, ArrayList<Integer>> abilityMap = new ConcurrentHashMap<>();
|
||||||
private static ConcurrentHashMap<Integer, CoreAbility> instances = new ConcurrentHashMap<>();
|
private static final ConcurrentHashMap<Class<? extends CoreAbility>, ConcurrentHashMap<Integer, CoreAbility>> classAbilityMap = new ConcurrentHashMap<>();
|
||||||
//protected static AbilityMap<Ability> instances = new AbilityMap<>();
|
|
||||||
private static ConcurrentHashMap<StockAbility, ArrayList<Integer>> abilityMap = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
private static int ID = Integer.MIN_VALUE;
|
private static int ID = Integer.MIN_VALUE;
|
||||||
|
|
||||||
private final StockAbility stockAbility = getStockAbility();
|
private final StockAbility stockAbility = getStockAbility();
|
||||||
private Player player;
|
private Player player;
|
||||||
private UUID uniqueId;
|
private UUID uniqueId;
|
||||||
|
@ -45,20 +44,7 @@ public abstract class CoreAbility implements Ability {
|
||||||
*/
|
*/
|
||||||
public static final boolean containsPlayer(Player player, Class<? extends CoreAbility> ability) {
|
public static final boolean containsPlayer(Player player, Class<? extends CoreAbility> ability) {
|
||||||
CoreAbility coreAbility = getAbilityFromPlayer(player, ability);
|
CoreAbility coreAbility = getAbilityFromPlayer(player, ability);
|
||||||
if (coreAbility != null) {
|
return coreAbility != null ? true : false;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
List<CoreAbility> abilities = getAbilitiesFromPlayer(player);
|
|
||||||
for (CoreAbility coreAbility : abilities) {
|
|
||||||
if (ability.isInstance(coreAbility)) {
|
|
||||||
if (coreAbility.getPlayer().getUniqueId().equals(player.getUniqueId())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,8 +94,8 @@ public abstract class CoreAbility implements Ability {
|
||||||
/**
|
/**
|
||||||
* An access method to get an the instances of a {@link StockAbility}.
|
* An access method to get an the instances of a {@link StockAbility}.
|
||||||
* <b>IMPORTANT: </b> If this is used in a for each loop use
|
* <b>IMPORTANT: </b> If this is used in a for each loop use
|
||||||
* {@link #getAbility(int)} to get the ability. Incorrect usage may
|
* {@link #getAbility(int)} to get the ability. Incorrect usage may cause
|
||||||
* cause over looping and is capable of hanging the thead.
|
* over looping and is capable of hanging the thead.
|
||||||
*
|
*
|
||||||
* @param ability The instances map to get
|
* @param ability The instances map to get
|
||||||
* @return a map of instances from the specified {@link StockAbility}
|
* @return a map of instances from the specified {@link StockAbility}
|
||||||
|
@ -128,21 +114,16 @@ public abstract class CoreAbility implements Ability {
|
||||||
/**
|
/**
|
||||||
* An access method to get an the instances of a {@link CoreAbility} by its
|
* An access method to get an the instances of a {@link CoreAbility} by its
|
||||||
* class. <b>IMPORTANT: </b> If this is used in a for each loop use
|
* class. <b>IMPORTANT: </b> If this is used in a for each loop use
|
||||||
* {@link #getAbility(int)} to get the ability. Incorrect usage may
|
* {@link #getAbility(int)} to get the ability. Incorrect usage may cause
|
||||||
* cause over looping and is capable of hanging the thead.
|
* over looping and is capable of hanging the thead.
|
||||||
*
|
*
|
||||||
* @param ability The instances map to get
|
* @param ability The instances map to get
|
||||||
* @return a map of instances from the specified class
|
* @return a map of instances from the specified class
|
||||||
* @see #getInstances(StockAbility)
|
* @see #getInstances(StockAbility)
|
||||||
*/
|
*/
|
||||||
public final static ConcurrentHashMap<Integer, CoreAbility> getInstances(Class<? extends CoreAbility> ability) {
|
public final static ConcurrentHashMap<Integer, CoreAbility> getInstances(Class<? extends CoreAbility> ability) {
|
||||||
ConcurrentHashMap<Integer, CoreAbility> instanceMap = new ConcurrentHashMap<>();
|
ConcurrentHashMap<Integer, CoreAbility> instanceMap = classAbilityMap.get(ability.getClass());
|
||||||
for (Integer id : instances.keySet()) {
|
return instanceMap != null ? instanceMap : new ConcurrentHashMap<Integer, CoreAbility>();
|
||||||
if (ability.isInstance(instances.get(id))) {
|
|
||||||
instanceMap.put(id, instances.get(id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return instanceMap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Update bending managers to use bellow method
|
//TODO: Update bending managers to use bellow method
|
||||||
|
@ -165,9 +146,10 @@ public abstract class CoreAbility implements Ability {
|
||||||
* @see #progressAll(StockAbility)
|
* @see #progressAll(StockAbility)
|
||||||
*/
|
*/
|
||||||
public static void progressAll(Class<? extends CoreAbility> ability) {
|
public static void progressAll(Class<? extends CoreAbility> ability) {
|
||||||
for (Integer id : instances.keySet()) {
|
ConcurrentHashMap<Integer, CoreAbility> classAbilities = classAbilityMap.get(ability);
|
||||||
if (ability.isInstance(instances.get(id))) {
|
if (classAbilities != null) {
|
||||||
instances.get(id).progress();
|
for (Integer id : classAbilities.keySet()) {
|
||||||
|
classAbilities.get(id).progress();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,10 +211,7 @@ public abstract class CoreAbility implements Ability {
|
||||||
* @return true if ability is a stock ability
|
* @return true if ability is a stock ability
|
||||||
*/
|
*/
|
||||||
public boolean isStockAbility() {
|
public boolean isStockAbility() {
|
||||||
if (getStockAbility() == null) {
|
return getStockAbility() != null ? true : false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -298,7 +277,14 @@ public abstract class CoreAbility implements Ability {
|
||||||
this.id = ID;
|
this.id = ID;
|
||||||
this.uniqueId = player.getUniqueId();
|
this.uniqueId = player.getUniqueId();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
Class<? extends CoreAbility> classKey = ability.getClass();
|
||||||
|
|
||||||
|
if (!classAbilityMap.containsKey(classKey)) {
|
||||||
|
classAbilityMap.put(classKey, new ConcurrentHashMap<Integer, CoreAbility>());
|
||||||
|
}
|
||||||
|
classAbilityMap.get(classKey).put(id, ability);
|
||||||
instances.put(id, ability);
|
instances.put(id, ability);
|
||||||
|
|
||||||
if (stockAbility != null) {
|
if (stockAbility != null) {
|
||||||
if (abilityMap.containsKey(stockAbility)) {
|
if (abilityMap.containsKey(stockAbility)) {
|
||||||
abilityMap.get(stockAbility).add(id);
|
abilityMap.get(stockAbility).add(id);
|
||||||
|
@ -306,6 +292,7 @@ public abstract class CoreAbility implements Ability {
|
||||||
abilityMap.put(stockAbility, new ArrayList<Integer>(Arrays.asList(id)));
|
abilityMap.put(stockAbility, new ArrayList<Integer>(Arrays.asList(id)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ID == Integer.MAX_VALUE)
|
if (ID == Integer.MAX_VALUE)
|
||||||
ID = Integer.MIN_VALUE;
|
ID = Integer.MIN_VALUE;
|
||||||
ID++;
|
ID++;
|
||||||
|
@ -329,6 +316,11 @@ public abstract class CoreAbility implements Ability {
|
||||||
if (instances.containsKey(id)) {
|
if (instances.containsKey(id)) {
|
||||||
instances.remove(id);
|
instances.remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (classAbilityMap.containsKey(this.getClass())) {
|
||||||
|
classAbilityMap.get(this.getClass()).remove(id);
|
||||||
|
}
|
||||||
|
|
||||||
if (stockAbility != null) {
|
if (stockAbility != null) {
|
||||||
if (abilityMap.containsKey(stockAbility)) {
|
if (abilityMap.containsKey(stockAbility)) {
|
||||||
abilityMap.get(stockAbility).remove(id);
|
abilityMap.get(stockAbility).remove(id);
|
||||||
|
|
|
@ -123,11 +123,16 @@ public class ComboManager {
|
||||||
descriptions.put("IceWave", "PhaseChange your WaterWave into an IceWave that freezes and damages enemies.");
|
descriptions.put("IceWave", "PhaseChange your WaterWave into an IceWave that freezes and damages enemies.");
|
||||||
instructions.put("IceWave", "Create a WaterSpout Wave > PhaseChange (Left Click)");
|
instructions.put("IceWave", "Create a WaterSpout Wave > PhaseChange (Left Click)");
|
||||||
|
|
||||||
/*ArrayList<AbilityInformation> icePillar = new ArrayList<AbilityInformation>();
|
/*
|
||||||
icePillar.add(new AbilityInformation("IceSpike", ClickType.LEFT_CLICK));
|
* ArrayList<AbilityInformation> icePillar = new
|
||||||
icePillar.add(new AbilityInformation("IceSpike", ClickType.LEFT_CLICK));
|
* ArrayList<AbilityInformation>(); icePillar.add(new
|
||||||
icePillar.add(new AbilityInformation("WaterSpout", ClickType.LEFT_CLICK));
|
* AbilityInformation("IceSpike", ClickType.LEFT_CLICK));
|
||||||
comboAbilityList.add(new ComboAbility("IcePillar", icePillar, WaterCombo.class));*/
|
* icePillar.add(new AbilityInformation("IceSpike",
|
||||||
|
* ClickType.LEFT_CLICK)); icePillar.add(new
|
||||||
|
* AbilityInformation("WaterSpout", ClickType.LEFT_CLICK));
|
||||||
|
* comboAbilityList.add(new ComboAbility("IcePillar", icePillar,
|
||||||
|
* WaterCombo.class));
|
||||||
|
*/
|
||||||
|
|
||||||
ArrayList<AbilityInformation> iceBullet = new ArrayList<AbilityInformation>();
|
ArrayList<AbilityInformation> iceBullet = new ArrayList<AbilityInformation>();
|
||||||
iceBullet.add(new AbilityInformation("WaterBubble", ClickType.SHIFT_DOWN));
|
iceBullet.add(new AbilityInformation("WaterBubble", ClickType.SHIFT_DOWN));
|
||||||
|
@ -219,18 +224,18 @@ public class ComboManager {
|
||||||
Enumeration<String> keys = recentlyUsedAbilities.keys();
|
Enumeration<String> keys = recentlyUsedAbilities.keys();
|
||||||
while (keys.hasMoreElements()) {
|
while (keys.hasMoreElements()) {
|
||||||
String name = keys.nextElement();
|
String name = keys.nextElement();
|
||||||
ArrayList<AbilityInformation> combos = recentlyUsedAbilities.get(name);
|
ArrayList<AbilityInformation> usedAbilities = recentlyUsedAbilities.get(name);
|
||||||
|
ArrayList<AbilityInformation> stillValidAbilities = new ArrayList<AbilityInformation>();
|
||||||
recentlyUsedAbilities.remove(name);
|
recentlyUsedAbilities.remove(name);
|
||||||
for (int i = 0; i < combos.size(); i++) {
|
|
||||||
AbilityInformation info = combos.get(i);
|
for (AbilityInformation info : usedAbilities) {
|
||||||
if (System.currentTimeMillis() - info.getTime() > CLEANUP_DELAY) {
|
if (System.currentTimeMillis() - info.getTime() <= CLEANUP_DELAY) {
|
||||||
combos.remove(i);
|
stillValidAbilities.add(info);
|
||||||
i--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (combos.size() > 0)
|
if (stillValidAbilities.size() > 0)
|
||||||
recentlyUsedAbilities.put(name, combos);
|
recentlyUsedAbilities.put(name, stillValidAbilities);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +257,8 @@ public class ComboManager {
|
||||||
public static ArrayList<String> getCombosForElement(Element element) {
|
public static ArrayList<String> getCombosForElement(Element element) {
|
||||||
ArrayList<String> list = new ArrayList<String>();
|
ArrayList<String> list = new ArrayList<String>();
|
||||||
for (ComboAbility comboab : comboAbilityList) {
|
for (ComboAbility comboab : comboAbilityList) {
|
||||||
if (GeneralMethods.getComboElement(comboab.getName()) == element && descriptions.containsKey(comboab.getName())) list.add(comboab.getName());
|
if (GeneralMethods.getComboElement(comboab.getName()) == element && descriptions.containsKey(comboab.getName()))
|
||||||
|
list.add(comboab.getName());
|
||||||
}
|
}
|
||||||
Collections.sort(list);
|
Collections.sort(list);
|
||||||
return list;
|
return list;
|
||||||
|
@ -263,7 +269,7 @@ public class ComboManager {
|
||||||
public void run() {
|
public void run() {
|
||||||
cleanupOldCombos();
|
cleanupOldCombos();
|
||||||
}
|
}
|
||||||
}.runTaskTimer(ProjectKorra.plugin, 0, CLEANUP_DELAY);
|
}.runTaskTimer(ProjectKorra.plugin, 0, CLEANUP_DELAY / 1000 * 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AbilityInformation {
|
public static class AbilityInformation {
|
||||||
|
|
|
@ -66,14 +66,14 @@ public class EarthSmash {
|
||||||
private ArrayList<TempBlock> affectedBlocks = new ArrayList<TempBlock>();
|
private ArrayList<TempBlock> affectedBlocks = new ArrayList<TempBlock>();
|
||||||
|
|
||||||
public EarthSmash(Player player, ClickType type) {
|
public EarthSmash(Player player, ClickType type) {
|
||||||
if(!GeneralMethods.hasPermission(player, "EarthSmash"))
|
if (!GeneralMethods.hasPermission(player, "EarthSmash"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.player = player;
|
this.player = player;
|
||||||
bplayer = GeneralMethods.getBendingPlayer(player.getName());
|
bplayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||||
this.time = System.currentTimeMillis();
|
this.time = System.currentTimeMillis();
|
||||||
|
|
||||||
if(type == ClickType.SHIFT_DOWN || type == ClickType.SHIFT_UP && !player.isSneaking()) {
|
if (type == ClickType.SHIFT_DOWN || type == ClickType.SHIFT_UP && !player.isSneaking()) {
|
||||||
grabRange = GRAB_RANGE;
|
grabRange = GRAB_RANGE;
|
||||||
chargeTime = CHARGE_TIME;
|
chargeTime = CHARGE_TIME;
|
||||||
cooldown = MAIN_COOLDOWN;
|
cooldown = MAIN_COOLDOWN;
|
||||||
|
@ -83,9 +83,9 @@ public class EarthSmash {
|
||||||
flySpeed = FLYING_PLAYER_SPEED;
|
flySpeed = FLYING_PLAYER_SPEED;
|
||||||
flightRemove = FLYING_REMOVE_TIMER;
|
flightRemove = FLYING_REMOVE_TIMER;
|
||||||
shootRange = TRAVEL_RANGE;
|
shootRange = TRAVEL_RANGE;
|
||||||
if(AvatarState.isAvatarState(player)) {
|
if (AvatarState.isAvatarState(player)) {
|
||||||
grabRange = AvatarState.getValue(grabRange);
|
grabRange = AvatarState.getValue(grabRange);
|
||||||
chargeTime = AvatarState.getValue(chargeTime);
|
chargeTime = 0;
|
||||||
cooldown = 0;
|
cooldown = 0;
|
||||||
damage = AvatarState.getValue(damage);
|
damage = AvatarState.getValue(damage);
|
||||||
knockback = AvatarState.getValue(knockback);
|
knockback = AvatarState.getValue(knockback);
|
||||||
|
@ -96,7 +96,7 @@ public class EarthSmash {
|
||||||
}
|
}
|
||||||
|
|
||||||
EarthSmash flySmash = flyingInSmashCheck(player);
|
EarthSmash flySmash = flyingInSmashCheck(player);
|
||||||
if(flySmash != null) {
|
if (flySmash != null) {
|
||||||
flySmash.state = State.FLYING;
|
flySmash.state = State.FLYING;
|
||||||
flySmash.player = player;
|
flySmash.player = player;
|
||||||
flySmash.flightStart = System.currentTimeMillis();
|
flySmash.flightStart = System.currentTimeMillis();
|
||||||
|
@ -110,35 +110,31 @@ public class EarthSmash {
|
||||||
}
|
}
|
||||||
grabbedSmash = aimingAtSmashCheck(player, State.SHOT);
|
grabbedSmash = aimingAtSmashCheck(player, State.SHOT);
|
||||||
}
|
}
|
||||||
if(grabbedSmash != null) {
|
if (grabbedSmash != null) {
|
||||||
grabbedSmash.state = State.GRABBED;
|
grabbedSmash.state = State.GRABBED;
|
||||||
grabbedSmash.grabbedRange = grabbedSmash.loc.distance(player.getEyeLocation());
|
grabbedSmash.grabbedRange = grabbedSmash.loc.distance(player.getEyeLocation());
|
||||||
grabbedSmash.player = player;
|
grabbedSmash.player = player;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else if (type == ClickType.LEFT_CLICK && player.isSneaking()) {
|
||||||
else if(type == ClickType.LEFT_CLICK && player.isSneaking()) {
|
for (EarthSmash smash : instances) {
|
||||||
for(EarthSmash smash : instances) {
|
if (smash.state == State.GRABBED && smash.player == player) {
|
||||||
if(smash.state == State.GRABBED && smash.player == player) {
|
|
||||||
smash.state = State.SHOT;
|
smash.state = State.SHOT;
|
||||||
smash.destination = player.getEyeLocation().clone().add
|
smash.destination = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().normalize().multiply(smash.shootRange));
|
||||||
(player.getEyeLocation().getDirection().normalize().multiply(smash.shootRange));
|
|
||||||
smash.loc.getWorld().playEffect(smash.loc, Effect.GHAST_SHOOT, 0, 10);
|
smash.loc.getWorld().playEffect(smash.loc, Effect.GHAST_SHOOT, 0, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
} else if (type == ClickType.RIGHT_CLICK && player.isSneaking()) {
|
||||||
else if(type == ClickType.RIGHT_CLICK && player.isSneaking()) {
|
|
||||||
EarthSmash grabbedSmash = aimingAtSmashCheck(player, State.GRABBED);
|
EarthSmash grabbedSmash = aimingAtSmashCheck(player, State.GRABBED);
|
||||||
if(grabbedSmash != null) {
|
if (grabbedSmash != null) {
|
||||||
player.teleport(grabbedSmash.loc.clone().add(0, 2, 0));
|
player.teleport(grabbedSmash.loc.clone().add(0, 2, 0));
|
||||||
grabbedSmash.state = State.FLYING;
|
grabbedSmash.state = State.FLYING;
|
||||||
grabbedSmash.player = player;
|
grabbedSmash.player = player;
|
||||||
grabbedSmash.flightStart = System.currentTimeMillis();
|
grabbedSmash.flightStart = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
instances.add(this);
|
instances.add(this);
|
||||||
|
@ -146,70 +142,62 @@ public class EarthSmash {
|
||||||
|
|
||||||
public void progress() {
|
public void progress() {
|
||||||
progressCounter++;
|
progressCounter++;
|
||||||
if(state == State.LIFTED && REMOVE_TIMER > 0 && System.currentTimeMillis() - time > REMOVE_TIMER) {
|
if (state == State.LIFTED && REMOVE_TIMER > 0 && System.currentTimeMillis() - time > REMOVE_TIMER) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(state == State.START || state == State.FLYING || state == State.GRABBED) {
|
if (state == State.START || state == State.FLYING || state == State.GRABBED) {
|
||||||
if(player.isDead() || !player.isOnline()) {
|
if (player.isDead() || !player.isOnline()) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else if (state == State.START) {
|
||||||
else if(state == State.START) {
|
|
||||||
String ability = GeneralMethods.getBoundAbility(player);
|
String ability = GeneralMethods.getBoundAbility(player);
|
||||||
if(ability == null || !ability.equalsIgnoreCase("EarthSmash") || bplayer.isOnCooldown("EarthSmash")) {
|
if (ability == null || !ability.equalsIgnoreCase("EarthSmash") || bplayer.isOnCooldown("EarthSmash")) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
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")) {
|
||||||
if(!GeneralMethods.canBend(player.getName(), "EarthSmash")) {
|
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(state == State.START && progressCounter > 1) {
|
if (state == State.START && progressCounter > 1) {
|
||||||
if(!player.isSneaking()) {
|
if (!player.isSneaking()) {
|
||||||
if(System.currentTimeMillis() - time > chargeTime) {
|
if (System.currentTimeMillis() - time > chargeTime) {
|
||||||
origin = EarthMethods.getEarthSourceBlock(player, grabRange);
|
origin = EarthMethods.getEarthSourceBlock(player, grabRange);
|
||||||
if(origin == null){
|
if (origin == null) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bplayer.addCooldown("EarthSmash", cooldown);
|
bplayer.addCooldown("EarthSmash", cooldown);
|
||||||
loc = origin.getLocation();
|
loc = origin.getLocation();
|
||||||
state = State.LIFTING;
|
state = State.LIFTING;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else if (System.currentTimeMillis() - time > chargeTime) {
|
||||||
else if(System.currentTimeMillis() - time > chargeTime) {
|
Location tempLoc = player.getEyeLocation().add(player.getEyeLocation().getDirection().normalize().multiply(1.2));
|
||||||
Location tempLoc = player.getEyeLocation().add(player.getEyeLocation()
|
|
||||||
.getDirection().normalize().multiply(1.2));
|
|
||||||
tempLoc.add(0, 0.3, 0);
|
tempLoc.add(0, 0.3, 0);
|
||||||
ParticleEffect.SMOKE.display(tempLoc, 0.3F, 0.1F, 0.3F, 0, 4);
|
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) {
|
||||||
if(System.currentTimeMillis() - delay >= LIFT_ANIMATION_COOLDOWN) {
|
|
||||||
delay = System.currentTimeMillis();
|
delay = System.currentTimeMillis();
|
||||||
animateLift();
|
animateLift();
|
||||||
}
|
}
|
||||||
}
|
} else if (state == State.GRABBED) {
|
||||||
else if(state == State.GRABBED) {
|
if (player.isSneaking()) {
|
||||||
if(player.isSneaking()) {
|
|
||||||
revert();
|
revert();
|
||||||
Location oldLoc = loc.clone();
|
Location oldLoc = loc.clone();
|
||||||
loc = player.getEyeLocation().add(
|
loc = player.getEyeLocation().add(player.getEyeLocation().getDirection().normalize().multiply(grabbedRange));
|
||||||
player.getEyeLocation().getDirection().normalize().multiply(grabbedRange));
|
|
||||||
|
|
||||||
//Check to make sure the new location is available to move to
|
//Check to make sure the new location is available to move to
|
||||||
for(Block block : getBlocks())
|
for (Block block : getBlocks())
|
||||||
if(block.getType() != Material.AIR && !EarthMethods.isTransparentToEarthbending(player, block)) {
|
if (block.getType() != Material.AIR && !EarthMethods.isTransparentToEarthbending(player, block)) {
|
||||||
loc = oldLoc;
|
loc = oldLoc;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -217,33 +205,30 @@ public class EarthSmash {
|
||||||
AirMethods.removeAirSpouts(loc, 2, player);
|
AirMethods.removeAirSpouts(loc, 2, player);
|
||||||
draw();
|
draw();
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
state = State.LIFTED;
|
state = State.LIFTED;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else if (state == State.SHOT) {
|
||||||
else if(state == State.SHOT) {
|
if (System.currentTimeMillis() - delay >= SHOOTING_ANIMATION_COOLDOWN) {
|
||||||
if(System.currentTimeMillis() - delay >= SHOOTING_ANIMATION_COOLDOWN) {
|
|
||||||
delay = System.currentTimeMillis();
|
delay = System.currentTimeMillis();
|
||||||
if(GeneralMethods.isRegionProtectedFromBuild(player, "EarthSmash", loc)) {
|
if (GeneralMethods.isRegionProtectedFromBuild(player, "EarthSmash", loc)) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
revert();
|
revert();
|
||||||
loc.add(GeneralMethods.getDirection(loc, destination).normalize().multiply(1));
|
loc.add(GeneralMethods.getDirection(loc, destination).normalize().multiply(1));
|
||||||
if(loc.distanceSquared(destination) < 4) {
|
if (loc.distanceSquared(destination) < 4) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If an earthsmash runs into too many blocks we should remove it
|
// If an earthsmash runs into too many blocks we should remove it
|
||||||
int badBlocksFound = 0;
|
int badBlocksFound = 0;
|
||||||
for(Block block : getBlocks())
|
for (Block block : getBlocks())
|
||||||
if(block.getType() != Material.AIR &&
|
if (block.getType() != Material.AIR && (!EarthMethods.isTransparentToEarthbending(player, block) || block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER))
|
||||||
(!EarthMethods.isTransparentToEarthbending(player, block) || block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER))
|
|
||||||
badBlocksFound++;
|
badBlocksFound++;
|
||||||
|
|
||||||
if(badBlocksFound > MAX_BLOCKS_TO_PASS_THROUGH) {
|
if (badBlocksFound > MAX_BLOCKS_TO_PASS_THROUGH) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -254,42 +239,38 @@ public class EarthSmash {
|
||||||
smashToSmashCollisionDetection();
|
smashToSmashCollisionDetection();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
} else if (state == State.FLYING) {
|
||||||
else if(state == State.FLYING) {
|
if (!player.isSneaking()) {
|
||||||
if(!player.isSneaking()){
|
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
} else if (System.currentTimeMillis() - delay >= FLYING_ANIMATION_COOLDOWN) {
|
||||||
else if(System.currentTimeMillis() - delay >= FLYING_ANIMATION_COOLDOWN)
|
|
||||||
{
|
|
||||||
delay = System.currentTimeMillis();
|
delay = System.currentTimeMillis();
|
||||||
if(GeneralMethods.isRegionProtectedFromBuild(player, "EarthSmash", loc)) {
|
if (GeneralMethods.isRegionProtectedFromBuild(player, "EarthSmash", loc)) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
revert();
|
revert();
|
||||||
destination = player.getEyeLocation().clone().add
|
destination = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().normalize().multiply(shootRange));
|
||||||
(player.getEyeLocation().getDirection().normalize().multiply(shootRange));
|
|
||||||
Vector direction = GeneralMethods.getDirection(loc, destination).normalize();
|
Vector direction = GeneralMethods.getDirection(loc, destination).normalize();
|
||||||
|
|
||||||
List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(loc.clone().add(0,2,0), FLIGHT_DETECTION_RADIUS);
|
List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(loc.clone().add(0, 2, 0), FLIGHT_DETECTION_RADIUS);
|
||||||
if(entities.size() == 0){
|
if (entities.size() == 0) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(Entity entity : entities)
|
for (Entity entity : entities)
|
||||||
entity.setVelocity(direction.clone().multiply(flySpeed));
|
entity.setVelocity(direction.clone().multiply(flySpeed));
|
||||||
|
|
||||||
//These values tend to work well when dealing with a person aiming upward or downward.
|
//These values tend to work well when dealing with a person aiming upward or downward.
|
||||||
if(direction.getY() < -0.35)
|
if (direction.getY() < -0.35)
|
||||||
loc = player.getLocation().clone().add(0,-3.2,0);
|
loc = player.getLocation().clone().add(0, -3.2, 0);
|
||||||
else if(direction.getY() > 0.35)
|
else if (direction.getY() > 0.35)
|
||||||
loc = player.getLocation().clone().add(0,-1.7,0);
|
loc = player.getLocation().clone().add(0, -1.7, 0);
|
||||||
else
|
else
|
||||||
loc = player.getLocation().clone().add(0,-2.2,0);
|
loc = player.getLocation().clone().add(0, -2.2, 0);
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
if(System.currentTimeMillis() - flightStart > flightRemove){
|
if (System.currentTimeMillis() - flightStart > flightRemove) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -297,87 +278,87 @@ public class EarthSmash {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void animateLift()
|
public void animateLift() {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Begins animating the EarthSmash from the ground. The lift animation consists
|
* Begins animating the EarthSmash from the ground. The lift animation
|
||||||
* of 3 steps, and each one has to design the shape in the ground that removes the
|
* consists of 3 steps, and each one has to design the shape in the
|
||||||
* earthbendable material. We also need to make sure that there is a clear path for
|
* ground that removes the earthbendable material. We also need to make
|
||||||
* the EarthSmash to rise, and that there is enough earthbendable material for it to be created.
|
* 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) {
|
if (animCounter < 4) {
|
||||||
revert();
|
revert();
|
||||||
loc.add(0,1,0);
|
loc.add(0, 1, 0);
|
||||||
//Remove the blocks underneath the rising smash
|
//Remove the blocks underneath the rising smash
|
||||||
if(animCounter == 0) {
|
if (animCounter == 0) {
|
||||||
//Check all of the blocks and make sure that they can be removed AND make sure there is enough dirt
|
//Check all of the blocks and make sure that they can be removed AND make sure there is enough dirt
|
||||||
int totalBendableBlocks = 0;
|
int totalBendableBlocks = 0;
|
||||||
for(int x = -1; x <= 1; x++)
|
for (int x = -1; x <= 1; x++)
|
||||||
for(int y = -2; y <= -1; y++)
|
for (int y = -2; y <= -1; y++)
|
||||||
for(int z = -1; z <= 1; z++) {
|
for (int z = -1; z <= 1; z++) {
|
||||||
Block block = loc.clone().add(x,y,z).getBlock();
|
Block block = loc.clone().add(x, y, z).getBlock();
|
||||||
if(GeneralMethods.isRegionProtectedFromBuild(player, "EarthSmash", block.getLocation())) {
|
if (GeneralMethods.isRegionProtectedFromBuild(player, "EarthSmash", block.getLocation())) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(isEarthbendableMaterial(block.getType()))
|
if (isEarthbendableMaterial(block.getType()))
|
||||||
totalBendableBlocks++;
|
totalBendableBlocks++;
|
||||||
}
|
}
|
||||||
if(totalBendableBlocks < REQUIRED_BENDABLE_BLOCKS) {
|
if (totalBendableBlocks < REQUIRED_BENDABLE_BLOCKS) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Make sure there is a clear path upward otherwise remove
|
//Make sure there is a clear path upward otherwise remove
|
||||||
for(int y = 0; y <= 3; y++) {
|
for (int y = 0; y <= 3; y++) {
|
||||||
Block tempBlock = loc.clone().add(0,y,0).getBlock();
|
Block tempBlock = loc.clone().add(0, y, 0).getBlock();
|
||||||
if(!EarthMethods.isTransparentToEarthbending(player, tempBlock) && tempBlock.getType() != Material.AIR) {
|
if (!EarthMethods.isTransparentToEarthbending(player, tempBlock) && tempBlock.getType() != Material.AIR) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Design what this EarthSmash looks like by using BlockRepresenters
|
//Design what this EarthSmash looks like by using BlockRepresenters
|
||||||
Location tempLoc = loc.clone().add(0,-2,0);
|
Location tempLoc = loc.clone().add(0, -2, 0);
|
||||||
for(int x = -1; x <= 1; x++)
|
for (int x = -1; x <= 1; x++)
|
||||||
for(int y = -1; y <= 1; y++)
|
for (int y = -1; y <= 1; y++)
|
||||||
for(int z = -1; z <= 1; z++)
|
for (int z = -1; z <= 1; z++)
|
||||||
if((Math.abs(x) + Math.abs(y) + Math.abs(z)) % 2 == 0) {
|
if ((Math.abs(x) + Math.abs(y) + Math.abs(z)) % 2 == 0) {
|
||||||
Block block = tempLoc.clone().add(x,y,z).getBlock();
|
Block block = tempLoc.clone().add(x, y, z).getBlock();
|
||||||
currentBlocks.add(new BlockRepresenter(x, y, z, selectMaterialForRepresenter(block.getType()), block.getData()));
|
currentBlocks.add(new BlockRepresenter(x, y, z, selectMaterialForRepresenter(block.getType()), block.getData()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Remove the design of the second level of removed dirt
|
//Remove the design of the second level of removed dirt
|
||||||
for(int x = -1; x <= 1; x++)
|
for (int x = -1; x <= 1; x++)
|
||||||
for(int z = -1; z <= 1; z++) {
|
for (int z = -1; z <= 1; z++) {
|
||||||
if((Math.abs(x) + Math.abs(z)) % 2 == 1) {
|
if ((Math.abs(x) + Math.abs(z)) % 2 == 1) {
|
||||||
Block block = loc.clone().add(x,-2,z).getBlock();
|
Block block = loc.clone().add(x, -2, z).getBlock();
|
||||||
if(isEarthbendableMaterial(block.getType()))
|
if (isEarthbendableMaterial(block.getType()))
|
||||||
EarthMethods.addTempAirBlock(block);
|
EarthMethods.addTempAirBlock(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Remove the first level of dirt
|
//Remove the first level of dirt
|
||||||
Block block = loc.clone().add(x,-1,z).getBlock();
|
Block block = loc.clone().add(x, -1, z).getBlock();
|
||||||
if(isEarthbendableMaterial(block.getType()))
|
if (isEarthbendableMaterial(block.getType()))
|
||||||
EarthMethods.addTempAirBlock(block);
|
EarthMethods.addTempAirBlock(block);
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* We needed to calculate all of the blocks based on the location being 1 above the initial
|
* We needed to calculate all of the blocks based on the
|
||||||
* bending block, however we want to animate it starting from the original bending block.
|
* 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.
|
* We must readjust the location back to what it originally was.
|
||||||
*/
|
*/
|
||||||
loc.add(0,-1,0);
|
loc.add(0, -1, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
//Move any entities that are above the rock
|
//Move any entities that are above the rock
|
||||||
List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(loc, 2.5);
|
List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(loc, 2.5);
|
||||||
for(Entity entity : entities) {
|
for (Entity entity : entities) {
|
||||||
org.bukkit.util.Vector velocity = entity.getVelocity();
|
org.bukkit.util.Vector velocity = entity.getVelocity();
|
||||||
entity.setVelocity(velocity.add(new Vector(0,0.36,0)));
|
entity.setVelocity(velocity.add(new Vector(0, 0.36, 0)));
|
||||||
}
|
}
|
||||||
loc.getWorld().playEffect(loc, Effect.GHAST_SHOOT, 0, 7);
|
loc.getWorld().playEffect(loc, Effect.GHAST_SHOOT, 0, 7);
|
||||||
draw();
|
draw();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
state = State.LIFTED;
|
state = State.LIFTED;
|
||||||
}
|
}
|
||||||
animCounter++;
|
animCounter++;
|
||||||
|
@ -387,13 +368,13 @@ public class EarthSmash {
|
||||||
/**
|
/**
|
||||||
* Redraws the blocks for this instance of EarthSmash.
|
* Redraws the blocks for this instance of EarthSmash.
|
||||||
*/
|
*/
|
||||||
if(currentBlocks.size() == 0) {
|
if (currentBlocks.size() == 0) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(BlockRepresenter blockRep : currentBlocks) {
|
for (BlockRepresenter blockRep : currentBlocks) {
|
||||||
Block block = loc.clone().add(blockRep.getX(),blockRep.getY(),blockRep.getZ()).getBlock();
|
Block block = loc.clone().add(blockRep.getX(), blockRep.getY(), blockRep.getZ()).getBlock();
|
||||||
if(player != null && EarthMethods.isTransparentToEarthbending(player,block)) {
|
if (player != null && EarthMethods.isTransparentToEarthbending(player, block)) {
|
||||||
affectedBlocks.add(new TempBlock(block, blockRep.getType(), blockRep.getData()));
|
affectedBlocks.add(new TempBlock(block, blockRep.getType(), blockRep.getData()));
|
||||||
EarthMethods.tempNoEarthbending.add(block);
|
EarthMethods.tempNoEarthbending.add(block);
|
||||||
}
|
}
|
||||||
|
@ -402,7 +383,7 @@ public class EarthSmash {
|
||||||
|
|
||||||
public void revert() {
|
public void revert() {
|
||||||
checkRemainingBlocks();
|
checkRemainingBlocks();
|
||||||
for(int i = 0; i < affectedBlocks.size(); i++) {
|
for (int i = 0; i < affectedBlocks.size(); i++) {
|
||||||
TempBlock tblock = affectedBlocks.get(i);
|
TempBlock tblock = affectedBlocks.get(i);
|
||||||
EarthMethods.tempNoEarthbending.remove(tblock.getBlock());
|
EarthMethods.tempNoEarthbending.remove(tblock.getBlock());
|
||||||
tblock.revertBlock();
|
tblock.revertBlock();
|
||||||
|
@ -414,20 +395,19 @@ public class EarthSmash {
|
||||||
public void checkRemainingBlocks() {
|
public void checkRemainingBlocks() {
|
||||||
/**
|
/**
|
||||||
* Checks to see which of the blocks are still attached to the
|
* Checks to see which of the blocks are still attached to the
|
||||||
* EarthSmash, remember that blocks can be broken or used in other abilities
|
* EarthSmash, remember that blocks can be broken or used in other
|
||||||
* so we need to double check and remove any that are not still attached.
|
* 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
|
* 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
|
* we should do it on a delay because tempair takes a couple seconds
|
||||||
* the block shows up in that map.
|
* before the block shows up in that map.
|
||||||
*/
|
*/
|
||||||
for(int i = 0; i < currentBlocks.size(); i++) {
|
for (int i = 0; i < currentBlocks.size(); i++) {
|
||||||
BlockRepresenter brep = currentBlocks.get(i);
|
BlockRepresenter brep = currentBlocks.get(i);
|
||||||
final Block block = loc.clone().add(brep.getX(), brep.getY(), brep.getZ()).getBlock();
|
final Block block = loc.clone().add(brep.getX(), brep.getY(), brep.getZ()).getBlock();
|
||||||
// Check for grass because sometimes the dirt turns into grass.
|
// Check for grass because sometimes the dirt turns into grass.
|
||||||
if(block.getType() != brep.getType()
|
if (block.getType() != brep.getType() && (block.getType() != Material.GRASS) && (block.getType() != Material.COBBLESTONE)) {
|
||||||
&& (block.getType() != Material.GRASS)
|
|
||||||
&& (block.getType() != Material.COBBLESTONE)) {
|
|
||||||
currentBlocks.remove(i);
|
currentBlocks.remove(i);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
@ -442,48 +422,52 @@ public class EarthSmash {
|
||||||
|
|
||||||
public List<Block> getBlocks() {
|
public List<Block> getBlocks() {
|
||||||
/**
|
/**
|
||||||
* Gets the blocks surrounding the EarthSmash's loc.
|
* Gets the blocks surrounding the EarthSmash's loc. This method ignores
|
||||||
* This method ignores the blocks that should be Air, and only returns the ones that are dirt.
|
* the blocks that should be Air, and only returns the ones that are
|
||||||
|
* dirt.
|
||||||
*/
|
*/
|
||||||
List<Block> blocks = new ArrayList<Block>();
|
List<Block> blocks = new ArrayList<Block>();
|
||||||
for(int x = -1; x <= 1; x++)
|
for (int x = -1; x <= 1; x++)
|
||||||
for(int y = -1; y <= 1; y++)
|
for (int y = -1; y <= 1; y++)
|
||||||
for(int z = -1; z <= 1; z++)
|
for (int z = -1; z <= 1; z++)
|
||||||
if((Math.abs(x) + Math.abs(y) + Math.abs(z)) % 2 == 0) //Give it the cool shape
|
if ((Math.abs(x) + Math.abs(y) + Math.abs(z)) % 2 == 0) //Give it the cool shape
|
||||||
if(loc != null)
|
if (loc != null)
|
||||||
blocks.add(loc.getWorld().getBlockAt(loc.clone().add(x,y,z)));
|
blocks.add(loc.getWorld().getBlockAt(loc.clone().add(x, y, z)));
|
||||||
return blocks;
|
return blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Block> getBlocksIncludingInner() {
|
public List<Block> getBlocksIncludingInner() {
|
||||||
/**
|
/**
|
||||||
* Gets the blocks surrounding the EarthSmash's loc.
|
* Gets the blocks surrounding the EarthSmash's loc. This method returns
|
||||||
* This method returns all the blocks surrounding the loc, including dirt and air.
|
* all the blocks surrounding the loc, including dirt and air.
|
||||||
*/
|
*/
|
||||||
List<Block> blocks = new ArrayList<Block>();
|
List<Block> blocks = new ArrayList<Block>();
|
||||||
for(int x = -1; x <= 1; x++)
|
for (int x = -1; x <= 1; x++)
|
||||||
for(int y = -1; y <= 1; y++)
|
for (int y = -1; y <= 1; y++)
|
||||||
for(int z = -1; z <= 1; z++)
|
for (int z = -1; z <= 1; z++)
|
||||||
if(loc != null)
|
if (loc != null)
|
||||||
blocks.add(loc.getWorld().getBlockAt(loc.clone().add(x,y,z)));
|
blocks.add(loc.getWorld().getBlockAt(loc.clone().add(x, y, z)));
|
||||||
return blocks;
|
return blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Material selectMaterial(Material mat) {
|
public static Material selectMaterial(Material mat) {
|
||||||
/**
|
/**
|
||||||
* Switches the Sand Material and Gravel to SandStone and stone respectively,
|
* Switches the Sand Material and Gravel to SandStone and stone
|
||||||
* since gravel and sand cannot be bent due to gravity.
|
* respectively, since gravel and sand cannot be bent due to gravity.
|
||||||
*/
|
*/
|
||||||
if(mat == Material.SAND) return Material.SANDSTONE;
|
if (mat == Material.SAND)
|
||||||
else if(mat == Material.GRAVEL) return Material.STONE;
|
return Material.SANDSTONE;
|
||||||
else return mat;
|
else if (mat == Material.GRAVEL)
|
||||||
|
return Material.STONE;
|
||||||
|
else
|
||||||
|
return mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Material selectMaterialForRepresenter(Material mat) {
|
public Material selectMaterialForRepresenter(Material mat) {
|
||||||
Material tempMat = selectMaterial(mat);
|
Material tempMat = selectMaterial(mat);
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
if(!isEarthbendableMaterial(tempMat)) {
|
if (!isEarthbendableMaterial(tempMat)) {
|
||||||
if(currentBlocks.size() < 1)
|
if (currentBlocks.size() < 1)
|
||||||
return Material.DIRT;
|
return Material.DIRT;
|
||||||
else
|
else
|
||||||
return currentBlocks.get(rand.nextInt(currentBlocks.size())).getType();
|
return currentBlocks.get(rand.nextInt(currentBlocks.size())).getType();
|
||||||
|
@ -493,18 +477,18 @@ public class EarthSmash {
|
||||||
|
|
||||||
private EarthSmash aimingAtSmashCheck(Player player, State reqState) {
|
private EarthSmash aimingAtSmashCheck(Player player, State reqState) {
|
||||||
/**
|
/**
|
||||||
* Determines if a player is trying to grab an EarthSmash.
|
* Determines if a player is trying to grab an EarthSmash. A player is
|
||||||
* A player is trying to grab an EarthSmash if they are staring at it and holding shift.
|
* trying to grab an EarthSmash if they are staring at it and holding
|
||||||
|
* shift.
|
||||||
*/
|
*/
|
||||||
if(!ALLOW_GRAB)
|
if (!ALLOW_GRAB)
|
||||||
return null;
|
return null;
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
List<Block> blocks = player.getLineOfSight(EarthMethods.getTransparentEarthbending(), (int) Math.round(grabRange));
|
List<Block> blocks = player.getLineOfSight(EarthMethods.getTransparentEarthbending(), (int) Math.round(grabRange));
|
||||||
for(EarthSmash smash : instances) {
|
for (EarthSmash smash : instances) {
|
||||||
if(reqState == null || smash.state == reqState)
|
if (reqState == null || smash.state == reqState)
|
||||||
for(Block block : blocks)
|
for (Block block : blocks)
|
||||||
if(block.getLocation().getWorld() == smash.loc.getWorld() &&
|
if (block.getLocation().getWorld() == smash.loc.getWorld() && block.getLocation().distanceSquared(smash.loc) <= Math.pow(GRAB_DETECTION_RADIUS, 2))
|
||||||
block.getLocation().distanceSquared(smash.loc) <= Math.pow(GRAB_DETECTION_RADIUS, 2))
|
|
||||||
return smash;
|
return smash;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -512,14 +496,13 @@ public class EarthSmash {
|
||||||
|
|
||||||
public void shootingCollisionDetection() {
|
public void shootingCollisionDetection() {
|
||||||
/**
|
/**
|
||||||
* This method handles any collision between an EarthSmash and the surrounding entities,
|
* This method handles any collision between an EarthSmash and the
|
||||||
* the method only applies to earthsmashes that have already been shot.
|
* surrounding entities, the method only applies to earthsmashes that
|
||||||
|
* have already been shot.
|
||||||
*/
|
*/
|
||||||
List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(loc, FLIGHT_DETECTION_RADIUS);
|
List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(loc, FLIGHT_DETECTION_RADIUS);
|
||||||
for(Entity entity : entities)
|
for (Entity entity : entities)
|
||||||
if(entity instanceof LivingEntity
|
if (entity instanceof LivingEntity && entity != player && !affectedEntities.contains(entity)) {
|
||||||
&& entity != player
|
|
||||||
&& !affectedEntities.contains(entity)) {
|
|
||||||
affectedEntities.add(entity);
|
affectedEntities.add(entity);
|
||||||
double damage = currentBlocks.size() / 13 * this.damage;
|
double damage = currentBlocks.size() / 13 * this.damage;
|
||||||
GeneralMethods.damageEntity(player, entity, damage);
|
GeneralMethods.damageEntity(player, entity, damage);
|
||||||
|
@ -527,19 +510,21 @@ public class EarthSmash {
|
||||||
entity.setVelocity(travelVec.setY(knockup).normalize().multiply(knockback));
|
entity.setVelocity(travelVec.setY(knockup).normalize().multiply(knockback));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void smashToSmashCollisionDetection() {
|
public void smashToSmashCollisionDetection() {
|
||||||
/**
|
/**
|
||||||
* EarthSmash to EarthSmash collision can only happen when one of the Smashes have
|
* EarthSmash to EarthSmash collision can only happen when one of the
|
||||||
* been shot by a player. If we find out that one of them have collided then we want to return
|
* Smashes have been shot by a player. If we find out that one of them
|
||||||
* since a smash can only remove 1 at a time.
|
* 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++) {
|
for (int i = 0; i < instances.size(); i++) {
|
||||||
EarthSmash smash = instances.get(i);
|
EarthSmash smash = instances.get(i);
|
||||||
if(smash.loc != null) {
|
if (smash.loc != null) {
|
||||||
if(smash != this && smash.loc.getWorld() == loc.getWorld() &&smash.loc.distanceSquared(loc) < Math.pow(FLIGHT_DETECTION_RADIUS, 2)) {
|
if (smash != this && smash.loc.getWorld() == loc.getWorld() && smash.loc.distanceSquared(loc) < Math.pow(FLIGHT_DETECTION_RADIUS, 2)) {
|
||||||
smash.remove();
|
smash.remove();
|
||||||
remove();
|
remove();
|
||||||
i-=2;
|
i -= 2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -548,17 +533,17 @@ public class EarthSmash {
|
||||||
|
|
||||||
private static EarthSmash flyingInSmashCheck(Player player) {
|
private static EarthSmash flyingInSmashCheck(Player player) {
|
||||||
/**
|
/**
|
||||||
* Determines whether or not a player is trying to fly ontop of an EarthSmash.
|
* Determines whether or not a player is trying to fly ontop of an
|
||||||
* A player is considered "flying" if they are standing ontop of the earthsmash and holding shift.
|
* EarthSmash. A player is considered "flying" if they are standing
|
||||||
|
* ontop of the earthsmash and holding shift.
|
||||||
*/
|
*/
|
||||||
if(!ALLOW_FLIGHT)
|
if (!ALLOW_FLIGHT)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
for(EarthSmash smash : instances) {
|
for (EarthSmash smash : instances) {
|
||||||
//Check to see if the player is standing on top of the smash.
|
//Check to see if the player is standing on top of the smash.
|
||||||
if(smash.state == State.LIFTED) {
|
if (smash.state == State.LIFTED) {
|
||||||
if(smash.loc.getWorld().equals(player.getWorld())
|
if (smash.loc.getWorld().equals(player.getWorld()) && smash.loc.clone().add(0, 2, 0).distanceSquared(player.getLocation()) <= Math.pow(FLIGHT_DETECTION_RADIUS, 2)) {
|
||||||
&& smash.loc.clone().add(0,2,0).distanceSquared(player.getLocation()) <= Math.pow(FLIGHT_DETECTION_RADIUS, 2)) {
|
|
||||||
return smash;
|
return smash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -575,12 +560,12 @@ public class EarthSmash {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void progressAll() {
|
public static void progressAll() {
|
||||||
for(int i = 0; i < instances.size(); i++)
|
for (int i = 0; i < instances.size(); i++)
|
||||||
instances.get(i).progress();
|
instances.get(i).progress();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeAll() {
|
public static void removeAll() {
|
||||||
for(int i = 0; i < instances.size(); i++) {
|
for (int i = 0; i < instances.size(); i++) {
|
||||||
instances.get(i).remove();
|
instances.get(i).remove();
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
@ -588,15 +573,17 @@ public class EarthSmash {
|
||||||
|
|
||||||
public class BlockRepresenter {
|
public class BlockRepresenter {
|
||||||
/**
|
/**
|
||||||
* A BlockRepresenter is used to keep track of each of
|
* A BlockRepresenter is used to keep track of each of the individual
|
||||||
* the individual types of blocks that are attached to an EarthSmash.
|
* types of blocks that are attached to an EarthSmash. Without the
|
||||||
* Without the representer then an EarthSmash can only be made up of 1 material
|
* representer then an EarthSmash can only be made up of 1 material at a
|
||||||
* at a time. For example, an ESmash that is entirely dirt, coalore, or sandstone.
|
* time. For example, an ESmash that is entirely dirt, coalore, or
|
||||||
* Using the representer will allow all the materials to be mixed together.
|
* sandstone. Using the representer will allow all the materials to be
|
||||||
|
* mixed together.
|
||||||
*/
|
*/
|
||||||
private int x, y, z;
|
private int x, y, z;
|
||||||
private Material type;
|
private Material type;
|
||||||
private byte data;
|
private byte data;
|
||||||
|
|
||||||
public BlockRepresenter(int x, int y, int z, Material type, byte data) {
|
public BlockRepresenter(int x, int y, int z, Material type, byte data) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
|
@ -604,6 +591,7 @@ public class EarthSmash {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getX() {
|
public int getX() {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
@ -650,29 +638,29 @@ public class EarthSmash {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Pair<F, S> {
|
public class Pair<F, S> {
|
||||||
private F first; //first member of pair
|
private F first; //first member of pair
|
||||||
private S second; //second member of pair
|
private S second; //second member of pair
|
||||||
|
|
||||||
public Pair(F first, S second) {
|
public Pair(F first, S second) {
|
||||||
this.first = first;
|
this.first = first;
|
||||||
this.second = second;
|
this.second = second;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFirst(F first) {
|
public void setFirst(F first) {
|
||||||
this.first = first;
|
this.first = first;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSecond(S second) {
|
public void setSecond(S second) {
|
||||||
this.second = second;
|
this.second = second;
|
||||||
}
|
}
|
||||||
|
|
||||||
public F getFirst() {
|
public F getFirst() {
|
||||||
return first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
public S getSecond() {
|
public S getSecond() {
|
||||||
return second;
|
return second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
|
@ -689,7 +677,7 @@ public class EarthSmash {
|
||||||
|
|
||||||
public void setCooldown(long cooldown) {
|
public void setCooldown(long cooldown) {
|
||||||
this.cooldown = cooldown;
|
this.cooldown = cooldown;
|
||||||
if(player != null)
|
if (player != null)
|
||||||
bplayer.addCooldown("EarthSmash", cooldown);
|
bplayer.addCooldown("EarthSmash", cooldown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,9 @@ public class FireBlast extends CoreAbility {
|
||||||
private void ignite(Location location) {
|
private void ignite(Location location) {
|
||||||
for (Block block : GeneralMethods.getBlocksAroundPoint(location, affectingradius)) {
|
for (Block block : GeneralMethods.getBlocksAroundPoint(location, affectingradius)) {
|
||||||
if (FireStream.isIgnitable(player, block) && !safe.contains(block)) {
|
if (FireStream.isIgnitable(player, block) && !safe.contains(block)) {
|
||||||
new Plantbending(block);
|
if (WaterMethods.isPlantbendable(block)) {
|
||||||
|
new Plantbending(block);
|
||||||
|
}
|
||||||
block.setType(Material.FIRE);
|
block.setType(Material.FIRE);
|
||||||
if (dissipate) {
|
if (dissipate) {
|
||||||
FireStream.ignitedblocks.put(block, player);
|
FireStream.ignitedblocks.put(block, player);
|
||||||
|
|
|
@ -308,6 +308,10 @@ public class WaterMethods {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isPlantbendable(Block block) {
|
||||||
|
return WaterMethods.isPlantbendable(block, false);
|
||||||
|
}
|
||||||
|
|
||||||
public static void playFocusWaterEffect(Block block) {
|
public static void playFocusWaterEffect(Block block) {
|
||||||
block.getWorld().playEffect(block.getLocation(), Effect.SMOKE, 4, 20);
|
block.getWorld().playEffect(block.getLocation(), Effect.SMOKE, 4, 20);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue