Compare commits

..

2 commits

11 changed files with 404 additions and 110 deletions

View file

@ -12,7 +12,17 @@ repositories {
name = 'tterrag maven'
url = 'https://maven.tterrag.com/'
}
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
filter {
includeGroup "maven.modrinth"
}
}
maven { url "https://maven.shedaniel.me/" }
}
@ -28,9 +38,10 @@ dependencies {
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:additional-additions-forge-582387:5155724"
modCompileOnly "curse.maven:create-industry-693815:5811638"
modCompileOnly "curse.maven:create-deep-dark-1020173:5868515"
modCompileOnly "curse.maven:additional-additions-forge-582387:5155724"
modCompileOnly "maven.modrinth:purecoppertools:UhYKtKPC"
}
sourceSets {

View file

@ -32,7 +32,7 @@ public enum AdditionalAdditionsToolMaterials implements ToolMaterials<Additional
4,
2031,
10.0F,
2.0F,
4.5F,
ConfigRegistry.WEAPON_ATTRIBUTES.ROSE_GOLD,
20,
ConfigRegistry.WEAPON_ATTRIBUTES.ROSE_GOLD_ENABLED,

View file

@ -15,10 +15,10 @@ public enum CreateDeepDarkToolMaterials implements ToolMaterials<CreateDeepDarkT
ECHO(
4,
2124,
9.0f,
10.0f,
6.0f,
ConfigRegistry.WEAPON_ATTRIBUTES.ECHO,
16,
18,
ConfigRegistry.WEAPON_ATTRIBUTES.ECHO_ENABLED,
new ResourceLocation(CreateDeepDarkMod.MODID, "echo_ingot")
);

View file

@ -0,0 +1,142 @@
package cc.toph.simplycompat.compat;
import cc.toph.simplycompat.registry.ConfigRegistry;
import cc.toph.simplycompat.util.ToolMaterials;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;
import net.purejosh.purecoppertools.PurecoppertoolsMod;
import org.jetbrains.annotations.NotNull;
public enum PureCopperToolMaterials implements ToolMaterials<PureCopperToolMaterials> {
COPPER(
0,
184,
3.0F,
1.5f,
ConfigRegistry.WEAPON_ATTRIBUTES.COPPER,
22,
ConfigRegistry.WEAPON_ATTRIBUTES.COPPER_ENABLED,
Items.COPPER_INGOT.arch$registryName()
),
EXPOSED_COPPER(
0,
218,
3.0f,
2.0f,
ConfigRegistry.WEAPON_ATTRIBUTES.EXPOSED_COPPER,
18,
ConfigRegistry.WEAPON_ATTRIBUTES.EXPOSED_COPPER_ENABLED,
new ResourceLocation(PurecoppertoolsMod.MODID, "exposed_copper_ingot")
),
WEATHERED_COPPER(
0,
258,
3.5f,
2.5f,
ConfigRegistry.WEAPON_ATTRIBUTES.WEATHERED_COPPER,
14,
ConfigRegistry.WEAPON_ATTRIBUTES.WEATHERED_COPPER_ENABLED,
new ResourceLocation(PurecoppertoolsMod.MODID, "weathered_copper_ingot")
),
OXIDIZED_COPPER(
0,
304,
4.0f,
3.0f,
ConfigRegistry.WEAPON_ATTRIBUTES.OXIDIZED_COPPER,
10,
ConfigRegistry.WEAPON_ATTRIBUTES.OXIDIZED_COPPER_ENABLED,
new ResourceLocation(PurecoppertoolsMod.MODID, "oxidized_copper_ingot")
);
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 ResourceLocation repairIngredient;
PureCopperToolMaterials(
int level,
int uses,
float speed,
float attackDamageBonus,
float damageModifier,
int enchantmentValue,
boolean enabled,
ResourceLocation 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 String getIdentifier() {
return repairIngredient.toString();
}
@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 Ingredient.of(BuiltInRegistries.ITEM.get(repairIngredient));
}
@Override
public PureCopperToolMaterials[] getValues() {
return values();
}
}

View file

@ -0,0 +1,38 @@
package cc.toph.simplycompat.item;
import cc.toph.simplycompat.registry.SimplyCompatRegistries;
import cc.toph.simplycompat.util.ToolMaterials;
import cc.toph.simplycompat.util.WeaponType;
import net.sweenus.simplyswords.item.SimplySwordsSwordItem;
/**
* Extended Class from Simply Swords to store sword type.
* Storing Sword type will let us avoid all the static mess in registries.
* This class stores all the data we need from the sword, so we can just
* retrieve the object from the registries thanks to {@link SimplyCompatRegistries#SWORD_ITEM} and do whatever we need.
*/
public class SimplyCompatSwordItem extends SimplySwordsSwordItem {
/**
* The type of the weapon.
*/
public final WeaponType TYPE;
/**
* Constructor for SimplyCompatSwordItem.
*
* @param toolMaterial The material of the tool, which some of its properties/stats.
* @param type The type of the weapon, which affects its modifiers.
* @param <E> The type of the enum that extends ToolMaterials.
*/
public <E extends Enum<E> & ToolMaterials<E>> SimplyCompatSwordItem(ToolMaterials<E> toolMaterial, WeaponType type) {
super(
toolMaterial,
(int) (toolMaterial.getDamageModifier() + type.getPositiveModifier() - type.getNegativeModifier()),
type.getAttackSpeed(),
toolMaterial.getRepairIngredient().toString()
);
this.TYPE = type;
}
}

View file

@ -1,14 +1,12 @@
package cc.toph.simplycompat.registry;
import cc.toph.simplycompat.compat.AdditionalAdditionsToolMaterials;
import cc.toph.simplycompat.compat.CreateDeepDarkToolMaterials;
import cc.toph.simplycompat.compat.CreateToolMaterials;
import cc.toph.simplycompat.compat.TFMGToolMaterials;
import cc.toph.simplycompat.compat.*;
import cc.toph.simplycompat.util.CompatRecord;
import com.drmangotea.tfmg.CreateTFMG;
import com.simibubi.create.Create;
import create_deep_dark.CreateDeepDarkMod;
import dqu.additionaladditions.AdditionalAdditions;
import net.purejosh.purecoppertools.PurecoppertoolsMod;
/**
@ -38,15 +36,6 @@ public final class CompatRegistry {
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
);
/**
* Compatibility setup for the Create Deep Dark mod.
*/
@ -56,14 +45,33 @@ public final class CompatRegistry {
CreateDeepDarkToolMaterials.class
);
/**
* Compatibility setup for the Create Deep Dark mod.
*/
public static final CompatRecord<PureCopperToolMaterials> PURE_COPPER = new CompatRecord<>(
PurecoppertoolsMod.MODID,
"1.0.1",
PureCopperToolMaterials.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.ADDITIONAL_ADDITIONS.register();
CompatRegistry.PURE_COPPER.register();
CompatRegistry.CREATE.register();
CompatRegistry.TFMG.register();
CompatRegistry.CREATE_DEEP_DARK.register();
CompatRegistry.TFMG.register();
}
}

