summaryrefslogtreecommitdiffstats
path: root/nms-patches/EnchantmentFrostWalker.patch
blob: 91fda45bf223c7d9adbb2272eb39e3ea4f8a1978 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
--- a/net/minecraft/server/EnchantmentFrostWalker.java
+++ b/net/minecraft/server/EnchantmentFrostWalker.java
@@ -1,5 +1,8 @@
 package net.minecraft.server;
 
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import org.bukkit.event.block.EntityBlockFormEvent;
+
 import java.util.Iterator;
 
 public class EnchantmentFrostWalker extends Enchantment {
@@ -42,8 +45,18 @@
                         IBlockData iblockdata1 = world.getType(blockposition_mutableblockposition1);
 
                         if (iblockdata1.getMaterial() == Material.WATER && ((Integer) iblockdata1.get(BlockFluids.LEVEL)).intValue() == 0 && world.a(Blocks.FROSTED_ICE, blockposition_mutableblockposition1, false, EnumDirection.DOWN, (Entity) null)) {
-                            world.setTypeUpdate(blockposition_mutableblockposition1, Blocks.FROSTED_ICE.getBlockData());
-                            world.a(blockposition_mutableblockposition1.h(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120));
+                            // CraftBukkit Start - Call EntityBlockFormEvent for Frost Walker
+                            org.bukkit.block.BlockState blockState = world.getWorld().getBlockAt(blockposition_mutableblockposition1.getX(), blockposition_mutableblockposition1.getY(), blockposition_mutableblockposition1.getZ()).getState();
+                            blockState.setType(CraftMagicNumbers.getMaterial(Blocks.FROSTED_ICE));
+
+                            EntityBlockFormEvent event = new EntityBlockFormEvent(entityliving.bukkitEntity, blockState.getBlock(), blockState);
+                            world.getServer().getPluginManager().callEvent(event);
+
+                            if (!event.isCancelled()) {
+                                blockState.update(true);
+                                world.a(blockposition_mutableblockposition1.h(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120));
+                            }
+                            // CraftBukkit End
                         }
                     }
                 }