From 707cf4d0fcfc13482d05d9eea69dc2c2583227df Mon Sep 17 00:00:00 2001 From: Waiting Idly <25394029+WaitingIdly@users.noreply.github.com> Date: Thu, 4 Apr 2024 20:38:29 -0700 Subject: [PATCH 1/2] Config to Disable Rendering Items in Smeltery --- README.md | 1 + .../universaltweaks/config/UTConfigMods.java | 4 ++++ .../mixin/SmelteryRendererMixin.java | 22 +++++++++++++++++++ .../resources/mixins.mods.tconstruct.json | 2 +- 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/main/java/mod/acgaming/universaltweaks/mods/tconstruct/mixin/SmelteryRendererMixin.java diff --git a/README.md b/README.md index fa227008..a9d1b2f4 100644 --- a/README.md +++ b/README.md @@ -330,6 +330,7 @@ All changes are toggleable via config files. * **Duplication Fixes:** Fixes various duplication exploits * **Insolator Custom Monoculture:** Adds Monoculture Cycle integration to desired phytogenic insolator recipes added by ModTweaker * **Tinkers' Construct** + * **Disable Rendering Items in Smeltery:** Disables rendering items in the world when they are inside the Smeltery to prevent lag while rendering * **Duplication Fixes:** Fixes various duplication exploits * **Gaseous Fluids:** Excludes gaseous fluids from being transferable via faucets * **Material Blacklist:** Hides tool/bow materials in the 'Materials and You' book diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java index 97b9aebe..786d0681 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java @@ -790,6 +790,10 @@ public static class TinkersConstructCategory @Config.Comment("Excludes gaseous fluids from being transferable via faucets") public boolean utTConGaseousFluidsToggle = false; + @Config.Name("Disable Rendering Items in Smeltery") + @Config.Comment("Disables rendering items in the world when they are inside the Smeltery to prevent lag while rendering") + public boolean utDisableItemRenderingSmeltery = false; + @Config.RequiresMcRestart @Config.Name("Material Blacklist") @Config.Comment diff --git a/src/main/java/mod/acgaming/universaltweaks/mods/tconstruct/mixin/SmelteryRendererMixin.java b/src/main/java/mod/acgaming/universaltweaks/mods/tconstruct/mixin/SmelteryRendererMixin.java new file mode 100644 index 00000000..b051ea64 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/mods/tconstruct/mixin/SmelteryRendererMixin.java @@ -0,0 +1,22 @@ +package mod.acgaming.universaltweaks.mods.tconstruct.mixin; + +import mod.acgaming.universaltweaks.config.UTConfigMods; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import slimeknights.tconstruct.smeltery.client.SmelteryRenderer; +import slimeknights.tconstruct.smeltery.client.SmelteryTankRenderer; +import slimeknights.tconstruct.smeltery.tileentity.TileSmeltery; + +// Courtesy of WaitingIdly +@Mixin(value = SmelteryRenderer.class, remap = false) +public abstract class SmelteryRendererMixin extends SmelteryTankRenderer +{ + @Inject(method = "render", at = @At(value = "INVOKE", target = "Lslimeknights/tconstruct/smeltery/client/SmelteryRenderer;renderFluids(Lslimeknights/tconstruct/library/smeltery/SmelteryTank;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;DDD)V", shift = At.Shift.AFTER), cancellable = true) + public void utRender(CallbackInfo ci) + { + if (!UTConfigMods.TINKERS_CONSTRUCT.utDisableItemRenderingSmeltery) return; + ci.cancel(); + } +} diff --git a/src/main/resources/mixins.mods.tconstruct.json b/src/main/resources/mixins.mods.tconstruct.json index f2c906c9..37679fdc 100644 --- a/src/main/resources/mixins.mods.tconstruct.json +++ b/src/main/resources/mixins.mods.tconstruct.json @@ -3,5 +3,5 @@ "refmap": "universaltweaks.refmap.json", "minVersion": "0.8", "compatibilityLevel": "JAVA_8", - "mixins": ["MaterialAccessor", "UTEntityProjectileBaseMixin", "UTFaucetMixin", "UTLongSwordMixin", "UTRapierMixin"] + "mixins": ["MaterialAccessor", "UTEntityProjectileBaseMixin", "UTFaucetMixin", "UTLongSwordMixin", "UTRapierMixin", "SmelteryRendererMixin"] } \ No newline at end of file From 523a6e0026bc077e6a0ef4025b94b816f9252e8b Mon Sep 17 00:00:00 2001 From: Waiting Idly <25394029+WaitingIdly@users.noreply.github.com> Date: Fri, 5 Apr 2024 02:26:35 -0700 Subject: [PATCH 2/2] convert to int --- .../acgaming/universaltweaks/config/UTConfigMods.java | 11 ++++++++--- .../mods/tconstruct/mixin/SmelteryRendererMixin.java | 10 +++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java index 786d0681..844b4298 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java @@ -790,9 +790,14 @@ public static class TinkersConstructCategory @Config.Comment("Excludes gaseous fluids from being transferable via faucets") public boolean utTConGaseousFluidsToggle = false; - @Config.Name("Disable Rendering Items in Smeltery") - @Config.Comment("Disables rendering items in the world when they are inside the Smeltery to prevent lag while rendering") - public boolean utDisableItemRenderingSmeltery = false; + @Config.Name("Maximum Items to Render in Smeltery") + @Config.Comment + ({ + "Determines the maximum number of possible items to display before not rendering any to prevent substantial lag", + "0 to disable rendering items in the smeltery entirely", + "-1 for the default, which is always rendering items" + }) + public int utMaximumItemRendersInSmeltery = -1; @Config.RequiresMcRestart @Config.Name("Material Blacklist") diff --git a/src/main/java/mod/acgaming/universaltweaks/mods/tconstruct/mixin/SmelteryRendererMixin.java b/src/main/java/mod/acgaming/universaltweaks/mods/tconstruct/mixin/SmelteryRendererMixin.java index b051ea64..3013e9af 100644 --- a/src/main/java/mod/acgaming/universaltweaks/mods/tconstruct/mixin/SmelteryRendererMixin.java +++ b/src/main/java/mod/acgaming/universaltweaks/mods/tconstruct/mixin/SmelteryRendererMixin.java @@ -9,14 +9,18 @@ import slimeknights.tconstruct.smeltery.client.SmelteryTankRenderer; import slimeknights.tconstruct.smeltery.tileentity.TileSmeltery; +import javax.annotation.Nonnull; + // Courtesy of WaitingIdly @Mixin(value = SmelteryRenderer.class, remap = false) public abstract class SmelteryRendererMixin extends SmelteryTankRenderer { @Inject(method = "render", at = @At(value = "INVOKE", target = "Lslimeknights/tconstruct/smeltery/client/SmelteryRenderer;renderFluids(Lslimeknights/tconstruct/library/smeltery/SmelteryTank;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/BlockPos;DDD)V", shift = At.Shift.AFTER), cancellable = true) - public void utRender(CallbackInfo ci) + public void utRender(@Nonnull TileSmeltery smeltery, double x, double y, double z, float partialTicks, int destroyStage, float alpha, CallbackInfo ci) { - if (!UTConfigMods.TINKERS_CONSTRUCT.utDisableItemRenderingSmeltery) return; - ci.cancel(); + if (UTConfigMods.TINKERS_CONSTRUCT.utMaximumItemRendersInSmeltery == -1) return; + if (smeltery.getSizeInventory() > UTConfigMods.TINKERS_CONSTRUCT.utMaximumItemRendersInSmeltery) { + ci.cancel(); + } } }