Compare commits

..

No commits in common. "0d8a4e4196507bf3e148ae6976d40a60edb549ec" and "9136660de7b4502ecd951914e4c70286d2283d47" have entirely different histories.

14 changed files with 236 additions and 716 deletions

View file

@ -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 {

View file

@ -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;
@ -26,6 +27,6 @@ public final class SimplyCompat {
public static void init() {
// TABS.register();
ConfigRegistry.registerConfigs();
ItemsRegistry.registerSwords();
ItemsRegistry.registerAllSwords();
}
}

View file

@ -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);
}
}
}
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -1,7 +1,9 @@
package cc.toph.simplycompat.config;
import cc.toph.simplycompat.SimplyCompat;
public class Config {
private final SimpleConfig config;
private SimpleConfig config;
private final ConfigProvider provider;
public Config(ConfigProvider provider) {

View file

@ -1,26 +1,19 @@
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;
@ -28,8 +21,7 @@ public enum SimplyCompatToolMaterials implements ToolMaterials<SimplyCompatToolM
private final float attackDamageBonus;
private final float damageModifier;
private final int enchantmentValue;
private final boolean enabled;
private final LazyLoadedValue<Ingredient> repairIngredient;
private final Supplier<Ingredient> repairIngredient;
SimplyCompatToolMaterials(
int level,
@ -38,25 +30,38 @@ public enum SimplyCompatToolMaterials implements ToolMaterials<SimplyCompatToolM
float attackDamageBonus,
float damageModifier,
int enchantmentValue,
boolean enabled,
Supplier<Ingredient> repairIngredient
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;
this.enabled = enabled;
this.repairIngredient = new LazyLoadedValue(repairIngredient);
}
@Override
/**
* 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();
}
/**
* 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 int getUses() {
return uses;
@ -72,7 +77,13 @@ public enum SimplyCompatToolMaterials implements ToolMaterials<SimplyCompatToolM
return attackDamageBonus;
}
@Override
/**
* 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;
}
@ -87,19 +98,8 @@ public enum SimplyCompatToolMaterials implements ToolMaterials<SimplyCompatToolM
return enchantmentValue;
}
@Override
public boolean isEnabled() {
return enabled;
}
@Override
public @NotNull Ingredient getRepairIngredient() {
return this.repairIngredient.get();
}
@Override
public SimplyCompatToolMaterials[] getValues() {
return values();
}
}

View file

@ -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();
}
}

View file

@ -1,21 +1,14 @@
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 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 final ConfigProvider PROVIDER = new ConfigProvider("weapon_attributes");
@ -28,64 +21,12 @@ public final class ConfigRegistry {
"Copper Damage Modifier"
);
COPPER_ENABLED = common.registerProp(
"copper_enabled",
true,
"Enable Copper Swords"
);
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();
}
}

View file

@ -2,21 +2,20 @@ 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 class ItemsRegistry {
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(
SimplyCompat.MOD_ID,
Registries.ITEM
);
public static <E extends Enum<E> & ToolMaterials<E>> void registerSword(
ToolMaterials<E> material,
private static void registerSword(
SimplyCompatToolMaterials material,
WeaponType type
) {
@ -36,16 +35,16 @@ public final class ItemsRegistry {
* 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() {
public static void registerAllSwords() {
// TODO: Register Compat Swords
// Register "Vanilla" swords
for (WeaponType type : WeaponType.values()) {
for (SimplyCompatToolMaterials material : SimplyCompatToolMaterials.values()) {
if (material.isEnabled()) registerSword(material, type);
registerSword(material, type);
}
}
CompatRegistry.registerAll();
ITEMS.register();
}
}

View file

@ -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();
}

View file

@ -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')

View file

@ -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