Skip to content

Commit

Permalink
1.20.1/main/fixed create valuebox rendering on ships (#638)
Browse files Browse the repository at this point in the history
* fixed create valuebox rendering on ships
  • Loading branch information
mrsterner authored Nov 30, 2023
1 parent 68a8929 commit be944c1
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public MixinLivingEntity(final EntityType<?> entityType, final Level level) {
*/
@Inject(method = "dismountVehicle", at = @At("HEAD"), cancellable = true)
private void preDismountVehicle(final Entity entity, final CallbackInfo ci) {
if (!this.isRemoved() && entity.isRemoved() || this.level.getBlockState(entity.blockPosition()).is(BlockTags.PORTALS)) {
if (VSGameUtilsKt.isBlockInShipyard(level, entity.position())) {
final Ship ship = VSGameUtilsKt.getShipManagingPos(level, entity.position());
if (!this.isRemoved() && entity.isRemoved() || this.level().getBlockState(entity.blockPosition()).is(BlockTags.PORTALS)) {
if (VSGameUtilsKt.isBlockInShipyard(level(), entity.position())) {
final Ship ship = VSGameUtilsKt.getShipManagingPos(level(), entity.position());
if (ship != null) {
final Vector3dc transformedPos = ship.getTransform().getShipToWorld().transformPosition(VectorConversionsMCKt.toJOML(entity.position()));
final double d = Math.max(this.getY(), transformedPos.y());
Expand Down
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 @@ -51,11 +51,11 @@ private BlockPos wrapBlockPosInUpdateEntityAfterFallOn(
if (draggingInformation.isEntityBeingDraggedByAShip()) {
final Long shipStandingOnId = draggingInformation.getLastShipStoodOn();
if (shipStandingOnId != null) {
final Ship ship = VSGameUtilsKt.getShipObjectWorld(entity.level).getLoadedShips().getById(shipStandingOnId);
final Ship ship = VSGameUtilsKt.getShipObjectWorld(entity.level()).getLoadedShips().getById(shipStandingOnId);
if (ship != null) {
final Vector3dc posInShip = ship.getTransform().getWorldToShip()
.transformPosition(entity.getX(), entity.getY(), entity.getZ(), new Vector3d());
return new BlockPos(posInShip.x(), posInShip.y(), posInShip.z());
return BlockPos.containing(posInShip.x(), posInShip.y(), posInShip.z());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,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 @@ -76,6 +76,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
5 changes: 2 additions & 3 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,12 @@ dependencies {
exclude module: "netty-buffer"
exclude module: "fastutil"
exclude module: "kotlin-stdlib-jdk8" // Don't shade kotlin-stdlib-jdk8, even though vs-core depends on it
<<<<<<<<< Temporary merge branch 1

exclude group: "com.google.guava"
}

// CC Restitched
modImplementation("curse.maven:cc-restitched-462672:3908334")
=========
modImplementation("curse.maven:cc-restitched-462672:3908334"){
exclude module: "jsonschema.module.addon"
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"compat.create.client.MixinCullingBlockEntityIterator",
"compat.create.client.MixinFlwContraption",
"compat.create.client.MixinSuperGlueSelectionHandler",
"compat.create.client.MixinValueBox",
"feature.duplicate_keybindings.KeyMappingAccessor",
"feature.duplicate_keybindings.MixinKeyMapping"
],
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 @@ -19,7 +19,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 be944c1

Please sign in to comment.