Search in sources :

Example 1 with AirshipDimensionManager

use of com.eriksonn.createaeronautics.dimension.AirshipDimensionManager in project Create_Aeronautics by Eriksonnaren.

the class AirshipAssemblerTileEntity method assemble.

public void assemble() {
    if (this.level.getBlockState(this.worldPosition).getBlock() instanceof AirshipAssemblerBlock) {
        AirshipContraption contraption = new AirshipContraption();
        try {
            if (!contraption.assemble(this.level, this.worldPosition)) {
                return;
            }
            this.lastException = null;
        } catch (AssemblyException var4) {
            this.lastException = var4;
            this.sendData();
            return;
        }
        AirshipDimensionManager manager = AirshipDimensionManager.INSTANCE;
        BlockPos targetSize = new BlockPos(contraption.bounds.maxX, contraption.bounds.maxY, contraption.bounds.maxZ);
        // manager.getWorldData();
        // AirshipDimensionPlot plot = manager.allocatePlot(targetSize);
        ServerWorld airshipWorld = manager.getWorld();
        contraption.removeBlocksFromWorld(this.level, BlockPos.ZERO);
        this.movedContraption = AirshipContraptionEntity.create(this.level, contraption);
        BlockPos anchor = this.worldPosition;
        this.movedContraption.simulatedRigidbody.tryInit();
        this.movedContraption.setPos((double) anchor.getX() + this.movedContraption.centerOfMassOffset.x, (double) anchor.getY() + this.movedContraption.centerOfMassOffset.y, (double) anchor.getZ() + this.movedContraption.centerOfMassOffset.z);
        this.level.addFreshEntity(this.movedContraption);
        AllSoundEvents.CONTRAPTION_ASSEMBLE.playOnServer(this.level, this.worldPosition);
        this.running = true;
        contraption.addBlocksToWorld(airshipWorld, new StructureTransform(this.movedContraption.getPlotPos(), 0.0F, 0, 0.0F));
        this.sendData();
    }
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) AirshipDimensionManager(com.eriksonn.createaeronautics.dimension.AirshipDimensionManager) AirshipContraption(com.eriksonn.createaeronautics.contraptions.AirshipContraption) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

AirshipContraption (com.eriksonn.createaeronautics.contraptions.AirshipContraption)1 AirshipDimensionManager (com.eriksonn.createaeronautics.dimension.AirshipDimensionManager)1 BlockPos (net.minecraft.util.math.BlockPos)1 ServerWorld (net.minecraft.world.server.ServerWorld)1