Skip to content

Commit

Permalink
Fix some bugs with the way Gui's work.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander committed Feb 17, 2014
1 parent e539d5b commit 5445364
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 92 deletions.
14 changes: 6 additions & 8 deletions src/main/java/tconstruct/blocks/logic/PartBuilderLogic.java
Expand Up @@ -38,18 +38,18 @@ public Container getGuiContainer (InventoryPlayer inventoryplayer, World world,
{
for (int zPos = z - 1; zPos <= z + 1; zPos++)
{
for (int yPos = y - 1; zPos <= y + 1; zPos++)
for (int yPos = y - 1; yPos <= y + 1; yPos++)
{
TileEntity tile = world.getTileEntity(xPos, yPos, zPos);
if (tile != null && tile instanceof PatternChestLogic)
if (tile != null && tile instanceof PatternChestLogic && (x == xPos || z == zPos))
return new PartCrafterChestContainer(inventoryplayer, this, (PatternChestLogic) tile);
}
}
}
return new PartCrafterContainer(inventoryplayer, this);
}

// Called when emptying a slot, not when another item is placed in it
//Called when emptying a slot, not when another item is placed in it
@Override
public ItemStack decrStackSize (int slotID, int quantity)
{
Expand All @@ -72,8 +72,7 @@ public void tryBuildPart (int slotID)
int decrease = cost / value;
if (cost % value != 0)
decrease++;
super.decrStackSize(2, decrease); // Call super to avoid
// crafting again
super.decrStackSize(2, decrease); //Call super to avoid crafting again
}
}

Expand All @@ -98,8 +97,7 @@ public void tryBuildPart (int slotID)
int decrease = cost / value;
if (cost % value != 0)
decrease++;
super.decrStackSize(3, decrease); // Call super to avoid
// crafting again
super.decrStackSize(3, decrease); //Call super to avoid crafting again
}
}

Expand All @@ -113,7 +111,7 @@ public void tryBuildPart (int slotID)
buildBottomPart();
}

