Fixed multiple bugs related to transferring recipes into the Crafting Grid.
Cherry picked from e0fab68fd3957ee5081a0a709b7fb7c6f7c704a9
This commit is contained in:
@@ -210,7 +210,7 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||
// If we are connected, first try to get the possibilities from the network
|
||||
if (network != null && grid.isGridActive()) {
|
||||
for (ItemStack possibility : possibilities) {
|
||||
ItemStack took = network.extractItem(possibility, 1, IComparer.COMPARE_NBT, Action.PERFORM);
|
||||
ItemStack took = network.extractItem(possibility, possibility.getCount(), IComparer.COMPARE_NBT, Action.PERFORM);
|
||||
|
||||
if (!took.isEmpty()) {
|
||||
grid.getCraftingMatrix().setItem(i, took);
|
||||
|
@@ -151,14 +151,15 @@ public class GridRecipeTransferHandler implements IRecipeTransferHandler<GridCon
|
||||
if (gridContainer.getGrid().getGridType() == GridType.PATTERN && !(recipe instanceof CraftingRecipe)) {
|
||||
moveForProcessing(recipeLayout, tracker);
|
||||
} else {
|
||||
move(gridContainer, recipeLayout);
|
||||
move(gridContainer, recipeLayout, recipe);
|
||||
}
|
||||
}
|
||||
|
||||
private void move(GridContainerMenu gridContainer, IRecipeLayout recipeLayout) {
|
||||
private void move(GridContainerMenu gridContainer, IRecipeLayout recipeLayout, Object recipe) {
|
||||
RS.NETWORK_HANDLER.sendToServer(new GridTransferMessage(
|
||||
recipeLayout.getItemStacks().getGuiIngredients(),
|
||||
gridContainer.slots.stream().filter(s -> s.container instanceof CraftingContainer).collect(Collectors.toList())
|
||||
gridContainer.slots.stream().filter(s -> s.container instanceof CraftingContainer).collect(Collectors.toList()),
|
||||
recipe instanceof CraftingRecipe
|
||||
));
|
||||
}
|
||||
|
||||
|
@@ -20,13 +20,15 @@ public class GridTransferMessage {
|
||||
private final ItemStack[][] recipe = new ItemStack[9][];
|
||||
private Map<Integer, ? extends IGuiIngredient<ItemStack>> inputs;
|
||||
private List<Slot> slots;
|
||||
boolean isCraftingRecipe;
|
||||
|
||||
public GridTransferMessage() {
|
||||
}
|
||||
|
||||
public GridTransferMessage(Map<Integer, ? extends IGuiIngredient<ItemStack>> inputs, List<Slot> slots) {
|
||||
public GridTransferMessage(Map<Integer, ? extends IGuiIngredient<ItemStack>> inputs, List<Slot> slots, boolean isCraftingRecipe) {
|
||||
this.inputs = inputs;
|
||||
this.slots = slots;
|
||||
this.isCraftingRecipe = isCraftingRecipe;
|
||||
}
|
||||
|
||||
public static GridTransferMessage decode(FriendlyByteBuf buf) {
|
||||
@@ -51,7 +53,7 @@ public class GridTransferMessage {
|
||||
buf.writeInt(message.slots.size());
|
||||
|
||||
for (Slot slot : message.slots) {
|
||||
IGuiIngredient<ItemStack> ingredient = message.inputs.get(slot.getSlotIndex() + 1);
|
||||
IGuiIngredient<ItemStack> ingredient = message.inputs.get(slot.getSlotIndex() + (message.isCraftingRecipe ? 1 : 0));
|
||||
|
||||
List<ItemStack> ingredients = new ArrayList<>();
|
||||
|
||||
|
Reference in New Issue
Block a user