Skip to content

Commit

Permalink
added javadoc descriptions for the mixins
Browse files Browse the repository at this point in the history
  • Loading branch information
Endalion committed Jan 24, 2024
1 parent 4d40185 commit 9d1b6ed
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
* <p>
* 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",
Expand All @@ -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",
Expand All @@ -59,6 +66,7 @@ public void mixinRenderTool(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 cam
}
}

// To fufill the class extension requirements
@Unique
@Override
public boolean handleRightClick() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>
* 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
* <p>
* 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() {
Expand Down

0 comments on commit 9d1b6ed

Please sign in to comment.