Some work on getting the Calcinators GUI to be more informative. Some small corner cases remain. That, and rendering it when its active.

This commit is contained in:
pahimar 2013-12-29 22:04:57 -05:00
parent 4066e6f6b0
commit 32615463ac
4 changed files with 121 additions and 45 deletions

View file

@ -100,6 +100,12 @@ public class BlockCalcinator extends BlockContainerEE
}
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random random)
{
// TODO Spawn particles
}
private void dropInventory(World world, int x, int y, int z)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);

View file

@ -21,12 +21,10 @@ import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class GuiCalcinator extends GuiContainer
{
private TileCalcinator tileCalcinator;
public GuiCalcinator(InventoryPlayer player, TileCalcinator tileCalcinator)
{
super(new ContainerCalcinator(player, tileCalcinator));
ySize = 176;
this.tileCalcinator = tileCalcinator;
@ -35,7 +33,6 @@ public class GuiCalcinator extends GuiContainer
@Override
protected void drawGuiContainerForegroundLayer(int x, int y)
{
String containerName = tileCalcinator.isInvNameLocalized() ? tileCalcinator.getInvName() : StatCollector.translateToLocal(tileCalcinator.getInvName());
fontRenderer.drawString(containerName, xSize / 2 - fontRenderer.getStringWidth(containerName) / 2, 6, 4210752);
fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_INVENTORY), 8, ySize - 96 + 2, 4210752);
@ -44,7 +41,6 @@ public class GuiCalcinator extends GuiContainer
@Override
protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(Textures.GUI_CALCINATOR);
@ -52,5 +48,15 @@ public class GuiCalcinator extends GuiContainer
int xStart = (width - xSize) / 2;
int yStart = (height - ySize) / 2;
this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
int scaleAdjustment;
if (this.tileCalcinator.isBurning())
{
scaleAdjustment = this.tileCalcinator.getBurnTimeRemainingScaled(12);
this.drawTexturedModalRect(xStart + 57, yStart + 36 + 23 - scaleAdjustment, 176, 12 - scaleAdjustment, 14, scaleAdjustment + 2);
}
scaleAdjustment = this.tileCalcinator.getCookProgressScaled(24);
this.drawTexturedModalRect(xStart + 83, yStart + 34, 176, 14, scaleAdjustment + 1, 16);
}
}

View file

@ -1,9 +1,12 @@
package com.pahimar.ee3.inventory;
import com.pahimar.ee3.tileentity.TileCalcinator;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityFurnace;
@ -17,8 +20,15 @@ import net.minecraft.tileentity.TileEntityFurnace;
*/
public class ContainerCalcinator extends Container
{
private TileCalcinator calcinator;
private int lastCookTime; // How much longer the Calcinator will burn
private int lastBurnTime; // The fuel value for the currently burning fuel
private int lastItemCookTime; // How long the current item has been "cooking"
public ContainerCalcinator(InventoryPlayer inventoryPlayer, TileCalcinator calcinator)
{
this.calcinator = calcinator;
// Add the fuel slot to the container
this.addSlotToContainer(new Slot(calcinator, TileCalcinator.FUEL_INVENTORY_INDEX, 56, 62));
@ -112,4 +122,62 @@ public class ContainerCalcinator extends Container
return itemStack;
}
@Override
public void addCraftingToCrafters(ICrafting iCrafting)
{
super.addCraftingToCrafters(iCrafting);
iCrafting.sendProgressBarUpdate(this, 0, this.calcinator.calcinatorCookTime);
iCrafting.sendProgressBarUpdate(this, 1, this.calcinator.fuelBurnTime);
iCrafting.sendProgressBarUpdate(this, 2, this.calcinator.itemCookTime);
}
@Override
public void detectAndSendChanges()
{
super.detectAndSendChanges();
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting icrafting = (ICrafting) this.crafters.get(i);
if (this.lastCookTime != this.calcinator.calcinatorCookTime)
{
icrafting.sendProgressBarUpdate(this, 0, this.calcinator.calcinatorCookTime);
}
if (this.lastBurnTime != this.calcinator.fuelBurnTime)
{
icrafting.sendProgressBarUpdate(this, 1, this.calcinator.fuelBurnTime);
}
if (this.lastItemCookTime != this.calcinator.itemCookTime)
{
icrafting.sendProgressBarUpdate(this, 2, this.calcinator.itemCookTime);
}
}
this.lastCookTime = this.calcinator.calcinatorCookTime;
this.lastBurnTime = this.calcinator.fuelBurnTime;
this.lastItemCookTime = this.calcinator.itemCookTime;
}
@SideOnly(Side.CLIENT)
public void updateProgressBar(int valueType, int updatedValue)
{
if (valueType == 0)
{
this.calcinator.calcinatorCookTime = updatedValue;
}
if (valueType == 1)
{
this.calcinator.fuelBurnTime = updatedValue;
}
if (valueType == 2)
{
this.calcinator.itemCookTime = updatedValue;
}
}
}

View file

@ -2,15 +2,14 @@ package com.pahimar.ee3.tileentity;
import com.pahimar.ee3.lib.Strings;
import com.pahimar.ee3.recipe.CalcinationManager;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntityFurnace;
import java.util.ArrayList;
import java.util.List;
/**
* Equivalent-Exchange-3
* <p/>
@ -32,9 +31,9 @@ public class TileCalcinator extends TileEE implements IInventory
public static final int OUTPUT_LEFT_INVENTORY_INDEX = 2;
public static final int OUTPUT_RIGHT_INVENTORY_INDEX = 3;
public int remainingBurnTime; // How much longer the Calcinator will burn
public int currentFuelsFuelValue; // The fuel value for the currently burning fuel
public int currentItemCookTime; // How long the current item has been "cooking"
public int calcinatorCookTime; // How much longer the Calcinator will cook
public int fuelBurnTime; // The fuel value for the currently burning fuel
public int itemCookTime; // How long the current item has been "cooking"
public TileCalcinator()
{
@ -181,23 +180,23 @@ public class TileCalcinator extends TileEE implements IInventory
@Override
public void updateEntity()
{
boolean isBurning = this.remainingBurnTime > 0;
boolean isBurning = this.calcinatorCookTime > 0;
boolean inventoryChanged = false;
// If the Calcinator still has burn time, decrement it
if (this.remainingBurnTime > 0)
if (this.calcinatorCookTime > 0)
{
this.remainingBurnTime--;
this.calcinatorCookTime--;
}
if (!this.worldObj.isRemote)
{
if (this.remainingBurnTime == 0 && this.canCalcinate())
if (this.calcinatorCookTime == 0 && this.canCalcinate())
{
// TODO Effect burn speed by fuel quality
this.currentFuelsFuelValue = this.remainingBurnTime = TileEntityFurnace.getItemBurnTime(this.inventory[FUEL_INVENTORY_INDEX]);
this.fuelBurnTime = this.calcinatorCookTime = TileEntityFurnace.getItemBurnTime(this.inventory[FUEL_INVENTORY_INDEX]);
if (this.remainingBurnTime > 0)
if (this.calcinatorCookTime > 0)
{
inventoryChanged = true;
@ -215,21 +214,21 @@ public class TileCalcinator extends TileEE implements IInventory
if (this.isBurning() && this.canCalcinate())
{
this.currentItemCookTime++;
this.itemCookTime++;
if (this.currentItemCookTime == 200)
if (this.itemCookTime == 200)
{
this.currentItemCookTime = 0;
this.itemCookTime = 0;
this.calcinateItem();
inventoryChanged = true;
}
}
else
{
this.currentItemCookTime = 0;
this.itemCookTime = 0;
}
if (isBurning != this.remainingBurnTime > 0)
if (isBurning != this.calcinatorCookTime > 0)
{
inventoryChanged = true;
// TODO Add in world effects to show that we are making dust
@ -244,13 +243,28 @@ public class TileCalcinator extends TileEE implements IInventory
public boolean isBurning()
{
return this.remainingBurnTime > 0;
return this.calcinatorCookTime > 0;
}
@SideOnly(Side.CLIENT)
public int getCookProgressScaled(int scale)
{
return this.itemCookTime * scale / 200;
}
@SideOnly(Side.CLIENT)
public int getBurnTimeRemainingScaled(int scale)
{
if (this.itemCookTime == 0)
{
this.itemCookTime = 200;
}
return this.calcinatorCookTime * scale / this.fuelBurnTime;
}
/**
* Determines if with the current inventory we can calcinate an item into dusts
*
* @return
*/
private boolean canCalcinate()
{
@ -292,20 +306,13 @@ public class TileCalcinator extends TileEE implements IInventory
{
return leftResult <= getInventoryStackLimit() && leftResult <= alchemicalDustStack.getMaxStackSize();
}
else if (!leftEquals && rightEquals)
else if (!leftEquals)
{
return rightResult <= getInventoryStackLimit() && rightResult <= alchemicalDustStack.getMaxStackSize();
}
else
{
if (leftResult <= getInventoryStackLimit() && leftResult <= alchemicalDustStack.getMaxStackSize())
{
return true;
}
else
{
return rightResult <= getInventoryStackLimit() && rightResult <= alchemicalDustStack.getMaxStackSize();
}
return leftResult <= getInventoryStackLimit() && leftResult <= alchemicalDustStack.getMaxStackSize() || rightResult <= getInventoryStackLimit() && rightResult <= alchemicalDustStack.getMaxStackSize();
}
}
}
@ -342,22 +349,11 @@ public class TileCalcinator extends TileEE implements IInventory
}
}
private List<ItemStack> getDustForItemStack(ItemStack cookedItemStack)
{
List<ItemStack> dustList = new ArrayList<ItemStack>();
return null;
}
@Override
// TODO This is not an ideal toString
public String toString()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(super.toString());
return stringBuilder.toString();
return super.toString();
}
public int getCombinedOutputSize()