--- 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 DATA_STRAY_CONVERSION_ID = SynchedEntityData.defineId(Skeleton.class, EntityDataSerializers.BOOLEAN); + public static final EntityDataAccessor 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 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); + } } + } }