diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/ChemicalContainerItemStrategy.java b/src/main/java/me/ramidzkh/mekae2/ae2/ChemicalContainerItemStrategy.java index 1469875..c204acc 100644 --- a/src/main/java/me/ramidzkh/mekae2/ae2/ChemicalContainerItemStrategy.java +++ b/src/main/java/me/ramidzkh/mekae2/ae2/ChemicalContainerItemStrategy.java @@ -12,7 +12,6 @@ import net.minecraft.world.item.ItemStack; import me.ramidzkh.mekae2.MekCapabilities; -import me.ramidzkh.mekae2.util.ChemicalBridge; import mekanism.api.Action; import mekanism.api.chemical.gas.GasStack; import mekanism.api.chemical.infuse.InfusionStack; @@ -83,7 +82,7 @@ public ItemStack findCarriedContext(Player player, AbstractContainerMenu menu) { @Override public long extract(ItemStack context, MekanismKey what, long amount, Actionable mode) { - var stack = ChemicalBridge.withAmount(what.getStack(), amount); + var stack = what.withAmount(amount); var action = Action.fromFluidAction(mode.getFluidAction()); if (stack instanceof GasStack gas) { @@ -105,7 +104,7 @@ public long extract(ItemStack context, MekanismKey what, long amount, Actionable @Override public long insert(ItemStack context, MekanismKey what, long amount, Actionable mode) { - var stack = ChemicalBridge.withAmount(what.getStack(), amount); + var stack = what.withAmount(amount); var action = Action.fromFluidAction(mode.getFluidAction()); if (stack instanceof GasStack gas) { diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/ChemicalIngredientConverter.java b/src/main/java/me/ramidzkh/mekae2/ae2/ChemicalIngredientConverter.java index cf9f3fa..51e11b9 100644 --- a/src/main/java/me/ramidzkh/mekae2/ae2/ChemicalIngredientConverter.java +++ b/src/main/java/me/ramidzkh/mekae2/ae2/ChemicalIngredientConverter.java @@ -2,7 +2,6 @@ import org.jetbrains.annotations.Nullable; -import me.ramidzkh.mekae2.util.ChemicalBridge; import mekanism.api.chemical.ChemicalStack; import mezz.jei.api.ingredients.IIngredientType; @@ -22,7 +21,7 @@ public IIngredientType getIngredientType() { @Override public S getIngredientFromStack(GenericStack stack) { if (stack.what() instanceof MekanismKey key) { - return ChemicalBridge.withAmount((S) key.getStack(), Math.max(1, stack.amount())); + return (S) key.withAmount(Math.max(1, stack.amount())); } else { return null; } diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/ChemicalP2PTunnelPart.java b/src/main/java/me/ramidzkh/mekae2/ae2/ChemicalP2PTunnelPart.java index d8faac0..b7d0b22 100644 --- a/src/main/java/me/ramidzkh/mekae2/ae2/ChemicalP2PTunnelPart.java +++ b/src/main/java/me/ramidzkh/mekae2/ae2/ChemicalP2PTunnelPart.java @@ -95,7 +95,7 @@ public boolean isValid(int tank, S stack) { @Override public S insertChemical(int tank, S stack, Action action) { - var total = 0; + var total = 0L; var outputTunnels = part.getOutputs().size(); var amount = stack.getAmount(); diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/GenericStackChemicalStorage.java b/src/main/java/me/ramidzkh/mekae2/ae2/GenericStackChemicalStorage.java index d62c6e6..fb4e36f 100644 --- a/src/main/java/me/ramidzkh/mekae2/ae2/GenericStackChemicalStorage.java +++ b/src/main/java/me/ramidzkh/mekae2/ae2/GenericStackChemicalStorage.java @@ -41,7 +41,7 @@ public int getTanks() { @Override public S getChemicalInTank(int tank) { if (inv.getKey(tank) instanceof MekanismKey what && what.getForm() == form) { - return (S) ChemicalBridge.withAmount(what.getStack(), inv.getAmount(tank)); + return (S) what.withAmount(inv.getAmount(tank)); } return getEmptyStack(); @@ -90,7 +90,7 @@ public S extractChemical(int tank, long amount, Action action) { var extracted = inv.extract(tank, what, amount, Actionable.of(action.toFluidAction())); if (extracted > 0) { - return (S) ChemicalBridge.withAmount(what.getStack(), extracted); + return (S) what.withAmount(extracted); } return getEmptyStack(); diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKey.java b/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKey.java index 7bd27b5..3bb106c 100644 --- a/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKey.java +++ b/src/main/java/me/ramidzkh/mekae2/ae2/MekanismKey.java @@ -57,6 +57,10 @@ public ChemicalStack getStack() { return stack; } + public ChemicalStack withAmount(long amount) { + return ChemicalBridge.withAmount(stack, amount); + } + public byte getForm() { if (stack instanceof GasStack) { return GAS; diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/stack/ChemicalHandlerFacade.java b/src/main/java/me/ramidzkh/mekae2/ae2/stack/ChemicalHandlerFacade.java new file mode 100644 index 0000000..245d365 --- /dev/null +++ b/src/main/java/me/ramidzkh/mekae2/ae2/stack/ChemicalHandlerFacade.java @@ -0,0 +1,99 @@ +package me.ramidzkh.mekae2.ae2.stack; + +import org.jetbrains.annotations.Nullable; + +import net.minecraft.network.chat.Component; + +import me.ramidzkh.mekae2.AMText; +import me.ramidzkh.mekae2.ae2.MekanismKey; +import mekanism.api.Action; +import mekanism.api.chemical.IChemicalHandler; + +import appeng.api.config.Actionable; +import appeng.api.networking.security.IActionSource; +import appeng.api.stacks.AEKey; +import appeng.api.stacks.KeyCounter; +import appeng.api.storage.MEStorage; +import appeng.core.localization.GuiText; + +public record ChemicalHandlerFacade(@Nullable IChemicalHandler[] handlers, boolean extractableOnly, + Runnable changeListener) implements MEStorage { + + @Override + public long insert(AEKey what, long amount, Actionable mode, IActionSource source) { + if (!(what instanceof MekanismKey key)) { + return 0; + } + + var handler = handlers[key.getForm()]; + + if (handler == null) { + return 0; + } + + var inserted = amount - handler.insertChemical(key.withAmount(amount), + Action.fromFluidAction(mode.getFluidAction())).getAmount(); + + if (inserted > 0 && mode == Actionable.MODULATE) { + if (this.changeListener != null) { + this.changeListener.run(); + } + } + + return inserted; + } + + @Override + public long extract(AEKey what, long amount, Actionable mode, IActionSource source) { + if (!(what instanceof MekanismKey key)) { + return 0; + } + + var handler = handlers[key.getForm()]; + + if (handler == null) { + return 0; + } + + var extracted = handler.extractChemical(key.withAmount(amount), + Action.fromFluidAction(mode.getFluidAction())).getAmount(); + + if (extracted > 0 && mode == Actionable.MODULATE) { + if (this.changeListener != null) { + this.changeListener.run(); + } + } + + return extracted; + } + + @Override + public Component getDescription() { + return GuiText.ExternalStorage.text(AMText.CHEMICAL); + } + + @Override + public void getAvailableStacks(KeyCounter out) { + for (var handler : handlers) { + if (handler == null) { + continue; + } + + for (var i = 0; i < handler.getTanks(); i++) { + // Skip resources that cannot be extracted if that filter was enabled + var stack = handler.getChemicalInTank(i); + var key = MekanismKey.of(stack); + + if (key == null) { + continue; + } + + if (extractableOnly && handler.extractChemical(stack, Action.SIMULATE).isEmpty()) { + continue; + } + + out.add(key, stack.getAmount()); + } + } + } +} diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/stack/CompositeFormStorage.java b/src/main/java/me/ramidzkh/mekae2/ae2/stack/CompositeFormStorage.java deleted file mode 100644 index e97598e..0000000 --- a/src/main/java/me/ramidzkh/mekae2/ae2/stack/CompositeFormStorage.java +++ /dev/null @@ -1,59 +0,0 @@ -package me.ramidzkh.mekae2.ae2.stack; - -import java.util.Map; -import java.util.Objects; - -import net.minecraft.network.chat.Component; - -import me.ramidzkh.mekae2.ae2.MekanismKey; - -import appeng.api.config.Actionable; -import appeng.api.networking.security.IActionSource; -import appeng.api.stacks.AEKey; -import appeng.api.stacks.KeyCounter; -import appeng.api.storage.MEStorage; -import appeng.core.localization.GuiText; -import appeng.me.storage.NullInventory; - -record CompositeFormStorage(Map storages) implements MEStorage { - - @Override - public boolean isPreferredStorageFor(AEKey what, IActionSource source) { - return getStorage(what).isPreferredStorageFor(what, source); - } - - @Override - public long insert(AEKey what, long amount, Actionable mode, IActionSource source) { - return getStorage(what).insert(what, amount, mode, source); - } - - @Override - public long extract(AEKey what, long amount, Actionable mode, IActionSource source) { - return getStorage(what).extract(what, amount, mode, source); - } - - /** - * Describes the types of storage represented by this object. - */ - @Override - public Component getDescription() { - return GuiText.ExternalStorage.text(Component.literal("Chemicals")); - } - - @Override - public void getAvailableStacks(KeyCounter out) { - for (var storage : storages.values()) { - storage.getAvailableStacks(out); - } - } - - private MEStorage getStorage(AEKey key) { - MEStorage storage = null; - - if (key instanceof MekanismKey mekanismKey) { - storage = storages.get(mekanismKey.getForm()); - } - - return Objects.requireNonNullElse(storage, NullInventory.of()); - } -} diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/stack/HandlerStrategy.java b/src/main/java/me/ramidzkh/mekae2/ae2/stack/HandlerStrategy.java deleted file mode 100644 index 8d0b5fa..0000000 --- a/src/main/java/me/ramidzkh/mekae2/ae2/stack/HandlerStrategy.java +++ /dev/null @@ -1,114 +0,0 @@ -package me.ramidzkh.mekae2.ae2.stack; - -import java.util.Set; - -import org.jetbrains.annotations.Nullable; - -import me.ramidzkh.mekae2.ae2.MekanismKey; -import me.ramidzkh.mekae2.ae2.MekanismKeyType; -import me.ramidzkh.mekae2.util.ChemicalBridge; -import mekanism.api.Action; -import mekanism.api.chemical.IChemicalHandler; - -import appeng.api.config.Actionable; -import appeng.api.stacks.AEKey; -import appeng.api.stacks.AEKeyType; -import appeng.api.stacks.GenericStack; -import appeng.api.stacks.KeyCounter; -import appeng.me.storage.ExternalStorageFacade; - -class HandlerStrategy { - - public static ExternalStorageFacade getFacade(IChemicalHandler handler) { - return new ExternalStorageFacade() { - @Override - public int getSlots() { - return handler.getTanks(); - } - - @Nullable - @Override - public GenericStack getStackInSlot(int slot) { - var stack = handler.getChemicalInTank(slot); - var key = MekanismKey.of(stack); - - if (key == null) { - return null; - } - - return new GenericStack(key, stack.getAmount()); - } - - @Override - public AEKeyType getKeyType() { - return MekanismKeyType.TYPE; - } - - @Override - public void getAvailableStacks(KeyCounter out) { - for (var i = 0; i < handler.getTanks(); i++) { - // Skip resources that cannot be extracted if that filter was enabled - var stack = handler.getChemicalInTank(i); - var key = MekanismKey.of(stack); - - if (key == null) { - continue; - } - - if (extractableOnly && handler.extractChemical(stack, Action.SIMULATE).isEmpty()) { - continue; - } - - out.add(key, stack.getAmount()); - } - } - - @Override - protected int insertExternal(AEKey what, int amount, Actionable mode) { - return (int) HandlerStrategy.insert(handler, what, amount, mode); - } - - @Override - public boolean containsAnyFuzzy(Set keys) { - for (var i = 0; i < handler.getTanks(); i++) { - var what = MekanismKey.of(handler.getChemicalInTank(i)); - - if (what != null && keys.contains(what.dropSecondary())) { - return true; - } - } - - return false; - } - - @Override - protected int extractExternal(AEKey what, int amount, Actionable mode) { - return (int) HandlerStrategy.extract(handler, what, amount, mode); - } - }; - } - - public static long extract(IChemicalHandler handler, AEKey what, long amount, Actionable mode) { - if (!(what instanceof MekanismKey key)) { - return 0; - } - - var stack = ChemicalBridge.withAmount(key.getStack(), amount); - return handler.extractChemical(stack, Action.fromFluidAction(mode.getFluidAction())).getAmount(); - } - - @Nullable - public static AEKey getStackInTank(int slot, IChemicalHandler handler) { - var stack = handler.getChemicalInTank(slot); - return MekanismKey.of(stack); - } - - public static long insert(IChemicalHandler handler, AEKey what, long amount, Actionable mode) { - if (what instanceof MekanismKey key) { - return amount - handler.insertChemical(ChemicalBridge.withAmount(key.getStack(), amount), - Action.fromFluidAction(mode.getFluidAction())).getAmount(); - } - - return 0; - } -} diff --git a/src/main/java/me/ramidzkh/mekae2/ae2/stack/MekanismExternalStorageStrategy.java b/src/main/java/me/ramidzkh/mekae2/ae2/stack/MekanismExternalStorageStrategy.java index 561043d..a016482 100644 --- a/src/main/java/me/ramidzkh/mekae2/ae2/stack/MekanismExternalStorageStrategy.java +++ b/src/main/java/me/ramidzkh/mekae2/ae2/stack/MekanismExternalStorageStrategy.java @@ -1,8 +1,5 @@ package me.ramidzkh.mekae2.ae2.stack; -import java.util.HashMap; -import java.util.Map; - import org.jetbrains.annotations.Nullable; import net.minecraft.core.BlockPos; @@ -10,7 +7,6 @@ import net.minecraft.server.level.ServerLevel; import me.ramidzkh.mekae2.MekCapabilities; -import me.ramidzkh.mekae2.ae2.MekanismKey; import mekanism.api.chemical.IChemicalHandler; import appeng.api.behaviors.ExternalStorageStrategy; @@ -19,42 +15,41 @@ public class MekanismExternalStorageStrategy implements ExternalStorageStrategy { - private final Map> lookups; + private final BlockApiCache[] lookups; private final Direction fromSide; public MekanismExternalStorageStrategy(ServerLevel level, BlockPos fromPos, Direction fromSide) { - this.lookups = Map.of( - MekanismKey.GAS, BlockApiCache.create(MekCapabilities.GAS_HANDLER_CAPABILITY, level, fromPos), - MekanismKey.INFUSION, BlockApiCache.create(MekCapabilities.INFUSION_HANDLER_CAPABILITY, level, fromPos), - MekanismKey.PIGMENT, BlockApiCache.create(MekCapabilities.PIGMENT_HANDLER_CAPABILITY, level, fromPos), - MekanismKey.SLURRY, BlockApiCache.create(MekCapabilities.SLURRY_HANDLER_CAPABILITY, level, fromPos)); + this.lookups = new BlockApiCache[] { + BlockApiCache.create(MekCapabilities.GAS_HANDLER_CAPABILITY, level, fromPos), + BlockApiCache.create(MekCapabilities.INFUSION_HANDLER_CAPABILITY, level, fromPos), + BlockApiCache.create(MekCapabilities.PIGMENT_HANDLER_CAPABILITY, level, fromPos), + BlockApiCache.create(MekCapabilities.SLURRY_HANDLER_CAPABILITY, level, fromPos) }; this.fromSide = fromSide; } @Nullable @Override public MEStorage createWrapper(boolean extractableOnly, Runnable injectOrExtractCallback) { - var storages = new HashMap(); + var handlers = new IChemicalHandler[4]; + var empty = true; - for (var entry : lookups.entrySet()) { - var storage = entry.getValue().find(fromSide); + for (int i = 0; i < 4; i++) { + var storage = lookups[i].find(fromSide); if (storage == null) { continue; } - var result = HandlerStrategy.getFacade(storage); - result.setChangeListener(injectOrExtractCallback); - result.setExtractableOnly(extractableOnly); - storages.put(entry.getKey(), result); + handlers[i] = storage; + empty = false; } - if (storages.isEmpty()) { + if (empty) { return null; } - return new CompositeFormStorage(storages); + return new ChemicalHandlerFacade(handlers, extractableOnly, injectOrExtractCallback); } } 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 934ad2a..01190bf 100644 --- a/src/main/java/me/ramidzkh/mekae2/ae2/stack/MekanismStackExportStrategy.java +++ b/src/main/java/me/ramidzkh/mekae2/ae2/stack/MekanismStackExportStrategy.java @@ -1,7 +1,5 @@ package me.ramidzkh.mekae2.ae2.stack; -import java.util.Map; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -11,7 +9,6 @@ import me.ramidzkh.mekae2.MekCapabilities; import me.ramidzkh.mekae2.ae2.MekanismKey; -import me.ramidzkh.mekae2.util.ChemicalBridge; import mekanism.api.Action; import mekanism.api.chemical.IChemicalHandler; @@ -25,17 +22,17 @@ public class MekanismStackExportStrategy implements StackExportStrategy { private static final Logger LOGGER = LoggerFactory.getLogger(MekanismStackExportStrategy.class); - private final Map> lookups; + private final BlockApiCache[] lookups; private final Direction fromSide; public MekanismStackExportStrategy(ServerLevel level, BlockPos fromPos, Direction fromSide) { - this.lookups = Map.of( - MekanismKey.GAS, BlockApiCache.create(MekCapabilities.GAS_HANDLER_CAPABILITY, level, fromPos), - MekanismKey.INFUSION, BlockApiCache.create(MekCapabilities.INFUSION_HANDLER_CAPABILITY, level, fromPos), - MekanismKey.PIGMENT, BlockApiCache.create(MekCapabilities.PIGMENT_HANDLER_CAPABILITY, level, fromPos), - MekanismKey.SLURRY, BlockApiCache.create(MekCapabilities.SLURRY_HANDLER_CAPABILITY, level, fromPos)); + this.lookups = new BlockApiCache[] { + BlockApiCache.create(MekCapabilities.GAS_HANDLER_CAPABILITY, level, fromPos), + BlockApiCache.create(MekCapabilities.INFUSION_HANDLER_CAPABILITY, level, fromPos), + BlockApiCache.create(MekCapabilities.PIGMENT_HANDLER_CAPABILITY, level, fromPos), + BlockApiCache.create(MekCapabilities.SLURRY_HANDLER_CAPABILITY, level, fromPos) }; this.fromSide = fromSide; } @@ -45,7 +42,7 @@ public long transfer(StackTransferContext context, AEKey what, long amount) { return 0; } - var storage = lookups.get(mekanismKey.getForm()).find(fromSide); + var storage = lookups[mekanismKey.getForm()].find(fromSide); if (storage == null) { return 0; @@ -62,7 +59,7 @@ public long transfer(StackTransferContext context, AEKey what, long amount) { Actionable.SIMULATE); var wasInserted = extracted - - storage.insertChemical(ChemicalBridge.withAmount(mekanismKey.getStack(), extracted), + - storage.insertChemical(mekanismKey.withAmount(extracted), Action.SIMULATE).getAmount(); if (wasInserted > 0) { @@ -75,7 +72,7 @@ public long transfer(StackTransferContext context, AEKey what, long amount) { Actionable.MODULATE); wasInserted = extracted - - storage.insertChemical(ChemicalBridge.withAmount(mekanismKey.getStack(), extracted), + - storage.insertChemical(mekanismKey.withAmount(extracted), Action.EXECUTE).getAmount(); if (wasInserted < extracted) { @@ -94,13 +91,13 @@ public long push(AEKey what, long amount, Actionable mode) { return 0; } - var storage = lookups.get(mekanismKey.getForm()).find(fromSide); + var storage = lookups[mekanismKey.getForm()].find(fromSide); if (storage == null) { return 0; } - return amount - storage.insertChemical(ChemicalBridge.withAmount(mekanismKey.getStack(), amount), + return amount - storage.insertChemical(mekanismKey.withAmount(amount), Action.fromFluidAction(mode.getFluidAction())).getAmount(); } 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 352415e..06a9ba1 100644 --- a/src/main/java/me/ramidzkh/mekae2/ae2/stack/MekanismStackImportStrategy.java +++ b/src/main/java/me/ramidzkh/mekae2/ae2/stack/MekanismStackImportStrategy.java @@ -1,7 +1,5 @@ package me.ramidzkh.mekae2.ae2.stack; -import java.util.List; - import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; @@ -9,7 +7,6 @@ import me.ramidzkh.mekae2.MekCapabilities; import me.ramidzkh.mekae2.ae2.MekanismKey; import me.ramidzkh.mekae2.ae2.MekanismKeyType; -import me.ramidzkh.mekae2.util.ChemicalBridge; import mekanism.api.Action; import mekanism.api.chemical.IChemicalHandler; @@ -22,16 +19,17 @@ @SuppressWarnings("UnstableApiUsage") public class MekanismStackImportStrategy implements StackImportStrategy { - private final List> lookups; + private final BlockApiCache[] lookups; private final Direction fromSide; public MekanismStackImportStrategy(ServerLevel level, BlockPos fromPos, Direction fromSide) { - this.lookups = List.of(BlockApiCache.create(MekCapabilities.GAS_HANDLER_CAPABILITY, level, fromPos), + this.lookups = new BlockApiCache[] { + BlockApiCache.create(MekCapabilities.GAS_HANDLER_CAPABILITY, level, fromPos), BlockApiCache.create(MekCapabilities.INFUSION_HANDLER_CAPABILITY, level, fromPos), BlockApiCache.create(MekCapabilities.PIGMENT_HANDLER_CAPABILITY, level, fromPos), - BlockApiCache.create(MekCapabilities.SLURRY_HANDLER_CAPABILITY, level, fromPos)); + BlockApiCache.create(MekCapabilities.SLURRY_HANDLER_CAPABILITY, level, fromPos) }; this.fromSide = fromSide; } @@ -72,7 +70,7 @@ public boolean transfer(StackTransferContext context) { // Try to simulate-extract it var amount = adjacentHandler - .extractChemical(ChemicalBridge.withAmount(stack, amountForThisResource), Action.EXECUTE) + .extractChemical(resource.withAmount(amountForThisResource), Action.EXECUTE) .getAmount(); if (amount > 0) { @@ -83,7 +81,7 @@ public boolean transfer(StackTransferContext context) { // Be nice and try to give the overflow back var leftover = amount - inserted; leftover = adjacentHandler - .insertChemical(ChemicalBridge.withAmount(stack, leftover), Action.EXECUTE).getAmount(); + .insertChemical(resource.withAmount(leftover), Action.EXECUTE).getAmount(); if (leftover > 0) { AELog.warn( diff --git a/src/main/java/me/ramidzkh/mekae2/integration/jade/package-info.java b/src/main/java/me/ramidzkh/mekae2/integration/jade/package-info.java new file mode 100644 index 0000000..40ec270 --- /dev/null +++ b/src/main/java/me/ramidzkh/mekae2/integration/jade/package-info.java @@ -0,0 +1,7 @@ +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +package me.ramidzkh.mekae2.integration.jade; + +import javax.annotation.ParametersAreNonnullByDefault; + +import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/main/java/me/ramidzkh/mekae2/AMJEIPlugin.java b/src/main/java/me/ramidzkh/mekae2/integration/jei/AMJEIPlugin.java similarity index 83% rename from src/main/java/me/ramidzkh/mekae2/AMJEIPlugin.java rename to src/main/java/me/ramidzkh/mekae2/integration/jei/AMJEIPlugin.java index be6222c..69b3675 100644 --- a/src/main/java/me/ramidzkh/mekae2/AMJEIPlugin.java +++ b/src/main/java/me/ramidzkh/mekae2/integration/jei/AMJEIPlugin.java @@ -1,18 +1,21 @@ -package me.ramidzkh.mekae2; +package me.ramidzkh.mekae2.integration.jei; import net.minecraft.resources.ResourceLocation; +import me.ramidzkh.mekae2.AppliedMekanistics; import me.ramidzkh.mekae2.ae2.ChemicalIngredientConverter; import mekanism.api.IMekanismAccess; import mezz.jei.api.IModPlugin; import mezz.jei.api.JeiPlugin; +import mezz.jei.api.runtime.IJeiRuntime; import appeng.api.integrations.jei.IngredientConverters; @JeiPlugin public class AMJEIPlugin implements IModPlugin { - public AMJEIPlugin() { + @Override + public void onRuntimeAvailable(IJeiRuntime jeiRuntime) { var helper = IMekanismAccess.INSTANCE.jeiHelper(); IngredientConverters diff --git a/src/main/java/me/ramidzkh/mekae2/integration/jei/package-info.java b/src/main/java/me/ramidzkh/mekae2/integration/jei/package-info.java new file mode 100644 index 0000000..3242e34 --- /dev/null +++ b/src/main/java/me/ramidzkh/mekae2/integration/jei/package-info.java @@ -0,0 +1,7 @@ +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +package me.ramidzkh.mekae2.integration.jei; + +import javax.annotation.ParametersAreNonnullByDefault; + +import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/main/java/me/ramidzkh/mekae2/qio/QioSupport.java b/src/main/java/me/ramidzkh/mekae2/qio/QioSupport.java index 31d76df..9137985 100644 --- a/src/main/java/me/ramidzkh/mekae2/qio/QioSupport.java +++ b/src/main/java/me/ramidzkh/mekae2/qio/QioSupport.java @@ -18,7 +18,6 @@ import me.ramidzkh.mekae2.AppliedMekanistics; import mekanism.api.inventory.qio.IQIOComponent; -import appeng.api.features.IPlayerRegistry; import appeng.api.networking.GridHelper; import appeng.api.storage.MEStorage; @@ -62,9 +61,8 @@ public LazyOptional getCapability(@NotNull Capability capability, break out; } - var owner = IPlayerRegistry.getMapping(object.getLevel()) - .getProfileId(source.getOwningPlayerId()); - var adapter = new QioStorageAdapter<>((BlockEntity & IQIOComponent) object, arg, owner); + var adapter = new QioStorageAdapter<>((BlockEntity & IQIOComponent) object, arg, + source.getOwningPlayerProfileId()); if (adapter.getFrequency() != null) { return LazyOptional.of(() -> adapter).cast(); diff --git a/src/main/java/me/ramidzkh/mekae2/qio/package-info.java b/src/main/java/me/ramidzkh/mekae2/qio/package-info.java new file mode 100644 index 0000000..a7a6084 --- /dev/null +++ b/src/main/java/me/ramidzkh/mekae2/qio/package-info.java @@ -0,0 +1,7 @@ +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +package me.ramidzkh.mekae2.qio; + +import javax.annotation.ParametersAreNonnullByDefault; + +import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/main/resources/appmek.mixins.json b/src/main/resources/appmek.mixins.json deleted file mode 100644 index a69b99c..0000000 --- a/src/main/resources/appmek.mixins.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "minVersion": "0.8", - "required": true, - "package": "me.ramidzkh.mekae2.mixin", - "compatibilityLevel": "JAVA_17", - "mixins": [], - "injectors": { - "defaultRequire": 1 - } -}