Work on Rotary Condensentrator, fixed an issue with factories

This commit is contained in:
Aidan Brady 2013-11-28 16:01:23 -05:00
parent ae580843aa
commit ccae995242
12 changed files with 233 additions and 56 deletions

View file

@ -29,6 +29,7 @@ import mekanism.client.gui.GuiRobitInventory;
import mekanism.client.gui.GuiRobitMain;
import mekanism.client.gui.GuiRobitRepair;
import mekanism.client.gui.GuiRobitSmelting;
import mekanism.client.gui.GuiRotaryCondensentrator;
import mekanism.client.gui.GuiTeleporter;
import mekanism.client.render.MekanismRenderer;
import mekanism.client.render.RenderTickHandler;
@ -303,8 +304,7 @@ public class ClientProxy extends CommonProxy
case 6:
return new GuiCrusher(player.inventory, (TileEntityElectricMachine)tileEntity);
case 7:
//return new GuiRotaryCondensentrator(player.inventory, (TileEntityRotaryCondensentrator)tileEntity); TODO
return null;
return new GuiRotaryCondensentrator(player.inventory, (TileEntityRotaryCondensentrator)tileEntity);
case 8:
return new GuiEnergyCube(player.inventory, (TileEntityEnergyCube)tileEntity);
case 9:

View file

@ -1,12 +1,12 @@
package mekanism.client.gui;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.Mekanism;
import mekanism.common.inventory.container.ContainerElectricPump;
import mekanism.common.tileentity.TileEntityElectricPump;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
@ -38,7 +38,7 @@ public class GuiElectricPump extends GuiMekanism
fontRenderer.drawString("Inventory", 8, (ySize - 94) + 2, 0x404040);
fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00);
fontRenderer.drawString(tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid().getName() + ": " + tileEntity.fluidTank.getFluid().amount : "No fluid.", 51, 35, 0x00CD00);
fontRenderer.drawString(tileEntity.getVoltage() + "v", 51, 44, 0x00CD00);
fontRenderer.drawString(tileEntity.getVoltage()*Mekanism.FROM_UE + "v", 51, 44, 0x00CD00);
if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14 && yAxis <= 72)
{

View file

@ -1,9 +1,16 @@
package mekanism.client.gui;
import java.util.ArrayList;
import mekanism.api.Object3D;
import mekanism.api.gas.GasStack;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.inventory.container.ContainerRotaryCondensentrator;
import mekanism.common.network.PacketTileEntity;
import mekanism.common.tileentity.TileEntityRotaryCondensentrator;
import mekanism.common.util.ListUtils;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.entity.player.InventoryPlayer;
@ -34,13 +41,15 @@ public class GuiRotaryCondensentrator extends GuiMekanism
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040);
fontRenderer.drawString("Inventory", 8, (ySize - 94) + 2, 0x404040);
fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00);
fontRenderer.drawString(tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid().getName() + ": " + tileEntity.fluidTank.getFluid().amount : "No fluid.", 51, 35, 0x00CD00);
fontRenderer.drawString(tileEntity.getVoltage() + "v", 51, 44, 0x00CD00);
fontRenderer.drawString("Rotary Condensentrator", 26, 4, 0x404040);
fontRenderer.drawString(tileEntity.mode == 0 ? "Condensentrating" : "Decondensentrating", 6, (ySize - 94) + 2, 0x404040);
if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14 && yAxis <= 72)
if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14 && yAxis <= 72)
{
drawCreativeTabHoveringText(tileEntity.gasTank != null ? tileEntity.gasTank.getGas().getLocalizedName() + ": " + tileEntity.gasTank.amount : "Empty", xAxis, yAxis);
}
if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14 && yAxis <= 72)
{
drawCreativeTabHoveringText(tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid().getLocalizedName() + ": " + tileEntity.fluidTank.getFluid().amount + "mB" : "Empty", xAxis, yAxis);
}
@ -50,6 +59,11 @@ public class GuiRotaryCondensentrator extends GuiMekanism
drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis);
}
if(xAxis >= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22)
{
drawCreativeTabHoveringText("Toggle operation", xAxis, yAxis);
}
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@ -65,20 +79,52 @@ public class GuiRotaryCondensentrator extends GuiMekanism
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
int displayInt;
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
displayInt = tileEntity.getScaledEnergyLevel(52);
drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 36, displayInt, 4);
if(tileEntity.getScaledFluidLevel(58) > 0)
{
displayGauge(26, 14, tileEntity.getScaledFluidLevel(58), tileEntity.fluidTank.getFluid(), null);
}
if(tileEntity.getScaledGasLevel(58) > 0)
{
displayGauge(134, 14, tileEntity.getScaledGasLevel(58), null, tileEntity.gasTank);
displayGauge(26, 14, tileEntity.getScaledGasLevel(58), null, tileEntity.gasTank);
}
if(tileEntity.getScaledFluidLevel(58) > 0)
{
displayGauge(134, 14, tileEntity.getScaledFluidLevel(58), tileEntity.fluidTank.getFluid(), null);
}
if(xAxis >= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22)
{
drawTexturedModalRect(guiWidth + 4, guiHeight + 4, 176, 0, 18, 18);
}
else {
drawTexturedModalRect(guiWidth + 4, guiHeight + 4, 176, 18, 18, 18);
}
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int button)
{
super.mouseClicked(mouseX, mouseY, button);
if(button == 0)
{
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
if(xAxis >= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22)
{
ArrayList data = new ArrayList();
data.add(0);
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
}
}
}
public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, GasStack gas)
{
if(fluid == null)

View file

@ -86,7 +86,7 @@ public class MachineRenderingHandler implements ISimpleBlockRenderingHandler
{
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F);
GL11.glTranslatef(0.0F, -1F, -0.05F);
GL11.glTranslatef(0.0F, -1F, -0.15F);
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "RotaryCondensentrator.png"));
rotaryCondensentrator.render(0.0625F);
}

