fix: jei transfer not working in single player
This commit is contained in:
@@ -10,6 +10,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixed JEI transfer in the Pattern Grid wrongly choosing "Processing" mode.
|
- Fixed JEI transfer in the Pattern Grid wrongly choosing "Processing" mode.
|
||||||
|
- Fixed JEI transfer not working in single player.
|
||||||
|
|
||||||
## [1.13.0-beta.1] - 2024-02-12
|
## [1.13.0-beta.1] - 2024-02-12
|
||||||
|
|
||||||
|
@@ -46,7 +46,6 @@ public abstract class NetworkNodeBlock extends BaseBlock implements EntityBlock
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) {
|
public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||||
if (state.getBlock() != newState.getBlock()) {
|
if (state.getBlock() != newState.getBlock()) {
|
||||||
BlockEntity blockEntity = level.getBlockEntity(pos);
|
BlockEntity blockEntity = level.getBlockEntity(pos);
|
||||||
|
@@ -156,7 +156,12 @@ public class GridRecipeTransferHandler implements IRecipeTransferHandler<GridCon
|
|||||||
return stacks;
|
return stacks;
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
RS.NETWORK_HANDLER.sendToServer(new GridTransferMessage(inputs));
|
final ItemStack[][] inputsArray = new ItemStack[inputs.size()][];
|
||||||
|
for (int i = 0; i < inputs.size(); i++) {
|
||||||
|
inputsArray[i] = inputs.get(i).toArray(new ItemStack[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
RS.NETWORK_HANDLER.sendToServer(new GridTransferMessage(inputsArray));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveForProcessing(IRecipeSlotsView recipeLayout, GridContainerMenu gridContainer, Player player) {
|
private void moveForProcessing(IRecipeSlotsView recipeLayout, GridContainerMenu gridContainer, Player player) {
|
||||||
|
@@ -16,30 +16,23 @@ import java.util.List;
|
|||||||
public class GridTransferMessage implements CustomPacketPayload {
|
public class GridTransferMessage implements CustomPacketPayload {
|
||||||
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "grid_transfer");
|
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "grid_transfer");
|
||||||
|
|
||||||
private ItemStack[][] recipe;
|
private final ItemStack[][] recipe;
|
||||||
private List<List<ItemStack>> inputs;
|
|
||||||
|
|
||||||
public GridTransferMessage() {
|
public GridTransferMessage(final ItemStack[][] recipe) {
|
||||||
}
|
this.recipe = recipe;
|
||||||
|
|
||||||
public GridTransferMessage(List<List<ItemStack>> inputs) {
|
|
||||||
this.inputs = inputs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GridTransferMessage decode(FriendlyByteBuf buf) {
|
public static GridTransferMessage decode(FriendlyByteBuf buf) {
|
||||||
GridTransferMessage msg = new GridTransferMessage();
|
|
||||||
int slots = buf.readInt();
|
int slots = buf.readInt();
|
||||||
msg.recipe = new ItemStack[slots][];
|
final ItemStack[][] recipe = new ItemStack[slots][];
|
||||||
for (int i = 0; i < slots; i++) {
|
for (int i = 0; i < slots; i++) {
|
||||||
int numberOfIngredients = buf.readInt();
|
int numberOfIngredients = buf.readInt();
|
||||||
msg.recipe[i] = new ItemStack[numberOfIngredients];
|
recipe[i] = new ItemStack[numberOfIngredients];
|
||||||
|
|
||||||
for (int j = 0; j < numberOfIngredients; j++) {
|
for (int j = 0; j < numberOfIngredients; j++) {
|
||||||
msg.recipe[i][j] = StackUtils.readItemStack(buf);
|
recipe[i][j] = StackUtils.readItemStack(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return new GridTransferMessage(recipe);
|
||||||
return msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handle(GridTransferMessage message, PlayPayloadContext ctx) {
|
public static void handle(GridTransferMessage message, PlayPayloadContext ctx) {
|
||||||
@@ -56,10 +49,9 @@ public class GridTransferMessage implements CustomPacketPayload {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(FriendlyByteBuf buf) {
|
public void write(FriendlyByteBuf buf) {
|
||||||
buf.writeInt(inputs.size());
|
buf.writeInt(recipe.length);
|
||||||
for (List<ItemStack> stacks : inputs) {
|
for (ItemStack[] stacks : recipe) {
|
||||||
buf.writeInt(stacks.size());
|
buf.writeInt(stacks.length);
|
||||||
|
|
||||||
for (ItemStack possibleStack : stacks) {
|
for (ItemStack possibleStack : stacks) {
|
||||||
StackUtils.writeItemStack(buf, possibleStack);
|
StackUtils.writeItemStack(buf, possibleStack);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user