PaperMC/nms-patches/EntityItemFrame.patch

95 lines
4.2 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityItemFrame.java
+++ b/net/minecraft/server/EntityItemFrame.java
@@ -11,7 +11,7 @@
private static final DataWatcherObject<ItemStack> ITEM = DataWatcher.a(EntityItemFrame.class, DataWatcherRegistry.g);
private static final DataWatcherObject<Integer> g = DataWatcher.a(EntityItemFrame.class, DataWatcherRegistry.b);
private float an = 1.0F;
- private boolean ao;
+ public boolean ao; // PAIL private -> public // PAIL rename isFixed
public EntityItemFrame(EntityTypes<? extends EntityItemFrame> entitytypes, World world) {
super(entitytypes, world);
2020-06-25 02:00:00 +02:00
@@ -53,16 +53,27 @@
@Override
protected void updateBoundingBox() {
if (this.direction != null) {
+ // CraftBukkit start code moved in to calculateBoundingBox
+ this.a(calculateBoundingBox(this, this.blockPosition, this.direction, this.getHangingWidth(), this.getHangingHeight()));
+ // CraftBukkit end
+ }
+ }
+
+ // CraftBukkit start - break out BB calc into own method
+ public static AxisAlignedBB calculateBoundingBox(@Nullable Entity entity, BlockPosition blockPosition, EnumDirection direction, int width, int height) {
+ {
double d0 = 0.46875D;
2019-12-10 23:00:00 +01:00
- double d1 = (double) this.blockPosition.getX() + 0.5D - (double) this.direction.getAdjacentX() * 0.46875D;
- double d2 = (double) this.blockPosition.getY() + 0.5D - (double) this.direction.getAdjacentY() * 0.46875D;
- double d3 = (double) this.blockPosition.getZ() + 0.5D - (double) this.direction.getAdjacentZ() * 0.46875D;
-
- this.setPositionRaw(d1, d2, d3);
- double d4 = (double) this.getHangingWidth();
- double d5 = (double) this.getHangingHeight();
- double d6 = (double) this.getHangingWidth();
2020-06-25 02:00:00 +02:00
- EnumDirection.EnumAxis enumdirection_enumaxis = this.direction.n();
2019-12-10 23:00:00 +01:00
+ double d1 = (double) blockPosition.getX() + 0.5D - (double) direction.getAdjacentX() * 0.46875D;
+ double d2 = (double) blockPosition.getY() + 0.5D - (double) direction.getAdjacentY() * 0.46875D;
+ double d3 = (double) blockPosition.getZ() + 0.5D - (double) direction.getAdjacentZ() * 0.46875D;
+
+ if (entity != null) {
2019-12-10 23:00:00 +01:00
+ entity.setPositionRaw(d1, d2, d3);
+ }
2019-12-10 23:00:00 +01:00
+ double d4 = (double) width;
+ double d5 = (double) height;
+ double d6 = (double) width;
2020-06-25 02:00:00 +02:00
+ EnumDirection.EnumAxis enumdirection_enumaxis = direction.n();
switch (enumdirection_enumaxis) {
case X:
2020-06-25 02:00:00 +02:00
@@ -78,9 +89,10 @@
2019-12-10 23:00:00 +01:00
d4 /= 32.0D;
d5 /= 32.0D;
d6 /= 32.0D;
- this.a(new AxisAlignedBB(d1 - d4, d2 - d5, d3 - d6, d1 + d4, d2 + d5, d3 + d6));
+ return new AxisAlignedBB(d1 - d4, d2 - d5, d3 - d6, d1 + d4, d2 + d5, d3 + d6);
}
}
+ // CraftBukkit end
@Override
public boolean survives() {
2020-06-25 02:00:00 +02:00
@@ -130,6 +142,11 @@
return false;
2016-11-17 02:41:03 +01:00
} else if (!damagesource.isExplosion() && !this.getItem().isEmpty()) {
2015-02-26 23:41:06 +01:00
if (!this.world.isClientSide) {
+ // CraftBukkit start - fire EntityDamageEvent
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false) || this.dead) {
+ return true;
+ }
+ // CraftBukkit end
2016-02-29 22:32:46 +01:00
this.b(damagesource.getEntity(), false);
2020-06-25 02:00:00 +02:00
this.playSound(SoundEffects.ENTITY_ITEM_FRAME_REMOVE_ITEM, 1.0F, 1.0F);
2018-07-15 02:00:00 +02:00
}
2020-06-25 02:00:00 +02:00
@@ -217,6 +234,12 @@
}
2018-10-22 21:00:00 +02:00
public void setItem(ItemStack itemstack, boolean flag) {
+ // CraftBukkit start
+ this.setItem(itemstack, flag, true);
+ }
+
+ public void setItem(ItemStack itemstack, boolean flag, boolean playSound) {
+ // CraftBukkit end
if (!itemstack.isEmpty()) {
itemstack = itemstack.cloneItemStack();
itemstack.setCount(1);
2020-06-25 02:00:00 +02:00
@@ -224,7 +247,7 @@
}
2019-04-23 04:00:00 +02:00
this.getDataWatcher().set(EntityItemFrame.ITEM, itemstack);
- if (!itemstack.isEmpty()) {
+ if (!itemstack.isEmpty() && playSound) { // CraftBukkit
2020-06-25 02:00:00 +02:00
this.playSound(SoundEffects.ENTITY_ITEM_FRAME_ADD_ITEM, 1.0F, 1.0F);
}