View file

@ -13,7 +13,6 @@ public final class ItemAttacher
static {
attachable.add(new ItemStack(Block.lever));
attachable.add(new ItemStack(Item.redstone));
attachable.add(new ItemStack(Block.torchRedstoneIdle));
attachable.add(new ItemStack(Block.torchWood));

View file

@ -535,7 +535,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
for(RecipeType recipe : RecipeType.values())
{
ItemStack stack = new ItemStack(i, 1, type.meta);
((IFactory)stack.getItem()).setRecipeType(type.ordinal(), stack);
((IFactory)stack.getItem()).setRecipeType(recipe.ordinal(), stack);
list.add(stack);
}
}

View file

@ -247,19 +247,19 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock
return;
}
ItemStack bucket = FluidContainerRegistry.isBucket(structure.inventory[0]) ? new ItemStack(Item.bucketEmpty) : null;
ItemStack containerItem = structure.inventory[0].getItem().getContainerItemStack(structure.inventory[0]);
boolean filled = false;
if(bucket != null)
if(containerItem != null)
{
if(structure.inventory[1] == null || (structure.inventory[1].isItemEqual(bucket) && structure.inventory[1].stackSize+1 <= bucket.getMaxStackSize()))
if(structure.inventory[1] == null || (structure.inventory[1].isItemEqual(containerItem) && structure.inventory[1].stackSize+1 <= containerItem.getMaxStackSize()))
{
structure.inventory[0] = null;
if(structure.inventory[1] == null)
{
structure.inventory[1] = bucket;
structure.inventory[1] = containerItem;
}
else {
structure.inventory[1].stackSize++;

View file

@ -44,14 +44,14 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasS
@Override
public void onUpdate()
{
if(inventory[0] != null && gasStored != null)
if(inventory[0] != null && getGas() != null)
{
setGas(new GasStack(getGas().getGas(), gasStored.amount - GasUtils.addGas(inventory[0], getGas())));
setGas(new GasStack(getGas().getGas(), getGas().amount - GasUtils.addGas(inventory[0], getGas())));
}
if(inventory[1] != null && (gasStored == null || gasStored.amount < getMaxGas()))
if(inventory[1] != null && (getGas() == null || getGas().amount < getMaxGas()))
{
if(gasStored == null)
if(getGas() == null)
{
setGas(GasUtils.removeGas(inventory[1], null, getMaxGas()));
}

View file

@ -7,6 +7,7 @@ import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTransmission;
import mekanism.api.gas.GasUtils;
import mekanism.api.gas.IGasAcceptor;
import mekanism.api.gas.IGasStorage;
import mekanism.api.gas.ITubeConnection;
@ -18,11 +19,13 @@ import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.network.PacketTileEntity;
import mekanism.common.util.ChargeUtils;
import mekanism.common.util.MekanismUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
@ -87,20 +90,129 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp
ChargeUtils.discharge(4, this);
if(mode == 1 && getGas() != null)
if(mode == 0)
{
GasStack toSend = new GasStack(getGas().getGas(), Math.min(getGas().amount, gasOutput));
setGas(new GasStack(getGas().getGas(), getGas().amount - GasTransmission.emitGasToNetwork(toSend, this, MekanismUtils.getLeft(facing))));
TileEntity tileEntity = Object3D.get(this).getFromSide(MekanismUtils.getLeft(facing)).getTileEntity(worldObj);
if(tileEntity instanceof IGasAcceptor)
if(inventory[1] != null && (getGas() == null || getGas().amount < getMaxGas()))
{
if(((IGasAcceptor)tileEntity).canReceiveGas(MekanismUtils.getLeft(facing).getOpposite(), getGas().getGas()))
if(getGas() == null)
{
int added = ((IGasAcceptor)tileEntity).receiveGas(new GasStack(getGas().getGas(), Math.min(getGas().amount, gasOutput)));
setGas(GasUtils.removeGas(inventory[1], null, getMaxGas()));
}
else {
GasStack removed = GasUtils.removeGas(inventory[1], getGas().getGas(), getMaxGas()-getGas().amount);
setGas(new GasStack(getGas().getGas(), getGas().amount + (removed != null ? removed.amount : 0)));
}
}
setGas(new GasStack(getGas().getGas(), getGas().amount - added));
if(inventory[2] != null)
{
if(FluidContainerRegistry.isEmptyContainer(inventory[2]))
{
if(fluidTank.getFluid() != null && fluidTank.getFluid().amount >= FluidContainerRegistry.BUCKET_VOLUME)
{
ItemStack filled = FluidContainerRegistry.fillFluidContainer(fluidTank.getFluid(), inventory[2]);
if(filled != null)
{
if(inventory[3] == null || (inventory[3].isItemEqual(filled) && inventory[3].stackSize+1 <= filled.getMaxStackSize()))
{
inventory[2].stackSize--;
if(inventory[2].stackSize <= 0)
{
inventory[2] = null;
}
if(inventory[3] == null)
{
inventory[3] = filled;
}
else {
inventory[3].stackSize++;
}
fluidTank.drain(FluidContainerRegistry.getFluidForFilledItem(filled).amount, true);
}
}
}
}
}
}
else if(mode == 1)
{
if(getGas() != null)
{
if(inventory[0] != null)
{
setGas(new GasStack(getGas().getGas(), getGas().amount - GasUtils.addGas(inventory[0], getGas())));
}
}
if(getGas() != null)
{
GasStack toSend = new GasStack(getGas().getGas(), Math.min(getGas().amount, gasOutput));
setGas(new GasStack(getGas().getGas(), getGas().amount - GasTransmission.emitGasToNetwork(toSend, this, MekanismUtils.getLeft(facing))));
TileEntity tileEntity = Object3D.get(this).getFromSide(MekanismUtils.getLeft(facing)).getTileEntity(worldObj);
if(tileEntity instanceof IGasAcceptor)
{
if(((IGasAcceptor)tileEntity).canReceiveGas(MekanismUtils.getLeft(facing).getOpposite(), getGas().getGas()))
{
int added = ((IGasAcceptor)tileEntity).receiveGas(new GasStack(getGas().getGas(), Math.min(getGas().amount, gasOutput)));
setGas(new GasStack(getGas().getGas(), getGas().amount - added));
}
}
}
if(FluidContainerRegistry.isFilledContainer(inventory[2]))
{
FluidStack itemFluid = FluidContainerRegistry.getFluidForFilledItem(inventory[2]);
if((fluidTank.getFluid() == null && itemFluid.amount <= 10000) || fluidTank.getFluid().amount+itemFluid.amount <= 10000)
{
if(fluidTank.getFluid() != null && !fluidTank.getFluid().isFluidEqual(itemFluid))
{
return;
}
ItemStack containerItem = inventory[2].getItem().getContainerItemStack(inventory[2]);
boolean filled = false;
if(containerItem != null)
{
if(inventory[3] == null || (inventory[3].isItemEqual(containerItem) && inventory[3].stackSize+1 <= containerItem.getMaxStackSize()))
{
inventory[2] = null;
if(inventory[3] == null)
{
inventory[3] = containerItem;
}
else {
inventory[3].stackSize++;
}
filled = true;
}
}
else {
inventory[2].stackSize--;
if(inventory[2].stackSize == 0)
{
inventory[2] = null;
}
filled = true;
}
if(filled)
{
fluidTank.fill(itemFluid, true);
}
}
}
}
@ -110,11 +222,28 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp
@Override
public void handlePacketData(ByteArrayDataInput dataStream)
{
if(!worldObj.isRemote)
{
int type = dataStream.readInt();
if(type == 0)
{
mode = mode == 0 ? 1 : 0;
}
for(EntityPlayer player : playersUsing)
{
PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())), player);
}
return;
}
super.handlePacketData(dataStream);
mode = dataStream.readInt();
if(dataStream.readInt() == 1)
if(dataStream.readBoolean())
{
fluidTank.setFluid(new FluidStack(dataStream.readInt(), dataStream.readInt()));
}
@ -143,12 +272,12 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp
if(fluidTank.getFluid() != null)
{
data.add(1);
data.add(true);
data.add(fluidTank.getFluid().fluidID);
data.add(fluidTank.getFluid().amount);
}
else {
data.add(0);
data.add(false);
}
if(gasTank != null)

View file

@ -61,17 +61,17 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
{
bioFuelSlot.setFluid(bioFuelSlot.fluidStored+fluidToAdd);
if(FluidContainerRegistry.isBucket(inventory[0]))
if(inventory[0].getItem().getContainerItemStack(inventory[0]) != null)
{
inventory[0] = new ItemStack(Item.bucketEmpty);
inventory[0] = inventory[0].getItem().getContainerItemStack(inventory[0]);
}
else {
inventory[0].stackSize--;
}
if(inventory[0].stackSize == 0)
{
inventory[0] = null;
}
if(inventory[0].stackSize == 0)
{
inventory[0] = null;
}
}
}
@ -83,20 +83,23 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
if(fuel > 0)
{
int fuelNeeded = bioFuelSlot.MAX_FLUID - bioFuelSlot.fluidStored;
if(fuel <= fuelNeeded)
{
bioFuelSlot.fluidStored += fuel;
inventory[0].stackSize--;
if(prevStack.isItemEqual(new ItemStack(Item.bucketLava)))
if(inventory[0].getItem().getContainerItemStack(inventory[0]) != null)
{
inventory[0] = new ItemStack(Item.bucketEmpty);
inventory[0] = inventory[0].getItem().getContainerItemStack(inventory[0]);
}
else {
inventory[0].stackSize--;
}
}
if(inventory[0].stackSize == 0)
{
inventory[0] = null;
if(inventory[0].stackSize == 0)
{
inventory[0] = null;
}
}
}
}

View file

@ -53,7 +53,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu
{
lavaTank.fill(fluid, true);
if(inventory[0].getItem().hasContainerItem())
if(inventory[0].getItem().getContainerItemStack(inventory[0]) != null)
{
inventory[0] = inventory[0].getItem().getContainerItemStack(inventory[0]);
}
@ -78,7 +78,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu
{
lavaTank.fill(new FluidStack(FluidRegistry.LAVA, fuel), true);
if(inventory[0].getItem().hasContainerItem())
if(inventory[0].getItem().getContainerItemStack(inventory[0]) != null)
{
inventory[0] = inventory[0].getItem().getContainerItemStack(inventory[0]);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB