diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6fc8fc3..1c36760 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -33,8 +33,9 @@ jobs: with: files: build/libs/Applied-Mekanistics-${{ github.event.release.tag_name }}.jar tag_name: ${{ github.event.release.tag_name }} - - name: Upload to CurseForge - run: ./gradlew curseforge --max-workers 1 + - name: Upload to external sites + run: ./gradlew curseforge modrinth --max-workers 1 env: APPMEK_VERSION: ${{ github.event.release.tag_name }} CURSEFORGE: ${{ secrets.CURSEFORGE }} + MODRINTH: ${{ secrets.MODRINTH }} diff --git a/.gitignore b/.gitignore index c10d7db..eb55e24 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,3 @@ .vscode/ build/ run/ - -# Temporary solution to the Mekanism question @ 9ec9ae8 -# libs/ diff --git a/build.gradle b/build.gradle index 24aee14..7f3fb06 100644 --- a/build.gradle +++ b/build.gradle @@ -1,25 +1,10 @@ -buildscript { - repositories { - maven { - name = "MinecraftForge" - url = uri("https://files.minecraftforge.net/maven/") - } - - mavenCentral() - } - - dependencies { - classpath(group: "net.minecraftforge.gradle", name: "ForgeGradle", version: "5.1.+", changing: true) - } -} - plugins { + id("net.minecraftforge.gradle") version "5.1.+" id("com.matthewprenger.cursegradle") version "1.4.0" - id("com.diffplug.spotless") version "6.4.1" + id("com.diffplug.spotless") version "6.7.2" + id("com.modrinth.minotaur") version "2.3.3" } -apply(plugin: "net.minecraftforge.gradle") - group = "me.ramidzkh" version = System.getenv("APPMEK_VERSION") ?: "0.0.0" @@ -58,8 +43,8 @@ dependencies { compileOnly(fg.deobf("mekanism:Mekanism:${minecraft_version}-${mekanism_version}:api")) runtimeOnly(fg.deobf("mekanism:Mekanism:${minecraft_version}-${mekanism_version}:all")) - compileOnly(fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}:api")) - runtimeOnly(fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}")) + compileOnly(fg.deobf("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}")) + runtimeOnly(fg.deobf("mezz.jei:jei-${minecraft_version}-forge:${jei_version}")) } sourceSets { @@ -210,3 +195,32 @@ System.getenv("CURSEFORGE")?.with { String key -> } } } + +//////////////// +// Modrinth +modrinth { + token.set(System.getenv("MODRINTH")) + projectId.set("applied-mekanistics") + changelog.set("View changelog at [the release page](https://github.com/AppliedEnergistics/Applied-Mekanistics/releases/tag/${version})") + versionNumber.set(project.version) + + if (version.contains("alpha")) { + versionType.set("alpha") + } else if (version.contains("beta")) { + versionType.set("beta") + } else { + versionType.set("release") + } + + uploadFile.set(jar) + gameVersions.add(minecraft_version) + + dependencies { + required.project("ae2") + required.project("mekanism") + } +} + +tasks.modrinth.onlyIf { + System.getenv("MODRINTH") +} diff --git a/gradle.properties b/gradle.properties index 020a7e9..ee312a7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ -minecraft_version=1.18.2 -forge_version=40.1.18 -ae2_version=11.0.0 -mekanism_version=10.2.1.461 -jei_version=9.7.0.180 +minecraft_version=1.19 +forge_version=41.1.0 +ae2_version=12.0.1-alpha +mekanism_version=10.3.0.467 +jei_version=11.1.1.239 org.gradle.daemon=false diff --git a/settings.gradle b/settings.gradle index a2e6625..df01aae 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,8 @@ +pluginManagement { + repositories { + gradlePluginPortal() + maven { url = 'https://maven.minecraftforge.net/' } + } +} + rootProject.name = "Applied-Mekanistics" diff --git a/src/main/java/me/ramidzkh/mekae2/AMItems.java b/src/main/java/me/ramidzkh/mekae2/AMItems.java index abbb9ca..8d8e481 100644 --- a/src/main/java/me/ramidzkh/mekae2/AMItems.java +++ b/src/main/java/me/ramidzkh/mekae2/AMItems.java @@ -1,8 +1,6 @@ package me.ramidzkh.mekae2; import net.minecraft.Util; -import net.minecraft.core.Registry; -import net.minecraft.tags.TagKey; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -29,10 +27,6 @@ public class AMItems { private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, AppliedMekanistics.ID); - // These are foreign items, but idk another nice place to put these so /shrug - public static TagKey MEKANISM_TANKS = TagKey.create(Registry.ITEM_REGISTRY, - AppliedMekanistics.id("mekanism_tanks")); - public static void initialize(IEventBus bus) { ITEMS.register(bus); } diff --git a/src/main/java/me/ramidzkh/mekae2/AMMenus.java b/src/main/java/me/ramidzkh/mekae2/AMMenus.java index 75e3f94..f012530 100644 --- a/src/main/java/me/ramidzkh/mekae2/AMMenus.java +++ b/src/main/java/me/ramidzkh/mekae2/AMMenus.java @@ -1,7 +1,6 @@ package me.ramidzkh.mekae2; import net.minecraft.world.inventory.MenuType; -import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; @@ -19,10 +18,6 @@ public class AMMenus { @SuppressWarnings("RedundantTypeArguments") public static void initialize(IEventBus bus) { - bus.addGenericListener(MenuType.class, (RegistryEvent.Register> event) -> { - event.getRegistry().registerAll(PORTABLE_CHEMICAL_CELL_TYPE); - }); - bus.addListener((FMLClientSetupEvent event) -> event.enqueueWork(() -> { InitScreens.>register(PORTABLE_CHEMICAL_CELL_TYPE, MEStorageScreen::new, "/screens/terminals/portable_chemical_cell.json"); diff --git a/src/main/java/me/ramidzkh/mekae2/AMText.java b/src/main/java/me/ramidzkh/mekae2/AMText.java index ffd504b..d99bedf 100644 --- a/src/main/java/me/ramidzkh/mekae2/AMText.java +++ b/src/main/java/me/ramidzkh/mekae2/AMText.java @@ -1,6 +1,6 @@ package me.ramidzkh.mekae2; -import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.network.chat.Component; public enum AMText { QIO_FREQUENCY("qio_frequency"), @@ -12,7 +12,7 @@ public enum AMText { this.key = "text.%s.%s".formatted(AppliedMekanistics.ID, key); } - public TranslatableComponent formatted(Object... params) { - return new TranslatableComponent(this.key, params); + public Component formatted(Object... params) { + return Component.translatable(this.key, params); } } diff --git a/src/main/java/me/ramidzkh/mekae2/AppliedMekanistics.java b/src/main/java/me/ramidzkh/mekae2/AppliedMekanistics.java index fb7b630..3bbf934 100644 --- a/src/main/java/me/ramidzkh/mekae2/AppliedMekanistics.java +++ b/src/main/java/me/ramidzkh/mekae2/AppliedMekanistics.java @@ -4,6 +4,7 @@ import org.jetbrains.annotations.Nullable; import net.minecraft.core.Direction; +import net.minecraft.core.Registry; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; @@ -15,11 +16,11 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.event.AttachCapabilitiesEvent; -import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.registries.RegisterEvent; import me.ramidzkh.mekae2.ae2.ChemicalContainerItemStrategy; import me.ramidzkh.mekae2.ae2.GenericStackChemicalStorage; @@ -65,7 +66,11 @@ public AppliedMekanistics() { bus.addListener(MekAE2DataGenerators::onGatherData); - bus.addGenericListener(AEKeyType.class, (RegistryEvent.Register event) -> { + bus.addListener((RegisterEvent event) -> { + if (!event.getRegistryKey().equals(Registry.BLOCK_REGISTRY)) { + return; + } + AEKeyTypes.register(MekanismKeyType.TYPE); }); @@ -169,6 +174,6 @@ private void initializeUpgrades() { } private void initializeAttunement() { - P2PTunnelAttunement.addItemByTag(AMItems.MEKANISM_TANKS, AMItems.CHEMICAL_P2P_TUNNEL::get); + P2PTunnelAttunement.registerAttunementTag(AMItems.CHEMICAL_P2P_TUNNEL::get); } } diff --git a/src/main/java/me/ramidzkh/mekae2/AppliedMekanisticsClient.java b/src/main/java/me/ramidzkh/mekae2/AppliedMekanisticsClient.java index 1bc530b..5757d0e 100644 --- a/src/main/java/me/ramidzkh/mekae2/AppliedMekanisticsClient.java +++ b/src/main/java/me/ramidzkh/mekae2/AppliedMekanisticsClient.java @@ -1,6 +1,6 @@ package me.ramidzkh.mekae2; -import net.minecraftforge.client.event.ColorHandlerEvent; +import net.minecraftforge.client.event.RegisterColorHandlersEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import me.ramidzkh.mekae2.ae2.AMChemicalStackRenderer; @@ -17,10 +17,10 @@ public static void initialize() { AMChemicalStackRenderer.initialize(bus); } - private static void registerItemColors(ColorHandlerEvent.Item event) { + private static void registerItemColors(RegisterColorHandlersEvent.Item event) { for (var tier : AMItems.Tier.values()) { - event.getItemColors().register(BasicStorageCell::getColor, AMItems.get(tier)::get); - event.getItemColors().register(PortableCellItem::getColor, AMItems.getPortableCell(tier)::get); + event.register(BasicStorageCell::getColor, AMItems.get(tier)::get); + event.register(PortableCellItem::getColor, AMItems.getPortableCell(tier)::get); } } } diff --git a/src/main/java/me/ramidzkh/mekae2/MekCapabilities.java b/src/main/java/me/ramidzkh/mekae2/MekCapabilities.java index b48049c..d315474 100644 --- a/src/main/java/me/ramidzkh/mekae2/MekCapabilities.java +++ b/src/main/java/me/ramidzkh/mekae2/MekCapabilities.java @@ -8,7 +8,6 @@ import mekanism.api.chemical.infuse.IInfusionHandler; import mekanism.api.chemical.pigment.IPigmentHandler; import mekanism.api.chemical.slurry.ISlurryHandler; -import mekanism.api.heat.IHeatHandler; public class MekCapabilities { @@ -26,8 +25,4 @@ public class MekCapabilities { public static final Capability SLURRY_HANDLER_CAPABILITY = CapabilityManager .get(new CapabilityToken<>() { }); - - public static final Capability HEAT_HANDLER_CAPABILITY = CapabilityManager - .get(new CapabilityToken<>() { - }); } diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/AMChemicalStackRenderer.java b/src/main/java/me/ramidzkh/mekae2/ae2/AMChemicalStackRenderer.java index 60d36ac..0268ed8 100644 --- a/src/main/java/me/ramidzkh/mekae2/ae2/AMChemicalStackRenderer.java +++ b/src/main/java/me/ramidzkh/mekae2/ae2/AMChemicalStackRenderer.java @@ -11,7 +11,6 @@ import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; @@ -104,13 +103,17 @@ public Component getDisplayName(MekanismKey stack) { @Override public List getTooltip(MekanismKey stack) { - var list = new ArrayList(); - list.add(getDisplayName(stack)); + var tooltip = new ArrayList(); + tooltip.add(getDisplayName(stack)); - stack.getStack().getAttributes().forEach(attribute -> attribute.addTooltipText(list)); + stack.getStack().getAttributes().forEach(attribute -> attribute.addTooltipText(tooltip)); - // Append the name of the mod by default as mods such as REI would also add that - list.add(new TextComponent(Platform.formatModName(stack.getModId()))); - return list; + // Heuristic: If the last line doesn't include the modname, add it ourselves + var modName = Platform.formatModName(stack.getModId()); + if (tooltip.isEmpty() || !tooltip.get(tooltip.size() - 1).getString().equals(modName)) { + tooltip.add(Component.literal(modName)); + } + + return tooltip; } } diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/ChemicalP2PTunnelPart.java b/src/main/java/me/ramidzkh/mekae2/ae2/ChemicalP2PTunnelPart.java index b15bda4..d8faac0 100644 --- a/src/main/java/me/ramidzkh/mekae2/ae2/ChemicalP2PTunnelPart.java +++ b/src/main/java/me/ramidzkh/mekae2/ae2/ChemicalP2PTunnelPart.java @@ -4,8 +4,8 @@ import net.minecraftforge.common.capabilities.Capability; +import me.ramidzkh.mekae2.AppliedMekanistics; import me.ramidzkh.mekae2.MekCapabilities; -import me.ramidzkh.mekae2.ae2.impl.P2PModels; import me.ramidzkh.mekae2.util.ChemicalBridge; import mekanism.api.Action; import mekanism.api.chemical.Chemical; @@ -28,10 +28,11 @@ import appeng.api.parts.IPartItem; import appeng.api.parts.IPartModel; import appeng.items.parts.PartModels; +import appeng.parts.p2p.P2PModels; public class ChemicalP2PTunnelPart extends MultipleCapabilityP2PTunnelPart { - private static final P2PModels MODELS = new P2PModels("part/chemical_p2p_tunnel"); + private static final P2PModels MODELS = new P2PModels(AppliedMekanistics.id("part/chemical_p2p_tunnel")); public ChemicalP2PTunnelPart(IPartItem partItem) { super(partItem, self -> List.of( diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKey.java b/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKey.java index 3aa9b38..a6e6bf2 100644 --- a/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKey.java +++ b/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKey.java @@ -9,6 +9,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; @@ -34,6 +35,7 @@ public class MekanismKey extends AEKey { private final ChemicalStack stack; private MekanismKey(ChemicalStack stack) { + super(stack.getTextComponent()); this.stack = stack; } @@ -91,6 +93,11 @@ public String getModId() { return stack.getTypeRegistryName().getNamespace(); } + @Override + public ResourceLocation getId() { + return stack.getTypeRegistryName(); + } + @Override public void writeToPacket(FriendlyByteBuf data) { data.writeByte(getForm()); diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKeyType.java b/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKeyType.java index 74df5b9..2031798 100644 --- a/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKeyType.java +++ b/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKeyType.java @@ -4,7 +4,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.network.chat.Component; import me.ramidzkh.mekae2.AppliedMekanistics; import mekanism.api.chemical.gas.GasStack; @@ -22,7 +22,7 @@ public class MekanismKeyType extends AEKeyType { private MekanismKeyType() { super(AppliedMekanistics.id("chemical"), MekanismKey.class, - new TranslatableComponent("gui." + AppliedMekanistics.ID + ".chemical")); + Component.translatable("gui." + AppliedMekanistics.ID + ".chemical")); } @Nullable diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/impl/P2PModels.java b/src/main/java/me/ramidzkh/mekae2/ae2/impl/P2PModels.java deleted file mode 100644 index 916169e..0000000 --- a/src/main/java/me/ramidzkh/mekae2/ae2/impl/P2PModels.java +++ /dev/null @@ -1,52 +0,0 @@ -package me.ramidzkh.mekae2.ae2.impl; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.resources.ResourceLocation; - -import me.ramidzkh.mekae2.AppliedMekanistics; - -import appeng.api.parts.IPartModel; -import appeng.core.AppEng; -import appeng.parts.PartModel; - -public class P2PModels { - - public static final ResourceLocation MODEL_STATUS_OFF = AppEng.makeId("part/p2p/p2p_tunnel_status_off"); - public static final ResourceLocation MODEL_STATUS_ON = AppEng.makeId("part/p2p/p2p_tunnel_status_on"); - public static final ResourceLocation MODEL_STATUS_HAS_CHANNEL = AppEng - .makeId("part/p2p/p2p_tunnel_status_has_channel"); - public static final ResourceLocation MODEL_FREQUENCY = AppEng.makeId("part/p2p/p2p_tunnel_frequency"); - - private final IPartModel modelsOff; - private final IPartModel modelsOn; - private final IPartModel modelsHasChannel; - - public P2PModels(String frontModelPath) { - var frontModel = AppliedMekanistics.id(frontModelPath); - - this.modelsOff = new PartModel(MODEL_STATUS_OFF, MODEL_FREQUENCY, frontModel); - this.modelsOn = new PartModel(MODEL_STATUS_ON, MODEL_FREQUENCY, frontModel); - this.modelsHasChannel = new PartModel(MODEL_STATUS_HAS_CHANNEL, MODEL_FREQUENCY, frontModel); - } - - public IPartModel getModel(boolean hasPower, boolean hasChannel) { - if (hasPower && hasChannel) { - return this.modelsHasChannel; - } else if (hasPower) { - return this.modelsOn; - } else { - return this.modelsOff; - } - } - - public List getModels() { - List result = new ArrayList<>(); - result.add(this.modelsOff); - result.add(this.modelsOn); - result.add(this.modelsHasChannel); - return result; - } - -} diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/impl/package-info.java b/src/main/java/me/ramidzkh/mekae2/ae2/impl/package-info.java deleted file mode 100644 index cd81855..0000000 --- a/src/main/java/me/ramidzkh/mekae2/ae2/impl/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault -package me.ramidzkh.mekae2.ae2.impl; - -import javax.annotation.ParametersAreNonnullByDefault; - -import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/stack/CompositeFormStorage.java b/src/main/java/me/ramidzkh/mekae2/ae2/stack/CompositeFormStorage.java index cb4a4e5..e97598e 100644 --- a/src/main/java/me/ramidzkh/mekae2/ae2/stack/CompositeFormStorage.java +++ b/src/main/java/me/ramidzkh/mekae2/ae2/stack/CompositeFormStorage.java @@ -4,7 +4,6 @@ import java.util.Objects; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; import me.ramidzkh.mekae2.ae2.MekanismKey; @@ -38,7 +37,7 @@ public long extract(AEKey what, long amount, Actionable mode, IActionSource sour */ @Override public Component getDescription() { - return GuiText.ExternalStorage.text(new TextComponent("Chemicals")); + return GuiText.ExternalStorage.text(Component.literal("Chemicals")); } @Override diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/stack/HandlerStrategy.java b/src/main/java/me/ramidzkh/mekae2/ae2/stack/HandlerStrategy.java index 8f11a15..8d0b5fa 100644 --- a/src/main/java/me/ramidzkh/mekae2/ae2/stack/HandlerStrategy.java +++ b/src/main/java/me/ramidzkh/mekae2/ae2/stack/HandlerStrategy.java @@ -29,13 +29,14 @@ public int getSlots() { @Nullable @Override public GenericStack getStackInSlot(int slot) { - var key = getStackInTank(slot, handler); + var stack = handler.getChemicalInTank(slot); + var key = MekanismKey.of(stack); if (key == null) { return null; } - return new GenericStack(key, handler.getChemicalInTank(slot).getAmount()); + return new GenericStack(key, stack.getAmount()); } @Override diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/stack/MekanismStackExportStrategy.java b/src/main/java/me/ramidzkh/mekae2/ae2/stack/MekanismStackExportStrategy.java index 1c2839c..e191ba0 100644 --- a/src/main/java/me/ramidzkh/mekae2/ae2/stack/MekanismStackExportStrategy.java +++ b/src/main/java/me/ramidzkh/mekae2/ae2/stack/MekanismStackExportStrategy.java @@ -2,6 +2,9 @@ import java.util.Map; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; @@ -19,6 +22,7 @@ public class MekanismStackExportStrategy implements StackExportStrategy { + private static final Logger LOGGER = LoggerFactory.getLogger(MekanismStackExportStrategy.class); private final Map> lookups; private final Direction fromSide; @@ -34,7 +38,7 @@ public MekanismStackExportStrategy(ServerLevel level, } @Override - public long transfer(StackTransferContext context, AEKey what, long amount, Actionable mode) { + public long transfer(StackTransferContext context, AEKey what, long amount) { if (!(what instanceof MekanismKey mekanismKey)) { return 0; } @@ -60,17 +64,21 @@ public long transfer(StackTransferContext context, AEKey what, long amount, Acti context.getActionSource(), Actionable.SIMULATE); - var wasInserted = HandlerStrategy.insert(storage, what, extracted, mode); + var wasInserted = HandlerStrategy.insert(storage, what, extracted, Actionable.MODULATE); if (wasInserted > 0) { - if (mode == Actionable.MODULATE) { - StorageHelper.poweredExtraction( - context.getEnergySource(), - inv.getInventory(), - what, - wasInserted, - context.getActionSource(), - Actionable.MODULATE); + extracted = StorageHelper.poweredExtraction( + context.getEnergySource(), + inv.getInventory(), + what, + wasInserted, + context.getActionSource(), + Actionable.MODULATE); + + wasInserted = HandlerStrategy.insert(storage, what, extracted, Actionable.MODULATE); + + if (wasInserted < extracted) { + LOGGER.error("Storage export issue, voided {}x{}", extracted - wasInserted, what); } return wasInserted; diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/stack/MekanismStackImportStrategy.java b/src/main/java/me/ramidzkh/mekae2/ae2/stack/MekanismStackImportStrategy.java index 3f56675..f4c38a3 100644 --- a/src/main/java/me/ramidzkh/mekae2/ae2/stack/MekanismStackImportStrategy.java +++ b/src/main/java/me/ramidzkh/mekae2/ae2/stack/MekanismStackImportStrategy.java @@ -50,7 +50,7 @@ public boolean transfer(StackTransferContext context) { var inv = context.getInternalStorage(); // Try to find an extractable resource that fits our filter - for (var i = 0; i < adjacentHandler.getTanks(); i++) { + for (var i = 0; i < adjacentHandler.getTanks() && remainingTransferAmount > 0; i++) { var resource = HandlerStrategy.getStackInTank(i, adjacentHandler); if (resource == null @@ -75,12 +75,18 @@ public boolean transfer(StackTransferContext context) { if (inserted < amount) { // Be nice and try to give the overflow back - AELog.warn("Extracted %dx%s from adjacent storage and voided it because network refused insert", - amount - inserted, resource); + var leftover = amount - inserted; + leftover -= HandlerStrategy.insert(adjacentHandler, resource, leftover, Actionable.MODULATE); + if (leftover > 0) { + AELog.warn( + "Extracted %dx%s from adjacent storage and voided it because network refused insert", + leftover, resource); + } } var opsUsed = Math.max(1, inserted / MekanismKeyType.TYPE.getAmountPerOperation()); context.reduceOperationsRemaining(opsUsed); + remainingTransferAmount -= inserted; } } diff --git a/src/main/java/me/ramidzkh/mekae2/data/ItemTagsProvider.java b/src/main/java/me/ramidzkh/mekae2/data/ItemTagsProvider.java index f58423c..4c884ce 100644 --- a/src/main/java/me/ramidzkh/mekae2/data/ItemTagsProvider.java +++ b/src/main/java/me/ramidzkh/mekae2/data/ItemTagsProvider.java @@ -10,6 +10,8 @@ import me.ramidzkh.mekae2.AMItems; import me.ramidzkh.mekae2.AppliedMekanistics; +import appeng.api.features.P2PTunnelAttunement; + public class ItemTagsProvider extends net.minecraft.data.tags.ItemTagsProvider { public ItemTagsProvider(DataGenerator generator, BlockTagsProvider blockTagsProvider, @@ -19,10 +21,12 @@ public ItemTagsProvider(DataGenerator generator, BlockTagsProvider blockTagsProv @Override protected void addTags() { - tag(AMItems.MEKANISM_TANKS).addOptional(new ResourceLocation("mekanism", "basic_chemical_tank")); - tag(AMItems.MEKANISM_TANKS).addOptional(new ResourceLocation("mekanism", "advanced_chemical_tank")); - tag(AMItems.MEKANISM_TANKS).addOptional(new ResourceLocation("mekanism", "elite_chemical_tank")); - tag(AMItems.MEKANISM_TANKS).addOptional(new ResourceLocation("mekanism", "ultimate_chemical_tank")); - tag(AMItems.MEKANISM_TANKS).addOptional(new ResourceLocation("mekanism", "creative_chemical_tank")); + var tanks = P2PTunnelAttunement.getAttunementTag(AMItems.CHEMICAL_P2P_TUNNEL::get); + + tag(tanks).addOptional(new ResourceLocation("mekanism", "basic_chemical_tank")); + tag(tanks).addOptional(new ResourceLocation("mekanism", "advanced_chemical_tank")); + tag(tanks).addOptional(new ResourceLocation("mekanism", "elite_chemical_tank")); + tag(tanks).addOptional(new ResourceLocation("mekanism", "ultimate_chemical_tank")); + tag(tanks).addOptional(new ResourceLocation("mekanism", "creative_chemical_tank")); } } diff --git a/src/main/java/me/ramidzkh/mekae2/data/MekAE2DataGenerators.java b/src/main/java/me/ramidzkh/mekae2/data/MekAE2DataGenerators.java index c8997e8..e489ef6 100644 --- a/src/main/java/me/ramidzkh/mekae2/data/MekAE2DataGenerators.java +++ b/src/main/java/me/ramidzkh/mekae2/data/MekAE2DataGenerators.java @@ -1,6 +1,6 @@ package me.ramidzkh.mekae2.data; -import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; +import net.minecraftforge.data.event.GatherDataEvent; public class MekAE2DataGenerators { @@ -9,11 +9,11 @@ public static void onGatherData(GatherDataEvent event) { var existingFileHelper = event.getExistingFileHelper(); var blockTagsProvider = new BlockTagsProvider(generator, existingFileHelper); - generator.addProvider(blockTagsProvider); - generator.addProvider(new ItemTagsProvider(generator, blockTagsProvider, existingFileHelper)); + generator.addProvider(true, blockTagsProvider); + generator.addProvider(true, new ItemTagsProvider(generator, blockTagsProvider, existingFileHelper)); - generator.addProvider(new BlockModelProvider(generator, existingFileHelper)); - generator.addProvider(new ItemModelProvider(generator, existingFileHelper)); - generator.addProvider(new RecipeProvider(generator)); + generator.addProvider(true, new BlockModelProvider(generator, existingFileHelper)); + generator.addProvider(true, new ItemModelProvider(generator, existingFileHelper)); + generator.addProvider(true, new RecipeProvider(generator)); } } diff --git a/src/main/java/me/ramidzkh/mekae2/data/RecipeProvider.java b/src/main/java/me/ramidzkh/mekae2/data/RecipeProvider.java index b438e02..739be03 100644 --- a/src/main/java/me/ramidzkh/mekae2/data/RecipeProvider.java +++ b/src/main/java/me/ramidzkh/mekae2/data/RecipeProvider.java @@ -58,7 +58,7 @@ protected void buildCraftingRecipes(Consumer consumer) { .requires(cellComponent) .requires(AEBlocks.ENERGY_CELL) .requires(housing) - .unlockedBy("has_" + housing.getRegistryName().getPath(), has(housing)) + .unlockedBy("has_" + housing.builtInRegistryHolder().key().location().getPath(), has(housing)) .unlockedBy("has_energy_cell", has(AEBlocks.ENERGY_CELL)) .save(consumer); } diff --git a/src/main/java/me/ramidzkh/mekae2/item/ChemicalPortableCellItem.java b/src/main/java/me/ramidzkh/mekae2/item/ChemicalPortableCellItem.java index 7cda20c..0a9e880 100644 --- a/src/main/java/me/ramidzkh/mekae2/item/ChemicalPortableCellItem.java +++ b/src/main/java/me/ramidzkh/mekae2/item/ChemicalPortableCellItem.java @@ -20,7 +20,7 @@ public ChemicalPortableCellItem(MenuType menuType, StorageTier tier, Properti public boolean isBlackListed(ItemStack cellItem, AEKey requestedAddition) { if (requestedAddition instanceof MekanismKey key) { // Disallow storage cells to contain radioactive stuff - return !ChemicalAttributeValidator.process(key.getStack(), ChemicalAttributeValidator.DEFAULT); + return !ChemicalAttributeValidator.DEFAULT.process(key.getStack()); } return true; diff --git a/src/main/java/me/ramidzkh/mekae2/item/ChemicalStorageCell.java b/src/main/java/me/ramidzkh/mekae2/item/ChemicalStorageCell.java index 3164cea..dab08c0 100644 --- a/src/main/java/me/ramidzkh/mekae2/item/ChemicalStorageCell.java +++ b/src/main/java/me/ramidzkh/mekae2/item/ChemicalStorageCell.java @@ -8,8 +8,6 @@ import mekanism.api.chemical.attribute.ChemicalAttributeValidator; import appeng.api.stacks.AEKey; -import appeng.api.upgrades.IUpgradeInventory; -import appeng.api.upgrades.UpgradeInventories; import appeng.items.storage.BasicStorageCell; public class ChemicalStorageCell extends BasicStorageCell { @@ -23,14 +21,9 @@ public ChemicalStorageCell(Properties properties, ItemLike coreItem, ItemLike ho public boolean isBlackListed(ItemStack cellItem, AEKey requestedAddition) { if (requestedAddition instanceof MekanismKey key) { // Disallow storage cells to contain radioactive stuff - return !ChemicalAttributeValidator.process(key.getStack(), ChemicalAttributeValidator.DEFAULT); + return !ChemicalAttributeValidator.DEFAULT.process(key.getStack()); } return true; } - - @Override - public IUpgradeInventory getUpgrades(ItemStack is) { - return UpgradeInventories.forItem(is, 3); - } } diff --git a/src/main/java/me/ramidzkh/mekae2/qio/QioSupport.java b/src/main/java/me/ramidzkh/mekae2/qio/QioSupport.java index 66b3f11..ee29d0b 100644 --- a/src/main/java/me/ramidzkh/mekae2/qio/QioSupport.java +++ b/src/main/java/me/ramidzkh/mekae2/qio/QioSupport.java @@ -13,6 +13,7 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.event.AttachCapabilitiesEvent; +import net.minecraftforge.registries.ForgeRegistries; import me.ramidzkh.mekae2.AppliedMekanistics; import mekanism.api.inventory.qio.IQIOComponent; @@ -33,7 +34,7 @@ public static void onBlockEntityCapability(AttachCapabilitiesEvent var object = event.getObject(); if (object instanceof IQIOComponent) { - if (DASHBOARD.equals(object.getType().getRegistryName())) { + if (DASHBOARD.equals(ForgeRegistries.BLOCK_ENTITY_TYPES.getKey(object.getType()))) { event.addCapability(AppliedMekanistics.id("qio_storage_monitorable"), new ICapabilityProvider() { @NotNull @Override diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 49fb4db..88ee059 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -13,24 +13,25 @@ modId = "appmek" version = "${version}" displayName = "Applied Mekanistics" description = "Use Mekanism resources through your ME network" +updateJSONURL = "https://api.modrinth.com/updates/applied-mekanistics/forge_updates.json" [[dependencies.appmek]] modId = "forge" mandatory = true -versionRange = "[40.0.0,41.0.0)" +versionRange = "[41.0.0,42.0.0)" ordering = "NONE" side = "BOTH" [[dependencies.appmek]] modId = "ae2" -mandatory = true -versionRange = "[11.0.0,12.0.0)" +mandatory = false +versionRange = "[12.0.0,13.0.0)" ordering = "AFTER" side = "BOTH" [[dependencies.appmek]] modId = "mekanism" mandatory = true -versionRange = "[10.2.1,11.0.0)" +versionRange = "[10.3.0,11.0.0)" ordering = "AFTER" side = "BOTH"