Skip to content

Commit

Permalink
Remove Addons enum in preparation for 1.21 porting
Browse files Browse the repository at this point in the history
Assumed from here on out that the only first-hand integration from AppliedE will be with AE2WTLib and nothing else AE2-related. Also, AE2WTLib's API has hopefully been stabilised enough in current (1.21) versions to no longer require a mixin on AppliedE's end in order to register a custom terminal.
 AECapFix is specific only to 1.18-1.20 and hence would no longer be relevant. As a result, the Mixin plugin is also expected to be removed once 1.21 porting commences.
  • Loading branch information
62832 committed Nov 17, 2024
1 parent 372f710 commit 50ebb98
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 47 deletions.
12 changes: 6 additions & 6 deletions src/main/java/gripe/_90/appliede/AppliedE.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraftforge.client.event.RegisterColorHandlersEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
Expand Down Expand Up @@ -57,7 +58,6 @@
import gripe._90.appliede.client.screen.EMCInterfaceScreen;
import gripe._90.appliede.client.screen.EMCSetStockAmountScreen;
import gripe._90.appliede.client.screen.TransmutationTerminalScreen;
import gripe._90.appliede.integration.Addons;
import gripe._90.appliede.integration.DummyIntegrationItem;
import gripe._90.appliede.integration.ae2wtlib.AE2WTIntegration;
import gripe._90.appliede.me.key.EMCKey;
Expand Down Expand Up @@ -128,9 +128,9 @@ public final class AppliedE {

public static final RegistryObject<Item> DUMMY_EMC_ITEM = ITEMS.register("dummy_emc_item", () -> new Item(new Item.Properties()));

public static final RegistryObject<Item> WIRELESS_TRANSMUTATION_TERMINAL = ITEMS.register("wireless_transmutation_terminal", () -> Addons.AE2WTLIB.isLoaded()
public static final RegistryObject<Item> WIRELESS_TRANSMUTATION_TERMINAL = ITEMS.register("wireless_transmutation_terminal", () -> ModList.get().isLoaded("ae2wtlib")
? AE2WTIntegration.getWirelessTerminalItem()
: new DummyIntegrationItem(new Item.Properties().stacksTo(1), Addons.AE2WTLIB));
: new DummyIntegrationItem(new Item.Properties().stacksTo(1), "AE2WTLib"));

private static final String PROTOCOL_VERSION = Integer.toString(1);
public static final SimpleChannel PACKET_HANDLER = NetworkRegistry.newSimpleChannel(
Expand All @@ -150,7 +150,7 @@ public final class AppliedE {
output.accept(LEARNING_CARD.get());
output.accept(WIRELESS_TRANSMUTATION_TERMINAL.get());

if (Addons.AE2WTLIB.isLoaded()) {
if (ModList.get().isLoaded("ae2wtlib")) {
output.accept(AE2WTIntegration.getChargedTerminal());
}
})
Expand Down Expand Up @@ -196,7 +196,7 @@ public AppliedE() {
registerEMC(AEParts.CABLE_ANCHOR, 32);
});

if (Addons.AE2WTLIB.isLoaded()) {
if (ModList.get().isLoaded("ae2wtlib")) {
bus.addListener(AE2WTIntegration::registerTerminalMenu);
bus.addListener(AE2WTIntegration::addTerminalToAE2WTLibTab);
}
Expand Down Expand Up @@ -255,7 +255,7 @@ private static void setup(IEventBus bus) {
TransmutationTerminalScreen<TransmutationTerminalMenu>::new,
"/screens/appliede/transmutation_terminal.json");

if (Addons.AE2WTLIB.isLoaded()) {
if (ModList.get().isLoaded("ae2wtlib")) {
AE2WTIntegration.Client.initScreen();
}
}));
Expand Down
28 changes: 0 additions & 28 deletions src/main/java/gripe/_90/appliede/integration/Addons.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
import gripe._90.appliede.AppliedE;

public class DummyIntegrationItem extends Item {
private final Addons addon;
private final String addon;

public DummyIntegrationItem(Properties props, Addons addon) {
public DummyIntegrationItem(Properties props, String addon) {
super(props);
this.addon = addon;
}

@ParametersAreNonnullByDefault
@Override
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> lines, TooltipFlag flag) {
lines.add(Component.translatable("tooltip." + AppliedE.MODID + ".not_installed." + addon.getModId())
lines.add(Component.translatable("tooltip." + AppliedE.MODID + ".not_installed", addon)
.withStyle(ChatFormatting.GRAY));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
import appeng.init.client.InitScreens;
import appeng.items.tools.powered.WirelessTerminalItem;

import gripe._90.appliede.integration.Addons;

public class AE2WTIntegration {
private static final Item TERMINAL = new WTTItem();

Expand All @@ -40,7 +38,7 @@ public static void registerTerminalMenu(RegisterEvent event) {
}

public static void addTerminalToAE2WTLibTab(BuildCreativeModeTabContentsEvent event) {
if (event.getTabKey().location().getNamespace().equals(Addons.AE2WTLIB.getModId())) {
if (event.getTabKey().location().getNamespace().equals("ae2wtlib")) {
event.accept(TERMINAL);
event.accept(AE2WTIntegration.getChargedTerminal());
}
Expand Down
22 changes: 17 additions & 5 deletions src/main/java/gripe/_90/appliede/mixin/Plugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,27 @@
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;

import gripe._90.appliede.integration.Addons;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.loading.LoadingModList;
import net.minecraftforge.forgespi.language.IModInfo;

public class Plugin implements IMixinConfigPlugin {
private static boolean isModLoaded(String modId) {
return ModList.get() != null
? ModList.get().isLoaded(modId)
: LoadingModList.get().getMods().stream()
.map(IModInfo::getModId)
.anyMatch(modId::equals);
}

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
for (var addon : Addons.values()) {
if (mixinClassName.contains(addon.getModId())) {
return addon.isLoaded();
}
if (mixinClassName.contains("aecapfix")) {
return isModLoaded("aecapfix");
}

if (mixinClassName.contains("ae2wtlib")) {
return isModLoaded("ae2wtlib");
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/appliede/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
"key.appliede.emc_tiered": "EMC^%s",
"tooltip.appliede.transmutable": "Transmutable from EMC (Shift+Click/Scroll)",
"tooltip.appliede.owner": "Owner: %s",
"tooltip.appliede.not_installed.ae2wtlib": "AE2WTLib not installed."
"tooltip.appliede.not_installed": "%s not installed."
}
2 changes: 1 addition & 1 deletion src/main/resources/assets/appliede/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
"key.appliede.emc_tiered": "EMC^%s",
"tooltip.appliede.transmutable": "转化为EMC (Shift+点击/滚动)",
"tooltip.appliede.owner": "所有者: %s",
"tooltip.appliede.not_installed.ae2wtlib": "AE2WTLib未安装"
"tooltip.appliede.not_installed": "%s未安装"
}

0 comments on commit 50ebb98

Please sign in to comment.