Continue migration

This commit is contained in:
Aleksey 2021-04-12 16:34:13 +03:00
parent 47ed597358
commit 33dbfbe633
263 changed files with 1450 additions and 1486 deletions

View file

@ -12,28 +12,28 @@ import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.SpawnReason;
import net.minecraft.world.entity.ai.control.MoveControl;
import net.minecraft.world.entity.attribute.DefaultAttributeContainer;
import net.minecraft.world.entity.attribute.EntityAttributes;
import net.minecraft.world.entity.attribute.Attributes;
import net.minecraft.world.entity.damage.DamageSource;
import net.minecraft.world.entity.data.DataTracker;
import net.minecraft.world.entity.data.TrackedData;
import net.minecraft.world.entity.data.TrackedDataHandlerRegistry;
import net.minecraft.world.entity.effect.StatusEffectInstance;
import net.minecraft.world.entity.effect.StatusEffects;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.passive.SchoolingFishEntity;
import net.minecraft.world.entity.player.PlayerEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.tags.FluidTags;
import net.minecraft.core.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.Mth;
import net.minecraft.world.LocalDifficulty;
import net.minecraft.world.ServerWorldAccess;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.Level;
import ru.betterend.registry.EndBiomes;
import ru.betterend.registry.EndItems;
@ -50,7 +50,7 @@ public class CubozoaEntity extends SchoolingFishEntity {
}
@Override
public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason,
public EntityData initialize(ServerLevelAccessor world, LocalDifficulty difficulty, SpawnReason spawnReason,
EntityData entityData, CompoundTag entityTag) {
EntityData data = super.initialize(world, difficulty, spawnReason, entityData, entityTag);
if (EndBiomes.getFromBiome(world.getBiome(getBlockPos())) == EndBiomes.SULPHUR_SPRINGS) {
@ -86,8 +86,8 @@ public class CubozoaEntity extends SchoolingFishEntity {
}
public static DefaultAttributeContainer.Builder createMobAttributes() {
return LivingEntity.createLivingAttributes().add(EntityAttributes.GENERIC_MAX_HEALTH, 2.0)
.add(EntityAttributes.GENERIC_FOLLOW_RANGE, 16.0).add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.5);
return LivingEntity.createLivingAttributes().add(Attributes.MAX_HEALTH, 2.0).add(Attributes.FOLLOW_RANGE, 16.0)
.add(Attributes.MOVEMENT_SPEED, 0.5);
}
public int getVariant() {
@ -98,7 +98,7 @@ public class CubozoaEntity extends SchoolingFishEntity {
return this.dataTracker.get(SCALE) / 32F + 0.75F;
}
public static boolean canSpawn(EntityType<CubozoaEntity> type, ServerWorldAccess world, SpawnReason spawnReason,
public static boolean canSpawn(EntityType<CubozoaEntity> type, ServerLevelAccessor world, SpawnReason spawnReason,
BlockPos pos, Random random) {
Box box = new Box(pos).expand(16);
List<CubozoaEntity> list = world.getEntitiesByClass(CubozoaEntity.class, box, (entity) -> {
@ -131,14 +131,14 @@ public class CubozoaEntity extends SchoolingFishEntity {
}
@Override
public void onPlayerCollision(PlayerEntity player) {
public void onPlayerCollision(Player player) {
if (player instanceof ServerPlayer && player.damage(DamageSource.mob(this), 0.5F)) {
if (!this.isSilent()) {
((ServerPlayer) player).networkHandler
.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PUFFERFISH_STING, 0.0F));
}
if (random.nextBoolean()) {
player.addStatusEffect(new StatusEffectInstance(StatusEffects.POISON, 20, 0));
player.addMobEffect(new MobEffectInstance(MobEffects.POISON, 20, 0));
}
}
}
@ -154,7 +154,7 @@ public class CubozoaEntity extends SchoolingFishEntity {
}
if (this.state == MoveControl.State.MOVE_TO && !this.entity.getNavigation().isIdle()) {
float f = (float) (this.speed * this.entity.getAttributeValue(EntityAttributes.GENERIC_MOVEMENT_SPEED));
float f = (float) (this.speed * this.entity.getAttributeValue(Attributes.MOVEMENT_SPEED));
this.entity.setMovementSpeed(Mth.lerp(0.125F, this.entity.getMovementSpeed(), f));
double d = this.targetX - this.entity.getX();
double e = this.targetY - this.entity.getY();

View file

@ -20,16 +20,16 @@ import net.minecraft.world.entity.ai.pathing.EntityNavigation;
import net.minecraft.world.entity.ai.pathing.Path;
import net.minecraft.world.entity.ai.pathing.PathNodeType;
import net.minecraft.world.entity.attribute.DefaultAttributeContainer;
import net.minecraft.world.entity.attribute.EntityAttributes;
import net.minecraft.world.entity.attribute.Attributes;
import net.minecraft.world.entity.mob.MobEntity;
import net.minecraft.world.entity.passive.AnimalEntity;
import net.minecraft.world.entity.passive.PassiveEntity;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.core.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.Heightmap.Type;
import net.minecraft.world.ServerWorldAccess;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.Level;
import net.minecraft.world.WorldView;
import ru.betterend.registry.EndEntities;
@ -48,9 +48,9 @@ public class DragonflyEntity extends AnimalEntity implements Flutterer {
}
public static DefaultAttributeContainer.Builder createMobAttributes() {
return LivingEntity.createLivingAttributes().add(EntityAttributes.GENERIC_MAX_HEALTH, 8.0D)
.add(EntityAttributes.GENERIC_FOLLOW_RANGE, 16.0D).add(EntityAttributes.GENERIC_FLYING_SPEED, 1.0D)
.add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.1D);
return LivingEntity.createLivingAttributes().add(Attributes.MAX_HEALTH, 8.0D)
.add(Attributes.FOLLOW_RANGE, 16.0D).add(Attributes.FLYING_SPEED, 1.0D)
.add(Attributes.MOVEMENT_SPEED, 0.1D);
}
@Override
@ -190,7 +190,7 @@ public class DragonflyEntity extends AnimalEntity implements Flutterer {
return EndEntities.DRAGONFLY.create(world);
}
public static boolean canSpawn(EntityType<DragonflyEntity> type, ServerWorldAccess world, SpawnReason spawnReason,
public static boolean canSpawn(EntityType<DragonflyEntity> type, ServerLevelAccessor world, SpawnReason spawnReason,
BlockPos pos, Random random) {
int y = world.getChunk(pos).sampleHeightmap(Type.WORLD_SURFACE, pos.getX() & 15, pos.getY() & 15);
return y > 0 && pos.getY() >= y;

View file

@ -10,7 +10,7 @@ import net.minecraft.world.entity.ItemEntity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.SpawnReason;
import net.minecraft.world.entity.attribute.DefaultAttributeContainer;
import net.minecraft.world.entity.attribute.EntityAttributes;
import net.minecraft.world.entity.attribute.Attributes;
import net.minecraft.world.entity.damage.DamageSource;
import net.minecraft.world.entity.data.DataTracker;
import net.minecraft.world.entity.data.TrackedData;
@ -19,12 +19,12 @@ import net.minecraft.world.entity.passive.SchoolingFishEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.core.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.world.LocalDifficulty;
import net.minecraft.world.ServerWorldAccess;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.Level;
import ru.betterend.registry.EndBiomes;
import ru.betterend.registry.EndItems;
@ -43,7 +43,7 @@ public class EndFishEntity extends SchoolingFishEntity {
}
@Override
public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason,
public EntityData initialize(ServerLevelAccessor world, LocalDifficulty difficulty, SpawnReason spawnReason,
EntityData entityData, CompoundTag entityTag) {
EntityData data = super.initialize(world, difficulty, spawnReason, entityData, entityTag);
if (EndBiomes.getFromBiome(world.getBiome(getBlockPos())) == EndBiomes.SULPHUR_SPRINGS) {
@ -115,8 +115,8 @@ public class EndFishEntity extends SchoolingFishEntity {
}
public static DefaultAttributeContainer.Builder createMobAttributes() {
return LivingEntity.createLivingAttributes().add(EntityAttributes.GENERIC_MAX_HEALTH, 2.0)
.add(EntityAttributes.GENERIC_FOLLOW_RANGE, 16.0).add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.75);
return LivingEntity.createLivingAttributes().add(Attributes.MAX_HEALTH, 2.0).add(Attributes.FOLLOW_RANGE, 16.0)
.add(Attributes.MOVEMENT_SPEED, 0.75);
}
public int getVariant() {
@ -127,7 +127,7 @@ public class EndFishEntity extends SchoolingFishEntity {
return this.dataTracker.get(SCALE) / 32F + 0.75F;
}
public static boolean canSpawn(EntityType<EndFishEntity> type, ServerWorldAccess world, SpawnReason spawnReason,
public static boolean canSpawn(EntityType<EndFishEntity> type, ServerLevelAccessor world, SpawnReason spawnReason,
BlockPos pos, Random random) {
Box box = new Box(pos).expand(16);
List<EndFishEntity> list = world.getEntitiesByClass(EndFishEntity.class, box, (entity) -> {

View file

@ -15,15 +15,15 @@ import net.minecraft.world.entity.ai.control.MoveControl;
import net.minecraft.world.entity.ai.goal.FollowTargetGoal;
import net.minecraft.world.entity.ai.goal.Goal;
import net.minecraft.world.entity.attribute.DefaultAttributeContainer;
import net.minecraft.world.entity.attribute.EntityAttributes;
import net.minecraft.world.entity.attribute.Attributes;
import net.minecraft.world.entity.damage.DamageSource;
import net.minecraft.world.entity.data.DataTracker;
import net.minecraft.world.entity.data.TrackedData;
import net.minecraft.world.entity.data.TrackedDataHandlerRegistry;
import net.minecraft.world.entity.effect.StatusEffects;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.mob.SlimeEntity;
import net.minecraft.world.entity.passive.IronGolemEntity;
import net.minecraft.world.entity.player.PlayerEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.nbt.CompoundTag;
@ -35,9 +35,9 @@ import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.Mth;
import net.minecraft.world.LocalDifficulty;
import net.minecraft.world.ServerWorldAccess;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.Level;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.level.biome.Biome;
import ru.betterend.interfaces.ISlime;
import ru.betterend.registry.EndBiomes;
import ru.betterend.util.BlocksHelper;
@ -59,21 +59,20 @@ public class EndSlimeEntity extends SlimeEntity {
this.goalSelector.add(2, new FaceTowardTargetGoal());
this.goalSelector.add(3, new RandomLookGoal());
this.goalSelector.add(5, new MoveGoal());
this.targetSelector.add(1,
new FollowTargetGoal<PlayerEntity>(this, PlayerEntity.class, 10, true, false, (livingEntity) -> {
return Math.abs(livingEntity.getY() - this.getY()) <= 4.0D;
}));
this.targetSelector.add(1, new FollowTargetGoal<Player>(this, Player.class, 10, true, false, (livingEntity) -> {
return Math.abs(livingEntity.getY() - this.getY()) <= 4.0D;
}));
this.targetSelector.add(3, new FollowTargetGoal<IronGolemEntity>(this, IronGolemEntity.class, true));
}
public static DefaultAttributeContainer.Builder createMobAttributes() {
return LivingEntity.createLivingAttributes().add(EntityAttributes.GENERIC_MAX_HEALTH, 1.0D)
.add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 1.0D).add(EntityAttributes.GENERIC_FOLLOW_RANGE, 16.0D)
.add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.15D);
return LivingEntity.createLivingAttributes().add(Attributes.MAX_HEALTH, 1.0D)
.add(Attributes.ATTACK_DAMAGE, 1.0D).add(Attributes.FOLLOW_RANGE, 16.0D)
.add(Attributes.MOVEMENT_SPEED, 0.15D);
}
@Override
public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason,
public EntityData initialize(ServerLevelAccessor world, LocalDifficulty difficulty, SpawnReason spawnReason,
EntityData entityData, CompoundTag entityTag) {
EntityData data = super.initialize(world, difficulty, spawnReason, entityData, entityTag);
EndBiome biome = EndBiomes.getFromBiome(world.getBiome(getBlockPos()));
@ -198,18 +197,18 @@ public class EndSlimeEntity extends SlimeEntity {
return this.dataTracker.get(VARIANT) == 0;
}
public static boolean canSpawn(EntityType<EndSlimeEntity> type, ServerWorldAccess world, SpawnReason spawnReason,
public static boolean canSpawn(EntityType<EndSlimeEntity> type, ServerLevelAccessor world, SpawnReason spawnReason,
BlockPos pos, Random random) {
return random.nextInt(16) == 0 || isPermanentBiome(world, pos)
|| (notManyEntities(world, pos, 32, 3) && isWaterNear(world, pos, 32, 8));
}
private static boolean isPermanentBiome(ServerWorldAccess world, BlockPos pos) {
private static boolean isPermanentBiome(ServerLevelAccessor world, BlockPos pos) {
Biome biome = world.getBiome(pos);
return EndBiomes.getFromBiome(biome) == EndBiomes.CHORUS_FOREST;
}
private static boolean notManyEntities(ServerWorldAccess world, BlockPos pos, int radius, int maxCount) {
private static boolean notManyEntities(ServerLevelAccessor world, BlockPos pos, int radius, int maxCount) {
Box box = new Box(pos).expand(radius);
List<EndSlimeEntity> list = world.getEntitiesByClass(EndSlimeEntity.class, box, (entity) -> {
return true;
@ -217,7 +216,7 @@ public class EndSlimeEntity extends SlimeEntity {
return list.size() <= maxCount;
}
private static boolean isWaterNear(ServerWorldAccess world, BlockPos pos, int radius, int radius2) {
private static boolean isWaterNear(ServerLevelAccessor world, BlockPos pos, int radius, int radius2) {
for (int x = pos.getX() - radius; x <= pos.getX() + radius; x++) {
POS.setX(x);
for (int z = pos.getZ() - radius; z <= pos.getZ() + radius; z++) {
@ -293,7 +292,7 @@ public class EndSlimeEntity extends SlimeEntity {
return EndSlimeEntity.this.getTarget() == null
&& (EndSlimeEntity.this.onGround || EndSlimeEntity.this.isTouchingWater()
|| EndSlimeEntity.this.isInLava()
|| EndSlimeEntity.this.hasStatusEffect(StatusEffects.LEVITATION))
|| EndSlimeEntity.this.hasMobEffect(MobEffects.LEVITATION))
&& EndSlimeEntity.this.getMoveControl() instanceof EndSlimeMoveControl;
}
@ -321,8 +320,7 @@ public class EndSlimeEntity extends SlimeEntity {
} else if (!livingEntity.isAlive()) {
return false;
} else {
return livingEntity instanceof PlayerEntity && ((PlayerEntity) livingEntity).abilities.invulnerable
? false
return livingEntity instanceof Player && ((Player) livingEntity).abilities.invulnerable ? false
: EndSlimeEntity.this.getMoveControl() instanceof EndSlimeMoveControl;
}
}
@ -338,7 +336,7 @@ public class EndSlimeEntity extends SlimeEntity {
return false;
} else if (!livingEntity.isAlive()) {
return false;
} else if (livingEntity instanceof PlayerEntity && ((PlayerEntity) livingEntity).abilities.invulnerable) {
} else if (livingEntity instanceof Player && ((Player) livingEntity).abilities.invulnerable) {
return false;
} else {
return --this.ticksLeft > 0;
@ -381,8 +379,8 @@ public class EndSlimeEntity extends SlimeEntity {
} else {
this.state = MoveControl.State.WAIT;
if (this.entity.isOnGround()) {
this.entity.setMovementSpeed((float) (this.speed
* this.entity.getAttributeValue(EntityAttributes.GENERIC_MOVEMENT_SPEED)));
this.entity.setMovementSpeed(
(float) (this.speed * this.entity.getAttributeValue(Attributes.MOVEMENT_SPEED)));
if (this.ticksUntilJump-- <= 0) {
this.ticksUntilJump = EndSlimeEntity.this.getTicksUntilNextJump();
if (this.jumpOften) {
@ -400,8 +398,8 @@ public class EndSlimeEntity extends SlimeEntity {
this.entity.setMovementSpeed(0.0F);
}
} else {
this.entity.setMovementSpeed((float) (this.speed
* this.entity.getAttributeValue(EntityAttributes.GENERIC_MOVEMENT_SPEED)));
this.entity.setMovementSpeed(
(float) (this.speed * this.entity.getAttributeValue(Attributes.MOVEMENT_SPEED)));
}
}

View file

@ -14,17 +14,17 @@ import net.minecraft.world.entity.ai.goal.LookAtEntityGoal;
import net.minecraft.world.entity.ai.goal.MeleeAttackGoal;
import net.minecraft.world.entity.ai.goal.WanderAroundFarGoal;
import net.minecraft.world.entity.attribute.DefaultAttributeContainer;
import net.minecraft.world.entity.attribute.EntityAttributes;
import net.minecraft.world.entity.attribute.Attributes;
import net.minecraft.world.entity.damage.DamageSource;
import net.minecraft.world.entity.effect.StatusEffectInstance;
import net.minecraft.world.entity.effect.StatusEffects;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.mob.HostileEntity;
import net.minecraft.world.entity.player.PlayerEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.core.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.world.ServerWorldAccess;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.Level;
import ru.betterend.registry.EndSounds;
import ru.betterend.util.MHelper;
@ -38,15 +38,15 @@ public class ShadowWalkerEntity extends HostileEntity {
protected void initGoals() {
this.goalSelector.add(2, new AttackGoal(this, 1.0D, false));
this.goalSelector.add(7, new WanderAroundFarGoal(this, 1.0D));
this.goalSelector.add(8, new LookAtEntityGoal(this, PlayerEntity.class, 8.0F));
this.goalSelector.add(8, new LookAtEntityGoal(this, Player.class, 8.0F));
this.goalSelector.add(8, new LookAroundGoal(this));
this.targetSelector.add(2, new FollowTargetGoal<PlayerEntity>(this, PlayerEntity.class, true));
this.targetSelector.add(2, new FollowTargetGoal<Player>(this, Player.class, true));
}
public static DefaultAttributeContainer.Builder createMobAttributes() {
return HostileEntity.createHostileAttributes().add(EntityAttributes.GENERIC_FOLLOW_RANGE, 35.0)
.add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.15).add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 4.5)
.add(EntityAttributes.GENERIC_ARMOR, 2.0).add(EntityAttributes.ZOMBIE_SPAWN_REINFORCEMENTS);
return HostileEntity.createHostileAttributes().add(Attributes.FOLLOW_RANGE, 35.0)
.add(Attributes.MOVEMENT_SPEED, 0.15).add(Attributes.ATTACK_DAMAGE, 4.5).add(Attributes.ARMOR, 2.0)
.add(Attributes.ZOMBIE_SPAWN_REINFORCEMENTS);
}
@Override
@ -94,14 +94,14 @@ public class ShadowWalkerEntity extends HostileEntity {
boolean attack = super.tryAttack(target);
if (attack && target instanceof LivingEntity) {
LivingEntity living = (LivingEntity) target;
if (!(living.hasStatusEffect(StatusEffects.BLINDNESS))) {
living.addStatusEffect(new StatusEffectInstance(StatusEffects.BLINDNESS, 60));
if (!(living.hasMobEffect(MobEffects.BLINDNESS))) {
living.addMobEffect(new MobEffectInstance(MobEffects.BLINDNESS, 60));
}
}
return attack;
}
public static boolean canSpawn(EntityType<ShadowWalkerEntity> type, ServerWorldAccess world,
public static boolean canSpawn(EntityType<ShadowWalkerEntity> type, ServerLevelAccessor world,
SpawnReason spawnReason, BlockPos pos, Random random) {
if (HostileEntity.canSpawnInDark(type, world, spawnReason, pos, random)) {
Box box = new Box(pos).expand(16);

View file

@ -24,7 +24,7 @@ import net.minecraft.world.entity.ai.pathing.BirdNavigation;
import net.minecraft.world.entity.ai.pathing.EntityNavigation;
import net.minecraft.world.entity.ai.pathing.PathNodeType;
import net.minecraft.world.entity.attribute.DefaultAttributeContainer;
import net.minecraft.world.entity.attribute.EntityAttributes;
import net.minecraft.world.entity.attribute.Attributes;
import net.minecraft.world.entity.damage.DamageSource;
import net.minecraft.world.entity.mob.MobEntity;
import net.minecraft.world.entity.passive.AnimalEntity;
@ -41,9 +41,9 @@ import net.minecraft.core.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d;
import net.minecraft.core.Registry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.Heightmap.Type;
import net.minecraft.world.ServerWorldAccess;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.Level;
import ru.betterend.BetterEnd;
import ru.betterend.blocks.BlockProperties;
@ -68,9 +68,9 @@ public class SilkMothEntity extends AnimalEntity implements Flutterer {
}
public static DefaultAttributeContainer.Builder createMobAttributes() {
return LivingEntity.createLivingAttributes().add(EntityAttributes.GENERIC_MAX_HEALTH, 2.0D)
.add(EntityAttributes.GENERIC_FOLLOW_RANGE, 16.0D).add(EntityAttributes.GENERIC_FLYING_SPEED, 0.4D)
.add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.1D);
return LivingEntity.createLivingAttributes().add(Attributes.MAX_HEALTH, 2.0D)
.add(Attributes.FOLLOW_RANGE, 16.0D).add(Attributes.FLYING_SPEED, 0.4D)
.add(Attributes.MOVEMENT_SPEED, 0.1D);
}
public void setHive(Level world, BlockPos hive) {
@ -92,7 +92,7 @@ public class SilkMothEntity extends AnimalEntity implements Flutterer {
hivePos = NbtHelper.toBlockPos(tag.getCompound("HivePos"));
ResourceLocation worldID = new ResourceLocation(tag.getString("HiveWorld"));
try {
hiveWorld = world.getServer().getLevel(RegistryKey.of(Registry.DIMENSION, worldID));
hiveWorld = world.getServer().getLevel(ResourceKey.of(Registry.DIMENSION, worldID));
} catch (Exception e) {
BetterEnd.LOGGER.warning("Silk Moth Hive Level {} is missing!", worldID);
hivePos = null;
@ -174,13 +174,13 @@ public class SilkMothEntity extends AnimalEntity implements Flutterer {
this.world.spawnEntity(drop);
}
public static boolean canSpawn(EntityType<SilkMothEntity> type, ServerWorldAccess world, SpawnReason spawnReason,
public static boolean canSpawn(EntityType<SilkMothEntity> type, ServerLevelAccessor world, SpawnReason spawnReason,
BlockPos pos, Random random) {
int y = world.getChunk(pos).sampleHeightmap(Type.WORLD_SURFACE, pos.getX() & 15, pos.getY() & 15);
return y > 0 && pos.getY() >= y && notManyEntities(world, pos, 32, 1);
}
private static boolean notManyEntities(ServerWorldAccess world, BlockPos pos, int radius, int maxCount) {
private static boolean notManyEntities(ServerLevelAccessor world, BlockPos pos, int radius, int maxCount) {
Box box = new Box(pos).expand(radius);
List<SilkMothEntity> list = world.getEntitiesByClass(SilkMothEntity.class, box, (entity) -> true);
return list.size() <= maxCount;