diff --git a/src/main/java/appeng/core/sync/packets/JEIRecipePacket.java b/src/main/java/appeng/core/sync/packets/JEIRecipePacket.java index 7c0ec908c..c1916f1ca 100644 --- a/src/main/java/appeng/core/sync/packets/JEIRecipePacket.java +++ b/src/main/java/appeng/core/sync/packets/JEIRecipePacket.java @@ -28,18 +28,18 @@ import com.mojang.datafixers.util.Pair; import io.netty.buffer.Unpooled; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.inventory.container.Container; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.IRecipeSerializer; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.item.crafting.ShapedRecipe; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.crafting.IShapedRecipe; -import net.minecraftforge.items.IItemHandler; +import net.minecraft.network.PacketByteBuf; +import net.minecraft.recipe.Ingredient; +import net.minecraft.recipe.Recipe; +import net.minecraft.recipe.RecipeSerializer; +import net.minecraft.recipe.ShapedRecipe; +import net.minecraft.screen.ScreenHandler; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.util.Identifier; +import net.minecraft.util.collection.DefaultedList; + +import alexiil.mc.lib.attributes.item.FixedItemInv; import appeng.api.config.Actionable; import appeng.api.config.SecurityPermissions; @@ -59,9 +59,10 @@ import appeng.core.sync.BasePacketHandler; import appeng.core.sync.network.INetworkInfo; import appeng.helpers.IContainerCraftingPacket; import appeng.items.storage.ViewCellItem; +import appeng.mixins.IngredientAccessor; import appeng.util.Platform; import appeng.util.helpers.ItemHandlerUtil; -import appeng.util.inv.AdaptorItemHandler; +import appeng.util.inv.AdaptorFixedInv; import appeng.util.inv.WrapperInvItemHandler; import appeng.util.item.AEItemStack; import appeng.util.prioritylist.IPartitionList; @@ -79,26 +80,26 @@ public class JEIRecipePacket extends BasePacket { */ private static final int INLINE_RECIPE_SHAPED = 2; - private ResourceLocation recipeId; + private Identifier recipeId; /** * This is optional, in case the client already knows it could not resolve the * recipe id. */ @Nullable - private IRecipe recipe; + private Recipe recipe; private boolean crafting; - public JEIRecipePacket(final PacketBuffer stream) { + public JEIRecipePacket(final PacketByteBuf stream) { this.crafting = stream.readBoolean(); final String id = stream.readString(Short.MAX_VALUE); - this.recipeId = new ResourceLocation(id); + this.recipeId = new Identifier(id); int inlineRecipeType = stream.readVarInt(); switch (inlineRecipeType) { case INLINE_RECIPE_NONE: break; case INLINE_RECIPE_SHAPED: - recipe = IRecipeSerializer.CRAFTING_SHAPED.read(this.recipeId, stream); + recipe = RecipeSerializer.SHAPED.read(this.recipeId, stream); break; default: throw new IllegalArgumentException("Invalid inline recipe type."); @@ -109,8 +110,8 @@ public class JEIRecipePacket extends BasePacket { * Sends a recipe identified by the given recipe ID to the server for either * filling a crafting grid or a pattern. */ - public JEIRecipePacket(final ResourceLocation recipeId, final boolean crafting) { - PacketBuffer data = createCommonHeader(recipeId, crafting, INLINE_RECIPE_NONE); + public JEIRecipePacket(final Identifier recipeId, final boolean crafting) { + PacketByteBuf data = createCommonHeader(recipeId, crafting, INLINE_RECIPE_NONE); this.configureWrite(data); } @@ -120,17 +121,17 @@ public class JEIRecipePacket extends BasePacket { * Prefer the id-based constructor above whereever possible. */ public JEIRecipePacket(final ShapedRecipe recipe, final boolean crafting) { - PacketBuffer data = createCommonHeader(recipe.getId(), crafting, INLINE_RECIPE_SHAPED); - IRecipeSerializer.CRAFTING_SHAPED.write(data, recipe); + PacketByteBuf data = createCommonHeader(recipe.getId(), crafting, INLINE_RECIPE_SHAPED); + RecipeSerializer.SHAPED.write(data, recipe); this.configureWrite(data); } - private PacketBuffer createCommonHeader(ResourceLocation recipeId, boolean crafting, int inlineRecipeType) { - final PacketBuffer data = new PacketBuffer(Unpooled.buffer()); + private PacketByteBuf createCommonHeader(Identifier recipeId, boolean crafting, int inlineRecipeType) { + final PacketByteBuf data = new PacketByteBuf(Unpooled.buffer()); data.writeInt(this.getPacketID()); data.writeBoolean(crafting); - data.writeResourceLocation(recipeId); + data.writeIdentifier(recipeId); data.writeVarInt(inlineRecipeType); return data; @@ -147,10 +148,10 @@ public class JEIRecipePacket extends BasePacket { public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) { // Setup and verification final ServerPlayerEntity pmp = (ServerPlayerEntity) player; - final Container con = pmp.openContainer; + final ScreenHandler con = pmp.currentScreenHandler; Preconditions.checkArgument(con instanceof IContainerCraftingPacket); - IRecipe recipe = player.getEntityWorld().getRecipeManager().getRecipe(this.recipeId).orElse(null); + Recipe recipe = player.getEntityWorld().getRecipeManager().get(this.recipeId).orElse(null); if (recipe == null && this.recipe != null) { // Certain recipes (i.e. AE2 facades) are represented in JEI as ShapedRecipe's, // while in reality they @@ -175,17 +176,17 @@ public class JEIRecipePacket extends BasePacket { final IEnergyGrid energy = grid.getCache(IEnergyGrid.class); final ICraftingGrid crafting = grid.getCache(ICraftingGrid.class); - final IItemHandler craftMatrix = cct.getInventoryByName("crafting"); - final IItemHandler playerInventory = cct.getInventoryByName("player"); + final FixedItemInv craftMatrix = cct.getInventoryByName("crafting"); + final FixedItemInv playerInventory = cct.getInventoryByName("player"); final IMEMonitor storage = inv .getInventory(Api.instance().storage().getStorageChannel(IItemStorageChannel.class)); final IPartitionList filter = ViewCellItem.createFilter(cct.getViewCells()); - final NonNullList ingredients = this.ensure3by3CraftingMatrix(recipe); + final DefaultedList ingredients = this.ensure3by3CraftingMatrix(recipe); // Handle each slot - for (int x = 0; x < craftMatrix.getSlots(); x++) { - ItemStack currentItem = craftMatrix.getStackInSlot(x); + for (int x = 0; x < craftMatrix.getSlotCount(); x++) { + ItemStack currentItem = craftMatrix.getInvStack(x); Ingredient ingredient = ingredients.get(x); // prepare slots @@ -222,8 +223,8 @@ public class JEIRecipePacket extends BasePacket { if (out == null) { out = findBestMatchingItemStack(ingredient, filter, storage, cct); } - if (out == null && ingredient.getMatchingStacks().length > 0) { - out = AEItemStack.fromItemStack(ingredient.getMatchingStacks()[0]); + if (out == null && getMatchingStacks(ingredient).length > 0) { + out = AEItemStack.fromItemStack(getMatchingStacks(ingredient)[0]); } } @@ -234,10 +235,10 @@ public class JEIRecipePacket extends BasePacket { // If still nothing, search the player inventory. if (currentItem.isEmpty()) { - ItemStack[] matchingStacks = ingredient.getMatchingStacks(); + ItemStack[] matchingStacks = getMatchingStacks(ingredient); for (ItemStack matchingStack : matchingStacks) { if (currentItem.isEmpty()) { - AdaptorItemHandler ad = new AdaptorItemHandler(playerInventory); + AdaptorFixedInv ad = new AdaptorFixedInv(playerInventory); if (cct.useRealItems()) { currentItem = ad.removeItems(1, matchingStack, null); @@ -254,7 +255,21 @@ public class JEIRecipePacket extends BasePacket { this.handleProcessing(con, cct, recipe); } - con.onCraftMatrixChanged(new WrapperInvItemHandler(craftMatrix)); + con.onContentChanged(new WrapperInvItemHandler(craftMatrix)); + } + + @SuppressWarnings("ConstantConditions") + private static ItemStack[] getMatchingStacks(Ingredient ingredient) { + IngredientAccessor accessor = (IngredientAccessor) (Object) ingredient; +// accessor.callCacheMatchingStacks(); + if (ingredient.isEmpty()) { + return new ItemStack[0]; + } + ItemStack[] stacks = accessor.getMatchingStacks(); + if (stacks.length == 1 && stacks[0].isEmpty()) { + return new ItemStack[0]; + } + return stacks; } /** @@ -263,18 +278,18 @@ public class JEIRecipePacket extends BasePacket { * Will throw an {@link IllegalArgumentException} in case it has more than 9 or * a shaped recipe is either wider or higher than 3. ingredients. */ - private NonNullList ensure3by3CraftingMatrix(IRecipe recipe) { - NonNullList ingredients = recipe.getIngredients(); - NonNullList expandedIngredients = NonNullList.withSize(9, Ingredient.EMPTY); + private DefaultedList ensure3by3CraftingMatrix(Recipe recipe) { + DefaultedList ingredients = recipe.getPreviewInputs(); + DefaultedList expandedIngredients = DefaultedList.ofSize(9, Ingredient.EMPTY); Preconditions.checkArgument(ingredients.size() <= 9); // shaped recipes can be smaller than 3x3, expand to 3x3 to match the crafting // matrix - if (recipe instanceof IShapedRecipe) { - IShapedRecipe shapedRecipe = (IShapedRecipe) recipe; - int width = shapedRecipe.getRecipeWidth(); - int height = shapedRecipe.getRecipeHeight(); + if (recipe instanceof ShapedRecipe) { + ShapedRecipe shapedRecipe = (ShapedRecipe) recipe; + int width = shapedRecipe.getWidth(); + int height = shapedRecipe.getHeight(); Preconditions.checkArgument(width <= 3 && height <= 3); for (int h = 0; h < height; h++) { @@ -301,7 +316,7 @@ public class JEIRecipePacket extends BasePacket { * @return is if it can be used, else EMPTY */ private ItemStack canUseInSlot(Ingredient ingredient, ItemStack is) { - return Arrays.stream(ingredient.getMatchingStacks()).filter(p -> p.isItemEqual(is)).findFirst() + return Arrays.stream(getMatchingStacks(ingredient)).filter(p -> p.isItemEqual(is)).findFirst() .orElse(ItemStack.EMPTY); } @@ -310,7 +325,7 @@ public class JEIRecipePacket extends BasePacket { */ private IAEItemStack findBestMatchingItemStack(Ingredient ingredients, IPartitionList filter, IMEMonitor storage, IContainerCraftingPacket cct) { - return Arrays.stream(ingredients.getMatchingStacks()).map(AEItemStack::fromItemStack) // + return Arrays.stream(getMatchingStacks(ingredients)).map(AEItemStack::fromItemStack) // .filter(r -> r != null && (filter == null || filter.isListed(r))) // .map(s -> { // Determine the stored count @@ -329,7 +344,7 @@ public class JEIRecipePacket extends BasePacket { */ private IAEItemStack findBestMatchingPattern(Ingredient ingredients, IPartitionList filter, ICraftingGrid crafting, IMEMonitor storage, IContainerCraftingPacket cct) { - return Arrays.stream(ingredients.getMatchingStacks()).map(AEItemStack::fromItemStack) + return Arrays.stream(getMatchingStacks(ingredients)).map(AEItemStack::fromItemStack) .filter(r -> r != null && (filter == null || filter.isListed(r))) .map(s -> s.setCraftable(!crafting.getCraftingFor(s, null, 0, null).isEmpty())) .filter(IAEItemStack::isCraftable).map(s -> { @@ -341,12 +356,12 @@ public class JEIRecipePacket extends BasePacket { }).orElse(null); } - private void handleProcessing(Container con, IContainerCraftingPacket cct, IRecipe recipe) { + private void handleProcessing(ScreenHandler con, IContainerCraftingPacket cct, Recipe recipe) { if (con instanceof PatternTermContainer) { PatternTermContainer patternTerm = (PatternTermContainer) con; if (!patternTerm.craftingMode) { - final IItemHandler output = cct.getInventoryByName("output"); - ItemHandlerUtil.setStackInSlot(output, 0, recipe.getRecipeOutput()); + final FixedItemInv output = cct.getInventoryByName("output"); + ItemHandlerUtil.setStackInSlot(output, 0, recipe.getOutput()); ItemHandlerUtil.setStackInSlot(output, 1, ItemStack.EMPTY); ItemHandlerUtil.setStackInSlot(output, 2, ItemStack.EMPTY); } diff --git a/src/main/java/appeng/integration/abstraction/IRei.java b/src/main/java/appeng/integration/abstraction/IRei.java index 6684a3767..005a1db5b 100644 --- a/src/main/java/appeng/integration/abstraction/IRei.java +++ b/src/main/java/appeng/integration/abstraction/IRei.java @@ -18,8 +18,6 @@ package appeng.integration.abstraction; -import mezz.jei.api.runtime.IJeiRuntime; - import appeng.integration.IIntegrationModule; /** @@ -27,10 +25,6 @@ import appeng.integration.IIntegrationModule; */ public interface IRei extends IIntegrationModule { - default IJeiRuntime getRuntime() { - return null; - } - default String getSearchText() { return ""; } diff --git a/src/main/java/appeng/integration/modules/jei/CraftingRecipeTransferHandler.java b/src/main/java/appeng/integration/modules/jei/CraftingRecipeTransferHandler.java index 7b3e8e7c2..fe3afd0ad 100644 --- a/src/main/java/appeng/integration/modules/jei/CraftingRecipeTransferHandler.java +++ b/src/main/java/appeng/integration/modules/jei/CraftingRecipeTransferHandler.java @@ -18,24 +18,21 @@ package appeng.integration.modules.jei; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.crafting.IRecipe; - -import mezz.jei.api.gui.IRecipeLayout; -import mezz.jei.api.recipe.transfer.IRecipeTransferError; -import mezz.jei.api.recipe.transfer.IRecipeTransferHandlerHelper; +import me.shedaniel.rei.api.AutoTransferHandler; +import me.shedaniel.rei.api.RecipeDisplay; +import me.shedaniel.rei.api.TransferRecipeDisplay; import appeng.container.implementations.CraftingTermContainer; public class CraftingRecipeTransferHandler extends RecipeTransferHandler { - CraftingRecipeTransferHandler(Class containerClass, IRecipeTransferHandlerHelper helper) { - super(containerClass, helper); + public CraftingRecipeTransferHandler(Class containerClass) { + super(containerClass); } @Override - protected IRecipeTransferError doTransferRecipe(CraftingTermContainer container, IRecipe recipe, - IRecipeLayout recipeLayout, PlayerEntity player, boolean maxTransfer) { + protected AutoTransferHandler.Result doTransferRecipe(CraftingTermContainer container, RecipeDisplay recipe, + AutoTransferHandler.Context context) { return null; } diff --git a/src/main/java/appeng/integration/modules/jei/FacadeRegistryGenerator.java b/src/main/java/appeng/integration/modules/jei/FacadeRegistryGenerator.java index 0f3981507..3f48a7c4d 100644 --- a/src/main/java/appeng/integration/modules/jei/FacadeRegistryGenerator.java +++ b/src/main/java/appeng/integration/modules/jei/FacadeRegistryGenerator.java @@ -108,6 +108,8 @@ class FacadeRegistryGenerator implements LiveRecipeGenerator { - PatternRecipeTransferHandler(Class containerClass, IRecipeTransferHandlerHelper helper) { - super(containerClass, helper); + PatternRecipeTransferHandler(Class containerClass) { + super(containerClass); } - protected IRecipeTransferError doTransferRecipe(PatternTermContainer container, IRecipe recipe, - IRecipeLayout recipeLayout, PlayerEntity player, boolean maxTransfer) { - if (container.isCraftingMode() - && recipeLayout.getRecipeCategory().getUid() != VanillaRecipeCategoryUid.CRAFTING) { - return this.helper - .createUserErrorWithTooltip(I18n.format("jei.appliedenergistics2.requires_processing_mode")); + protected AutoTransferHandler.Result doTransferRecipe(PatternTermContainer container, RecipeDisplay recipe, + AutoTransferHandler.Context context) { + + if (container.isCraftingMode() && recipe.getRecipeCategory() != DefaultPlugin.CRAFTING) { + return AutoTransferHandler.Result.createFailed("jei.appliedenergistics2.requires_processing_mode"); } - if (recipe.getRecipeOutput().isEmpty()) { - return this.helper.createUserErrorWithTooltip(I18n.format("jei.appliedenergistics2.no_output")); + if (recipe.getResultingEntries().isEmpty()) { + return AutoTransferHandler.Result.createFailed("jei.appliedenergistics2.no_output"); } return null; diff --git a/src/main/java/appeng/integration/modules/jei/RecipeTransferHandler.java b/src/main/java/appeng/integration/modules/jei/RecipeTransferHandler.java index 607cb4ab1..99c2ae59f 100644 --- a/src/main/java/appeng/integration/modules/jei/RecipeTransferHandler.java +++ b/src/main/java/appeng/integration/modules/jei/RecipeTransferHandler.java @@ -18,82 +18,70 @@ package appeng.integration.modules.jei; -import java.util.Map; +import java.util.List; +import java.util.stream.Stream; -import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.container.Container; import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.item.crafting.ShapedRecipe; -import net.minecraft.item.crafting.ShapelessRecipe; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; +import net.minecraft.recipe.Ingredient; +import net.minecraft.recipe.ShapedRecipe; +import net.minecraft.screen.ScreenHandler; +import net.minecraft.util.Identifier; +import net.minecraft.util.collection.DefaultedList; -import mezz.jei.api.gui.IRecipeLayout; -import mezz.jei.api.gui.ingredient.IGuiIngredient; -import mezz.jei.api.recipe.transfer.IRecipeTransferError; -import mezz.jei.api.recipe.transfer.IRecipeTransferHandler; -import mezz.jei.api.recipe.transfer.IRecipeTransferHandlerHelper; +import me.shedaniel.rei.api.AutoTransferHandler; +import me.shedaniel.rei.api.EntryStack; +import me.shedaniel.rei.api.RecipeDisplay; +import me.shedaniel.rei.api.TransferRecipeDisplay; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.JEIRecipePacket; import appeng.helpers.IContainerCraftingPacket; -abstract class RecipeTransferHandler - implements IRecipeTransferHandler { +abstract class RecipeTransferHandler + implements AutoTransferHandler { private final Class containerClass; - protected final IRecipeTransferHandlerHelper helper; - RecipeTransferHandler(Class containerClass, IRecipeTransferHandlerHelper helper) { + RecipeTransferHandler(Class containerClass) { this.containerClass = containerClass; - this.helper = helper; } @Override - public final Class getContainerClass() { - return this.containerClass; - } + public AutoTransferHandler.Result handle(AutoTransferHandler.Context context) { + RecipeDisplay recipe = context.getRecipe(); - @Override - public final IRecipeTransferError transferRecipe(T container, Object recipe, IRecipeLayout recipeLayout, - PlayerEntity player, boolean maxTransfer, boolean doTransfer) { - if (!(recipe instanceof IRecipe)) { - return this.helper.createInternalError(); + if (!containerClass.isInstance(context.getContainerScreen().getScreenHandler())) { + return AutoTransferHandler.Result.createNotApplicable(); } - final IRecipe irecipe = (IRecipe) recipe; - final ResourceLocation recipeId = irecipe.getId(); - if (recipeId == null) { - return this.helper.createUserErrorWithTooltip(I18n.format("jei.appliedenergistics2.missing_id")); - } + T container = containerClass.cast(context.getContainerScreen().getScreenHandler()); + + final Identifier recipeId = recipe.getRecipeLocation().orElse(null); // Check that the recipe can actually be looked up via the manager, i.e. our // facade recipes // have an ID, but are never registered with the recipe manager. boolean canSendReference = true; - if (!player.getEntityWorld().getRecipeManager().getRecipe(recipeId).isPresent()) { - // Validate that the recipe is a shapeless or shapedrecipe, since we can - // serialize those - if (!(recipe instanceof ShapedRecipe) && !(recipe instanceof ShapelessRecipe)) { - return this.helper.createUserErrorWithTooltip(I18n.format("jei.appliedenergistics2.missing_id")); - } + if (recipeId == null || !context.getMinecraft().world.getRecipeManager().get(recipeId).isPresent()) { canSendReference = false; } - if (!irecipe.canFit(3, 3)) { - return this.helper.createUserErrorWithTooltip(I18n.format("jei.appliedenergistics2.recipe_too_large")); + if (recipe instanceof TransferRecipeDisplay) { + TransferRecipeDisplay trd = (TransferRecipeDisplay) recipe; + if (trd.getWidth() > 3 || trd.getHeight() > 3) { + return AutoTransferHandler.Result.createFailed("jei.appliedenergistics2.recipe_too_large"); + } + } else if (recipe.getInputEntries().size() > 9) { + return AutoTransferHandler.Result.createFailed("jei.appliedenergistics2.recipe_too_large"); } - final IRecipeTransferError error = doTransferRecipe(container, irecipe, recipeLayout, player, maxTransfer); + final AutoTransferHandler.Result error = doTransferRecipe(container, recipe, context); if (error != null) { return error; } - if (doTransfer) { + if (context.isActuallyCrafting()) { if (canSendReference) { NetworkHandler.instance().sendToServer(new JEIRecipePacket(recipeId, isCrafting())); } else { @@ -102,31 +90,29 @@ abstract class RecipeTransferHandler flatIngredients = NonNullList.withSize(9, Ingredient.EMPTY); - ItemStack output = ItemStack.EMPTY; - - // Determine the first JEI slot that has an actual input, we'll use this to - // offset the - // crafting grid target slot - int firstInputSlot = recipeLayout.getItemStacks().getGuiIngredients().entrySet().stream() - .filter(e -> e.getValue().isInput()).mapToInt(Map.Entry::getKey).min().orElse(0); + DefaultedList flatIngredients = DefaultedList.ofSize(9, Ingredient.EMPTY); + ItemStack output = null; + for (EntryStack entryStack : recipe.getResultingEntries().get(0)) { + if (entryStack.getType() == EntryStack.Type.ITEM) { + output = entryStack.getItemStack(); + } + } + if (output == null || output.isEmpty()) { + return AutoTransferHandler.Result.createFailed("jei.appliedenergistics2.no_output"); + } // Now map the actual ingredients into the output/input - for (Map.Entry> entry : recipeLayout.getItemStacks() - .getGuiIngredients().entrySet()) { - IGuiIngredient item = entry.getValue(); - if (item.getDisplayedIngredient() == null) { + for (int i = 0; i < recipe.getInputEntries().size(); i++) { + List inputEntry = recipe.getInputEntries().get(i); + if (inputEntry.isEmpty()) { continue; } - - int inputIndex = entry.getKey() - firstInputSlot; - if (item.isInput() && inputIndex < flatIngredients.size()) { - ItemStack displayedIngredient = item.getDisplayedIngredient(); + EntryStack first = inputEntry.get(0); + if (i < flatIngredients.size()) { + ItemStack displayedIngredient = first.getItemStack(); if (displayedIngredient != null) { - flatIngredients.set(inputIndex, Ingredient.fromStacks(displayedIngredient)); + flatIngredients.set(i, Ingredient.method_26964(Stream.of(displayedIngredient))); } - } else if (!item.isInput() && output.isEmpty()) { - output = item.getDisplayedIngredient(); } } @@ -135,11 +121,11 @@ abstract class RecipeTransferHandler recipe, IRecipeLayout recipeLayout, - PlayerEntity player, boolean maxTransfer); + protected abstract AutoTransferHandler.Result doTransferRecipe(T container, RecipeDisplay recipe, + AutoTransferHandler.Context context); protected abstract boolean isCrafting(); } diff --git a/src/main/java/appeng/integration/modules/jei/ReiPlugin.java b/src/main/java/appeng/integration/modules/jei/ReiPlugin.java index a43d10410..8317154be 100644 --- a/src/main/java/appeng/integration/modules/jei/ReiPlugin.java +++ b/src/main/java/appeng/integration/modules/jei/ReiPlugin.java @@ -32,7 +32,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; -import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.BaseBoundsHandler; import me.shedaniel.rei.api.DisplayHelper; import me.shedaniel.rei.api.EntryRegistry; @@ -124,8 +123,8 @@ public class ReiPlugin implements REIPluginV0 { @Override public void registerOthers(RecipeHelper recipeHelper) { // Allow recipe transfer from JEI to crafting and pattern terminal - recipeHelper.registerAutoCraftingHandler(new RecipeTransferHandler<>(CraftingTermContainer.class)); - recipeHelper.registerAutoCraftingHandler(new RecipeTransferHandler<>(PatternTermContainer.class)); + recipeHelper.registerAutoCraftingHandler(new CraftingRecipeTransferHandler(CraftingTermContainer.class)); + recipeHelper.registerAutoCraftingHandler(new PatternRecipeTransferHandler(PatternTermContainer.class)); recipeHelper.removeAutoCraftButton(GrinderRecipeCategory.UID); recipeHelper.removeAutoCraftButton(InscriberRecipeCategory.UID); @@ -227,7 +226,7 @@ public class ReiPlugin implements REIPluginV0 { ItemStack stack = entryStack.getItemStack(); if (items.dummyFluidItem().isSameAs(stack) || items.facade().isSameAs(stack) // REI will add a broken facade - // with no NBT + // with no NBT || blocks.multiPart().isSameAs(stack) || blocks.matrixFrame().isSameAs(stack) || blocks.paint().isSameAs(stack)) { return true; diff --git a/src/main/java/appeng/integration/modules/jei/ReiRuntimeAdapter.java b/src/main/java/appeng/integration/modules/jei/ReiRuntimeAdapter.java index fbfb608de..45ba2694b 100644 --- a/src/main/java/appeng/integration/modules/jei/ReiRuntimeAdapter.java +++ b/src/main/java/appeng/integration/modules/jei/ReiRuntimeAdapter.java @@ -39,10 +39,6 @@ class ReiRuntimeAdapter implements IRei { return true; } - public IJeiRuntime getRuntime() { - return runtime; - } - @Override public String getSearchText() { TextFieldWidget searchField = this.runtime.getSearchTextField(); diff --git a/src/main/java/appeng/mixins/IngredientAccessor.java b/src/main/java/appeng/mixins/IngredientAccessor.java new file mode 100644 index 000000000..54fdfebad --- /dev/null +++ b/src/main/java/appeng/mixins/IngredientAccessor.java @@ -0,0 +1,19 @@ +package appeng.mixins; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.gen.Invoker; + +import net.minecraft.item.ItemStack; +import net.minecraft.recipe.Ingredient; + +@Mixin(Ingredient.class) +public interface IngredientAccessor { + + @Invoker + void callCacheMatchingStacks(); + + @Accessor + ItemStack[] getMatchingStacks(); + +} diff --git a/src/main/java/appeng/parts/automation/FormationPlanePart.java b/src/main/java/appeng/parts/automation/FormationPlanePart.java index 8790c4932..6114e30f3 100644 --- a/src/main/java/appeng/parts/automation/FormationPlanePart.java +++ b/src/main/java/appeng/parts/automation/FormationPlanePart.java @@ -291,7 +291,7 @@ public class FormationPlanePart extends AbstractFormationPlanePart // Replace it if there is a custom entity if (is.getItem() instanceof AECustomEntityItem) { - Entity result = ((AECustomEntityItem) is.getItem()).replaceItemEntity(w, entity, is); + Entity result = ((AECustomEntityItem) is.getItem()).replaceItemEntity(w, (ItemEntity) entity, is); // Destroy the old one, in case it's spawned somehow and replace with the new // one. if (result != entity) { @@ -300,16 +300,6 @@ public class FormationPlanePart extends AbstractFormationPlanePart } } - if (is.getItem().hasCustomEntity(is)) { - Entity result = is.getItem().createEntity(w, entity, is); - // Destroy the old one, in case it's spawned somehow and replace with the new - // one. - if (result != null) { - entity.remove(); - entity = result; - } - } - // When spawning downwards, we have to take into account that it spawns it at // their "feet" and not center like x or z. So we move it up to be flush with // the plane @@ -340,7 +330,7 @@ public class FormationPlanePart extends AbstractFormationPlanePart final double absoluteZ = centerZ + offsetZ; // Set to correct position and slow the motion down a bit - entity.setPosition(absoluteX, absoluteY, absoluteZ); + entity.setPos(absoluteX, absoluteY, absoluteZ); entity.setVelocity(side.xOffset * .1, side.yOffset * 0.1, side.zOffset * 0.1); // Try to spawn it and destroy it in case it's not possible diff --git a/src/main/resources/appliedenergistics2.mixins.json b/src/main/resources/appliedenergistics2.mixins.json index a87d82dec..4f99da186 100644 --- a/src/main/resources/appliedenergistics2.mixins.json +++ b/src/main/resources/appliedenergistics2.mixins.json @@ -25,7 +25,8 @@ "TntAccessor", "ServerWorldCustomItemEntityMixin", "BootstrapMixin", - "ItemEntityAccessor" + "ItemEntityAccessor", + "IngredientAccessor" ], "client": [ "spatial.SkyRenderMixin", diff --git a/src/main/resources/assets/appliedenergistics2/lang/en_gb.json b/src/main/resources/assets/appliedenergistics2/lang/en_gb.json index 9b534cb5e..9fa387e19 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/en_gb.json +++ b/src/main/resources/assets/appliedenergistics2/lang/en_gb.json @@ -2,8 +2,8 @@ "gui.appliedenergistics2.Gray": "Grey", "gui.appliedenergistics2.LightGray": "Light Grey", "gui.appliedenergistics2.inWorldCraftingPresses": "Crafting Presses are found in the centre of meteorites which can be found in around the world, they can be located by using a meteorite compass.", - "gui.tooltips.appliedenergistics2.SearchMode_JEIAuto": "JEI Synchronised Auto", - "gui.tooltips.appliedenergistics2.SearchMode_JEIStandard": "JEI Synchronised Standard", + "gui.tooltips.appliedenergistics2.SearchMode_JEIAuto": "REI Synchronised Auto", + "gui.tooltips.appliedenergistics2.SearchMode_JEIStandard": "REI Synchronised Standard", "gui.tooltips.appliedenergistics2.TerminalStyle_Small": "Small Centered Terminal", "gui.tooltips.appliedenergistics2.TerminalStyle_Tall": "Tall Centered Terminal", "item.appliedenergistics2.color_applicator": "Colour Applicator" diff --git a/src/main/resources/assets/appliedenergistics2/lang/en_us.json b/src/main/resources/assets/appliedenergistics2/lang/en_us.json index 5f152f1bb..9ecfa4a7a 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/en_us.json +++ b/src/main/resources/assets/appliedenergistics2/lang/en_us.json @@ -380,10 +380,10 @@ "gui.tooltips.appliedenergistics2.SearchMode": "Search Box Mode", "gui.tooltips.appliedenergistics2.SearchMode_Auto": "Auto Search", "gui.tooltips.appliedenergistics2.SearchMode_AutoKeep": "Auto Search Keep", - "gui.tooltips.appliedenergistics2.SearchMode_JEIAuto": "JEI Synchronized Auto", - "gui.tooltips.appliedenergistics2.SearchMode_JEIAutoKeep": "JEI Synchronized Auto Keep", - "gui.tooltips.appliedenergistics2.SearchMode_JEIStandard": "JEI Synchronized Standard", - "gui.tooltips.appliedenergistics2.SearchMode_JEIStandardKeep": "JEI Synchronized Standard Keep", + "gui.tooltips.appliedenergistics2.SearchMode_JEIAuto": "REI Synchronized Auto", + "gui.tooltips.appliedenergistics2.SearchMode_JEIAutoKeep": "REI Synchronized Auto Keep", + "gui.tooltips.appliedenergistics2.SearchMode_JEIStandard": "REI Synchronized Standard", + "gui.tooltips.appliedenergistics2.SearchMode_JEIStandardKeep": "REI Synchronized Standard Keep", "gui.tooltips.appliedenergistics2.SearchMode_Standard": "Standard Search", "gui.tooltips.appliedenergistics2.SearchMode_StandardKeep": "Standard Search Keep", "gui.tooltips.appliedenergistics2.Singularity": "Condense Into Singularities\n%s per item",