83 lines
2.3 KiB
Java
83 lines
2.3 KiB
Java
package net.minecraft.world.entity.monster;
|
|
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.server.level.ServerLevel;
|
|
import net.minecraft.sounds.SoundEvent;
|
|
import net.minecraft.sounds.SoundEvents;
|
|
import net.minecraft.util.RandomSource;
|
|
import net.minecraft.world.damagesource.DamageSource;
|
|
import net.minecraft.world.effect.MobEffectInstance;
|
|
import net.minecraft.world.effect.MobEffects;
|
|
import net.minecraft.world.entity.Entity;
|
|
import net.minecraft.world.entity.EntitySpawnReason;
|
|
import net.minecraft.world.entity.EntityType;
|
|
import net.minecraft.world.entity.LivingEntity;
|
|
import net.minecraft.world.item.ItemStack;
|
|
import net.minecraft.world.level.Level;
|
|
import net.minecraft.world.level.ServerLevelAccessor;
|
|
|
|
public class Husk extends Zombie {
|
|
public Husk(EntityType<? extends Husk> entityType, Level level) {
|
|
super(entityType, level);
|
|
}
|
|
|
|
public static boolean checkHuskSpawnRules(
|
|
EntityType<Husk> entityType, ServerLevelAccessor level, EntitySpawnReason spawnReason, BlockPos pos, RandomSource random
|
|
) {
|
|
return checkMonsterSpawnRules(entityType, level, spawnReason, pos, random) && (EntitySpawnReason.isSpawner(spawnReason) || level.canSeeSky(pos));
|
|
}
|
|
|
|
@Override
|
|
protected boolean isSunSensitive() {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
protected SoundEvent getAmbientSound() {
|
|
return SoundEvents.HUSK_AMBIENT;
|
|
}
|
|
|
|
@Override
|
|
protected SoundEvent getHurtSound(DamageSource damageSource) {
|
|
return SoundEvents.HUSK_HURT;
|
|
}
|
|
|
|
@Override
|
|
protected SoundEvent getDeathSound() {
|
|
return SoundEvents.HUSK_DEATH;
|
|
}
|
|
|
|
@Override
|
|
protected SoundEvent getStepSound() {
|
|
return SoundEvents.HUSK_STEP;
|
|
}
|
|
|
|
@Override
|
|
public boolean doHurtTarget(ServerLevel level, Entity source) {
|
|
boolean bl = super.doHurtTarget(level, source);
|
|
if (bl && this.getMainHandItem().isEmpty() && source instanceof LivingEntity) {
|
|
float f = this.level().getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty();
|
|
((LivingEntity)source).addEffect(new MobEffectInstance(MobEffects.HUNGER, 140 * (int)f), this);
|
|
}
|
|
|
|
return bl;
|
|
}
|
|
|
|
@Override
|
|
protected boolean convertsInWater() {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
protected void doUnderWaterConversion() {
|
|
this.convertToZombieType(EntityType.ZOMBIE);
|
|
if (!this.isSilent()) {
|
|
this.level().levelEvent(null, 1041, this.blockPosition(), 0);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected ItemStack getSkull() {
|
|
return ItemStack.EMPTY;
|
|
}
|
|
}
|