summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntityHanging.patch
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2016-03-01 08:32:46 +1100
committermd_5 <git@md-5.net>2016-03-01 09:32:45 +1100
commitaa008dff0f9bedbe88e1fe79831776b0a52eb90a (patch)
treecb520e0f4cc5d683fb9b7fb95de37480a7443dfb /nms-patches/EntityHanging.patch
parente1ebe524a78e27f6a2829ed4574fded3779094e1 (diff)
downloadcraftbukkit-aa008dff0f9bedbe88e1fe79831776b0a52eb90a.tar
craftbukkit-aa008dff0f9bedbe88e1fe79831776b0a52eb90a.tar.gz
craftbukkit-aa008dff0f9bedbe88e1fe79831776b0a52eb90a.tar.lz
craftbukkit-aa008dff0f9bedbe88e1fe79831776b0a52eb90a.tar.xz
craftbukkit-aa008dff0f9bedbe88e1fe79831776b0a52eb90a.zip
Update to Minecraft 1.9
Diffstat (limited to 'nms-patches/EntityHanging.patch')
-rw-r--r--nms-patches/EntityHanging.patch95
1 files changed, 40 insertions, 55 deletions
diff --git a/nms-patches/EntityHanging.patch b/nms-patches/EntityHanging.patch
index aee058d5..086d3fa9 100644
--- a/nms-patches/EntityHanging.patch
+++ b/nms-patches/EntityHanging.patch
@@ -1,24 +1,22 @@
--- a/net/minecraft/server/EntityHanging.java
+++ b/net/minecraft/server/EntityHanging.java
-@@ -4,6 +4,13 @@
- import java.util.List;
+@@ -3,6 +3,11 @@
+ import com.google.common.base.Predicate;
import org.apache.commons.lang3.Validate;
+// CraftBukkit start
+import org.bukkit.entity.Hanging;
-+import org.bukkit.entity.Painting;
+import org.bukkit.event.hanging.HangingBreakEvent;
-+import org.bukkit.event.painting.PaintingBreakEvent;
+// CraftBukkit end
+
public abstract class EntityHanging extends Entity {
- private int c;
-@@ -30,30 +37,34 @@
+ private static final Predicate<Entity> c = new Predicate() {
+@@ -38,30 +43,39 @@
this.updateBoundingBox();
}
-- private void updateBoundingBox() {
+- protected void updateBoundingBox() {
- if (this.direction != null) {
- double d0 = (double) this.blockPosition.getX() + 0.5D;
- double d1 = (double) this.blockPosition.getY() + 0.5D;
@@ -31,15 +29,15 @@
+ Placing here as it's more likely to be noticed as something which needs to be updated
+ then something in a CraftBukkit file.
+ */
-+ public static AxisAlignedBB calculateBoundingBox(BlockPosition blockPosition, EnumDirection direction, int width, int height) {
++ public static AxisAlignedBB calculateBoundingBox(Entity entity, BlockPosition blockPosition, EnumDirection direction, int width, int height) {
+ double d0 = (double) blockPosition.getX() + 0.5D;
+ double d1 = (double) blockPosition.getY() + 0.5D;
+ double d2 = (double) blockPosition.getZ() + 0.5D;
double d3 = 0.46875D;
-- double d4 = this.a(this.l());
-- double d5 = this.a(this.m());
-+ double d4 = width % 32 == 0 ? 0.5D : 0.0D;
-+ double d5 = height % 32 == 0 ? 0.5D : 0.0D;
+- double d4 = this.a(this.getWidth());
+- double d5 = this.a(this.getHeight());
++ double d4 = a(width);
++ double d5 = a(height);
- d0 -= (double) this.direction.getAdjacentX() * 0.46875D;
- d2 -= (double) this.direction.getAdjacentZ() * 0.46875D;
@@ -54,9 +52,14 @@
- this.locX = d0;
- this.locY = d1;
- this.locZ = d2;
-- double d6 = (double) this.l();
-- double d7 = (double) this.m();
-- double d8 = (double) this.l();
+- double d6 = (double) this.getWidth();
+- double d7 = (double) this.getHeight();
+- double d8 = (double) this.getWidth();
++ if (entity != null) {
++ entity.locX = d0;
++ entity.locY = d1;
++ entity.locZ = d2;
++ }
+ double d6 = (double) width;
+ double d7 = (double) height;
+ double d8 = (double) width;
@@ -66,7 +69,7 @@
d8 = 1.0D;
} else {
d6 = 1.0D;
-@@ -62,7 +73,18 @@
+@@ -70,11 +84,18 @@
d6 /= 32.0D;
d7 /= 32.0D;
d8 /= 32.0D;
@@ -74,24 +77,25 @@
+ return new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8);
+ }
+
-+ private void updateBoundingBox() {
++ protected void updateBoundingBox() {
+ if (this.direction != null) {
+ // CraftBukkit start code moved in to calculateBoundingBox
-+ AxisAlignedBB bb = calculateBoundingBox(this.blockPosition, this.direction, this.l(), this.m());
-+ this.locX = (bb.a + bb.d) / 2.0D;
-+ this.locY = (bb.b + bb.e) / 2.0D;
-+ this.locZ = (bb.c + bb.f) / 2.0D;
-+ this.a(bb);
++ this.a(calculateBoundingBox(this, this.blockPosition, this.direction, this.getWidth(), this.getHeight()));
+ // CraftBukkit end
}
}
-@@ -77,6 +99,32 @@
- if (this.c++ == 100 && !this.world.isClientSide) {
- this.c = 0;
+- private double a(int i) {
++ private static double a(int i) {
+ return i % 32 == 0 ? 0.5D : 0.0D;
+ }
+
+@@ -85,6 +106,24 @@
+ if (this.d++ == 100 && !this.world.isClientSide) {
+ this.d = 0;
if (!this.dead && !this.survives()) {
+ // CraftBukkit start - fire break events
-+ Material material = this.world.getType(new BlockPosition(this)).getBlock().getMaterial();
++ Material material = this.world.getType(new BlockPosition(this)).getMaterial();
+ HangingBreakEvent.RemoveCause cause;
+
+ if (!material.equals(Material.AIR)) {
@@ -104,55 +108,36 @@
+ HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), cause);
+ this.world.getServer().getPluginManager().callEvent(event);
+
-+ PaintingBreakEvent paintingEvent = null;
-+ if (this instanceof EntityPainting) {
-+ // Fire old painting event until it can be removed
-+ paintingEvent = new PaintingBreakEvent((Painting) this.getBukkitEntity(), PaintingBreakEvent.RemoveCause.valueOf(cause.name()));
-+ paintingEvent.setCancelled(event.isCancelled());
-+ this.world.getServer().getPluginManager().callEvent(paintingEvent);
-+ }
-+
-+ if (dead || event.isCancelled() || (paintingEvent != null && paintingEvent.isCancelled())) {
++ if (dead || event.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
this.die();
- this.b((Entity) null);
+ this.a((Entity) null);
}
-@@ -138,6 +186,32 @@
+@@ -135,6 +174,21 @@
return false;
} else {
if (!this.dead && !this.world.isClientSide) {
+ // CraftBukkit start - fire break events
+ HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.DEFAULT);
-+ PaintingBreakEvent paintingEvent = null;
+ if (damagesource.getEntity() != null) {
+ event = new org.bukkit.event.hanging.HangingBreakByEntityEvent((Hanging) this.getBukkitEntity(), damagesource.getEntity() == null ? null : damagesource.getEntity().getBukkitEntity());
-+
-+ if (this instanceof EntityPainting) {
-+ // Fire old painting event until it can be removed
-+ paintingEvent = new org.bukkit.event.painting.PaintingBreakByEntityEvent((Painting) this.getBukkitEntity(), damagesource.getEntity() == null ? null : damagesource.getEntity().getBukkitEntity());
-+ }
+ } else if (damagesource.isExplosion()) {
+ event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.EXPLOSION);
+ }
+
+ this.world.getServer().getPluginManager().callEvent(event);
+
-+ if (paintingEvent != null) {
-+ paintingEvent.setCancelled(event.isCancelled());
-+ this.world.getServer().getPluginManager().callEvent(paintingEvent);
-+ }
-+
-+ if (this.dead || event.isCancelled() || (paintingEvent != null && paintingEvent.isCancelled())) {
++ if (this.dead || event.isCancelled()) {
+ return true;
+ }
+ // CraftBukkit end
+
this.die();
- this.ac();
- this.b(damagesource.getEntity());
-@@ -149,6 +223,18 @@
+ this.ao();
+ this.a(damagesource.getEntity());
+@@ -146,6 +200,18 @@
public void move(double d0, double d1, double d2) {
if (!this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) {
@@ -169,14 +154,14 @@
+ // CraftBukkit end
+
this.die();
- this.b((Entity) null);
+ this.a((Entity) null);
}
-@@ -156,7 +242,7 @@
+@@ -153,7 +219,7 @@
}
public void g(double d0, double d1, double d2) {
- if (!this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) {
+ if (false && !this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { // CraftBukkit - not needed
this.die();
- this.b((Entity) null);
+ this.a((Entity) null);
}