Skip to content

Commit

Permalink
fixed create valuebox rendering on ships (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsterner authored Nov 30, 2023
1 parent b370b41 commit c2e8c77
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.valkyrienskies.mod.mixin.mod_compat.create.client;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.blockEntity.behaviour.ValueBox;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.valkyrienskies.core.api.ships.ClientShip;
import org.valkyrienskies.mod.common.VSClientGameUtils;

@Mixin(ValueBox.class)
public class MixinValueBox {

@Shadow
protected BlockPos pos;

@WrapOperation(
method = "render",
at = @At(
value = "INVOKE",
target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V",
ordinal = 0
)
)
public void wrapOpTranslate(final PoseStack instance, final double x, final double y, final double z, final Operation<Void> operation) {
final ClientShip ship = VSClientGameUtils.getClientShip(x, y, z);
if (ship != null) {
final var camera = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition();
VSClientGameUtils.transformRenderWithShip(ship.getRenderTransform(), instance, pos.getX(),pos.getY(),pos.getZ(), camera.x, camera.y, camera.z );
} else {
operation.call(instance, x, y, z);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ object VSClientGameUtils {
}
}

@JvmStatic
fun getClientShip(offsetX: Double, offsetY: Double, offsetZ: Double): ClientShip? {
return Minecraft.getInstance().level?.getShipObjectManagingPos(offsetX, offsetY, offsetZ)
}

/**
* Modify the last transform of [poseStack] to be the following:
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"mod_compat.create.blockentity.MixinCrushingWheelControllerTileEntity",
"mod_compat.create.blockentity.MixinEjectorTileEntity",
"mod_compat.create.blockentity.MixinEncasedFanTileEntity",
"mod_compat.create.client.MixinValueBox",
"mod_compat.create.entity.MixinAbstractContraptionEntity",
"mod_compat.create.entity.MixinCarriageContraptionEntity",
"mod_compat.create.entity.MixinControlledContraptionEntity",
Expand Down

This file was deleted.

3 changes: 1 addition & 2 deletions fabric/src/main/resources/valkyrienskies-fabric.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
"compat.create.client.MixinContraptionRenderInfo",
"compat.create.client.MixinCullingBlockEntityIterator",
"compat.create.client.MixinFlwContraption",
"compat.create.client.MixinSuperGlueSelectionHandler",
"compat.create.client.MixinValueBox"
"compat.create.client.MixinSuperGlueSelectionHandler"
],
"injectors": {
"defaultRequire": 1
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion forge/src/main/resources/valkyrienskies-forge.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"compat.create.client.MixinContraptionRenderInfo",
"compat.create.client.MixinFlwContraption",
"compat.create.client.MixinSuperGlueSelectionHandler",
"compat.create.client.MixinValueBox",
"compat.sodium.MixinRenderSectionManager",
"compat.tis3d.MixinCasingTileEntityRender",
"compat.tis3d.MixinRenderContextImpl"
Expand Down

0 comments on commit c2e8c77

Please sign in to comment.