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();
}
}
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);
}
}
}
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));
}
}
//
}
Aggregations