summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nms-patches/BlockRedstoneOre.patch2
-rw-r--r--nms-patches/BlockSoil.patch2
-rw-r--r--nms-patches/BlockWaterLily.patch2
-rw-r--r--nms-patches/EntityEnderman.patch2
-rw-r--r--nms-patches/EntityFallingBlock.patch4
-rw-r--r--nms-patches/EntityPotion.patch2
-rw-r--r--nms-patches/EntityRabbit.patch4
-rw-r--r--nms-patches/EntitySilverfish.patch4
-rw-r--r--nms-patches/EntityWither.patch2
-rw-r--r--nms-patches/PathfinderGoalVillagerFarm.patch49
-rw-r--r--src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java4
11 files changed, 63 insertions, 14 deletions
diff --git a/nms-patches/BlockRedstoneOre.patch b/nms-patches/BlockRedstoneOre.patch
index f209a284..417cd311 100644
--- a/nms-patches/BlockRedstoneOre.patch
+++ b/nms-patches/BlockRedstoneOre.patch
@@ -56,7 +56,7 @@
this.playEffect(world, blockposition);
if (this == Blocks.REDSTONE_ORE) {
+ // CraftBukkit start
-+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition.getX(), blockposition.getY(), blockposition.getZ(), Blocks.LIT_REDSTONE_ORE, 0).isCancelled()) {
++ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.LIT_REDSTONE_ORE, 0).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
diff --git a/nms-patches/BlockSoil.patch b/nms-patches/BlockSoil.patch
index c8396b93..35c2fd56 100644
--- a/nms-patches/BlockSoil.patch
+++ b/nms-patches/BlockSoil.patch
@@ -45,7 +45,7 @@
+ return;
+ }
+
-+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition.getX(), blockposition.getY(), blockposition.getZ(), Blocks.DIRT, 0).isCancelled()) {
++ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.DIRT, 0).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
diff --git a/nms-patches/BlockWaterLily.patch b/nms-patches/BlockWaterLily.patch
index 561facbf..83a6ae1d 100644
--- a/nms-patches/BlockWaterLily.patch
+++ b/nms-patches/BlockWaterLily.patch
@@ -5,7 +5,7 @@
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
super.a(world, blockposition, iblockdata, entity);
- if (entity instanceof EntityBoat) {
-+ if (entity instanceof EntityBoat && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition.getX(), blockposition.getY(), blockposition.getZ(), Blocks.AIR, 0).isCancelled()) { // CraftBukkit
++ if (entity instanceof EntityBoat && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR, 0).isCancelled()) { // CraftBukkit
world.setAir(new BlockPosition(blockposition), true);
}
diff --git a/nms-patches/EntityEnderman.patch b/nms-patches/EntityEnderman.patch
index 1c4a6acf..fbb2c661 100644
--- a/nms-patches/EntityEnderman.patch
+++ b/nms-patches/EntityEnderman.patch
@@ -56,7 +56,7 @@
if (iblockdata2 != null && this.a(world, blockposition, iblockdata2.getBlock(), iblockdata, iblockdata1)) {
+ // CraftBukkit start - Place event
-+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.a.getCarried().getBlock(), this.a.getCarried().getBlock().toLegacyData(this.a.getCarried())).isCancelled()) {
++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, this.a.getCarried().getBlock(), this.a.getCarried().getBlock().toLegacyData(this.a.getCarried())).isCancelled()) {
world.setTypeAndData(blockposition, iblockdata2, 3);
this.a.setCarried((IBlockData) null);
+ }
diff --git a/nms-patches/EntityFallingBlock.patch b/nms-patches/EntityFallingBlock.patch
index 2c1dcfd2..8dd4e980 100644
--- a/nms-patches/EntityFallingBlock.patch
+++ b/nms-patches/EntityFallingBlock.patch
@@ -14,7 +14,7 @@
if (this.ticksLived++ == 0) {
blockposition = new BlockPosition(this);
- if (this.world.getType(blockposition).getBlock() == block) {
-+ if (this.world.getType(blockposition).getBlock() == block && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition.getX(), blockposition.getY(), blockposition.getZ(), Blocks.AIR, 0).isCancelled()) {
++ if (this.world.getType(blockposition).getBlock() == block && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR, 0).isCancelled()) {
this.world.setAir(blockposition);
} else if (!this.world.isClientSide) {
this.die();
@@ -34,7 +34,7 @@
- if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null, (ItemStack) null) && !BlockFalling.i(this.world.getType(blockposition.down())) && this.world.setTypeAndData(blockposition, this.block, 3)) {
+ // CraftBukkit start
+ if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null, (ItemStack) null) && !BlockFalling.i(this.world.getType(blockposition.down()))) {
-+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.block.getBlock(), this.block.getBlock().toLegacyData(this.block)).isCancelled()) {
++ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.block.getBlock(), this.block.getBlock().toLegacyData(this.block)).isCancelled()) {
+ return;
+ }
+ this.world.setTypeAndData(blockposition, this.block, 3);
diff --git a/nms-patches/EntityPotion.patch b/nms-patches/EntityPotion.patch
index b6831b1a..ef720315 100644
--- a/nms-patches/EntityPotion.patch
+++ b/nms-patches/EntityPotion.patch
@@ -128,7 +128,7 @@
private void a(BlockPosition blockposition) {
if (this.world.getType(blockposition).getBlock() == Blocks.FIRE) {
-+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockposition.getX(), blockposition.getY(), blockposition.getZ(), Blocks.AIR, 0).isCancelled()) return; // CraftBukkit
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR, 0).isCancelled()) return; // CraftBukkit
this.world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 2);
}
diff --git a/nms-patches/EntityRabbit.patch b/nms-patches/EntityRabbit.patch
index 0ecf7855..ede26f1e 100644
--- a/nms-patches/EntityRabbit.patch
+++ b/nms-patches/EntityRabbit.patch
@@ -20,7 +20,7 @@
if (integer.intValue() == 0) {
+ // CraftBukkit start
-+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.c, blockposition.getX(), blockposition.getY(), blockposition.getZ(), Blocks.AIR, 0).isCancelled()) {
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.c, blockposition, Blocks.AIR, 0).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
@@ -30,7 +30,7 @@
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(
+ this.c,
-+ blockposition.getX(), blockposition.getY(), blockposition.getZ(),
++ blockposition,
+ block, block.toLegacyData(iblockdata.set(BlockCarrots.AGE, Integer.valueOf(integer.intValue() - 1)))
+ ).isCancelled()) {
+ return;
diff --git a/nms-patches/EntitySilverfish.patch b/nms-patches/EntitySilverfish.patch
index 8c698231..1763e175 100644
--- a/nms-patches/EntitySilverfish.patch
+++ b/nms-patches/EntitySilverfish.patch
@@ -5,7 +5,7 @@
if (BlockMonsterEggs.i(iblockdata)) {
+ // CraftBukkit start
-+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition.getX(), blockposition.getY(), blockposition.getZ(), Blocks.MONSTER_EGG, Block.getId(BlockMonsterEggs.getById(iblockdata.getBlock().toLegacyData(iblockdata)))).isCancelled()) {
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition, Blocks.MONSTER_EGG, Block.getId(BlockMonsterEggs.getById(iblockdata.getBlock().toLegacyData(iblockdata)))).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
@@ -17,7 +17,7 @@
if (iblockdata.getBlock() == Blocks.MONSTER_EGG) {
+ // CraftBukkit start
-+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ(), Blocks.AIR, 0).isCancelled()) {
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition1, Blocks.AIR, 0).isCancelled()) {
+ continue;
+ }
+ // CraftBukkit end
diff --git a/nms-patches/EntityWither.patch b/nms-patches/EntityWither.patch
index 4ba2f41d..3e25bf5b 100644
--- a/nms-patches/EntityWither.patch
+++ b/nms-patches/EntityWither.patch
@@ -60,7 +60,7 @@
if (iblockdata.getMaterial() != Material.AIR && a(block)) {
+ // CraftBukkit start
-+ if (CraftEventFactory.callEntityChangeBlockEvent(this, j2, k2, l2, Blocks.AIR, 0).isCancelled()) {
++ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR, 0).isCancelled()) {
+ continue;
+ }
+ // CraftBukkit end
diff --git a/nms-patches/PathfinderGoalVillagerFarm.patch b/nms-patches/PathfinderGoalVillagerFarm.patch
new file mode 100644
index 00000000..449a3a77
--- /dev/null
+++ b/nms-patches/PathfinderGoalVillagerFarm.patch
@@ -0,0 +1,49 @@
+--- a/net/minecraft/server/PathfinderGoalVillagerFarm.java
++++ b/net/minecraft/server/PathfinderGoalVillagerFarm.java
+@@ -48,7 +48,11 @@
+ Block block = iblockdata.getBlock();
+
+ if (this.f == 0 && block instanceof BlockCrops && ((BlockCrops) block).y(iblockdata)) {
+- world.setAir(blockposition, true);
++ // CraftBukkit start
++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.c, blockposition, Blocks.AIR, 0).isCancelled()) {
++ world.setAir(blockposition, true);
++ }
++ // CraftBukkit end
+ } else if (this.f == 1 && iblockdata.getMaterial() == Material.AIR) {
+ InventorySubcontainer inventorysubcontainer = this.c.dj();
+
+@@ -57,19 +61,29 @@
+ boolean flag = false;
+
+ if (itemstack != null) {
++ // CraftBukkit start
++ Block planted = null;
++
+ if (itemstack.getItem() == Items.WHEAT_SEEDS) {
+- world.setTypeAndData(blockposition, Blocks.WHEAT.getBlockData(), 3);
++ planted = Blocks.WHEAT;
+ flag = true;
+ } else if (itemstack.getItem() == Items.POTATO) {
+- world.setTypeAndData(blockposition, Blocks.POTATOES.getBlockData(), 3);
++ planted = Blocks.POTATOES;
+ flag = true;
+ } else if (itemstack.getItem() == Items.CARROT) {
+- world.setTypeAndData(blockposition, Blocks.CARROTS.getBlockData(), 3);
++ planted = Blocks.CARROTS;
+ flag = true;
+ } else if (itemstack.getItem() == Items.BEETROOT_SEEDS) {
+- world.setTypeAndData(blockposition, Blocks.BEETROOT.getBlockData(), 3);
++ planted = Blocks.BEETROOT;
+ flag = true;
+ }
++
++ if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.c, blockposition, planted, 0).isCancelled()) {
++ world.setTypeAndData(blockposition, planted.getBlockData(), 3);
++ } else {
++ flag = false;
++ }
++ // CraftBukkit end
+ }
+
+ if (flag) {
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 5c9ea4de..a42ecf3e 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -686,8 +686,8 @@ public class CraftEventFactory {
return callEntityChangeBlockEvent(entity.getBukkitEntity(), block, material, 0, cancelled);
}
- public static EntityChangeBlockEvent callEntityChangeBlockEvent(Entity entity, int x, int y, int z, net.minecraft.server.Block type, int data) {
- Block block = entity.world.getWorld().getBlockAt(x, y, z);
+ public static EntityChangeBlockEvent callEntityChangeBlockEvent(Entity entity, BlockPosition position, net.minecraft.server.Block type, int data) {
+ Block block = entity.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ());
Material material = CraftMagicNumbers.getMaterial(type);
return callEntityChangeBlockEvent(entity.getBukkitEntity(), block, material, data);