Add TFMG compatibility and refactor tool material handling
- Introduced support for TFMG mod with new materials (Aluminum, Lead, Steel). - Refactored tool material management by adding a `ToolMaterials` interface. - Enhanced configurability with enable flags for materials and streamlined mod version checks.
This commit is contained in:
parent
bd0125cc21
commit
c20ec9580e
7 changed files with 405 additions and 160 deletions
|
@ -1,6 +1,5 @@
|
||||||
package cc.toph.simplycompat;
|
package cc.toph.simplycompat;
|
||||||
|
|
||||||
import cc.toph.simplycompat.config.Config;
|
|
||||||
import cc.toph.simplycompat.registry.ConfigRegistry;
|
import cc.toph.simplycompat.registry.ConfigRegistry;
|
||||||
import cc.toph.simplycompat.registry.ItemsRegistry;
|
import cc.toph.simplycompat.registry.ItemsRegistry;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
@ -8,25 +7,25 @@ import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public final class SimplyCompat {
|
public final class SimplyCompat {
|
||||||
|
|
||||||
public static final String MOD_ID = "simplycompat";
|
public static final String MOD_ID = "simplycompat";
|
||||||
|
|
||||||
// Unused TAB, for now added so SS's Tab registry by SSSwordItem class
|
// Unused TAB, for now added so SS's Tab registry by SSSwordItem class
|
||||||
// public static final DeferredRegister<CreativeModeTab> TABS = DeferredRegister.create(
|
// public static final DeferredRegister<CreativeModeTab> TABS = DeferredRegister.create(
|
||||||
// MOD_ID,
|
// MOD_ID,
|
||||||
// Registries.CREATIVE_MODE_TAB
|
// Registries.CREATIVE_MODE_TAB
|
||||||
// );
|
// );
|
||||||
// public static final RegistrySupplier<CreativeModeTab> SIMPLYCOMPAT = TABS.register(MOD_ID, () ->
|
// public static final RegistrySupplier<CreativeModeTab> SIMPLYCOMPAT = TABS.register(MOD_ID, () ->
|
||||||
// CreativeTabRegistry.create(
|
// CreativeTabRegistry.create(
|
||||||
// Component.translatable("creativeTab.simplycompat.simplycompat"),
|
// Component.translatable("creativeTab.simplycompat.simplycompat"),
|
||||||
// () -> new ItemStack(Items.AMETHYST_SHARD)
|
// () -> new ItemStack(Items.AMETHYST_SHARD)
|
||||||
// )
|
// )
|
||||||
// );
|
// );
|
||||||
|
|
||||||
public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
|
public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
// TABS.register();
|
// TABS.register();
|
||||||
ConfigRegistry.registerConfigs();
|
ConfigRegistry.registerConfigs();
|
||||||
ItemsRegistry.registerAllSwords();
|
ItemsRegistry.registerSwords();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
28
common/src/main/java/cc/toph/simplycompat/compat/TFMG.java
Normal file
28
common/src/main/java/cc/toph/simplycompat/compat/TFMG.java
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,119 @@
|
||||||
|
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.world.item.crafting.Ingredient;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public enum TFMGToolMaterials implements ToolMaterials, Tier {
|
||||||
|
ALUMINUM(
|
||||||
|
TFMGTiers.ALUMINUM.getLevel(),
|
||||||
|
TFMGTiers.ALUMINUM.getUses(),
|
||||||
|
TFMGTiers.ALUMINUM.getSpeed(),
|
||||||
|
TFMGTiers.ALUMINUM.getAttackDamageBonus(),
|
||||||
|
ConfigRegistry.WEAPON_ATTRIBUTES.STEEL,
|
||||||
|
TFMGTiers.ALUMINUM.getEnchantmentValue(),
|
||||||
|
ConfigRegistry.WEAPON_ATTRIBUTES.STEEL_ENABLED,
|
||||||
|
Ingredient.of(AllTags.AllItemTags.CREATE_INGOTS.tag)
|
||||||
|
),
|
||||||
|
LEAD(
|
||||||
|
TFMGTiers.LEAD.getLevel(),
|
||||||
|
TFMGTiers.LEAD.getUses(),
|
||||||
|
TFMGTiers.LEAD.getSpeed(),
|
||||||
|
TFMGTiers.LEAD.getAttackDamageBonus(),
|
||||||
|
ConfigRegistry.WEAPON_ATTRIBUTES.STEEL,
|
||||||
|
TFMGTiers.LEAD.getEnchantmentValue(),
|
||||||
|
ConfigRegistry.WEAPON_ATTRIBUTES.STEEL_ENABLED,
|
||||||
|
Ingredient.of(AllTags.AllItemTags.CREATE_INGOTS.tag)
|
||||||
|
),
|
||||||
|
STEEL(
|
||||||
|
TFMGTiers.STEEL.getLevel(),
|
||||||
|
TFMGTiers.STEEL.getUses(),
|
||||||
|
TFMGTiers.STEEL.getSpeed(),
|
||||||
|
TFMGTiers.STEEL.getAttackDamageBonus(),
|
||||||
|
ConfigRegistry.WEAPON_ATTRIBUTES.STEEL,
|
||||||
|
TFMGTiers.STEEL.getEnchantmentValue(),
|
||||||
|
ConfigRegistry.WEAPON_ATTRIBUTES.STEEL_ENABLED,
|
||||||
|
Ingredient.of(AllTags.AllItemTags.CREATE_INGOTS.tag)
|
||||||
|
);
|
||||||
|
|
||||||
|
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 Ingredient repairIngredient;
|
||||||
|
|
||||||
|
TFMGToolMaterials(
|
||||||
|
int level,
|
||||||
|
int uses,
|
||||||
|
float speed,
|
||||||
|
float attackDamageBonus,
|
||||||
|
float damageModifier,
|
||||||
|
int enchantmentValue,
|
||||||
|
boolean enabled,
|
||||||
|
Ingredient repairIngredient
|
||||||
|
) {
|
||||||
|
this.level = level;
|
||||||
|
this.uses = uses;
|
||||||
|
this.speed = speed;
|
||||||
|
this.attackDamageBonus = attackDamageBonus;
|
||||||
|
this.enchantmentValue = enchantmentValue;
|
||||||
|
this.damageModifier = damageModifier;
|
||||||
|
this.enabled = enabled;
|
||||||
|
this.repairIngredient = 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,105 +1,97 @@
|
||||||
package cc.toph.simplycompat.item;
|
package cc.toph.simplycompat.item;
|
||||||
|
|
||||||
import cc.toph.simplycompat.registry.ConfigRegistry.WEAPON_ATTRIBUTES;
|
import cc.toph.simplycompat.registry.ConfigRegistry.WEAPON_ATTRIBUTES;
|
||||||
import com.google.common.base.Suppliers;
|
import cc.toph.simplycompat.util.ToolMaterials;
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.tags.ItemTags;
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.Items;
|
|
||||||
import net.minecraft.world.item.Tier;
|
import net.minecraft.world.item.Tier;
|
||||||
import net.minecraft.world.item.crafting.Ingredient;
|
import net.minecraft.world.item.crafting.Ingredient;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
public enum SimplyCompatToolMaterials implements ToolMaterials, Tier {
|
||||||
|
COPPER(
|
||||||
|
1,
|
||||||
|
125,
|
||||||
|
4.5F,
|
||||||
|
1.0F,
|
||||||
|
WEAPON_ATTRIBUTES.COPPER,
|
||||||
|
8,
|
||||||
|
WEAPON_ATTRIBUTES.COPPER_ENABLED,
|
||||||
|
Ingredient.of(ItemTags.COPPER_ORES)
|
||||||
|
);
|
||||||
|
|
||||||
|
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 Ingredient repairIngredient;
|
||||||
|
|
||||||
public enum SimplyCompatToolMaterials implements Tier {
|
SimplyCompatToolMaterials(
|
||||||
COPPER(1, 125, 4.5F, 1.0F, WEAPON_ATTRIBUTES.COPPER, 8, Items.COPPER_INGOT),
|
int level,
|
||||||
STEEL(2, 600, 6.5F, 2.5F, WEAPON_ATTRIBUTES.STEEL, 12, Items.DIAMOND);
|
int uses,
|
||||||
|
float speed,
|
||||||
private final int level;
|
float attackDamageBonus,
|
||||||
private final int uses;
|
float damageModifier,
|
||||||
private final float speed;
|
int enchantmentValue,
|
||||||
private final float attackDamageBonus;
|
boolean enabled,
|
||||||
private final float damageModifier;
|
Ingredient repairIngredient
|
||||||
private final int enchantmentValue;
|
) {
|
||||||
private final Supplier<Ingredient> repairIngredient;
|
this.level = level;
|
||||||
|
this.uses = uses;
|
||||||
SimplyCompatToolMaterials(
|
this.speed = speed;
|
||||||
int level,
|
this.attackDamageBonus = attackDamageBonus;
|
||||||
int uses,
|
this.enchantmentValue = enchantmentValue;
|
||||||
float speed,
|
this.damageModifier = damageModifier;
|
||||||
float attackDamageBonus,
|
this.enabled = enabled;
|
||||||
float damageModifier,
|
this.repairIngredient = repairIngredient;
|
||||||
int enchantmentValue,
|
}
|
||||||
Item... repairIngredient
|
|
||||||
) {
|
|
||||||
this.level = level;
|
|
||||||
this.uses = uses;
|
|
||||||
this.speed = speed;
|
|
||||||
this.attackDamageBonus = attackDamageBonus;
|
|
||||||
this.enchantmentValue = enchantmentValue;
|
|
||||||
this.repairIngredient = Suppliers.memoize(() -> Ingredient.of(repairIngredient));
|
|
||||||
this.damageModifier = damageModifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Returns the name of the enum constant in lowercase.
|
public String getName() {
|
||||||
*
|
return this.name().toLowerCase();
|
||||||
* @return the name of the enum constant as a lowercase string
|
}
|
||||||
*/
|
|
||||||
public String getName() {
|
|
||||||
return this.name().toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Returns RepairIngredient ResourceLocation as a string
|
public int getUses() {
|
||||||
*
|
return uses;
|
||||||
* @return String ResourceLocation Path (mod:item)
|
}
|
||||||
*/
|
|
||||||
public String getIdentifier() {
|
|
||||||
return BuiltInRegistries.ITEM.getKey(
|
|
||||||
this.repairIngredient.get().getItems()[0].getItem()
|
|
||||||
).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getUses() {
|
public float getSpeed() {
|
||||||
return uses;
|
return speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getSpeed() {
|
public float getAttackDamageBonus() {
|
||||||
return speed;
|
return attackDamageBonus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getAttackDamageBonus() {
|
public float getDamageModifier() {
|
||||||
return attackDamageBonus;
|
return damageModifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Retrieves the base damage modifier associated with the tool material.
|
public int getLevel() {
|
||||||
* <p>
|
return level;
|
||||||
* Simply Swords specific value, not related to {@link Tier#getAttackDamageBonus()}
|
}
|
||||||
*
|
|
||||||
* @return the base damage modifier as a float value
|
|
||||||
*/
|
|
||||||
public float getDamageModifier() {
|
|
||||||
return damageModifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLevel() {
|
public int getEnchantmentValue() {
|
||||||
return level;
|
return enchantmentValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnchantmentValue() {
|
public boolean isEnabled() {
|
||||||
return enchantmentValue;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Ingredient getRepairIngredient() {
|
||||||
|
return this.repairIngredient;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull Ingredient getRepairIngredient() {
|
|
||||||
return this.repairIngredient.get();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,37 +1,81 @@
|
||||||
package cc.toph.simplycompat.registry;
|
package cc.toph.simplycompat.registry;
|
||||||
|
|
||||||
import cc.toph.simplycompat.SimplyCompat;
|
import cc.toph.simplycompat.compat.TFMG;
|
||||||
import cc.toph.simplycompat.config.Config;
|
import cc.toph.simplycompat.config.Config;
|
||||||
import cc.toph.simplycompat.config.ConfigProvider;
|
import cc.toph.simplycompat.config.ConfigProvider;
|
||||||
|
|
||||||
public class ConfigRegistry {
|
public class ConfigRegistry {
|
||||||
public static final class WEAPON_ATTRIBUTES {
|
public static final class WEAPON_ATTRIBUTES {
|
||||||
|
|
||||||
public static float COPPER;
|
public static float COPPER;
|
||||||
public static float STEEL;
|
public static boolean COPPER_ENABLED;
|
||||||
|
public static float ALUMINUM;
|
||||||
|
public static boolean ALUMINUM_ENABLED;
|
||||||
|
public static float LEAD;
|
||||||
|
public static boolean LEAD_ENABLED;
|
||||||
|
public static float STEEL;
|
||||||
|
public static boolean STEEL_ENABLED;
|
||||||
|
|
||||||
public static final ConfigProvider PROVIDER = new ConfigProvider("weapon_attributes");
|
public static final ConfigProvider PROVIDER = new ConfigProvider("weapon_attributes");
|
||||||
|
|
||||||
public static void register() {
|
public static void register() {
|
||||||
Config common = new Config(PROVIDER);
|
Config common = new Config(PROVIDER);
|
||||||
|
|
||||||
COPPER = common.registerProp(
|
COPPER = common.registerProp(
|
||||||
"copper_damageModifier",
|
"copper_damageModifier",
|
||||||
3.0f,
|
3.0f,
|
||||||
"Copper Damage Modifier"
|
"Copper Damage Modifier"
|
||||||
);
|
);
|
||||||
|
|
||||||
STEEL = common.registerProp(
|
COPPER_ENABLED = common.registerProp(
|
||||||
"steel_damageModifier",
|
"copper_enabled",
|
||||||
5.0f,
|
true,
|
||||||
"Steel Damage Modifier"
|
"Enable Copper Swords"
|
||||||
);
|
);
|
||||||
|
|
||||||
common.register();
|
if (TFMG.passCheck()) {
|
||||||
|
ALUMINUM = common.registerProp(
|
||||||
|
"aluminum_damageModifier",
|
||||||
|
3.0f,
|
||||||
|
"Aluminum Damage Modifier"
|
||||||
|
);
|
||||||
|
|
||||||
|
ALUMINUM_ENABLED = common.registerProp(
|
||||||
|
"aluminum_enabled",
|
||||||
|
true,
|
||||||
|
"Enable Aluminum Swords"
|
||||||
|
);
|
||||||
|
|
||||||
|
LEAD = common.registerProp(
|
||||||
|
"lead_damageModifier",
|
||||||
|
2.0f,
|
||||||
|
"Lead Damage Modifier"
|
||||||
|
);
|
||||||
|
|
||||||
|
LEAD_ENABLED = common.registerProp(
|
||||||
|
"lead_enabled",
|
||||||
|
true,
|
||||||
|
"Enable Lead Swords"
|
||||||
|
);
|
||||||
|
STEEL = common.registerProp(
|
||||||
|
"steel_damageModifier",
|
||||||
|
5.0f,
|
||||||
|
"Steel Damage Modifier"
|
||||||
|
);
|
||||||
|
|
||||||
|
STEEL_ENABLED = common.registerProp(
|
||||||
|
"steel_enabled",
|
||||||
|
true,
|
||||||
|
"Enable Steel Swords"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
common.register();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static void registerConfigs() {
|
public static void registerConfigs() {
|
||||||
WEAPON_ATTRIBUTES.register();
|
WEAPON_ATTRIBUTES.register();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package cc.toph.simplycompat.registry;
|
package cc.toph.simplycompat.registry;
|
||||||
|
|
||||||
import cc.toph.simplycompat.SimplyCompat;
|
import cc.toph.simplycompat.SimplyCompat;
|
||||||
|
import cc.toph.simplycompat.compat.TFMG;
|
||||||
import cc.toph.simplycompat.item.SimplyCompatToolMaterials;
|
import cc.toph.simplycompat.item.SimplyCompatToolMaterials;
|
||||||
|
import cc.toph.simplycompat.util.ToolMaterials;
|
||||||
import cc.toph.simplycompat.util.WeaponType;
|
import cc.toph.simplycompat.util.WeaponType;
|
||||||
import dev.architectury.registry.registries.DeferredRegister;
|
import dev.architectury.registry.registries.DeferredRegister;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
|
@ -9,42 +11,41 @@ import net.minecraft.world.item.Item;
|
||||||
import net.sweenus.simplyswords.item.SimplySwordsSwordItem;
|
import net.sweenus.simplyswords.item.SimplySwordsSwordItem;
|
||||||
|
|
||||||
public class ItemsRegistry {
|
public class ItemsRegistry {
|
||||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(
|
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(
|
||||||
SimplyCompat.MOD_ID,
|
SimplyCompat.MOD_ID,
|
||||||
Registries.ITEM
|
Registries.ITEM
|
||||||
);
|
|
||||||
|
|
||||||
private static void registerSword(
|
|
||||||
SimplyCompatToolMaterials material,
|
|
||||||
WeaponType type
|
|
||||||
) {
|
|
||||||
|
|
||||||
float finalDamage = material.getDamageModifier() + type.getPositiveModifier() - type.getNegativeModifier();
|
|
||||||
String name = material.getName() + "_" + type.getWeaponNameSuffix();
|
|
||||||
|
|
||||||
ITEMS.register(name, () ->
|
|
||||||
new SimplySwordsSwordItem(material, (int) finalDamage, type.getAttackSpeed(), material.getIdentifier())
|
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
public static void registerSword(
|
||||||
* Registers all sword items. Iterate through all available weapon types
|
ToolMaterials material,
|
||||||
* and tool materials. For each combination, the corresponding sword
|
WeaponType type
|
||||||
* is registered using the private {@code registerSword} method.
|
) {
|
||||||
* <br>
|
|
||||||
* This ensures that each defined material and weapon type combination is
|
|
||||||
* registered within the item registry for use within the mod.
|
|
||||||
*/
|
|
||||||
public static void registerAllSwords() {
|
|
||||||
// TODO: Register Compat Swords
|
|
||||||
|
|
||||||
// Register "Vanilla" swords
|
float finalDamage = material.getDamageModifier() + type.getPositiveModifier() - type.getNegativeModifier();
|
||||||
for (WeaponType type : WeaponType.values()) {
|
String name = material.getName() + "_" + type.getWeaponNameSuffix();
|
||||||
for (SimplyCompatToolMaterials material : SimplyCompatToolMaterials.values()) {
|
|
||||||
registerSword(material, type);
|
ITEMS.register(name, () ->
|
||||||
}
|
new SimplySwordsSwordItem(material, (int) finalDamage, type.getAttackSpeed(), material.getIdentifier())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ITEMS.register();
|
/**
|
||||||
}
|
* Registers all sword items. Iterate through all available weapon types
|
||||||
|
* and tool materials. For each combination, the corresponding sword
|
||||||
|
* is registered using the private {@code registerSword} method.
|
||||||
|
* <br>
|
||||||
|
* This ensures that each defined material and weapon type combination is
|
||||||
|
* 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()) {
|
||||||
|
if (material.isEnabled()) registerSword(material, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TFMG.register();
|
||||||
|
ITEMS.register();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
package cc.toph.simplycompat.util;
|
||||||
|
|
||||||
|
import cc.toph.simplycompat.SimplyCompat;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import net.minecraft.world.item.Tier;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ToolMaterials interface outlines the properties and behaviors required
|
||||||
|
* for defining custom tool materials. It provides methods for retrieving
|
||||||
|
* information about the tool material, such as its name, repair ingredient,
|
||||||
|
* base damage modifier, and enabled status.
|
||||||
|
* <p>
|
||||||
|
* Suggested implementation with Enums
|
||||||
|
*/
|
||||||
|
public interface ToolMaterials extends Tier {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the enum constant in lowercase.
|
||||||
|
*
|
||||||
|
* @return the name of the enum constant as a lowercase string
|
||||||
|
*/
|
||||||
|
String getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns RepairIngredient ResourceLocation as a string
|
||||||
|
*
|
||||||
|
* @return String ResourceLocation Path (mod:item)
|
||||||
|
*/
|
||||||
|
default String getIdentifier() {
|
||||||
|
|
||||||
|
JsonElement json = this.getRepairIngredient().toJson();
|
||||||
|
if (json.isJsonObject()) {
|
||||||
|
if (json.getAsJsonObject().has("item")) {
|
||||||
|
return json.getAsJsonObject().get("item").getAsString();
|
||||||
|
}
|
||||||
|
if (json.getAsJsonObject().has("tag")) {
|
||||||
|
return json.getAsJsonObject().get("tag").getAsString();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SimplyCompat.LOGGER.error("Invalid Ingredient: could not parse from json.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return "minecraft:air";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the base damage modifier associated with the tool material.
|
||||||
|
* <p>
|
||||||
|
* Simply Swords specific value, not related to {@link Tier#getAttackDamageBonus()}
|
||||||
|
*
|
||||||
|
* @return the base damage modifier as a float value
|
||||||
|
*/
|
||||||
|
float getDamageModifier();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if Material has been enabled
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
boolean isEnabled();
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue