2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/EntityMinecartAbstract.java
|
|
|
|
+++ b/net/minecraft/server/EntityMinecartAbstract.java
|
2016-06-09 03:43:49 +02:00
|
|
|
@@ -6,6 +6,15 @@
|
2015-02-26 23:41:06 +01:00
|
|
|
import java.util.Map;
|
2016-05-10 13:47:39 +02:00
|
|
|
import javax.annotation.Nullable;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.Location;
|
|
|
|
+import org.bukkit.entity.Vehicle;
|
|
|
|
+import org.bukkit.event.vehicle.VehicleDamageEvent;
|
|
|
|
+import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
|
|
|
+import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
|
|
|
|
+import org.bukkit.util.Vector;
|
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
|
|
|
public abstract class EntityMinecartAbstract extends Entity implements INamableTileEntity {
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
private static final DataWatcherObject<Integer> a = DataWatcher.a(EntityMinecartAbstract.class, DataWatcherRegistry.b);
|
2016-06-09 03:43:49 +02:00
|
|
|
@@ -23,6 +32,17 @@
|
2016-11-17 02:41:03 +01:00
|
|
|
private double ax;
|
2016-05-10 13:47:39 +02:00
|
|
|
private double ay;
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ public boolean slowWhenEmpty = true;
|
|
|
|
+ private double derailedX = 0.5;
|
|
|
|
+ private double derailedY = 0.5;
|
|
|
|
+ private double derailedZ = 0.5;
|
|
|
|
+ private double flyingX = 0.95;
|
|
|
|
+ private double flyingY = 0.95;
|
|
|
|
+ private double flyingZ = 0.95;
|
|
|
|
+ public double maxSpeed = 0.4D;
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
public EntityMinecartAbstract(World world) {
|
|
|
|
super(world);
|
2016-02-29 22:32:46 +01:00
|
|
|
this.i = true;
|
2016-06-09 03:43:49 +02:00
|
|
|
@@ -90,6 +110,8 @@
|
2015-04-13 12:55:00 +02:00
|
|
|
this.lastX = d0;
|
|
|
|
this.lastY = d1;
|
|
|
|
this.lastZ = d2;
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleCreateEvent((Vehicle) this.getBukkitEntity())); // CraftBukkit
|
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
public double ay() {
|
2016-06-09 03:43:49 +02:00
|
|
|
@@ -101,6 +123,19 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
if (this.isInvulnerable(damagesource)) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
+ // CraftBukkit start - fire VehicleDamageEvent
|
|
|
|
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
|
|
|
+ org.bukkit.entity.Entity passenger = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();
|
|
|
|
+
|
|
|
|
+ VehicleDamageEvent event = new VehicleDamageEvent(vehicle, passenger, f);
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ f = (float) event.getDamage();
|
|
|
|
+ // CraftBukkit end
|
2016-02-29 22:32:46 +01:00
|
|
|
this.e(-this.u());
|
|
|
|
this.d(10);
|
2016-06-09 03:43:49 +02:00
|
|
|
this.ap();
|
|
|
|
@@ -108,6 +143,15 @@
|
2015-04-13 13:01:55 +02:00
|
|
|
boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;
|
|
|
|
|
|
|
|
if (flag || this.getDamage() > 40.0F) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger);
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(destroyEvent);
|
|
|
|
+
|
|
|
|
+ if (destroyEvent.isCancelled()) {
|
|
|
|
+ this.setDamage(40); // Maximize damage so this doesn't get triggered again right away
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2016-02-29 22:32:46 +01:00
|
|
|
this.az();
|
|
|
|
if (flag && !this.hasCustomName()) {
|
|
|
|
this.die();
|
2016-11-17 02:41:03 +01:00
|
|
|
@@ -146,6 +190,14 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2016-11-17 02:41:03 +01:00
|
|
|
public void A_() {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ double prevX = this.locX;
|
|
|
|
+ double prevY = this.locY;
|
|
|
|
+ double prevZ = this.locZ;
|
|
|
|
+ float prevYaw = this.yaw;
|
|
|
|
+ float prevPitch = this.pitch;
|
|
|
|
+ // CraftBukkit end
|
2016-02-29 22:32:46 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
if (this.getType() > 0) {
|
2016-02-29 22:32:46 +01:00
|
|
|
this.d(this.getType() - 1);
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2016-11-17 02:41:03 +01:00
|
|
|
@@ -166,7 +218,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
i = this.V();
|
2016-11-17 02:41:03 +01:00
|
|
|
if (this.ak) {
|
2014-11-25 22:32:16 +01:00
|
|
|
- if (minecraftserver.getAllowNether()) {
|
2015-02-26 23:41:06 +01:00
|
|
|
+ if (true || minecraftserver.getAllowNether()) { // CraftBukkit - multi-world should still allow teleport even if default vanilla nether disabled
|
2016-11-17 02:41:03 +01:00
|
|
|
if (!this.isPassenger() && this.al++ >= i) {
|
|
|
|
this.al = i;
|
2016-06-09 03:43:49 +02:00
|
|
|
this.portalCooldown = this.aE();
|
2016-11-17 02:41:03 +01:00
|
|
|
@@ -266,6 +318,18 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
this.setYawPitch(this.yaw, this.pitch);
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ org.bukkit.World bworld = this.world.getWorld();
|
|
|
|
+ Location from = new Location(bworld, prevX, prevY, prevZ, prevYaw, prevPitch);
|
|
|
|
+ Location to = new Location(bworld, this.locX, this.locY, this.locZ, this.yaw, this.pitch);
|
|
|
|
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
|
|
|
+
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
|
|
|
|
+
|
|
|
|
+ if (!from.equals(to)) {
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to));
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2016-06-09 03:43:49 +02:00
|
|
|
if (this.v() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE && this.motX * this.motX + this.motZ * this.motZ > 0.01D) {
|
|
|
|
List list = this.world.getEntities(this, this.getBoundingBox().grow(0.20000000298023224D, 0.0D, 0.20000000298023224D), IEntitySelector.a(this));
|
|
|
|
|
2016-11-17 02:41:03 +01:00
|
|
|
@@ -274,8 +338,24 @@
|
2016-06-09 03:43:49 +02:00
|
|
|
Entity entity = (Entity) list.get(l);
|
|
|
|
|
|
|
|
if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.isVehicle() && !entity.isPassenger()) {
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, entity.getBukkitEntity());
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(collisionEvent);
|
|
|
|
+
|
|
|
|
+ if (collisionEvent.isCancelled()) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
entity.startRiding(this);
|
|
|
|
} else {
|
2016-06-12 02:45:03 +02:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, entity.getBukkitEntity());
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(collisionEvent);
|
|
|
|
+
|
|
|
|
+ if (collisionEvent.isCancelled()) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2016-06-09 03:43:49 +02:00
|
|
|
entity.collide(this);
|
2016-06-12 02:45:03 +02:00
|
|
|
}
|
|
|
|
}
|
2016-11-17 02:41:03 +01:00
|
|
|
@@ -287,6 +367,14 @@
|
2016-06-12 02:45:03 +02:00
|
|
|
Entity entity1 = (Entity) iterator.next();
|
|
|
|
|
|
|
|
if (!this.w(entity1) && entity1.isCollidable() && entity1 instanceof EntityMinecartAbstract) {
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, entity1.getBukkitEntity());
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(collisionEvent);
|
|
|
|
+
|
|
|
|
+ if (collisionEvent.isCancelled()) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
entity1.collide(this);
|
|
|
|
}
|
|
|
|
}
|
2016-11-17 02:41:03 +01:00
|
|
|
@@ -297,7 +385,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
protected double o() {
|
2014-11-25 22:32:16 +01:00
|
|
|
- return 0.4D;
|
|
|
|
+ return this.maxSpeed; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(int i, int j, int k, boolean flag) {}
|
2016-11-17 02:41:03 +01:00
|
|
|
@@ -308,16 +396,20 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
this.motX = MathHelper.a(this.motX, -d0, d0);
|
|
|
|
this.motZ = MathHelper.a(this.motZ, -d0, d0);
|
|
|
|
if (this.onGround) {
|
|
|
|
- this.motX *= 0.5D;
|
|
|
|
- this.motY *= 0.5D;
|
|
|
|
- this.motZ *= 0.5D;
|
|
|
|
+ // CraftBukkit start - replace magic numbers with our variables
|
|
|
|
+ this.motX *= this.derailedX;
|
|
|
|
+ this.motY *= this.derailedY;
|
|
|
|
+ this.motZ *= this.derailedZ;
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2016-11-17 02:41:03 +01:00
|
|
|
this.move(EnumMoveType.SELF, this.motX, this.motY, this.motZ);
|
2014-11-25 22:32:16 +01:00
|
|
|
if (!this.onGround) {
|
|
|
|
- this.motX *= 0.949999988079071D;
|
|
|
|
- this.motY *= 0.949999988079071D;
|
|
|
|
- this.motZ *= 0.949999988079071D;
|
|
|
|
+ // CraftBukkit start - replace magic numbers with our variables
|
|
|
|
+ this.motX *= this.flyingX;
|
|
|
|
+ this.motY *= this.flyingY;
|
|
|
|
+ this.motZ *= this.flyingZ;
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2016-11-17 02:41:03 +01:00
|
|
|
@@ -505,7 +597,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
protected void r() {
|
|
|
|
- if (this.isVehicle()) {
|
|
|
|
+ if (this.isVehicle() || !this.slowWhenEmpty) { // CraftBukkit - add !this.slowWhenEmpty
|
2014-11-25 22:32:16 +01:00
|
|
|
this.motX *= 0.996999979019165D;
|
|
|
|
this.motY *= 0.0D;
|
|
|
|
this.motZ *= 0.996999979019165D;
|
2016-11-17 02:41:03 +01:00
|
|
|
@@ -780,4 +872,26 @@
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // CraftBukkit start - Methods for getting and setting flying and derailed velocity modifiers
|
|
|
|
+ public Vector getFlyingVelocityMod() {
|
|
|
|
+ return new Vector(flyingX, flyingY, flyingZ);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setFlyingVelocityMod(Vector flying) {
|
|
|
|
+ flyingX = flying.getX();
|
|
|
|
+ flyingY = flying.getY();
|
|
|
|
+ flyingZ = flying.getZ();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Vector getDerailedVelocityMod() {
|
|
|
|
+ return new Vector(derailedX, derailedY, derailedZ);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setDerailedVelocityMod(Vector derailed) {
|
|
|
|
+ derailedX = derailed.getX();
|
|
|
|
+ derailedY = derailed.getY();
|
|
|
|
+ derailedZ = derailed.getZ();
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|