diff --git a/build.gradle b/build.gradle index 5e4447c..2b27b91 100644 --- a/build.gradle +++ b/build.gradle @@ -1092,13 +1092,17 @@ boolean performBuildScriptUpdate() { boolean isNewBuildScriptVersionAvailable() { Map parameters = ["connectTimeout": 10000, "readTimeout": 10000] - String currentBuildScript = getFile("build.gradle").getText() - String currentBuildScriptHash = getVersionHash(currentBuildScript) - String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText() - String availableBuildScriptHash = getVersionHash(availableBuildScript) + try { + String currentBuildScript = getFile("build.gradle").getText() + String currentBuildScriptHash = getVersionHash(currentBuildScript) + String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText() + String availableBuildScriptHash = getVersionHash(availableBuildScript) - boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash - return !isUpToDate + boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash + return !isUpToDate + } catch (Exception ignored) { + return false + } } static String getVersionHash(String buildScriptContent) { diff --git a/gradle.properties b/gradle.properties index 87f6652..7339827 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ modId=crazyae modGroup=dev.beecube31.crazyae2 # Version of your mod. # This field can be left empty if you want your mod's version to be determined by the latest git tag instead. -modVersion=v0.6.0.2 +modVersion=v0.6.0.3 # The name of your jar when you produce builds, not including any versioning info modArchivesBaseName=CrazyAE-1.12.2 # Will update your build.gradle automatically whenever an update is available diff --git a/src/main/java/dev/beecube31/crazyae2/client/gui/implementations/GuiCrazyAEUpgradeable.java b/src/main/java/dev/beecube31/crazyae2/client/gui/implementations/GuiCrazyAEUpgradeable.java index a455b39..f74d925 100644 --- a/src/main/java/dev/beecube31/crazyae2/client/gui/implementations/GuiCrazyAEUpgradeable.java +++ b/src/main/java/dev/beecube31/crazyae2/client/gui/implementations/GuiCrazyAEUpgradeable.java @@ -430,7 +430,7 @@ public List> getPhantomTargets(Object ingredient) { List slots = new ArrayList<>(); if (!this.inventorySlots.inventorySlots.isEmpty()) { for (Slot slot : this.inventorySlots.inventorySlots) { - if (slot instanceof SlotFake && !itemStack.isEmpty()) { + if (slot instanceof SlotFake fakeSlot && fakeSlot.isDraggable() && !itemStack.isEmpty()) { slots.add((IJEITargetSlot) slot); } } diff --git a/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerBreweryMechanical.java b/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerBreweryMechanical.java index 2dfeda9..5c6f09b 100644 --- a/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerBreweryMechanical.java +++ b/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerBreweryMechanical.java @@ -2,8 +2,8 @@ import appeng.api.networking.IGridNode; import dev.beecube31.crazyae2.client.gui.sprites.StateSprite; +import dev.beecube31.crazyae2.common.containers.base.slot.BotaniaSlotFake; import dev.beecube31.crazyae2.common.containers.base.slot.RestrictedSlot; -import dev.beecube31.crazyae2.common.containers.base.slot.SlotFake; import dev.beecube31.crazyae2.common.containers.base.slot.SlotOutput; import dev.beecube31.crazyae2.common.enums.BotaniaMechanicalDeviceType; import dev.beecube31.crazyae2.common.tile.botania.TileMechanicalBrewery; @@ -26,11 +26,11 @@ protected void initSlots() { for (int y = 0; y < 2; y++) { for (int x = 0; x < 3; x++) { - this.addSlotToContainer(new SlotFake(input, x + y * 3, 62 + x * 18, 16 + y * 18, true)); + this.addSlotToContainer(new BotaniaSlotFake(input, x + y * 3, 62 + x * 18, 16 + y * 18, true)); } } - this.addSlotToContainer(new SlotFake(bottle, 0, 80, 53, true).setIIcon(StateSprite.BREW)); + this.addSlotToContainer(new BotaniaSlotFake(bottle, 0, 80, 53, true).setIIcon(StateSprite.BREW)); this.addSlotToContainer(new SlotOutput(output, 0, 80, 87, null)); this.addSlotToContainer(new RestrictedSlot( diff --git a/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerElventradeMechanical.java b/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerElventradeMechanical.java index d693828..58fcb77 100644 --- a/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerElventradeMechanical.java +++ b/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerElventradeMechanical.java @@ -2,8 +2,8 @@ import appeng.api.networking.IGridNode; import dev.beecube31.crazyae2.client.gui.sprites.StateSprite; +import dev.beecube31.crazyae2.common.containers.base.slot.BotaniaSlotFake; import dev.beecube31.crazyae2.common.containers.base.slot.RestrictedSlot; -import dev.beecube31.crazyae2.common.containers.base.slot.SlotFake; import dev.beecube31.crazyae2.common.containers.base.slot.SlotOutput; import dev.beecube31.crazyae2.common.enums.BotaniaMechanicalDeviceType; import dev.beecube31.crazyae2.common.tile.botania.TileMechanicalElventrade; @@ -26,7 +26,7 @@ protected void initSlots() { for (int y = 0; y < 2; y++) { for (int x = 0; x < 8; x++) { - this.addSlotToContainer(new SlotFake(input, x + y * 8, 17 + 18 * x, 14 + 18 * y, true)); + this.addSlotToContainer(new BotaniaSlotFake(input, x + y * 8, 17 + 18 * x, 14 + 18 * y, true)); } } diff --git a/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerManapoolMechanical.java b/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerManapoolMechanical.java index fdc6fc6..6260b95 100644 --- a/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerManapoolMechanical.java +++ b/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerManapoolMechanical.java @@ -1,9 +1,9 @@ package dev.beecube31.crazyae2.common.containers; import appeng.api.networking.IGridNode; +import dev.beecube31.crazyae2.common.containers.base.slot.BotaniaSlotFake; import dev.beecube31.crazyae2.client.gui.sprites.StateSprite; import dev.beecube31.crazyae2.common.containers.base.slot.RestrictedSlot; -import dev.beecube31.crazyae2.common.containers.base.slot.SlotFake; import dev.beecube31.crazyae2.common.containers.base.slot.SlotOutput; import dev.beecube31.crazyae2.common.enums.BotaniaMechanicalDeviceType; import dev.beecube31.crazyae2.common.tile.botania.TileMechanicalManapool; @@ -23,8 +23,8 @@ protected void initSlots() { final IItemHandler input = this.getUpgradeable().getInventoryByName("input"); final IItemHandler output = this.getUpgradeable().getInventoryByName("output"); - this.addSlotToContainer(new SlotFake(input, 0, 70, 30, true)); - this.addSlotToContainer((new SlotFake(input, 1, 89, 30, true)).setIIcon(StateSprite.BOTANIA_CATALYSTS_SLOT)); + this.addSlotToContainer(new BotaniaSlotFake(input, 0, 70, 30, true)); + this.addSlotToContainer((new BotaniaSlotFake(input, 1, 89, 30, true)).setIIcon(StateSprite.BOTANIA_CATALYSTS_SLOT)); this.addSlotToContainer(new SlotOutput(output, 0, 80, 68, null)); diff --git a/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerPetalMechanical.java b/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerPetalMechanical.java index 603797c..7a0bf4f 100644 --- a/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerPetalMechanical.java +++ b/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerPetalMechanical.java @@ -1,9 +1,9 @@ package dev.beecube31.crazyae2.common.containers; import appeng.api.networking.IGridNode; +import dev.beecube31.crazyae2.common.containers.base.slot.BotaniaSlotFake; import dev.beecube31.crazyae2.client.gui.sprites.StateSprite; import dev.beecube31.crazyae2.common.containers.base.slot.RestrictedSlot; -import dev.beecube31.crazyae2.common.containers.base.slot.SlotFake; import dev.beecube31.crazyae2.common.containers.base.slot.SlotOutput; import dev.beecube31.crazyae2.common.enums.BotaniaMechanicalDeviceType; import dev.beecube31.crazyae2.common.tile.botania.TileMechanicalPetal; @@ -25,7 +25,7 @@ protected void initSlots() { for (int y = 0; y < 2; y++) { for (int x = 0; x < 8; x++) { - this.addSlotToContainer(new SlotFake(input, x + y * 8, 17 + 18 * x, 14 + 18 * y, true)); + this.addSlotToContainer(new BotaniaSlotFake(input, x + y * 8, 17 + 18 * x, 14 + 18 * y, true)); } } diff --git a/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerPuredaisyMechanical.java b/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerPuredaisyMechanical.java index df0da62..cefb375 100644 --- a/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerPuredaisyMechanical.java +++ b/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerPuredaisyMechanical.java @@ -2,8 +2,8 @@ import appeng.api.networking.IGridNode; import dev.beecube31.crazyae2.client.gui.sprites.StateSprite; +import dev.beecube31.crazyae2.common.containers.base.slot.BotaniaSlotFake; import dev.beecube31.crazyae2.common.containers.base.slot.RestrictedSlot; -import dev.beecube31.crazyae2.common.containers.base.slot.SlotFake; import dev.beecube31.crazyae2.common.containers.base.slot.SlotOutput; import dev.beecube31.crazyae2.common.enums.BotaniaMechanicalDeviceType; import dev.beecube31.crazyae2.common.tile.botania.TileMechanicalPuredaisy; @@ -23,7 +23,7 @@ protected void initSlots() { final IItemHandler input = this.getUpgradeable().getInventoryByName("input"); final IItemHandler output = this.getUpgradeable().getInventoryByName("output"); - this.addSlotToContainer(new SlotFake(input, 0, 80, 30, true)); + this.addSlotToContainer(new BotaniaSlotFake(input, 0, 80, 30, true)); this.addSlotToContainer(new SlotOutput(output, 0, 80, 68, null)); diff --git a/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerRunealtarMechanical.java b/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerRunealtarMechanical.java index 5ca9e84..65e0a5b 100644 --- a/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerRunealtarMechanical.java +++ b/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerRunealtarMechanical.java @@ -1,8 +1,8 @@ package dev.beecube31.crazyae2.common.containers; import appeng.api.networking.IGridNode; +import dev.beecube31.crazyae2.common.containers.base.slot.BotaniaSlotFake; import dev.beecube31.crazyae2.common.containers.base.slot.RestrictedSlot; -import dev.beecube31.crazyae2.common.containers.base.slot.SlotFake; import dev.beecube31.crazyae2.common.containers.base.slot.SlotOutput; import dev.beecube31.crazyae2.common.enums.BotaniaMechanicalDeviceType; import dev.beecube31.crazyae2.common.tile.botania.TileMechanicalRunealtar; @@ -24,7 +24,7 @@ protected void initSlots() { for (int y = 0; y < 2; y++) { for (int x = 0; x < 8; x++) { - this.addSlotToContainer(new SlotFake(input, x + y * 8, 17 + 18 * x, 14 + 18 * y, true)); + this.addSlotToContainer(new BotaniaSlotFake(input, x + y * 8, 17 + 18 * x, 14 + 18 * y, true)); } } diff --git a/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerTeraplateMechanical.java b/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerTeraplateMechanical.java index 1706c89..6e25b43 100644 --- a/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerTeraplateMechanical.java +++ b/src/main/java/dev/beecube31/crazyae2/common/containers/ContainerTeraplateMechanical.java @@ -1,8 +1,8 @@ package dev.beecube31.crazyae2.common.containers; import appeng.api.networking.IGridNode; +import dev.beecube31.crazyae2.common.containers.base.slot.BotaniaSlotFake; import dev.beecube31.crazyae2.common.containers.base.slot.RestrictedSlot; -import dev.beecube31.crazyae2.common.containers.base.slot.SlotFake; import dev.beecube31.crazyae2.common.containers.base.slot.SlotOutput; import dev.beecube31.crazyae2.common.enums.BotaniaMechanicalDeviceType; import dev.beecube31.crazyae2.common.tile.botania.TileMechanicalTerraplate; @@ -21,12 +21,17 @@ protected void initSlots() { final IItemHandler upgrades = this.getUpgradeable().getInventoryByName("upgrades"); final IItemHandler input = this.getUpgradeable().getInventoryByName("input"); final IItemHandler output = this.getUpgradeable().getInventoryByName("output"); + final IItemHandler marker = this.getUpgradeable().getInventoryByName("findSlot"); - this.addSlotToContainer(new SlotFake(input, 0, 61, 30, true)); - this.addSlotToContainer(new SlotFake(input, 1, 80, 30, true)); - this.addSlotToContainer(new SlotFake(input, 2, 99, 30, true)); + for (int y = 0; y < 2; y++) { + for (int x = 0; x < 7; x++) { + this.addSlotToContainer(new BotaniaSlotFake(input, x + y * 7, 26 + 18 * x, 16 + 18 * y, true)); + } + } + + this.addSlotToContainer(new BotaniaSlotFake(marker, 0, 80, 52, true).setNotDraggable()); - this.addSlotToContainer(new SlotOutput(output, 0, 80, 68, null)); + this.addSlotToContainer(new SlotOutput(output, 0, 80, 86, null)); this.addSlotToContainer(new RestrictedSlot( this.type == BotaniaMechanicalDeviceType.ELVENTRADE ? RestrictedSlot.PlaceableItemType.ELVENTRADE_BLANK_PATTERN diff --git a/src/main/java/dev/beecube31/crazyae2/common/containers/base/slot/BotaniaSlotFake.java b/src/main/java/dev/beecube31/crazyae2/common/containers/base/slot/BotaniaSlotFake.java new file mode 100644 index 0000000..a58fe68 --- /dev/null +++ b/src/main/java/dev/beecube31/crazyae2/common/containers/base/slot/BotaniaSlotFake.java @@ -0,0 +1,25 @@ +package dev.beecube31.crazyae2.common.containers.base.slot; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.items.IItemHandler; + +public class BotaniaSlotFake extends SlotFake { + + public BotaniaSlotFake(final IItemHandler inv, final int idx, final int x, final int y) { + super(inv, idx, x, y); + } + + public BotaniaSlotFake(final IItemHandler inv, final int idx, final int x, final int y, final boolean oneStack) { + super(inv, idx, x, y, oneStack); + } + + @Override + public void putStack(ItemStack is) { + if (!is.isEmpty()) { + is = is.copy(); + is.setCount(1); + } + + super.putStack(is); + } +} diff --git a/src/main/java/dev/beecube31/crazyae2/common/features/Features.java b/src/main/java/dev/beecube31/crazyae2/common/features/Features.java index 4e4758a..998c977 100644 --- a/src/main/java/dev/beecube31/crazyae2/common/features/Features.java +++ b/src/main/java/dev/beecube31/crazyae2/common/features/Features.java @@ -95,9 +95,7 @@ public enum Features implements IFeature { QUANTUM_CHANNELS_MULTIPLIER( new FeatureSet().add("mixin:qcm") ), - PATTERNS_INTERFACE( - new FeatureSet().add("mixin:patterns.interface") - ), + PATTERNS_INTERFACE, DENSE_CPU_COPROCESSORS( new FeatureSet().add("mixin:dense.coprocessor") diff --git a/src/main/java/dev/beecube31/crazyae2/common/networking/packets/orig/PacketInventoryAction.java b/src/main/java/dev/beecube31/crazyae2/common/networking/packets/orig/PacketInventoryAction.java index 4e2974f..6283aec 100644 --- a/src/main/java/dev/beecube31/crazyae2/common/networking/packets/orig/PacketInventoryAction.java +++ b/src/main/java/dev/beecube31/crazyae2/common/networking/packets/orig/PacketInventoryAction.java @@ -11,6 +11,7 @@ import appeng.helpers.InventoryAction; import appeng.util.Platform; import appeng.util.item.AEItemStack; +import dev.beecube31.crazyae2.client.gui.CrazyAESlot; import dev.beecube31.crazyae2.common.containers.base.CrazyAEBaseContainer; import dev.beecube31.crazyae2.common.containers.base.slot.SlotDisconnected; import dev.beecube31.crazyae2.common.containers.base.slot.SlotFake; @@ -130,7 +131,7 @@ public void serverPacketData(final INetworkInfo manager, final CrazyAEPacket pac if (this.action == InventoryAction.PLACE_JEI_GHOST_ITEM) { if (this.slot < sender.openContainer.inventorySlots.size()) { Slot senderSlot = sender.openContainer.inventorySlots.get(this.slot); - if (senderSlot instanceof SlotFake) { + if (senderSlot instanceof SlotFake && (!(senderSlot instanceof CrazyAESlot) || ((CrazyAESlot) senderSlot).isDraggable())) { if (this.slotItem != null) { senderSlot.putStack(this.slotItem.createItemStack()); if (senderSlot.getStack().isEmpty()) { diff --git a/src/main/java/dev/beecube31/crazyae2/common/recipes/botania/RecipeRepo.java b/src/main/java/dev/beecube31/crazyae2/common/recipes/botania/RecipeRepo.java index 2a0f4bc..9da8b07 100644 --- a/src/main/java/dev/beecube31/crazyae2/common/recipes/botania/RecipeRepo.java +++ b/src/main/java/dev/beecube31/crazyae2/common/recipes/botania/RecipeRepo.java @@ -2,17 +2,31 @@ import com.google.common.collect.ImmutableList; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.Loader; import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.ItemStackHandler; import quaternary.botaniatweaks.modules.botania.recipe.AgglomerationRecipe; import quaternary.botaniatweaks.modules.botania.recipe.AgglomerationRecipes; +import vazkii.botania.api.recipe.RecipePetals; import vazkii.botania.common.item.ModItems; +import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.List; import java.util.Optional; public class RecipeRepo { public static ArrayList terraplateRecipes = new ArrayList<>(); + public static boolean isBotaniaTweaksLoaded() { + return Loader.isModLoaded("botania_tweaks") || Loader.isModLoaded("botaniatweaks"); + } + + public static boolean isGodAgglomerationPlateLoaded() { + return Loader.isModLoaded("godagglomerationplate"); + } + public static void copyFromBotaniaTweaks() { terraplateRecipes.clear(); @@ -31,10 +45,132 @@ public static void addDefaultTerrasteelRecipe() { } public static Optional findMatchingRecipe(IItemHandler inv) { + final IItemHandler compactedInv = compactInventory(inv); + for (RecipeTerraplate recipe : terraplateRecipes) { - if(recipe.matches(inv)) + if (recipe.matches(compactedInv)) { return Optional.of(recipe); + } + } + + if (isBotaniaTweaksLoaded()) { + for (AgglomerationRecipe recipe : AgglomerationRecipes.recipes) { + final RecipeTerraplate wrapped = new RecipeTerraplate(recipe); + if (wrapped.matches(compactedInv)) { + return Optional.of(wrapped); + } + } + } + + final Optional botanicAdditionsMatch = findMatchingBotanicAdditionsRecipe(compactedInv); + if (botanicAdditionsMatch.isPresent()) { + return botanicAdditionsMatch; + } + + final Optional godAgglomerationMatch = findMatchingGodAgglomerationRecipe(compactedInv); + if (godAgglomerationMatch.isPresent()) { + return godAgglomerationMatch; + } + + return Optional.empty(); + } + + private static Optional findMatchingBotanicAdditionsRecipe(IItemHandler inv) { + if (!Loader.isModLoaded("botanicadds")) { + return Optional.empty(); + } + + try { + final Class gaiaRecipesClass = Class.forName("tk.zeitheron.botanicadds.api.GaiaPlateRecipes"); + final Field gaiaRecipesField = gaiaRecipesClass.getField("gaiaRecipes"); + final Object recipes = gaiaRecipesField.get(null); + if (!(recipes instanceof List recipeList)) { + return Optional.empty(); + } + + for (Object recipeObj : recipeList) { + if (!(recipeObj instanceof RecipePetals recipePetals)) { + continue; + } + + if (!recipePetals.matches(inv)) { + continue; + } + + int manaCost = 0; + try { + final Method getManaMethod = recipeObj.getClass().getMethod("getMana"); + final Object manaObj = getManaMethod.invoke(recipeObj); + if (manaObj instanceof Number number) { + manaCost = number.intValue(); + } + } catch (ReflectiveOperationException ignored) { + } + + return Optional.of(new RecipeTerraplate(recipePetals.getOutput().copy(), manaCost, RecipeTerraplate.PlateType.GAIA_PLATE)); + } + } catch (ReflectiveOperationException ignored) { } + + return Optional.empty(); + } + + private static Optional findMatchingGodAgglomerationRecipe(IItemHandler inv) { + if (!isGodAgglomerationPlateLoaded()) { + return Optional.empty(); + } + + try { + final Class recipesClass = Class.forName("com.wdcftgg.godagglomerationplate.recipes.GodAgglomerationRecipes"); + final Field recipesField = recipesClass.getField("recipes"); + final Object recipes = recipesField.get(null); + if (!(recipes instanceof List recipeList)) { + return Optional.empty(); + } + + for (Object recipeObj : recipeList) { + final Field stacksField = recipeObj.getClass().getField("recipeStacks"); + final Field oreKeysField = recipeObj.getClass().getField("recipeOreKeys"); + final Field outputField = recipeObj.getClass().getField("recipeOutput"); + final Field manaField = recipeObj.getClass().getField("manaCost"); + + final Object stacksObj = stacksField.get(recipeObj); + final Object oreKeysObj = oreKeysField.get(recipeObj); + final Object outputObj = outputField.get(recipeObj); + final Object manaObj = manaField.get(recipeObj); + + if (!(stacksObj instanceof List stackList) + || !(oreKeysObj instanceof List oreKeyList) + || !(outputObj instanceof ItemStack outputStack) + || !(manaObj instanceof Number manaNumber)) { + continue; + } + + final ArrayList inputs = new ArrayList<>(); + for (Object stack : stackList) { + if (stack instanceof ItemStack itemStack) { + inputs.add(itemStack.copy()); + } + } + for (Object oreKey : oreKeyList) { + if (oreKey instanceof String key) { + inputs.add(key); + } + } + + final RecipeTerraplate wrapped = new RecipeTerraplate( + ImmutableList.copyOf(inputs), + outputStack.copy(), + manaNumber.intValue(), + RecipeTerraplate.PlateType.GOD_AGGLOMERATION_PLATE + ); + if (wrapped.matches(inv)) { + return Optional.of(wrapped); + } + } + } catch (ReflectiveOperationException ignored) { + } + return Optional.empty(); } @@ -49,4 +185,16 @@ public static void remove(RecipeTerraplate recipe) { private static ItemStack manaResource(int meta) { return new ItemStack(ModItems.manaResource, 1, meta); } + + private static IItemHandler compactInventory(IItemHandler inv) { + ItemStackHandler compacted = new ItemStackHandler(inv.getSlots()); + int index = 0; + for (int i = 0; i < inv.getSlots(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if (!stack.isEmpty()) { + compacted.setStackInSlot(index++, stack.copy()); + } + } + return compacted; + } } diff --git a/src/main/java/dev/beecube31/crazyae2/common/recipes/botania/RecipeTerraplate.java b/src/main/java/dev/beecube31/crazyae2/common/recipes/botania/RecipeTerraplate.java index cac71bd..0687b58 100644 --- a/src/main/java/dev/beecube31/crazyae2/common/recipes/botania/RecipeTerraplate.java +++ b/src/main/java/dev/beecube31/crazyae2/common/recipes/botania/RecipeTerraplate.java @@ -2,10 +2,13 @@ import com.google.common.collect.ImmutableList; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.oredict.OreDictionary; import quaternary.botaniatweaks.modules.botania.recipe.AgglomerationRecipe; -import vazkii.botania.common.core.helper.ItemNBTHelper; + +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.HashSet; @@ -13,10 +16,17 @@ public class RecipeTerraplate { + public enum PlateType { + TERRA_PLATE, + GAIA_PLATE, + GOD_AGGLOMERATION_PLATE + } + public final ImmutableList recipeStacks; public final ImmutableList recipeOreKeys; public final ItemStack recipeOutput; public final int manaCost; + public final PlateType plateType; final int totalInputs; @@ -30,6 +40,10 @@ private void verifyInputs(ImmutableList inputs) { } public RecipeTerraplate(ImmutableList recipeInputs, ItemStack recipeOutput, int manaCost) { + this(recipeInputs, recipeOutput, manaCost, PlateType.TERRA_PLATE); + } + + public RecipeTerraplate(ImmutableList recipeInputs, ItemStack recipeOutput, int manaCost, PlateType plateType) { verifyInputs(recipeInputs); ImmutableList.Builder stackInputBuilder = new ImmutableList.Builder<>(); @@ -46,67 +60,72 @@ public RecipeTerraplate(ImmutableList recipeInputs, ItemStack recipeOutp this.recipeOutput = recipeOutput; this.manaCost = manaCost; + this.plateType = plateType; } public RecipeTerraplate(AgglomerationRecipe s) { - ImmutableList.Builder stackInputBuilder = new ImmutableList.Builder<>(); - ImmutableList.Builder keyInputBuilder = new ImmutableList.Builder<>(); - - for(Object o : s.recipeStacks) { - if(o instanceof ItemStack) stackInputBuilder.add((ItemStack) o); - else keyInputBuilder.add((String) o); - } - - this.recipeStacks = stackInputBuilder.build(); - this.recipeOreKeys = keyInputBuilder.build(); + this.recipeStacks = ImmutableList.copyOf(s.recipeStacks); + this.recipeOreKeys = ImmutableList.copyOf(s.recipeOreKeys); this.totalInputs = recipeStacks.size() + recipeOreKeys.size(); - this.recipeOutput = s.recipeOutput; + this.recipeOutput = s.getRecipeOutputCopy(); this.manaCost = s.manaCost; + this.plateType = PlateType.TERRA_PLATE; } - public boolean matches(IItemHandler inv) { - List inputsMissing = new ArrayList<>(this.recipeStacks); + public RecipeTerraplate(ItemStack recipeOutput, int manaCost) { + this(recipeOutput, manaCost, PlateType.TERRA_PLATE); + } - for(int i = 0; i < inv.getSlots(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if(stack.isEmpty()) - break; - - int stackIndex = -1, oredictIndex = -1; - - for(int j = 0; j < inputsMissing.size(); j++) { - Object input = inputsMissing.get(j); - if(input instanceof String) { - boolean found = false; - for(ItemStack ostack : OreDictionary.getOres((String) input, false)) { - if(OreDictionary.itemMatches(ostack, stack, false)) { - oredictIndex = j; - found = true; - break; - } - } + public RecipeTerraplate(ItemStack recipeOutput, int manaCost, PlateType plateType) { + this.recipeStacks = ImmutableList.of(); + this.recipeOreKeys = ImmutableList.of(); + this.totalInputs = 0; + this.recipeOutput = recipeOutput; + this.manaCost = manaCost; + this.plateType = plateType; + } - if(found) break; - } else if(input instanceof ItemStack && compareStacks((ItemStack) input, stack)) { - stackIndex = j; - break; - } + public boolean matches(IItemHandler inv) { + final List userInputs = new ArrayList<>(); + for (int i = 0; i < inv.getSlots(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if (!stack.isEmpty()) { + userInputs.add(stack); } - - if(stackIndex != -1) - inputsMissing.remove(stackIndex); - else if(oredictIndex != -1) - inputsMissing.remove(oredictIndex); - else return false; } - return inputsMissing.isEmpty(); + return itemsMatch(userInputs); } private boolean compareStacks(ItemStack recipe, ItemStack supplied) { - return recipe.getItem() == supplied.getItem() && recipe.getItemDamage() == supplied.getItemDamage() && ItemNBTHelper.matchTag(recipe.getTagCompound(), supplied.getTagCompound()); + if(recipe.isEmpty() || supplied.isEmpty()) return false; + if(recipe.getItem() != supplied.getItem()) return false; + if(recipe.getItemDamage() != supplied.getItemDamage()) return false; + + return isTagSubset(recipe.getTagCompound(), supplied.getTagCompound()); + } + + private static boolean isTagSubset(@Nullable NBTTagCompound recipeTag, @Nullable NBTTagCompound suppliedTag) { + if (recipeTag == null || recipeTag.isEmpty()) return true; + if (suppliedTag == null || suppliedTag.isEmpty()) return false; + if (recipeTag.getKeySet().size() > suppliedTag.getKeySet().size()) return false; + + for (String key : suppliedTag.getKeySet()) { + if (!recipeTag.hasKey(key)) continue; + + NBTBase suppliedEntry = suppliedTag.getTag(key); + NBTBase recipeEntry = recipeTag.getTag(key); + + if (suppliedEntry instanceof NBTTagCompound && recipeEntry instanceof NBTTagCompound) { + if (!isTagSubset((NBTTagCompound) recipeEntry, (NBTTagCompound) suppliedEntry)) return false; + } else { + if (!suppliedEntry.equals(recipeEntry)) return false; + } + } + + return true; } public boolean itemsMatch(List userInputs) { @@ -164,6 +183,10 @@ public ItemStack getOutput() { return recipeOutput; } + public PlateType getPlateType() { + return this.plateType; + } + @Override public boolean equals(Object obj) { if (this == obj) return true; diff --git a/src/main/java/dev/beecube31/crazyae2/common/registration/Registration.java b/src/main/java/dev/beecube31/crazyae2/common/registration/Registration.java index baf99be..d9766ea 100644 --- a/src/main/java/dev/beecube31/crazyae2/common/registration/Registration.java +++ b/src/main/java/dev/beecube31/crazyae2/common/registration/Registration.java @@ -69,9 +69,7 @@ public void postInit(FMLPostInitializationEvent event) { if (Loader.isModLoaded("botania")) { ManaPoolRecipesMaker.init(); - if (Loader.isModLoaded("botania_tweaks")) { - RecipeRepo.copyFromBotaniaTweaks(); - } else { + if (!RecipeRepo.isBotaniaTweaksLoaded()) { RecipeRepo.addDefaultTerrasteelRecipe(); } } diff --git a/src/main/java/dev/beecube31/crazyae2/common/tile/botania/TileMechanicalBrewery.java b/src/main/java/dev/beecube31/crazyae2/common/tile/botania/TileMechanicalBrewery.java index 57f8377..d614813 100644 --- a/src/main/java/dev/beecube31/crazyae2/common/tile/botania/TileMechanicalBrewery.java +++ b/src/main/java/dev/beecube31/crazyae2/common/tile/botania/TileMechanicalBrewery.java @@ -21,6 +21,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.ItemStackHandler; import org.apache.commons.lang3.ArrayUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -145,7 +146,20 @@ public static RecipeBrew getMatchingRecipe(@Nonnull CrazyAEInternalInv inv) { } private static boolean compareRecipes(RecipeBrew recipe, @Nonnull CrazyAEInternalInv inv) { - return recipe.matches(inv); + return recipe.matches(compactInventory(inv)); + } + + @Nonnull + private static ItemStackHandler compactInventory(@Nonnull CrazyAEInternalInv inv) { + ItemStackHandler compacted = new ItemStackHandler(inv.getSlots()); + int index = 0; + for (int i = 0; i < inv.getSlots(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if (!stack.isEmpty()) { + compacted.setStackInSlot(index++, stack.copy()); + } + } + return compacted; } @NotNull diff --git a/src/main/java/dev/beecube31/crazyae2/common/tile/botania/TileMechanicalElventrade.java b/src/main/java/dev/beecube31/crazyae2/common/tile/botania/TileMechanicalElventrade.java index ab4cde0..524b693 100644 --- a/src/main/java/dev/beecube31/crazyae2/common/tile/botania/TileMechanicalElventrade.java +++ b/src/main/java/dev/beecube31/crazyae2/common/tile/botania/TileMechanicalElventrade.java @@ -57,6 +57,7 @@ public boolean validateRecipe() { for (int i = 0; i < this.craftingOutputInv.getSlots(); i++) { this.craftingOutputInv.setStackInSlot(i, ItemStack.EMPTY); } + List input = new ArrayList<>(); for (ItemStack s : this.craftingInputInv) { if (!s.isEmpty()) { @@ -114,15 +115,20 @@ public static RecipeElvenTrade getMatchingRecipe(@Nonnull List input, private static boolean compareRecipes(RecipeElvenTrade recipe, @Nonnull List input, @Nonnull AppEngInternalInventory inv) { if (recipe.matches(input, false) && input.size() == recipe.getInputs().size()) { - for (int i = 0; i < inv.getSlots(); i++) { - if (i > recipe.getInputs().size() - 1) break; + int recipeInputIndex = 0; + for (int i = 0; i < inv.getSlots() && recipeInputIndex < recipe.getInputs().size(); i++) { ItemStack invStack = inv.getStackInSlot(i); + if (invStack.isEmpty()) { + continue; + } - if (!invStack.isEmpty() && recipe.getInputs().get(i) instanceof ItemStack ris) { + if (recipe.getInputs().get(recipeInputIndex) instanceof ItemStack ris) { invStack.setCount(ris.getCount()); - } else if (recipe.getInputs().get(i) instanceof String) { + } else if (recipe.getInputs().get(recipeInputIndex) instanceof String) { invStack.setCount(1); } + + recipeInputIndex++; } return true; } diff --git a/src/main/java/dev/beecube31/crazyae2/common/tile/botania/TileMechanicalPetal.java b/src/main/java/dev/beecube31/crazyae2/common/tile/botania/TileMechanicalPetal.java index e1097b7..6cb4e37 100644 --- a/src/main/java/dev/beecube31/crazyae2/common/tile/botania/TileMechanicalPetal.java +++ b/src/main/java/dev/beecube31/crazyae2/common/tile/botania/TileMechanicalPetal.java @@ -20,6 +20,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.items.ItemStackHandler; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import vazkii.botania.api.BotaniaAPI; @@ -58,6 +59,7 @@ public boolean validateRecipe() { for (int i = 0; i < this.craftingOutputInv.getSlots(); i++) { this.craftingOutputInv.setStackInSlot(i, ItemStack.EMPTY); } + ItemStack input = null; for (ItemStack s : this.craftingInputInv) { if (!s.isEmpty()) { @@ -111,7 +113,20 @@ public static RecipePetals getMatchingRecipe(@Nonnull AppEngInternalInventory in } private static boolean compareRecipes(RecipePetals recipe, @Nonnull AppEngInternalInventory inv) { - return recipe.matches(inv); + return recipe.matches(compactInventory(inv)); + } + + @Nonnull + private static ItemStackHandler compactInventory(@Nonnull AppEngInternalInventory inv) { + ItemStackHandler compacted = new ItemStackHandler(inv.getSlots()); + int index = 0; + for (int i = 0; i < inv.getSlots(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if (!stack.isEmpty()) { + compacted.setStackInSlot(index++, stack.copy()); + } + } + return compacted; } @NotNull diff --git a/src/main/java/dev/beecube31/crazyae2/common/tile/botania/TileMechanicalRunealtar.java b/src/main/java/dev/beecube31/crazyae2/common/tile/botania/TileMechanicalRunealtar.java index eb3f7eb..1ebf993 100644 --- a/src/main/java/dev/beecube31/crazyae2/common/tile/botania/TileMechanicalRunealtar.java +++ b/src/main/java/dev/beecube31/crazyae2/common/tile/botania/TileMechanicalRunealtar.java @@ -24,6 +24,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.items.ItemStackHandler; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import vazkii.botania.api.BotaniaAPI; @@ -113,6 +114,7 @@ public boolean validateRecipe() { for (int i = 0; i < this.craftingOutputInv.getSlots(); i++) { this.craftingOutputInv.setStackInSlot(i, ItemStack.EMPTY); } + ItemStack input = null; for (ItemStack s : this.craftingInputInv) { if (!s.isEmpty()) { @@ -167,7 +169,20 @@ public static RecipeRuneAltar getMatchingRecipe(@Nonnull AppEngInternalInventory } private static boolean compareRecipes(RecipeRuneAltar recipe, @Nonnull AppEngInternalInventory inv) { - return recipe.matches(inv); + return recipe.matches(compactInventory(inv)); + } + + @Nonnull + private static ItemStackHandler compactInventory(@Nonnull AppEngInternalInventory inv) { + ItemStackHandler compacted = new ItemStackHandler(inv.getSlots()); + int index = 0; + for (int i = 0; i < inv.getSlots(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if (!stack.isEmpty()) { + compacted.setStackInSlot(index++, stack.copy()); + } + } + return compacted; } @NotNull diff --git a/src/main/java/dev/beecube31/crazyae2/common/tile/botania/TileMechanicalTerraplate.java b/src/main/java/dev/beecube31/crazyae2/common/tile/botania/TileMechanicalTerraplate.java index a91bcd3..65b765a 100644 --- a/src/main/java/dev/beecube31/crazyae2/common/tile/botania/TileMechanicalTerraplate.java +++ b/src/main/java/dev/beecube31/crazyae2/common/tile/botania/TileMechanicalTerraplate.java @@ -16,11 +16,14 @@ import dev.beecube31.crazyae2.common.util.inv.CrazyAEInternalInv; import dev.beecube31.crazyae2.common.util.patterns.crafting.TeraplateCraftingPatternDetails; import dev.beecube31.crazyae2.core.CrazyAE; +import appeng.util.inv.InvOperation; import net.minecraft.block.Block; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.items.IItemHandler; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -33,7 +36,7 @@ public class TileMechanicalTerraplate extends TileBotaniaMechanicalMachineBase { public TileMechanicalTerraplate() { super(); - this.craftingInputInv = new CrazyAEInternalInv(this, 16, 64); + this.craftingInputInv = new CrazyAEInternalInv(this, 14, 64); (this.craftingOutputInv = new CrazyAEInternalInv(this, 1, 64)).setFilter(new DisabledFilter()); this.actionSource = new MachineSource(this); @@ -76,7 +79,7 @@ public boolean validateRecipe() { if (input != null) { final Optional recipe = RecipeRepo.findMatchingRecipe(this.craftingInputInv); - if (recipe.isPresent()) { + if (recipe.isPresent() && this.hasValidPlateMarker(recipe.get())) { this.isRecipeValidated = true; this.currentRecipe = recipe.get(); this.craftingOutputInv.setStackInSlot(0, recipe.get().getOutput()); @@ -87,6 +90,33 @@ public boolean validateRecipe() { return false; } + private boolean hasValidPlateMarker(RecipeTerraplate recipe) { + final ItemStack marker = this.findSlot.getStackInSlot(0); + if (marker.isEmpty() || marker.getItem() == null) { + return false; + } + + final ResourceLocation registryName = marker.getItem().getRegistryName(); + if (registryName == null) { + return false; + } + + return switch (recipe.getPlateType()) { + case TERRA_PLATE -> registryName.toString().equals("botania:terraplate"); + case GAIA_PLATE -> registryName.toString().equals("botanicadds:gaia_plate"); + case GOD_AGGLOMERATION_PLATE -> registryName.toString().equals("godagglomerationplate:godagglomerationplate"); + }; + } + + @Override + public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added) { + super.onChangeInventory(inv, slot, mc, removed, added); + + if (inv == this.findSlot && (!removed.isEmpty() || !added.isEmpty())) { + this.validateRecipe(); + } + } + @NotNull @Override public TickRateModulation tickingRequest(@NotNull IGridNode iGridNode, int ticksSinceLastCall) { diff --git a/src/main/java/dev/beecube31/crazyae2/mixins/core/crafting/MixinPacketCraftRequest.java b/src/main/java/dev/beecube31/crazyae2/mixins/core/crafting/MixinPacketCraftRequest.java index 9e2b1fa..a0c92af 100644 --- a/src/main/java/dev/beecube31/crazyae2/mixins/core/crafting/MixinPacketCraftRequest.java +++ b/src/main/java/dev/beecube31/crazyae2/mixins/core/crafting/MixinPacketCraftRequest.java @@ -25,7 +25,7 @@ import java.util.concurrent.Future; -@Mixin(value = PacketCraftRequest.class, remap = false) +@Mixin(value = PacketCraftRequest.class, remap = false, priority = 900) public abstract class MixinPacketCraftRequest extends AppEngPacket { @Shadow @Final private long amount; diff --git a/src/main/java/dev/beecube31/crazyae2/mixins/core/crafting/container/MixinContainerCraftConfirm.java b/src/main/java/dev/beecube31/crazyae2/mixins/core/crafting/container/MixinContainerCraftConfirm.java index 38241bb..f69593c 100644 --- a/src/main/java/dev/beecube31/crazyae2/mixins/core/crafting/container/MixinContainerCraftConfirm.java +++ b/src/main/java/dev/beecube31/crazyae2/mixins/core/crafting/container/MixinContainerCraftConfirm.java @@ -55,7 +55,7 @@ import java.util.Set; import java.util.concurrent.Future; -@Mixin(value = ContainerCraftConfirm.class, remap = false) +@Mixin(value = ContainerCraftConfirm.class, remap = false, priority = 900) public abstract class MixinContainerCraftConfirm extends AEBaseContainer { public MixinContainerCraftConfirm(InventoryPlayer ip, TileEntity myTile, IPart myPart) { super(ip, myTile, myPart); diff --git a/src/main/java/dev/beecube31/crazyae2/mixins/features/interfaceterm/MixinContainerInterfaceTerminal.java b/src/main/java/dev/beecube31/crazyae2/mixins/features/interfaceterm/MixinContainerInterfaceTerminal.java deleted file mode 100644 index 40d9b07..0000000 --- a/src/main/java/dev/beecube31/crazyae2/mixins/features/interfaceterm/MixinContainerInterfaceTerminal.java +++ /dev/null @@ -1,433 +0,0 @@ -package dev.beecube31.crazyae2.mixins.features.interfaceterm; - -import appeng.api.config.Settings; -import appeng.api.config.YesNo; -import appeng.api.networking.IGrid; -import appeng.api.networking.IGridNode; -import appeng.api.networking.security.IActionHost; -import appeng.api.parts.IPart; -import appeng.container.AEBaseContainer; -import appeng.container.implementations.ContainerInterfaceTerminal; -import appeng.core.sync.network.NetworkHandler; -import appeng.core.sync.packets.PacketCompressedNBT; -import appeng.helpers.DualityInterface; -import appeng.helpers.IInterfaceHost; -import appeng.helpers.InventoryAction; -import appeng.helpers.ItemStackHelper; -import appeng.items.misc.ItemEncodedPattern; -import appeng.parts.misc.PartInterface; -import appeng.tile.misc.TileInterface; -import appeng.util.InventoryAdaptor; -import appeng.util.Platform; -import appeng.util.helpers.ItemHandlerUtil; -import appeng.util.inv.AdaptorItemHandler; -import appeng.util.inv.WrapperCursorItemHandler; -import appeng.util.inv.WrapperFilteredItemHandler; -import appeng.util.inv.WrapperRangeItemHandler; -import appeng.util.inv.filter.IAEItemFilter; -import dev.beecube31.crazyae2.common.interfaces.IGridHostMonitorable; -import dev.beecube31.crazyae2.common.interfaces.gui.IPriHostExtender; -import dev.beecube31.crazyae2.common.parts.implementations.PartPatternsInterface; -import dev.beecube31.crazyae2.common.tile.crafting.TileImprovedMAC; -import dev.beecube31.crazyae2.common.tile.networking.TilePatternsInterface; -import dev.beecube31.crazyae2.common.util.InvTracker; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.items.IItemHandler; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -@Mixin(value = ContainerInterfaceTerminal.class, remap = false, priority = 990) -public abstract class MixinContainerInterfaceTerminal extends AEBaseContainer { - @Shadow private IGrid grid; - - @Shadow private NBTTagCompound data; - - public MixinContainerInterfaceTerminal(InventoryPlayer ip, TileEntity myTile, IPart myPart) { - super(ip, myTile, myPart); - } - - @Shadow protected abstract boolean isDifferent(ItemStack a, ItemStack b); - - @Unique private final Map crazyae$diList = new HashMap<>(); - - @Unique private final Map crazyae$macDiList = new HashMap<>(); - - @Unique private final Map crazyae$byId = new HashMap<>(); - - /** - * @author Beecube31 - * @reason Support Patterns interface - */ - @Overwrite - @Override - public void detectAndSendChanges() { - - if (Platform.isClient()) { - return; - } - - super.detectAndSendChanges(); - - if (this.grid == null) { - return; - } - - int total = 0; - boolean missing = false; - - final IActionHost host = this.getActionHost(); - if (host != null) { - final IGridNode agn = host.getActionableNode(); - if (agn.isActive()) { - for (final IGridNode gn : this.grid.getMachines(TileInterface.class)) { - if (gn.isActive()) { - final IInterfaceHost ih = (IInterfaceHost) gn.getMachine(); - if (ih.getInterfaceDuality().getConfigManager().getSetting(Settings.INTERFACE_TERMINAL) == YesNo.NO) { - continue; - } - - final InvTracker t = this.crazyae$diList.get(ih); - - if (t == null) { - missing = true; - } else { - final DualityInterface dual = ih.getInterfaceDuality(); - if (!t.unlocalizedName.equals(dual.getTermName())) { - missing = true; - } - } - - total++; - } - } - - for (final IGridNode gn : this.grid.getMachines(PartInterface.class)) { - if (gn.isActive()) { - final IInterfaceHost ih = (IInterfaceHost) gn.getMachine(); - if (ih.getInterfaceDuality().getConfigManager().getSetting(Settings.INTERFACE_TERMINAL) == YesNo.NO) { - continue; - } - - final InvTracker t = this.crazyae$diList.get(ih); - - if (t == null) { - missing = true; - } else { - final DualityInterface dual = ih.getInterfaceDuality(); - if (!t.unlocalizedName.equals(dual.getTermName())) { - missing = true; - } - } - - total++; - } - } - - for (final IGridNode gn : this.grid.getMachines(TilePatternsInterface.class)) { - if (gn.isActive()) { - final IInterfaceHost ih = (IInterfaceHost) gn.getMachine(); - if (ih.getInterfaceDuality().getConfigManager().getSetting(Settings.INTERFACE_TERMINAL) == YesNo.NO) { - continue; - } - - final InvTracker t = this.crazyae$diList.get(ih); - - if (t == null) { - missing = true; - } else { - final DualityInterface dual = ih.getInterfaceDuality(); - if (!t.unlocalizedName.equals(dual.getTermName())) { - missing = true; - } - } - - total++; - } - } - - for (final IGridNode gn : this.grid.getMachines(PartPatternsInterface.class)) { - if (gn.isActive()) { - final IInterfaceHost ih = (IInterfaceHost) gn.getMachine(); - if (ih.getInterfaceDuality().getConfigManager().getSetting(Settings.INTERFACE_TERMINAL) == YesNo.NO) { - continue; - } - - final InvTracker t = this.crazyae$diList.get(ih); - - if (t == null) { - missing = true; - } else { - final DualityInterface dual = ih.getInterfaceDuality(); - if (!t.unlocalizedName.equals(dual.getTermName())) { - missing = true; - } - } - - total++; - } - } - - for (final IGridNode gn : this.grid.getMachines(TileImprovedMAC.class)) { - if (gn.isActive()) { - final IGridHostMonitorable node = (IGridHostMonitorable) gn.getMachine(); - final InvTracker t = this.crazyae$macDiList.get(node); - - missing = t == null; - - total++; - } - } - } - } - - - if (total != this.crazyae$diList.size() + this.crazyae$macDiList.size() || missing) { - this.regenList(this.data); - } else { - for (final Map.Entry en : this.crazyae$diList.entrySet()) { - final InvTracker inv = en.getValue(); - for (int x = 0; x < inv.server.getSlots(); x++) { - if (this.isDifferent(inv.server.getStackInSlot(x), inv.client.getStackInSlot(x))) { - this.crazyae$addItems(this.data, inv, x, inv.server.getSlots(), false); - } - } - } - - for (final Map.Entry en : this.crazyae$macDiList.entrySet()) { - final InvTracker inv = en.getValue(); - for (int x = 0; x < inv.server.getSlots(); x++) { - if (this.isDifferent(inv.server.getStackInSlot(x), inv.client.getStackInSlot(x))) { - this.crazyae$addItems(this.data, inv, x, inv.server.getSlots(), true); - } - } - } - } - - if (!data.isEmpty()) { - try { - NetworkHandler.instance().sendTo(new PacketCompressedNBT(this.data), (EntityPlayerMP) this.getPlayerInv().player); - } catch (final IOException e) { - // :P - } - this.data = new NBTTagCompound(); - } - } - - /** - * @author Beecube31 - * @reason Support Patterns interface - */ - @Override - @Overwrite - public void doAction(EntityPlayerMP player, InventoryAction action, int slot, long id) { - final InvTracker inv = this.crazyae$byId.get(id); - if (inv != null) { - final ItemStack is = inv.server.getStackInSlot(slot); - final boolean hasItemInHand = !player.inventory.getItemStack().isEmpty(); - - final InventoryAdaptor playerHand = new AdaptorItemHandler(new WrapperCursorItemHandler(player.inventory)); - - final IItemHandler theSlot = new WrapperFilteredItemHandler(new WrapperRangeItemHandler(inv.server, slot, slot + 1), - new IAEItemFilter() { - @Override - public boolean allowExtract(IItemHandler inv, int slot, int amount) { - return true; - } - - @Override - public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) { - return !stack.isEmpty() && stack.getItem() instanceof ItemEncodedPattern; - } - }); - final InventoryAdaptor interfaceSlot = new AdaptorItemHandler(theSlot); - - switch (action) { - case PICKUP_OR_SET_DOWN: - - if (hasItemInHand) { - ItemStack inSlot = theSlot.getStackInSlot(0); - if (inSlot.isEmpty()) { - player.inventory.setItemStack(interfaceSlot.addItems(player.inventory.getItemStack())); - } else { - inSlot = inSlot.copy(); - final ItemStack inHand = player.inventory.getItemStack().copy(); - - ItemHandlerUtil.setStackInSlot(theSlot, 0, ItemStack.EMPTY); - player.inventory.setItemStack(ItemStack.EMPTY); - - player.inventory.setItemStack(interfaceSlot.addItems(inHand.copy())); - - if (player.inventory.getItemStack().isEmpty()) { - player.inventory.setItemStack(inSlot); - } else { - player.inventory.setItemStack(inHand); - ItemHandlerUtil.setStackInSlot(theSlot, 0, inSlot); - } - } - } else { - ItemHandlerUtil.setStackInSlot(theSlot, 0, playerHand.addItems(theSlot.getStackInSlot(0))); - } - - break; - case SPLIT_OR_PLACE_SINGLE: - - if (hasItemInHand) { - ItemStack extra = playerHand.removeItems(1, ItemStack.EMPTY, null); - if (!extra.isEmpty()) { - extra = interfaceSlot.addItems(extra); - } - if (!extra.isEmpty()) { - playerHand.addItems(extra); - } - } else if (!is.isEmpty()) { - ItemStack extra = interfaceSlot.removeItems((is.getCount() + 1) / 2, ItemStack.EMPTY, null); - if (!extra.isEmpty()) { - extra = playerHand.addItems(extra); - } - if (!extra.isEmpty()) { - interfaceSlot.addItems(extra); - } - } - - break; - case SHIFT_CLICK: - - final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player); - - ItemHandlerUtil.setStackInSlot(theSlot, 0, playerInv.addItems(theSlot.getStackInSlot(0))); - - break; - case MOVE_REGION: - - final InventoryAdaptor playerInvAd = InventoryAdaptor.getAdaptor(player); - for (int x = 0; x < inv.server.getSlots(); x++) { - ItemHandlerUtil.setStackInSlot(inv.server, x, playerInvAd.addItems(inv.server.getStackInSlot(x))); - } - - break; - case CREATIVE_DUPLICATE: - - if (player.capabilities.isCreativeMode && !hasItemInHand) { - player.inventory.setItemStack(is.isEmpty() ? ItemStack.EMPTY : is.copy()); - } - - break; - default: - return; - } - - this.updateHeld(player); - } - } - - /** - * @author Beecube31 - * @reason Support Patterns interface - */ - @Overwrite - private void regenList(final NBTTagCompound data) { - this.crazyae$byId.clear(); - this.crazyae$diList.clear(); - this.crazyae$macDiList.clear(); - - - final IActionHost host = this.getActionHost(); - if (host != null) { - final IGridNode agn = host.getActionableNode(); - if (agn.isActive()) { - for (final IGridNode gn : this.grid.getMachines(TileInterface.class)) { - final IInterfaceHost ih = (IInterfaceHost) gn.getMachine(); - final DualityInterface dual = ih.getInterfaceDuality(); - if (gn.isActive() && dual.getConfigManager().getSetting(Settings.INTERFACE_TERMINAL) == YesNo.YES) { - this.crazyae$diList.put(ih, new InvTracker(dual, dual.getPatterns(), dual.getTermName())); - } - } - - for (final IGridNode gn : this.grid.getMachines(PartInterface.class)) { - final IInterfaceHost ih = (IInterfaceHost) gn.getMachine(); - final DualityInterface dual = ih.getInterfaceDuality(); - if (gn.isActive() && dual.getConfigManager().getSetting(Settings.INTERFACE_TERMINAL) == YesNo.YES) { - this.crazyae$diList.put(ih, new InvTracker(dual, dual.getPatterns(), dual.getTermName())); - } - } - - for (final IGridNode gn : this.grid.getMachines(TilePatternsInterface.class)) { - final IInterfaceHost ih = (IInterfaceHost) gn.getMachine(); - final DualityInterface dual = ih.getInterfaceDuality(); - if (gn.isActive() && dual.getConfigManager().getSetting(Settings.INTERFACE_TERMINAL) == YesNo.YES) { - this.crazyae$diList.put(ih, new InvTracker(dual, dual.getPatterns(), dual.getTermName())); - } - } - - for (final IGridNode gn : this.grid.getMachines(PartPatternsInterface.class)) { - final IPriHostExtender ih = (IPriHostExtender) gn.getMachine(); - final DualityInterface dual = ih.getInterfaceDuality(); - if (gn.isActive() && dual.getConfigManager().getSetting(Settings.INTERFACE_TERMINAL) == YesNo.YES) { - this.crazyae$diList.put(ih, new InvTracker(dual, dual.getPatterns(), dual.getTermName())); - } - } - - for (final IGridNode gn : this.grid.getMachines(TileImprovedMAC.class)) { - final IGridHostMonitorable ih = (IGridHostMonitorable) gn.getMachine(); - if (gn.isActive()) { - this.crazyae$macDiList.put(ih, new InvTracker(ih, ih.getPatternsInv(), ih.getName())); - } - } - } - } - - data.setBoolean("clear", true); - - for (final Map.Entry en : this.crazyae$diList.entrySet()) { - final InvTracker inv = en.getValue(); - this.crazyae$byId.put(inv.which, inv); - this.crazyae$addItems(data, inv, 0, inv.server.getSlots(), false); - } - - for (final Map.Entry en : this.crazyae$macDiList.entrySet()) { - final InvTracker inv = en.getValue(); - this.crazyae$byId.put(inv.which, inv); - this.crazyae$addItems(data, inv, 0, inv.server.getSlots(), true); - } - } - - @Unique - private void crazyae$addItems(NBTTagCompound data, InvTracker inv, int offset, int length, boolean mac) { - String name = '=' + Long.toString(inv.which, 36); - NBTTagCompound tag = data.getCompoundTag(name); - if (tag.isEmpty()) { - tag.setLong("sortBy", inv.sortBy); - tag.setString("un", inv.unlocalizedName); - tag.setTag("pos", NBTUtil.createPosTag(inv.pos)); - tag.setInteger("dim", inv.dim); - tag.setInteger("numUpgrades", inv.numUpgrades); - tag.setBoolean("isMAC", mac); - tag.setInteger("patternsNum", length); - } - - for (int x = 0; x < length; ++x) { - if (x + offset >= length) break; - NBTTagCompound itemNBT = new NBTTagCompound(); - ItemStack is = inv.server.getStackInSlot(x + offset); - ItemHandlerUtil.setStackInSlot(inv.client, x + offset, is.isEmpty() ? ItemStack.EMPTY : is.copy()); - if (!is.isEmpty()) { - ItemStackHelper.stackWriteToNBT(is, itemNBT); - } - - tag.setTag(Integer.toString(x + offset), itemNBT); - } - - data.setTag(name, tag); - } -} diff --git a/src/main/java/dev/beecube31/crazyae2/mixins/features/interfaceterm/MixinGuiInterfaceTerminal.java b/src/main/java/dev/beecube31/crazyae2/mixins/features/interfaceterm/MixinGuiInterfaceTerminal.java deleted file mode 100644 index 93a249a..0000000 --- a/src/main/java/dev/beecube31/crazyae2/mixins/features/interfaceterm/MixinGuiInterfaceTerminal.java +++ /dev/null @@ -1,414 +0,0 @@ -package dev.beecube31.crazyae2.mixins.features.interfaceterm; - -import appeng.api.config.ActionItems; -import appeng.api.config.Settings; -import appeng.api.config.TerminalStyle; -import appeng.client.gui.AEBaseGui; -import appeng.client.gui.implementations.GuiInterfaceTerminal; -import appeng.client.gui.widgets.GuiImgButton; -import appeng.client.gui.widgets.MEGuiTooltipTextField; -import appeng.client.me.ClientDCInternalInv; -import appeng.client.me.SlotDisconnected; -import appeng.core.AEConfig; -import appeng.core.localization.GuiText; -import com.google.common.collect.HashMultimap; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.inventory.Container; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.spongepowered.asm.mixin.*; - -import java.util.*; - -@Mixin(value = GuiInterfaceTerminal.class, remap = false, priority = 990) -@SideOnly(Side.CLIENT) -public abstract class MixinGuiInterfaceTerminal extends AEBaseGui { - - @Shadow @Final private HashMap byId; - - @Shadow private boolean refreshList; - - @Shadow @Final private Map> cachedSearches; - - @Shadow @Final private HashMultimap byName; - - @Shadow @Final private ArrayList names; - - @Shadow @Final private MEGuiTooltipTextField searchFieldInputs; - - @Shadow @Final private MEGuiTooltipTextField searchFieldOutputs; - - @Shadow private int rows; - - @Shadow @Final private ArrayList lines; - - @Shadow @Final private Map numUpgradesMap; - - @Shadow @Final private HashMap blockPosHashMap; - - @Shadow @Final private Map dimHashMap; - - @Shadow @Final private Set matchedStacks; - - @Shadow @Final private MEGuiTooltipTextField searchFieldNames; - - @Shadow @Final private HashMap guiButtonHashMap; - - @Shadow @Final private GuiImgButton guiButtonAssemblersOnly; - - @Shadow private boolean onlyMolecularAssemblers; - - @Shadow @Final private GuiImgButton guiButtonHideFull; - - @Shadow private boolean onlyShowWithSpace; - - @Shadow private boolean onlyBrokenRecipes; - - @Shadow @Final private GuiImgButton guiButtonBrokenRecipes; - - @Shadow @Final private GuiImgButton terminalStyleBox; - - @Shadow protected abstract boolean recipeIsBroken(ItemStack stack); - - @Shadow protected abstract boolean itemStackMatchesSearchTerm(ItemStack itemStack, String searchTerm, int pass); - - @Shadow @Final private static String MOLECULAR_ASSEMBLER; - - @Shadow protected abstract void setScrollBar(); - - @Shadow protected abstract Set getCacheForSearchTerm(String searchTerm); - - @Unique @Final private final Map crazyae$patterns = new HashMap<>(); - - @Unique @Final private final Map crazyae$macs = new HashMap<>(); - - public MixinGuiInterfaceTerminal(Container container) { - super(container); - } - - /** - * @author Beecube31 - * @reason Support Patterns interface - */ - @Overwrite - private int getMaxRows() { - return AEConfig.instance().getConfigManager().getSetting(Settings.TERMINAL_STYLE) != TerminalStyle.TALL ? 8 : Integer.MAX_VALUE; - } - - /** - * @author Beecube31 - * @reason Support Patterns interface - */ - @Override - @Overwrite - public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - - this.fontRenderer.drawString(this.getGuiDisplayName(GuiText.InterfaceTerminal.getLocal()), 8, 6, 4210752); - this.fontRenderer.drawString(GuiText.inventory.getLocal(), 24, this.ySize - 96, 4210752); - - final int currentScroll = this.getScrollBar().getCurrentScroll(); - - int offset = 51; - int linesDraw = 0; - - for (int x = 0; x < rows && linesDraw < rows && currentScroll + x < this.lines.size(); x++) { - final Object lineObj = this.lines.get(currentScroll + x); - if (lineObj instanceof ClientDCInternalInv inv) { - - final int extraLines = numUpgradesMap.get(inv); - boolean isPatternTile = crazyae$patterns.get(inv); - boolean isMAC = crazyae$macs.get(inv); - for (int row = 0; row < 1 + (isPatternTile ? 7 : isMAC ? 4 : extraLines) && linesDraw < rows; ++row) { - for (int z = 0; z < 9; z++) { - if (this.matchedStacks.contains(inv.getInventory().getStackInSlot(z + (row * 9)))) { - drawRect(z * 18 + 22, 1 + offset, z * 18 + 22 + 16, 1 + offset + 16, 0x2A00FF00); - } - } - linesDraw++; - offset += 18; - } - } else if (lineObj instanceof String name) { - final int rows = this.byName.get(name).size(); - if (rows > 1) { - name = name + " (" + rows + ')'; - } - - while (name.length() > 2 && this.fontRenderer.getStringWidth(name) > 158) { - name = name.substring(0, name.length() - 1); - } - this.fontRenderer.drawString(name, 24, 6 + offset, 4210752); - linesDraw++; - offset += 18; - } - } - } - - /** - * @author Beecube31 - * @reason Support Patterns interface - */ - @Overwrite - @Override - public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - this.bindTexture("guis/newinterfaceterminal.png"); - - // draw the top portion of the background, above the interface list - this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, 53); - - for (int x = 0; x < this.rows; x++) { - // draw the background of the rows in the interface list - this.drawTexturedModalRect(offsetX, offsetY + 53 + x * 18, 0, 52, this.xSize, 18); - } - - int offset = 51; - final int ex = this.getScrollBar().getCurrentScroll(); - int linesDraw = 0; - for (int x = 0; x < rows && linesDraw < rows && ex + x < this.lines.size(); x++) { - final Object lineObj = this.lines.get(ex + x); - if (lineObj instanceof ClientDCInternalInv) { - GlStateManager.color(1, 1, 1, 1); - final int width = 9 * 18; - - int extraLines = numUpgradesMap.get(lineObj); - boolean isPatternTile = crazyae$patterns.get(lineObj); - boolean isMAC = crazyae$macs.get(lineObj); - - for (int row = 0; row < 1 + (isPatternTile ? 7 : isMAC ? 4 : extraLines) && linesDraw < rows; ++row) { - this.drawTexturedModalRect(offsetX + 20, offsetY + offset, 20, 173, width, 18); - - offset += 18; - linesDraw++; - } - } else { - offset += 18; - linesDraw++; - } - } - - // draw the background below the interface list - this.drawTexturedModalRect(offsetX, offsetY + 50 + this.rows * 18, 0, 158, this.xSize, 99); - - // draw the text boxes - this.searchFieldInputs.drawTextBox(); - this.searchFieldOutputs.drawTextBox(); - this.searchFieldNames.drawTextBox(); - } - - /** - * @author Beecube31 - * @reason Support Patterns interface - */ - @Overwrite - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - buttonList.clear(); - guiButtonHashMap.clear(); - inventorySlots.inventorySlots.removeIf(slot -> slot instanceof SlotDisconnected); - - guiButtonAssemblersOnly.set(onlyMolecularAssemblers ? ActionItems.MOLECULAR_ASSEMBLERS_ON : ActionItems.MOLECULAR_ASSEMBLERS_OFF); - guiButtonHideFull.set(onlyShowWithSpace ? ActionItems.TOGGLE_SHOW_FULL_INTERFACES_OFF : ActionItems.TOGGLE_SHOW_FULL_INTERFACES_ON); - guiButtonBrokenRecipes.set(onlyBrokenRecipes ? ActionItems.TOGGLE_SHOW_ONLY_INVALID_PATTERNS_ON : ActionItems.TOGGLE_SHOW_ONLY_INVALID_PATTERNS_OFF); - terminalStyleBox.set(AEConfig.instance().getConfigManager().getSetting(Settings.TERMINAL_STYLE)); - - buttonList.add(guiButtonAssemblersOnly); - buttonList.add(guiButtonHideFull); - buttonList.add(guiButtonBrokenRecipes); - buttonList.add(terminalStyleBox); - - int offset = 51; - final int currentScroll = this.getScrollBar().getCurrentScroll(); - int linesDraw = 0; - - for (int x = 0; x < rows && linesDraw < rows && currentScroll + x < this.lines.size(); x++) { - final Object lineObj = this.lines.get(currentScroll + x); - if (lineObj instanceof ClientDCInternalInv inv) { - - GuiButton guiButton = new GuiImgButton(guiLeft + 4, guiTop + offset + 1, Settings.ACTIONS, ActionItems.HIGHLIGHT_INTERFACE); - guiButtonHashMap.put(guiButton, inv); - this.buttonList.add(guiButton); - - int extraLines = numUpgradesMap.get(lineObj); - boolean isPatternTile = crazyae$patterns.get(lineObj); - boolean isMAC = crazyae$macs.get(lineObj); - - for (int row = 0; row < 1 + (isPatternTile ? 7 : isMAC ? 4 : extraLines) && linesDraw < rows; ++row) { - for (int z = 0; z < 9; z++) { - this.inventorySlots.inventorySlots.add(new SlotDisconnected(inv, z + (row * 9), z * 18 + 22, 1 + offset)); - } - linesDraw++; - offset += 18; - } - } else if (lineObj instanceof String) { - linesDraw++; - offset += 18; - } - } - - super.drawScreen(mouseX, mouseY, partialTicks); - - drawTooltip(searchFieldInputs, mouseX, mouseY); - drawTooltip(searchFieldOutputs, mouseX, mouseY); - drawTooltip(searchFieldNames, mouseX, mouseY); - } - - /** - * @author Beecube31 - * @reason Support Patterns interface - */ - @Overwrite - public void postUpdate(final NBTTagCompound in) { - - if (in.getBoolean("clear")) { - this.byId.clear(); - this.refreshList = true; - } - - for (final String oKey : in.getKeySet()) { - if (oKey.startsWith("=")) { - try { - final long id = Long.parseLong(oKey.substring(1), Character.MAX_RADIX); - final NBTTagCompound invData = in.getCompoundTag(oKey); - final ClientDCInternalInv current = this.crazyae$getById(invData.getInteger("patternsNum"), id, invData.getLong("sortBy"), invData.getString("un")); - - blockPosHashMap.put(current, NBTUtil.getPosFromTag(invData.getCompoundTag("pos"))); - dimHashMap.put(current, invData.getInteger("dim")); - numUpgradesMap.put(current, invData.getInteger("numUpgrades")); - crazyae$patterns.put(current, (!invData.getBoolean("isMAC") && invData.getInteger("patternsNum") == 72)); - crazyae$macs.put(current, (invData.getBoolean("isMAC") && invData.getInteger("patternsNum") == 45)); - - for (int x = 0; x < current.getInventory().getSlots(); x++) { - final String which = Integer.toString(x); - if (invData.hasKey(which)) { - current.getInventory().setStackInSlot(x, new ItemStack(invData.getCompoundTag(which))); - } - } - } catch (final NumberFormatException ignored) {} - } - } - - if (this.refreshList) { - this.refreshList = false; - this.cachedSearches.clear(); - this.refreshList(); - } - } - - /** - * @author Beecube31 - * @reason Support Patterns interface - */ - @Overwrite - private void refreshList() { - this.byName.clear(); - this.buttonList.clear(); - this.matchedStacks.clear(); - - final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase(); - final String searchFieldOutputs = this.searchFieldOutputs.getText().toLowerCase(); - final String searchFieldNames = this.searchFieldNames.getText().toLowerCase(); - - final Set cachedSearch = this.getCacheForSearchTerm("IN:" + searchFieldInputs + " OUT:" + searchFieldOutputs - + "NAME:" + searchFieldNames + onlyShowWithSpace + onlyMolecularAssemblers + onlyBrokenRecipes); - final boolean rebuild = cachedSearch.isEmpty(); - - for (final ClientDCInternalInv entry : this.byId.values()) { - // ignore inventory if not doing a full rebuild and cache already marks it as miss. - if (!rebuild && !cachedSearch.contains(entry)) { - continue; - } - - // Shortcut to skip any filter if search term is ""/empty - - boolean found = searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty(); - boolean interfaceHasFreeSlots = false; - boolean interfaceHasBrokenRecipes = false; - - // Search if the current inventory holds a pattern containing the search term. - if (!found || onlyShowWithSpace || onlyBrokenRecipes) { - int slot = 0; - for (final ItemStack itemStack : entry.getInventory()) { - if (crazyae$patterns.get(entry) ? slot > 72 : crazyae$macs.get(entry) ? slot > 45 : slot > 8 + numUpgradesMap.get(entry) * 9) { - break; - } - - if (itemStack.isEmpty()) { - interfaceHasFreeSlots = true; - } - - if (onlyBrokenRecipes && recipeIsBroken(itemStack)) { - interfaceHasBrokenRecipes = true; - } - - if ((!searchFieldInputs.isEmpty() && itemStackMatchesSearchTerm(itemStack, searchFieldInputs, 0)) - || (!searchFieldOutputs.isEmpty() && itemStackMatchesSearchTerm(itemStack, searchFieldOutputs, 1))) { - found = true; - matchedStacks.add(itemStack); - } - - slot++; - } - } - - // Exit if not found - if (!found) { - cachedSearch.remove(entry); - continue; - } - // Exit if the interface does not match the name search - if (!entry.getName().toLowerCase().contains(searchFieldNames)) { - cachedSearch.remove(entry); - continue; - } - // Exit if molecular assembler filter is on and this is not a molecular assembler - if (onlyMolecularAssemblers && !entry.getName().toLowerCase().contains(MOLECULAR_ASSEMBLER)) { - cachedSearch.remove(entry); - continue; - } - // Exit if we are only showing interfaces with free slots and there are none free in this interface - if (onlyShowWithSpace && !interfaceHasFreeSlots) { - cachedSearch.remove(entry); - continue; - } - // Exit if we are only showing interfaces with broken patterns and there are no broken patterns in this interface - if (onlyBrokenRecipes && !interfaceHasBrokenRecipes) { - cachedSearch.remove(entry); - continue; - } - - // Successful search - this.byName.put(entry.getName(), entry); - cachedSearch.add(entry); - } - - this.names.clear(); - this.names.addAll(this.byName.keySet()); - Collections.sort(this.names); - - this.lines.clear(); - this.lines.ensureCapacity(this.names.size() + this.byId.size()); - - for (final String n : this.names) { - this.lines.add(n); - final ArrayList clientInventories = new ArrayList<>(this.byName.get(n)); - Collections.sort(clientInventories); - this.lines.addAll(clientInventories); - } - - this.setScrollBar(); - } - - @Unique - private ClientDCInternalInv crazyae$getById(final int length, final long id, final long sortBy, final String string) { - ClientDCInternalInv o = this.byId.get(id); - if (o == null) { - this.byId.put(id, o = new ClientDCInternalInv(length, id, sortBy, string)); - this.refreshList = true; - } - return o; - } -} diff --git a/src/main/resources/assets/crazyae/lang/zh_cn.lang b/src/main/resources/assets/crazyae/lang/zh_cn.lang index 8d1910c..8e5031b 100644 --- a/src/main/resources/assets/crazyae/lang/zh_cn.lang +++ b/src/main/resources/assets/crazyae/lang/zh_cn.lang @@ -113,7 +113,7 @@ item.crazyae.material.manapool_blank_pattern.name=魔力灌注空白样板 item.crazyae.material.petal_blank_pattern.name=花瓣炼制空白样板 item.crazyae.material.runealtar_blank_pattern.name=符文祭坛空白样板 item.crazyae.material.puredaisy_blank_pattern.name=白雏活化空白样板 -item.crazyae.material.teraplate_blank_pattern.name=泰拉凝聚空白样板 +item.crazyae.material.teraplate_blank_pattern.name=魔力凝聚空白样板 item.crazyae.material.brewery_blank_pattern.name=植物酿造空白样板 item.crazyae.elventrade_encoded_pattern.name=精灵交易编码样板 @@ -121,7 +121,7 @@ item.crazyae.manapool_encoded_pattern.name=魔力灌注编码样板 item.crazyae.petal_encoded_pattern.name=花瓣炼制编码样板 item.crazyae.runealtar_encoded_pattern.name=符文祭坛编码样板 item.crazyae.puredaisy_encoded_pattern.name=白雏活化编码样板 -item.crazyae.teraplate_encoded_pattern.name=泰拉凝聚编码样板 +item.crazyae.teraplate_encoded_pattern.name=魔力凝聚编码样板 item.crazyae.brewery_encoded_pattern.name=植物酿造编码样板 item.crazyae.creative_mana_cell.name=创造型ME魔力存储组件 @@ -139,8 +139,8 @@ tooltip.crazyae.mana_connector_lets_connect_to_bus.name=Shift+右键 ME魔力输 item.crazyae.part.improved_import_bus.name=增强型ME输入总线 item.crazyae.part.improved_export_bus.name=增强型ME输出总线 -item.crazyae.part.improved_export_fluid_bus.name=增强型ME流体输入总线 -item.crazyae.part.improved_import_fluid_bus.name=增强型ME流体输出总线 +item.crazyae.part.improved_export_fluid_bus.name=增强型ME流体输出总线 +item.crazyae.part.improved_import_fluid_bus.name=增强型ME流体输入总线 item.crazyae.part.mana_import_bus.name=ME魔力输入总线 item.crazyae.part.mana_export_bus.name=ME魔力输出总线 @@ -213,7 +213,7 @@ tile.crazyae.mechanical_manapool.name=魔力灌注处理仓 tile.crazyae.mechanical_runealtar.name=符文祭坛处理仓 tile.crazyae.mechanical_petal.name=花瓣炼制处理仓 tile.crazyae.mechanical_puredaisy.name=白雏活化处理仓 -tile.crazyae.mechanical_teraplate.name=泰拉凝聚处理仓 +tile.crazyae.mechanical_teraplate.name=魔力凝聚处理仓 tile.crazyae.mechanical_brewery.name=植物酿造处理仓 @@ -262,7 +262,7 @@ gui.crazyae.mechanical_manapool.name=魔力灌注处理仓 gui.crazyae.mechanical_runealtar.name=符文祭坛处理仓 gui.crazyae.mechanical_petal.name=花瓣炼制处理仓 gui.crazyae.mechanical_puredaisy.name=白雏活化处理仓 -gui.crazyae.mechanical_teraplate.name=泰拉凝聚处理仓 +gui.crazyae.mechanical_teraplate.name=魔力凝聚处理仓 gui.crazyae.mechanical_brewery.name=植物酿造处理仓 gui.crazyae.patterns_inv_gui.name=样板存放处 diff --git a/src/main/resources/assets/crazyae/textures/guis/teraplate_mechanical.png b/src/main/resources/assets/crazyae/textures/guis/teraplate_mechanical.png index 17440a0..0412577 100644 Binary files a/src/main/resources/assets/crazyae/textures/guis/teraplate_mechanical.png and b/src/main/resources/assets/crazyae/textures/guis/teraplate_mechanical.png differ diff --git a/src/main/resources/mixins.crazyae.patterns.interface.json b/src/main/resources/mixins.crazyae.patterns.interface.json deleted file mode 100644 index 0233250..0000000 --- a/src/main/resources/mixins.crazyae.patterns.interface.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "package": "dev.beecube31.crazyae2.mixins", - "refmap": "mixins.crazyae.refmap.json", - "target": "@env(DEFAULT)", - "minVersion": "0.8", - "compatibilityLevel": "JAVA_8", - "mixins": [ - "features.interfaceterm.MixinContainerInterfaceTerminal" - ], - "client": [ - "features.interfaceterm.MixinGuiInterfaceTerminal" - ], - "server": [] -}