diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 55f0378a..9d5e3c7e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,10 +21,13 @@ jobs: with: cache-read-only: true - - name: Build with Gradle - run: gradle build + - name: Build and publish with Gradle + run: gradle build publishAllPublicationsToModmavenRepository env: TAG: ${{ github.event.release.tag_name }} + MODMAVEN_USER: ${{ secrets.MODMAVEN_USER }} + MODMAVEN_PASSWORD: ${{ secrets.MODMAVEN_PASSWORD }} + ORG_GRADLE_PROJECT_runtimeItemlistMod: none - name: Upload a neoforge build uses: actions/upload-artifact@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29b..6d97803e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -0,0 +1,2 @@ +- new API for addons +- updated the mod icon diff --git a/README.md b/README.md index 6cb0726e..0214291a 100644 --- a/README.md +++ b/README.md @@ -36,3 +36,55 @@ It also adds a wireless universal terminal which has all wireless terminals in o * Text and Translations - [![License](https://img.shields.io/badge/License-No%20Restriction-green.svg?style=flat-square)](https://creativecommons.org/publicdomain/zero/1.0/) + +## API + +Like ae2, ae2wtlib is available on modmaven +``` +repositories { + maven { + url = uri("https://modmaven.dev/") + content { + includeGroup "appeng" + includeGroup "de.mari_023" + } + } +} +``` + +ae2wtlib has an api, which is what you should compile against when making integrations with ae2wtlib +``` +dependencies { + implementation("de.mari_023:ae2wtlib_api:VERSION") + runtimeOnly("de.mari_023:ae2wtlib:VERSION") +} +``` + +If you want to add your own terminals, you should jar-in-jar ae2wtlib_api +``` +dependencies { + jarJar(implementation("de.mari_023:ae2wtlib_api:VERSION")) + runtimeOnly("de.mari_023:ae2wtlib:VERSION") +} +``` + +If you want to add upgrades to ae2wtlib terminals, you can use `UpgradeHelper#addUpgradeToAllTerminals` +```java +addUpgradeToAllTerminals(upgradeCard, maxSupported); +// use 0 to add the maximum amount of upgrades the terminal can fit +addUpgradeToAllTerminals(upgradeCard, 0); +``` + +### Adding terminals + +For a simple example of a wireless terminal, you can look at the Wireless Pattern Access Terminal. +The related classes are `ItemWAT`, `WATMenu`, `WATMenuHost` and `WATScreen` + +For registration, you need to listen to the `AddTerminalEvent` (it isn't actually an EventBus event) +```java +AddTerminalEvent.register(event -> event.builder( + ... +).addTerminal()) +``` + +The builder has some additional methods for overriding properties that are inferred from other attributes, like `WTDefinitionBuilder#translationKey` diff --git a/api/build.gradle.kts b/api/build.gradle.kts new file mode 100644 index 00000000..336e3e4b --- /dev/null +++ b/api/build.gradle.kts @@ -0,0 +1,111 @@ +plugins { + id("net.neoforged.moddev") + id("com.diffplug.spotless") + id("maven-publish") + java + idea +} + +val ae2Version: String by project +val neoforgeVersion: String by project +val mavenGroup: String by project +val modID: String by project + + +version = "0.0.0-SNAPSHOT" + +val pr = System.getenv("PR_NUMBER") ?: "" +if (pr != "") { + version = "0.0.0-pr$pr" +} + +val tag = System.getenv("TAG") ?: "" +if (tag != "") { + version = tag +} + +val artifactVersion = version + +java.toolchain.languageVersion = JavaLanguageVersion.of(21) + +dependencies { + implementation("appeng:appliedenergistics2:${ae2Version}") + compileOnly("com.google.code.findbugs:jsr305:3.0.2") +} + +tasks { + processResources { + // Ensure the resources get re-evaluate when the version changes + inputs.property("version", version) + inputs.property("ae2_version", ae2Version) + + val replaceProperties = mapOf( + "version" to version as String, "ae2_version" to ae2Version + ) + + inputs.properties(replaceProperties) + filesMatching("META-INF/neoforge.mods.toml") { + expand(replaceProperties) + } + } + withType { + options.encoding = "UTF-8" + } +} + +neoForge { + version = neoforgeVersion + mods { + create(modID) { + sourceSet(sourceSets.main.get()) + } + } + runs { + configureEach { + gameDirectory.file("run") + systemProperty("forge.logging.console.level", "debug") + } + + create("api_client") { + client() + } + create("api_server") { + server() + } + } +} + +publishing { + publications { + create(modID) { + groupId = mavenGroup + artifactId = modID + version = artifactVersion.toString() + + from(components["java"]) + } + } + repositories { + maven { + credentials { + username = System.getenv("MODMAVEN_USER") + password = System.getenv("MODMAVEN_PASSWORD") + } + name = "modmaven" + url = uri("https://modmaven.dev/artifactory/local-releases/") + } + } +} + +spotless { + java { + target("/src/**/java/**/*.java") + + endWithNewline() + indentWithSpaces() + removeUnusedImports() + toggleOffOn() + eclipse().configFile("../codeformat/codeformat.xml") + importOrderFile("../codeformat/ae2wtlib.importorder") + } +} \ No newline at end of file diff --git a/api/gradle.properties b/api/gradle.properties new file mode 100644 index 00000000..6c29adcc --- /dev/null +++ b/api/gradle.properties @@ -0,0 +1 @@ +modID=ae2wtlib_api \ No newline at end of file diff --git a/api/src/main/java/de/mari_023/ae2wtlib/api/AE2wtlibAPI.java b/api/src/main/java/de/mari_023/ae2wtlib/api/AE2wtlibAPI.java new file mode 100644 index 00000000..fef42983 --- /dev/null +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/AE2wtlibAPI.java @@ -0,0 +1,76 @@ +package de.mari_023.ae2wtlib.api; + +import java.util.function.Supplier; + +import com.mojang.datafixers.util.Unit; + +import org.jetbrains.annotations.ApiStatus; + +import net.minecraft.core.component.DataComponentType; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.neoforged.fml.ModList; + +import appeng.api.upgrades.IUpgradeInventory; +import appeng.menu.locator.ItemMenuHostLocator; + +import de.mari_023.ae2wtlib.api.terminal.ItemWUT; + +public class AE2wtlibAPI { + public static final String MOD_NAME = "ae2wtlib"; + public static final String API_MOD_NAME = "ae2wtlib_api"; + + private AE2wtlibAPI() {} + + public static ResourceLocation id(String name) { + return ResourceLocation.fromNamespaceAndPath(MOD_NAME, name); + } + + public static boolean isModPresent(String mod) { + return ModList.get().isLoaded(mod); + } + + public static boolean hasQuantumBridgeCard(Supplier upgrades) { + return AE2wtlibAPIImpl.instance().hasQuantumBridgeCard(upgrades); + } + + public static boolean isUniversalTerminal(Item item) { + return AE2wtlibAPIImpl.instance().isUniversalTerminal(item); + } + + public static boolean isUniversalTerminal(ItemStack stack) { + return isUniversalTerminal(stack.getItem()); + } + + public static ItemStack makeWUT(DataComponentType componentType) { + if (!(getWUT() instanceof ItemWUT wutItem)) + return ItemStack.EMPTY; + ItemStack wut = new ItemStack(wutItem); + + wut.set(componentType, Unit.INSTANCE); + return wut; + } + + public static Item getWUT() { + return AE2wtlibAPIImpl.instance().getWUT(); + } + + @ApiStatus.Internal + public static void cycleTerminal(boolean isHandlingRightClick) { + AE2wtlibAPIImpl.instance().cycleTerminal(isHandlingRightClick); + } + + /** + * Sends an update to the client about the current terminal. This is only relevant for Universal Terminals, and only + * sent when ae2wtlib is present. + * + * @param player The server player. + * @param locator The menu locator. + * @param stack The compound tag containing terminal data. + */ + public static void updateClientTerminal(ServerPlayer player, ItemMenuHostLocator locator, ItemStack stack) { + AE2wtlibAPIImpl.instance().updateClientTerminal(player, locator, stack); + } +} diff --git a/api/src/main/java/de/mari_023/ae2wtlib/api/AE2wtlibAPIEntrypoint.java b/api/src/main/java/de/mari_023/ae2wtlib/api/AE2wtlibAPIEntrypoint.java new file mode 100644 index 00000000..6c25fd68 --- /dev/null +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/AE2wtlibAPIEntrypoint.java @@ -0,0 +1,26 @@ +package de.mari_023.ae2wtlib.api; + +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.fml.common.Mod; +import net.neoforged.neoforge.registries.RegisterEvent; + +import de.mari_023.ae2wtlib.api.registration.AddTerminalEvent; +import de.mari_023.ae2wtlib.api.registration.UpgradeHelper; + +@Mod(AE2wtlibAPI.API_MOD_NAME) +public class AE2wtlibAPIEntrypoint { + public AE2wtlibAPIEntrypoint(IEventBus modEventBus) { + modEventBus.addListener((RegisterEvent event) -> { + if (!event.getRegistryKey().equals(Registries.ITEM)) { + return; + } + AddTerminalEvent.run(); + UpgradeHelper.addUpgrades(); + for (var entry : AE2wtlibComponents.DR.entrySet()) + Registry.register(BuiltInRegistries.DATA_COMPONENT_TYPE, entry.getKey(), entry.getValue()); + }); + } +} diff --git a/api/src/main/java/de/mari_023/ae2wtlib/api/AE2wtlibAPIImpl.java b/api/src/main/java/de/mari_023/ae2wtlib/api/AE2wtlibAPIImpl.java new file mode 100644 index 00000000..95b9fc98 --- /dev/null +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/AE2wtlibAPIImpl.java @@ -0,0 +1,53 @@ +package de.mari_023.ae2wtlib.api; + +import java.util.Objects; +import java.util.function.Supplier; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; + +import appeng.api.upgrades.IUpgradeInventory; +import appeng.menu.locator.ItemMenuHostLocator; + +@ApiStatus.Internal +public class AE2wtlibAPIImpl { + @Nullable + private static AE2wtlibAPIImpl instance; + + protected AE2wtlibAPIImpl() { + if (instance != null) + throw new IllegalStateException("Already initialized"); + instance = this; + } + + public static AE2wtlibAPIImpl instance() { + return Objects.requireNonNull(instance); + } + + static { + if (!AE2wtlibAPI.isModPresent("ae2wtlib")) + new AE2wtlibAPIImpl(); + } + + public boolean hasQuantumBridgeCard(Supplier upgrades) { + return false; + } + + public boolean isUniversalTerminal(Item item) { + return false; + } + + public Item getWUT() { + return Items.AIR; + } + + @ApiStatus.Internal + public void cycleTerminal(boolean isHandlingRightClick) {} + + public void updateClientTerminal(ServerPlayer player, ItemMenuHostLocator locator, ItemStack stack) {} +} diff --git a/src/main/java/de/mari_023/ae2wtlib/AE2wtlibComponents.java b/api/src/main/java/de/mari_023/ae2wtlib/api/AE2wtlibComponents.java similarity index 78% rename from src/main/java/de/mari_023/ae2wtlib/AE2wtlibComponents.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/AE2wtlibComponents.java index 09801cea..c9f16bbc 100644 --- a/src/main/java/de/mari_023/ae2wtlib/AE2wtlibComponents.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/AE2wtlibComponents.java @@ -1,12 +1,10 @@ -package de.mari_023.ae2wtlib; +package de.mari_023.ae2wtlib.api; import java.util.HashMap; import java.util.Map; import java.util.function.Consumer; -import java.util.function.Supplier; import com.mojang.serialization.Codec; -import com.mojang.serialization.DataResult; import net.minecraft.core.component.DataComponentType; import net.minecraft.nbt.CompoundTag; @@ -14,19 +12,15 @@ import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.component.ItemContainerContents; -import net.neoforged.neoforge.attachment.AttachmentType; import net.neoforged.neoforge.network.codec.NeoForgeStreamCodecs; import appeng.api.config.IncludeExclude; import appeng.menu.locator.ItemMenuHostLocator; import appeng.menu.locator.MenuLocators; -import de.mari_023.ae2wtlib.wct.CraftingTerminalHandler; -import de.mari_023.ae2wtlib.wct.magnet_card.MagnetMode; -import de.mari_023.ae2wtlib.wut.WTDefinition; +import de.mari_023.ae2wtlib.api.registration.WTDefinition; public class AE2wtlibComponents { private static final Consumer> COMPOUND_TAG_CODECS = builder -> builder @@ -51,10 +45,6 @@ public class AE2wtlibComponents { builder -> builder.persistent(ItemContainerContents.CODEC) .networkSynchronized(ItemContainerContents.STREAM_CODEC)); - public static final DataComponentType MAGNET_SETTINGS = register("magnet_settings", - builder -> builder.persistent(Codec.BYTE.comapFlatMap(b -> DataResult.success(MagnetMode.fromByte(b)), - MagnetMode::getId)) - .networkSynchronized(NeoForgeStreamCodecs.enumCodec(MagnetMode.class))); public static final DataComponentType PICKUP_CONFIG = register("pickup_config", COMPOUND_TAG_CODECS); public static final DataComponentType INSERT_CONFIG = register("insert_config", COMPOUND_TAG_CODECS); public static final DataComponentType PICKUP_MODE = register("pickup_mode", INCLUDE_EXCLUDE_CODECS); @@ -65,15 +55,11 @@ public class AE2wtlibComponents { public static final DataComponentType PATTERN_ENCODING_LOGIC = register("pattern_encoding_logic", COMPOUND_TAG_CODECS); - public static final Supplier> CT_HANDLER = AE2wtlib.ATTACHMENT_TYPES - .register("ct_handler", - () -> AttachmentType.builder((player) -> new CraftingTerminalHandler((Player) player)).build()); - public static DataComponentType register(String name, Consumer> customizer) { var builder = DataComponentType.builder(); customizer.accept(builder); var componentType = builder.build(); - DR.put(AE2wtlib.id(name), componentType); + DR.put(AE2wtlibAPI.id(name), componentType); return componentType; } diff --git a/src/main/java/de/mari_023/ae2wtlib/TextConstants.java b/api/src/main/java/de/mari_023/ae2wtlib/api/TextConstants.java similarity index 98% rename from src/main/java/de/mari_023/ae2wtlib/TextConstants.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/TextConstants.java index 093fcea1..3d3d8a2b 100644 --- a/src/main/java/de/mari_023/ae2wtlib/TextConstants.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/TextConstants.java @@ -1,4 +1,4 @@ -package de.mari_023.ae2wtlib; +package de.mari_023.ae2wtlib.api; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; @@ -7,7 +7,7 @@ import appeng.api.config.IncludeExclude; -import de.mari_023.ae2wtlib.wut.WTDefinition; +import de.mari_023.ae2wtlib.api.registration.WTDefinition; public final class TextConstants { private TextConstants() {} diff --git a/src/main/java/de/mari_023/ae2wtlib/AE2wtlibSlotSemantics.java b/api/src/main/java/de/mari_023/ae2wtlib/api/gui/AE2wtlibSlotSemantics.java similarity index 96% rename from src/main/java/de/mari_023/ae2wtlib/AE2wtlibSlotSemantics.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/gui/AE2wtlibSlotSemantics.java index f63a7cdf..d9e6a88b 100644 --- a/src/main/java/de/mari_023/ae2wtlib/AE2wtlibSlotSemantics.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/gui/AE2wtlibSlotSemantics.java @@ -1,4 +1,4 @@ -package de.mari_023.ae2wtlib; +package de.mari_023.ae2wtlib.api.gui; import appeng.menu.SlotSemantic; import appeng.menu.SlotSemantics; diff --git a/src/main/java/de/mari_023/ae2wtlib/terminal/Icon.java b/api/src/main/java/de/mari_023/ae2wtlib/api/gui/Icon.java similarity index 98% rename from src/main/java/de/mari_023/ae2wtlib/terminal/Icon.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/gui/Icon.java index 3d108bf1..e5be9c7b 100644 --- a/src/main/java/de/mari_023/ae2wtlib/terminal/Icon.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/gui/Icon.java @@ -1,4 +1,4 @@ -package de.mari_023.ae2wtlib.terminal; +package de.mari_023.ae2wtlib.api.gui; import net.minecraft.resources.ResourceLocation; diff --git a/src/main/java/de/mari_023/ae2wtlib/terminal/IconButton.java b/api/src/main/java/de/mari_023/ae2wtlib/api/gui/IconButton.java similarity index 98% rename from src/main/java/de/mari_023/ae2wtlib/terminal/IconButton.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/gui/IconButton.java index 60c5caba..6bdc4593 100644 --- a/src/main/java/de/mari_023/ae2wtlib/terminal/IconButton.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/gui/IconButton.java @@ -1,4 +1,4 @@ -package de.mari_023.ae2wtlib.terminal; +package de.mari_023.ae2wtlib.api.gui; import java.util.Collections; import java.util.List; diff --git a/src/main/java/de/mari_023/ae2wtlib/terminal/ScrollingUpgradesPanel.java b/api/src/main/java/de/mari_023/ae2wtlib/api/gui/ScrollingUpgradesPanel.java similarity index 97% rename from src/main/java/de/mari_023/ae2wtlib/terminal/ScrollingUpgradesPanel.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/gui/ScrollingUpgradesPanel.java index 719e2e9f..da0ed502 100644 --- a/src/main/java/de/mari_023/ae2wtlib/terminal/ScrollingUpgradesPanel.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/gui/ScrollingUpgradesPanel.java @@ -1,4 +1,4 @@ -package de.mari_023.ae2wtlib.terminal; +package de.mari_023.ae2wtlib.api.gui; import java.util.List; import java.util.function.Consumer; @@ -22,7 +22,7 @@ import appeng.core.localization.GuiText; import appeng.menu.slot.AppEngSlot; -import de.mari_023.ae2wtlib.AE2wtlibItems; +import de.mari_023.ae2wtlib.api.AE2wtlibAPI; public class ScrollingUpgradesPanel implements ICompositeWidget { private static final int SLOT_SIZE = 18; @@ -58,7 +58,7 @@ public ScrollingUpgradesPanel(List slots, IUpgradeableObject upgradeableOb private boolean singularitySlotHidden() { return isDisabledSlotEmpty((AppEngSlot) slots.getFirst()) - && !upgrades.get().isInstalled(AE2wtlibItems.QUANTUM_BRIDGE_CARD); + && !AE2wtlibAPI.hasQuantumBridgeCard(upgrades); } private boolean isDisabledSlotEmpty(AppEngSlot slot) { diff --git a/src/main/java/de/mari_023/ae2wtlib/terminal/UpgradeBackground.java b/api/src/main/java/de/mari_023/ae2wtlib/api/gui/UpgradeBackground.java similarity index 93% rename from src/main/java/de/mari_023/ae2wtlib/terminal/UpgradeBackground.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/gui/UpgradeBackground.java index ff1452cc..f5ab70d2 100644 --- a/src/main/java/de/mari_023/ae2wtlib/terminal/UpgradeBackground.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/gui/UpgradeBackground.java @@ -1,4 +1,4 @@ -package de.mari_023.ae2wtlib.terminal; +package de.mari_023.ae2wtlib.api.gui; public record UpgradeBackground(Icon top, Icon middle, Icon bottom) { diff --git a/src/main/java/de/mari_023/ae2wtlib/terminal/package-info.java b/api/src/main/java/de/mari_023/ae2wtlib/api/gui/package-info.java similarity index 86% rename from src/main/java/de/mari_023/ae2wtlib/terminal/package-info.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/gui/package-info.java index 6936041d..7b1a8b7b 100644 --- a/src/main/java/de/mari_023/ae2wtlib/terminal/package-info.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/gui/package-info.java @@ -1,7 +1,7 @@ @FieldsAreNonnullByDefault @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault -package de.mari_023.ae2wtlib.terminal; +package de.mari_023.ae2wtlib.api.gui; import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/de/mari_023/ae2wtlib/terminal/results/package-info.java b/api/src/main/java/de/mari_023/ae2wtlib/api/package-info.java similarity index 83% rename from src/main/java/de/mari_023/ae2wtlib/terminal/results/package-info.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/package-info.java index 438daa3c..d77201ef 100644 --- a/src/main/java/de/mari_023/ae2wtlib/terminal/results/package-info.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/package-info.java @@ -1,7 +1,7 @@ @FieldsAreNonnullByDefault @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault -package de.mari_023.ae2wtlib.terminal.results; +package de.mari_023.ae2wtlib.api; import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/de/mari_023/ae2wtlib/wut/AddTerminalEvent.java b/api/src/main/java/de/mari_023/ae2wtlib/api/registration/AddTerminalEvent.java similarity index 92% rename from src/main/java/de/mari_023/ae2wtlib/wut/AddTerminalEvent.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/registration/AddTerminalEvent.java index 6a6d178f..e21074f8 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wut/AddTerminalEvent.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/registration/AddTerminalEvent.java @@ -1,4 +1,4 @@ -package de.mari_023.ae2wtlib.wut; +package de.mari_023.ae2wtlib.api.registration; import java.util.ArrayList; import java.util.List; @@ -9,8 +9,8 @@ import net.minecraft.world.inventory.MenuType; -import de.mari_023.ae2wtlib.terminal.Icon; -import de.mari_023.ae2wtlib.terminal.ItemWT; +import de.mari_023.ae2wtlib.api.gui.Icon; +import de.mari_023.ae2wtlib.api.terminal.ItemWT; public final class AddTerminalEvent { private AddTerminalEvent() {} diff --git a/src/main/java/de/mari_023/ae2wtlib/UpgradeHelper.java b/api/src/main/java/de/mari_023/ae2wtlib/api/registration/UpgradeHelper.java similarity index 73% rename from src/main/java/de/mari_023/ae2wtlib/UpgradeHelper.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/registration/UpgradeHelper.java index fa35d7de..a3567566 100644 --- a/src/main/java/de/mari_023/ae2wtlib/UpgradeHelper.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/registration/UpgradeHelper.java @@ -1,27 +1,25 @@ -package de.mari_023.ae2wtlib; +package de.mari_023.ae2wtlib.api.registration; import java.util.HashMap; import java.util.Map; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; import net.minecraft.world.level.ItemLike; import appeng.api.upgrades.Upgrades; import appeng.core.definitions.AEItems; import appeng.core.localization.GuiText; -import de.mari_023.ae2wtlib.wut.WTDefinition; -import de.mari_023.ae2wtlib.wut.WUTHandler; +import de.mari_023.ae2wtlib.api.AE2wtlibAPI; +import de.mari_023.ae2wtlib.api.terminal.WUTHandler; public class UpgradeHelper { private static volatile boolean readyForUpgrades = false; private static final Map upgrades = new HashMap<>(); - static synchronized void addUpgrades() { + public static synchronized void addUpgrades() { addUpgradeToAllTerminals(AEItems.ENERGY_CARD, 0); - addUpgradeToAllTerminals(AE2wtlibItems.QUANTUM_BRIDGE_CARD, 1); - - Upgrades.add(AE2wtlibItems.MAGNET_CARD, AEItems.WIRELESS_CRAFTING_TERMINAL, 1); - Upgrades.add(AE2wtlibItems.MAGNET_CARD, AE2wtlibItems.UNIVERSAL_TERMINAL, 1); readyForUpgrades = true; for (var upgrade : upgrades.entrySet()) { @@ -49,11 +47,11 @@ public static synchronized void addUpgradeToAllTerminals(ItemLike upgradeCard, i Upgrades.add(upgradeCard, terminal.item(), Math.min(maxSupported, max), GuiText.WirelessTerminals.getTranslationKey()); } - Upgrades.add(upgradeCard, AE2wtlibItems.UNIVERSAL_TERMINAL, maxSupported); + addUpgradesToUniversalTerminal(upgradeCard, maxSupported); } private static void addMaxUpgradesToAllTerminals(ItemLike upgradeCard) { - Upgrades.add(upgradeCard, AE2wtlibItems.UNIVERSAL_TERMINAL, WUTHandler.getUpgradeCardCount()); + addUpgradesToUniversalTerminal(upgradeCard, WUTHandler.getUpgradeCardCount()); for (var terminal : WTDefinition.wirelessTerminals()) { int max = terminal.upgradeCount(); if (max == 0) @@ -61,4 +59,10 @@ private static void addMaxUpgradesToAllTerminals(ItemLike upgradeCard) { Upgrades.add(upgradeCard, terminal.item(), max, GuiText.WirelessTerminals.getTranslationKey()); } } + + private static void addUpgradesToUniversalTerminal(ItemLike upgradeCard, int maxSupported) { + Item wut = AE2wtlibAPI.getWUT(); + if (wut != Items.AIR) + Upgrades.add(upgradeCard, wut, maxSupported); + } } diff --git a/src/main/java/de/mari_023/ae2wtlib/wut/WTDefinition.java b/api/src/main/java/de/mari_023/ae2wtlib/api/registration/WTDefinition.java similarity index 89% rename from src/main/java/de/mari_023/ae2wtlib/wut/WTDefinition.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/registration/WTDefinition.java index adc0fb42..16435fd4 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wut/WTDefinition.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/registration/WTDefinition.java @@ -1,4 +1,4 @@ -package de.mari_023.ae2wtlib.wut; +package de.mari_023.ae2wtlib.api.registration; import java.util.*; import java.util.function.BiConsumer; @@ -7,6 +7,7 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.DataResult; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; import io.netty.buffer.ByteBuf; @@ -22,10 +23,11 @@ import appeng.menu.ISubMenu; import appeng.menu.locator.ItemMenuHostLocator; -import de.mari_023.ae2wtlib.AE2wtlibComponents; -import de.mari_023.ae2wtlib.terminal.Icon; -import de.mari_023.ae2wtlib.terminal.ItemWT; -import de.mari_023.ae2wtlib.terminal.WTMenuHost; +import de.mari_023.ae2wtlib.api.AE2wtlibComponents; +import de.mari_023.ae2wtlib.api.gui.Icon; +import de.mari_023.ae2wtlib.api.terminal.ItemWT; +import de.mari_023.ae2wtlib.api.terminal.ItemWUT; +import de.mari_023.ae2wtlib.api.terminal.WTMenuHost; public record WTDefinition(String terminalName, ContainerOpener containerOpener, WTMenuHostFactory wTMenuHostFactory, MenuType menuType, ItemWT item, ItemStack universalTerminal, MutableComponent formattedName, @@ -43,7 +45,8 @@ WTMenuHost create(ItemWT item, Player player, ItemMenuHostLocator locator, } private static final Map wirelessTerminals = new HashMap<>(); - static final List wirelessTerminalList = new ArrayList<>(); + @ApiStatus.Internal + public static final List wirelessTerminalList = new ArrayList<>(); public static final Codec CODEC = Codec.STRING.comapFlatMap(s -> { var terminal = wirelessTerminals.get(s); @@ -72,7 +75,7 @@ public static Collection wirelessTerminals() { return wirelessTerminals.values(); } - static WTDefinition of(String name) { + public static WTDefinition of(String name) { return Objects.requireNonNull(wirelessTerminals.get(name)); } diff --git a/src/main/java/de/mari_023/ae2wtlib/wut/WTDefinitionBuilder.java b/api/src/main/java/de/mari_023/ae2wtlib/api/registration/WTDefinitionBuilder.java similarity index 87% rename from src/main/java/de/mari_023/ae2wtlib/wut/WTDefinitionBuilder.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/registration/WTDefinitionBuilder.java index 17e8ea9d..5a92499b 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wut/WTDefinitionBuilder.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/registration/WTDefinitionBuilder.java @@ -1,4 +1,4 @@ -package de.mari_023.ae2wtlib.wut; +package de.mari_023.ae2wtlib.api.registration; import com.mojang.datafixers.util.Unit; import com.mojang.serialization.Codec; @@ -8,17 +8,16 @@ import net.minecraft.core.component.DataComponentType; import net.minecraft.world.inventory.MenuType; -import net.minecraft.world.item.ItemStack; import net.neoforged.neoforge.network.codec.NeoForgeStreamCodecs; import appeng.hotkeys.HotkeyActions; -import de.mari_023.ae2wtlib.AE2wtlibComponents; -import de.mari_023.ae2wtlib.AE2wtlibItems; -import de.mari_023.ae2wtlib.TextConstants; -import de.mari_023.ae2wtlib.hotkeys.Ae2wtlibLocatingService; -import de.mari_023.ae2wtlib.terminal.Icon; -import de.mari_023.ae2wtlib.terminal.ItemWT; +import de.mari_023.ae2wtlib.api.AE2wtlibAPI; +import de.mari_023.ae2wtlib.api.AE2wtlibComponents; +import de.mari_023.ae2wtlib.api.TextConstants; +import de.mari_023.ae2wtlib.api.gui.Icon; +import de.mari_023.ae2wtlib.api.terminal.Ae2wtlibLocatingService; +import de.mari_023.ae2wtlib.api.terminal.ItemWT; public class WTDefinitionBuilder { private final AddTerminalEvent event; @@ -60,9 +59,7 @@ public void addTerminal() { if (WTDefinition.exists(name)) throw new IllegalStateException("Trying to register terminal with name " + name + " but it already exists"); - ItemStack wut = new ItemStack(AE2wtlibItems.UNIVERSAL_TERMINAL); - - wut.set(componentType, Unit.INSTANCE); + var wut = AE2wtlibAPI.makeWUT(componentType); WTDefinition wtDefinition = new WTDefinition(name, item::tryOpen, wTMenuHostFactory, menuType, item, wut, TextConstants.formatTerminalName(translationKey), translationKey, hotkeyName, componentType, diff --git a/api/src/main/java/de/mari_023/ae2wtlib/api/registration/package-info.java b/api/src/main/java/de/mari_023/ae2wtlib/api/registration/package-info.java new file mode 100644 index 00000000..58133808 --- /dev/null +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/registration/package-info.java @@ -0,0 +1,9 @@ +@FieldsAreNonnullByDefault +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +package de.mari_023.ae2wtlib.api.registration; + +import javax.annotation.ParametersAreNonnullByDefault; + +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/main/java/de/mari_023/ae2wtlib/terminal/results/ActionHostResult.java b/api/src/main/java/de/mari_023/ae2wtlib/api/results/ActionHostResult.java similarity index 90% rename from src/main/java/de/mari_023/ae2wtlib/terminal/results/ActionHostResult.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/results/ActionHostResult.java index 48063eb3..c89e35e7 100644 --- a/src/main/java/de/mari_023/ae2wtlib/terminal/results/ActionHostResult.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/results/ActionHostResult.java @@ -1,4 +1,4 @@ -package de.mari_023.ae2wtlib.terminal.results; +package de.mari_023.ae2wtlib.api.results; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/de/mari_023/ae2wtlib/terminal/results/LongResult.java b/api/src/main/java/de/mari_023/ae2wtlib/api/results/LongResult.java similarity index 85% rename from src/main/java/de/mari_023/ae2wtlib/terminal/results/LongResult.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/results/LongResult.java index 9a9ca19d..b48c0992 100644 --- a/src/main/java/de/mari_023/ae2wtlib/terminal/results/LongResult.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/results/LongResult.java @@ -1,4 +1,4 @@ -package de.mari_023.ae2wtlib.terminal.results; +package de.mari_023.ae2wtlib.api.results; public record LongResult(long result, Status status) implements Result { public static LongResult valid(long result) { diff --git a/src/main/java/de/mari_023/ae2wtlib/terminal/results/Result.java b/api/src/main/java/de/mari_023/ae2wtlib/api/results/Result.java similarity index 80% rename from src/main/java/de/mari_023/ae2wtlib/terminal/results/Result.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/results/Result.java index a2dadcca..6277d968 100644 --- a/src/main/java/de/mari_023/ae2wtlib/terminal/results/Result.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/results/Result.java @@ -1,4 +1,4 @@ -package de.mari_023.ae2wtlib.terminal.results; +package de.mari_023.ae2wtlib.api.results; public interface Result { Status status(); diff --git a/src/main/java/de/mari_023/ae2wtlib/terminal/results/Status.java b/api/src/main/java/de/mari_023/ae2wtlib/api/results/Status.java similarity index 93% rename from src/main/java/de/mari_023/ae2wtlib/terminal/results/Status.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/results/Status.java index be0db2ac..a4ba82ef 100644 --- a/src/main/java/de/mari_023/ae2wtlib/terminal/results/Status.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/results/Status.java @@ -1,4 +1,4 @@ -package de.mari_023.ae2wtlib.terminal.results; +package de.mari_023.ae2wtlib.api.results; import javax.annotation.Nullable; @@ -7,7 +7,7 @@ import appeng.api.storage.ILinkStatus; import appeng.core.localization.PlayerMessages; -import de.mari_023.ae2wtlib.TextConstants; +import de.mari_023.ae2wtlib.api.TextConstants; public enum Status { // Generic results diff --git a/api/src/main/java/de/mari_023/ae2wtlib/api/results/package-info.java b/api/src/main/java/de/mari_023/ae2wtlib/api/results/package-info.java new file mode 100644 index 00000000..2b609cbf --- /dev/null +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/results/package-info.java @@ -0,0 +1,9 @@ +@FieldsAreNonnullByDefault +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +package de.mari_023.ae2wtlib.api.results; + +import javax.annotation.ParametersAreNonnullByDefault; + +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/main/java/de/mari_023/ae2wtlib/hotkeys/Ae2wtlibLocatingService.java b/api/src/main/java/de/mari_023/ae2wtlib/api/terminal/Ae2wtlibLocatingService.java similarity index 83% rename from src/main/java/de/mari_023/ae2wtlib/hotkeys/Ae2wtlibLocatingService.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/terminal/Ae2wtlibLocatingService.java index 452db582..24535b8a 100644 --- a/src/main/java/de/mari_023/ae2wtlib/hotkeys/Ae2wtlibLocatingService.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/terminal/Ae2wtlibLocatingService.java @@ -1,4 +1,4 @@ -package de.mari_023.ae2wtlib.hotkeys; +package de.mari_023.ae2wtlib.api.terminal; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; @@ -6,8 +6,7 @@ import appeng.api.features.HotkeyAction; import appeng.menu.locator.ItemMenuHostLocator; -import de.mari_023.ae2wtlib.wut.WTDefinition; -import de.mari_023.ae2wtlib.wut.WUTHandler; +import de.mari_023.ae2wtlib.api.registration.WTDefinition; public record Ae2wtlibLocatingService(WTDefinition terminal) implements HotkeyAction { @Override diff --git a/src/main/java/de/mari_023/ae2wtlib/wut/IUniversalTerminalCapable.java b/api/src/main/java/de/mari_023/ae2wtlib/api/terminal/IUniversalTerminalCapable.java similarity index 84% rename from src/main/java/de/mari_023/ae2wtlib/wut/IUniversalTerminalCapable.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/terminal/IUniversalTerminalCapable.java index 067bc3a0..e62c61a1 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wut/IUniversalTerminalCapable.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/terminal/IUniversalTerminalCapable.java @@ -1,4 +1,4 @@ -package de.mari_023.ae2wtlib.wut; +package de.mari_023.ae2wtlib.api.terminal; import java.util.ArrayList; import java.util.List; @@ -13,17 +13,17 @@ import appeng.menu.AEBaseMenu; import appeng.menu.SlotSemantics; -import de.mari_023.ae2wtlib.AE2wtlibSlotSemantics; -import de.mari_023.ae2wtlib.TextConstants; -import de.mari_023.ae2wtlib.networking.CycleTerminalPacket; -import de.mari_023.ae2wtlib.terminal.IconButton; -import de.mari_023.ae2wtlib.terminal.ScrollingUpgradesPanel; -import de.mari_023.ae2wtlib.terminal.WTMenuHost; +import de.mari_023.ae2wtlib.api.AE2wtlibAPI; +import de.mari_023.ae2wtlib.api.TextConstants; +import de.mari_023.ae2wtlib.api.gui.AE2wtlibSlotSemantics; +import de.mari_023.ae2wtlib.api.gui.IconButton; +import de.mari_023.ae2wtlib.api.gui.ScrollingUpgradesPanel; +import de.mari_023.ae2wtlib.api.registration.WTDefinition; public interface IUniversalTerminalCapable { default void cycleTerminal() { storeState(); - PacketDistributor.sendToServer(new CycleTerminalPacket(isHandlingRightClick())); + AE2wtlibAPI.cycleTerminal(isHandlingRightClick()); } WTMenuHost getHost(); diff --git a/src/main/java/de/mari_023/ae2wtlib/terminal/ItemWT.java b/api/src/main/java/de/mari_023/ae2wtlib/api/terminal/ItemWT.java similarity index 90% rename from src/main/java/de/mari_023/ae2wtlib/terminal/ItemWT.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/terminal/ItemWT.java index f4db1549..077d62b8 100644 --- a/src/main/java/de/mari_023/ae2wtlib/terminal/ItemWT.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/terminal/ItemWT.java @@ -1,4 +1,4 @@ -package de.mari_023.ae2wtlib.terminal; +package de.mari_023.ae2wtlib.api.terminal; import org.jetbrains.annotations.Nullable; @@ -19,8 +19,8 @@ import appeng.menu.locator.ItemMenuHostLocator; import appeng.menu.locator.MenuLocators; -import de.mari_023.ae2wtlib.AE2wtlibItems; -import de.mari_023.ae2wtlib.wut.WTDefinition; +import de.mari_023.ae2wtlib.api.AE2wtlibAPI; +import de.mari_023.ae2wtlib.api.registration.WTDefinition; public abstract class ItemWT extends WirelessTerminalItem { public ItemWT() { @@ -42,7 +42,7 @@ public boolean tryOpen(Player player, ItemMenuHostLocator locator, boolean retur protected boolean checkPreconditions(ItemStack item) { return !item.isEmpty() - && (item.getItem() == this || item.getItem() == AE2wtlibItems.UNIVERSAL_TERMINAL); + && (item.getItem() == this || AE2wtlibAPI.isUniversalTerminal(item.getItem())); } @Override diff --git a/src/main/java/de/mari_023/ae2wtlib/wut/ItemWUT.java b/api/src/main/java/de/mari_023/ae2wtlib/api/terminal/ItemWUT.java similarity index 96% rename from src/main/java/de/mari_023/ae2wtlib/wut/ItemWUT.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/terminal/ItemWUT.java index d015a918..db37ecb3 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wut/ItemWUT.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/terminal/ItemWUT.java @@ -1,4 +1,4 @@ -package de.mari_023.ae2wtlib.wut; +package de.mari_023.ae2wtlib.api.terminal; import java.util.List; import java.util.function.Supplier; @@ -23,8 +23,8 @@ import appeng.core.definitions.AEItems; import appeng.menu.locator.ItemMenuHostLocator; -import de.mari_023.ae2wtlib.TextConstants; -import de.mari_023.ae2wtlib.terminal.ItemWT; +import de.mari_023.ae2wtlib.api.TextConstants; +import de.mari_023.ae2wtlib.api.registration.WTDefinition; public class ItemWUT extends ItemWT { @Override diff --git a/src/main/java/de/mari_023/ae2wtlib/terminal/WTMenuHost.java b/api/src/main/java/de/mari_023/ae2wtlib/api/terminal/WTMenuHost.java similarity index 95% rename from src/main/java/de/mari_023/ae2wtlib/terminal/WTMenuHost.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/terminal/WTMenuHost.java index 30f03bf2..1d252cf9 100644 --- a/src/main/java/de/mari_023/ae2wtlib/terminal/WTMenuHost.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/terminal/WTMenuHost.java @@ -1,4 +1,4 @@ -package de.mari_023.ae2wtlib.terminal; +package de.mari_023.ae2wtlib.api.terminal; import java.util.function.BiConsumer; @@ -35,13 +35,12 @@ import appeng.util.inv.InternalInventoryHost; import appeng.util.inv.SupplierInternalInventory; -import de.mari_023.ae2wtlib.AE2wtlib; -import de.mari_023.ae2wtlib.AE2wtlibComponents; -import de.mari_023.ae2wtlib.AE2wtlibItems; -import de.mari_023.ae2wtlib.terminal.results.ActionHostResult; -import de.mari_023.ae2wtlib.terminal.results.LongResult; -import de.mari_023.ae2wtlib.terminal.results.Status; -import de.mari_023.ae2wtlib.wut.WTDefinition; +import de.mari_023.ae2wtlib.api.AE2wtlibAPI; +import de.mari_023.ae2wtlib.api.AE2wtlibComponents; +import de.mari_023.ae2wtlib.api.registration.WTDefinition; +import de.mari_023.ae2wtlib.api.results.ActionHostResult; +import de.mari_023.ae2wtlib.api.results.LongResult; +import de.mari_023.ae2wtlib.api.results.Status; public abstract class WTMenuHost extends WirelessTerminalMenuHost implements ISegmentedInventory { @@ -49,7 +48,7 @@ public abstract class WTMenuHost extends WirelessTerminalMenuHost private final SupplierInternalInventory viewCellInventory; @Nullable private IActionHost quantumBridge; - public static final ResourceLocation INV_SINGULARITY = AE2wtlib.id("singularity"); + public static final ResourceLocation INV_SINGULARITY = AE2wtlibAPI.id("singularity"); private final MEStorage storage; @UnknownNullability private ILinkStatus linkStatus; @@ -150,7 +149,7 @@ public LongResult getQEFrequency() { private ILinkStatus isQuantumLinked() { Status status = Status.Valid; - if (!getUpgrades().isInstalled(AE2wtlibItems.QUANTUM_BRIDGE_CARD)) + if (!AE2wtlibAPI.hasQuantumBridgeCard(this::getUpgrades)) status = Status.NoUpgrade; LongResult f = getQEFrequency(); if (!f.valid()) { diff --git a/src/main/java/de/mari_023/ae2wtlib/wut/WUTHandler.java b/api/src/main/java/de/mari_023/ae2wtlib/api/terminal/WUTHandler.java similarity index 85% rename from src/main/java/de/mari_023/ae2wtlib/wut/WUTHandler.java rename to api/src/main/java/de/mari_023/ae2wtlib/api/terminal/WUTHandler.java index 8ec49096..a8900459 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wut/WUTHandler.java +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/terminal/WUTHandler.java @@ -1,4 +1,4 @@ -package de.mari_023.ae2wtlib.wut; +package de.mari_023.ae2wtlib.api.terminal; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.Nullable; @@ -6,15 +6,15 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.neoforged.neoforge.network.PacketDistributor; import appeng.integration.modules.curios.CuriosIntegration; import appeng.menu.locator.ItemMenuHostLocator; import appeng.menu.locator.MenuLocators; -import de.mari_023.ae2wtlib.AE2wtlibComponents; -import de.mari_023.ae2wtlib.TextConstants; -import de.mari_023.ae2wtlib.networking.UpdateWUTPackage; +import de.mari_023.ae2wtlib.api.AE2wtlibAPI; +import de.mari_023.ae2wtlib.api.AE2wtlibComponents; +import de.mari_023.ae2wtlib.api.TextConstants; +import de.mari_023.ae2wtlib.api.registration.WTDefinition; /** * This class handles functionalities related to the Wireless Universal Terminal (WUT). It provides methods to get and @@ -98,7 +98,7 @@ public static WTDefinition nextTerminal(ItemStack stack, boolean reverse) { * @param stack The compound tag containing terminal data. */ public static void updateClientTerminal(ServerPlayer player, ItemMenuHostLocator locator, ItemStack stack) { - PacketDistributor.sendToPlayer(player, new UpdateWUTPackage(locator, stack)); + AE2wtlibAPI.updateClientTerminal(player, locator, stack); } /** @@ -127,20 +127,35 @@ public static boolean open(final Player player, final ItemMenuHostLocator locato */ @Nullable public static ItemMenuHostLocator findTerminal(Player player, WTDefinition terminal) { + ItemMenuHostLocator locator = null; + var cap = player.getCapability(CuriosIntegration.ITEM_HANDLER); if (cap != null) { for (int i = 0; i < cap.getSlots(); i++) { - if (hasTerminal(cap.getStackInSlot(i), terminal)) { + var stack = cap.getStackInSlot(i); + if (!hasTerminal(stack, terminal)) + continue; + + if (AE2wtlibAPI.isUniversalTerminal(stack)) { return MenuLocators.forCurioSlot(i); + } else if (locator == null) { + locator = MenuLocators.forCurioSlot(i); } } } for (int i = 0; i < player.getInventory().getContainerSize(); i++) { - if (hasTerminal(player.getInventory().getItem(i), terminal)) + var stack = player.getInventory().getItem(i); + if (!hasTerminal(stack, terminal)) + continue; + + if (AE2wtlibAPI.isUniversalTerminal(stack)) { return MenuLocators.forInventorySlot(i); + } else if (locator == null) { + locator = MenuLocators.forInventorySlot(i); + } } - return null; + return locator; } /** diff --git a/api/src/main/java/de/mari_023/ae2wtlib/api/terminal/package-info.java b/api/src/main/java/de/mari_023/ae2wtlib/api/terminal/package-info.java new file mode 100644 index 00000000..3d5eaa61 --- /dev/null +++ b/api/src/main/java/de/mari_023/ae2wtlib/api/terminal/package-info.java @@ -0,0 +1,9 @@ +@FieldsAreNonnullByDefault +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +package de.mari_023.ae2wtlib.api.terminal; + +import javax.annotation.ParametersAreNonnullByDefault; + +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/api/src/main/resources/META-INF/accesstransformer.cfg b/api/src/main/resources/META-INF/accesstransformer.cfg new file mode 100644 index 00000000..1836e8d3 --- /dev/null +++ b/api/src/main/resources/META-INF/accesstransformer.cfg @@ -0,0 +1,3 @@ +public net.minecraft.world.entity.item.ItemEntity target +public-f net.minecraft.world.inventory.Slot x +public-f net.minecraft.world.inventory.Slot y \ No newline at end of file diff --git a/api/src/main/resources/META-INF/neoforge.mods.toml b/api/src/main/resources/META-INF/neoforge.mods.toml new file mode 100644 index 00000000..cd04198f --- /dev/null +++ b/api/src/main/resources/META-INF/neoforge.mods.toml @@ -0,0 +1,44 @@ +modLoader = "javafml" +loaderVersion = "[1,)" +issueTrackerURL = "https://github.com/Mari023/AE2WirelessTerminalLibrary/issues" +license = "MIT" + +[[mods]] +modId = "ae2wtlib_api" +version = "${version}" +displayName = "AE2WTLib API" +authors = "mari_023, Ridanisaurus" +description = ''' +API for adding wireless terminals with easy integration with AE2wtlib. +''' +logoFile = "icon.png" +logoBlur=false + +[[dependencies.ae2wtlib_api]] +modId = "neoforge" +type="REQUIRED" +versionRange = "*" +ordering = "NONE" +side = "BOTH" + +[[dependencies.ae2wtlib_api]] +modId = "minecraft" +type="REQUIRED" +versionRange = "*" +ordering = "NONE" +side = "BOTH" + +[[dependencies.ae2wtlib_api]] +modId = "ae2" +type="REQUIRED" +versionRange = "[${ae2_version},20.0.0)" +ordering = "AFTER" +side = "BOTH" + +[[dependencies.ae2wtlib]] +modId = "ae2wtlib" +type="INCOMPATIBLE" +versionRange = "(,19.1.0-alpha)" +ordering = "NONE" +side = "BOTH" +reason = "breaking changes in the ae2wtlib api" \ No newline at end of file diff --git a/api/src/main/resources/assets/ae2/screens/wtlib/schema.json b/api/src/main/resources/assets/ae2/screens/wtlib/schema.json new file mode 100644 index 00000000..e854fb22 --- /dev/null +++ b/api/src/main/resources/assets/ae2/screens/wtlib/schema.json @@ -0,0 +1,505 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "$id": "https://appliedenergistics.github.io/screen_style", + "type": "object", + "title": "AE2 Screen Style", + "description": "Provides styling information for an AE2 UI screen", + "required": [], + "definitions": { + "position": { + "$comment": "Used to position an element in relationship to the size of the current dialog", + "$id": "Position", + "type": "object", + "properties": { + "left": { + "type": "number", + "description": "Positions the content to the right (positive) or left (negative) of the left screen edge." + }, + "top": { + "type": "number", + "description": "Positions the content to the bottom (positive) or top (negative) of the top screen edge." + }, + "right": { + "type": "number", + "description": "Positions the content to the left (positive) or right (negative) of the right screen edge." + }, + "bottom": { + "type": "number", + "description": "Positions the content to the top (positive) or bottom (negative) of the bottom screen edge." + } + } + }, + "color": { + "$comment": "Definition of a color using a fake HTML notation", + "type": "string", + "pattern": "^#([0-9a-fA-F]{2}){3,4}$" + }, + "text": { + "$comment": "JSON schema definition of Minecraft text https://minecraft.fandom.com/wiki/Raw_JSON_text_format", + "type": "object", + "properties": { + "extra": { + "description": "Text that is displayed after this text, but that inherits this texts properties.", + "type": "array", + "items": { + "$ref": "#/definitions/text" + } + }, + "color": { + "type": "string", + "pattern": "^#([0-9a-fA-F]{6})$" + }, + "font": { + "type": "string", + "default": "minecraft:default", + "description": "Font in assets//font" + }, + "bold": { + "type": "boolean", + "default": false + }, + "italic": { + "type": "boolean", + "default": false + }, + "underlined": { + "type": "boolean", + "default": false + }, + "strikethrough": { + "type": "boolean", + "default": false + }, + "obfuscated": { + "type": "boolean", + "default": false + }, + "insertion": { + "type": "string", + "description": "When shift-clicked while the chat is open, the text of this property will be inserted." + }, + "clickEvent": { + "type": "object", + "properties": { + "action": { + "type": "string", + "enum": [ + "open_url", + "open_file", + "run_command", + "suggest_command", + "change_page", + "copy_to_clipboard" + ] + }, + "value": { + "type": "string" + } + }, + "required": ["action", "value"] + }, + "hoverEvent": { + "type": "object", + "oneOf": [ + { + "properties": { + "action": { + "const": "show_text" + }, + "contents": { + "$ref": "#/definitions/text" + } + } + }, + { + "properties": { + "action": { + "const": "show_item" + }, + "contents": { + "type": "object", + "properties": { + "id": { + "type": "string", + "default": "minecraft:air", + "description": "The item to show" + }, + "count": { + "type": "integer", + "default": 1, + "description": "The item stack size" + }, + "tag": { + "type": "string", + "description": "NBT of the item, serialized as string. See https://minecraft.fandom.com/wiki/Player.dat_format#Item_structure" + } + }, + "required": ["id"] + } + } + }, + { + "properties": { + "action": { + "const": "show_entity" + }, + "contents": { + "type": "object", + "properties": { + "name": { + "$ref": "#/definitions/text" + }, + "type": { + "type": "string", + "default": "minecraft:pig", + "description": "The entity type id to show" + }, + "id": { + "type": "string", + "description": "UUID of the entity to show" + } + } + } + } + } + ] + } + }, + "oneOf": [ + { + "properties": { + "text": { + "description": "Display simple text", + "type": "string" + } + }, + "required": ["text"] + }, + { + "properties": { + "translate": { + "description": "The ID of a translation key", + "type": "string" + }, + "with": { + "type": "array", + "items": { + "$ref": "#/definitions/text" + } + } + }, + "required": ["translate"] + }, + { + "properties": { + "keybind": { + "type": "string", + "description": "A keybind identifier" + } + }, + "required": ["keybind"] + } + ] + }, + "rect": { + "oneOf": [ + { + "type": "array", + "items": [ + { + "type": "integer", + "description": "x" + }, + { + "type": "integer", + "description": "y" + }, + { + "type": "integer", + "description": "width" + }, + { + "type": "integer", + "description": "height" + } + ], + "additionalItems": false + }, + { + "type": "object", + "properties": { + "x": { + "type": "integer" + }, + "y": { + "type": "integer" + }, + "width": { + "type": "integer" + }, + "height": { + "type": "integer" + } + }, + "additionalProperties": false + } + ] + }, + "blitter": { + "type": "object", + "properties": { + "texture": { + "type": "string" + }, + "textureWidth": { + "type": "integer", + "default": 256 + }, + "textureHeight": { + "type": "integer", + "default": 256 + }, + "srcRect": { + "$ref": "#/definitions/rect" + } + }, + "required": ["texture"] + } + }, + "properties": { + "includes": { + "description": "Relative path to other files to include before processing this one.", + "type": "array", + "items": { + "type": "string" + } + }, + "palette": { + "$comment": "See PaletteColor enum", + "type": "object", + "description": "Defines colors used through the UI screen", + "properties": { + "TEXT_HEADLINE": { + "$ref": "#/definitions/color" + } + } + }, + "background": { + "$ref": "#/definitions/blitter" + }, + "slots": { + "type": "object", + "description": "Defines positions for slots and their grid alignment", + "additionalProperties": { + "type": "object", + "allOf": [ + { + "properties": { + "grid": { + "$comment": "Configures the slots with this semantic in a grid", + "enum": [ + "IO_BUS_CONFIG", + "BREAK_AFTER_9COLS", + "BREAK_AFTER_2COLS", + "BREAK_AFTER_3COLS", + "HORIZONTAL", + "VERTICAL" + ] + } + } + }, + { + "$ref": "#/definitions/position" + } + ] + }, + "propertyNames": { + "$comment": "List SlotSemantic names here", + "enum": [ + "NONE", + "STORAGE", + "PLAYER_INVENTORY", + "PLAYER_HOTBAR", + "TOOLBOX", + "CONFIG", + "UPGRADE", + "STORAGE_CELL", + "INSCRIBER_PLATE_TOP", + "INSCRIBER_PLATE_BOTTOM", + "MACHINE_INPUT", + "MACHINE_PROCESSING", + "MACHINE_OUTPUT", + "MACHINE_CRAFTING_GRID", + "BLANK_PATTERN", + "ENCODED_PATTERN", + "VIEW_CELL", + "CRAFTING_GRID", + "CRAFTING_RESULT", + "PROCESSING_PRIMARY_RESULT", + "PROCESSING_FIRST_OPTIONAL_RESULT", + "PROCESSING_SECOND_OPTIONAL_RESULT", + "BIOMETRIC_CARD", + "READONLY_STACKS", + "AE2WTLIB_HELMET", + "AE2WTLIB_CHESTPLATE", + "AE2WTLIB_LEGGINGS", + "AE2WTLIB_BOOTS", + "AE2WTLIB_OFFHAND", + "AE2WTLIB_TRASH", + "AE2WTLIB_MAGNET_CARD", + "AE2WTLIB_INFINITY_BOOSTER_CARD", + "AE2WTLIB_PICKUP_CONFIG", + "AE2WTLIB_INSERT_CONFIG", + "AE2WTLIB_SINGULARITY" + ] + } + }, + "text": { + "description": "Defines text that will be shown on the UI, the property name is used to reference text from code", + "type": "object", + "additionalProperties": { + "type": "object", + "properties": { + "text": { + "$ref": "#/definitions/text" + }, + "color": { + "$comment": "See enum PaletteColor", + "enum": ["DEFAULT_TEXT_COLOR"], + "default": "DEFAULT_TEXT_COLOR" + }, + "position": { + "$ref": "#/definitions/position" + }, + "centerHorizontally": { + "type": "boolean", + "default": false + } + } + } + }, + "tooltips": { + "description": "Defines areas that will show a tooltip on the screen. These areas are evaluated after everything else that could show a tooltip.", + "type": "object", + "additionalProperties": { + "allOf": [ + { + "type": "object", + "properties": { + "tooltip": { + "type": "array", + "items": { + "$ref": "#/definitions/text" + } + }, + "width": { + "type": "integer" + }, + "height": { + "type": "integer" + } + }, + "required": ["tooltip", "width", "height"] + }, + { + "$ref": "#/definitions/position" + } + ] + } + }, + "images": { + "description": "Additional screen-specific images", + "additionalProperties": { + "$ref": "#/definitions/blitter" + } + }, + "terminalStyle": { + "description": "If this screen is a terminal, this defines required properties to display it properly", + "type": "object", + "additionalProperties": false, + "properties": { + "header": { + "description": "The top of the terminal background right up to the first row of content.", + "$ref": "#/definitions/blitter" + }, + "firstRow": { + "description": "The area to draw for the first row in the terminal. Usually this includes the top of the scrollbar.", + "$ref": "#/definitions/blitter" + }, + "row": { + "description": "The area to repeat for every row in the terminal. Should be 16px for the item + 2px for the border in size.", + "$ref": "#/definitions/blitter" + }, + "lastRow": { + "description": "The area to draw for the last row in the terminal. Usually this includes the top of the scrollbar.", + "$ref": "#/definitions/blitter" + }, + "bottom": { + "description": "The area to draw at the bottom of the terminal (i.e. includes the player inventory).", + "$ref": "#/definitions/blitter" + }, + "maxRows": { + "description": "If specified, limits the terminal to at most this many rows rather than using up available space.", + "type": "integer", + "minimum": 3 + }, + "slotsPerRow": { + "description": "The number of slots per row on the background image.", + "type": "integer", + "minimum": 1 + }, + "searchFieldRect": { + "description": "The bounding box of the search field in the background.", + "$ref": "#/definitions/rect" + }, + "sortable": { + "description": "Defines if this terminal has a sort by button.", + "type": "boolean", + "default": true + }, + "supportsAutoCrafting": { + "description": "Defines if this terminal supports auto-crafting. If not, the button to show only craftable items is hidden.", + "type": "boolean", + "default": false + }, + "stackSizeStyle": { + "description": "The type of stack size rendering to use.", + "type": "string", + "default": "ITEMS", + "enum": ["ITEMS", "FLUIDS"] + }, + "showTooltipsWithItemInHand": { + "type": "boolean", + "default": false, + "description": "Should the terminal show item tooltips for the network inventory even if the player has an item in their hand? Useful for showing fluid tooltips when the player has a bucket in hand." + } + } + }, + "widgets": { + "description": "Defines properties of various widgets that are positioned on the screen. The properties are widget-dependant. Which widget is placed is decided in code.", + "type": "object", + "additionalProperties": { + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/position" + }, + { + "properties": { + "width": { + "type": "integer" + }, + "height": { + "type": "integer" + }, + "hideEdge": { + "description": "Used to hide the border around TabButtons", + "type": "boolean" + } + } + } + ] + } + } + } +} diff --git a/src/main/resources/assets/ae2/screens/wtlib/universal_terminal.json b/api/src/main/resources/assets/ae2/screens/wtlib/universal_terminal.json similarity index 100% rename from src/main/resources/assets/ae2/screens/wtlib/universal_terminal.json rename to api/src/main/resources/assets/ae2/screens/wtlib/universal_terminal.json diff --git a/api/src/main/resources/assets/ae2/textures/wtlib/guis/icons.png b/api/src/main/resources/assets/ae2/textures/wtlib/guis/icons.png new file mode 100644 index 00000000..ef120904 Binary files /dev/null and b/api/src/main/resources/assets/ae2/textures/wtlib/guis/icons.png differ diff --git a/api/src/main/resources/assets/ae2wtlib_api/lang/de_de.json b/api/src/main/resources/assets/ae2wtlib_api/lang/de_de.json new file mode 100644 index 00000000..a9a3f331 --- /dev/null +++ b/api/src/main/resources/assets/ae2wtlib_api/lang/de_de.json @@ -0,0 +1,7 @@ +{ + "chat.ae2wtlib.NetworkNotPowered" : "Netzwerk hat keine Energie", + "chat.ae2wtlib.SingularityNotPresent" : "Singularität fehlt", + "chat.ae2wtlib.NoQuantumBridgeCard" : "Quantenbrückenkarte fehlt", + "chat.ae2wtlib.NoQuantumBridge" : "Quantenbrücke nicht gefunden. Ist sie in geladenen chunks?", + "chat.ae2wtlib.NetworkMismatch": "Quantenbrücke und Drahtloser Zugangspunkt sind mit verschiedenen Netzwerken verbunden" +} diff --git a/api/src/main/resources/assets/ae2wtlib_api/lang/en_ud.json b/api/src/main/resources/assets/ae2wtlib_api/lang/en_ud.json new file mode 100644 index 00000000..3d500c12 --- /dev/null +++ b/api/src/main/resources/assets/ae2wtlib_api/lang/en_ud.json @@ -0,0 +1,7 @@ +{ + "chat.ae2wtlib.NetworkNotPowered" : "pǝɹǝʍoԀ ʇoN ʞɹoʍʇǝN", + "chat.ae2wtlib.SingularityNotPresent" : "ʎʇᴉɹɐlnƃuᴉS ƃuᴉssᴉW", + "chat.ae2wtlib.NoQuantumBridgeCard" : "pɹɐƆ ǝƃpᴉɹq ɯnʇuɐnꝹ ƃuᴉssᴉW", + "chat.ae2wtlib.NoQuantumBridge" : "¿sʞunɥɔ pǝpɐol uᴉ ʇᴉ sI .punoɟ ʇou ǝƃpᴉɹq ʞɹoʍʇǝN ɯnʇuɐnꝹ", + "chat.ae2wtlib.NetworkMismatch": "sʞɹoʍʇǝN ʇuǝɹǝɟɟᴉp oʇ pǝʇɔǝuuoɔ ǝɹɐ ʇuᴉoԀ ssǝɔɔ∀ ssǝlǝɹᴉM puɐ ǝƃpᴉɹq ɯnʇuɐnꝹ" +} diff --git a/api/src/main/resources/assets/ae2wtlib_api/lang/en_us.json b/api/src/main/resources/assets/ae2wtlib_api/lang/en_us.json new file mode 100644 index 00000000..b8c71e7d --- /dev/null +++ b/api/src/main/resources/assets/ae2wtlib_api/lang/en_us.json @@ -0,0 +1,7 @@ +{ + "chat.ae2wtlib.NetworkNotPowered" : "Network Not Powered", + "chat.ae2wtlib.SingularityNotPresent" : "Missing Singularity", + "chat.ae2wtlib.NoQuantumBridgeCard" : "Missing Quantum Bridge Card", + "chat.ae2wtlib.NoQuantumBridge" : "Quantum Network Bridge not found. Is it in loaded chunks?", + "chat.ae2wtlib.NetworkMismatch": "Quantum Bridge and Wireless Access Point are connected to Different Networks" +} diff --git a/api/src/main/resources/icon.png b/api/src/main/resources/icon.png new file mode 100644 index 00000000..c0d91d7e Binary files /dev/null and b/api/src/main/resources/icon.png differ diff --git a/build.gradle.kts b/build.gradle.kts index d35f0a50..0d2fa45f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,6 @@ plugins { idea } -val clothVersion: String by project val ae2Version: String by project val architecturyVersion: String by project val runtimeItemlistMod: String by project @@ -39,6 +38,8 @@ java.toolchain.languageVersion = JavaLanguageVersion.of(21) dependencies { //implementation("top.theillusivec4.curios:curios-neoforge:${curiosVersion}") implementation("appeng:appliedenergistics2:${ae2Version}") + jarJar(project(path = ":api")) + api(project(path = ":api")) compileOnly("me.shedaniel:RoughlyEnoughItems-neoforge:${reiVersion}") compileOnly("mezz.jei:jei-${jeiMinecraftVersion}-neoforge:${jeiVersion}") @@ -62,53 +63,48 @@ dependencies { } } - implementation("com.google.code.findbugs:jsr305:3.0.2") + compileOnly("com.google.code.findbugs:jsr305:3.0.2") //testing //runtimeOnly(fg.deobf("maven.modrinth:aeinfinitybooster:1.20.1-1.0.0+20")) } -repositories { - mavenLocal() - mavenCentral() - maven { - url = uri("https://prmaven.neoforged.net/NeoForge/pr1199") - content { - includeModule("net.neoforged", "testframework") - includeModule("net.neoforged", "neoforge") +allprojects { + repositories { + mavenLocal() + mavenCentral() + maven { + url = uri("https://modmaven.dev/") + content { + includeGroup("appeng") + includeGroup("mezz.jei") + } } - } - maven { - url = uri("https://modmaven.dev/") - content { - includeGroup("appeng") - includeGroup("mezz.jei") - } - } - maven { - url = uri("https://maven.shedaniel.me/") - content { - includeGroup("me.shedaniel") - includeGroup("me.shedaniel.cloth") - includeGroup("dev.architectury") + maven { + url = uri("https://maven.shedaniel.me/") + content { + includeGroup("me.shedaniel") + includeGroup("me.shedaniel.cloth") + includeGroup("dev.architectury") + } } - } - maven { - url = uri("https://maven.terraformersmc.com/") - content { - includeGroup("dev.emi") + maven { + url = uri("https://maven.terraformersmc.com/") + content { + includeGroup("dev.emi") + } } - } - maven { - url = uri("https://maven.theillusivec4.top/") - content { - includeGroup("top.theillusivec4.curios") + maven { + url = uri("https://maven.theillusivec4.top/") + content { + includeGroup("top.theillusivec4.curios") + } } - } - maven { - url = uri("https://api.modrinth.com/maven") - content { - includeGroup("maven.modrinth") + maven { + url = uri("https://api.modrinth.com/maven") + content { + includeGroup("maven.modrinth") + } } } } @@ -165,6 +161,16 @@ publishing { from(components["java"]) } } + repositories { + maven { + credentials { + username = System.getenv("MODMAVEN_USER") + password = System.getenv("MODMAVEN_PASSWORD") + } + name = "modmaven" + url = uri("https://modmaven.dev/artifactory/local-releases/") + } + } } spotless { diff --git a/gradle.properties b/gradle.properties index 7c7f3863..9b3d089b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -neoforgeVersion=21.0.126-beta-pr-1199-ui +neoforgeVersion=21.0.139-beta neoForge.parchment.minecraftVersion=1.21 neoForge.parchment.mappingsVersion=2024.06.23 @@ -6,13 +6,13 @@ neoForge.parchment.mappingsVersion=2024.06.23 mavenGroup=de.mari_023 modID=ae2wtlib -ae2Version=19.0.10-alpha +ae2Version=19.0.16-beta curiosVersion=8.0.0-beta.4+1.20.6 -reiVersion=16.0.729 -architecturyVersion=13.0.4 +reiVersion=16.0.744 +architecturyVersion=13.0.6 jeiMinecraftVersion=1.21 -jeiVersion=19.0.0.3 +jeiVersion=19.5.2.66 emiVersion=1.1.10 emiMinecraftVersion=1.21 diff --git a/gradlew b/gradlew index 1aa94a42..b740cf13 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. diff --git a/settings.gradle.kts b/settings.gradle.kts index 2e893a5e..18bfd94f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1 +1,2 @@ rootProject.name = "ae2wtlib" +include("api") diff --git a/src/main/java/de/mari_023/ae2wtlib/AE2wtlib.java b/src/main/java/de/mari_023/ae2wtlib/AE2wtlib.java index 9aad4ad2..c95d6a0e 100644 --- a/src/main/java/de/mari_023/ae2wtlib/AE2wtlib.java +++ b/src/main/java/de/mari_023/ae2wtlib/AE2wtlib.java @@ -2,20 +2,24 @@ import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; import net.neoforged.neoforge.attachment.AttachmentType; import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent; import net.neoforged.neoforge.registries.DeferredRegister; import net.neoforged.neoforge.registries.NeoForgeRegistries; import appeng.api.features.HotkeyAction; +import appeng.api.upgrades.Upgrades; import appeng.core.definitions.AEItems; import appeng.hotkeys.HotkeyActions; import appeng.init.client.InitScreens; +import de.mari_023.ae2wtlib.api.AE2wtlibAPI; +import de.mari_023.ae2wtlib.api.gui.Icon; +import de.mari_023.ae2wtlib.api.registration.AddTerminalEvent; +import de.mari_023.ae2wtlib.api.registration.UpgradeHelper; +import de.mari_023.ae2wtlib.api.registration.WTDefinition; import de.mari_023.ae2wtlib.hotkeys.MagnetHotkeyAction; import de.mari_023.ae2wtlib.hotkeys.RestockHotkeyAction; -import de.mari_023.ae2wtlib.terminal.Icon; import de.mari_023.ae2wtlib.wat.WATMenu; import de.mari_023.ae2wtlib.wat.WATMenuHost; import de.mari_023.ae2wtlib.wat.WATScreen; @@ -25,16 +29,14 @@ import de.mari_023.ae2wtlib.wet.WETMenu; import de.mari_023.ae2wtlib.wet.WETMenuHost; import de.mari_023.ae2wtlib.wet.WETScreen; -import de.mari_023.ae2wtlib.wut.AddTerminalEvent; import de.mari_023.ae2wtlib.wut.recipe.Combine; import de.mari_023.ae2wtlib.wut.recipe.CombineSerializer; import de.mari_023.ae2wtlib.wut.recipe.Upgrade; import de.mari_023.ae2wtlib.wut.recipe.UpgradeSerializer; public class AE2wtlib { - public static final String MOD_NAME = "ae2wtlib"; public static final DeferredRegister> ATTACHMENT_TYPES = DeferredRegister - .create(NeoForgeRegistries.ATTACHMENT_TYPES, MOD_NAME); + .create(NeoForgeRegistries.ATTACHMENT_TYPES, AE2wtlibAPI.MOD_NAME); public static void onAe2Initialized() { AddTerminalEvent.register((event -> { @@ -50,23 +52,24 @@ public static void onAe2Initialized() { .addTerminal(); })); - AddTerminalEvent.run(); + UpgradeHelper.addUpgradeToAllTerminals(AE2wtlibItems.QUANTUM_BRIDGE_CARD, 1); + Upgrades.add(AE2wtlibItems.MAGNET_CARD, AEItems.WIRELESS_CRAFTING_TERMINAL, 1); + Upgrades.add(AE2wtlibItems.MAGNET_CARD, AE2wtlibItems.UNIVERSAL_TERMINAL, 1); - Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, id(UpgradeSerializer.NAME), Upgrade.serializer); - Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, id(CombineSerializer.NAME), Combine.serializer); + Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, AE2wtlibAPI.id(UpgradeSerializer.NAME), + Upgrade.serializer); + Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, AE2wtlibAPI.id(CombineSerializer.NAME), + Combine.serializer); HotkeyActions.register(new RestockHotkeyAction(), "ae2wtlib_restock"); HotkeyActions.register(new MagnetHotkeyAction(), "ae2wtlib_magnet"); - - UpgradeHelper.addUpgrades(); } static void addToCreativeTab() { if (AE2wtlibCreativeTab.registrationHappened()) return; - AE2wtlibCreativeTab.addTerminal(AEItems.WIRELESS_CRAFTING_TERMINAL.asItem()); - AE2wtlibCreativeTab.addTerminal(AE2wtlibItems.PATTERN_ENCODING_TERMINAL); - AE2wtlibCreativeTab.addTerminal(AE2wtlibItems.PATTERN_ACCESS_TERMINAL); + for (var t : WTDefinition.wirelessTerminals()) + AE2wtlibCreativeTab.addTerminal(t.item()); AE2wtlibCreativeTab.addUniversalTerminal(AE2wtlibItems.UNIVERSAL_TERMINAL); AE2wtlibCreativeTab.add(AE2wtlibItems.QUANTUM_BRIDGE_CARD); AE2wtlibCreativeTab.add(AE2wtlibItems.MAGNET_CARD); @@ -93,8 +96,4 @@ public static void registerScreens(RegisterMenuScreensEvent event) { InitScreens.register(event, MagnetMenu.TYPE, MagnetScreen::new, "/screens/wtlib/magnet.json"); InitScreens.register(event, TrashMenu.TYPE, TrashScreen::new, "/screens/wtlib/trash.json"); } - - public static ResourceLocation id(String name) { - return ResourceLocation.fromNamespaceAndPath(MOD_NAME, name); - } } diff --git a/src/main/java/de/mari_023/ae2wtlib/AE2wtlibAPIImplementation.java b/src/main/java/de/mari_023/ae2wtlib/AE2wtlibAPIImplementation.java new file mode 100644 index 00000000..6e190736 --- /dev/null +++ b/src/main/java/de/mari_023/ae2wtlib/AE2wtlibAPIImplementation.java @@ -0,0 +1,42 @@ +package de.mari_023.ae2wtlib; + +import java.util.function.Supplier; + +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.neoforged.neoforge.network.PacketDistributor; + +import appeng.api.upgrades.IUpgradeInventory; +import appeng.menu.locator.ItemMenuHostLocator; + +import de.mari_023.ae2wtlib.api.AE2wtlibAPIImpl; +import de.mari_023.ae2wtlib.networking.CycleTerminalPacket; +import de.mari_023.ae2wtlib.networking.UpdateWUTPackage; + +public class AE2wtlibAPIImplementation extends AE2wtlibAPIImpl { + @Override + public boolean hasQuantumBridgeCard(Supplier upgrades) { + return upgrades.get().isInstalled(AE2wtlibItems.QUANTUM_BRIDGE_CARD); + } + + @Override + public boolean isUniversalTerminal(Item item) { + return item == AE2wtlibItems.UNIVERSAL_TERMINAL; + } + + @Override + public void cycleTerminal(boolean isHandlingRightClick) { + PacketDistributor.sendToServer(new CycleTerminalPacket(isHandlingRightClick)); + } + + @Override + public void updateClientTerminal(ServerPlayer player, ItemMenuHostLocator locator, ItemStack stack) { + PacketDistributor.sendToPlayer(player, new UpdateWUTPackage(locator, stack)); + } + + @Override + public Item getWUT() { + return AE2wtlibItems.UNIVERSAL_TERMINAL; + } +} diff --git a/src/main/java/de/mari_023/ae2wtlib/AE2wtlibAdditionalComponents.java b/src/main/java/de/mari_023/ae2wtlib/AE2wtlibAdditionalComponents.java new file mode 100644 index 00000000..bcd0d3d6 --- /dev/null +++ b/src/main/java/de/mari_023/ae2wtlib/AE2wtlibAdditionalComponents.java @@ -0,0 +1,28 @@ +package de.mari_023.ae2wtlib; + +import java.util.function.Supplier; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.DataResult; + +import net.minecraft.core.component.DataComponentType; +import net.minecraft.world.entity.player.Player; +import net.neoforged.neoforge.attachment.AttachmentType; +import net.neoforged.neoforge.network.codec.NeoForgeStreamCodecs; + +import de.mari_023.ae2wtlib.api.AE2wtlibComponents; +import de.mari_023.ae2wtlib.wct.CraftingTerminalHandler; +import de.mari_023.ae2wtlib.wct.magnet_card.MagnetMode; + +public class AE2wtlibAdditionalComponents { + public static final DataComponentType MAGNET_SETTINGS = AE2wtlibComponents.register("magnet_settings", + builder -> builder.persistent(Codec.BYTE.comapFlatMap(b -> DataResult.success(MagnetMode.fromByte(b)), + MagnetMode::getId)) + .networkSynchronized(NeoForgeStreamCodecs.enumCodec(MagnetMode.class))); + + public static final Supplier> CT_HANDLER = AE2wtlib.ATTACHMENT_TYPES + .register("ct_handler", + () -> AttachmentType.builder((player) -> new CraftingTerminalHandler((Player) player)).build()); + + public static void init() {} +} diff --git a/src/main/java/de/mari_023/ae2wtlib/AE2wtlibCreativeTab.java b/src/main/java/de/mari_023/ae2wtlib/AE2wtlibCreativeTab.java index 0dc35380..d80a83bf 100644 --- a/src/main/java/de/mari_023/ae2wtlib/AE2wtlibCreativeTab.java +++ b/src/main/java/de/mari_023/ae2wtlib/AE2wtlibCreativeTab.java @@ -12,8 +12,10 @@ import appeng.api.config.Actionable; import appeng.items.tools.powered.WirelessTerminalItem; -import de.mari_023.ae2wtlib.wut.ItemWUT; -import de.mari_023.ae2wtlib.wut.WTDefinition; +import de.mari_023.ae2wtlib.api.AE2wtlibAPI; +import de.mari_023.ae2wtlib.api.TextConstants; +import de.mari_023.ae2wtlib.api.registration.WTDefinition; +import de.mari_023.ae2wtlib.api.terminal.ItemWUT; import de.mari_023.ae2wtlib.wut.recipe.Common; public class AE2wtlibCreativeTab { @@ -30,7 +32,7 @@ public static void init() { }) .displayItems(AE2wtlibCreativeTab::buildDisplayItems) .build(); - Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, AE2wtlib.id("main"), tab); + Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, AE2wtlibAPI.id("main"), tab); } public static boolean registrationHappened() { diff --git a/src/main/java/de/mari_023/ae2wtlib/AE2wtlibEvents.java b/src/main/java/de/mari_023/ae2wtlib/AE2wtlibEvents.java index a0713407..7cdac35a 100644 --- a/src/main/java/de/mari_023/ae2wtlib/AE2wtlibEvents.java +++ b/src/main/java/de/mari_023/ae2wtlib/AE2wtlibEvents.java @@ -15,6 +15,7 @@ import appeng.api.stacks.AEItemKey; import appeng.me.helpers.PlayerSource; +import de.mari_023.ae2wtlib.api.AE2wtlibComponents; import de.mari_023.ae2wtlib.networking.UpdateRestockPacket; import de.mari_023.ae2wtlib.wct.CraftingTerminalHandler; import de.mari_023.ae2wtlib.wct.magnet_card.MagnetHandler; diff --git a/src/main/java/de/mari_023/ae2wtlib/AE2wtlibForge.java b/src/main/java/de/mari_023/ae2wtlib/AE2wtlibForge.java index c9216d3b..15436253 100644 --- a/src/main/java/de/mari_023/ae2wtlib/AE2wtlibForge.java +++ b/src/main/java/de/mari_023/ae2wtlib/AE2wtlibForge.java @@ -1,7 +1,5 @@ package de.mari_023.ae2wtlib; -import net.minecraft.core.Registry; -import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; @@ -11,7 +9,7 @@ import net.neoforged.bus.api.EventPriority; import net.neoforged.bus.api.IEventBus; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.ModLoadingContext; +import net.neoforged.fml.ModContainer; import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.fml.common.Mod; import net.neoforged.fml.config.ModConfig; @@ -30,34 +28,33 @@ import appeng.items.tools.powered.powersink.PoweredItemCapabilities; +import de.mari_023.ae2wtlib.api.AE2wtlibAPI; +import de.mari_023.ae2wtlib.api.terminal.ItemWT; import de.mari_023.ae2wtlib.networking.AE2wtlibPacket; import de.mari_023.ae2wtlib.networking.CycleTerminalPacket; import de.mari_023.ae2wtlib.networking.RestockAmountPacket; import de.mari_023.ae2wtlib.networking.UpdateRestockPacket; import de.mari_023.ae2wtlib.networking.UpdateWUTPackage; -import de.mari_023.ae2wtlib.terminal.ItemWT; -@Mod(AE2wtlib.MOD_NAME) +@Mod(AE2wtlibAPI.MOD_NAME) @EventBusSubscriber public class AE2wtlibForge { - public AE2wtlibForge(IEventBus modEventBus) { + public AE2wtlibForge(IEventBus modEventBus, ModContainer modContainer) { + new AE2wtlibAPIImplementation(); CommonHooks.markComponentClassAsValid(ItemStack.class);// TODO figure out if there is a better way AE2wtlib.registerMenus(); - ModLoadingContext.get().getActiveContainer().registerConfig(ModConfig.Type.COMMON, AE2wtlibConfig.SPEC, - AE2wtlib.MOD_NAME + ".toml"); + modContainer.registerConfig(ModConfig.Type.COMMON, AE2wtlibConfig.SPEC, + AE2wtlibAPI.MOD_NAME + ".toml"); modEventBus.addListener((RegisterEvent e) -> { if (!e.getRegistryKey().equals(Registries.ITEM)) return; AE2wtlibItems.init(); AE2wtlib.onAe2Initialized(); AE2wtlibCreativeTab.init(); - - for (var entry : AE2wtlibComponents.DR.entrySet()) - Registry.register(BuiltInRegistries.DATA_COMPONENT_TYPE, entry.getKey(), entry.getValue()); }); modEventBus.addListener((BuildCreativeModeTabContentsEvent e) -> AE2wtlib.addToCreativeTab()); modEventBus.addListener((RegisterPayloadHandlersEvent event) -> { - PayloadRegistrar registrar = event.registrar(AE2wtlib.MOD_NAME); + PayloadRegistrar registrar = event.registrar(AE2wtlibAPI.MOD_NAME); registerPacket(registrar, CycleTerminalPacket.ID, CycleTerminalPacket.STREAM_CODEC); registerPacket(registrar, UpdateWUTPackage.ID, UpdateWUTPackage.STREAM_CODEC); registerPacket(registrar, UpdateRestockPacket.ID, UpdateRestockPacket.STREAM_CODEC); @@ -69,6 +66,7 @@ public AE2wtlibForge(IEventBus modEventBus) { registerPowerStorageItem(event, AE2wtlibItems.PATTERN_ACCESS_TERMINAL); registerPowerStorageItem(event, AE2wtlibItems.PATTERN_ENCODING_TERMINAL); }); + AE2wtlibAdditionalComponents.init(); AE2wtlib.ATTACHMENT_TYPES.register(modEventBus); } diff --git a/src/main/java/de/mari_023/ae2wtlib/AE2wtlibItems.java b/src/main/java/de/mari_023/ae2wtlib/AE2wtlibItems.java index 895c9507..de36a8b6 100644 --- a/src/main/java/de/mari_023/ae2wtlib/AE2wtlibItems.java +++ b/src/main/java/de/mari_023/ae2wtlib/AE2wtlibItems.java @@ -1,6 +1,6 @@ package de.mari_023.ae2wtlib; -import static de.mari_023.ae2wtlib.AE2wtlib.id; +import static de.mari_023.ae2wtlib.api.AE2wtlibAPI.id; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; @@ -11,10 +11,10 @@ import appeng.core.definitions.AEItems; import appeng.items.tools.powered.WirelessTerminalItem; +import de.mari_023.ae2wtlib.api.terminal.ItemWUT; import de.mari_023.ae2wtlib.wat.ItemWAT; import de.mari_023.ae2wtlib.wct.ItemWCT; import de.mari_023.ae2wtlib.wet.ItemWET; -import de.mari_023.ae2wtlib.wut.ItemWUT; public final class AE2wtlibItems { private AE2wtlibItems() {} diff --git a/src/main/java/de/mari_023/ae2wtlib/AE2wtlibTestPlots.java b/src/main/java/de/mari_023/ae2wtlib/AE2wtlibTestPlots.java index 3601c8a9..07e8972d 100644 --- a/src/main/java/de/mari_023/ae2wtlib/AE2wtlibTestPlots.java +++ b/src/main/java/de/mari_023/ae2wtlib/AE2wtlibTestPlots.java @@ -17,7 +17,7 @@ import appeng.server.testplots.TestPlotClass; import appeng.server.testworld.PlotBuilder; -import de.mari_023.ae2wtlib.wut.WTDefinition; +import de.mari_023.ae2wtlib.api.registration.WTDefinition; import de.mari_023.ae2wtlib.wut.recipe.Common; @TestPlotClass diff --git a/src/main/java/de/mari_023/ae2wtlib/hotkeys/MagnetHotkeyAction.java b/src/main/java/de/mari_023/ae2wtlib/hotkeys/MagnetHotkeyAction.java index 2feec557..d6965e12 100644 --- a/src/main/java/de/mari_023/ae2wtlib/hotkeys/MagnetHotkeyAction.java +++ b/src/main/java/de/mari_023/ae2wtlib/hotkeys/MagnetHotkeyAction.java @@ -5,7 +5,7 @@ import appeng.api.features.HotkeyAction; -import de.mari_023.ae2wtlib.TextConstants; +import de.mari_023.ae2wtlib.api.TextConstants; import de.mari_023.ae2wtlib.wct.CraftingTerminalHandler; import de.mari_023.ae2wtlib.wct.magnet_card.MagnetHandler; import de.mari_023.ae2wtlib.wct.magnet_card.MagnetMode; diff --git a/src/main/java/de/mari_023/ae2wtlib/hotkeys/RestockHotkeyAction.java b/src/main/java/de/mari_023/ae2wtlib/hotkeys/RestockHotkeyAction.java index 878ec0e1..1b50e872 100644 --- a/src/main/java/de/mari_023/ae2wtlib/hotkeys/RestockHotkeyAction.java +++ b/src/main/java/de/mari_023/ae2wtlib/hotkeys/RestockHotkeyAction.java @@ -7,11 +7,11 @@ import appeng.api.features.HotkeyAction; import appeng.menu.locator.ItemMenuHostLocator; -import de.mari_023.ae2wtlib.AE2wtlibComponents; -import de.mari_023.ae2wtlib.TextConstants; -import de.mari_023.ae2wtlib.terminal.ItemWT; +import de.mari_023.ae2wtlib.api.AE2wtlibComponents; +import de.mari_023.ae2wtlib.api.TextConstants; +import de.mari_023.ae2wtlib.api.terminal.ItemWT; +import de.mari_023.ae2wtlib.api.terminal.WUTHandler; import de.mari_023.ae2wtlib.wct.CraftingTerminalHandler; -import de.mari_023.ae2wtlib.wut.WUTHandler; public class RestockHotkeyAction implements HotkeyAction { @Override diff --git a/src/main/java/de/mari_023/ae2wtlib/mixin/RestockRender.java b/src/main/java/de/mari_023/ae2wtlib/mixin/RestockRender.java index 047cd074..a0fcc06c 100644 --- a/src/main/java/de/mari_023/ae2wtlib/mixin/RestockRender.java +++ b/src/main/java/de/mari_023/ae2wtlib/mixin/RestockRender.java @@ -15,7 +15,7 @@ import appeng.util.ReadableNumberConverter; -import de.mari_023.ae2wtlib.AE2wtlibComponents; +import de.mari_023.ae2wtlib.api.AE2wtlibComponents; import de.mari_023.ae2wtlib.wct.CraftingTerminalHandler; @Mixin(value = GuiGraphics.class, remap = false) diff --git a/src/main/java/de/mari_023/ae2wtlib/networking/CycleTerminalPacket.java b/src/main/java/de/mari_023/ae2wtlib/networking/CycleTerminalPacket.java index b9a83018..114e516a 100644 --- a/src/main/java/de/mari_023/ae2wtlib/networking/CycleTerminalPacket.java +++ b/src/main/java/de/mari_023/ae2wtlib/networking/CycleTerminalPacket.java @@ -12,12 +12,12 @@ import appeng.menu.AEBaseMenu; import appeng.menu.locator.ItemMenuHostLocator; -import de.mari_023.ae2wtlib.AE2wtlib; -import de.mari_023.ae2wtlib.wut.ItemWUT; -import de.mari_023.ae2wtlib.wut.WUTHandler; +import de.mari_023.ae2wtlib.api.AE2wtlibAPI; +import de.mari_023.ae2wtlib.api.terminal.ItemWUT; +import de.mari_023.ae2wtlib.api.terminal.WUTHandler; public record CycleTerminalPacket(boolean isRightClick) implements AE2wtlibPacket { - public static final Type ID = new Type<>(AE2wtlib.id("cycle_terminal")); + public static final Type ID = new Type<>(AE2wtlibAPI.id("cycle_terminal")); public static final StreamCodec STREAM_CODEC = ByteBufCodecs.BOOL .map(CycleTerminalPacket::new, CycleTerminalPacket::isRightClick); diff --git a/src/main/java/de/mari_023/ae2wtlib/networking/RestockAmountPacket.java b/src/main/java/de/mari_023/ae2wtlib/networking/RestockAmountPacket.java index 4fa20c8e..7f276e37 100644 --- a/src/main/java/de/mari_023/ae2wtlib/networking/RestockAmountPacket.java +++ b/src/main/java/de/mari_023/ae2wtlib/networking/RestockAmountPacket.java @@ -13,11 +13,11 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; -import de.mari_023.ae2wtlib.AE2wtlib; +import de.mari_023.ae2wtlib.api.AE2wtlibAPI; import de.mari_023.ae2wtlib.wct.CraftingTerminalHandler; public record RestockAmountPacket(HashMap, Long> items) implements AE2wtlibPacket { - public static final Type ID = new Type<>(AE2wtlib.id("restock_amounts")); + public static final Type ID = new Type<>(AE2wtlibAPI.id("restock_amounts")); public static final StreamCodec STREAM_CODEC = ByteBufCodecs .map(Maps::newHashMapWithExpectedSize, ByteBufCodecs.holderRegistry(Registries.ITEM), ByteBufCodecs.VAR_LONG) diff --git a/src/main/java/de/mari_023/ae2wtlib/networking/UpdateRestockPacket.java b/src/main/java/de/mari_023/ae2wtlib/networking/UpdateRestockPacket.java index becde846..aa306568 100644 --- a/src/main/java/de/mari_023/ae2wtlib/networking/UpdateRestockPacket.java +++ b/src/main/java/de/mari_023/ae2wtlib/networking/UpdateRestockPacket.java @@ -8,10 +8,10 @@ import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; -import de.mari_023.ae2wtlib.AE2wtlib; +import de.mari_023.ae2wtlib.api.AE2wtlibAPI; public record UpdateRestockPacket(int slot, int amount) implements AE2wtlibPacket { - public static final Type ID = new Type<>(AE2wtlib.id("update_restock")); + public static final Type ID = new Type<>(AE2wtlibAPI.id("update_restock")); public static final StreamCodec STREAM_CODEC = StreamCodec.composite( ByteBufCodecs.INT, UpdateRestockPacket::slot, ByteBufCodecs.INT, UpdateRestockPacket::amount, diff --git a/src/main/java/de/mari_023/ae2wtlib/networking/UpdateWUTPackage.java b/src/main/java/de/mari_023/ae2wtlib/networking/UpdateWUTPackage.java index 0b17bc95..4f336f2c 100644 --- a/src/main/java/de/mari_023/ae2wtlib/networking/UpdateWUTPackage.java +++ b/src/main/java/de/mari_023/ae2wtlib/networking/UpdateWUTPackage.java @@ -9,12 +9,12 @@ import appeng.menu.locator.ItemMenuHostLocator; -import de.mari_023.ae2wtlib.AE2wtlib; -import de.mari_023.ae2wtlib.AE2wtlibComponents; -import de.mari_023.ae2wtlib.terminal.WTMenuHost; +import de.mari_023.ae2wtlib.api.AE2wtlibAPI; +import de.mari_023.ae2wtlib.api.AE2wtlibComponents; +import de.mari_023.ae2wtlib.api.terminal.WTMenuHost; public record UpdateWUTPackage(ItemMenuHostLocator locator, DataComponentPatch patch) implements AE2wtlibPacket { - public static final Type ID = new Type<>(AE2wtlib.id("update_wut")); + public static final Type ID = new Type<>(AE2wtlibAPI.id("update_wut")); public static final StreamCodec STREAM_CODEC = StreamCodec .composite(AE2wtlibComponents.MENU_HOST_LOCATOR_STREAM_CODEC, UpdateWUTPackage::locator, DataComponentPatch.STREAM_CODEC, UpdateWUTPackage::patch, diff --git a/src/main/java/de/mari_023/ae2wtlib/recipeviewer/JEIPlugin.java b/src/main/java/de/mari_023/ae2wtlib/recipeviewer/JEIPlugin.java index 2e637e1f..fde22eba 100644 --- a/src/main/java/de/mari_023/ae2wtlib/recipeviewer/JEIPlugin.java +++ b/src/main/java/de/mari_023/ae2wtlib/recipeviewer/JEIPlugin.java @@ -11,13 +11,13 @@ import appeng.api.config.Actionable; -import de.mari_023.ae2wtlib.AE2wtlib; import de.mari_023.ae2wtlib.AE2wtlibItems; +import de.mari_023.ae2wtlib.api.AE2wtlibAPI; import de.mari_023.ae2wtlib.wut.WTDefinitions; @JeiPlugin public class JEIPlugin implements IModPlugin { - private static final ResourceLocation ID = AE2wtlib.id("core"); + private static final ResourceLocation ID = AE2wtlibAPI.id("core"); @Override public ResourceLocation getPluginUid() { diff --git a/src/main/java/de/mari_023/ae2wtlib/recipeviewer/REIPlugin.java b/src/main/java/de/mari_023/ae2wtlib/recipeviewer/REIPlugin.java index ca9b614e..3c6abf15 100644 --- a/src/main/java/de/mari_023/ae2wtlib/recipeviewer/REIPlugin.java +++ b/src/main/java/de/mari_023/ae2wtlib/recipeviewer/REIPlugin.java @@ -10,15 +10,15 @@ import appeng.api.config.Actionable; -import de.mari_023.ae2wtlib.AE2wtlib; import de.mari_023.ae2wtlib.AE2wtlibItems; +import de.mari_023.ae2wtlib.api.AE2wtlibAPI; import de.mari_023.ae2wtlib.wut.WTDefinitions; @REIPluginClient public class REIPlugin implements REIClientPlugin { @Override public String getPluginProviderName() { - return AE2wtlib.MOD_NAME; + return AE2wtlibAPI.MOD_NAME; } @Override diff --git a/src/main/java/de/mari_023/ae2wtlib/wat/ItemWAT.java b/src/main/java/de/mari_023/ae2wtlib/wat/ItemWAT.java index 39fd2902..fa4b9e51 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wat/ItemWAT.java +++ b/src/main/java/de/mari_023/ae2wtlib/wat/ItemWAT.java @@ -11,7 +11,7 @@ import appeng.api.util.IConfigManager; import appeng.menu.locator.ItemMenuHostLocator; -import de.mari_023.ae2wtlib.terminal.ItemWT; +import de.mari_023.ae2wtlib.api.terminal.ItemWT; public class ItemWAT extends ItemWT { @Override diff --git a/src/main/java/de/mari_023/ae2wtlib/wat/WATMenu.java b/src/main/java/de/mari_023/ae2wtlib/wat/WATMenu.java index 7bb6d4ca..97118df5 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wat/WATMenu.java +++ b/src/main/java/de/mari_023/ae2wtlib/wat/WATMenu.java @@ -11,9 +11,9 @@ import appeng.menu.implementations.PatternAccessTermMenu; import appeng.menu.slot.RestrictedInputSlot; -import de.mari_023.ae2wtlib.AE2wtlibSlotSemantics; -import de.mari_023.ae2wtlib.terminal.WTMenuHost; -import de.mari_023.ae2wtlib.wut.ItemWUT; +import de.mari_023.ae2wtlib.api.gui.AE2wtlibSlotSemantics; +import de.mari_023.ae2wtlib.api.terminal.ItemWUT; +import de.mari_023.ae2wtlib.api.terminal.WTMenuHost; public class WATMenu extends PatternAccessTermMenu { public static final String ID = "wireless_pattern_access_terminal"; diff --git a/src/main/java/de/mari_023/ae2wtlib/wat/WATMenuHost.java b/src/main/java/de/mari_023/ae2wtlib/wat/WATMenuHost.java index a4aa326a..515e78e7 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wat/WATMenuHost.java +++ b/src/main/java/de/mari_023/ae2wtlib/wat/WATMenuHost.java @@ -11,8 +11,8 @@ import appeng.menu.ISubMenu; import appeng.menu.locator.ItemMenuHostLocator; -import de.mari_023.ae2wtlib.terminal.ItemWT; -import de.mari_023.ae2wtlib.terminal.WTMenuHost; +import de.mari_023.ae2wtlib.api.terminal.ItemWT; +import de.mari_023.ae2wtlib.api.terminal.WTMenuHost; public class WATMenuHost extends WTMenuHost implements IPatternAccessTermMenuHost { public WATMenuHost(ItemWT item, Player player, ItemMenuHostLocator locator, diff --git a/src/main/java/de/mari_023/ae2wtlib/wat/WATScreen.java b/src/main/java/de/mari_023/ae2wtlib/wat/WATScreen.java index aee601c7..6b799b83 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wat/WATScreen.java +++ b/src/main/java/de/mari_023/ae2wtlib/wat/WATScreen.java @@ -7,9 +7,9 @@ import appeng.client.gui.style.ScreenStyle; import appeng.client.gui.widgets.ToolboxPanel; -import de.mari_023.ae2wtlib.terminal.ScrollingUpgradesPanel; -import de.mari_023.ae2wtlib.terminal.WTMenuHost; -import de.mari_023.ae2wtlib.wut.IUniversalTerminalCapable; +import de.mari_023.ae2wtlib.api.gui.ScrollingUpgradesPanel; +import de.mari_023.ae2wtlib.api.terminal.IUniversalTerminalCapable; +import de.mari_023.ae2wtlib.api.terminal.WTMenuHost; public class WATScreen extends PatternAccessTermScreen implements IUniversalTerminalCapable { private final ScrollingUpgradesPanel upgradesPanel; diff --git a/src/main/java/de/mari_023/ae2wtlib/terminal/ArmorSlot.java b/src/main/java/de/mari_023/ae2wtlib/wct/ArmorSlot.java similarity index 96% rename from src/main/java/de/mari_023/ae2wtlib/terminal/ArmorSlot.java rename to src/main/java/de/mari_023/ae2wtlib/wct/ArmorSlot.java index d3691735..8f83f992 100644 --- a/src/main/java/de/mari_023/ae2wtlib/terminal/ArmorSlot.java +++ b/src/main/java/de/mari_023/ae2wtlib/wct/ArmorSlot.java @@ -1,4 +1,4 @@ -package de.mari_023.ae2wtlib.terminal; +package de.mari_023.ae2wtlib.wct; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.player.Inventory; @@ -8,6 +8,8 @@ import appeng.menu.slot.AppEngSlot; +import de.mari_023.ae2wtlib.api.gui.Icon; + public class ArmorSlot extends AppEngSlot { private final Inventory playerInventory; private final Armor armor; diff --git a/src/main/java/de/mari_023/ae2wtlib/wct/CraftingTerminalHandler.java b/src/main/java/de/mari_023/ae2wtlib/wct/CraftingTerminalHandler.java index d37a9bc7..83924b6c 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wct/CraftingTerminalHandler.java +++ b/src/main/java/de/mari_023/ae2wtlib/wct/CraftingTerminalHandler.java @@ -13,11 +13,11 @@ import appeng.api.networking.IGridNode; import appeng.menu.locator.ItemMenuHostLocator; -import de.mari_023.ae2wtlib.AE2wtlibComponents; -import de.mari_023.ae2wtlib.terminal.WTMenuHost; +import de.mari_023.ae2wtlib.AE2wtlibAdditionalComponents; +import de.mari_023.ae2wtlib.api.terminal.WTMenuHost; +import de.mari_023.ae2wtlib.api.terminal.WUTHandler; import de.mari_023.ae2wtlib.wct.magnet_card.MagnetHost; import de.mari_023.ae2wtlib.wut.WTDefinitions; -import de.mari_023.ae2wtlib.wut.WUTHandler; public class CraftingTerminalHandler { public final Player player; @@ -35,7 +35,7 @@ public CraftingTerminalHandler(Player player) { } public static CraftingTerminalHandler getCraftingTerminalHandler(Player player) { - return player.getData(AE2wtlibComponents.CT_HANDLER); + return player.getData(AE2wtlibAdditionalComponents.CT_HANDLER); } private void invalidateCache() { diff --git a/src/main/java/de/mari_023/ae2wtlib/wct/ItemWCT.java b/src/main/java/de/mari_023/ae2wtlib/wct/ItemWCT.java index 8a8df63c..a6f97950 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wct/ItemWCT.java +++ b/src/main/java/de/mari_023/ae2wtlib/wct/ItemWCT.java @@ -9,7 +9,7 @@ import appeng.menu.locator.ItemMenuHostLocator; -import de.mari_023.ae2wtlib.terminal.ItemWT; +import de.mari_023.ae2wtlib.api.terminal.ItemWT; import de.mari_023.ae2wtlib.wct.magnet_card.MagnetHandler; public class ItemWCT extends ItemWT { diff --git a/src/main/java/de/mari_023/ae2wtlib/wct/TrashMenu.java b/src/main/java/de/mari_023/ae2wtlib/wct/TrashMenu.java index a97c4f7e..b3ca2978 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wct/TrashMenu.java +++ b/src/main/java/de/mari_023/ae2wtlib/wct/TrashMenu.java @@ -9,7 +9,7 @@ import appeng.menu.implementations.MenuTypeBuilder; import appeng.menu.slot.AppEngSlot; -import de.mari_023.ae2wtlib.AE2wtlibSlotSemantics; +import de.mari_023.ae2wtlib.api.gui.AE2wtlibSlotSemantics; public class TrashMenu extends AEBaseMenu implements ISubMenu { public static final String ID = "trash"; diff --git a/src/main/java/de/mari_023/ae2wtlib/wct/WCTMenu.java b/src/main/java/de/mari_023/ae2wtlib/wct/WCTMenu.java index 7c34c524..9b12c24e 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wct/WCTMenu.java +++ b/src/main/java/de/mari_023/ae2wtlib/wct/WCTMenu.java @@ -13,13 +13,12 @@ import appeng.menu.me.items.CraftingTermMenu; import appeng.menu.slot.RestrictedInputSlot; -import de.mari_023.ae2wtlib.AE2wtlibSlotSemantics; -import de.mari_023.ae2wtlib.terminal.ArmorSlot; -import de.mari_023.ae2wtlib.terminal.WTMenuHost; +import de.mari_023.ae2wtlib.api.gui.AE2wtlibSlotSemantics; +import de.mari_023.ae2wtlib.api.terminal.ItemWUT; +import de.mari_023.ae2wtlib.api.terminal.WTMenuHost; import de.mari_023.ae2wtlib.wct.magnet_card.MagnetHandler; import de.mari_023.ae2wtlib.wct.magnet_card.MagnetMenu; import de.mari_023.ae2wtlib.wct.magnet_card.MagnetMode; -import de.mari_023.ae2wtlib.wut.ItemWUT; public class WCTMenu extends CraftingTermMenu { public static final String ID = "wireless_crafting_terminal"; diff --git a/src/main/java/de/mari_023/ae2wtlib/wct/WCTMenuHost.java b/src/main/java/de/mari_023/ae2wtlib/wct/WCTMenuHost.java index 6b9c5f34..e19a21c2 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wct/WCTMenuHost.java +++ b/src/main/java/de/mari_023/ae2wtlib/wct/WCTMenuHost.java @@ -17,14 +17,14 @@ import appeng.util.inv.AppEngInternalInventory; import appeng.util.inv.SupplierInternalInventory; -import de.mari_023.ae2wtlib.AE2wtlib; -import de.mari_023.ae2wtlib.terminal.ItemWT; -import de.mari_023.ae2wtlib.terminal.WTMenuHost; +import de.mari_023.ae2wtlib.api.AE2wtlibAPI; +import de.mari_023.ae2wtlib.api.terminal.ItemWT; +import de.mari_023.ae2wtlib.api.terminal.WTMenuHost; public class WCTMenuHost extends WTMenuHost implements IViewCellStorage { private final SupplierInternalInventory craftingGrid; private final AppEngInternalInventory trash = new AppEngInternalInventory(27); - public static final ResourceLocation INV_TRASH = AE2wtlib.id("wct_trash"); + public static final ResourceLocation INV_TRASH = AE2wtlibAPI.id("wct_trash"); public WCTMenuHost(ItemWT item, Player player, ItemMenuHostLocator locator, BiConsumer returnToMainMenu) { diff --git a/src/main/java/de/mari_023/ae2wtlib/wct/WCTScreen.java b/src/main/java/de/mari_023/ae2wtlib/wct/WCTScreen.java index 98fa0f68..7c3d7ada 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wct/WCTScreen.java +++ b/src/main/java/de/mari_023/ae2wtlib/wct/WCTScreen.java @@ -11,10 +11,13 @@ import appeng.client.gui.me.items.CraftingTermScreen; import appeng.client.gui.style.ScreenStyle; -import de.mari_023.ae2wtlib.TextConstants; -import de.mari_023.ae2wtlib.terminal.*; +import de.mari_023.ae2wtlib.api.TextConstants; +import de.mari_023.ae2wtlib.api.gui.Icon; +import de.mari_023.ae2wtlib.api.gui.IconButton; +import de.mari_023.ae2wtlib.api.gui.ScrollingUpgradesPanel; +import de.mari_023.ae2wtlib.api.terminal.IUniversalTerminalCapable; +import de.mari_023.ae2wtlib.api.terminal.WTMenuHost; import de.mari_023.ae2wtlib.wct.magnet_card.MagnetMode; -import de.mari_023.ae2wtlib.wut.IUniversalTerminalCapable; public class WCTScreen extends CraftingTermScreen implements IUniversalTerminalCapable { private final IconButton magnetCardToggleButton; diff --git a/src/main/java/de/mari_023/ae2wtlib/terminal/WrappedPlayerInventory.java b/src/main/java/de/mari_023/ae2wtlib/wct/WrappedPlayerInventory.java similarity index 95% rename from src/main/java/de/mari_023/ae2wtlib/terminal/WrappedPlayerInventory.java rename to src/main/java/de/mari_023/ae2wtlib/wct/WrappedPlayerInventory.java index cd0ccd4f..1832901a 100644 --- a/src/main/java/de/mari_023/ae2wtlib/terminal/WrappedPlayerInventory.java +++ b/src/main/java/de/mari_023/ae2wtlib/wct/WrappedPlayerInventory.java @@ -1,4 +1,4 @@ -package de.mari_023.ae2wtlib.terminal; +package de.mari_023.ae2wtlib.wct; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.item.ItemStack; diff --git a/src/main/java/de/mari_023/ae2wtlib/wct/magnet_card/MagnetHandler.java b/src/main/java/de/mari_023/ae2wtlib/wct/magnet_card/MagnetHandler.java index 798cd511..6b44f2bb 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wct/magnet_card/MagnetHandler.java +++ b/src/main/java/de/mari_023/ae2wtlib/wct/magnet_card/MagnetHandler.java @@ -21,9 +21,10 @@ import appeng.api.upgrades.IUpgradeableItem; import appeng.api.upgrades.Upgrades; -import de.mari_023.ae2wtlib.AE2wtlibComponents; +import de.mari_023.ae2wtlib.AE2wtlibAdditionalComponents; import de.mari_023.ae2wtlib.AE2wtlibConfig; import de.mari_023.ae2wtlib.AE2wtlibItems; +import de.mari_023.ae2wtlib.api.AE2wtlibComponents; import de.mari_023.ae2wtlib.networking.RestockAmountPacket; import de.mari_023.ae2wtlib.wct.CraftingTerminalHandler; @@ -124,14 +125,14 @@ public static void saveMagnetMode(ItemStack terminal, MagnetMode magnetSettings) return; if (!upgradeableItem.getUpgrades(terminal).isInstalled(AE2wtlibItems.MAGNET_CARD)) return; - terminal.set(AE2wtlibComponents.MAGNET_SETTINGS, magnetSettings); + terminal.set(AE2wtlibAdditionalComponents.MAGNET_SETTINGS, magnetSettings); } public static MagnetMode getMagnetMode(ItemStack terminal) { if (terminal.getItem() instanceof IUpgradeableItem upgradeableItem && Upgrades.getMaxInstallable(AE2wtlibItems.MAGNET_CARD, upgradeableItem) != 0) { if (upgradeableItem.getUpgrades(terminal).isInstalled(AE2wtlibItems.MAGNET_CARD)) - return terminal.getOrDefault(AE2wtlibComponents.MAGNET_SETTINGS, MagnetMode.OFF); + return terminal.getOrDefault(AE2wtlibAdditionalComponents.MAGNET_SETTINGS, MagnetMode.OFF); return MagnetMode.NO_CARD; } return MagnetMode.INVALID; diff --git a/src/main/java/de/mari_023/ae2wtlib/wct/magnet_card/MagnetHost.java b/src/main/java/de/mari_023/ae2wtlib/wct/magnet_card/MagnetHost.java index 1ed9cb32..d71e10b7 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wct/magnet_card/MagnetHost.java +++ b/src/main/java/de/mari_023/ae2wtlib/wct/magnet_card/MagnetHost.java @@ -9,7 +9,7 @@ import appeng.util.ConfigInventory; import appeng.util.prioritylist.IPartitionList; -import de.mari_023.ae2wtlib.AE2wtlibComponents; +import de.mari_023.ae2wtlib.api.AE2wtlibComponents; import de.mari_023.ae2wtlib.wct.CraftingTerminalHandler; public class MagnetHost { diff --git a/src/main/java/de/mari_023/ae2wtlib/wct/magnet_card/MagnetMenu.java b/src/main/java/de/mari_023/ae2wtlib/wct/magnet_card/MagnetMenu.java index fd76ddca..bd5bde33 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wct/magnet_card/MagnetMenu.java +++ b/src/main/java/de/mari_023/ae2wtlib/wct/magnet_card/MagnetMenu.java @@ -14,7 +14,7 @@ import appeng.util.ConfigInventory; import appeng.util.ConfigMenuInventory; -import de.mari_023.ae2wtlib.AE2wtlibSlotSemantics; +import de.mari_023.ae2wtlib.api.gui.AE2wtlibSlotSemantics; import de.mari_023.ae2wtlib.wct.CraftingTerminalHandler; import de.mari_023.ae2wtlib.wct.WCTMenuHost; diff --git a/src/main/java/de/mari_023/ae2wtlib/wct/magnet_card/MagnetScreen.java b/src/main/java/de/mari_023/ae2wtlib/wct/magnet_card/MagnetScreen.java index 9d79654e..5fd92ddb 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wct/magnet_card/MagnetScreen.java +++ b/src/main/java/de/mari_023/ae2wtlib/wct/magnet_card/MagnetScreen.java @@ -8,9 +8,9 @@ import appeng.client.gui.implementations.AESubScreen; import appeng.client.gui.style.ScreenStyle; -import de.mari_023.ae2wtlib.TextConstants; -import de.mari_023.ae2wtlib.terminal.Icon; -import de.mari_023.ae2wtlib.terminal.IconButton; +import de.mari_023.ae2wtlib.api.TextConstants; +import de.mari_023.ae2wtlib.api.gui.Icon; +import de.mari_023.ae2wtlib.api.gui.IconButton; public class MagnetScreen extends AEBaseScreen { public MagnetScreen(MagnetMenu menu, Inventory playerInventory, Component title, ScreenStyle style) { diff --git a/src/main/java/de/mari_023/ae2wtlib/wet/ItemWET.java b/src/main/java/de/mari_023/ae2wtlib/wet/ItemWET.java index 53fc3308..a3cd8c4e 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wet/ItemWET.java +++ b/src/main/java/de/mari_023/ae2wtlib/wet/ItemWET.java @@ -5,7 +5,7 @@ import appeng.menu.locator.ItemMenuHostLocator; -import de.mari_023.ae2wtlib.terminal.ItemWT; +import de.mari_023.ae2wtlib.api.terminal.ItemWT; public class ItemWET extends ItemWT { @Override diff --git a/src/main/java/de/mari_023/ae2wtlib/wet/WETMenu.java b/src/main/java/de/mari_023/ae2wtlib/wet/WETMenu.java index 471d9ead..193be2b7 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wet/WETMenu.java +++ b/src/main/java/de/mari_023/ae2wtlib/wet/WETMenu.java @@ -8,9 +8,9 @@ import appeng.menu.me.items.PatternEncodingTermMenu; import appeng.menu.slot.RestrictedInputSlot; -import de.mari_023.ae2wtlib.AE2wtlibSlotSemantics; -import de.mari_023.ae2wtlib.terminal.WTMenuHost; -import de.mari_023.ae2wtlib.wut.ItemWUT; +import de.mari_023.ae2wtlib.api.gui.AE2wtlibSlotSemantics; +import de.mari_023.ae2wtlib.api.terminal.ItemWUT; +import de.mari_023.ae2wtlib.api.terminal.WTMenuHost; public class WETMenu extends PatternEncodingTermMenu { public static final String ID = "wireless_pattern_encoding_terminal"; diff --git a/src/main/java/de/mari_023/ae2wtlib/wet/WETMenuHost.java b/src/main/java/de/mari_023/ae2wtlib/wet/WETMenuHost.java index 9e067e85..ed333492 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wet/WETMenuHost.java +++ b/src/main/java/de/mari_023/ae2wtlib/wet/WETMenuHost.java @@ -13,9 +13,9 @@ import appeng.menu.locator.ItemMenuHostLocator; import appeng.parts.encoding.PatternEncodingLogic; -import de.mari_023.ae2wtlib.AE2wtlibComponents; -import de.mari_023.ae2wtlib.terminal.ItemWT; -import de.mari_023.ae2wtlib.terminal.WTMenuHost; +import de.mari_023.ae2wtlib.api.AE2wtlibComponents; +import de.mari_023.ae2wtlib.api.terminal.ItemWT; +import de.mari_023.ae2wtlib.api.terminal.WTMenuHost; public class WETMenuHost extends WTMenuHost implements IViewCellStorage, IPatternTerminalMenuHost, IPatternTerminalLogicHost { diff --git a/src/main/java/de/mari_023/ae2wtlib/wet/WETScreen.java b/src/main/java/de/mari_023/ae2wtlib/wet/WETScreen.java index 513394d3..8e3a919f 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wet/WETScreen.java +++ b/src/main/java/de/mari_023/ae2wtlib/wet/WETScreen.java @@ -6,9 +6,9 @@ import appeng.client.gui.me.items.PatternEncodingTermScreen; import appeng.client.gui.style.ScreenStyle; -import de.mari_023.ae2wtlib.terminal.ScrollingUpgradesPanel; -import de.mari_023.ae2wtlib.terminal.WTMenuHost; -import de.mari_023.ae2wtlib.wut.IUniversalTerminalCapable; +import de.mari_023.ae2wtlib.api.gui.ScrollingUpgradesPanel; +import de.mari_023.ae2wtlib.api.terminal.IUniversalTerminalCapable; +import de.mari_023.ae2wtlib.api.terminal.WTMenuHost; public class WETScreen extends PatternEncodingTermScreen implements IUniversalTerminalCapable { private final ScrollingUpgradesPanel upgradesPanel; diff --git a/src/main/java/de/mari_023/ae2wtlib/wut/WTDefinitions.java b/src/main/java/de/mari_023/ae2wtlib/wut/WTDefinitions.java index 4a282f08..4fc80baa 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wut/WTDefinitions.java +++ b/src/main/java/de/mari_023/ae2wtlib/wut/WTDefinitions.java @@ -1,5 +1,8 @@ package de.mari_023.ae2wtlib.wut; +import de.mari_023.ae2wtlib.api.registration.AddTerminalEvent; +import de.mari_023.ae2wtlib.api.registration.WTDefinition; + /** * Holds links to AE2wtlib wireless terminal definition. *

@@ -18,17 +21,17 @@ private WTDefinitions() {} *

* Don't access until terminal registration happened, or it WILL crash. */ - public static WTDefinition CRAFTING = WTDefinition.of("crafting"); + public static final WTDefinition CRAFTING = WTDefinition.of("crafting"); /** * Wireless Pattern Encoding Terminal *

* Don't access until terminal registration happened, or it WILL crash. */ - public static WTDefinition PATTERN_ENCODING = WTDefinition.of("pattern_encoding"); + public static final WTDefinition PATTERN_ENCODING = WTDefinition.of("pattern_encoding"); /** * Wireless Pattern Access Terminal *

* Don't access until terminal registration happened, or it WILL crash. */ - public static WTDefinition PATTERN_ACCESS = WTDefinition.of("pattern_access"); + public static final WTDefinition PATTERN_ACCESS = WTDefinition.of("pattern_access"); } diff --git a/src/main/java/de/mari_023/ae2wtlib/wut/recipe/Combine.java b/src/main/java/de/mari_023/ae2wtlib/wut/recipe/Combine.java index 4ad800ea..8043c132 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wut/recipe/Combine.java +++ b/src/main/java/de/mari_023/ae2wtlib/wut/recipe/Combine.java @@ -10,7 +10,7 @@ import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.level.Level; -import de.mari_023.ae2wtlib.wut.WTDefinition; +import de.mari_023.ae2wtlib.api.registration.WTDefinition; public class Combine extends Common { public static final CombineSerializer serializer = new CombineSerializer(); diff --git a/src/main/java/de/mari_023/ae2wtlib/wut/recipe/CombineSerializer.java b/src/main/java/de/mari_023/ae2wtlib/wut/recipe/CombineSerializer.java index 57645ace..ebe8ad56 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wut/recipe/CombineSerializer.java +++ b/src/main/java/de/mari_023/ae2wtlib/wut/recipe/CombineSerializer.java @@ -7,7 +7,7 @@ import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.crafting.Ingredient; -import de.mari_023.ae2wtlib.wut.WTDefinition; +import de.mari_023.ae2wtlib.api.registration.WTDefinition; public class CombineSerializer implements net.minecraft.world.item.crafting.RecipeSerializer { public static final String NAME = "combine"; diff --git a/src/main/java/de/mari_023/ae2wtlib/wut/recipe/Common.java b/src/main/java/de/mari_023/ae2wtlib/wut/recipe/Common.java index 977acdf1..034a1c61 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wut/recipe/Common.java +++ b/src/main/java/de/mari_023/ae2wtlib/wut/recipe/Common.java @@ -14,9 +14,9 @@ import appeng.api.upgrades.IUpgradeInventory; import de.mari_023.ae2wtlib.AE2wtlibItems; -import de.mari_023.ae2wtlib.terminal.ItemWT; -import de.mari_023.ae2wtlib.wut.ItemWUT; -import de.mari_023.ae2wtlib.wut.WTDefinition; +import de.mari_023.ae2wtlib.api.registration.WTDefinition; +import de.mari_023.ae2wtlib.api.terminal.ItemWT; +import de.mari_023.ae2wtlib.api.terminal.ItemWUT; public abstract class Common implements CraftingRecipe { protected final ItemStack outputStack = new ItemStack(AE2wtlibItems.UNIVERSAL_TERMINAL); diff --git a/src/main/java/de/mari_023/ae2wtlib/wut/recipe/Upgrade.java b/src/main/java/de/mari_023/ae2wtlib/wut/recipe/Upgrade.java index 4b15f323..75e452f7 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wut/recipe/Upgrade.java +++ b/src/main/java/de/mari_023/ae2wtlib/wut/recipe/Upgrade.java @@ -10,7 +10,7 @@ import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.level.Level; -import de.mari_023.ae2wtlib.wut.WTDefinition; +import de.mari_023.ae2wtlib.api.registration.WTDefinition; public class Upgrade extends Common { public static final UpgradeSerializer serializer = new UpgradeSerializer(); diff --git a/src/main/java/de/mari_023/ae2wtlib/wut/recipe/UpgradeSerializer.java b/src/main/java/de/mari_023/ae2wtlib/wut/recipe/UpgradeSerializer.java index f5b85d03..29252139 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wut/recipe/UpgradeSerializer.java +++ b/src/main/java/de/mari_023/ae2wtlib/wut/recipe/UpgradeSerializer.java @@ -7,7 +7,7 @@ import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.crafting.Ingredient; -import de.mari_023.ae2wtlib.wut.WTDefinition; +import de.mari_023.ae2wtlib.api.registration.WTDefinition; public class UpgradeSerializer implements net.minecraft.world.item.crafting.RecipeSerializer { public static final String NAME = "upgrade"; diff --git a/src/main/java/de/mari_023/ae2wtlib/wut/select/WUTSelectScreen.java b/src/main/java/de/mari_023/ae2wtlib/wut/select/WUTSelectScreen.java index da73a395..d70079de 100644 --- a/src/main/java/de/mari_023/ae2wtlib/wut/select/WUTSelectScreen.java +++ b/src/main/java/de/mari_023/ae2wtlib/wut/select/WUTSelectScreen.java @@ -1,5 +1,6 @@ package de.mari_023.ae2wtlib.wut.select; +import java.awt.*; import java.util.ArrayList; import java.util.List; @@ -13,9 +14,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; -import me.shedaniel.math.Color; - -import de.mari_023.ae2wtlib.wut.WTDefinition; +import de.mari_023.ae2wtlib.api.registration.WTDefinition; public class WUTSelectScreen extends Screen { private final List terminals = new ArrayList<>(); @@ -37,7 +36,7 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partia for (int i = 0; i < terminals.size(); i++) drawSegment(guiGraphics.pose(), i * angle, (i + 1) * angle, hWidth, hHeight, 100, 50, - Color.ofRGB(125, 125, 125), + new Color(125, 125, 125), i == selected); super.render(guiGraphics, mouseX, mouseY, partialTicks); @@ -47,7 +46,7 @@ public static void drawSegment(PoseStack poseStack, int startingAngle, int endin float centerY, int outerRadius, int innerRadius, Color color, boolean selected) { if (selected) { outerRadius += 10; - color = color.darker(2); + color = color.darker(); } poseStack.pushPose(); diff --git a/src/main/resources/META-INF/neoforge.mods.toml b/src/main/resources/META-INF/neoforge.mods.toml index 1904c692..32101946 100644 --- a/src/main/resources/META-INF/neoforge.mods.toml +++ b/src/main/resources/META-INF/neoforge.mods.toml @@ -13,22 +13,16 @@ Adds Wireless versions of ae2 Terminals with infinite range capabilities. ''' updateJSONURL = "https://api.modrinth.com/updates/applied-energistics-2-wireless-terminals/forge_updates.json?neoforge=only" logoFile = "icon.png" +logoBlur=false [[mixins]] config="ae2wtlib.mixins.json" [[dependencies.ae2wtlib]] -modId = "neoforge" +modId = "ae2wtlib_api" type="REQUIRED" -versionRange = "*" -ordering = "NONE" -side = "BOTH" - -[[dependencies.ae2wtlib]] -modId = "minecraft" -type="REQUIRED" -versionRange = "*" -ordering = "NONE" +versionRange = "[${version}]" +ordering = "BEFORE" side = "BOTH" [[dependencies.ae2wtlib]] @@ -42,5 +36,21 @@ side = "BOTH" modId = "curios" type="OPTIONAL" versionRange = "*" -ordering = "AFTER" -side = "BOTH" \ No newline at end of file +ordering = "NONE" +side = "BOTH" + +[[dependencies.ae2wtlib]] +modId = "extendedae" +type="INCOMPATIBLE" +versionRange = "(,1.21-1.1.4-neoforge]" +ordering = "NONE" +side = "BOTH" +reason = "breaking changes in the ae2wtlib api" + +[[dependencies.ae2wtlib]] +modId = "megacells" +type="INCOMPATIBLE" +versionRange = "(0.0.0,4.0.0-alpha]" +ordering = "NONE" +side = "BOTH" +reason = "breaking changes in the ae2wtlib api" diff --git a/src/main/resources/assets/ae2/textures/wtlib/guis/crafting-REF-FULL.png b/src/main/resources/assets/ae2/textures/wtlib/guis/crafting-REF-FULL.png deleted file mode 100644 index 4e5c480d..00000000 Binary files a/src/main/resources/assets/ae2/textures/wtlib/guis/crafting-REF-FULL.png and /dev/null differ diff --git a/src/main/resources/assets/ae2/textures/wtlib/guis/crafting-REF.png b/src/main/resources/assets/ae2/textures/wtlib/guis/crafting-REF.png deleted file mode 100644 index 6939b6c7..00000000 Binary files a/src/main/resources/assets/ae2/textures/wtlib/guis/crafting-REF.png and /dev/null differ diff --git a/src/main/resources/assets/ae2/textures/wtlib/guis/icons.png b/src/main/resources/assets/ae2/textures/wtlib/guis/icons.png deleted file mode 100644 index 4ed7e88e..00000000 Binary files a/src/main/resources/assets/ae2/textures/wtlib/guis/icons.png and /dev/null differ diff --git a/src/main/resources/assets/ae2/textures/wtlib/guis/magnet-REF.png b/src/main/resources/assets/ae2/textures/wtlib/guis/magnet-REF.png deleted file mode 100644 index 9fca23b0..00000000 Binary files a/src/main/resources/assets/ae2/textures/wtlib/guis/magnet-REF.png and /dev/null differ diff --git a/src/main/resources/assets/ae2wtlib/lang/de_de.json b/src/main/resources/assets/ae2wtlib/lang/de_de.json index 86997a9d..241cb6a9 100644 --- a/src/main/resources/assets/ae2wtlib/lang/de_de.json +++ b/src/main/resources/assets/ae2wtlib/lang/de_de.json @@ -37,11 +37,5 @@ "key.ae2.wireless_pattern_access_terminal": "Drahtlose Schablonenkonsole Öffnen", "key.ae2.wireless_pattern_encoding_terminal": "Drahtlose Schnittstellenkonsole Öffnen", "key.ae2.ae2wtlib_restock": "Nachfüllen umschalten", - "key.ae2.ae2wtlib_magnet": "Magnet Karte umschalten", - - "chat.ae2wtlib.NetworkNotPowered" : "Netzwerk hat keine Energie", - "chat.ae2wtlib.SingularityNotPresent" : "Singularität fehlt", - "chat.ae2wtlib.NoQuantumBridgeCard" : "Quantenbrückenkarte fehlt", - "chat.ae2wtlib.NoQuantumBridge" : "Quantenbrücke nicht gefunden. Ist sie in geladenen chunks?", - "chat.ae2wtlib.NetworkMismatch": "Quantenbrücke und Drahtloser Zugangspunkt sind mit verschiedenen Netzwerken verbunden" + "key.ae2.ae2wtlib_magnet": "Magnet Karte umschalten" } diff --git a/src/main/resources/assets/ae2wtlib/lang/en_ud.json b/src/main/resources/assets/ae2wtlib/lang/en_ud.json index 0d376e47..f555ec19 100644 --- a/src/main/resources/assets/ae2wtlib/lang/en_ud.json +++ b/src/main/resources/assets/ae2wtlib/lang/en_ud.json @@ -37,11 +37,5 @@ "key.ae2.wireless_pattern_access_terminal": "lɐuᴉɯɹǝ⟘ ssǝɔɔ∀ uɹǝʇʇɐԀ ssǝlǝɹᴉM uǝdO", "key.ae2.wireless_pattern_encoding_terminal": "lɐuᴉɯɹǝ⟘ ƃuᴉpoɔuƎ uɹǝʇʇɐԀ ssǝlǝɹᴉM uǝdO", "key.ae2.ae2wtlib_restock": "ʞɔoʇsǝᴚ ǝlƃƃo⟘", - "key.ae2.ae2wtlib_magnet": "pɹɐƆ ʇǝuƃɐW ǝlƃƃo⟘", - - "chat.ae2wtlib.NetworkNotPowered" : "pǝɹǝʍoԀ ʇoN ʞɹoʍʇǝN", - "chat.ae2wtlib.SingularityNotPresent" : "ʎʇᴉɹɐlnƃuᴉS ƃuᴉssᴉW", - "chat.ae2wtlib.NoQuantumBridgeCard" : "pɹɐƆ ǝƃpᴉɹq ɯnʇuɐnꝹ ƃuᴉssᴉW", - "chat.ae2wtlib.NoQuantumBridge" : "¿sʞunɥɔ pǝpɐol uᴉ ʇᴉ sI .punoɟ ʇou ǝƃpᴉɹq ʞɹoʍʇǝN ɯnʇuɐnꝹ", - "chat.ae2wtlib.NetworkMismatch": "sʞɹoʍʇǝN ʇuǝɹǝɟɟᴉp oʇ pǝʇɔǝuuoɔ ǝɹɐ ʇuᴉoԀ ssǝɔɔ∀ ssǝlǝɹᴉM puɐ ǝƃpᴉɹq ɯnʇuɐnꝹ" + "key.ae2.ae2wtlib_magnet": "pɹɐƆ ʇǝuƃɐW ǝlƃƃo⟘" } diff --git a/src/main/resources/assets/ae2wtlib/lang/en_us.json b/src/main/resources/assets/ae2wtlib/lang/en_us.json index 2c6eb459..bd873f62 100644 --- a/src/main/resources/assets/ae2wtlib/lang/en_us.json +++ b/src/main/resources/assets/ae2wtlib/lang/en_us.json @@ -37,11 +37,5 @@ "key.ae2.wireless_pattern_access_terminal": "Open Wireless Pattern Access Terminal", "key.ae2.wireless_pattern_encoding_terminal": "Open Wireless Pattern Encoding Terminal", "key.ae2.ae2wtlib_restock": "Toggle Restock", - "key.ae2.ae2wtlib_magnet": "Toggle Magnet Card", - - "chat.ae2wtlib.NetworkNotPowered" : "Network Not Powered", - "chat.ae2wtlib.SingularityNotPresent" : "Missing Singularity", - "chat.ae2wtlib.NoQuantumBridgeCard" : "Missing Quantum Bridge Card", - "chat.ae2wtlib.NoQuantumBridge" : "Quantum Network Bridge not found. Is it in loaded chunks?", - "chat.ae2wtlib.NetworkMismatch": "Quantum Bridge and Wireless Access Point are connected to Different Networks" + "key.ae2.ae2wtlib_magnet": "Toggle Magnet Card" } diff --git a/src/main/resources/texture_references/crafting-REF-FULL.png b/src/main/resources/texture_references/crafting-REF-FULL.png new file mode 100644 index 00000000..5890475c Binary files /dev/null and b/src/main/resources/texture_references/crafting-REF-FULL.png differ diff --git a/src/main/resources/texture_references/magnet-REF.png b/src/main/resources/texture_references/magnet-REF.png new file mode 100644 index 00000000..dc3b7d2d Binary files /dev/null and b/src/main/resources/texture_references/magnet-REF.png differ