// Called when a slot has something placed into it.
//Called when a slot has something placed into it.
@Override
public void setInventorySlotContents (int slot, ItemStack itemstack)
{
Expand Down
21 changes: 10 additions & 11 deletions src/main/java/tconstruct/blocks/logic/StencilTableLogic.java
Expand Up @@ -35,25 +35,24 @@ public Container getGuiContainer (InventoryPlayer inventoryplayer, World world,
return new PatternShaperContainer(inventoryplayer, this);
}

/*
* @Override public void markDirty() { if (inventory[0] == null)
* inventory[1] = null; super.markDirty(); }
*/
/*@Override
public void onInventoryChanged()
{
if (inventory[0] == null)
inventory[1] = null;
super.onInventoryChanged();
}*/

@Override
public void setInventorySlotContents (int slot, ItemStack itemstack)
{
super.setInventorySlotContents(slot, itemstack);
if (slot == 0 && itemstack != null && itemstack.getItem() == TRepo.blankPattern)// instanceof
// tconstruct.items.Pattern)
if (slot == 0 && itemstack != null && itemstack.getItem() == TRepo.blankPattern)//instanceof tconstruct.items.Pattern)
{
if (itemstack.getItemDamage() == 0)
setInventorySlotContents(1, new ItemStack(TRepo.woodPattern, 1, 1));
/*
* else if (itemstack.getItemDamage() == 1)
* setInventorySlotContents(1, new ItemStack(TContent.metalPattern,
* 1, 0));
*/
/*else if (itemstack.getItemDamage() == 1)
setInventorySlotContents(1, new ItemStack(TContent.metalPattern, 1, 0));*/
}
}

Expand Down
Expand Up @@ -8,13 +8,11 @@
import net.minecraft.init.Blocks;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import tconstruct.TConstruct;

public class BlockSkinRenderHelper
{
public static boolean renderMetadataBlock (Block block, int metadata, int x, int y, int z, RenderBlocks renderer, IBlockAccess world)
{
TConstruct.logger.error(block);
// TODO CHECK THESE!!!!
int var5 = block.colorMultiplier(world, x, y, z);
float var6 = (float) (var5 >> 16 & 255) / 255.0F;
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/tconstruct/client/gui/PartCrafterGui.java
Expand Up @@ -58,9 +58,9 @@ void drawDefaultInformation ()
void drawMaterialInformation ()
{
ItemStack top = logic.getStackInSlot(2);
// ItemStack topResult = logic.getStackInSlot(4);
//ItemStack topResult = logic.getStackInSlot(4);
ItemStack bottom = logic.getStackInSlot(3);
// ItemStack bottomResult = logic.getStackInSlot(6);
//ItemStack bottomResult = logic.getStackInSlot(6);
if (topMaterial != top)
{
topMaterial = top;
Expand Down Expand Up @@ -133,17 +133,17 @@ public static String getHarvestLevelName (int num)
switch (num)
{
case 0:
return StatCollector.translateToLocal("gui.partcrafter.mining1");
return (StatCollector.translateToLocal("gui.partcrafter.mining1"));
case 1:
return StatCollector.translateToLocal("gui.partcrafter.mining2");
return (StatCollector.translateToLocal("gui.partcrafter.mining2"));
case 2:
return StatCollector.translateToLocal("gui.partcrafter.mining3");
return (StatCollector.translateToLocal("gui.partcrafter.mining3"));
case 3:
return StatCollector.translateToLocal("gui.partcrafter.mining4");
return (StatCollector.translateToLocal("gui.partcrafter.mining4"));
case 4:
return StatCollector.translateToLocal("gui.partcrafter.mining5");
return (StatCollector.translateToLocal("gui.partcrafter.mining5"));
case 5:
return StatCollector.translateToLocal("gui.partcrafter.mining6");
return (StatCollector.translateToLocal("gui.partcrafter.mining6"));
default:
return String.valueOf(num);
}
Expand Down Expand Up @@ -298,4 +298,4 @@ else if (clickNum == 1)
this.field_94070_G = l;
this.field_94073_I = clickNum;
}
}
}
41 changes: 18 additions & 23 deletions src/main/java/tconstruct/client/gui/StencilTableGui.java
Expand Up @@ -65,27 +65,20 @@ public void initGui ()
int cornerY = (this.height - this.ySize) / 2;

this.buttonList.clear();
/*
* ToolGuiElement repair = TConstruct.toolButtons.get(0); GuiButtonTool
* repairButton = new GuiButtonTool(0, cornerX - 110, cornerY,
* repair.buttonIconX, repair.buttonIconY, repair.texture); // Repair
* repairButton.enabled = false; this.buttonList.add(repairButton);
*/
/*ToolGuiElement repair = TConstruct.toolButtons.get(0);
GuiButtonTool repairButton = new GuiButtonTool(0, cornerX - 110, cornerY, repair.buttonIconX, repair.buttonIconY, repair.texture); // Repair
repairButton.enabled = false;
this.buttonList.add(repairButton);*/
this.buttonList.add(new GuiButton(0, cornerX - 120, cornerY, 120, 20, (StatCollector.translateToLocal("gui.stenciltable1"))));
this.buttonList.add(new GuiButton(1, cornerX - 120, cornerY + 20, 120, 20, (StatCollector.translateToLocal("gui.stenciltable2"))));

// for (int iter = 0; iter < TConstructContent.patternOutputs.length;
// iter++)
// {

/*
* ToolGuiElement element = TConstruct.toolButtons.get(iter);
* GuiButtonTool button = new GuiButtonTool(iter, cornerX - 110 + 22 *
* (iter % 5), cornerY + 22 * (iter / 5), element.buttonIconX,
* element.buttonIconY, element.texture); // Repair
* this.buttonList.add(button);
*/
// }
//for (int iter = 0; iter < TConstructContent.patternOutputs.length; iter++)
//{

/*ToolGuiElement element = TConstruct.toolButtons.get(iter);
GuiButtonTool button = new GuiButtonTool(iter, cornerX - 110 + 22 * (iter % 5), cornerY + 22 * (iter / 5), element.buttonIconX, element.buttonIconY, element.texture); // Repair
this.buttonList.add(button);*/
//}
}

@Override
Expand Down Expand Up @@ -117,16 +110,18 @@ else if (button.id == 1)
logic.setInventorySlotContents(1, stack);
updateServer(stack);
}
/*
* else if (meta == 1 || meta == 2) { ItemStack stack = new
* ItemStack(TContent.metalPattern, 1, 0);
* logic.setInventorySlotContents(1, stack); updateServer(stack); }
*/
/*else if (meta == 1 || meta == 2)
{
ItemStack stack = new ItemStack(TContent.metalPattern, 1, 0);
logic.setInventorySlotContents(1, stack);
updateServer(stack);
}*/
}
}

