Search in sources :

Example 1 with AirshipAssemblerTileEntity

use of com.eriksonn.createaeronautics.blocks.airship_assembler.AirshipAssemblerTileEntity in project Create_Aeronautics by Eriksonnaren.

the class AirshipContraptionEntity method tickContraption.

@Override
public void tickContraption() {
    AirshipAssemblerTileEntity controller = getController();
    airshipContraption = (AirshipContraption) contraption;
    if (controller != null)
        controller.attach(this);
    simulatedRigidbody.tick();
    if (!airshipInitialized) {
        initFakeClientWorld();
    }
    if (level.isClientSide) {
        profiler.startTick();
        fakeClientWorld.tick(() -> true);
        fakeClientWorld.tickEntities();
        for (ControlledContraptionEntity contraptionEntity : subContraptions.values()) {
            contraptionEntity.tick();
        }
        profiler.endTick();
        if (invalid) {
            ContraptionRenderDispatcher.invalidate(airshipContraption);
            invalid = false;
        }
    }
    if (!airshipInitialized) {
        airshipInitialized = true;
        syncNextTick = true;
    }
    if (syncNextTick) {
        syncPacket();
        syncPacket();
        syncNextTick = false;
    }
    contraption.getContraptionWorld().tickBlockEntities();
    if (!level.isClientSide) {
        serverUpdate();
    }
    if (level.isClientSide && false) {
        CompoundNBT tag = this.entityData.get(physicsDataAccessor);
        if (tag.contains("velocity")) {
            simulatedRigidbody.globalVelocity = simulatedRigidbody.arrayToVec(readDoubleArray(tag, "velocity"));
            // simulatedRigidbody.angularVelocity = simulatedRigidbody.arrayToVec(readDoubleArray(tag, "angularVelocity"));
            simulatedRigidbody.angularMomentum = simulatedRigidbody.arrayToVec(readDoubleArray(tag, "angularMomentum"));
            // simulatedRigidbody.momentum = simulatedRigidbody.arrayToVec(readDoubleArray(tag, "momentum"));
            simulatedRigidbody.orientation = simulatedRigidbody.arrayToQuat(readDoubleArray(tag, "orientation"));
        }
    }
// if(level.isClientSide)
// Vector3d particlePos = toGlobalVector(new Vector3d(0,0,0),0);
// level.addParticle(new RedstoneParticleData(1,1,1,1),particlePos.x,particlePos.y,particlePos.z,0,0,0);
// this.getContraption().getContraptionWorld().tickBlockEntities();
}
Also used : AirshipAssemblerTileEntity(com.eriksonn.createaeronautics.blocks.airship_assembler.AirshipAssemblerTileEntity)

Example 2 with AirshipAssemblerTileEntity

use of com.eriksonn.createaeronautics.blocks.airship_assembler.AirshipAssemblerTileEntity in project Create_Aeronautics by Eriksonnaren.

the class AirshipContraptionEntity method getController.

public AirshipAssemblerTileEntity getController() {
    BlockPos controllerPos = getPlotPos();
    World w = AirshipDimensionManager.INSTANCE.getWorld();
    if (!w.isLoaded(controllerPos))
        return null;
    TileEntity te = w.getBlockEntity(controllerPos);
    if (!(te instanceof AirshipAssemblerTileEntity))
        return null;
    return (AirshipAssemblerTileEntity) te;
}
Also used : AirshipAssemblerTileEntity(com.eriksonn.createaeronautics.blocks.airship_assembler.AirshipAssemblerTileEntity) ITickableTileEntity(net.minecraft.tileentity.ITickableTileEntity) SmartTileEntity(com.simibubi.create.foundation.tileEntity.SmartTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) BlockPos(net.minecraft.util.math.BlockPos) ServerWorld(net.minecraft.world.server.ServerWorld) FakeAirshipClientWorld(com.eriksonn.createaeronautics.world.FakeAirshipClientWorld) World(net.minecraft.world.World) ClientWorld(net.minecraft.client.world.ClientWorld) AirshipAssemblerTileEntity(com.eriksonn.createaeronautics.blocks.airship_assembler.AirshipAssemblerTileEntity)

Aggregations

AirshipAssemblerTileEntity (com.eriksonn.createaeronautics.blocks.airship_assembler.AirshipAssemblerTileEntity)2 FakeAirshipClientWorld (com.eriksonn.createaeronautics.world.FakeAirshipClientWorld)1 SmartTileEntity (com.simibubi.create.foundation.tileEntity.SmartTileEntity)1 ClientWorld (net.minecraft.client.world.ClientWorld)1 ITickableTileEntity (net.minecraft.tileentity.ITickableTileEntity)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1 ServerWorld (net.minecraft.world.server.ServerWorld)1