Compare commits
No commits in common. "0d8a4e4196507bf3e148ae6976d40a60edb549ec" and "9136660de7b4502ecd951914e4c70286d2283d47" have entirely different histories.
0d8a4e4196
...
9136660de7
14 changed files with 236 additions and 716 deletions
|
@ -8,11 +8,10 @@ repositories {
|
|||
includeGroup "curse.maven"
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name = 'tterrag maven'
|
||||
url = 'https://maven.tterrag.com/'
|
||||
}
|
||||
|
||||
// maven {
|
||||
// name = "Team Resourceful Maven"
|
||||
// url = "https://maven.teamresourceful.com/repository/maven-public/"
|
||||
// }
|
||||
maven { url "https://maven.shedaniel.me/" }
|
||||
}
|
||||
|
||||
|
@ -22,18 +21,15 @@ dependencies {
|
|||
// Do NOT use other classes from Fabric Loader.
|
||||
modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version"
|
||||
|
||||
// modImplementation "com.teamresourceful.resourcefulconfig:resourcefulconfig-common-$minecraft_version:$rconfig_version"
|
||||
modImplementation "curse.maven:simplyswords-659887:5639538"
|
||||
modImplementation "dev.architectury:architectury:$rootProject.architectury_api_version"
|
||||
|
||||
modCompileOnly("com.simibubi.create:create-$rootProject.minecraft_version:$rootProject.create_version:slim") { transitive = false }
|
||||
modCompileOnly "com.jozufozu.flywheel:flywheel-forge-$rootProject.minecraft_version:$rootProject.flywheel_version"
|
||||
modCompileOnly "com.tterrag.registrate:Registrate:$rootProject.registrate_version"
|
||||
modCompileOnly "curse.maven:create-industry-693815:5811638"
|
||||
|
||||
// runtimeOnly "curse.maven:better-combat-by-daedelus-639842:5625757"
|
||||
// runtimeOnly "curse.maven:playeranimator-658587:4587214"
|
||||
// implementation "curse.maven:additional-additions-forge-582387:5155724"
|
||||
// implementation "curse.maven:create-328085:5838779"
|
||||
// implementation "curse.maven:create-industry-693815:5811638"
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cc.toph.simplycompat;
|
||||
|
||||
import cc.toph.simplycompat.config.Config;
|
||||
import cc.toph.simplycompat.registry.ConfigRegistry;
|
||||
import cc.toph.simplycompat.registry.ItemsRegistry;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
@ -7,25 +8,25 @@ import org.apache.logging.log4j.Logger;
|
|||
|
||||
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
|
||||
// public static final DeferredRegister<CreativeModeTab> TABS = DeferredRegister.create(
|
||||
// MOD_ID,
|
||||
// Registries.CREATIVE_MODE_TAB
|
||||
// );
|
||||
// public static final RegistrySupplier<CreativeModeTab> SIMPLYCOMPAT = TABS.register(MOD_ID, () ->
|
||||
// CreativeTabRegistry.create(
|
||||
// Component.translatable("creativeTab.simplycompat.simplycompat"),
|
||||
// () -> new ItemStack(Items.AMETHYST_SHARD)
|
||||
// )
|
||||
// );
|
||||
// Unused TAB, for now added so SS's Tab registry by SSSwordItem class
|
||||
// public static final DeferredRegister<CreativeModeTab> TABS = DeferredRegister.create(
|
||||
// MOD_ID,
|
||||
// Registries.CREATIVE_MODE_TAB
|
||||
// );
|
||||
// public static final RegistrySupplier<CreativeModeTab> SIMPLYCOMPAT = TABS.register(MOD_ID, () ->
|
||||
// CreativeTabRegistry.create(
|
||||
// Component.translatable("creativeTab.simplycompat.simplycompat"),
|
||||
// () -> 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() {
|
||||
// TABS.register();
|
||||
ConfigRegistry.registerConfigs();
|
||||
ItemsRegistry.registerSwords();
|
||||
}
|
||||
public static void init() {
|
||||
// TABS.register();
|
||||
ConfigRegistry.registerConfigs();
|
||||
ItemsRegistry.registerAllSwords();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
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 <E> 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<E extends Enum<E> & ToolMaterials<E>>(
|
||||
String modId,
|
||||
String requiredVersion,
|
||||
Class<E> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
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<CreateToolMaterials> {
|
||||
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<Ingredient> repairIngredient;
|
||||
|
||||
CreateToolMaterials(
|
||||
int level,
|
||||
int uses,
|
||||
float speed,
|
||||
float attackDamageBonus,
|
||||
float damageModifier,
|
||||
int enchantmentValue,
|
||||
boolean enabled,
|
||||
Supplier<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 = 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();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,131 +0,0 @@
|
|||
package cc.toph.simplycompat.compat;
|
||||
|
||||
import cc.toph.simplycompat.registry.ConfigRegistry;
|
||||
import cc.toph.simplycompat.util.ToolMaterials;
|
||||
import com.drmangotea.tfmg.registry.TFMGTiers;
|
||||
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 TFMGToolMaterials implements ToolMaterials<TFMGToolMaterials> {
|
||||
ALUMINUM(
|
||||
TFMGTiers.ALUMINUM.getLevel(),
|
||||
TFMGTiers.ALUMINUM.getUses(),
|
||||
TFMGTiers.ALUMINUM.getSpeed(),
|
||||
TFMGTiers.ALUMINUM.getAttackDamageBonus(),
|
||||
ConfigRegistry.WEAPON_ATTRIBUTES.ALUMINUM,
|
||||
TFMGTiers.ALUMINUM.getEnchantmentValue(),
|
||||
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.LEAD,
|
||||
TFMGTiers.LEAD.getEnchantmentValue(),
|
||||
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(),
|
||||
TFMGTiers.STEEL.getUses(),
|
||||
TFMGTiers.STEEL.getSpeed(),
|
||||
TFMGTiers.STEEL.getAttackDamageBonus(),
|
||||
ConfigRegistry.WEAPON_ATTRIBUTES.STEEL,
|
||||
TFMGTiers.STEEL.getEnchantmentValue(),
|
||||
ConfigRegistry.WEAPON_ATTRIBUTES.STEEL_ENABLED,
|
||||
// () -> Ingredient.of(new ItemLike[]{(ItemLike) TFMGItems.STEEL_INGOT.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<Ingredient> repairIngredient;
|
||||
|
||||
TFMGToolMaterials(
|
||||
int level,
|
||||
int uses,
|
||||
float speed,
|
||||
float attackDamageBonus,
|
||||
float damageModifier,
|
||||
int enchantmentValue,
|
||||
boolean enabled,
|
||||
Supplier<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 = 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 TFMGToolMaterials[] getValues() {
|
||||
return values();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,46 +1,48 @@
|
|||
package cc.toph.simplycompat.config;
|
||||
|
||||
import cc.toph.simplycompat.SimplyCompat;
|
||||
|
||||
public class Config {
|
||||
private final SimpleConfig config;
|
||||
private final ConfigProvider provider;
|
||||
private 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);
|
||||
}
|
||||
}
|
|
@ -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<String, String> configMap = new HashMap<>();
|
||||
private String contents = String.format("""
|
||||
## Simply Compat Config
|
||||
## Version: %s
|
||||
|
||||
""", SimplyCompatExpectPlatform.getVersion());
|
||||
private final String namespace;
|
||||
private final HashMap<String, String> 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<String, String> getMap() {
|
||||
return configMap;
|
||||
}
|
||||
@Override
|
||||
public HashMap<String, String> getMap() {
|
||||
return configMap;
|
||||
}
|
||||
|
||||
public String getNamespace() {
|
||||
return namespace;
|
||||
}
|
||||
public String getNamespace() {
|
||||
return namespace;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,105 +1,105 @@
|
|||
package cc.toph.simplycompat.item;
|
||||
|
||||
import cc.toph.simplycompat.registry.ConfigRegistry.WEAPON_ATTRIBUTES;
|
||||
import cc.toph.simplycompat.util.ToolMaterials;
|
||||
import net.minecraft.util.LazyLoadedValue;
|
||||
import com.google.common.base.Suppliers;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.Tier;
|
||||
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 SimplyCompatToolMaterials implements ToolMaterials<SimplyCompatToolMaterials> {
|
||||
COPPER(
|
||||
1,
|
||||
125,
|
||||
4.5F,
|
||||
1.0F,
|
||||
WEAPON_ATTRIBUTES.COPPER,
|
||||
8,
|
||||
WEAPON_ATTRIBUTES.COPPER_ENABLED,
|
||||
() -> Ingredient.of(new ItemLike[]{(ItemLike) Items.COPPER_INGOT})
|
||||
);
|
||||
public enum SimplyCompatToolMaterials implements Tier {
|
||||
COPPER(1, 125, 4.5F, 1.0F, WEAPON_ATTRIBUTES.COPPER, 8, Items.COPPER_INGOT),
|
||||
STEEL(2, 600, 6.5F, 2.5F, WEAPON_ATTRIBUTES.STEEL, 12, Items.DIAMOND);
|
||||
|
||||
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<Ingredient> repairIngredient;
|
||||
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 Supplier<Ingredient> repairIngredient;
|
||||
|
||||
SimplyCompatToolMaterials(
|
||||
int level,
|
||||
int uses,
|
||||
float speed,
|
||||
float attackDamageBonus,
|
||||
float damageModifier,
|
||||
int enchantmentValue,
|
||||
boolean enabled,
|
||||
Supplier<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 = new LazyLoadedValue(repairIngredient);
|
||||
}
|
||||
SimplyCompatToolMaterials(
|
||||
int level,
|
||||
int uses,
|
||||
float speed,
|
||||
float attackDamageBonus,
|
||||
float damageModifier,
|
||||
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
|
||||
public String getName() {
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
/**
|
||||
* Returns the name of the enum constant in lowercase.
|
||||
*
|
||||
* @return the name of the enum constant as a lowercase string
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUses() {
|
||||
return uses;
|
||||
}
|
||||
/**
|
||||
* Returns RepairIngredient ResourceLocation as a string
|
||||
*
|
||||
* @return String ResourceLocation Path (mod:item)
|
||||
*/
|
||||
public String getIdentifier() {
|
||||
return BuiltInRegistries.ITEM.getKey(
|
||||
this.repairIngredient.get().getItems()[0].getItem()
|
||||
).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
@Override
|
||||
public int getUses() {
|
||||
return uses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAttackDamageBonus() {
|
||||
return attackDamageBonus;
|
||||
}
|
||||
@Override
|
||||
public float getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDamageModifier() {
|
||||
return damageModifier;
|
||||
}
|
||||
@Override
|
||||
public float getAttackDamageBonus() {
|
||||
return attackDamageBonus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public float getDamageModifier() {
|
||||
return damageModifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnchantmentValue() {
|
||||
return enchantmentValue;
|
||||
}
|
||||
@Override
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Ingredient getRepairIngredient() {
|
||||
return this.repairIngredient.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimplyCompatToolMaterials[] getValues() {
|
||||
return values();
|
||||
}
|
||||
@Override
|
||||
public int getEnchantmentValue() {
|
||||
return enchantmentValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Ingredient getRepairIngredient() {
|
||||
return this.repairIngredient.get();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
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.
|
||||
*
|
||||
* <p>Use {@link #registerAll()} to initialize all integrations.</p>
|
||||
*/
|
||||
|
||||
public final class CompatRegistry {
|
||||
|
||||
/**
|
||||
* Compatibility setup for the Create mod.
|
||||
*/
|
||||
public static final CompatRecord<CreateToolMaterials> CREATE = new CompatRecord<>(
|
||||
Create.ID,
|
||||
"0.5.1.j-55",
|
||||
CreateToolMaterials.class
|
||||
);
|
||||
|
||||
/**
|
||||
* Compatibility setup for the TFMG mod.
|
||||
*/
|
||||
public static final CompatRecord<TFMGToolMaterials> 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();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,96 +1,37 @@
|
|||
package cc.toph.simplycompat.registry;
|
||||
|
||||
import cc.toph.simplycompat.SimplyCompat;
|
||||
import cc.toph.simplycompat.config.Config;
|
||||
import cc.toph.simplycompat.config.ConfigProvider;
|
||||
|
||||
public final class ConfigRegistry {
|
||||
public static final class WEAPON_ATTRIBUTES {
|
||||
public class ConfigRegistry {
|
||||
public static final class WEAPON_ATTRIBUTES {
|
||||
|
||||
public static float COPPER;
|
||||
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 float STURDY;
|
||||
public static boolean STURDY_ENABLED;
|
||||
public static float COPPER;
|
||||
public static float STEEL;
|
||||
|
||||
public static final ConfigProvider PROVIDER = new ConfigProvider("weapon_attributes");
|
||||
public static final ConfigProvider PROVIDER = new ConfigProvider("weapon_attributes");
|
||||
|
||||
public static void register() {
|
||||
Config common = new Config(PROVIDER);
|
||||
public static void register() {
|
||||
Config common = new Config(PROVIDER);
|
||||
|
||||
COPPER = common.registerProp(
|
||||
"copper_damageModifier",
|
||||
3.0f,
|
||||
"Copper Damage Modifier"
|
||||
);
|
||||
COPPER = common.registerProp(
|
||||
"copper_damageModifier",
|
||||
3.0f,
|
||||
"Copper Damage Modifier"
|
||||
);
|
||||
|
||||
COPPER_ENABLED = common.registerProp(
|
||||
"copper_enabled",
|
||||
true,
|
||||
"Enable Copper Swords"
|
||||
);
|
||||
STEEL = common.registerProp(
|
||||
"steel_damageModifier",
|
||||
5.0f,
|
||||
"Steel Damage Modifier"
|
||||
);
|
||||
|
||||
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,
|
||||
"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();
|
||||
}
|
||||
common.register();
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerConfigs() {
|
||||
WEAPON_ATTRIBUTES.register();
|
||||
}
|
||||
public static void registerConfigs() {
|
||||
WEAPON_ATTRIBUTES.register();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,50 +2,49 @@ package cc.toph.simplycompat.registry;
|
|||
|
||||
import cc.toph.simplycompat.SimplyCompat;
|
||||
import cc.toph.simplycompat.item.SimplyCompatToolMaterials;
|
||||
import cc.toph.simplycompat.util.ToolMaterials;
|
||||
import cc.toph.simplycompat.util.WeaponType;
|
||||
import dev.architectury.registry.registries.DeferredRegister;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.sweenus.simplyswords.item.SimplySwordsSwordItem;
|
||||
|
||||
public final class ItemsRegistry {
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(
|
||||
SimplyCompat.MOD_ID,
|
||||
Registries.ITEM
|
||||
public class ItemsRegistry {
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(
|
||||
SimplyCompat.MOD_ID,
|
||||
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 <E extends Enum<E> & ToolMaterials<E>> void registerSword(
|
||||
ToolMaterials<E> material,
|
||||
WeaponType type
|
||||
) {
|
||||
/**
|
||||
* 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 registerAllSwords() {
|
||||
// TODO: Register Compat Swords
|
||||
|
||||
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())
|
||||
);
|
||||
// Register "Vanilla" swords
|
||||
for (WeaponType type : WeaponType.values()) {
|
||||
for (SimplyCompatToolMaterials material : SimplyCompatToolMaterials.values()) {
|
||||
registerSword(material, type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
CompatRegistry.registerAll();
|
||||
ITEMS.register();
|
||||
}
|
||||
ITEMS.register();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
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<E extends Enum<E> & ToolMaterials<E>>
|
||||
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();
|
||||
|
||||
E[] getValues();
|
||||
}
|
|
@ -64,10 +64,6 @@ repositories {
|
|||
// name = "Team Resourceful Maven"
|
||||
// url = "https://maven.teamresourceful.com/repository/maven-public/"
|
||||
// }
|
||||
maven {
|
||||
name = 'tterrag maven'
|
||||
url = 'https://maven.tterrag.com/'
|
||||
}
|
||||
maven { url "https://maven.shedaniel.me/" }
|
||||
}
|
||||
|
||||
|
@ -76,24 +72,16 @@ dependencies {
|
|||
modImplementation "dev.architectury:architectury-forge:$rootProject.architectury_api_version"
|
||||
|
||||
modImplementation "curse.maven:simplyswords-659887:5639538"
|
||||
|
||||
modLocalRuntime "me.shedaniel.cloth:cloth-config-forge:$rootProject.cloth_config_version"
|
||||
modLocalRuntime("me.shedaniel.cloth:cloth-config-forge:${rootProject.cloth_config_version}")
|
||||
modLocalRuntime "curse.maven:better-combat-by-daedelus-639842:5625757"
|
||||
modLocalRuntime "curse.maven:playeranimator-658587:4587214"
|
||||
modLocalRuntime "curse.maven:create-industry-693815:5811638"
|
||||
modLocalRuntime("com.simibubi.create:create-$rootProject.minecraft_version:$rootProject.create_version:slim") { transitive = false }
|
||||
modLocalRuntime "com.jozufozu.flywheel:flywheel-forge-$rootProject.minecraft_version:$rootProject.flywheel_version"
|
||||
modLocalRuntime "com.tterrag.registrate:Registrate:$rootProject.registrate_version"
|
||||
localRuntime(include("io.github.llamalad7:mixinextras-forge:0.4.1"))
|
||||
|
||||
|
||||
// modLocalRuntime "dev.engine-room.flywheel:flywheel-forge-$rootProject.minecraft_version}:$rootProject.flywheel_version}"
|
||||
//// modLocalRuntime "com.jozufozu.flywheel:flywheel-forge-$rootProject.minecraft_version:$rootProject.flywheel_version"
|
||||
// modLocalRuntime "com.simibubi.create:create-$rootProject.minecraft_version-$rootProject.create_version:all"
|
||||
|
||||
|
||||
// modImplementation "com.teamresourceful.resourcefulconfig:resourcefulconfig-forge-$minecraft_version:$rconfig_version"
|
||||
// implementation "curse.maven:additional-additions-forge-582387:ID"
|
||||
// implementation "curse.maven:create-328085:ID"
|
||||
// implementation "curse.maven:create-industry-693815:ID"
|
||||
|
||||
common(project(path: ':common', configuration: 'namedElements')) { transitive false }
|
||||
shadowBundle project(path: ':common', configuration: 'transformProductionForge')
|
||||
|
|
|
@ -11,11 +11,7 @@ minecraft_version=1.20.1
|
|||
# Dependencies
|
||||
architectury_api_version=9.2.14
|
||||
cloth_config_version=11.1.106
|
||||
create_version=0.5.1.j-55
|
||||
fabric_api_version=0.92.3+1.20.1
|
||||
fabric_loader_version=0.16.10
|
||||
flywheel_version=0.6.11-13
|
||||
fabric_api_version=0.92.3+1.20.1
|
||||
forge_version=1.20.1-47.3.22
|
||||
parchment_version=1.20.1:2023.09.03
|
||||
registrate_version=MC1.20-1.3.3
|
||||
|
||||
parchment_version=1.20.1:2023.09.03
|
Loading…
Add table
Reference in a new issue