116 lines
3.1 KiB
Java
116 lines
3.1 KiB
Java
package net.minecraft.world.entity.monster;
|
|
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.core.particles.ParticleOptions;
|
|
import net.minecraft.core.particles.ParticleTypes;
|
|
import net.minecraft.sounds.SoundEvent;
|
|
import net.minecraft.sounds.SoundEvents;
|
|
import net.minecraft.tags.FluidTags;
|
|
import net.minecraft.tags.TagKey;
|
|
import net.minecraft.util.RandomSource;
|
|
import net.minecraft.world.Difficulty;
|
|
import net.minecraft.world.damagesource.DamageSource;
|
|
import net.minecraft.world.entity.EntitySpawnReason;
|
|
import net.minecraft.world.entity.EntityType;
|
|
import net.minecraft.world.entity.ai.attributes.Attributes;
|
|
import net.minecraft.world.entity.ai.attributes.AttributeSupplier.Builder;
|
|
import net.minecraft.world.level.Level;
|
|
import net.minecraft.world.level.LevelAccessor;
|
|
import net.minecraft.world.level.material.Fluid;
|
|
import net.minecraft.world.phys.Vec3;
|
|
|
|
public class MagmaCube extends Slime {
|
|
public MagmaCube(EntityType<? extends MagmaCube> entityType, Level level) {
|
|
super(entityType, level);
|
|
}
|
|
|
|
public static Builder createAttributes() {
|
|
return Monster.createMonsterAttributes().add(Attributes.MOVEMENT_SPEED, 0.2F);
|
|
}
|
|
|
|
public static boolean checkMagmaCubeSpawnRules(
|
|
EntityType<MagmaCube> entityType, LevelAccessor level, EntitySpawnReason spawnReason, BlockPos pos, RandomSource random
|
|
) {
|
|
return level.getDifficulty() != Difficulty.PEACEFUL;
|
|
}
|
|
|
|
@Override
|
|
public void setSize(int size, boolean resetHealth) {
|
|
super.setSize(size, resetHealth);
|
|
this.getAttribute(Attributes.ARMOR).setBaseValue(size * 3);
|
|
}
|
|
|
|
@Override
|
|
public float getLightLevelDependentMagicValue() {
|
|
return 1.0F;
|
|
}
|
|
|
|
@Override
|
|
protected ParticleOptions getParticleType() {
|
|
return ParticleTypes.FLAME;
|
|
}
|
|
|
|
@Override
|
|
public boolean isOnFire() {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
protected int getJumpDelay() {
|
|
return super.getJumpDelay() * 4;
|
|
}
|
|
|
|
@Override
|
|
protected void decreaseSquish() {
|
|
this.targetSquish *= 0.9F;
|
|
}
|
|
|
|
@Override
|
|
public void jumpFromGround() {
|
|
Vec3 vec3 = this.getDeltaMovement();
|
|
float f = this.getSize() * 0.1F;
|
|
this.setDeltaMovement(vec3.x, this.getJumpPower() + f, vec3.z);
|
|
this.hasImpulse = true;
|
|
}
|
|
|
|
@Override
|
|
protected void jumpInLiquid(TagKey<Fluid> fluidTag) {
|
|
if (fluidTag == FluidTags.LAVA) {
|
|
Vec3 vec3 = this.getDeltaMovement();
|
|
this.setDeltaMovement(vec3.x, 0.22F + this.getSize() * 0.05F, vec3.z);
|
|
this.hasImpulse = true;
|
|
} else {
|
|
super.jumpInLiquid(fluidTag);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected boolean isDealsDamage() {
|
|
return this.isEffectiveAi();
|
|
}
|
|
|
|
@Override
|
|
protected float getAttackDamage() {
|
|
return super.getAttackDamage() + 2.0F;
|
|
}
|
|
|
|
@Override
|
|
protected SoundEvent getHurtSound(DamageSource damageSource) {
|
|
return this.isTiny() ? SoundEvents.MAGMA_CUBE_HURT_SMALL : SoundEvents.MAGMA_CUBE_HURT;
|
|
}
|
|
|
|
@Override
|
|
protected SoundEvent getDeathSound() {
|
|
return this.isTiny() ? SoundEvents.MAGMA_CUBE_DEATH_SMALL : SoundEvents.MAGMA_CUBE_DEATH;
|
|
}
|
|
|
|
@Override
|
|
protected SoundEvent getSquishSound() {
|
|
return this.isTiny() ? SoundEvents.MAGMA_CUBE_SQUISH_SMALL : SoundEvents.MAGMA_CUBE_SQUISH;
|
|
}
|
|
|
|
@Override
|
|
protected SoundEvent getJumpSound() {
|
|
return SoundEvents.MAGMA_CUBE_JUMP;
|
|
}
|
|
}
|