Search in sources :

Example 1 with DefaultGatePlacement

use of com.mraof.minestuck.world.lands.structure.DefaultGatePlacement in project Minestuck by mraof.

the class ChunkProviderLands method populate.

@Override
public void populate(int chunkX, int chunkZ) {
    ChunkPos coord = new ChunkPos(chunkX, chunkZ);
    BlockPos gatePos = GateHandler.getGatePos(-1, landWorld.provider.getDimension());
    boolean generatingGate = false;
    if (gatePos != null)
        if (gatePos.getX() >= (chunkX << 4) && gatePos.getX() < (chunkX << 4) + 32 && gatePos.getZ() >= (chunkZ << 4) && gatePos.getZ() < (chunkZ << 4) + 32) {
            generatingGate = true;
            this.generatingStructure = true;
        }
    this.random.setSeed(getSeedFor(chunkX, chunkZ));
    this.generatingStructure = structureHandler.generateStructure(landWorld, random, new ChunkPos(chunkX, chunkZ));
    this.generatingStructure |= villageHandler.generateStructure(landWorld, random, new ChunkPos(chunkX, chunkZ));
    BlockPos pos = null;
    for (Object decorator : decorators) {
        BlockPos tempPos = ((ILandDecorator) decorator).generate(landWorld, random, chunkX, chunkZ, this);
        if (tempPos != null)
            pos = tempPos;
    }
    if (!generatingGate)
        structureHandler.placeReturnNodes(landWorld, random, new ChunkPos(chunkX, chunkZ), pos);
    else if (gatePos.getX() >= (chunkX << 4) + 8 && gatePos.getX() < (chunkX << 4) + 24 && gatePos.getZ() >= (chunkZ << 4) + 8 && gatePos.getZ() < (chunkZ << 4) + 24) {
        IGateStructure gate1 = aspect1.getGateStructure();
        IGateStructure gate2 = aspect2.getGateStructure();
        IGateStructure structure;
        if (gate1 != null && gate2 != null)
            structure = random.nextBoolean() ? gate1 : gate2;
        else if (gate1 != null)
            structure = gate1;
        else if (gate2 != null)
            structure = gate2;
        else
            structure = new DefaultGatePlacement();
        gatePos = structure.generateGateStructure(landWorld, gatePos, this);
        GateHandler.setDefiniteGatePos(-1, landWorld.provider.getDimension(), gatePos);
        for (int x = -1; x <= 1; x++) for (int z = -1; z <= 1; z++) {
            if (x == 0 && z == 0) {
                landWorld.setBlockState(gatePos, MinestuckBlocks.gate.getDefaultState().cycleProperty(BlockGate.isMainComponent), 2);
                TileEntityGate tileEntity = (TileEntityGate) landWorld.getTileEntity(gatePos);
                tileEntity.gateCount = -1;
            } else
                landWorld.setBlockState(gatePos.add(x, 0, z), MinestuckBlocks.gate.getDefaultState(), 2);
        }
    }
    this.generatingStructure = false;
}
Also used : IGateStructure(com.mraof.minestuck.world.lands.structure.IGateStructure) ILandDecorator(com.mraof.minestuck.world.lands.decorator.ILandDecorator) DefaultGatePlacement(com.mraof.minestuck.world.lands.structure.DefaultGatePlacement) ChunkPos(net.minecraft.util.math.ChunkPos) BlockPos(net.minecraft.util.math.BlockPos) TileEntityGate(com.mraof.minestuck.tileentity.TileEntityGate)

Aggregations

TileEntityGate (com.mraof.minestuck.tileentity.TileEntityGate)1 ILandDecorator (com.mraof.minestuck.world.lands.decorator.ILandDecorator)1 DefaultGatePlacement (com.mraof.minestuck.world.lands.structure.DefaultGatePlacement)1 IGateStructure (com.mraof.minestuck.world.lands.structure.IGateStructure)1 BlockPos (net.minecraft.util.math.BlockPos)1 ChunkPos (net.minecraft.util.math.ChunkPos)1