From 974e338d99325d5dca19e42a99404c5bd1174677 Mon Sep 17 00:00:00 2001 From: RubixDev Date: Thu, 1 Feb 2024 18:06:48 +0800 Subject: [PATCH] fix: incompatible with "Inifinite Banner Patterns" This disables the rule `maxBannerLayers` when `infinite_banner_stack` is loaded, as that mod provides the same functionality but better. --- src/main/java/de/rubixdev/rug/RugSettings.java | 12 ++++++++++++ .../rug/mixins/BannerDuplicateRecipeMixin.java | 8 +++++--- .../java/de/rubixdev/rug/mixins/BannerItemMixin.java | 4 ++-- .../rubixdev/rug/mixins/LoomScreenHandlerMixin.java | 4 ++-- .../java/de/rubixdev/rug/util/MixinConfigPlugin.java | 6 ++++++ src/main/resources/assets/rug/lang/en_us.yml | 3 ++- 6 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/rubixdev/rug/RugSettings.java b/src/main/java/de/rubixdev/rug/RugSettings.java index c9cfb32..56ea1bd 100644 --- a/src/main/java/de/rubixdev/rug/RugSettings.java +++ b/src/main/java/de/rubixdev/rug/RugSettings.java @@ -687,10 +687,22 @@ public String description() { } } + public static boolean shouldApplyBannerLayers() { + return !FabricLoader.getInstance().isModLoaded("infinite_banner_stack"); + } + + public static class conditionMaxBannerLayers implements Condition { + @Override + public boolean shouldRegister() { + return shouldApplyBannerLayers(); + } + } + @Rule( options = {"3", "6", "10", "12"}, strict = false, validators = validatorMaxBannerLayers.class, + conditions = conditionMaxBannerLayers.class, categories = {EXPERIMENTAL, SURVIVAL, CLIENT, CRAFTING, RUG}) public static int maxBannerLayers = 6; diff --git a/src/main/java/de/rubixdev/rug/mixins/BannerDuplicateRecipeMixin.java b/src/main/java/de/rubixdev/rug/mixins/BannerDuplicateRecipeMixin.java index 9f41dee..c73ce5a 100644 --- a/src/main/java/de/rubixdev/rug/mixins/BannerDuplicateRecipeMixin.java +++ b/src/main/java/de/rubixdev/rug/mixins/BannerDuplicateRecipeMixin.java @@ -6,11 +6,12 @@ import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.ModifyConstant; -@Mixin(BannerDuplicateRecipe.class) +@Mixin(value = BannerDuplicateRecipe.class, priority = 990) public class BannerDuplicateRecipeMixin { @ModifyConstant( method = "matches(Lnet/minecraft/inventory/RecipeInputInventory;Lnet/minecraft/world/World;)Z", - constant = @Constant(intValue = 6)) + constant = @Constant(intValue = 6), + require = 0) private int matches_overwriteMaxLayers(final int original) { return RugSettings.maxBannerLayers; } @@ -18,7 +19,8 @@ private int matches_overwriteMaxLayers(final int original) { @ModifyConstant( method = "craft(Lnet/minecraft/inventory/RecipeInputInventory;Lnet/minecraft/registry/DynamicRegistryManager;)Lnet/minecraft/item/ItemStack;", - constant = @Constant(intValue = 6)) + constant = @Constant(intValue = 6), + require = 0) private int craft_overwriteMaxLayers(final int original) { return RugSettings.maxBannerLayers; } diff --git a/src/main/java/de/rubixdev/rug/mixins/BannerItemMixin.java b/src/main/java/de/rubixdev/rug/mixins/BannerItemMixin.java index 91b2dc0..8884005 100644 --- a/src/main/java/de/rubixdev/rug/mixins/BannerItemMixin.java +++ b/src/main/java/de/rubixdev/rug/mixins/BannerItemMixin.java @@ -6,9 +6,9 @@ import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.ModifyConstant; -@Mixin(BannerItem.class) +@Mixin(value = BannerItem.class, priority = 990) public class BannerItemMixin { - @ModifyConstant(method = "appendBannerTooltip", constant = @Constant(intValue = 6)) + @ModifyConstant(method = "appendBannerTooltip", constant = @Constant(intValue = 6), require = 0) private static int overwriteMaxLayers(final int original) { return RugSettings.maxBannerLayers; } diff --git a/src/main/java/de/rubixdev/rug/mixins/LoomScreenHandlerMixin.java b/src/main/java/de/rubixdev/rug/mixins/LoomScreenHandlerMixin.java index 9a72150..3cc2d44 100644 --- a/src/main/java/de/rubixdev/rug/mixins/LoomScreenHandlerMixin.java +++ b/src/main/java/de/rubixdev/rug/mixins/LoomScreenHandlerMixin.java @@ -6,9 +6,9 @@ import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.ModifyConstant; -@Mixin(LoomScreenHandler.class) +@Mixin(value = LoomScreenHandler.class, priority = 990) public class LoomScreenHandlerMixin { - @ModifyConstant(method = "onContentChanged", constant = @Constant(intValue = 6)) + @ModifyConstant(method = "onContentChanged", constant = @Constant(intValue = 6), require = 0) private int overwriteMaxLayers(final int original) { return RugSettings.maxBannerLayers; } diff --git a/src/main/java/de/rubixdev/rug/util/MixinConfigPlugin.java b/src/main/java/de/rubixdev/rug/util/MixinConfigPlugin.java index e3ef61d..68162b8 100644 --- a/src/main/java/de/rubixdev/rug/util/MixinConfigPlugin.java +++ b/src/main/java/de/rubixdev/rug/util/MixinConfigPlugin.java @@ -28,9 +28,15 @@ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { "de.rubixdev.rug.mixins.reach.ServerPlayerInteractionManagerMixin", "de.rubixdev.rug.mixins.reach.ServerPlayNetworkHandlerMixin", "de.rubixdev.rug.mixins.reach.VehicleInventoryMixin"); + List bannerLayersMixins = Lists.newArrayList( + "de.rubixdev.rug.mixins.BannerDuplicateRecipeMixin", + "de.rubixdev.rug.mixins.BannerItemMixin", + "de.rubixdev.rug.mixins.LoomScreenHandlerMixin"); if (reachDistanceMixins.contains(mixinClassName)) { return RugSettings.shouldApplyReachDistance(); + } else if (bannerLayersMixins.contains(mixinClassName)) { + return RugSettings.shouldApplyBannerLayers(); } return true; } diff --git a/src/main/resources/assets/rug/lang/en_us.yml b/src/main/resources/assets/rug/lang/en_us.yml index 528f6f9..05c3d31 100644 --- a/src/main/resources/assets/rug/lang/en_us.yml +++ b/src/main/resources/assets/rug/lang/en_us.yml @@ -185,6 +185,7 @@ rug: desc: Maximum number of layers, that can be applied to a banner extra: '0': This only works for clients with this mod installed and the Banner tooltips never show more than 6 layers + '1': Is disabled when [Infinite Banner Patterns](https://modrinth.com/mod/infinite-banner-patterns) is installed additional: '[Idea from SouthernPixel](https://github.com/gnembon/carpet-extra/issues/111)' minecartMaxSpeedMultiplier: desc: Maximum minecart speed multiplier @@ -226,7 +227,7 @@ rug: desc: Reach in which you can place and break blocks. Value will be 0.5 higher in creative extra: '0': Mod needed on server and client for this feature to work - additional: Is disabled when [reach-entity-attributes](https://github.com/JamiesWhiteShirt/reach-entity-attributes) or [Pehkui](https://www.curseforge.com/minecraft/mc-mods/pehkui) is installed + '1': Is disabled when [reach-entity-attributes](https://github.com/JamiesWhiteShirt/reach-entity-attributes) or [Pehkui](https://www.curseforge.com/minecraft/mc-mods/pehkui) is installed redstoneLampTurnOffDelay: desc: Delay in game ticks for Redstone Lamps to turn off sculkBlocksAlwaysDropXp: