Add the basic gui for side configuration
This commit is contained in:
parent
088f49c305
commit
7541ba4dbb
3 changed files with 59 additions and 8 deletions
|
@ -97,17 +97,18 @@ public class GuiBase extends GuiContainer {
|
|||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
builder.drawDefaultBackground(this, guiLeft, guiTop, xSize, ySize);
|
||||
builder.drawPlayerSlots(this, guiLeft + xSize / 2, guiTop + 93, true);
|
||||
if(tile instanceof IUpgradeable){
|
||||
if(tryAddUpgrades() && tile instanceof IUpgradeable){
|
||||
IUpgradeable upgradeable = (IUpgradeable) tile;
|
||||
if(upgradeable.canBeUpgraded()){
|
||||
// for (int i = 0; i < upgradeable.getUpgradeSlotCount(); i++) {
|
||||
// drawSlot(-22, i * 22 + 5, Layer.BACKGROUND);
|
||||
// }
|
||||
builder.drawUpgrades(this, upgradeable, guiLeft, guiTop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean tryAddUpgrades(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package techreborn.client.gui.upgrades;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
|
||||
/**
|
||||
* Created by Mark on 12/04/2017.
|
||||
*/
|
||||
public class GuiSideConfig extends GuiBase {
|
||||
|
||||
public GuiSideConfig(EntityPlayer player, TileEntity tile, BuiltContainer container) {
|
||||
super(player, tile, container);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||
final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawTitle() {
|
||||
drawCentredString("Side Configuration", 6, 4210752, Layer.FOREGROUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryAddUpgrades() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
package techreborn.items;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
@ -43,6 +44,8 @@ import reborncore.common.tile.TileLegacyMachineBase;
|
|||
import reborncore.common.util.InventoryHelper;
|
||||
import techreborn.client.TechRebornCreativeTabMisc;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import techreborn.client.gui.upgrades.GuiSideConfig;
|
||||
import techreborn.init.ModItems;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -153,10 +156,16 @@ public class ItemUpgrades extends ItemTRNoDestroy implements IUpgrade {
|
|||
|
||||
@Override
|
||||
public void handleRightClick(TileEntity tile, ItemStack stack, BuiltContainer container) {
|
||||
if(stack.getItemDamage() == 4){
|
||||
System.out.println("open a gui here");
|
||||
} else if(stack.getItemDamage() == 5){
|
||||
System.out.println("open a gui here");
|
||||
if(tile.getWorld().isRemote){
|
||||
if(stack.getItemDamage() == 4){
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiSideConfig(Minecraft.getMinecraft().player, tile, getContainer(Minecraft.getMinecraft().player)));
|
||||
} else if(stack.getItemDamage() == 5){
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiSideConfig(Minecraft.getMinecraft().player, tile, getContainer(Minecraft.getMinecraft().player)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BuiltContainer getContainer(EntityPlayer player){
|
||||
return new ContainerBuilder("sides").player(player.inventory).inventory().hotbar().addInventory().create();
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue