Skip to content

Commit

Permalink
refactor code: removed unused lines of code + refactor gradle.properties
Browse files Browse the repository at this point in the history
  • Loading branch information
lustig7 committed Dec 30, 2024
1 parent 214baa7 commit 2f92bdb
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 116 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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,]
6 changes: 3 additions & 3 deletions src/main/java/item/Capacitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(
)
);
Expand Down
8 changes: 2 additions & 6 deletions src/main/java/item/CustomCapacitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
import java.util.List;

public class CustomCapacitor extends Item {
private final DataComponentType<CapacitorData> dataType;

private final CapacitorData capacitorData;

public CustomCapacitor(Properties properties, DataComponentType<CapacitorData> dataType, CapacitorData capacitorData) {
public CustomCapacitor(Properties properties, CapacitorData capacitorData) {
super(properties);
this.dataType = dataType;
this.capacitorData = capacitorData;
}

Expand All @@ -29,9 +28,6 @@ public CapacitorData getCapacitorData(@NotNull ItemStack stack) {
return capacitorData;
}

public DataComponentType<CapacitorData> getDataType() {
return dataType;
}

@Override
public void verifyComponentsAfterLoad(ItemStack stack) {
Expand Down
48 changes: 6 additions & 42 deletions src/main/java/item/Items.java
Original file line number Diff line number Diff line change
@@ -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<DataComponentType<CapacitorData>> CAPACITOR_DATA_TYPE
* = DATA_COMPONENT_TYPES.registerComponentType("capacitor_data",
* builder ->
* builder.persistent(CapacitorData.CODEC).networkSynchronized(CapacitorData.
* STREAM_CODEC));
*/

public static final DeferredItem<Item> vibranium_capacitor = ITEMS.register(
"vibranium_capacitor",
() -> new CustomCapacitor(new Item.Properties(), CAPACITOR_DATA_TYPE.get(),
Capacitor.VIBRANIUM_CAPACITOR_DATA));

public static final DeferredItem<Item> 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<Item> 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<Item> vibranium_capacitor = ITEMS.register(
* "vibranium_capacitor",
* () -> new CustomCapacitor(new Item.Properties()));
*
*
* public static final DeferredItem<Item> allthemodium_capacitor =
* ITEMS.register(
* "allthemodium_capacitor",
* () -> new CustomCapacitor(new Item.Properties()));
*
* public static final DeferredItem<Item> unobtainium_capacitor =
* ITEMS.register(
* "unobtainium_capacitor",
* () -> new CustomCapacitor(new Item.Properties()));
*/
public static final DeferredItem<Item> vibranium_capacitor = ITEMS.register(
"vibranium_capacitor",
() -> new CustomCapacitor(new Item.Properties(),
Capacitor.VIBRANIUM_CAPACITOR_DATA));

public static void register(IEventBus eventBus) {
ITEMS.register(eventBus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister
.create(Registries.CREATIVE_MODE_TAB, MOD_ID);

Expand All @@ -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) {
Expand Down
48 changes: 0 additions & 48 deletions src/main/java/net/enderio/capacitoradditions/Config.java
Original file line number Diff line number Diff line change
@@ -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<String> 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<List<? extends String>> 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<Item> 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());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "capacitatoradditions:item/unobtainium_capacitor"
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/main/templates/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ 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"

[[dependencies.${mod_id}]]
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"

Expand Down

0 comments on commit 2f92bdb

Please sign in to comment.