Fix up inventory insert calculation

This commit is contained in:
Aidan Brady 2013-11-03 00:14:54 -04:00
parent dcea9fa8f5
commit 65012d8427
5 changed files with 44 additions and 32 deletions

View file

@ -200,6 +200,21 @@ public class MekanismRenderer
GL11.glPopAttrib(); GL11.glPopAttrib();
} }
public static void blendOn()
{
GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
public static void blendOff()
{
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glDisable(GL11.GL_LINE_SMOOTH);
GL11.glDisable(GL11.GL_POLYGON_SMOOTH);
GL11.glDisable(GL11.GL_BLEND);
}
/** /**
* Cleaned-up snip of ItemRenderer.renderItem() -- meant to render 2D items as equipped. * Cleaned-up snip of ItemRenderer.renderItem() -- meant to render 2D items as equipped.
* @param item - ItemStack to render * @param item - ItemStack to render

View file

@ -26,7 +26,7 @@ public class RenderEnergyCube extends TileEntitySpecialRenderer
@Override @Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
{ {
renderAModelAt((TileEntityEnergyCube)tileEntity, x, y, z, 1F); renderAModelAt((TileEntityEnergyCube)tileEntity, x, y, z, partialTick);
} }
private void renderAModelAt(TileEntityEnergyCube tileEntity, double x, double y, double z, float partialTick) private void renderAModelAt(TileEntityEnergyCube tileEntity, double x, double y, double z, float partialTick)
@ -40,15 +40,11 @@ public class RenderEnergyCube extends TileEntitySpecialRenderer
model.render(0.0625F); model.render(0.0625F);
GL11.glPopMatrix(); GL11.glPopMatrix();
//Energy Core Render
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "EnergyCore.png")); bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "EnergyCore.png"));
GL11.glShadeModel(GL11.GL_SMOOTH); MekanismRenderer.blendOn();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
MekanismRenderer.glowOn(); MekanismRenderer.glowOn();
EnumColor c = tileEntity.tier.color; EnumColor c = tileEntity.tier.color;
@ -63,11 +59,7 @@ public class RenderEnergyCube extends TileEntitySpecialRenderer
GL11.glPopMatrix(); GL11.glPopMatrix();
MekanismRenderer.glowOff(); MekanismRenderer.glowOff();
MekanismRenderer.blendOff();
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glDisable(GL11.GL_LINE_SMOOTH);
GL11.glDisable(GL11.GL_POLYGON_SMOOTH);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }

View file

@ -345,6 +345,6 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
@Override @Override
public String getFlow() public String getFlow()
{ {
return ElectricityDisplay.getDisplay((float)(getPower()*Mekanism.TO_UE), ElectricityDisplay.ElectricUnit.WATT); return ElectricityDisplay.getDisplay((float)(getPower()*Mekanism.TO_UE), ElectricityDisplay.ElectricUnit.JOULES);
} }
} }

View file

@ -271,7 +271,8 @@ public final class CableUtils
{ {
if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.ENERGY)) if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.ENERGY))
{ {
emitter.setEnergy(emitter.getEnergy() - (Math.min(emitter.getEnergy(), emitter.getMaxOutput()) - CableUtils.emitEnergyToNetwork(Math.min(emitter.getEnergy(), emitter.getMaxOutput()), emitter, emitter.getOutputtingSide()))); double energyToSend = Math.min(emitter.getEnergy(), emitter.getMaxOutput());
emitter.setEnergy(emitter.getEnergy() - (energyToSend - emitEnergyToNetwork(energyToSend, emitter, emitter.getOutputtingSide())));
return; return;
} }
else if(tileEntity instanceof IStrictEnergyAcceptor) else if(tileEntity instanceof IStrictEnergyAcceptor)

View file

@ -229,40 +229,43 @@ public final class TransporterUtils
public static ItemStack putStackInInventory(IInventory inventory, ItemStack itemStack, int side) public static ItemStack putStackInInventory(IInventory inventory, ItemStack itemStack, int side)
{ {
ItemStack toInsert = itemStack.copy();
if(!(inventory instanceof ISidedInventory)) if(!(inventory instanceof ISidedInventory))
{ {
for(int i = 0; i <= inventory.getSizeInventory() - 1; i++) for(int i = 0; i <= inventory.getSizeInventory() - 1; i++)
{ {
if(inventory.isItemValidForSlot(i, itemStack)) if(inventory.isItemValidForSlot(i, toInsert))
{ {
ItemStack inSlot = inventory.getStackInSlot(i); ItemStack inSlot = inventory.getStackInSlot(i);
if(inSlot == null) if(inSlot == null)
{ {
inventory.setInventorySlotContents(i, itemStack); inventory.setInventorySlotContents(i, toInsert);
return null; return null;
} }
else if(inSlot.isItemEqual(itemStack) && inSlot.stackSize < inSlot.getMaxStackSize()) else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize())
{ {
if(inSlot.stackSize + itemStack.stackSize <= inSlot.getMaxStackSize()) if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize())
{ {
ItemStack toSet = itemStack.copy(); ItemStack toSet = toInsert.copy();
toSet.stackSize += inSlot.stackSize; toSet.stackSize += inSlot.stackSize;
inventory.setInventorySlotContents(i, toSet); inventory.setInventorySlotContents(i, toSet);
return null; return null;
} }
else { else {
int rejects = (inSlot.stackSize + itemStack.stackSize) - inSlot.getMaxStackSize(); int rejects = (inSlot.stackSize + toInsert.stackSize) - inSlot.getMaxStackSize();
ItemStack toSet = itemStack.copy(); ItemStack toSet = toInsert.copy();
toSet.stackSize = inSlot.getMaxStackSize(); toSet.stackSize = inSlot.getMaxStackSize();
ItemStack remains = itemStack.copy(); ItemStack remains = toInsert.copy();
remains.stackSize = rejects; remains.stackSize = rejects;
inventory.setInventorySlotContents(i, toSet); inventory.setInventorySlotContents(i, toSet);
return remains;
toInsert = remains;
} }
} }
} }
@ -278,36 +281,37 @@ public final class TransporterUtils
{ {
int slotID = slots[get]; int slotID = slots[get];
if(sidedInventory.isItemValidForSlot(slotID, itemStack) && sidedInventory.canInsertItem(slotID, itemStack, ForgeDirection.getOrientation(side).getOpposite().ordinal())) if(sidedInventory.isItemValidForSlot(slotID, toInsert) && sidedInventory.canInsertItem(slotID, toInsert, ForgeDirection.getOrientation(side).getOpposite().ordinal()))
{ {
ItemStack inSlot = inventory.getStackInSlot(slotID); ItemStack inSlot = inventory.getStackInSlot(slotID);
if(inSlot == null) if(inSlot == null)
{ {
inventory.setInventorySlotContents(slotID, itemStack); inventory.setInventorySlotContents(slotID, toInsert);
return null; return null;
} }
else if(inSlot.isItemEqual(itemStack) && inSlot.stackSize < inSlot.getMaxStackSize()) else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize())
{ {
if(inSlot.stackSize + itemStack.stackSize <= inSlot.getMaxStackSize()) if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize())
{ {
ItemStack toSet = itemStack.copy(); ItemStack toSet = toInsert.copy();
toSet.stackSize += inSlot.stackSize; toSet.stackSize += inSlot.stackSize;
inventory.setInventorySlotContents(slotID, toSet); inventory.setInventorySlotContents(slotID, toSet);
return null; return null;
} }
else { else {
int rejects = (inSlot.stackSize + itemStack.stackSize) - inSlot.getMaxStackSize(); int rejects = (inSlot.stackSize + toInsert.stackSize) - inSlot.getMaxStackSize();
ItemStack toSet = itemStack.copy(); ItemStack toSet = toInsert.copy();
toSet.stackSize = inSlot.getMaxStackSize(); toSet.stackSize = inSlot.getMaxStackSize();
ItemStack remains = itemStack.copy(); ItemStack remains = toInsert.copy();
remains.stackSize = rejects; remains.stackSize = rejects;
inventory.setInventorySlotContents(slotID, toSet); inventory.setInventorySlotContents(slotID, toSet);
return remains;
toInsert = remains;
} }
} }
} }
@ -315,7 +319,7 @@ public final class TransporterUtils
} }
} }
return itemStack; return toInsert;
} }
public static SlotInfo takeItem(IInventory inventory, int side) public static SlotInfo takeItem(IInventory inventory, int side)