summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntitySnowman.patch
blob: 8edc685c0782c1367427653c0aba2407ef34fc9f (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
33
34
35
36
37
38
39
40
41
42
--- a/net/minecraft/server/EntitySnowman.java
+++ b/net/minecraft/server/EntitySnowman.java
@@ -1,6 +1,11 @@
 package net.minecraft.server;
 
 import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import org.bukkit.event.block.EntityBlockFormEvent;
+// CraftBukkit end
 
 public class EntitySnowman extends EntityGolem implements IRangedEntity {
 
@@ -42,7 +47,7 @@
             }
 
             if (this.world.getBiome(new BlockPosition(i, 0, k)).a(new BlockPosition(i, j, k)) > 1.0F) {
-                this.damageEntity(DamageSource.BURN, 1.0F);
+                this.damageEntity(CraftEventFactory.MELTING, 1.0F); // CraftBukkit - DamageSource.BURN -> CraftEventFactory.MELTING
             }
 
             if (!this.world.getGameRules().getBoolean("mobGriefing")) {
@@ -56,7 +61,17 @@
                 BlockPosition blockposition = new BlockPosition(i, j, k);
 
                 if (this.world.getType(blockposition).getMaterial() == Material.AIR && this.world.getBiome(new BlockPosition(i, 0, k)).a(blockposition) < 0.8F && Blocks.SNOW_LAYER.canPlace(this.world, blockposition)) {
-                    this.world.setTypeUpdate(blockposition, Blocks.SNOW_LAYER.getBlockData());
+                    // CraftBukkit start
+                    org.bukkit.block.BlockState blockState = this.world.getWorld().getBlockAt(i, j, k).getState();
+                    blockState.setType(CraftMagicNumbers.getMaterial(Blocks.SNOW_LAYER));
+
+                    EntityBlockFormEvent event = new EntityBlockFormEvent(this.getBukkitEntity(), blockState.getBlock(), blockState);
+                    this.world.getServer().getPluginManager().callEvent(event);
+
+                    if(!event.isCancelled()) {
+                        blockState.update(true);
+                    }
+                    // CraftBukkit end
                 }
             }
         }