| 1 | package net.minecraft.world.entity.monster.skeleton;
|
| 2 |
|
| 3 | import com.google.common.annotations.VisibleForTesting;
|
| 4 | import net.minecraft.network.syncher.EntityDataAccessor;
|
| 5 | import net.minecraft.network.syncher.EntityDataSerializers;
|
| 6 | import net.minecraft.network.syncher.SynchedEntityData;
|
| 7 | import net.minecraft.sounds.SoundEvent;
|
| 8 | import net.minecraft.sounds.SoundEvents;
|
| 9 | import net.minecraft.world.damagesource.DamageSource;
|
| 10 | import net.minecraft.world.entity.ConversionTracker;
|
| 11 | import net.minecraft.world.entity.EntityType;
|
| 12 | import net.minecraft.world.entity.EntityTypes;
|
| 13 | import net.minecraft.world.level.Level;
|
| 14 | import net.minecraft.world.level.storage.ValueInput;
|
| 15 | import net.minecraft.world.level.storage.ValueOutput;
|
| 16 |
|
| 17 | public class Skeleton extends AbstractSkeleton {
|
| 18 | private static final EntityDataAccessor<Boolean> DATA_STRAY_CONVERSION_ID = SynchedEntityData.defineId(Skeleton.class, EntityDataSerializers.BOOLEAN);
|
| 19 | private final ConversionTracker<AbstractSkeleton> freezingTracker = new ConversionTracker<>(
|
| 20 | this, DATA_STRAY_CONVERSION_ID, () -> EntityTypes.STRAY, () -> 1048, () -> this.isInPowderSnow, "FreezingTime", 140, "StrayConversionTime", 300, null
|
| 21 | );
|
| 22 |
|
| 23 | public Skeleton(final EntityType<? extends Skeleton> type, final Level level) {
|
| 24 | super(type, level);
|
| 25 | }
|
| 26 |
|
| 27 | @Override
|
| 28 | protected void defineSynchedData(final SynchedEntityData.Builder entityData) {
|
| 29 | super.defineSynchedData(entityData);
|
| 30 | entityData.define(DATA_STRAY_CONVERSION_ID, false);
|
| 31 | }
|
| 32 |
|
| 33 | @Override
|
| 34 | public boolean isShaking() {
|
| 35 | return this.freezingTracker.isConverting();
|
| 36 | }
|
| 37 |
|
| 38 | @Override
|
| 39 | public void tick() {
|
| 40 | this.freezingTracker.tick();
|
| 41 | super.tick();
|
| 42 | }
|
| 43 |
|
| 44 | @Override
|
| 45 | protected void addAdditionalSaveData(final ValueOutput output) {
|
| 46 | super.addAdditionalSaveData(output);
|
| 47 | this.freezingTracker.addAdditionalSaveData(output);
|
| 48 | }
|
| 49 |
|
| 50 | @Override
|
| 51 | protected void readAdditionalSaveData(final ValueInput input) {
|
| 52 | super.readAdditionalSaveData(input);
|
| 53 | this.freezingTracker.readAdditionalSaveData(input);
|
| 54 | }
|
| 55 |
|
| 56 | @VisibleForTesting
|
| 57 | public void startFreezeConversion(final int time) {
|
| 58 | this.freezingTracker.startConversion(time);
|
| 59 | }
|
| 60 |
|
| 61 | @Override
|
| 62 | public boolean canFreeze() {
|
| 63 | return false;
|
| 64 | }
|
| 65 |
|
| 66 | @Override
|
| 67 | protected SoundEvent getAmbientSound() {
|
| 68 | return SoundEvents.SKELETON_AMBIENT;
|
| 69 | }
|
| 70 |
|
| 71 | @Override
|
| 72 | protected SoundEvent getHurtSound(final DamageSource source) {
|
| 73 | return SoundEvents.SKELETON_HURT;
|
| 74 | }
|
| 75 |
|
| 76 | @Override
|
| 77 | protected SoundEvent getDeathSound() {
|
| 78 | return SoundEvents.SKELETON_DEATH;
|
| 79 | }
|
| 80 |
|
| 81 | @Override
|
| 82 | protected SoundEvent getStepSound() {
|
| 83 | return SoundEvents.SKELETON_STEP;
|
| 84 | }
|
| 85 | }
|
| 86 |
|