Search in sources :

Example 1 with StructureManager

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);
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) IServerWorld(net.minecraft.world.IServerWorld) StructureManager(net.minecraft.world.gen.feature.structure.StructureManager) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

BlockPos (net.minecraft.util.math.BlockPos)1 IServerWorld (net.minecraft.world.IServerWorld)1 StructureManager (net.minecraft.world.gen.feature.structure.StructureManager)1 ServerWorld (net.minecraft.world.server.ServerWorld)1