Add gui and packets for locking the rolling machine. #1412

This commit is contained in:
modmuss50 2018-04-05 10:31:22 +01:00
parent d8f3a8b9b0
commit c17f232bf8
No known key found for this signature in database
GPG key ID: 773D17BE8BF49C82
6 changed files with 98 additions and 10 deletions

View file

@ -25,8 +25,12 @@
package techreborn.client.gui;
import net.minecraft.entity.player.EntityPlayer;
import reborncore.common.network.NetworkManager;
import techreborn.packets.PacketRollingMachineLock;
import techreborn.tiles.TileRollingMachine;
import java.io.IOException;
public class GuiRollingMachine extends GuiBase {
TileRollingMachine rollingMachine;
@ -50,6 +54,7 @@ public class GuiRollingMachine extends GuiBase {
this.drawOutputSlot(124, gridYPos + 18, layer);
this.builder.drawJEIButton(this, 150, 4, layer);
this.builder.drawLockButton(this, 130, 4, mouseX, mouseY, layer,rollingMachine.locked);
}
@Override
@ -60,4 +65,13 @@ public class GuiRollingMachine extends GuiBase {
this.builder.drawProgressBar(this, this.rollingMachine.getProgressScaled(100), 100, 92, 43, mouseX, mouseY, TRBuilder.ProgressDirection.RIGHT, layer);
this.builder.drawMultiEnergyBar(this, 9, 17, (int) this.rollingMachine.getEnergy(), (int) this.rollingMachine.getMaxPower(), mouseX, mouseY, 0, layer);
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
if(this.builder.isInRect(130 + getGuiLeft(), 4 + getGuiTop(), 20, 12, mouseX, mouseY)){
NetworkManager.sendToServer(new PacketRollingMachineLock(rollingMachine, !rollingMachine.locked));
return;
}
super.mouseClicked(mouseX, mouseY, mouseButton);
}
}

View file

@ -228,6 +228,30 @@ public class TRBuilder extends GuiBuilder {
}
}
public void drawLockButton(GuiBase gui, int x, int y, int mouseX, int mouseY, GuiBase.Layer layer, boolean locked) {
if(GuiBase.showSlotConfig){
return;
}
if (layer == GuiBase.Layer.BACKGROUND) {
x += gui.getGuiLeft();
y += gui.getGuiTop();
}
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
gui.drawTexturedModalRect(x, y, 204, 70 + (locked ? 12 : 0) , 20, 12);
if (isInRect(x, y, 20, 12, mouseX, mouseY)) {
List<String> list = new ArrayList<>();
if(locked){
list.add("Unlock items");
} else {
list.add("Lock Items");
}
GlStateManager.pushMatrix();
net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(list, mouseX, mouseY, gui.width, gui.height, 80, gui.mc.fontRenderer);
GlStateManager.popMatrix();
}
}
public void drawHologramButton(GuiBase gui, int x, int y, int mouseX, int mouseY, GuiBase.Layer layer) {
if(GuiBase.showSlotConfig){
return;