From 2f92bdb1158fc260768ba33239b6410b5f103664 Mon Sep 17 00:00:00 2001 From: lustig7 Date: Mon, 30 Dec 2024 11:08:08 +0100 Subject: [PATCH] refactor code: removed unused lines of code + refactor gradle.properties --- build.gradle | 4 +- gradle.properties | 7 ++- src/main/java/item/Capacitor.java | 6 +-- src/main/java/item/CustomCapacitor.java | 8 +--- src/main/java/item/Items.java | 48 +++---------------- .../CapacitorAdditions.java | 4 +- .../enderio/capacitoradditions/Config.java | 48 ------------------- .../models/item/unobtainium_capacitor.json | 6 +++ .../models/item/unobtanium_capacitor.json | 6 --- .../recipe/vibranium_capacitor.json | 8 ++-- .../templates/META-INF/neoforge.mods.toml | 4 +- 11 files changed, 33 insertions(+), 116 deletions(-) create mode 100644 src/main/resources/assets/capacitatoradditions/models/item/unobtainium_capacitor.json delete mode 100644 src/main/resources/assets/capacitatoradditions/models/item/unobtanium_capacitor.json diff --git a/build.gradle b/build.gradle index 8c7a7f0..323db80 100644 --- a/build.gradle +++ b/build.gradle @@ -157,7 +157,9 @@ var generateModMetadata = tasks.register("generateModMetadata", ProcessResources mod_license : mod_license, mod_version : mod_version, mod_authors : mod_authors, - mod_description : mod_description + mod_description : mod_description, + enderio_version_range : enderio_version_range, + allthemodium_version_range : allthemodium_version_range ] inputs.properties replaceProperties expand replaceProperties diff --git a/gradle.properties b/gradle.properties index 20b96ac..ed78f8a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -42,4 +42,9 @@ mod_group_id=net.enderio.capacitatoradditions # The authors of the mod. This is a simple text string that is used for display purposes in the mod list. mod_authors=lustig7 # The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list. -mod_description=Adds Allthemodium, Vibranium, and Enderium capacitors to Ender IO, enhancing energy efficiency and capacity for All the Mods progression.\n +mod_description=Adds Allthemodium, Vibranium, and Enderium capacitors to Ender IO, enhancing machine speed and capacity for All the Mods progression.\n + +## Dependencies + +allthemodium_version_range=[2.0.0,] +enderio_version_range=[7.0.0,] \ No newline at end of file diff --git a/src/main/java/item/Capacitor.java b/src/main/java/item/Capacitor.java index 0ff95ca..0330d4b 100644 --- a/src/main/java/item/Capacitor.java +++ b/src/main/java/item/Capacitor.java @@ -6,19 +6,19 @@ public class Capacitor { public static final CapacitorData ALLTHEMODIUM_CAPACITOR_DATA = new CapacitorData( - 3.5f, // Base value + 4, // Base value Map.of( ) ); public static final CapacitorData VIBRANIUM_CAPACITOR_DATA = new CapacitorData( - 4.0f, + 5, Map.of( ) ); public static final CapacitorData UNOBTAINIUM_CAPACITOR_DATA = new CapacitorData( - 4.5f, // Base value + 6, // Base value Map.of( ) ); diff --git a/src/main/java/item/CustomCapacitor.java b/src/main/java/item/CustomCapacitor.java index 993ed45..8474be5 100644 --- a/src/main/java/item/CustomCapacitor.java +++ b/src/main/java/item/CustomCapacitor.java @@ -13,12 +13,11 @@ import java.util.List; public class CustomCapacitor extends Item { - private final DataComponentType dataType; + private final CapacitorData capacitorData; - public CustomCapacitor(Properties properties, DataComponentType dataType, CapacitorData capacitorData) { + public CustomCapacitor(Properties properties, CapacitorData capacitorData) { super(properties); - this.dataType = dataType; this.capacitorData = capacitorData; } @@ -29,9 +28,6 @@ public CapacitorData getCapacitorData(@NotNull ItemStack stack) { return capacitorData; } - public DataComponentType getDataType() { - return dataType; - } @Override public void verifyComponentsAfterLoad(ItemStack stack) { diff --git a/src/main/java/item/Items.java b/src/main/java/item/Items.java index 806f458..f01584a 100644 --- a/src/main/java/item/Items.java +++ b/src/main/java/item/Items.java @@ -1,65 +1,29 @@ package item; -import com.enderio.base.api.capacitor.CapacitorData; -import com.enderio.base.api.registry.EnderIORegistries; -import com.enderio.regilite.holder.RegiliteItem; import net.enderio.capacitoradditions.CapacitorAdditions; -import net.enderio.capacitoradditions.component.ModDataComponents; -import net.minecraft.core.Registry; -import net.minecraft.core.component.DataComponentType; -import net.minecraft.core.registries.Registries; import net.minecraft.world.item.Item; import net.neoforged.bus.api.IEventBus; import net.neoforged.neoforge.registries.DeferredItem; import net.neoforged.neoforge.registries.DeferredRegister; -import java.util.function.Supplier; - -import static net.enderio.capacitoradditions.component.ModDataComponents.CAPACITOR_DATA_TYPE; - public class Items { public static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(CapacitorAdditions.MOD_ID); - /* - * public static Supplier> CAPACITOR_DATA_TYPE - * = DATA_COMPONENT_TYPES.registerComponentType("capacitor_data", - * builder -> - * builder.persistent(CapacitorData.CODEC).networkSynchronized(CapacitorData. - * STREAM_CODEC)); - */ - - public static final DeferredItem vibranium_capacitor = ITEMS.register( - "vibranium_capacitor", - () -> new CustomCapacitor(new Item.Properties(), CAPACITOR_DATA_TYPE.get(), - Capacitor.VIBRANIUM_CAPACITOR_DATA)); - public static final DeferredItem allthemodium_capacitor = ITEMS.register( "allthemodium_capacitor", - () -> new CustomCapacitor(new Item.Properties(), CAPACITOR_DATA_TYPE.get(), + () -> new CustomCapacitor(new Item.Properties(), Capacitor.ALLTHEMODIUM_CAPACITOR_DATA)); public static final DeferredItem unobtainium_capacitor = ITEMS.register( "unobtainium_capacitor", - () -> new CustomCapacitor(new Item.Properties(), CAPACITOR_DATA_TYPE.get(), + () -> new CustomCapacitor(new Item.Properties(), Capacitor.UNOBTAINIUM_CAPACITOR_DATA)); - /* - * public static final DeferredItem vibranium_capacitor = ITEMS.register( - * "vibranium_capacitor", - * () -> new CustomCapacitor(new Item.Properties())); - * - * - * public static final DeferredItem allthemodium_capacitor = - * ITEMS.register( - * "allthemodium_capacitor", - * () -> new CustomCapacitor(new Item.Properties())); - * - * public static final DeferredItem unobtainium_capacitor = - * ITEMS.register( - * "unobtainium_capacitor", - * () -> new CustomCapacitor(new Item.Properties())); - */ + public static final DeferredItem vibranium_capacitor = ITEMS.register( + "vibranium_capacitor", + () -> new CustomCapacitor(new Item.Properties(), + Capacitor.VIBRANIUM_CAPACITOR_DATA)); public static void register(IEventBus eventBus) { ITEMS.register(eventBus); diff --git a/src/main/java/net/enderio/capacitoradditions/CapacitorAdditions.java b/src/main/java/net/enderio/capacitoradditions/CapacitorAdditions.java index bff7c96..a06854a 100644 --- a/src/main/java/net/enderio/capacitoradditions/CapacitorAdditions.java +++ b/src/main/java/net/enderio/capacitoradditions/CapacitorAdditions.java @@ -32,8 +32,6 @@ public class CapacitorAdditions { public static final String MOD_ID = "capacitatoradditions"; - private static final Logger LOGGER = LogUtils.getLogger(); - public static final DeferredRegister CREATIVE_MODE_TABS = DeferredRegister .create(Registries.CREATIVE_MODE_TAB, MOD_ID); @@ -43,9 +41,9 @@ public class CapacitorAdditions { .icon(() -> Items.unobtainium_capacitor.get().getDefaultInstance()) .displayItems((parameters, output) -> { - output.accept(Items.unobtainium_capacitor.get()); output.accept(Items.allthemodium_capacitor.get()); output.accept(Items.vibranium_capacitor.get()); + output.accept(Items.unobtainium_capacitor.get()); }).build()); public CapacitorAdditions(IEventBus modEventBus, ModContainer modContainer) { diff --git a/src/main/java/net/enderio/capacitoradditions/Config.java b/src/main/java/net/enderio/capacitoradditions/Config.java index fb73a50..bcabfb2 100644 --- a/src/main/java/net/enderio/capacitoradditions/Config.java +++ b/src/main/java/net/enderio/capacitoradditions/Config.java @@ -1,63 +1,15 @@ package net.enderio.capacitoradditions; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.Item; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.fml.event.config.ModConfigEvent; -import net.neoforged.neoforge.common.ModConfigSpec; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -// An example config class. This is not required, but it's a good idea to have one to keep your config organized. -// Demonstrates how to use Neo's config APIs @EventBusSubscriber(modid = CapacitorAdditions.MOD_ID, bus = EventBusSubscriber.Bus.MOD) public class Config { - private static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder(); - - private static final ModConfigSpec.BooleanValue LOG_DIRT_BLOCK = BUILDER - .comment("Whether to log the dirt block on common setup") - .define("logDirtBlock", true); - - private static final ModConfigSpec.IntValue MAGIC_NUMBER = BUILDER - .comment("A magic number") - .defineInRange("magicNumber", 42, 0, Integer.MAX_VALUE); - - public static final ModConfigSpec.ConfigValue MAGIC_NUMBER_INTRODUCTION = BUILDER - .comment("What you want the introduction message to be for the magic number") - .define("magicNumberIntroduction", "The magic number is... "); - - // a list of strings that are treated as resource locations for items - private static final ModConfigSpec.ConfigValue> ITEM_STRINGS = BUILDER - .comment("A list of items to log on common setup.") - .defineListAllowEmpty("items", List.of("minecraft:iron_ingot"), Config::validateItemName); - - static final ModConfigSpec SPEC = BUILDER.build(); - - public static boolean logDirtBlock; - public static int magicNumber; - public static String magicNumberIntroduction; - public static Set items; - - private static boolean validateItemName(final Object obj) - { - return obj instanceof String itemName && BuiltInRegistries.ITEM.containsKey(ResourceLocation.parse(itemName)); - } @SubscribeEvent static void onLoad(final ModConfigEvent event) { - logDirtBlock = LOG_DIRT_BLOCK.get(); - magicNumber = MAGIC_NUMBER.get(); - magicNumberIntroduction = MAGIC_NUMBER_INTRODUCTION.get(); - - // convert the list of strings into a set of items - items = ITEM_STRINGS.get().stream() - .map(itemName -> BuiltInRegistries.ITEM.get(ResourceLocation.parse(itemName))) - .collect(Collectors.toSet()); } } diff --git a/src/main/resources/assets/capacitatoradditions/models/item/unobtainium_capacitor.json b/src/main/resources/assets/capacitatoradditions/models/item/unobtainium_capacitor.json new file mode 100644 index 0000000..bf06e45 --- /dev/null +++ b/src/main/resources/assets/capacitatoradditions/models/item/unobtainium_capacitor.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "capacitatoradditions:item/unobtainium_capacitor" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/capacitatoradditions/models/item/unobtanium_capacitor.json b/src/main/resources/assets/capacitatoradditions/models/item/unobtanium_capacitor.json deleted file mode 100644 index a6894e0..0000000 --- a/src/main/resources/assets/capacitatoradditions/models/item/unobtanium_capacitor.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "minecraft:item/generated", - "textures": { - "layer0": "capacitatoradditions:item/unobtanium_capacitor" - } -} \ No newline at end of file diff --git a/src/main/resources/data/capacitatoradditions/recipe/vibranium_capacitor.json b/src/main/resources/data/capacitatoradditions/recipe/vibranium_capacitor.json index 2f0e3bd..397eb8e 100644 --- a/src/main/resources/data/capacitatoradditions/recipe/vibranium_capacitor.json +++ b/src/main/resources/data/capacitatoradditions/recipe/vibranium_capacitor.json @@ -2,17 +2,17 @@ "type": "minecraft:crafting_shaped", "category": "misc", "key": { - "C": { + "A": { "item": "capacitatoradditions:allthemodium_capacitor" }, - "G": { - "item": "enderio:grains_of_infinity" + "C": { + "item": "enderio:powdered_coal" }, "I": { "item": "allthemodium:vibranium_ingot" } }, - "pattern": [" I ", "CGC", " I "], + "pattern": [" I ", "ACA", " I "], "result": { "count": 1, "id": "capacitatoradditions:vibranium_capacitor" diff --git a/src/main/templates/META-INF/neoforge.mods.toml b/src/main/templates/META-INF/neoforge.mods.toml index 3daa2cc..1009c6e 100644 --- a/src/main/templates/META-INF/neoforge.mods.toml +++ b/src/main/templates/META-INF/neoforge.mods.toml @@ -80,7 +80,7 @@ description='''${mod_description}''' modId="enderio" type="required" # This version range declares a minimum of the current minecraft version up to but not including the next major version - versionRange="[7.0.0,8.0.0]" + versionRange="${enderio_version_range}" ordering="NONE" side="BOTH" @@ -88,7 +88,7 @@ description='''${mod_description}''' modId="allthemodium" type="required" # This version range declares a minimum of the current minecraft version up to but not including the next major version - versionRange="[2.7.0,3.0.0]" + versionRange="${allthemodium_version_range}" ordering="NONE" side="BOTH"