mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-23 00:15:05 +00:00
Revert "Revert "Modified the HorizontalCollision damage calculation.""
This reverts commit 31cbac3666
.
This commit is contained in:
parent
31cbac3666
commit
b67d3d2e0a
5 changed files with 51 additions and 10 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -38,4 +38,9 @@ Icon
|
|||
.Trashes
|
||||
|
||||
bin/
|
||||
*.classpath
|
||||
*.classpath
|
||||
.idea/.name
|
||||
*.xml
|
||||
*.class
|
||||
*.class
|
||||
ProjectKorra.iml
|
|
@ -65,6 +65,7 @@ public class ConfigManager {
|
|||
config.addDefault("Properties.BendingAffectFallingSand.TNTStrengthMultiplier", 1.0);
|
||||
config.addDefault("Properties.GlobalCooldown", 500);
|
||||
config.addDefault("Properties.SeaLevel", 62);
|
||||
config.addDefault("Properties.HorizontalCollisionPhysics.WallDamageMinimumDistance", 5.0);
|
||||
|
||||
config.addDefault("Properties.CustomItems.GrapplingHook.Enable", true);
|
||||
config.addDefault("Properties.CustomItems.GrapplingHook.IronUses", 25);
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.projectkorra.ProjectKorra.Objects;
|
|||
import com.projectkorra.ProjectKorra.Methods;
|
||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
import com.projectkorra.ProjectKorra.Utilities.HorizontalVelocityChangeEvent;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -24,6 +25,8 @@ public class HorizontalVelocityTracker
|
|||
private Player instigator;
|
||||
private Vector lastVelocity;
|
||||
private Vector thisVelocity;
|
||||
private Location launchLocation;
|
||||
private Location impactLocation;
|
||||
|
||||
public HorizontalVelocityTracker(Entity e, Player instigator, long delay)
|
||||
{
|
||||
|
@ -31,7 +34,9 @@ public class HorizontalVelocityTracker
|
|||
this.instigator = instigator;
|
||||
fireTime = System.currentTimeMillis();
|
||||
this.delay = delay;
|
||||
thisVelocity = e.getVelocity();
|
||||
thisVelocity = e.getVelocity().clone();
|
||||
launchLocation = e.getLocation().clone();
|
||||
impactLocation = launchLocation.clone();
|
||||
this.delay = delay;
|
||||
update();
|
||||
instances.put(entity, this);
|
||||
|
@ -69,11 +74,12 @@ public class HorizontalVelocityTracker
|
|||
if((diff.getX() > 1 || diff.getX() < -1)
|
||||
|| (diff.getZ() > 1 || diff.getZ() < -1))
|
||||
{
|
||||
for(Block b : blocks)
|
||||
impactLocation = entity.getLocation();
|
||||
for (Block b : blocks)
|
||||
{
|
||||
if(!Methods.isTransparentToEarthbending(instigator, b))
|
||||
if (!Methods.isTransparentToEarthbending(instigator, b))
|
||||
{
|
||||
ProjectKorra.plugin.getServer().getPluginManager().callEvent(new HorizontalVelocityChangeEvent(entity, instigator, lastVelocity, thisVelocity, diff));
|
||||
ProjectKorra.plugin.getServer().getPluginManager().callEvent(new HorizontalVelocityChangeEvent(entity, instigator, lastVelocity, thisVelocity, diff, launchLocation, impactLocation));
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -13,10 +13,7 @@ import com.projectkorra.ProjectKorra.earthbending.LavaFlow.AbilityType;
|
|||
import com.projectkorra.ProjectKorra.firebending.*;
|
||||
import com.projectkorra.ProjectKorra.firebending.Fireball;
|
||||
import com.projectkorra.ProjectKorra.waterbending.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -71,7 +68,9 @@ public class PKListener implements Listener {
|
|||
{
|
||||
if(e.getEntity().getEntityId() != e.getInstigator().getEntityId())
|
||||
{
|
||||
Methods.damageEntity(e.getInstigator(), e.getEntity(), e.getDifference().length() * 2);
|
||||
double minimumDistance = plugin.getConfig().getDouble("Properties.HorizontalCollisionPhysics.WallDamageMinimumDistance");
|
||||
double damage = ((e.getDistanceTravelled() - minimumDistance) < 0 ? 0 : e.getDistanceTravelled() - minimumDistance) / (e.getDifference().length());
|
||||
Methods.damageEntity(e.getInstigator(), e.getEntity(), damage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.projectkorra.ProjectKorra.Utilities;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
@ -21,7 +22,10 @@ public class HorizontalVelocityChangeEvent extends Event implements Cancellable
|
|||
private Vector from;
|
||||
private Vector to;
|
||||
private Vector difference;
|
||||
private Location start;
|
||||
private Location end;
|
||||
|
||||
@Deprecated
|
||||
public HorizontalVelocityChangeEvent(Entity entity, Player instigator, Vector from, Vector to, Vector difference)
|
||||
{
|
||||
this.entity = entity;
|
||||
|
@ -31,6 +35,17 @@ public class HorizontalVelocityChangeEvent extends Event implements Cancellable
|
|||
this.difference = difference;
|
||||
}
|
||||
|
||||
public HorizontalVelocityChangeEvent(Entity entity, Player instigator, Vector from, Vector to, Vector difference, Location start, Location end)
|
||||
{
|
||||
this.entity = entity;
|
||||
this.instigator = instigator;
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.difference = difference;
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
public Entity getEntity()
|
||||
{
|
||||
return entity;
|
||||
|
@ -51,6 +66,21 @@ public class HorizontalVelocityChangeEvent extends Event implements Cancellable
|
|||
return to;
|
||||
}
|
||||
|
||||
public Location getStartPoint()
|
||||
{
|
||||
return start;
|
||||
}
|
||||
|
||||
public Location getEndPoint()
|
||||
{
|
||||
return end;
|
||||
}
|
||||
|
||||
public double getDistanceTravelled()
|
||||
{
|
||||
return start.distance(end);
|
||||
}
|
||||
|
||||
public Vector getDifference()
|
||||
{
|
||||
return difference;
|
||||
|
|
Loading…
Reference in a new issue