Skip to content

Commit

Permalink
Make public mixin methods private and make more use of MixinExtras
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4ckscor3 committed Jan 1, 2025
1 parent b7f5d31 commit 31cfca0
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public abstract class ClientChunkCacheMixin implements IChunkStorageProvider {
* frame camera
*/
@Inject(method = "drop", at = @At(value = "HEAD"))
public void securitycraft$onDrop(ChunkPos pos, CallbackInfo ci) {
private void securitycraft$onDrop(ChunkPos pos, CallbackInfo ci) {
int renderDistance = Minecraft.getInstance().options.renderDistance().get();
Entity cameraEntity = Minecraft.getInstance().cameraEntity;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
Expand All @@ -36,12 +35,12 @@ public class GameRendererMixin {
/**
* Makes sure camera zooming works, because the fov is only updated when the camera entity is the player itself
*/
@ModifyConstant(method = "tickFov", constant = @Constant(floatValue = 1.0F))
private float securitycraft$modifyInitialFValue(float f) {
@ModifyExpressionValue(method = "tickFov", at = @At(value = "CONSTANT", args = "floatValue=1.0F"))
private float securitycraft$modifyInitialFValue(float original) {
if (minecraft.cameraEntity instanceof SecurityCamera cam)
return cam.getZoomAmount();
else
return f;
return original;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public abstract class LevelRendererMixin {
@Unique
private boolean securitycraft$entityOutlineRendered;

@Shadow protected abstract boolean collectVisibleEntities(Camera camera, Frustum frustum, List<Entity> output);
@Shadow
protected abstract boolean collectVisibleEntities(Camera camera, Frustum frustum, List<Entity> output);

/**
* Allows entities to render in the first frame of a render section being rendered when Sodium is installed, as entities in
Expand All @@ -73,8 +74,8 @@ public abstract class LevelRendererMixin {
}

/**
* If the collection of renderable entities within the mixin above returned that one or more entities should be rendered
* with an outline, correctly modify the respective flag in LevelRenderer#renderLevel so the shader post chain respects the
* If the collection of renderable entities within the mixin above returned that one or more entities should be rendered with
* an outline, correctly modify the respective flag in LevelRenderer#renderLevel so the shader post chain respects the
* outline.
*/
@ModifyVariable(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;compileSections(Lnet/minecraft/client/Camera;)V"), ordinal = 3)
Expand All @@ -94,7 +95,7 @@ private boolean modifyEntityOutlineRendered(boolean original) {
* performant, and since that happens in setupRender too, the method is not exited early in this case.
*/
@Inject(method = "setupRender", at = @At(value = "HEAD"), cancellable = true)
public void securitycraft$onSetupRender(Camera camera, Frustum frustum, boolean hasCapturedFrustum, boolean isSpectator, CallbackInfo callbackInfo) {
private void securitycraft$onSetupRender(Camera camera, Frustum frustum, boolean hasCapturedFrustum, boolean isSpectator, CallbackInfo callbackInfo) {
if (CameraController.currentlyCapturedCamera != null && SecurityCraftClient.INSTALLED_IUM_MOD == IumCompat.NONE)
callbackInfo.cancel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
@Mixin(RenderTarget.class)
public class RenderTargetMixin {
@SuppressWarnings("unlikely-arg-type")
@Inject(method = "bindWrite", at = @At(value = "HEAD"), cancellable = true)
private void securitycraft$onRegisterRenderTarget(boolean setViewport, CallbackInfo callbackInfo) {
if (CameraController.currentlyCapturedCamera != null && equals(Minecraft.getInstance().getMainRenderTarget()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public abstract class TrackedEntityMixin {
Entity entity;

@ModifyVariable(method = "updatePlayer", name = "flag", at = @At(value = "JUMP", opcode = Opcodes.IFEQ, shift = At.Shift.BEFORE, ordinal = 2))
public boolean securitycraft$modifyFlag(boolean original, ServerPlayer player, @Local(ordinal = 0) double viewDistance) {
private boolean securitycraft$modifyFlag(boolean original, ServerPlayer player, @Local(ordinal = 0) double viewDistance) {
if (original)
return true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Redirect;

import com.llamalad7.mixinextras.sugar.Local;

import net.geforcemods.securitycraft.misc.F3Spoofer;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FluidState;
Expand All @@ -19,13 +19,13 @@
"me.cominixo.betterf3.modules.TargetModule"
})
public class BetterF3TargetModuleMixin {
@Redirect(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"))
public BlockState securitycraft$spoofBlockState(ClientLevel level, BlockPos pos) {
return F3Spoofer.spoofBlockState(level.getBlockState(pos), pos);
@ModifyVariable(method = "update", name = "blockState", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"))
private BlockState securitycraft$spoofBlockState(BlockState state, @Local(ordinal = 0) BlockPos blockPos) {
return F3Spoofer.spoofBlockState(state, blockPos);
}

@ModifyVariable(method = "update", name = "fluidState", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;"))
public FluidState securitycraft$spoofFluidState(FluidState originalState) {
private FluidState securitycraft$spoofFluidState(FluidState originalState) {
return F3Spoofer.spoofFluidState(originalState);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public class DebugScreenOverlayMixin {
private HitResult block;

@ModifyVariable(method = "getSystemInformation", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"))
public BlockState securitycraft$spoofBlockState(BlockState originalState) {
private BlockState securitycraft$spoofBlockState(BlockState originalState) {
return F3Spoofer.spoofBlockState(originalState, ((BlockHitResult) block).getBlockPos());
}

@ModifyVariable(method = "getSystemInformation", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;"))
public FluidState securitycraft$spoofFluidState(FluidState originalState) {
private FluidState securitycraft$spoofFluidState(FluidState originalState) {
return F3Spoofer.spoofFluidState(originalState);
}
}

0 comments on commit 31cfca0

Please sign in to comment.