mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-06-02 12:03:37 +02:00
55 lines
2 KiB
Java
55 lines
2 KiB
Java
package de.ellpeck.prettypipes.terminal.containers;
|
|
|
|
import de.ellpeck.prettypipes.PrettyPipes;
|
|
import de.ellpeck.prettypipes.packets.PacketButton;
|
|
import de.ellpeck.prettypipes.packets.PacketHandler;
|
|
import de.ellpeck.prettypipes.packets.PacketRequest;
|
|
import de.ellpeck.prettypipes.terminal.CraftingTerminalTileEntity;
|
|
import net.minecraft.client.gui.widget.Widget;
|
|
import net.minecraft.client.gui.widget.button.Button;
|
|
import net.minecraft.client.resources.I18n;
|
|
import net.minecraft.entity.player.PlayerInventory;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.util.ResourceLocation;
|
|
import net.minecraft.util.text.ITextComponent;
|
|
|
|
public class CraftingTerminalGui extends ItemTerminalGui {
|
|
private static final ResourceLocation TEXTURE = new ResourceLocation(PrettyPipes.ID, "textures/gui/crafting_terminal.png");
|
|
private Button requestButton;
|
|
|
|
public CraftingTerminalGui(ItemTerminalContainer screenContainer, PlayerInventory inv, ITextComponent titleIn) {
|
|
super(screenContainer, inv, titleIn);
|
|
this.xSize = 256;
|
|
}
|
|
|
|
@Override
|
|
protected void init() {
|
|
super.init();
|
|
this.requestButton = this.addButton(new Button(this.guiLeft + 8, this.guiTop + 100, 50, 20, I18n.format("info." + PrettyPipes.ID + ".request"), button -> {
|
|
int all = hasShiftDown() ? 1 : 0;
|
|
PacketHandler.sendToServer(new PacketButton(this.container.tile.getPos(), PacketButton.ButtonResult.CRAFT_TERMINAL_REQUEST, all));
|
|
}));
|
|
this.requestButton.active = !this.getCraftingContainer().craftInventory.isEmpty();
|
|
}
|
|
|
|
@Override
|
|
public void tick() {
|
|
super.tick();
|
|
this.requestButton.active = !this.getCraftingContainer().craftInventory.isEmpty();
|
|
}
|
|
|
|
@Override
|
|
protected ResourceLocation getTexture() {
|
|
return TEXTURE;
|
|
}
|
|
|
|
@Override
|
|
protected int getXOffset() {
|
|
return 65;
|
|
}
|
|
|
|
protected CraftingTerminalContainer getCraftingContainer() {
|
|
return (CraftingTerminalContainer) this.container;
|
|
}
|
|
}
|