summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntitySnowman.patch
blob: 4464a1a008ad76df1b131547367e90c960bb8d93 (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
--- ../work/decompile-8eb82bde//net/minecraft/server/EntitySnowman.java	2014-11-28 17:43:43.161707434 +0000
+++ src/main/java/net/minecraft/server/EntitySnowman.java	2014-11-28 17:38:18.000000000 +0000
@@ -1,5 +1,11 @@
 package net.minecraft.server;
 
+// 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 {
 
     public EntitySnowman(World world) {
@@ -31,7 +37,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
             }
 
             for (int l = 0; l < 4; ++l) {
@@ -39,7 +45,17 @@
                 j = MathHelper.floor(this.locY);
                 k = MathHelper.floor(this.locZ + (double) ((float) (l / 2 % 2 * 2 - 1) * 0.25F));
                 if (this.world.getType(new BlockPosition(i, j, k)).getBlock().getMaterial() == Material.AIR && this.world.getBiome(new BlockPosition(i, 0, k)).a(new BlockPosition(i, j, k)) < 0.8F && Blocks.SNOW_LAYER.canPlace(this.world, new BlockPosition(i, j, k))) {
-                    this.world.setTypeUpdate(new BlockPosition(i, j, k), 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
                 }
             }
         }