Fix new block data for EntityChangeBlockEvent
Also standardizes how to handle EntityChangeBlockEvent before a removeBlock or destroyBlock call. Always use 'state.getFluidState().createLegacyBlock()' to get the new state instead of just using the 'air' state. Also fixes the new block data for EntityBreakDoorEvent (a sub-event from EntityChangeBlockEvent) Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
This commit is contained in:
@@ -138,7 +138,7 @@
|
||||
boolean flag = movingobjectpositionblock.getBlockPos().equals(blockposition);
|
||||
|
||||
if (iblockdata.is(BlockTags.ENDERMAN_HOLDABLE) && flag) {
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, Blocks.AIR.defaultBlockState())) { // CraftBukkit - Place event
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, iblockdata.getFluidState().createLegacyBlock())) { // CraftBukkit - Place event // Paper - fix wrong block state
|
||||
world.removeBlock(blockposition, false);
|
||||
world.gameEvent((Holder) GameEvent.BLOCK_DESTROY, blockposition, GameEvent.Context.of(this.enderman, iblockdata));
|
||||
this.enderman.setCarriedBlock(iblockdata.getBlock().defaultBlockState());
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
if (block instanceof LeavesBlock) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState())) {
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.getFluidState().createLegacyBlock())) { // Paper - fix wrong block state
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
@@ -20,19 +20,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,6 +164,11 @@
|
||||
@@ -160,6 +164,12 @@
|
||||
Block block = iblockdata.getBlock();
|
||||
|
||||
if (block instanceof InfestedBlock) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition1, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState())) {
|
||||
+ BlockState afterState = getServerLevel(world).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? iblockdata.getFluidState().createLegacyBlock() : ((InfestedBlock) block).hostStateByInfested(world.getBlockState(blockposition1)); // Paper - fix wrong block state
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition1, afterState)) { // Paper - fix wrong block state
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (getServerLevel(world).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
|
||||
world.destroyBlock(blockposition1, true, this.silverfish);
|
||||
} else {
|
||||
@@ -229,9 +238,14 @@
|
||||
@@ -229,9 +239,14 @@
|
||||
BlockState iblockdata = world.getBlockState(blockposition);
|
||||
|
||||
if (InfestedBlock.isCompatibleHostBlock(iblockdata)) {
|
||||
|
||||
Reference in New Issue
Block a user