-
-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a button to the QIO crafting windows to allow emptying the grid t…
…o the QIO storage/player's inventory
- Loading branch information
1 parent
94fe7c6
commit c4c9737
Showing
9 changed files
with
105 additions
and
6 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
src/datagen/generated/mekanism/.cache/ef78a28b75a57238cdbddc354771ab0fbdd2908a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
// 1.19 2022-07-28T14:42:43.4374534 Languages: en_us: mekanism | ||
00299ad845351c79bcaaac6748e01a8435eab248 assets/mekanism/lang/en_ud.json | ||
97c144f7a8902b1c06eded4b81597c1cab835429 assets/mekanism/lang/en_us.json | ||
// 1.19 2022-07-28T15:54:04.7130404 Languages: en_us: mekanism | ||
9b52eac698f6422e6fc5b856cb96dffef256e794 assets/mekanism/lang/en_ud.json | ||
b67eb9332d1a183dc1891e60fa85e0a53efd038a assets/mekanism/lang/en_us.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/mekanism/common/network/to_server/PacketQIOClearCraftingWindow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package mekanism.common.network.to_server; | ||
|
||
import mekanism.common.Mekanism; | ||
import mekanism.common.content.qio.QIOCraftingWindow; | ||
import mekanism.common.inventory.container.QIOItemViewerContainer; | ||
import mekanism.common.network.IMekanismPacket; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraftforge.network.NetworkEvent; | ||
|
||
public class PacketQIOClearCraftingWindow implements IMekanismPacket { | ||
|
||
private final byte window; | ||
private final boolean toPlayerInv; | ||
|
||
public PacketQIOClearCraftingWindow(byte window, boolean toPlayerInv) { | ||
this.window = window; | ||
this.toPlayerInv = toPlayerInv; | ||
} | ||
|
||
@Override | ||
public void handle(NetworkEvent.Context context) { | ||
ServerPlayer player = context.getSender(); | ||
if (player != null && player.containerMenu instanceof QIOItemViewerContainer container) { | ||
byte selectedCraftingGrid = container.getSelectedCraftingGrid(player.getUUID()); | ||
if (selectedCraftingGrid == -1) { | ||
Mekanism.logger.warn("Received clear request from: {}, but they do not currently have a crafting window open.", player); | ||
} else if (selectedCraftingGrid != window) { | ||
Mekanism.logger.warn("Received clear request from: {}, but they currently have a different crafting window open.", player); | ||
} else { | ||
QIOCraftingWindow craftingWindow = container.getCraftingWindow(selectedCraftingGrid); | ||
craftingWindow.emptyTo(toPlayerInv, container.getHotBarSlots(), container.getMainInventorySlots()); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void encode(FriendlyByteBuf buffer) { | ||
buffer.writeByte(window); | ||
buffer.writeBoolean(toPlayerInv); | ||
} | ||
|
||
public static PacketQIOClearCraftingWindow decode(FriendlyByteBuf buffer) { | ||
return new PacketQIOClearCraftingWindow(buffer.readByte(), buffer.readBoolean()); | ||
} | ||
} |