Search in sources :

Example 1 with FakeAirshipClientWorld

use of com.eriksonn.createaeronautics.world.FakeAirshipClientWorld in project Create_Aeronautics by Eriksonnaren.

the class AirshipContraptionEntity method initFakeClientWorld.

public void initFakeClientWorld() {
    if (level.isClientSide) {
        profiler = new Profiler(() -> 0, () -> 0, false);
        RegistryKey<World> dimension = level.dimension();
        DimensionType dimensionType = level.dimensionType();
        ClientWorld.ClientWorldInfo clientWorldInfo = new ClientWorld.ClientWorldInfo(Difficulty.PEACEFUL, false, true);
        fakeClientWorld = new FakeAirshipClientWorld(this, Minecraft.getInstance().getConnection(), clientWorldInfo, dimension, dimensionType, 0, () -> profiler, null, false, 0);
        AirshipManager.INSTANCE.AllClientAirships.put(plotId, this);
        airshipContraption.maybeInstancedTileEntities.clear();
        airshipContraption.specialRenderedTileEntities.clear();
        airshipContraption.presentTileEntities.clear();
    }
}
Also used : DimensionType(net.minecraft.world.DimensionType) Profiler(net.minecraft.profiler.Profiler) FakeAirshipClientWorld(com.eriksonn.createaeronautics.world.FakeAirshipClientWorld) ClientWorld(net.minecraft.client.world.ClientWorld) ServerWorld(net.minecraft.world.server.ServerWorld) FakeAirshipClientWorld(com.eriksonn.createaeronautics.world.FakeAirshipClientWorld) World(net.minecraft.world.World) ClientWorld(net.minecraft.client.world.ClientWorld) FakeAirshipClientWorld(com.eriksonn.createaeronautics.world.FakeAirshipClientWorld)

Example 2 with FakeAirshipClientWorld

use of com.eriksonn.createaeronautics.world.FakeAirshipClientWorld in project Create_Aeronautics by Eriksonnaren.

the class SubcontraptionMatrixTransformer method setupTransforms.

public static void setupTransforms(AbstractContraptionEntity entity, MatrixStack model) {
    if (entity instanceof ControlledContraptionEntity && entity.level instanceof FakeAirshipClientWorld) {
        int plotId = AirshipManager.getIdFromPlotPos(((FakeAirshipClientWorld) entity.level).airship.blockPosition());
        AirshipContraptionEntity airshipEntity = AirshipManager.INSTANCE.AllClientAirships.get(plotId);
        if (airshipEntity != null) {
            BlockPos clientWorldOffset = AirshipManager.getPlotPosFromId(plotId);
            Vector3d airshipPosition = airshipEntity.getPartialPosition(AnimationTickHolder.getPartialTicks());
            Vector3d rotationOffset = VecHelper.getCenterOf(BlockPos.ZERO);
            model.translate(0, -clientWorldOffset.getY(), 0);
            model.translate(airshipPosition.x, airshipPosition.y, airshipPosition.z);
            // get local position
            Vector3d localPosition = entity.getAnchorVec().subtract(0, clientWorldOffset.getY(), 0);
            model.translate(-localPosition.x, -localPosition.y, -localPosition.z);
            Vector3d centerOfMassOffset = airshipEntity.applyRotation(airshipEntity.centerOfMassOffset, AnimationTickHolder.getPartialTicks());
            model.translate(-centerOfMassOffset.x, -centerOfMassOffset.y, -centerOfMassOffset.z);
            model.translate(rotationOffset.x, rotationOffset.y, rotationOffset.z);
            // rotate
            Quaternion Q = airshipEntity.quat.copy();
            Q.conj();
            model.mulPose(Q);
            Vector3d postRotationOffset = airshipEntity.applyRotation(rotationOffset, AnimationTickHolder.getPartialTicks());
            model.translate(-rotationOffset.x, -rotationOffset.y, -rotationOffset.z);
            // model.translate(-postRotationOffset.x, -postRotationOffset.y, -postRotationOffset.z);
            // model.translate(rotat.x, postRotationOffset.y, postRotationOffset.z);
            // translate again by local position
            model.translate(localPosition.x, localPosition.y, localPosition.z);
            // model.translate(-rotationOffset.x, -rotationOffset.y, -rotationOffset.z);
            // Vector3d postCenterOfMassOffset = airshipEntity.reverseRotation(centerOfMassOffset, 1.0f);
            Vector3d postCenterOfMassOffset = centerOfMassOffset;
        // 
        // model.translate(rotationOffset.x, rotationOffset.y, rotationOffset.z);
        // model.translate(globalPos.x,globalPos.y,globalPos.z);
        // Vector3d newPos = ((AbstractContraptionEntityExtension) entity).createAeronautics$getOriginalPosition();
        // entity.setPos(newPos.x,newPos.y,newPos.z);
        }
    }
}
Also used : ControlledContraptionEntity(com.simibubi.create.content.contraptions.components.structureMovement.ControlledContraptionEntity) Vector3d(net.minecraft.util.math.vector.Vector3d) Quaternion(net.minecraft.util.math.vector.Quaternion) BlockPos(net.minecraft.util.math.BlockPos) FakeAirshipClientWorld(com.eriksonn.createaeronautics.world.FakeAirshipClientWorld)

