mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-22 19:58:35 +01:00
parent
a06c91be5a
commit
bb06cb34eb
4 changed files with 9 additions and 9 deletions
|
@ -113,8 +113,7 @@ public class PacketButton {
|
||||||
}),
|
}),
|
||||||
CRAFT_TERMINAL_REQUEST((pos, data, player) -> {
|
CRAFT_TERMINAL_REQUEST((pos, data, player) -> {
|
||||||
CraftingTerminalTileEntity tile = Utility.getTileEntity(CraftingTerminalTileEntity.class, player.world, pos);
|
CraftingTerminalTileEntity tile = Utility.getTileEntity(CraftingTerminalTileEntity.class, player.world, pos);
|
||||||
boolean all = data[0] > 0;
|
tile.requestCraftingItems(player, data[0]);
|
||||||
tile.requestCraftingItems(player, all);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
public final TriConsumer<BlockPos, int[], PlayerEntity> action;
|
public final TriConsumer<BlockPos, int[], PlayerEntity> action;
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class CraftingTerminalTileEntity extends ItemTerminalTileEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestCraftingItems(PlayerEntity player, boolean all) {
|
public void requestCraftingItems(PlayerEntity player, int maxAmount) {
|
||||||
PipeNetwork network = PipeNetwork.get(this.world);
|
PipeNetwork network = PipeNetwork.get(this.world);
|
||||||
network.startProfile("terminal_request_crafting");
|
network.startProfile("terminal_request_crafting");
|
||||||
this.updateItems();
|
this.updateItems();
|
||||||
|
@ -137,9 +137,9 @@ public class CraftingTerminalTileEntity extends ItemTerminalTileEntity {
|
||||||
player.sendMessage(new TranslationTextComponent("info." + PrettyPipes.ID + ".not_found", stack.stack.getDisplayName()).setStyle(Style.EMPTY.setFormatting(TextFormatting.RED)), UUID.randomUUID());
|
player.sendMessage(new TranslationTextComponent("info." + PrettyPipes.ID + ".not_found", stack.stack.getDisplayName()).setStyle(Style.EMPTY.setFormatting(TextFormatting.RED)), UUID.randomUUID());
|
||||||
}
|
}
|
||||||
if (lowestAvailable > 0) {
|
if (lowestAvailable > 0) {
|
||||||
// if we're only crafting one item, pretend we only have enough for one
|
// if we're limiting the amount, pretend we only have that amount available
|
||||||
if (!all)
|
if (maxAmount < lowestAvailable)
|
||||||
lowestAvailable = 1;
|
lowestAvailable = maxAmount;
|
||||||
for (int i = 0; i < this.craftItems.getSlots(); i++) {
|
for (int i = 0; i < this.craftItems.getSlots(); i++) {
|
||||||
ItemStack requested = this.getRequestedCraftItem(i);
|
ItemStack requested = this.getRequestedCraftItem(i);
|
||||||
if (requested.isEmpty())
|
if (requested.isEmpty())
|
||||||
|
|
|
@ -31,8 +31,8 @@ public class CraftingTerminalGui extends ItemTerminalGui {
|
||||||
protected void init() {
|
protected void init() {
|
||||||
super.init();
|
super.init();
|
||||||
this.requestButton = this.addButton(new Button(this.guiLeft + 8, this.guiTop + 100, 50, 20, new TranslationTextComponent("info." + PrettyPipes.ID + ".request"), button -> {
|
this.requestButton = this.addButton(new Button(this.guiLeft + 8, this.guiTop + 100, 50, 20, new TranslationTextComponent("info." + PrettyPipes.ID + ".request"), button -> {
|
||||||
int all = hasShiftDown() ? 1 : 0;
|
int amount = requestModifier();
|
||||||
PacketHandler.sendToServer(new PacketButton(this.container.tile.getPos(), PacketButton.ButtonResult.CRAFT_TERMINAL_REQUEST, all));
|
PacketHandler.sendToServer(new PacketButton(this.container.tile.getPos(), PacketButton.ButtonResult.CRAFT_TERMINAL_REQUEST, amount));
|
||||||
}));
|
}));
|
||||||
this.tick();
|
this.tick();
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ public class ItemTerminalGui extends ContainerScreen<ItemTerminalContainer> {
|
||||||
} else {
|
} else {
|
||||||
this.requestAmount += modifier;
|
this.requestAmount += modifier;
|
||||||
}
|
}
|
||||||
|
// 384 items is 6 stacks, which is what fits into the terminal slots
|
||||||
if (this.requestAmount > 384)
|
if (this.requestAmount > 384)
|
||||||
this.requestAmount = 384;
|
this.requestAmount = 384;
|
||||||
}));
|
}));
|
||||||
|
@ -247,7 +248,7 @@ public class ItemTerminalGui extends ContainerScreen<ItemTerminalContainer> {
|
||||||
.map(w -> (ItemTerminalWidget) w);
|
.map(w -> (ItemTerminalWidget) w);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int requestModifier() {
|
public static int requestModifier() {
|
||||||
if (hasControlDown()) {
|
if (hasControlDown()) {
|
||||||
return 10;
|
return 10;
|
||||||
} else if (hasShiftDown()) {
|
} else if (hasShiftDown()) {
|
||||||
|
|
Loading…
Reference in a new issue