Entities spawn fixes
This commit is contained in:
parent
e17271d1dd
commit
24b4b722c2
3 changed files with 17 additions and 3 deletions
|
@ -1,9 +1,13 @@
|
|||
package ru.betterend.entity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.entity.ai.goal.FollowTargetGoal;
|
||||
import net.minecraft.entity.ai.goal.LookAroundGoal;
|
||||
import net.minecraft.entity.ai.goal.LookAtEntityGoal;
|
||||
|
@ -19,6 +23,8 @@ import net.minecraft.entity.player.PlayerEntity;
|
|||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.world.ServerWorldAccess;
|
||||
import net.minecraft.world.World;
|
||||
import ru.betterend.registry.EndSounds;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
@ -106,6 +112,15 @@ public class EntityShadowWalker extends HostileEntity {
|
|||
return attack;
|
||||
}
|
||||
|
||||
public static boolean canSpawn(EntityType<EntityShadowWalker> type, ServerWorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) {
|
||||
if (HostileEntity.canSpawnInDark(type, world, spawnReason, pos, random)) {
|
||||
Box box = new Box(pos).expand(16);
|
||||
List<EntityShadowWalker> entities = world.getEntitiesByClass(EntityShadowWalker.class, box, (entity) -> { return true; });
|
||||
return entities.size() < 6;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private final class AttackGoal extends MeleeAttackGoal {
|
||||
private final EntityShadowWalker walker;
|
||||
private int ticks;
|
||||
|
|
|
@ -21,7 +21,7 @@ public class HostileEntityMixin {
|
|||
@Inject(method = "canSpawnInDark", at = @At(value = "RETURN"), cancellable = true)
|
||||
private static void endermenCheck(EntityType<? extends HostileEntity> type, ServerWorldAccess serverWorldAccess, SpawnReason spawnReason, BlockPos pos, Random random, CallbackInfoReturnable<Boolean> info) {
|
||||
boolean canSpawn = info.getReturnValue();
|
||||
if (canSpawn && spawnReason == SpawnReason.NATURAL) {
|
||||
if (canSpawn && spawnReason == SpawnReason.NATURAL && type == EntityType.ENDERMAN) {
|
||||
Box box = new Box(pos).expand(16);
|
||||
List<EndermanEntity> entities = serverWorldAccess.getEntitiesByClass(EndermanEntity.class, box, (entity) -> { return true; });
|
||||
info.setReturnValue(entities.size() < 6);
|
||||
|
|
|
@ -9,7 +9,6 @@ import net.minecraft.entity.EntityType.EntityFactory;
|
|||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.entity.attribute.DefaultAttributeContainer.Builder;
|
||||
import net.minecraft.entity.mob.HostileEntity;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.entity.EntityCubozoa;
|
||||
|
@ -30,7 +29,7 @@ public class EndEntities {
|
|||
public static void register() {
|
||||
SpawnHelper.restrictionLand(END_SLIME, EntityEndSlime::canSpawn);
|
||||
SpawnHelper.restrictionWater(END_FISH, EntityEndFish::canSpawn);
|
||||
SpawnHelper.restrictionLand(SHADOW_WALKER, HostileEntity::canSpawnInDark);
|
||||
SpawnHelper.restrictionLand(SHADOW_WALKER, EntityShadowWalker::canSpawn);
|
||||
SpawnHelper.restrictionWater(CUBOZOA, EntityCubozoa::canSpawn);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue