summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntityBoat.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/EntityBoat.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/EntityBoat.patch')
-rw-r--r--nms-patches/EntityBoat.patch249
1 files changed, 249 insertions, 0 deletions
diff --git a/nms-patches/EntityBoat.patch b/nms-patches/EntityBoat.patch
new file mode 100644
index 00000000..6ab202bf
--- /dev/null
+++ b/nms-patches/EntityBoat.patch
@@ -0,0 +1,249 @@
+--- ../work/decompile-bb26c12b/net/minecraft/server/EntityBoat.java 2014-11-27 08:59:46.653422058 +1100
++++ src/main/java/net/minecraft/server/EntityBoat.java 2014-11-27 08:42:10.172850872 +1100
+@@ -2,6 +2,16 @@
+
+ import java.util.List;
+
++// CraftBukkit start
++import org.bukkit.Location;
++import org.bukkit.craftbukkit.event.CraftEventFactory;
++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.event.vehicle.VehicleMoveEvent;
++// CraftBukkit end
++
+ public class EntityBoat extends Entity {
+
+ private boolean a;
+@@ -12,6 +22,27 @@
+ private double f;
+ private double g;
+ private double h;
++
++ // CraftBukkit start
++ public double maxSpeed = 0.4D;
++ public double occupiedDeceleration = 0.2D;
++ public double unoccupiedDeceleration = -1;
++ public boolean landBoats = false;
++
++ @Override
++ public void collide(Entity entity) {
++ org.bukkit.entity.Entity hitEntity = (entity == null) ? null : entity.getBukkitEntity();
++
++ VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), hitEntity);
++ this.world.getServer().getPluginManager().callEvent(event);
++
++ if (event.isCancelled()) {
++ return;
++ }
++
++ super.collide(entity);
++ }
++ // CraftBukkit end
+
+ public EntityBoat(World world) {
+ super(world);
+@@ -52,6 +83,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() {
+@@ -65,6 +98,19 @@
+ if (this.passenger != null && this.passenger == damagesource.getEntity() && damagesource instanceof EntityDamageSourceIndirect) {
+ return false;
+ } else {
++ // CraftBukkit start
++ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
++ org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();
++
++ VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) f);
++ this.world.getServer().getPluginManager().callEvent(event);
++
++ if (event.isCancelled()) {
++ return true;
++ }
++ // f = event.getDamage(); // TODO Why don't we do this?
++ // CraftBukkit end
++
+ this.b(-this.m());
+ this.a(10);
+ this.setDamage(this.j() + f * 10.0F);
+@@ -72,6 +118,15 @@
+ boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;
+
+ if (flag || this.j() > 40.0F) {
++ // CraftBukkit start
++ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker);
++ this.world.getServer().getPluginManager().callEvent(destroyEvent);
++
++ if (destroyEvent.isCancelled()) {
++ this.setDamage(40F); // Maximize damage so this doesn't get triggered again right away
++ return true;
++ }
++ // CraftBukkit end
+ if (this.passenger != null) {
+ this.passenger.mount(this);
+ }
+@@ -95,6 +150,13 @@
+ }
+
+ 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
+ super.s_();
+ if (this.l() > 0) {
+ this.a(this.l() - 1);
+@@ -196,6 +258,19 @@
+ this.motX += -Math.sin((double) (f * 3.1415927F / 180.0F)) * this.b * (double) entityliving.aY * 0.05000000074505806D;
+ this.motZ += Math.cos((double) (f * 3.1415927F / 180.0F)) * this.b * (double) entityliving.aY * 0.05000000074505806D;
+ }
++ // CraftBukkit start - Support unoccupied deceleration
++ else if (unoccupiedDeceleration >= 0) {
++ this.motX *= unoccupiedDeceleration;
++ this.motZ *= unoccupiedDeceleration;
++ // Kill lingering speed
++ if (motX <= 0.00001) {
++ motX = 0;
++ }
++ if (motZ <= 0.00001) {
++ motZ = 0;
++ }
++ }
++ // CraftBukkit end
+
+ d4 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
+ if (d4 > 0.35D) {
+@@ -230,16 +305,26 @@
+ Block block = this.world.getType(blockposition).getBlock();
+
+ if (block == Blocks.SNOW_LAYER) {
++ // CraftBukkit start
++ if (CraftEventFactory.callEntityChangeBlockEvent(this, l, j1, j, Blocks.AIR, 0).isCancelled()) {
++ continue;
++ }
++ // CraftBukkit end
+ this.world.setAir(blockposition);
+ this.positionChanged = false;
+ } else if (block == Blocks.WATERLILY) {
++ // CraftBukkit start
++ if (CraftEventFactory.callEntityChangeBlockEvent(this, l, j1, j, Blocks.AIR, 0).isCancelled()) {
++ continue;
++ }
++ // CraftBukkit end
+ this.world.setAir(blockposition, true);
+ this.positionChanged = false;
+ }
+ }
+ }
+
+- if (this.onGround) {
++ if (this.onGround && !this.landBoats) { // CraftBukkit
+ this.motX *= 0.5D;
+ this.motY *= 0.5D;
+ this.motZ *= 0.5D;
+@@ -247,16 +332,23 @@
+
+ this.move(this.motX, this.motY, this.motZ);
+ if (this.positionChanged && d3 > 0.2D) {
+- if (!this.world.isStatic && !this.dead) {
+- this.die();
++ if (!this.world.isStatic && !this.dead) {
++ // CraftBukkit start
++ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
++ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null);
++ this.world.getServer().getPluginManager().callEvent(destroyEvent);
++ if (!destroyEvent.isCancelled()) {
++ this.die();
+
+- for (k = 0; k < 3; ++k) {
+- this.a(Item.getItemOf(Blocks.PLANKS), 1, 0.0F);
+- }
++ for (k = 0; k < 3; ++k) {
++ this.a(Item.getItemOf(Blocks.PLANKS), 1, 0.0F);
++ }
+
+- for (k = 0; k < 2; ++k) {
+- this.a(Items.STICK, 1, 0.0F);
++ for (k = 0; k < 2; ++k) {
++ this.a(Items.STICK, 1, 0.0F);
++ }
+ }
++ // CraftBukkit end
+ }
+ } else {
+ this.motX *= 0.9900000095367432D;
+@@ -284,6 +376,23 @@
+
+ this.yaw = (float) ((double) this.yaw + d12);
+ this.setYawPitch(this.yaw, this.pitch);
++
++ // CraftBukkit start
++ org.bukkit.Server server = this.world.getServer();
++ 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();
++
++ server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
++
++ if (!from.equals(to)) {
++ VehicleMoveEvent event = new VehicleMoveEvent(vehicle, from, to);
++ server.getPluginManager().callEvent(event);
++ }
++ // CraftBukkit end
++
+ if (!this.world.isStatic) {
+ List list = this.world.getEntities(this, this.getBoundingBox().grow(0.20000000298023224D, 0.0D, 0.20000000298023224D));
+
+@@ -298,6 +407,7 @@
+ }
+
+ if (this.passenger != null && this.passenger.dead) {
++ this.passenger.vehicle = null; // CraftBukkit
+ this.passenger = null;
+ }
+
+@@ -335,17 +445,24 @@
+ if (this.fallDistance > 3.0F) {
+ this.e(this.fallDistance, 1.0F);
+ if (!this.world.isStatic && !this.dead) {
+- this.die();
++ // CraftBukkit start
++ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
++ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null);
++ this.world.getServer().getPluginManager().callEvent(destroyEvent);
++ if (!destroyEvent.isCancelled()) {
++ this.die();
+
+- int i;
++ int i;
+
+- for (i = 0; i < 3; ++i) {
+- this.a(Item.getItemOf(Blocks.PLANKS), 1, 0.0F);
+- }
++ for (i = 0; i < 3; ++i) {
++ this.a(Item.getItemOf(Blocks.PLANKS), 1, 0.0F);
++ }
+
+- for (i = 0; i < 2; ++i) {
+- this.a(Items.STICK, 1, 0.0F);
++ for (i = 0; i < 2; ++i) {
++ this.a(Items.STICK, 1, 0.0F);
++ }
+ }
++ // CraftBukkit end
+ }
+
+ this.fallDistance = 0.0F;