use of net.minecraft.world.gen.feature.structure.StructureManager in project ChaosAwakens by ChaosAwakens.
the class EntEntity method finalizeSpawn.
@Override
public ILivingEntityData finalizeSpawn(IServerWorld worldIn, DifficultyInstance difficultyIn, SpawnReason reason, @Nullable ILivingEntityData spawnDataIn, @Nullable CompoundNBT dataTag) {
// Only allow the ENT to wander when spawned outside the tree
if (worldIn instanceof ServerWorld) {
BlockPos pos = this.getOnPos();
StructureManager strucManager = worldIn.getLevel().structureFeatureManager();
boolean inDungeon = strucManager.getStructureAt(pos, false, CAStructures.ACACIA_ENT_TREE.get()).isValid() || strucManager.getStructureAt(pos, false, CAStructures.BIRCH_ENT_TREE.get()).isValid() || strucManager.getStructureAt(pos, false, CAStructures.CRIMSON_ENT_TREE.get()).isValid() || strucManager.getStructureAt(pos, false, CAStructures.DARK_OAK_ENT_TREE.get()).isValid() || strucManager.getStructureAt(pos, false, CAStructures.JUNGLE_ENT_TREE.get()).isValid() || strucManager.getStructureAt(pos, false, CAStructures.OAK_ENT_TREE.get()).isValid() || strucManager.getStructureAt(pos, false, CAStructures.SPRUCE_ENT_TREE.get()).isValid() || strucManager.getStructureAt(pos, false, CAStructures.WARPED_ENT_TREE.get()).isValid();
if (!inDungeon || reason != SpawnReason.STRUCTURE) {
this.goalSelector.addGoal(4, new RandomWalkingGoal(this, 1.6));
}
}
return super.finalizeSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag);
}
Aggregations