From 9d1b6edc48d0c504085f138953f3eb01c93ce779 Mon Sep 17 00:00:00 2001 From: Endalion <34496536+Endalion@users.noreply.github.com> Date: Wed, 24 Jan 2024 15:39:34 +0800 Subject: [PATCH] added javadoc descriptions for the mixins --- .../mod_compat/create/client/MixinDeployTool.java | 12 ++++++++++-- .../create/client/MixinSchematicToolBase.java | 13 ++++++++++--- .../create/client/MixinSchematicTransformation.java | 6 ++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinDeployTool.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinDeployTool.java index bf86edbab..d74ed0b39 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinDeployTool.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinDeployTool.java @@ -19,10 +19,17 @@ import org.valkyrienskies.mod.common.VSClientGameUtils; import org.valkyrienskies.mod.common.VSGameUtilsKt; +/** + * DeployTool is responsible for the render transform of the placement bounding box (not the preview) + *

+ * Create applies both the camera and bounding-box position in the same PoseStack operation, + * the latter of which does not respect ship-space. + * This mixin cancels the aforementioned operation and injects the fix in front. + */ @Mixin(value={DeployTool.class}) public class MixinDeployTool extends SchematicToolBase { @Redirect( - method = "Lcom/simibubi/create/content/schematics/client/tools/DeployTool;renderTool(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/simibubi/create/foundation/render/SuperRenderTypeBuffer;Lnet/minecraft/world/phys/Vec3;)V", + method = "renderTool(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/simibubi/create/foundation/render/SuperRenderTypeBuffer;Lnet/minecraft/world/phys/Vec3;)V", at = @At( value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V", @@ -33,7 +40,7 @@ public void redirectTranslate(PoseStack ms, double _x, double _y, double _z) { } @Inject( - method = "Lcom/simibubi/create/content/schematics/client/tools/DeployTool;renderTool(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/simibubi/create/foundation/render/SuperRenderTypeBuffer;Lnet/minecraft/world/phys/Vec3;)V", + method = "renderTool(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/simibubi/create/foundation/render/SuperRenderTypeBuffer;Lnet/minecraft/world/phys/Vec3;)V", at = @At( value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V", @@ -59,6 +66,7 @@ public void mixinRenderTool(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 cam } } + // To fufill the class extension requirements @Unique @Override public boolean handleRightClick() { diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSchematicToolBase.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSchematicToolBase.java index 5b15a7382..20496ca8f 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSchematicToolBase.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSchematicToolBase.java @@ -8,18 +8,25 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; +/** + * SchematicToolBase is responsible for the placement position of the schematic. + *

+ * Create uses HitResult::getLocation to get the schematic placement position, which doesn't respect ship-space. + * This mixin redirects it to BlockHitResult::getBlockPos instead which *does* respect ship-space. + * The original behaviour is otherwise not changed. + */ @Mixin(value={SchematicToolBase.class}) public abstract class MixinSchematicToolBase { @Redirect( - method = "Lcom/simibubi/create/content/schematics/client/tools/SchematicToolBase;updateTargetPos()V", + method = "updateTargetPos()V", at = @At( value = "INVOKE", target = "Lnet/minecraft/world/phys/BlockHitResult;getLocation()Lnet/minecraft/world/phys/Vec3;", ordinal = 0 ) ) - public Vec3 injectgetLocation(BlockHitResult instance) { + public Vec3 redirectGetLocation(BlockHitResult instance) { BlockPos b = instance.getBlockPos(); - return new Vec3(b.getX() + 0.5, b.getY() + 0.5, b.getZ() + 0.5); + return Vec3.atLowerCornerOf(b); } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSchematicTransformation.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSchematicTransformation.java index 8595ca23f..a8ae2b290 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSchematicTransformation.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSchematicTransformation.java @@ -16,6 +16,12 @@ import org.valkyrienskies.mod.common.VSClientGameUtils; import org.valkyrienskies.mod.common.VSGameUtilsKt; +/** + * SchematicTransformation is responsible for the render transform of the schematic preview + *

+ * Create applies both the camera and schematic positions in the same operation, the latter of which does not respect ship-space. + * This mixin redirects the operation to the fix and extracts the position components from the argument. + */ @Mixin(value = {SchematicTransformation.class}, remap = false) public class MixinSchematicTransformation { public MixinSchematicTransformation() {