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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
--- a/net/minecraft/world/entity/monster/Skeleton.java
+++ b/net/minecraft/world/entity/monster/Skeleton.java
@@ -7,16 +7,20 @@
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.damagesource.DamageSource;
+import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
+import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Items;
+import net.minecraft.world.level.IMaterial;
import net.minecraft.world.level.Level;
public class Skeleton extends AbstractSkeleton {
+
private static final int TOTAL_CONVERSION_TIME = 300;
- private static final EntityDataAccessor<Boolean> DATA_STRAY_CONVERSION_ID = SynchedEntityData.defineId(Skeleton.class, EntityDataSerializers.BOOLEAN);
+ public static final EntityDataAccessor<Boolean> DATA_STRAY_CONVERSION_ID = SynchedEntityData.defineId(Skeleton.class, EntityDataSerializers.BOOLEAN);
public static final String CONVERSION_TAG = "StrayConversionTime";
private int inPowderSnowTime;
- private int conversionTime;
+ public int conversionTime;
public Skeleton(EntityType<? extends Skeleton> entityType, Level level) {
super(entityType, level);
@@ -25,15 +29,15 @@
@Override
protected void defineSynchedData() {
super.defineSynchedData();
- this.getEntityData().define(DATA_STRAY_CONVERSION_ID, false);
+ this.getEntityData().define(Skeleton.DATA_STRAY_CONVERSION_ID, false);
}
public boolean isFreezeConverting() {
- return this.getEntityData().get(DATA_STRAY_CONVERSION_ID);
+ return (Boolean) this.getEntityData().get(Skeleton.DATA_STRAY_CONVERSION_ID);
}
public void setFreezeConverting(boolean isFrozen) {
- this.entityData.set(DATA_STRAY_CONVERSION_ID, isFrozen);
+ this.entityData.set(Skeleton.DATA_STRAY_CONVERSION_ID, isFrozen);
}
@Override
@@ -46,12 +50,12 @@
if (!this.level().isClientSide && this.isAlive() && !this.isNoAi()) {
if (this.isInPowderSnow) {
if (this.isFreezeConverting()) {
- this.conversionTime--;
+ --this.conversionTime;
if (this.conversionTime < 0) {
this.doFreezeConversion();
}
} else {
- this.inPowderSnowTime++;
+ ++this.inPowderSnowTime;
if (this.inPowderSnowTime >= 140) {
this.startFreezeConversion(300);
}
@@ -77,18 +81,20 @@
if (compound.contains("StrayConversionTime", 99) && compound.getInt("StrayConversionTime") > -1) {
this.startFreezeConversion(compound.getInt("StrayConversionTime"));
}
+
}
- private void startFreezeConversion(int conversionTime) {
+ public void startFreezeConversion(int conversionTime) {
this.conversionTime = conversionTime;
this.setFreezeConverting(true);
}
protected void doFreezeConversion() {
- this.convertTo(EntityType.STRAY, true);
+ this.convertTo(EntityType.STRAY, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.FROZEN, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.FROZEN); // CraftBukkit - add spawn and transform reasons
if (!this.isSilent()) {
- this.level().levelEvent(null, 1048, this.blockPosition(), 0);
+ this.level().levelEvent((Player) null, 1048, this.blockPosition(), 0);
}
+
}
@Override
@@ -119,9 +125,16 @@
@Override
protected void dropCustomDeathLoot(DamageSource source, int looting, boolean recentlyHit) {
super.dropCustomDeathLoot(source, looting, recentlyHit);
- if (source.getEntity() instanceof Creeper creeper && creeper.canDropMobsSkull()) {
- creeper.increaseDroppedSkulls();
- this.spawnAtLocation(Items.SKELETON_SKULL);
+ Entity entity = source.getEntity();
+
+ if (entity instanceof Creeper) {
+ Creeper entitycreeper = (Creeper) entity;
+
+ if (entitycreeper.canDropMobsSkull()) {
+ entitycreeper.increaseDroppedSkulls();
+ this.spawnAtLocation((IMaterial) Items.SKELETON_SKULL);
+ }
}
+
}
}
|