|
| 1 | +package barch.mc_extended.Entities; |
| 2 | + |
| 3 | +import net.minecraft.entity.EntityType; |
| 4 | +import net.minecraft.entity.SpawnReason; |
| 5 | +import net.minecraft.entity.attribute.DefaultAttributeContainer; |
| 6 | +import net.minecraft.entity.attribute.EntityAttributes; |
| 7 | +import net.minecraft.entity.damage.DamageSource; |
| 8 | +import net.minecraft.entity.mob.HostileEntity; |
| 9 | +import net.minecraft.entity.mob.SlimeEntity; |
| 10 | +import net.minecraft.fluid.Fluid; |
| 11 | +import net.minecraft.particle.ParticleEffect; |
| 12 | +import net.minecraft.particle.ParticleTypes; |
| 13 | +import net.minecraft.registry.tag.FluidTags; |
| 14 | +import net.minecraft.registry.tag.TagKey; |
| 15 | +import net.minecraft.sound.SoundEvent; |
| 16 | +import net.minecraft.sound.SoundEvents; |
| 17 | +import net.minecraft.util.math.BlockPos; |
| 18 | +import net.minecraft.util.math.Vec3d; |
| 19 | +import net.minecraft.util.math.random.Random; |
| 20 | +import net.minecraft.world.Difficulty; |
| 21 | +import net.minecraft.world.World; |
| 22 | +import net.minecraft.world.WorldAccess; |
| 23 | +import net.minecraft.world.WorldView; |
| 24 | + |
| 25 | +public class EnderCubeEntity |
| 26 | +extends SlimeEntity { |
| 27 | + public EnderCubeEntity(EntityType<? extends EnderCubeEntity> entityType, World world) { |
| 28 | + super((EntityType<? extends SlimeEntity>)entityType, world); |
| 29 | + } |
| 30 | + |
| 31 | + public static DefaultAttributeContainer.Builder createEnderCubeAttributes() { |
| 32 | + return HostileEntity.createHostileAttributes().add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.2f); |
| 33 | + } |
| 34 | + |
| 35 | + public static boolean canEnderCubeSpawn(EntityType<EnderCubeEntity> type, WorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) { |
| 36 | + return world.getDifficulty() != Difficulty.PEACEFUL; |
| 37 | + } |
| 38 | + |
| 39 | + @Override |
| 40 | + public boolean canSpawn(WorldView world) { |
| 41 | + return world.doesNotIntersectEntities(this) && !world.containsFluid(this.getBoundingBox()); |
| 42 | + } |
| 43 | + |
| 44 | + @Override |
| 45 | + public void setSize(int size, boolean heal) { |
| 46 | + super.setSize(size, heal); |
| 47 | + this.getAttributeInstance(EntityAttributes.GENERIC_ARMOR).setBaseValue(size * 3); |
| 48 | + } |
| 49 | + |
| 50 | + @Override |
| 51 | + public float getBrightnessAtEyes() { |
| 52 | + return 1.0f; |
| 53 | + } |
| 54 | + |
| 55 | + @Override |
| 56 | + protected ParticleEffect getParticles() { |
| 57 | + return ParticleTypes.PORTAL; |
| 58 | + } |
| 59 | + |
| 60 | + @Override |
| 61 | + public boolean isOnFire() { |
| 62 | + return false; |
| 63 | + } |
| 64 | + |
| 65 | + @Override |
| 66 | + protected int getTicksUntilNextJump() { |
| 67 | + return super.getTicksUntilNextJump() * 4; |
| 68 | + } |
| 69 | + |
| 70 | + @Override |
| 71 | + protected void updateStretch() { |
| 72 | + this.targetStretch *= 0.9f; |
| 73 | + } |
| 74 | + |
| 75 | + @Override |
| 76 | + protected void jump() { |
| 77 | + Vec3d vec3d = this.getVelocity(); |
| 78 | + float f = (float)this.getSize() * 0.1f; |
| 79 | + this.setVelocity(vec3d.x, this.getJumpVelocity() + f, vec3d.z); |
| 80 | + this.velocityDirty = true; |
| 81 | + } |
| 82 | + |
| 83 | + @Override |
| 84 | + protected void swimUpward(TagKey<Fluid> fluid) { |
| 85 | + if (fluid == FluidTags.LAVA) { |
| 86 | + Vec3d vec3d = this.getVelocity(); |
| 87 | + this.setVelocity(vec3d.x, 0.22f + (float)this.getSize() * 0.05f, vec3d.z); |
| 88 | + this.velocityDirty = true; |
| 89 | + } else { |
| 90 | + super.swimUpward(fluid); |
| 91 | + } |
| 92 | + } |
| 93 | + |
| 94 | + @Override |
| 95 | + protected boolean canAttack() { |
| 96 | + return this.canMoveVoluntarily(); |
| 97 | + } |
| 98 | + |
| 99 | + @Override |
| 100 | + protected float getDamageAmount() { |
| 101 | + return super.getDamageAmount() + 4.0f; |
| 102 | + } |
| 103 | + |
| 104 | + @Override |
| 105 | + protected SoundEvent getHurtSound(DamageSource source) { |
| 106 | + if (this.isSmall()) { |
| 107 | + return SoundEvents.ENTITY_MAGMA_CUBE_HURT_SMALL; |
| 108 | + } |
| 109 | + return SoundEvents.ENTITY_MAGMA_CUBE_HURT; |
| 110 | + } |
| 111 | + |
| 112 | + @Override |
| 113 | + protected SoundEvent getDeathSound() { |
| 114 | + if (this.isSmall()) { |
| 115 | + return SoundEvents.ENTITY_MAGMA_CUBE_DEATH_SMALL; |
| 116 | + } |
| 117 | + return SoundEvents.ENTITY_MAGMA_CUBE_DEATH; |
| 118 | + } |
| 119 | + |
| 120 | + @Override |
| 121 | + protected SoundEvent getSquishSound() { |
| 122 | + if (this.isSmall()) { |
| 123 | + return SoundEvents.ENTITY_MAGMA_CUBE_SQUISH_SMALL; |
| 124 | + } |
| 125 | + return SoundEvents.ENTITY_MAGMA_CUBE_SQUISH; |
| 126 | + } |
| 127 | + |
| 128 | + @Override |
| 129 | + protected SoundEvent getJumpSound() { |
| 130 | + return SoundEvents.ENTITY_MAGMA_CUBE_JUMP; |
| 131 | + } |
| 132 | +} |
| 133 | + |
0 commit comments