void updateServer (ItemStack stack)
{

TConstruct.packetPipeline.sendToServer(new PacketStencilTable(logic.xCoord, logic.yCoord, logic.zCoord, stack));
}
}
Expand Up @@ -91,4 +91,4 @@ protected boolean mergeItemStack (ItemStack stack, int inventorySize, int slotSi

return super.mergeItemStack(stack, inventorySize, slotSize, par4);
}
}
}
91 changes: 56 additions & 35 deletions src/main/java/tconstruct/inventory/PatternShaperContainer.java
Expand Up @@ -16,11 +16,13 @@ public PatternShaperContainer(InventoryPlayer inventoryplayer, StencilTableLogic
logic = shaper;
this.addSlotToContainer(new Slot(shaper, 0, 48, 35));
this.addSlotToContainer(new SlotOnlyTake(shaper, 1, 106, 35));
/*
* for (int i = 0; i < 3; i++) { for (int l = 0; l < 3; l++) {
* this.addSlotToContainer(new Slot(craftMatrix, l + i * 3, 30 + l * 18,
* 17 + i * 18)); } }
*/
/*for (int i = 0; i < 3; i++)
{
for (int l = 0; l < 3; l++)
{
this.addSlotToContainer(new Slot(craftMatrix, l + i * 3, 30 + l * 18, 17 + i * 18));
}
}*/

/* Player inventory */
for (int column = 0; column < 3; column++)
Expand All @@ -37,19 +39,25 @@ public PatternShaperContainer(InventoryPlayer inventoryplayer, StencilTableLogic
}
}

/*
* public void onCraftMatrixChanged(IInventory iinventory) {
* craftResult.setInventorySlotContents(0,
* CraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj));
* }
*/
/*public void onCraftMatrixChanged(IInventory iinventory)
{
craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj));
}*/

/*
* @Override public void onContainerClosed(EntityPlayer entityplayer) {
* super.onContainerClosed(entityplayer); if (logic.worldObj.isRemote) {
* return; } ItemStack itemstack = logic.getStackInSlot(0); if (itemstack !=
* null) { entityplayer.dropPlayerItem(itemstack); } }
*/
/*@Override
public void onContainerClosed(EntityPlayer entityplayer)
{
super.onContainerClosed(entityplayer);
if (logic.worldObj.isRemote)
{
return;
}
ItemStack itemstack = logic.getStackInSlot(0);
if (itemstack != null)
{
entityplayer.dropPlayerItem(itemstack);
}
}*/

@Override
public boolean canInteractWith (EntityPlayer entityplayer)
Expand All @@ -61,24 +69,37 @@ public boolean canInteractWith (EntityPlayer entityplayer)
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
{
return null;
/*
* ItemStack stack = null; Slot slot =
* (Slot)this.inventorySlots.get(slotID);
*
* if (slot != null && slot.getHasStack()) { ItemStack slotStack =
* slot.getStack(); stack = slotStack.copy();
*
* if (slotID < logic.getSizeInventory()) { if
* (!this.mergeItemStack(slotStack, logic.getSizeInventory(),
* this.inventorySlots.size(), true)) { return null; } } else if
* (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory()-1,
* false)) { return null; }
*
* if (slotStack.stackSize == 0) { slot.putStack((ItemStack)null); }
* else { slot.onSlotChanged(); } }
*
* return stack;
*/
/*ItemStack stack = null;
Slot slot = (Slot)this.inventorySlots.get(slotID);
if (slot != null && slot.getHasStack())
{
ItemStack slotStack = slot.getStack();
stack = slotStack.copy();
if (slotID < logic.getSizeInventory())
{
if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true))
{
return null;
}
}
else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory()-1, false))
{
return null;
}
if (slotStack.stackSize == 0)
{
slot.putStack((ItemStack)null);
}
else
{
slot.onSlotChanged();
}
}
return stack;*/
}

}
5 changes: 2 additions & 3 deletions src/main/java/tconstruct/inventory/SlotPattern.java
Expand Up @@ -13,12 +13,11 @@ public SlotPattern(IInventory builder, int par3, int par4, int par5)
}

/**
* Check if the stack is a valid item for this slot. Always true beside for
* the armor slots.
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
*/
@Override
public boolean isItemValid (ItemStack stack)
{
return stack.getItem() instanceof IPattern;
}
}
}

0 comments on commit 5445364

Please sign in to comment.