Search in sources :

Example 1 with AirshipContraption

use of com.eriksonn.createaeronautics.contraptions.AirshipContraption 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)

Example 2 with AirshipContraption

use of com.eriksonn.createaeronautics.contraptions.AirshipContraption in project Create_Aeronautics by Eriksonnaren.

the class ContraptionRenderMixin method renderTileEntities.

/**
 * @author Eriksonn
 */
@Overwrite(remap = false)
public static void renderTileEntities(World world, PlacementSimulationWorld renderWorld, Contraption c, ContraptionMatrices matrices, IRenderTypeBuffer buffer) {
    MatrixStack ms = matrices.getModelViewProjection();
    if (c instanceof AirshipContraption) {
        int plotId = ((AirshipContraptionEntity) c.entity).plotId;
        BlockPos anchorPos = AirshipManager.getPlotPosFromId(plotId);
        ms.translate(0, -anchorPos.getY(), 0);
    }
    // if(world.dimension() == AirshipDimensionManager.WORLD_ID)
    // {
    // int plotId = AirshipManager.getIdFromPlotPos(c.anchor);
    // AirshipContraptionEntity entity = AirshipManager.INSTANCE.AllAirships.get(plotId);
    // }
    TileEntityRenderHelper.renderTileEntities(world, renderWorld, c.specialRenderedTileEntities, ms, matrices.getLight(), buffer);
}
Also used : AirshipContraptionEntity(com.eriksonn.createaeronautics.contraptions.AirshipContraptionEntity) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) AirshipContraption(com.eriksonn.createaeronautics.contraptions.AirshipContraption) BlockPos(net.minecraft.util.math.BlockPos) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Aggregations

AirshipContraption (com.eriksonn.createaeronautics.contraptions.AirshipContraption)2 BlockPos (net.minecraft.util.math.BlockPos)2 AirshipContraptionEntity (com.eriksonn.createaeronautics.contraptions.AirshipContraptionEntity)1 AirshipDimensionManager (com.eriksonn.createaeronautics.dimension.AirshipDimensionManager)1 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 ServerWorld (net.minecraft.world.server.ServerWorld)1 Overwrite (org.spongepowered.asm.mixin.Overwrite)1