Skip to content

Commit

Permalink
fix: incompatible with "Inifinite Banner Patterns"
Browse files Browse the repository at this point in the history
This disables the rule `maxBannerLayers` when `infinite_banner_stack` is
loaded, as that mod provides the same functionality but better.
  • Loading branch information
RubixDev committed Feb 1, 2024
1 parent 9ee1ad7 commit 974e338
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 8 deletions.
12 changes: 12 additions & 0 deletions src/main/java/de/rubixdev/rug/RugSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@
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;
}

@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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/rubixdev/rug/mixins/BannerItemMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/de/rubixdev/rug/util/MixinConfigPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/assets/rug/lang/en_us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 974e338

Please sign in to comment.