Example 3 with FakeAirshipClientWorld

use of com.eriksonn.createaeronautics.world.FakeAirshipClientWorld in project Create_Aeronautics by Eriksonnaren.

the class ContraptionRenderInfoMixin method afterBeginFrame.

// /**
// * @author Eriksonn
// */
// @Overwrite(remap = false)
// public void beginFrame(BeginFrameEvent event) {
// matrices.clear();
// 
// AbstractContraptionEntity entity = contraption.entity;
// if(entity instanceof ControlledContraptionEntity && entity.level.dimension() == AirshipDimensionManager.WORLD_ID) {
// int plotId = AirshipManager.getIdFromPlotPos(entity.blockPosition());
// AirshipContraptionEntity airshipEntity = AirshipManager.INSTANCE.AllAirships.get(plotId);
// if (airshipEntity != null) {
// entity = airshipEntity;
// }
// }
// visible = event.getClippingHelper().isVisible(entity.getBoundingBoxForCulling().inflate(2));
// }
@Inject(locals = LocalCapture.CAPTURE_FAILHARD, remap = false, method = "beginFrame", at = @At("TAIL"))
public void afterBeginFrame(BeginFrameEvent event, CallbackInfo ci, AbstractContraptionEntity entity) {
    if (entity instanceof ControlledContraptionEntity && entity.level instanceof FakeAirshipClientWorld) {
        int plotId = AirshipManager.getIdFromPlotPos(entity.blockPosition());
        AirshipContraptionEntity airshipEntity = AirshipManager.INSTANCE.AllAirships.get(plotId);
        if (airshipEntity != null) {
            visible = event.getClippingHelper().isVisible(airshipEntity.getBoundingBoxForCulling().inflate(2));
        }
    }
// 
}
Also used : AirshipContraptionEntity(com.eriksonn.createaeronautics.contraptions.AirshipContraptionEntity) FakeAirshipClientWorld(com.eriksonn.createaeronautics.world.FakeAirshipClientWorld) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

FakeAirshipClientWorld (com.eriksonn.createaeronautics.world.FakeAirshipClientWorld)3 AirshipContraptionEntity (com.eriksonn.createaeronautics.contraptions.AirshipContraptionEntity)1 ControlledContraptionEntity (com.simibubi.create.content.contraptions.components.structureMovement.ControlledContraptionEntity)1 ClientWorld (net.minecraft.client.world.ClientWorld)1 Profiler (net.minecraft.profiler.Profiler)1 BlockPos (net.minecraft.util.math.BlockPos)1 Quaternion (net.minecraft.util.math.vector.Quaternion)1 Vector3d (net.minecraft.util.math.vector.Vector3d)1 DimensionType (net.minecraft.world.DimensionType)1 World (net.minecraft.world.World)1 ServerWorld (net.minecraft.world.server.ServerWorld)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1