mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-25 12:05:53 +01:00
SPIGOT-5940: EntityChangeBlockEvent is not called for villager emptying composter
This commit is contained in:
parent
b6a876bc34
commit
5209a4f731
@ -9,6 +9,15 @@
|
|||||||
Optional<GlobalPos> optional = entityvillager.getBehaviorController().getMemory(MemoryModuleType.JOB_SITE);
|
Optional<GlobalPos> optional = entityvillager.getBehaviorController().getMemory(MemoryModuleType.JOB_SITE);
|
||||||
|
|
||||||
if (optional.isPresent()) {
|
if (optional.isPresent()) {
|
||||||
|
@@ -28,7 +28,7 @@
|
||||||
|
|
||||||
|
private void a(WorldServer worldserver, EntityVillager entityvillager, GlobalPos globalpos, IBlockData iblockdata) {
|
||||||
|
if ((Integer) iblockdata.get(BlockComposter.a) == 8) {
|
||||||
|
- iblockdata = BlockComposter.d(iblockdata, (World) worldserver, globalpos.getBlockPosition());
|
||||||
|
+ iblockdata = BlockComposter.d(iblockdata, (World) worldserver, globalpos.getBlockPosition(), entityvillager); // CraftBukkit
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = 20;
|
||||||
@@ -52,7 +52,7 @@
|
@@ -52,7 +52,7 @@
|
||||||
i -= k1;
|
i -= k1;
|
||||||
|
|
||||||
|
@ -19,12 +19,20 @@
|
|||||||
for (int i = 0; i < 8; ++i) {
|
for (int i = 0; i < 8; ++i) {
|
||||||
avoxelshape[i] = VoxelShapes.a(BlockComposter.c, Block.a(2.0D, (double) Math.max(2, 1 + i * 2), 2.0D, 14.0D, 16.0D, 14.0D), OperatorBoolean.ONLY_FIRST);
|
avoxelshape[i] = VoxelShapes.a(BlockComposter.c, Block.a(2.0D, (double) Math.max(2, 1 + i * 2), 2.0D, 14.0D, 16.0D, 14.0D), OperatorBoolean.ONLY_FIRST);
|
||||||
}
|
}
|
||||||
@@ -163,11 +167,18 @@
|
@@ -156,18 +160,25 @@
|
||||||
|
|
||||||
|
return EnumInteractionResult.a(world.isClientSide);
|
||||||
|
} else if (i == 8) {
|
||||||
|
- d(iblockdata, world, blockposition);
|
||||||
|
+ d(iblockdata, world, blockposition, (Entity) null); // CraftBukkit - no event for players
|
||||||
|
return EnumInteractionResult.a(world.isClientSide);
|
||||||
|
} else {
|
||||||
|
return EnumInteractionResult.PASS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- public static IBlockData a(IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition) {
|
- public static IBlockData a(IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition) {
|
||||||
+ public static IBlockData a(IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition, EntityVillager entity) { // CraftBukkit
|
+ public static IBlockData a(IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition, Entity entity) { // CraftBukkit
|
||||||
int i = (Integer) iblockdata.get(BlockComposter.a);
|
int i = (Integer) iblockdata.get(BlockComposter.a);
|
||||||
|
|
||||||
if (i < 7 && BlockComposter.b.containsKey(itemstack.getItem())) {
|
if (i < 7 && BlockComposter.b.containsKey(itemstack.getItem())) {
|
||||||
@ -40,7 +48,24 @@
|
|||||||
|
|
||||||
itemstack.subtract(1);
|
itemstack.subtract(1);
|
||||||
worldserver.triggerEffect(1500, blockposition, iblockdata != iblockdata1 ? 1 : 0);
|
worldserver.triggerEffect(1500, blockposition, iblockdata != iblockdata1 ? 1 : 0);
|
||||||
@@ -203,10 +214,16 @@
|
@@ -177,7 +188,15 @@
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- public static IBlockData d(IBlockData iblockdata, World world, BlockPosition blockposition) {
|
||||||
|
+ // CraftBukkit start
|
||||||
|
+ public static IBlockData d(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
|
||||||
|
+ if (entity != null) {
|
||||||
|
+ IBlockData iblockdata1 = d(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition);
|
||||||
|
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1).isCancelled()) {
|
||||||
|
+ return iblockdata;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // CraftBukkit end
|
||||||
|
if (!world.isClientSide) {
|
||||||
|
float f = 0.7F;
|
||||||
|
double d0 = (double) (world.random.nextFloat() * 0.7F) + 0.15000000596046448D;
|
||||||
|
@@ -203,10 +222,16 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IBlockData b(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) {
|
private static IBlockData b(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) {
|
||||||
@ -58,7 +83,7 @@
|
|||||||
return iblockdata;
|
return iblockdata;
|
||||||
} else {
|
} else {
|
||||||
int j = i + 1;
|
int j = i + 1;
|
||||||
@@ -254,7 +271,8 @@
|
@@ -254,7 +279,8 @@
|
||||||
public IWorldInventory a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
|
public IWorldInventory a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
|
||||||
int i = (Integer) iblockdata.get(BlockComposter.a);
|
int i = (Integer) iblockdata.get(BlockComposter.a);
|
||||||
|
|
||||||
@ -68,7 +93,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
static class ContainerInput extends InventorySubcontainer implements IWorldInventory {
|
static class ContainerInput extends InventorySubcontainer implements IWorldInventory {
|
||||||
@@ -266,6 +284,7 @@
|
@@ -266,6 +292,7 @@
|
||||||
|
|
||||||
public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
|
public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
|
||||||
super(1);
|
super(1);
|
||||||
@ -76,7 +101,7 @@
|
|||||||
this.a = iblockdata;
|
this.a = iblockdata;
|
||||||
this.b = generatoraccess;
|
this.b = generatoraccess;
|
||||||
this.c = blockposition;
|
this.c = blockposition;
|
||||||
@@ -318,6 +337,7 @@
|
@@ -318,6 +345,7 @@
|
||||||
this.blockData = iblockdata;
|
this.blockData = iblockdata;
|
||||||
this.generatorAccess = generatoraccess;
|
this.generatorAccess = generatoraccess;
|
||||||
this.blockPosition = blockposition;
|
this.blockPosition = blockposition;
|
||||||
@ -84,7 +109,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -342,15 +362,23 @@
|
@@ -342,15 +370,23 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
|
Loading…
Reference in New Issue
Block a user