New mob spawning API
This commit is contained in:
parent
a55cbe67de
commit
acec6a2213
11 changed files with 40 additions and 128 deletions
|
@ -9,7 +9,6 @@ import net.minecraft.world.effect.MobEffects;
|
|||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal;
|
||||
|
@ -20,15 +19,10 @@ import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;
|
|||
import net.minecraft.world.entity.monster.Monster;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import ru.bclib.util.MHelper;
|
||||
import ru.betterend.registry.EndSounds;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class ShadowWalkerEntity extends Monster {
|
||||
public ShadowWalkerEntity(EntityType<ShadowWalkerEntity> entityType, Level world) {
|
||||
super(entityType, world);
|
||||
|
@ -125,17 +119,6 @@ public class ShadowWalkerEntity extends Monster {
|
|||
return attack;
|
||||
}
|
||||
|
||||
public static boolean canSpawn(EntityType<ShadowWalkerEntity> type, ServerLevelAccessor world, MobSpawnType spawnReason, BlockPos pos, Random random) {
|
||||
if (Monster.checkMonsterSpawnRules(type, world, spawnReason, pos, random)) {
|
||||
AABB box = new AABB(pos).inflate(16);
|
||||
List<ShadowWalkerEntity> entities = world.getEntitiesOfClass(ShadowWalkerEntity.class, box, (entity) -> {
|
||||
return true;
|
||||
});
|
||||
return entities.size() < 6;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private final class AttackGoal extends MeleeAttackGoal {
|
||||
private final ShadowWalkerEntity walker;
|
||||
private int ticks;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue