2025-11-24 22:52:51 +03:00

131 lines
3.8 KiB
Java

/*
* Decompiled with CFR 0.152.
*/
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.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.monster.Monster;
import net.minecraft.world.entity.monster.Slime;
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> type, Level level) {
super((EntityType<? extends Slime>)type, level);
}
public static AttributeSupplier.Builder createAttributes() {
return Monster.createMonsterAttributes().add(Attributes.MOVEMENT_SPEED, 0.2f);
}
public static boolean checkMagmaCubeSpawnRules(EntityType<MagmaCube> type, LevelAccessor level, EntitySpawnReason spawnReason, BlockPos pos, RandomSource random) {
return level.getDifficulty() != Difficulty.PEACEFUL;
}
@Override
public void setSize(int size, boolean updateHealth) {
super.setSize(size, updateHealth);
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 movement = this.getDeltaMovement();
float sizeJumpBoostPower = (float)this.getSize() * 0.1f;
this.setDeltaMovement(movement.x, this.getJumpPower() + sizeJumpBoostPower, movement.z);
this.needsSync = true;
}
@Override
protected void jumpInLiquid(TagKey<Fluid> type) {
if (type == FluidTags.LAVA) {
Vec3 movement = this.getDeltaMovement();
this.setDeltaMovement(movement.x, 0.22f + (float)this.getSize() * 0.05f, movement.z);
this.needsSync = true;
} else {
super.jumpInLiquid(type);
}
}
@Override
protected boolean isDealsDamage() {
return this.isEffectiveAi();
}
@Override
protected float getAttackDamage() {
return super.getAttackDamage() + 2.0f;
}
@Override
protected SoundEvent getHurtSound(DamageSource source) {
if (this.isTiny()) {
return SoundEvents.MAGMA_CUBE_HURT_SMALL;
}
return SoundEvents.MAGMA_CUBE_HURT;
}
@Override
protected SoundEvent getDeathSound() {
if (this.isTiny()) {
return SoundEvents.MAGMA_CUBE_DEATH_SMALL;
}
return SoundEvents.MAGMA_CUBE_DEATH;
}
@Override
protected SoundEvent getSquishSound() {
if (this.isTiny()) {
return SoundEvents.MAGMA_CUBE_SQUISH_SMALL;
}
return SoundEvents.MAGMA_CUBE_SQUISH;
}
@Override
protected SoundEvent getJumpSound() {
return SoundEvents.MAGMA_CUBE_JUMP;
}
}