Skip to content

Commit

Permalink
Replaced INSTANCE fields with global getter
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Nov 26, 2023
1 parent 34d7808 commit d129cb5
Show file tree
Hide file tree
Showing 32 changed files with 65 additions and 595,719 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private void injectFindGlyph(int codePoint, CallbackInfoReturnable<FontStorage.G
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
if (viaFabricPlus$isForbiddenCharacter(font, codePoint)) cir.setReturnValue(FontStorage.GlyphPair.MISSING);

if (VisualSettings.INSTANCE.changeFontRendererBehaviour.isEnabled() && cir.getReturnValue() == FontStorage.GlyphPair.MISSING) {
if (VisualSettings.global().changeFontRendererBehaviour.isEnabled() && cir.getReturnValue() == FontStorage.GlyphPair.MISSING) {
cir.setReturnValue(new FontStorage.GlyphPair(BuiltinEmptyGlyph1_12_2.VERY_MISSING, BuiltinEmptyGlyph1_12_2.VERY_MISSING));
}
}
Expand All @@ -103,7 +103,7 @@ private void injectFindGlyphRenderer(int codePoint, CallbackInfoReturnable<Glyph
if (!viaFabricPlus$obfuscation && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
if (viaFabricPlus$isForbiddenCharacter(font, codePoint)) cir.setReturnValue(this.blankGlyphRenderer);

if (VisualSettings.INSTANCE.changeFontRendererBehaviour.isEnabled() && cir.getReturnValue() == this.blankGlyphRenderer) {
if (VisualSettings.global().changeFontRendererBehaviour.isEnabled() && cir.getReturnValue() == this.blankGlyphRenderer) {
cir.setReturnValue(BuiltinEmptyGlyph1_12_2.VERY_MISSING.bake(this::getGlyphRenderer));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private void updateCooldown(CallbackInfo ci) {
@Inject(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;",
ordinal = 4, shift = At.Shift.BEFORE))
private void injectTick(CallbackInfo ci) {
if (!DebugSettings.INSTANCE.executeInputsInSync.isEnabled()) {
if (!DebugSettings.global().executeInputsInSync.isEnabled()) {
return;
}

Expand All @@ -127,7 +127,7 @@ private void injectTick(CallbackInfo ci) {

@Inject(method = "handleInputEvents", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;hasRidingInventory()Z"))
private void onInventoryKeyPressed(CallbackInfo ci) {
if (getNetworkHandler() != null && DebugSettings.INSTANCE.sendOpenInventoryPacket.isEnabled()) {
if (getNetworkHandler() != null && DebugSettings.global().sendOpenInventoryPacket.isEnabled()) {
final UserConnection userConnection = ProtocolHack.getPlayNetworkUserConnection();

if (userConnection != null && userConnection.getProtocolInfo().getPipeline().contains(Protocol1_12To1_11_1.class)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public abstract class MixinPendingUpdateManager {

@Inject(method = "incrementSequence", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/PendingUpdateManager;pendingSequence:Z", shift = At.Shift.BEFORE), cancellable = true)
private void injectIncrementSequence(CallbackInfoReturnable<PendingUpdateManager> cir) {
if (DebugSettings.INSTANCE.disableSequencing.isEnabled()) {
if (DebugSettings.global().disableSequencing.isEnabled()) {
cir.setReturnValue((PendingUpdateManager) (Object) this);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public abstract class MixinAbstractBlock {

@Inject(method = "calcBlockBreakingDelta", at = @At("HEAD"), cancellable = true)
private void changeMiningSpeedCalculation(BlockState state, PlayerEntity player, BlockView world, BlockPos pos, CallbackInfoReturnable<Float> cir) {
if (DebugSettings.INSTANCE.legacyMiningSpeeds.isEnabled()) {
if (DebugSettings.global().legacyMiningSpeeds.isEnabled()) {
final float hardness = state.getHardness(world, pos);
if (hardness == -1.0F) {
cir.setReturnValue(0.0F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public abstract class MixinBipedEntityModel<T extends LivingEntity> {

@Inject(method = "setAngles(Lnet/minecraft/entity/LivingEntity;FFFFF)V", at = @At(value = "FIELD", target = "Lnet/minecraft/client/model/ModelPart;roll:F", ordinal = 1, shift = At.Shift.AFTER))
private void addOldWalkAnimation(T livingEntity, float f, float g, float h, float i, float j, CallbackInfo ci) {
if (VisualSettings.INSTANCE.oldWalkingAnimation.isEnabled()) {
if (VisualSettings.global().oldWalkingAnimation.isEnabled()) {
this.rightArm.pitch = MathHelper.cos(f * 0.6662F + 3.1415927F) * 2.0F * g;
this.rightArm.roll = (MathHelper.cos(f * 0.2312F) + 1.0F) * 1.0F * g;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private void incrementLastPositionPacketSentCounter(CallbackInfo ci) {

@Redirect(method = "sendMovementPackets", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayerEntity;lastOnGround:Z", ordinal = 0))
private boolean sendIdlePacket(ClientPlayerEntity instance) {
if (DebugSettings.INSTANCE.sendIdlePacket.isEnabled()) {
if (DebugSettings.global().sendIdlePacket.isEnabled()) {
return !isOnGround();
}
return lastOnGround;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private void removeAttackCooldown(CallbackInfoReturnable<Float> ci) {

@Inject(method = "getHurtSound", at = @At("HEAD"), cancellable = true)
private void replaceSound(DamageSource source, CallbackInfoReturnable<SoundEvent> cir) {
if (VisualSettings.INSTANCE.replaceHurtSoundWithOOFSound.isEnabled()) {
if (VisualSettings.global().replaceHurtSoundWithOOFSound.isEnabled()) {
cir.setReturnValue(viaFabricPlus$random_hurt);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public abstract class MixinCamera {

@Inject(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;setPos(DDD)V", shift = At.Shift.BEFORE))
private void onUpdateHeight(BlockView area, Entity focusedEntity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo ci) {
if (!DebugSettings.INSTANCE.replaceSneaking.isEnabled() && DebugSettings.INSTANCE.sneakInstant.isEnabled()) {
if (!DebugSettings.global().replaceSneaking.isEnabled() && DebugSettings.global().sneakInstant.isEnabled()) {
cameraY = lastCameraY = focusedEntity.getStandingEyeHeight();
}
}
Expand All @@ -53,14 +53,14 @@ private void onUpdateHeight(BlockView area, Entity focusedEntity, boolean thirdP
private void onUpdateEyeHeight(CallbackInfo ci) {
if (this.focusedEntity == null) return;

if (DebugSettings.INSTANCE.replaceSneaking.isEnabled()) {
if (DebugSettings.global().replaceSneaking.isEnabled()) {
ci.cancel();
this.lastCameraY = this.cameraY;

if (this.focusedEntity instanceof PlayerEntity player && !player.isSleeping()) {
if (player.isSneaking()) {
cameraY = 1.54F;
} else if (!DebugSettings.INSTANCE.longSneaking.isEnabled()) {
} else if (!DebugSettings.global().longSneaking.isEnabled()) {
cameraY = 1.62F;
} else if (cameraY < 1.62F) {
float delta = 1.62F - cameraY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private void transformLegacyBlockAnimations(AbstractClientPlayerEntity player, f
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
matrices.translate(-0.1F, 0.05F, 0.0F);

if (VisualSettings.INSTANCE.blockHitAnimation.isEnabled()) {
if (VisualSettings.global().blockHitAnimation.isEnabled()) {
final var arm = (hand == Hand.MAIN_HAND) ? player.getMainArm() : player.getMainArm().getOpposite();
applySwingOffset(matrices, arm, swingProgress);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public abstract class MixinItemCooldownManager {

@Inject(method = "set", at = @At("HEAD"), cancellable = true)
private void dontSetCooldown(Item item, int duration, CallbackInfo ci) {
if (DebugSettings.INSTANCE.removeCooldowns.isEnabled()) {
if (DebugSettings.global().removeCooldowns.isEnabled()) {
ci.cancel();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public abstract class MixinItemRenderer {

@Inject(method = "getModel", at = @At("HEAD"), cancellable = true)
private void removeModel(ItemStack stack, World world, LivingEntity entity, int seed, CallbackInfoReturnable<BakedModel> cir) {
if (VisualSettings.INSTANCE.replacePetrifiedOakSlab.isEnabled() && world != null /* world is null in gui rendering */ && stack.isOf(Items.PETRIFIED_OAK_SLAB)) {
if (VisualSettings.global().replacePetrifiedOakSlab.isEnabled() && world != null /* world is null in gui rendering */ && stack.isOf(Items.PETRIFIED_OAK_SLAB)) {
cir.setReturnValue(this.models.getModelManager().getMissingModel());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private double fixDamageCalculation(PlayerEntity player, EntityAttribute attribu
@SuppressWarnings({"InvalidInjectorMethodSignature", "MixinAnnotationTarget"})
@ModifyVariable(method = "getAttributeModifiers", ordinal = 0, at = @At(value = "STORE", ordinal = 1))
private Multimap<EntityAttribute, EntityAttributeModifier> modifyVariableGetAttributeModifiers(Multimap<EntityAttribute, EntityAttributeModifier> modifiers) {
if (!DebugSettings.INSTANCE.replaceAttributeModifiers.isEnabled() || modifiers.isEmpty()) return modifiers;
if (!DebugSettings.global().replaceAttributeModifiers.isEnabled() || modifiers.isEmpty()) return modifiers;

modifiers = HashMultimap.create(modifiers);
modifiers.removeAll(EntityAttributes.GENERIC_ATTACK_DAMAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private boolean removeError(Logger instance, String s, Object o) {

@Redirect(method = "onServerMetadata", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/ServerMetadataS2CPacket;isSecureChatEnforced()Z"))
private boolean removeSecureChatWarning(ServerMetadataS2CPacket instance) {
return instance.isSecureChatEnforced() || VisualSettings.INSTANCE.disableSecureChatWarning.isEnabled();
return instance.isSecureChatEnforced() || VisualSettings.global().disableSecureChatWarning.isEnabled();
}

@Redirect(method = "onSynchronizeRecipes", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/SynchronizeRecipesS2CPacket;getRecipes()Ljava/util/List;"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private void changeChatLength(CallbackInfo ci) {

@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;getIndicatorAt(DD)Lnet/minecraft/client/gui/hud/MessageIndicator;"))
private MessageIndicator removeIndicator(ChatHud instance, double mouseX, double mouseY) {
if (VisualSettings.INSTANCE.hideSignatureIndicator.isEnabled()) {
if (VisualSettings.global().hideSignatureIndicator.isEnabled()) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public abstract class MixinCommandBlockScreen {

@Inject(method = "init", at = @At("TAIL"))
private void removeWidgets(CallbackInfo ci) {
if (VisualSettings.INSTANCE.removeNewerFeaturesFromCommandBlockScreen.isEnabled()) {
if (VisualSettings.global().removeNewerFeaturesFromCommandBlockScreen.isEnabled()) {
modeButton.visible = false;
conditionalModeButton.visible = false;
redstoneTriggerButton.visible = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private int replacePort(InetSocketAddress instance) {

@Redirect(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;send(Lnet/minecraft/network/packet/Packet;)V"))
private void spoofUserName(ClientConnection instance, Packet<?> packet) {
if (AuthenticationSettings.INSTANCE.setSessionNameToClassiCubeNameInServerList.getValue() && ViaFabricPlusClassicMPPassProvider.classiCubeMPPass != null) {
if (AuthenticationSettings.global().setSessionNameToClassiCubeNameInServerList.getValue() && ViaFabricPlusClassicMPPassProvider.classiCubeMPPass != null) {
final var account = ViaFabricPlus.global().getSaveManager().getAccountsSave().getClassicubeAccount();
if (account != null) {
instance.send(new LoginHelloC2SPacket(account.username(), MinecraftClient.getInstance().getSession().getUuidOrNull()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public abstract class MixinCreativeInventoryScreen {

@Inject(method = "init", at = @At("RETURN"))
private void replaceCreativeMenu(CallbackInfo ci) {
if (VisualSettings.INSTANCE.replaceCreativeInventory.isEnabled()) {
if (VisualSettings.global().replaceCreativeInventory.isEnabled()) {
if (ClassicItemSelectionScreen.INSTANCE == null) return;

MinecraftClient.getInstance().setScreen(ClassicItemSelectionScreen.INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public MixinJigsawBlockScreen(Text title) {

@Inject(method = "init", at = @At("RETURN"))
private void injectInit(CallbackInfo ci) {
if (VisualSettings.INSTANCE.removeNewerFeaturesFromJigsawScreen.isEnabled()) {
if (VisualSettings.global().removeNewerFeaturesFromJigsawScreen.isEnabled()) {
nameField.active = false;
jointRotationButton.active = false;
int index = children().indexOf(jointRotationButton);
Expand All @@ -64,7 +64,7 @@ private void injectInit(CallbackInfo ci) {

@Inject(method = "render", at = @At("HEAD"))
private void injectRender(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
if (VisualSettings.INSTANCE.removeNewerFeaturesFromJigsawScreen.isEnabled()) {
if (VisualSettings.global().removeNewerFeaturesFromJigsawScreen.isEnabled()) {
nameField.setText(targetField.getText());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected MixinOptionsScreen(Text title) {

@Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/GridWidget$Adder;add(Lnet/minecraft/client/gui/widget/Widget;)Lnet/minecraft/client/gui/widget/Widget;", ordinal = 10, shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD)
private void showSuperSecretSettings(CallbackInfo ci, GridWidget gridWidget, GridWidget.Adder adder) {
if (VisualSettings.INSTANCE.showSuperSecretSettings.isEnabled() && MinecraftClient.getInstance().player != null) {
if (VisualSettings.global().showSuperSecretSettings.isEnabled() && MinecraftClient.getInstance().player != null) {
this.addDrawableChild(ButtonWidget.builder(Text.literal("Super Secret Settings..."), button -> MinecraftClient.getInstance().gameRenderer.cycleSuperSecretSetting()).dimensions(this.width / 2 + 5, this.height / 6 + 18, 150, 20).build());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public abstract class MixinChatHud {

@WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHudLine$Visible;indicator()Lnet/minecraft/client/gui/hud/MessageIndicator;"), require = 0)
private MessageIndicator removeIndicators(ChatHudLine.Visible instance, Operation<MessageIndicator> original) {
if (VisualSettings.INSTANCE.hideSignatureIndicator.isEnabled()) {
if (VisualSettings.global().hideSignatureIndicator.isEnabled()) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@ public abstract class MixinInGameHud {

@Inject(method = "renderExperienceBar", at = @At("HEAD"), cancellable = true)
private void removeExperienceBar(DrawContext context, int x, CallbackInfo ci) {
if (VisualSettings.INSTANCE.removeNewerHudElements.isEnabled()) ci.cancel();
if (VisualSettings.global().removeNewerHudElements.isEnabled()) ci.cancel();
}

@Inject(method = "renderMountJumpBar", at = @At("HEAD"), cancellable = true)
private void removeMountJumpBar(JumpingMount mount, DrawContext context, int x, CallbackInfo ci) {
if (VisualSettings.INSTANCE.removeNewerHudElements.isEnabled()) ci.cancel();
if (VisualSettings.global().removeNewerHudElements.isEnabled()) ci.cancel();
}

@Inject(method = "renderMountHealth", at = @At("HEAD"), cancellable = true)
private void removeMountHealth(DrawContext context, CallbackInfo ci) {
if (VisualSettings.INSTANCE.removeNewerHudElements.isEnabled()) ci.cancel();
if (VisualSettings.global().removeNewerHudElements.isEnabled()) ci.cancel();
}

@Inject(method = "getHeartCount", at = @At("HEAD"), cancellable = true)
private void removeHungerBar(LivingEntity entity, CallbackInfoReturnable<Integer> cir) {
if (VisualSettings.INSTANCE.removeNewerHudElements.isEnabled()) {
if (VisualSettings.global().removeNewerHudElements.isEnabled()) {
cir.setReturnValue(1);
}
}
Expand All @@ -67,7 +67,7 @@ private void removeHungerBar(LivingEntity entity, CallbackInfoReturnable<Integer
@ModifyExpressionValue(method = "renderStatusBars", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/hud/InGameHud;scaledHeight:I", opcode = Opcodes.GETFIELD),
require = 0)
private int moveHealthDown(int originalValue) {
if (VisualSettings.INSTANCE.removeNewerHudElements.isEnabled()) return originalValue + 6;
if (VisualSettings.global().removeNewerHudElements.isEnabled()) return originalValue + 6;
return originalValue;
}

Expand All @@ -76,7 +76,7 @@ private int moveHealthDown(int originalValue) {
to = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 0)), index = 1,
require = 0)
private int moveArmor(int old) {
if (VisualSettings.INSTANCE.removeNewerHudElements.isEnabled()) return scaledWidth - old - 9;
if (VisualSettings.global().removeNewerHudElements.isEnabled()) return scaledWidth - old - 9;
return old;
}

Expand All @@ -85,7 +85,7 @@ private int moveArmor(int old) {
to = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 0)), index = 2,
require = 0)
private int moveArmorDown(int old) {
if (VisualSettings.INSTANCE.removeNewerHudElements.isEnabled()) return scaledWidth - 39 + 6;
if (VisualSettings.global().removeNewerHudElements.isEnabled()) return scaledWidth - 39 + 6;
return old;
}

Expand All @@ -94,7 +94,7 @@ private int moveArmorDown(int old) {
to = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;pop()V")), index = 1,
require = 0)
private int moveAir(int old) {
if (VisualSettings.INSTANCE.removeNewerHudElements.isEnabled()) return scaledWidth - old - 9;
if (VisualSettings.global().removeNewerHudElements.isEnabled()) return scaledWidth - old - 9;
return old;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private void reset(CallbackInfo ci) {

@Inject(method = "syncRecipeIndex", at = @At("HEAD"))
private void smoothOutRecipeIndex(CallbackInfo ci) {
if (DebugSettings.INSTANCE.smoothOutMerchantScreens.isEnabled()) {
if (DebugSettings.global().smoothOutMerchantScreens.isEnabled()) {
if (viaFabricPlus$previousRecipeIndex != selectedIndex) {
int direction = viaFabricPlus$previousRecipeIndex < selectedIndex ? 1 : -1;
for (int smooth = viaFabricPlus$previousRecipeIndex + direction /* don't send the page we already are on */; smooth != selectedIndex; smooth += direction) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class ViaFabricPlusTransferProvider extends TransferProvider {
public void connectToServer(UserConnection user, InetSocketAddress newAddress) {
final var mc = MinecraftClient.getInstance();
mc.execute(() -> {
if (BedrockSettings.INSTANCE.openPromptGUIToConfirmTransfer.getValue()) {
if (BedrockSettings.global().openPromptGUIToConfirmTransfer.getValue()) {
mc.setScreen(new ConfirmScreen(
(bl) -> {
if (bl)
Expand Down
Loading

0 comments on commit d129cb5

Please sign in to comment.