Finished the gui, and start work on adding support for the furnace.
This commit is contained in:
parent
7541ba4dbb
commit
d9af8309b1
8 changed files with 167 additions and 27 deletions
|
@ -107,7 +107,7 @@ public class BuiltContainer extends Container {
|
|||
|
||||
@Override
|
||||
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
|
||||
if(slotId > 0 && slotId < 1000){
|
||||
if(dragType == 1 && slotId > 0 && slotId < 1000){
|
||||
Slot slot = this.inventorySlots.get(slotId);
|
||||
if(slot instanceof IRightClickHandler){
|
||||
if(((IRightClickHandler) slot).handleRightClick(slot.getSlotIndex(), player, this)){
|
||||
|
|
|
@ -68,7 +68,7 @@ public class UpgradeSlot extends Slot implements IRightClickHandler {
|
|||
ItemStack stack = upgradeable.getUpgradeInvetory().getStackInSlot(slotID);
|
||||
if(!stack.isEmpty() && stack.getItem() instanceof IUpgrade){
|
||||
//Called on both sides :)
|
||||
((IUpgrade) stack.getItem()).handleRightClick(tileEntity, stack, container);
|
||||
((IUpgrade) stack.getItem()).handleRightClick(tileEntity, stack, container, slotID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,9 @@ public class GuiBase extends GuiContainer {
|
|||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int mouseX, int mouseY) {
|
||||
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(drawPlayerSlots()){
|
||||
builder.drawPlayerSlots(this, guiLeft + xSize / 2, guiTop + 93, true);
|
||||
}
|
||||
if(tryAddUpgrades() && tile instanceof IUpgradeable){
|
||||
IUpgradeable upgradeable = (IUpgradeable) tile;
|
||||
if(upgradeable.canBeUpgraded()){
|
||||
|
@ -105,6 +107,10 @@ public class GuiBase extends GuiContainer {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean drawPlayerSlots(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean tryAddUpgrades(){
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,17 +1,46 @@
|
|||
package techreborn.client.gui.upgrades;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import reborncore.common.network.NetworkManager;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
import techreborn.packets.PacketSyncSideConfig;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by Mark on 12/04/2017.
|
||||
*/
|
||||
public class GuiSideConfig extends GuiBase {
|
||||
|
||||
public GuiSideConfig(EntityPlayer player, TileEntity tile, BuiltContainer container) {
|
||||
TileEntity tileEntity;
|
||||
int slotID;
|
||||
|
||||
public GuiSideConfig(EntityPlayer player, TileEntity tile, BuiltContainer container, int slotID) {
|
||||
super(player, tile, container);
|
||||
this.tileEntity = tile;
|
||||
this.slotID = slotID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
this.buttonList.clear();
|
||||
int i = 0;
|
||||
for(EnumFacing facing : EnumFacing.VALUES){
|
||||
buttonList.add(new GuiButton(facing.getIndex(), guiLeft + 150, guiTop + i++ * 23 + 22, 20, 20, "✓"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,7 +55,26 @@ public class GuiSideConfig extends GuiBase {
|
|||
protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND;
|
||||
int offset = 10;
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
for(EnumFacing facing : EnumFacing.VALUES){
|
||||
BlockPos pos = tileEntity.getPos().offset(facing);
|
||||
IBlockState state = tileEntity.getWorld().getBlockState(pos);
|
||||
ItemStack stack = state.getBlock().getPickBlock(state, new RayTraceResult(new Vec3d(0, 0, 0), facing, pos), tileEntity.getWorld(), pos, Minecraft.getMinecraft().player);
|
||||
if(stack != null && !stack.isEmpty() && stack.getItem() != null){
|
||||
drawCentredString(stack.getDisplayName() + " - " + facing.getName(), offset += 22, 4210752, layer);
|
||||
itemRender.renderItemIntoGUI(stack, 10, offset - 2);
|
||||
} else {
|
||||
drawCentredString(state.getBlock().getLocalizedName() + " - " + facing.getName(), offset += 22, 4210752, layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
NetworkManager.sendToServer(new PacketSyncSideConfig(slotID, button.id, tileEntity.getPos()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,4 +86,9 @@ public class GuiSideConfig extends GuiBase {
|
|||
public boolean tryAddUpgrades() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean drawPlayerSlots() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue