summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntityMinecartAbstract.patch
diff options
context:
space:
mode:
authorThinkofdeath <thinkofdeath@spigotmc.org>2014-11-26 08:32:16 +1100
committermd_5 <git@md-5.net>2014-11-28 17:16:30 +1100
commit24557bc2b37deb6a0edf497d547471832457b1dd (patch)
treec560572889a3b0b34964a0cddb35dc87fda3c914 /nms-patches/EntityMinecartAbstract.patch
parenta4805dbd77da057cc1ea0bf344379bc6e53ca1f6 (diff)
downloadcraftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.gz
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.lz
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.xz
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.zip
Update to Minecraft 1.8
For more information please see http://www.spigotmc.org/
Diffstat (limited to 'nms-patches/EntityMinecartAbstract.patch')
-rw-r--r--nms-patches/EntityMinecartAbstract.patch231
1 files changed, 231 insertions, 0 deletions
diff --git a/nms-patches/EntityMinecartAbstract.patch b/nms-patches/EntityMinecartAbstract.patch
new file mode 100644
index 00000000..c8ed3d56
--- /dev/null
+++ b/nms-patches/EntityMinecartAbstract.patch
@@ -0,0 +1,231 @@
+--- ../work/decompile-bb26c12b/net/minecraft/server/EntityMinecartAbstract.java 2014-11-27 08:59:46.705421829 +1100
++++ src/main/java/net/minecraft/server/EntityMinecartAbstract.java 2014-11-27 08:42:10.136850942 +1100
+@@ -2,6 +2,15 @@
+
+ import java.util.Iterator;
+
++// 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 {
+
+ private boolean a;
+@@ -13,6 +22,17 @@
+ private double g;
+ private double h;
+ private double i;
++
++ // 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
+
+ public EntityMinecartAbstract(World world) {
+ super(world);
+@@ -79,6 +99,8 @@
+ this.lastX = d0;
+ this.lastY = d1;
+ this.lastZ = d2;
++
++ this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleCreateEvent((Vehicle) this.getBukkitEntity())); // CraftBukkit
+ }
+
+ public double an() {
+@@ -90,16 +112,39 @@
+ 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
++
+ this.k(-this.r());
+ this.j(10);
+ this.ac();
+ this.setDamage(this.getDamage() + f * 10.0F);
+ boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;
+
+- if (flag || this.getDamage() > 40.0F) {
++ if (flag || this.getDamage() > 40.0F) { // CraftBukkit - multi-world should still allow teleport even if default vanilla nether disabled
+ if (this.passenger != null) {
+ this.passenger.mount((Entity) null);
+ }
++ // 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
+
+ if (flag && !this.hasCustomName()) {
+ this.die();
+@@ -135,6 +180,14 @@
+ }
+
+ public void s_() {
++ // CraftBukkit start
++ double prevX = this.locX;
++ double prevY = this.locY;
++ double prevZ = this.locZ;
++ float prevYaw = this.yaw;
++ float prevPitch = this.pitch;
++ // CraftBukkit end
++
+ if (this.getType() > 0) {
+ this.j(this.getType() - 1);
+ }
+@@ -155,7 +208,7 @@
+
+ i = this.L();
+ if (this.ak) {
+- if (minecraftserver.getAllowNether()) {
++ if (true || minecraftserver.getAllowNether()) {
+ if (this.vehicle == null && this.al++ >= i) {
+ this.al = i;
+ this.portalCooldown = this.ar();
+@@ -252,6 +305,20 @@
+ }
+
+ 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
++
+ Iterator iterator = this.world.getEntities(this, this.getBoundingBox().grow(0.20000000298023224D, 0.0D, 0.20000000298023224D)).iterator();
+
+ while (iterator.hasNext()) {
+@@ -275,7 +342,7 @@
+ }
+
+ protected double m() {
+- return 0.4D;
++ return this.maxSpeed; // CraftBukkit
+ }
+
+ public void a(int i, int j, int k, boolean flag) {}
+@@ -286,16 +353,20 @@
+ 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
+ }
+
+ this.move(this.motX, this.motY, this.motZ);
+ 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
+ }
+
+ }
+@@ -483,7 +554,7 @@
+ }
+
+ protected void o() {
+- if (this.passenger != null) {
++ if (this.passenger != null || !this.slowWhenEmpty) { // CraftBukkit - add !this.slowWhenEmpty
+ this.motX *= 0.996999979019165D;
+ this.motY *= 0.0D;
+ this.motZ *= 0.996999979019165D;
+@@ -611,6 +682,17 @@
+ if (!this.world.isStatic) {
+ if (!entity.T && !this.T) {
+ if (entity != this.passenger) {
++ // CraftBukkit start
++ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
++ org.bukkit.entity.Entity hitEntity = (entity == null) ? null : entity.getBukkitEntity();
++
++ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, hitEntity);
++ this.world.getServer().getPluginManager().callEvent(collisionEvent);
++
++ if (collisionEvent.isCancelled()) {
++ return;
++ }
++ // CraftBukkit end
+ if (entity instanceof EntityLiving && !(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && this.s() == EnumMinecartType.RIDEABLE && this.motX * this.motX + this.motZ * this.motZ > 0.01D && this.passenger == null && entity.vehicle == null) {
+ entity.mount(this);
+ }
+@@ -619,7 +701,8 @@
+ double d1 = entity.locZ - this.locZ;
+ double d2 = d0 * d0 + d1 * d1;
+
+- if (d2 >= 9.999999747378752E-5D) {
++ // CraftBukkit - collision
++ if (d2 >= 9.999999747378752E-5D && !collisionEvent.isCollisionCancelled()) {
+ d2 = (double) MathHelper.sqrt(d2);
+ d0 /= d2;
+ d1 /= d2;
+@@ -775,4 +858,26 @@
+ return chatmessage;
+ }
+ }
++
++ // 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
+ }