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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
--- a/net/minecraft/world/entity/animal/SnowGolem.java
+++ b/net/minecraft/world/entity/animal/SnowGolem.java
@@ -39,6 +40,9 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.Vec3;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackMob {
private static final EntityDataAccessor<Byte> DATA_PUMPKIN_ID = SynchedEntityData.defineId(SnowGolem.class, EntityDataSerializers.BYTE);
@@ -92,7 +100,7 @@
super.aiStep();
if (!this.level().isClientSide) {
if (this.level().getBiome(this.blockPosition()).is(BiomeTags.SNOW_GOLEM_MELTS)) {
- this.hurt(this.damageSources().onFire(), 1.0F);
+ this.hurt(this.damageSources().melting, 1.0F); // CraftBukkit - DamageSource.BURN -> CraftEventFactory.MELTING
}
if (!this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
@@ -101,14 +109,19 @@
BlockState blockState = Blocks.SNOW.defaultBlockState();
- for (int i = 0; i < 4; i++) {
- int floor = Mth.floor(this.getX() + (double)((float)(i % 2 * 2 - 1) * 0.25F));
- int floor1 = Mth.floor(this.getY());
- int floor2 = Mth.floor(this.getZ() + (double)((float)(i / 2 % 2 * 2 - 1) * 0.25F));
- BlockPos blockPos = new BlockPos(floor, floor1, floor2);
- if (this.level().getBlockState(blockPos).isAir() && blockState.canSurvive(this.level(), blockPos)) {
- this.level().setBlockAndUpdate(blockPos, blockState);
- this.level().gameEvent(GameEvent.BLOCK_PLACE, blockPos, GameEvent.Context.of(this, blockState));
+ for (int i = 0; i < 4; ++i) {
+ int j = Mth.floor(this.getX() + (double) ((float) (i % 2 * 2 - 1) * 0.25F));
+ int k = Mth.floor(this.getY());
+ int l = Mth.floor(this.getZ() + (double) ((float) (i / 2 % 2 * 2 - 1) * 0.25F));
+ BlockPos blockposition = new BlockPos(j, k, l);
+
+ if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
+ // CraftBukkit start
+ if (!CraftEventFactory.handleBlockFormEvent(this.level(), blockposition, iblockdata, this)) {
+ continue;
+ }
+ // CraftBukkit end
+ this.level().gameEvent(GameEvent.BLOCK_PLACE, blockposition, GameEvent.Context.of(this, iblockdata));
}
}
}
@@ -133,9 +148,15 @@
}
@Override
- protected InteractionResult mobInteract(Player player, InteractionHand hand) {
- ItemStack itemInHand = player.getItemInHand(hand);
- if (itemInHand.is(Items.SHEARS) && this.readyForShearing()) {
+ protected InteractionResult mobInteract(Player player, EnumHand hand) {
+ ItemStack itemstack = player.getItemInHand(hand);
+
+ if (itemstack.is(Items.SHEARS) && this.readyForShearing()) {
+ // CraftBukkit start
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(player, this, itemstack, hand)) {
+ return InteractionResult.PASS;
+ }
+ // CraftBukkit end
this.shear(SoundSource.PLAYERS);
this.gameEvent(GameEvent.SHEAR, player);
if (!this.level().isClientSide) {
@@ -153,7 +176,9 @@
this.level().playSound(null, this, SoundEvents.SNOW_GOLEM_SHEAR, category, 1.0F, 1.0F);
if (!this.level().isClientSide()) {
this.setPumpkin(false);
+ this.forceDrops = true; // CraftBukkit
this.spawnAtLocation(new ItemStack(Items.CARVED_PUMPKIN), 1.7F);
+ this.forceDrops = false; // CraftBukkit
}
}
|