View file

@ -6,60 +6,64 @@ import cc.toph.simplycompat.config.ConfigProvider;
public final class ConfigRegistry {
public static final class WEAPON_ATTRIBUTES {
public static float ALUMINUM;
public static boolean ALUMINUM_ENABLED;
public static float COPPER;
public static boolean COPPER_ENABLED;
public static float ECHO;
public static boolean ECHO_ENABLED;
public static float GILDED_NETHERITE;
public static boolean GILDED_NETHERITE_ENABLED;
public static float LEAD;
public static boolean LEAD_ENABLED;
// Additional Additions //
public static float ROSE_GOLD;
public static boolean ROSE_GOLD_ENABLED;
public static float STEEL;
public static boolean STEEL_ENABLED;
public static float GILDED_NETHERITE;
public static boolean GILDED_NETHERITE_ENABLED;
// Create //
public static float STURDY;
public static boolean STURDY_ENABLED;
// Create: Deep Dark//
public static float ECHO;
public static boolean ECHO_ENABLED;
// Pure Cooper Tools //
public static float COPPER;
public static boolean COPPER_ENABLED;
public static float EXPOSED_COPPER;
public static boolean EXPOSED_COPPER_ENABLED;
public static float WEATHERED_COPPER;
public static boolean WEATHERED_COPPER_ENABLED;
public static float OXIDIZED_COPPER;
public static boolean OXIDIZED_COPPER_ENABLED;
// TFMG //
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 void register() {
Config common = new Config(PROVIDER);
COPPER = common.registerProp(
"copper_damageModifier",
3.0f,
"Copper Damage Modifier"
);
COPPER_ENABLED = common.registerProp(
"copper_enabled",
true,
"Enable Copper Swords"
);
Config config = new Config(PROVIDER);
if (CompatRegistry.ADDITIONAL_ADDITIONS.passCheck()) {
ROSE_GOLD = common.registerProp(
ROSE_GOLD = config.registerProp(
"rose_gold_damageModifier",
4.0f,
3.0f,
"Rose Gold Damage Modifier"
);
ROSE_GOLD_ENABLED = common.registerProp(
ROSE_GOLD_ENABLED = config.registerProp(
"rose_gold_enabled",
true,
"Enable Rose Gold Swords"
);
GILDED_NETHERITE = common.registerProp(
GILDED_NETHERITE = config.registerProp(
"gilded_netherite_damageModifier",
4.0f,
"Gilded Netherite Damage Modifier"
);
GILDED_NETHERITE_ENABLED = common.registerProp(
GILDED_NETHERITE_ENABLED = config.registerProp(
"gilded_netherite_enabled",
true,
"Enable Gilded Netherite Swords"
@ -67,72 +71,122 @@ public final class ConfigRegistry {
}
if (CompatRegistry.CREATE.passCheck()) {
STURDY = common.registerProp(
STURDY = config.registerProp(
"sturdy_damageModifier",
4.0f,
3.5f,
"Sturdy Damage Modifier"
);
STURDY_ENABLED = common.registerProp(
STURDY_ENABLED = config.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"
);
}
if (CompatRegistry.CREATE_DEEP_DARK.passCheck()) {
ECHO = common.registerProp(
ECHO = config.registerProp(
"echo_damageModifier",
6.0f,
5.0f,
"Steel Echo Modifier"
);
ECHO_ENABLED = common.registerProp(
ECHO_ENABLED = config.registerProp(
"echo_enabled",
true,
"Enable Echo Swords"
);
}
common.register();
COPPER = config.registerProp(
"copper_damageModifier",
3.0f,
"Copper Damage Modifier"
);
COPPER_ENABLED = config.registerProp(
"copper_enabled",
true,
"Enable Copper Swords"
);
if (CompatRegistry.PURE_COPPER.passCheck()) {
EXPOSED_COPPER = config.registerProp(
"exposed_copper_damageModifier",
3.0f,
"Copper Damage Modifier"
);
EXPOSED_COPPER_ENABLED = config.registerProp(
"exposed_copper_enabled",
true,
"Enable Exposed Copper Swords"
);
WEATHERED_COPPER = config.registerProp(
"weathered_copper_damageModifier",
3.0f,
"Copper Weathered Copper Modifier"
);
WEATHERED_COPPER_ENABLED = config.registerProp(
"exposed_copper_enabled",
true,
"Enable Exposed Copper Swords"
);
OXIDIZED_COPPER = config.registerProp(
"oxidized_copper_damageModifier",
3.5f,
"Copper Weathered Copper Modifier"
);
OXIDIZED_COPPER_ENABLED = config.registerProp(
"oxidized_copper_enabled",
true,
"Enable Oxidized Copper Swords"
);
}
if (CompatRegistry.TFMG.passCheck()) {
ALUMINUM = config.registerProp(
"aluminum_damageModifier",
2.5f,
"Aluminum Damage Modifier"
);
ALUMINUM_ENABLED = config.registerProp(
"aluminum_enabled",
true,
"Enable Aluminum Swords"
);
LEAD = config.registerProp(
"lead_damageModifier",
-0.5f,
"Lead Damage Modifier"
);
LEAD_ENABLED = config.registerProp(
"lead_enabled",
true,
"Enable Lead Swords"
);
STEEL = config.registerProp(
"steel_damageModifier",
3.5f,
"Steel Damage Modifier"
);
STEEL_ENABLED = config.registerProp(
"steel_enabled",
true,
"Enable Steel Swords"
);
}
config.register();
}
}

View file

@ -1,31 +1,36 @@
package cc.toph.simplycompat.registry;
import cc.toph.simplycompat.SimplyCompat;
import cc.toph.simplycompat.item.SimplyCompatSwordItem;
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(
/**
* Special register for swords only.
*/
public static final DeferredRegister<SimplyCompatSwordItem> SWORDS = DeferredRegister.create(
SimplyCompat.MOD_ID,
Registries.ITEM
SimplyCompatRegistries.SWORD_ITEM
);
/**
* Registers a sword item with the given material and weapon type.
*
* @param material The material of the tool, which some of its properties/stats.
* @param type The type of the weapon, which affects its modifiers.
* @param <E> The type of the enum that extends ToolMaterials.
*/
public static <E extends Enum<E> & ToolMaterials<E>> void registerSword(
ToolMaterials<E> 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())
);
SWORDS.register(name, () ->
new SimplyCompatSwordItem(material, type));
}
/**
@ -46,6 +51,6 @@ public final class ItemsRegistry {
}
CompatRegistry.registerAll();
ITEMS.register();
SWORDS.register();
}
}

View file

@ -0,0 +1,16 @@
package cc.toph.simplycompat.registry;
import cc.toph.simplycompat.SimplyCompat;
import cc.toph.simplycompat.item.SimplyCompatSwordItem;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
public class SimplyCompatRegistries extends Registries {
// Defines a Key for Sword Items, enabling the usage of Sword Specific Registries
// In essence allows the usage of the SimplyCompatSwordItem so we can access modded sword data
public static final ResourceKey<Registry<SimplyCompatSwordItem>> SWORD_ITEM = ResourceKey.createRegistryKey(new ResourceLocation(SimplyCompat.MOD_ID, "sword_item"));
}

View file

@ -68,6 +68,17 @@ repositories {
name = 'tterrag maven'
url = 'https://maven.tterrag.com/'
}
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
filter {
includeGroup "maven.modrinth"
}
}
maven { url "https://maven.shedaniel.me/" }
}
@ -84,9 +95,11 @@ dependencies {
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"
modLocalRuntime "curse.maven:additional-additions-forge-582387:5155724"
modLocalRuntime "curse.maven:create-industry-693815:5811638"
modLocalRuntime "curse.maven:create-deep-dark-1020173:5868515"
modLocalRuntime "curse.maven:additional-additions-forge-582387:5155724"
modLocalRuntime "maven.modrinth:purecoppertools:UhYKtKPC"
modLocalRuntime "curse.maven:emi-580555:6205514"

View file

@ -50,16 +50,16 @@ ordering = "AFTER"
side = "BOTH"
[[dependencies.simplycompat]]
modId = "create"
modId = "purecoppertools"
mandatory = false
versionRange = "[0.5.1.j-55,)"
versionRange = "[1.0.1,)"
ordering = "AFTER"
side = "BOTH"
[[dependencies.simplycompat]]
modId = "tfmg"
modId = "create"
mandatory = false
versionRange = "[0.9.3-1.20.1,)"
versionRange = "[0.5.1.j-55,)"
ordering = "AFTER"
side = "BOTH"
@ -69,3 +69,10 @@ mandatory = false
versionRange = "[1.7.0,)"
ordering = "AFTER"
side = "BOTH"
[[dependencies.simplycompat]]
modId = "tfmg"
mandatory = false
versionRange = "[0.9.3-1.20.1,)"
ordering = "AFTER"
side = "BOTH"