From 0d8a4e4196507bf3e148ae6976d40a60edb549ec Mon Sep 17 00:00:00 2001 From: Chris Toph Date: Sun, 23 Feb 2025 17:39:12 -0500 Subject: [PATCH] Refactor compatibility system for modular integration - Migrated mod-specific compatibility logic to a unified `CompatRegistry`, improving modularity and scalability. - Enhanced `ToolMaterials` interface and enums to support generics and lazy-loaded repair ingredients. - Simplified and centralized sword registration logic while removing TFMG-specific code. --- .../simplycompat/compat/CompatRecord.java | 55 +++++++++ .../compat/CreateToolMaterials.java | 107 ++++++++++++++++++ .../cc/toph/simplycompat/compat/TFMG.java | 28 ----- .../compat/TFMGToolMaterials.java | 40 ++++--- .../cc/toph/simplycompat/config/Config.java | 72 ++++++------ .../simplycompat/config/ConfigProvider.java | 58 +++++----- .../item/SimplyCompatToolMaterials.java | 26 +++-- .../simplycompat/registry/CompatRegistry.java | 45 ++++++++ .../simplycompat/registry/ConfigRegistry.java | 21 +++- .../simplycompat/registry/ItemsRegistry.java | 10 +- .../toph/simplycompat/util/ToolMaterials.java | 5 +- 11 files changed, 341 insertions(+), 126 deletions(-) create mode 100644 common/src/main/java/cc/toph/simplycompat/compat/CompatRecord.java create mode 100644 common/src/main/java/cc/toph/simplycompat/compat/CreateToolMaterials.java delete mode 100644 common/src/main/java/cc/toph/simplycompat/compat/TFMG.java create mode 100644 common/src/main/java/cc/toph/simplycompat/registry/CompatRegistry.java diff --git a/common/src/main/java/cc/toph/simplycompat/compat/CompatRecord.java b/common/src/main/java/cc/toph/simplycompat/compat/CompatRecord.java new file mode 100644 index 0000000..b7af703 --- /dev/null +++ b/common/src/main/java/cc/toph/simplycompat/compat/CompatRecord.java @@ -0,0 +1,55 @@ +package cc.toph.simplycompat.compat; + +import cc.toph.simplycompat.registry.ItemsRegistry; +import cc.toph.simplycompat.util.ToolMaterials; +import cc.toph.simplycompat.util.WeaponType; +import dev.architectury.platform.Platform; + +/** + * The CompatRecord class represents a compatibility record used for managing + * mod integrations and extending functionality based on certain requirements. + * This record checks whether a specific mod is present, its version is compatible, + * and registers tool materials and weapon types if the conditions are met. + * + * @param A type parameter that extends Enum and implements the ToolMaterials + * interface. This defines the supported tool materials for the integration. + * @param modId The unique identifier for the mod to be checked. + * @param requiredVersion The minimum version of the mod that is required for compatibility. + * @param toolMaterialClass The class representing the enumeration of tool materials to register. + */ +public record CompatRecord & ToolMaterials>( + String modId, + String requiredVersion, + Class toolMaterialClass +) { + + /** + * Checks whether the mod's version is loaded + * and passes the required version check. + */ + public boolean passCheck() { + if (Platform.isModLoaded(modId)) { + return Platform.getMod(modId) + .getVersion() + .compareTo(requiredVersion) >= 0; + } + return false; + } + + /** + * Registers swords for each enum constant in toolMaterialClass, + * if the material is enabled. + */ + public void register() { + if (!passCheck()) { + return; + } + for (WeaponType type : WeaponType.values()) { + for (E material : toolMaterialClass.getEnumConstants()) { + if (material.isEnabled()) { + ItemsRegistry.registerSword(material, type); + } + } + } + } +} diff --git a/common/src/main/java/cc/toph/simplycompat/compat/CreateToolMaterials.java b/common/src/main/java/cc/toph/simplycompat/compat/CreateToolMaterials.java new file mode 100644 index 0000000..a0c59ff --- /dev/null +++ b/common/src/main/java/cc/toph/simplycompat/compat/CreateToolMaterials.java @@ -0,0 +1,107 @@ +package cc.toph.simplycompat.compat; + +import cc.toph.simplycompat.registry.ConfigRegistry; +import cc.toph.simplycompat.util.ToolMaterials; +import net.minecraft.util.LazyLoadedValue; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.level.ItemLike; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Supplier; + +public enum CreateToolMaterials implements ToolMaterials { + STURDY( + 3, + 1800, + 8.0f, + 3.5f, + ConfigRegistry.WEAPON_ATTRIBUTES.STURDY, + 14, + ConfigRegistry.WEAPON_ATTRIBUTES.STURDY_ENABLED, +// () -> Ingredient.of(new ItemLike[]{(ItemLike) AllItems.STURDY_SHEET.get()}) + () -> Ingredient.of(new ItemLike[]{(ItemLike) Items.STICK}) + ); + + private final int level; + private final int uses; + private final float speed; + private final float attackDamageBonus; + private final float damageModifier; + private final int enchantmentValue; + private final boolean enabled; + private final LazyLoadedValue repairIngredient; + + CreateToolMaterials( + int level, + int uses, + float speed, + float attackDamageBonus, + float damageModifier, + int enchantmentValue, + boolean enabled, + Supplier repairIngredient + ) { + this.level = level; + this.uses = uses; + this.speed = speed; + this.attackDamageBonus = attackDamageBonus; + this.enchantmentValue = enchantmentValue; + this.damageModifier = damageModifier; + this.enabled = enabled; + this.repairIngredient = new LazyLoadedValue(repairIngredient); + } + + @Override + public String getName() { + return this.name().toLowerCase(); + } + + @Override + public int getUses() { + return uses; + } + + @Override + public float getSpeed() { + return speed; + } + + @Override + public float getAttackDamageBonus() { + return attackDamageBonus; + } + + @Override + public float getDamageModifier() { + return damageModifier; + } + + @Override + public int getLevel() { + return level; + } + + @Override + public int getEnchantmentValue() { + return enchantmentValue; + } + + @Override + public boolean isEnabled() { + return enabled; + } + + + @Override + public @NotNull Ingredient getRepairIngredient() { + return this.repairIngredient.get(); + } + + @Override + public CreateToolMaterials[] getValues() { + return values(); + } + + +} \ No newline at end of file diff --git a/common/src/main/java/cc/toph/simplycompat/compat/TFMG.java b/common/src/main/java/cc/toph/simplycompat/compat/TFMG.java deleted file mode 100644 index f04b41e..0000000 --- a/common/src/main/java/cc/toph/simplycompat/compat/TFMG.java +++ /dev/null @@ -1,28 +0,0 @@ -package cc.toph.simplycompat.compat; - -import cc.toph.simplycompat.registry.ItemsRegistry; -import cc.toph.simplycompat.util.WeaponType; -import dev.architectury.platform.Platform; - -public class TFMG { - - public static final String MOD_ID = "tfmg"; - public static final String requiredVersion = "0.9.3-1.20.1"; - - public static void register() { - if (!passCheck()) return; - - for (WeaponType type : WeaponType.values()) { - for (TFMGToolMaterials material : TFMGToolMaterials.values()) { - if (material.isEnabled()) ItemsRegistry.registerSword(material, type); - } - } - } - - public static boolean passCheck() { - if (Platform.isModLoaded(MOD_ID)) { - return Platform.getMod(MOD_ID).getVersion().compareTo(requiredVersion) >= 0; - } - return false; - } -} \ No newline at end of file diff --git a/common/src/main/java/cc/toph/simplycompat/compat/TFMGToolMaterials.java b/common/src/main/java/cc/toph/simplycompat/compat/TFMGToolMaterials.java index 2d56eff..0cf79e7 100644 --- a/common/src/main/java/cc/toph/simplycompat/compat/TFMGToolMaterials.java +++ b/common/src/main/java/cc/toph/simplycompat/compat/TFMGToolMaterials.java @@ -3,31 +3,36 @@ package cc.toph.simplycompat.compat; import cc.toph.simplycompat.registry.ConfigRegistry; import cc.toph.simplycompat.util.ToolMaterials; import com.drmangotea.tfmg.registry.TFMGTiers; -import com.simibubi.create.AllTags; -import net.minecraft.world.item.Tier; +import net.minecraft.util.LazyLoadedValue; +import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.level.ItemLike; import org.jetbrains.annotations.NotNull; -public enum TFMGToolMaterials implements ToolMaterials, Tier { +import java.util.function.Supplier; + +public enum TFMGToolMaterials implements ToolMaterials { ALUMINUM( TFMGTiers.ALUMINUM.getLevel(), TFMGTiers.ALUMINUM.getUses(), TFMGTiers.ALUMINUM.getSpeed(), TFMGTiers.ALUMINUM.getAttackDamageBonus(), - ConfigRegistry.WEAPON_ATTRIBUTES.STEEL, + ConfigRegistry.WEAPON_ATTRIBUTES.ALUMINUM, TFMGTiers.ALUMINUM.getEnchantmentValue(), - ConfigRegistry.WEAPON_ATTRIBUTES.STEEL_ENABLED, - Ingredient.of(AllTags.AllItemTags.CREATE_INGOTS.tag) + ConfigRegistry.WEAPON_ATTRIBUTES.ALUMINUM_ENABLED, +// () -> Ingredient.of(new ItemLike[]{(ItemLike) TFMGItems.ALUMINUM_INGOT.get()}) + () -> Ingredient.of(new ItemLike[]{(ItemLike) Items.STICK}) ), LEAD( TFMGTiers.LEAD.getLevel(), TFMGTiers.LEAD.getUses(), TFMGTiers.LEAD.getSpeed(), TFMGTiers.LEAD.getAttackDamageBonus(), - ConfigRegistry.WEAPON_ATTRIBUTES.STEEL, + ConfigRegistry.WEAPON_ATTRIBUTES.LEAD, TFMGTiers.LEAD.getEnchantmentValue(), - ConfigRegistry.WEAPON_ATTRIBUTES.STEEL_ENABLED, - Ingredient.of(AllTags.AllItemTags.CREATE_INGOTS.tag) + ConfigRegistry.WEAPON_ATTRIBUTES.LEAD_ENABLED, +// () -> Ingredient.of(new ItemLike[]{(ItemLike) TFMGItems.LEAD_INGOT.get()}) + () -> Ingredient.of(new ItemLike[]{(ItemLike) Items.STICK}) ), STEEL( TFMGTiers.STEEL.getLevel(), @@ -37,7 +42,8 @@ public enum TFMGToolMaterials implements ToolMaterials, Tier { ConfigRegistry.WEAPON_ATTRIBUTES.STEEL, TFMGTiers.STEEL.getEnchantmentValue(), ConfigRegistry.WEAPON_ATTRIBUTES.STEEL_ENABLED, - Ingredient.of(AllTags.AllItemTags.CREATE_INGOTS.tag) +// () -> Ingredient.of(new ItemLike[]{(ItemLike) TFMGItems.STEEL_INGOT.get()}) + () -> Ingredient.of(new ItemLike[]{(ItemLike) Items.STICK}) ); private final int level; @@ -47,7 +53,7 @@ public enum TFMGToolMaterials implements ToolMaterials, Tier { private final float damageModifier; private final int enchantmentValue; private final boolean enabled; - private final Ingredient repairIngredient; + private final LazyLoadedValue repairIngredient; TFMGToolMaterials( int level, @@ -57,7 +63,7 @@ public enum TFMGToolMaterials implements ToolMaterials, Tier { float damageModifier, int enchantmentValue, boolean enabled, - Ingredient repairIngredient + Supplier repairIngredient ) { this.level = level; this.uses = uses; @@ -66,7 +72,7 @@ public enum TFMGToolMaterials implements ToolMaterials, Tier { this.enchantmentValue = enchantmentValue; this.damageModifier = damageModifier; this.enabled = enabled; - this.repairIngredient = repairIngredient; + this.repairIngredient = new LazyLoadedValue(repairIngredient); } @@ -113,7 +119,13 @@ public enum TFMGToolMaterials implements ToolMaterials, Tier { @Override public @NotNull Ingredient getRepairIngredient() { - return this.repairIngredient; + return this.repairIngredient.get(); + } + + + @Override + public TFMGToolMaterials[] getValues() { + return values(); } } \ No newline at end of file diff --git a/common/src/main/java/cc/toph/simplycompat/config/Config.java b/common/src/main/java/cc/toph/simplycompat/config/Config.java index a39541f..fde3019 100644 --- a/common/src/main/java/cc/toph/simplycompat/config/Config.java +++ b/common/src/main/java/cc/toph/simplycompat/config/Config.java @@ -1,48 +1,46 @@ package cc.toph.simplycompat.config; -import cc.toph.simplycompat.SimplyCompat; - public class Config { - private SimpleConfig config; - private final ConfigProvider provider; + private final SimpleConfig config; + private final ConfigProvider provider; - public Config(ConfigProvider provider) { - this.provider = provider; - config = SimpleConfig.of(provider.getNamespace()).provider(provider).request(); - } + public Config(ConfigProvider provider) { + this.provider = provider; + config = SimpleConfig.of(provider.getNamespace()).provider(provider).request(); + } - public void register() { - config.update(); - } + public void register() { + config.update(); + } - // Overloaded registerProp for float - public float registerProp(String key, float defaultValue, String comment) { - provider.addKeyValuePair(key, defaultValue, comment); - // Cast needed because getOrDefault for numbers returns double - return (float) config.getOrDefault(key, defaultValue); - } + // Overloaded registerProp for float + public float registerProp(String key, float defaultValue, String comment) { + provider.addKeyValuePair(key, defaultValue, comment); + // Cast needed because getOrDefault for numbers returns double + return (float) config.getOrDefault(key, defaultValue); + } - // Overloaded registerProp for int - public int registerProp(String key, int defaultValue, String comment) { - provider.addKeyValuePair(key, defaultValue, comment); - return config.getOrDefault(key, defaultValue); - } + // Overloaded registerProp for int + public int registerProp(String key, int defaultValue, String comment) { + provider.addKeyValuePair(key, defaultValue, comment); + return config.getOrDefault(key, defaultValue); + } - // Overloaded registerProp for double - public double registerProp(String key, double defaultValue, String comment) { - provider.addKeyValuePair(key, defaultValue, comment); - return config.getOrDefault(key, defaultValue); - } + // Overloaded registerProp for double + public double registerProp(String key, double defaultValue, String comment) { + provider.addKeyValuePair(key, defaultValue, comment); + return config.getOrDefault(key, defaultValue); + } - // Overloaded registerProp for String - public String registerProp(String key, String defaultValue, String comment) { - provider.addKeyValuePair(key, defaultValue, comment); - return config.getOrDefault(key, defaultValue); - } + // Overloaded registerProp for String + public String registerProp(String key, String defaultValue, String comment) { + provider.addKeyValuePair(key, defaultValue, comment); + return config.getOrDefault(key, defaultValue); + } - // Overloaded registerProp for boolean - public boolean registerProp(String key, boolean defaultValue, String comment) { - provider.addKeyValuePair(key, defaultValue, comment); - return config.getOrDefault(key, defaultValue); - } + // Overloaded registerProp for boolean + public boolean registerProp(String key, boolean defaultValue, String comment) { + provider.addKeyValuePair(key, defaultValue, comment); + return config.getOrDefault(key, defaultValue); + } } \ No newline at end of file diff --git a/common/src/main/java/cc/toph/simplycompat/config/ConfigProvider.java b/common/src/main/java/cc/toph/simplycompat/config/ConfigProvider.java index a169f2a..beb0922 100644 --- a/common/src/main/java/cc/toph/simplycompat/config/ConfigProvider.java +++ b/common/src/main/java/cc/toph/simplycompat/config/ConfigProvider.java @@ -5,40 +5,40 @@ import cc.toph.simplycompat.SimplyCompatExpectPlatform; import java.util.HashMap; public class ConfigProvider implements SimpleConfig.DefaultConfig { - private final String namespace; - private final HashMap configMap = new HashMap<>(); - private String contents = String.format(""" - ## Simply Compat Config - ## Version: %s - - """, SimplyCompatExpectPlatform.getVersion()); + private final String namespace; + private final HashMap configMap = new HashMap<>(); + private String contents = String.format(""" + ## Simply Compat Config + ## Version: %s + + """, SimplyCompatExpectPlatform.getVersion()); - public ConfigProvider(String namespace) { - this.namespace = namespace; - } + public ConfigProvider(String namespace) { + this.namespace = namespace; + } - public void addKeyValuePair(String key, Object value, String comment) { - String stringValue = String.valueOf(value); // safely handle `null` too - configMap.put(key, stringValue); - contents += String.format(""" - # %s - %s = %s - """, comment, key, value); - } + public void addKeyValuePair(String key, Object value, String comment) { + String stringValue = String.valueOf(value); // safely handle `null` too + configMap.put(key, stringValue); + contents += String.format(""" + # %s + %s = %s + """, comment, key, value); + } - @Override - public String get(String namespace) { - return contents; - } + @Override + public String get(String namespace) { + return contents; + } - @Override - public HashMap getMap() { - return configMap; - } + @Override + public HashMap getMap() { + return configMap; + } - public String getNamespace() { - return namespace; - } + public String getNamespace() { + return namespace; + } } diff --git a/common/src/main/java/cc/toph/simplycompat/item/SimplyCompatToolMaterials.java b/common/src/main/java/cc/toph/simplycompat/item/SimplyCompatToolMaterials.java index f26d446..054e55c 100644 --- a/common/src/main/java/cc/toph/simplycompat/item/SimplyCompatToolMaterials.java +++ b/common/src/main/java/cc/toph/simplycompat/item/SimplyCompatToolMaterials.java @@ -2,12 +2,15 @@ package cc.toph.simplycompat.item; import cc.toph.simplycompat.registry.ConfigRegistry.WEAPON_ATTRIBUTES; import cc.toph.simplycompat.util.ToolMaterials; -import net.minecraft.tags.ItemTags; -import net.minecraft.world.item.Tier; +import net.minecraft.util.LazyLoadedValue; +import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.level.ItemLike; import org.jetbrains.annotations.NotNull; -public enum SimplyCompatToolMaterials implements ToolMaterials, Tier { +import java.util.function.Supplier; + +public enum SimplyCompatToolMaterials implements ToolMaterials { COPPER( 1, 125, @@ -16,9 +19,9 @@ public enum SimplyCompatToolMaterials implements ToolMaterials, Tier { WEAPON_ATTRIBUTES.COPPER, 8, WEAPON_ATTRIBUTES.COPPER_ENABLED, - Ingredient.of(ItemTags.COPPER_ORES) + () -> Ingredient.of(new ItemLike[]{(ItemLike) Items.COPPER_INGOT}) ); - + private final int level; private final int uses; private final float speed; @@ -26,7 +29,7 @@ public enum SimplyCompatToolMaterials implements ToolMaterials, Tier { private final float damageModifier; private final int enchantmentValue; private final boolean enabled; - private final Ingredient repairIngredient; + private final LazyLoadedValue repairIngredient; SimplyCompatToolMaterials( int level, @@ -36,7 +39,7 @@ public enum SimplyCompatToolMaterials implements ToolMaterials, Tier { float damageModifier, int enchantmentValue, boolean enabled, - Ingredient repairIngredient + Supplier repairIngredient ) { this.level = level; this.uses = uses; @@ -45,7 +48,7 @@ public enum SimplyCompatToolMaterials implements ToolMaterials, Tier { this.enchantmentValue = enchantmentValue; this.damageModifier = damageModifier; this.enabled = enabled; - this.repairIngredient = repairIngredient; + this.repairIngredient = new LazyLoadedValue(repairIngredient); } @@ -91,7 +94,12 @@ public enum SimplyCompatToolMaterials implements ToolMaterials, Tier { @Override public @NotNull Ingredient getRepairIngredient() { - return this.repairIngredient; + return this.repairIngredient.get(); + } + + @Override + public SimplyCompatToolMaterials[] getValues() { + return values(); } } diff --git a/common/src/main/java/cc/toph/simplycompat/registry/CompatRegistry.java b/common/src/main/java/cc/toph/simplycompat/registry/CompatRegistry.java new file mode 100644 index 0000000..baff94f --- /dev/null +++ b/common/src/main/java/cc/toph/simplycompat/registry/CompatRegistry.java @@ -0,0 +1,45 @@ +package cc.toph.simplycompat.registry; + +import cc.toph.simplycompat.compat.CompatRecord; +import cc.toph.simplycompat.compat.CreateToolMaterials; +import cc.toph.simplycompat.compat.TFMGToolMaterials; +import com.drmangotea.tfmg.CreateTFMG; +import com.simibubi.create.Create; + + +/** + * A registry for compatibility records. Each record represents + * a supported mod's integration setup. + * + *

Use {@link #registerAll()} to initialize all integrations.

+ */ + +public final class CompatRegistry { + + /** + * Compatibility setup for the Create mod. + */ + public static final CompatRecord CREATE = new CompatRecord<>( + Create.ID, + "0.5.1.j-55", + CreateToolMaterials.class + ); + + /** + * Compatibility setup for the TFMG mod. + */ + public static final CompatRecord TFMG = new CompatRecord<>( + CreateTFMG.MOD_ID, + "0.9.3-1.20.1", + TFMGToolMaterials.class + ); + + /** + * Initializes all declared compat records. + */ + public static void registerAll() { + CompatRegistry.CREATE.register(); + CompatRegistry.TFMG.register(); + } +} + diff --git a/common/src/main/java/cc/toph/simplycompat/registry/ConfigRegistry.java b/common/src/main/java/cc/toph/simplycompat/registry/ConfigRegistry.java index 36d1b5a..0e46af6 100644 --- a/common/src/main/java/cc/toph/simplycompat/registry/ConfigRegistry.java +++ b/common/src/main/java/cc/toph/simplycompat/registry/ConfigRegistry.java @@ -1,10 +1,9 @@ package cc.toph.simplycompat.registry; -import cc.toph.simplycompat.compat.TFMG; import cc.toph.simplycompat.config.Config; import cc.toph.simplycompat.config.ConfigProvider; -public class ConfigRegistry { +public final class ConfigRegistry { public static final class WEAPON_ATTRIBUTES { public static float COPPER; @@ -15,6 +14,8 @@ public class ConfigRegistry { public static boolean LEAD_ENABLED; public static float STEEL; public static boolean STEEL_ENABLED; + public static float STURDY; + public static boolean STURDY_ENABLED; public static final ConfigProvider PROVIDER = new ConfigProvider("weapon_attributes"); @@ -33,7 +34,21 @@ public class ConfigRegistry { "Enable Copper Swords" ); - if (TFMG.passCheck()) { + if (CompatRegistry.CREATE.passCheck()) { + STURDY = common.registerProp( + "sturdy_damageModifier", + 4.0f, + "Sturdy Damage Modifier" + ); + + STURDY_ENABLED = common.registerProp( + "sturdy_enabled", + true, + "Enable Sturdy Swords" + ); + } + + if (CompatRegistry.TFMG.passCheck()) { ALUMINUM = common.registerProp( "aluminum_damageModifier", 3.0f, diff --git a/common/src/main/java/cc/toph/simplycompat/registry/ItemsRegistry.java b/common/src/main/java/cc/toph/simplycompat/registry/ItemsRegistry.java index a743395..4dc96ac 100644 --- a/common/src/main/java/cc/toph/simplycompat/registry/ItemsRegistry.java +++ b/common/src/main/java/cc/toph/simplycompat/registry/ItemsRegistry.java @@ -1,7 +1,6 @@ package cc.toph.simplycompat.registry; import cc.toph.simplycompat.SimplyCompat; -import cc.toph.simplycompat.compat.TFMG; import cc.toph.simplycompat.item.SimplyCompatToolMaterials; import cc.toph.simplycompat.util.ToolMaterials; import cc.toph.simplycompat.util.WeaponType; @@ -10,14 +9,14 @@ import net.minecraft.core.registries.Registries; import net.minecraft.world.item.Item; import net.sweenus.simplyswords.item.SimplySwordsSwordItem; -public class ItemsRegistry { +public final class ItemsRegistry { public static final DeferredRegister ITEMS = DeferredRegister.create( SimplyCompat.MOD_ID, Registries.ITEM ); - public static void registerSword( - ToolMaterials material, + public static & ToolMaterials> void registerSword( + ToolMaterials material, WeaponType type ) { @@ -38,6 +37,7 @@ public class ItemsRegistry { * registered within the item registry for use within the mod. */ public static void registerSwords() { + // Register "Vanilla" swords for (WeaponType type : WeaponType.values()) { for (SimplyCompatToolMaterials material : SimplyCompatToolMaterials.values()) { @@ -45,7 +45,7 @@ public class ItemsRegistry { } } - TFMG.register(); + CompatRegistry.registerAll(); ITEMS.register(); } } diff --git a/common/src/main/java/cc/toph/simplycompat/util/ToolMaterials.java b/common/src/main/java/cc/toph/simplycompat/util/ToolMaterials.java index 48bbcb4..a0c0db6 100644 --- a/common/src/main/java/cc/toph/simplycompat/util/ToolMaterials.java +++ b/common/src/main/java/cc/toph/simplycompat/util/ToolMaterials.java @@ -13,7 +13,8 @@ import net.minecraft.world.item.Tier; *

* Suggested implementation with Enums */ -public interface ToolMaterials extends Tier { +public interface ToolMaterials & ToolMaterials> + extends Tier { /** * Returns the name of the enum constant in lowercase. @@ -59,4 +60,6 @@ public interface ToolMaterials extends Tier { * @return boolean */ boolean isEnabled(); + + E[] getValues(); }