Gas API completely overhauled. Sorry @micdoodle8 :(

General cleanup, pressurized tubes are 40 times more efficient, a few enhancements, Miners balanced.
This commit is contained in:
Aidan Brady 2013-11-26 20:11:26 -05:00
parent c2c4c4f93f
commit dacc68e6c6
58 changed files with 897 additions and 910 deletions

View file

@ -1,43 +0,0 @@
package mekanism.api.gas;
import net.minecraft.util.Icon;
/**
* The gasses currently available in Mekanism.
* @author AidanBrady
*
*/
public enum EnumGas
{
NONE("None", null),
OXYGEN("Oxygen", null),
HYDROGEN("Hydrogen", null);
public String name;
public Icon gasIcon;
public static EnumGas getFromName(String gasName)
{
for(EnumGas gas : values())
{
if(gasName.contains(gas.name))
{
return gas;
}
}
System.out.println("[Mekanism] Invalid gas identifier when retrieving with name.");
return NONE;
}
public boolean hasTexture()
{
return gasIcon != null;
}
private EnumGas(String s, Icon icon)
{
name = s;
gasIcon = icon;
}
}

View file

@ -0,0 +1,98 @@
package mekanism.api.gas;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Icon;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
public class Gas
{
private String name;
private String localizedName;
private Fluid fluid;
private Icon icon;
public Gas(String s)
{
name = s;
}
public String getName()
{
return name;
}
public String getLocalizedName()
{
return localizedName;
}
public Gas setLocalizedName(String s)
{
localizedName = s;
return this;
}
public Icon getIcon()
{
return icon;
}
public Gas setIcon(Icon i)
{
icon = i;
if(hasFluid())
{
fluid.setIcons(getIcon());
}
return this;
}
public int getID()
{
return GasRegistry.getGasID(this);
}
public NBTTagCompound write(NBTTagCompound nbtTags)
{
nbtTags.setInteger("id", getID());
return nbtTags;
}
public static Gas readFromNBT(NBTTagCompound nbtTags)
{
if(nbtTags == null || nbtTags.hasNoTags())
{
return null;
}
return GasRegistry.getGas(nbtTags.getInteger("id"));
}
public boolean hasFluid()
{
return fluid != null;
}
public void registerFluid()
{
if(fluid == null)
{
fluid = new Fluid(getName()).setGaseous(true);
FluidRegistry.registerFluid(fluid);
}
}
@Override
public String toString()
{
return name;
}
}

View file

@ -11,12 +11,10 @@ import java.util.Set;
import mekanism.api.transmitters.DynamicNetwork;
import mekanism.api.transmitters.ITransmitter;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.FluidNetwork.FluidTransferEvent;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.Event;
import net.minecraftforge.fluids.FluidStack;
import cpw.mods.fml.common.FMLCommonHandler;
public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
@ -26,7 +24,7 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
public float gasScale;
public float prevGasScale;
public EnumGas refGas = null;
public Gas refGas = null;
public GasNetwork(ITransmitter<GasNetwork>... varPipes)
{
@ -55,24 +53,25 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
register();
}
public synchronized int emit(int gasToSend, EnumGas transferType, TileEntity emitter)
public synchronized int emit(GasStack stack, TileEntity emitter)
{
if(refGas != null && refGas != transferType)
if(refGas != null && refGas != stack.getGas())
{
return gasToSend;
return 0;
}
List availableAcceptors = Arrays.asList(getAcceptors(transferType).toArray());
List availableAcceptors = Arrays.asList(getAcceptors(stack.getGas()).toArray());
Collections.shuffle(availableAcceptors);
int prevSending = gasToSend;
int toSend = stack.amount;
int prevSending = toSend;
if(!availableAcceptors.isEmpty())
{
int divider = availableAcceptors.size();
int remaining = gasToSend % divider;
int sending = (gasToSend-remaining)/divider;
int remaining = toSend % divider;
int sending = (toSend-remaining)/divider;
for(Object obj : availableAcceptors)
{
@ -88,29 +87,29 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
remaining--;
}
gasToSend -= (currentSending - acceptor.transferGasToAcceptor(currentSending, transferType));
toSend -= acceptor.receiveGas(new GasStack(stack.getGas(), currentSending));
}
}
}
int sent = prevSending-gasToSend;
int sent = prevSending-toSend;
if(sent > 0 && FMLCommonHandler.instance().getEffectiveSide().isServer())
{
if(transferType == refGas)
if(stack.getGas() == refGas)
{
gasScale = Math.min(1, gasScale+((float)sent/100));
}
else if(refGas == null)
{
refGas = transferType;
refGas = stack.getGas();
gasScale = Math.min(1, ((float)sent/100));
}
transferDelay = 2;
}
return gasToSend;
return sent;
}
@Override
@ -124,7 +123,7 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
{
if(gasScale > 0)
{
gasScale -= .02;
gasScale = Math.max(0, gasScale-.02F);
}
else {
refGas = null;
@ -136,7 +135,7 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
if(gasScale != prevGasScale)
{
MinecraftForge.EVENT_BUS.post(new GasTransferEvent(this, refGas, gasScale));
MinecraftForge.EVENT_BUS.post(new GasTransferEvent(this, refGas != null ? refGas.getID() : -1, gasScale));
}
prevGasScale = gasScale;
@ -146,14 +145,16 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
@Override
public synchronized Set<IGasAcceptor> getAcceptors(Object... data)
{
EnumGas transferType = (EnumGas)data[0];
Gas type = (Gas)data[0];
Set<IGasAcceptor> toReturn = new HashSet<IGasAcceptor>();
for(IGasAcceptor acceptor : possibleAcceptors)
{
if(acceptor.canReceiveGas(acceptorDirections.get(acceptor).getOpposite(), transferType))
if(acceptor.canReceiveGas(acceptorDirections.get(acceptor).getOpposite(), type))
{
if(!(acceptor instanceof IGasStorage) || (acceptor instanceof IGasStorage && (((IGasStorage)acceptor).getMaxGas(transferType) - ((IGasStorage)acceptor).getGas(transferType)) > 0))
int stored = ((IGasStorage)acceptor).getGas() != null ? ((IGasStorage)acceptor).getGas().amount : 0;
if(!(acceptor instanceof IGasStorage) || (acceptor instanceof IGasStorage && (((IGasStorage)acceptor).getMaxGas() - stored) > 0))
{
toReturn.add(acceptor);
}
@ -218,10 +219,10 @@ public class GasNetwork extends DynamicNetwork<IGasAcceptor, GasNetwork>
{
public final GasNetwork gasNetwork;
public final EnumGas transferType;
public final int transferType;
public final float gasScale;
public GasTransferEvent(GasNetwork network, EnumGas type, float scale)
public GasTransferEvent(GasNetwork network, int type, float scale)
{
gasNetwork = network;
transferType = type;

View file

@ -0,0 +1,73 @@
package mekanism.api.gas;
import java.util.ArrayList;
import java.util.List;
public class GasRegistry
{
private static ArrayList<Gas> registeredGasses = new ArrayList<Gas>();
public static void registerOxygen()
{
if(getGas("oxygen") == null)
{
register(new Gas("oxygen").setLocalizedName("Oxygen"));
}
}
public static void registerHydrogen()
{
if(getGas("hydrogen") == null)
{
register(new Gas("hydrogen").setLocalizedName("Hydrogen"));
}
}
public static void register(Gas gas)
{
registeredGasses.add(gas);
}
public static Gas getGas(int id)
{
if(id == -1)
{
return null;
}
return registeredGasses.get(id);
}
public static boolean containsGas(String name)
{
return getGas(name) != null;
}
public static List<Gas> getRegisteredGasses()
{
return (List<Gas>)registeredGasses.clone();
}
public static Gas getGas(String name)
{
for(Gas gas : registeredGasses)
{
if(gas.getName().equals(name.toLowerCase()))
{
return gas;
}
}
return null;
}
public static int getGasID(Gas gas)
{
if(gas == null || !containsGas(gas.getName()))
{
return -1;
}
return registeredGasses.indexOf(gas);
}
}

View file

@ -0,0 +1,66 @@
package mekanism.api.gas;
import net.minecraft.nbt.NBTTagCompound;
public class GasStack
{
private Gas type;
public int amount;
public GasStack(int id, int quantity)
{
type = GasRegistry.getGas(id);
amount = quantity;
}
public GasStack(Gas gas, int quantity)
{
type = gas;
amount = quantity;
}
private GasStack() {}
public Gas getGas()
{
return type;
}
public NBTTagCompound write(NBTTagCompound nbtTags)
{
type.write(nbtTags);
nbtTags.setInteger("amount", amount);
return nbtTags;
}
private void read(NBTTagCompound nbtTags)
{
type = Gas.readFromNBT(nbtTags);
amount = nbtTags.getInteger("amount");
}
public static GasStack readFromNBT(NBTTagCompound nbtTags)
{
if(nbtTags == null || nbtTags.hasNoTags())
{
return null;
}
GasStack stack = new GasStack();
stack.read(nbtTags);
return stack;
}
public GasStack copy()
{
return new GasStack(type, amount);
}
@Override
public String toString()
{
return "[" + type + ", " + amount + "]";
}
}

View file

@ -88,56 +88,17 @@ public final class GasTransmission
* @param amount - amount of gas to send
* @param sender - the sender of the gas
* @param facing - side the sender is outputting from
* @return rejected gas
* @return gas sent
*/
public static int emitGasToNetwork(EnumGas type, int amount, TileEntity sender, ForgeDirection facing)
public static int emitGasToNetwork(GasStack stack, TileEntity sender, ForgeDirection facing)
{
TileEntity pointer = Object3D.get(sender).getFromSide(facing).getTileEntity(sender.worldObj);
if(TransmissionType.checkTransmissionType(pointer, TransmissionType.GAS, sender))
{
return ((ITransmitter<GasNetwork>)pointer).getTransmitterNetwork().emit(amount, type, sender);
return ((ITransmitter<GasNetwork>)pointer).getTransmitterNetwork().emit(stack, sender);
}
return amount;
}
/**
* Emits gas from all sides of a TileEntity.
* @param type - gas type to send
* @param amount - amount of gas to send
* @param pointer - sending TileEntity
* @return rejected gas
*/
public static int emitGasFromAllSides(EnumGas type, int amount, TileEntity pointer)
{
if(pointer != null)
{
Set<GasNetwork> networks = new HashSet<GasNetwork>();
int totalRemaining = 0;
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity sideTile = Object3D.get(pointer).getFromSide(side).getTileEntity(pointer.worldObj);
if(TransmissionType.checkTransmissionType(sideTile, TransmissionType.GAS, pointer))
{
networks.add(((ITransmitter<GasNetwork>)sideTile).getTransmitterNetwork());
}
}
int remaining = amount%networks.size();
int splitGas = (amount-remaining)/networks.size();
for(GasNetwork network : networks)
{
totalRemaining += network.emit(splitGas+remaining, type, pointer);
remaining = 0;
}
return totalRemaining;
}
return amount;
return 0;
}
}

View file

@ -0,0 +1,33 @@
package mekanism.api.gas;
import net.minecraft.item.ItemStack;
public final class GasUtils
{
public static int addGas(ItemStack itemStack, GasStack stack)
{
if(itemStack != null && itemStack.getItem() instanceof IGasItem && ((IGasItem)itemStack.getItem()).canReceiveGas(itemStack, stack.getGas()))
{
return ((IGasItem)itemStack.getItem()).addGas(itemStack, stack.copy());
}
return 0;
}
public static GasStack removeGas(ItemStack itemStack, Gas type, int amount)
{
if(itemStack != null && itemStack.getItem() instanceof IGasItem)
{
IGasItem item = (IGasItem)itemStack.getItem();
if(type != null && item.getGas(itemStack) != null && item.getGas(itemStack).getGas() != type || !item.canProvideGas(itemStack, type))
{
return null;
}
return item.removeGas(itemStack, amount);
}
return null;
}
}

View file

@ -14,12 +14,12 @@ public interface IGasAcceptor
* @param amount - amount to transfer
* @return rejects
*/
public int transferGasToAcceptor(int amount, EnumGas type);
public int receiveGas(GasStack stack);
/**
* Whether or not this tile entity accepts gas from a certain side.
* @param side - side to check
* @return if tile entity accepts gas
*/
public boolean canReceiveGas(ForgeDirection side, EnumGas type);
public boolean canReceiveGas(ForgeDirection side, Gas type);
}

View file

@ -1,7 +1,5 @@
package mekanism.api;
package mekanism.api.gas;
import mekanism.api.gas.EnumGas;
import mekanism.api.gas.IGasStorage;
import net.minecraft.item.ItemStack;
/**
@ -9,7 +7,7 @@ import net.minecraft.item.ItemStack;
* @author AidanBrady
*
*/
public interface IStorageTank extends IGasStorage
public interface IGasItem extends IGasStorage
{
/**
* Gets the rate of transfer this item can handle.
@ -22,18 +20,18 @@ public interface IStorageTank extends IGasStorage
* @param itemstack - the itemstack of a Storage Tank to add gas to
* @param type - the type of gas to add
* @param amount - the amount of gas to add
* @return leftover gas
* @return used gas
*/
public int addGas(ItemStack itemstack, EnumGas type, int amount);
public int addGas(ItemStack itemstack, GasStack stack);
/**
* Removes the defined amount of a certain gas from the item.
* @param itemstack - the itemstack of a Storage Tank to remove gas from
* @param type - the type of gas to remove
* @param amount - the amount of gas to remove
* @return how much gas was used by this item
* @return removed gas
*/
public int removeGas(ItemStack itemstack, EnumGas type, int amount);
public GasStack removeGas(ItemStack itemstack, int amount);
/**
* Whether or not this storage tank be given a specific gas.
@ -41,7 +39,7 @@ public interface IStorageTank extends IGasStorage
* @param type - the type of gas the tank can possibly receive
* @return if the item be charged
*/
public boolean canReceiveGas(ItemStack itemstack, EnumGas type);
public boolean canReceiveGas(ItemStack itemstack, Gas type);
/**
* Whether or not this energized item can give a gas receiver a certain amount of gas.
@ -49,19 +47,5 @@ public interface IStorageTank extends IGasStorage
* @param type - the type of gas the tank can possibly provide
* @return if the item can provide gas
*/
public boolean canProvideGas(ItemStack itemstack, EnumGas type);
/**
* Gets this storage tank's current stored gas.
* @param itemstack - the itemstack of a Storage Tank to check.
* @return which gas the tank is holding
*/
public EnumGas getGasType(ItemStack itemstack);
/**
* Sets a storage tank's current stored gas.
* @param itemstack - the itemstack of a Storage Tank to set.
* @param type - the type of gas to change to
*/
public void setGasType(ItemStack itemstack, EnumGas type);
public boolean canProvideGas(ItemStack itemstack, Gas type);
}

View file

@ -14,7 +14,7 @@ public interface IGasStorage
* @param data - ItemStack parameter if necessary
* @return gas stored
*/
public int getGas(EnumGas type, Object... data);
public GasStack getGas(Object... data);
/**
* Set the gas of a declared type to a new amount;
@ -22,7 +22,7 @@ public interface IGasStorage
* @param data - ItemStack parameter if necessary
* @param amount - amount to store
*/
public void setGas(EnumGas type, int amount, Object... data);
public void setGas(GasStack stack, Object... data);
/**
* Gets the maximum amount of gas this tile entity can store.
@ -30,5 +30,5 @@ public interface IGasStorage
* @param data - ItemStack parameter if necessary
* @return maximum gas
*/
public int getMaxGas(EnumGas type, Object... data);
public int getMaxGas(Object... data);
}

View file

@ -11,6 +11,7 @@ import net.minecraft.world.chunk.IChunkProvider;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.world.ChunkEvent;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;
import cpw.mods.fml.common.registry.TickRegistry;
@ -109,7 +110,7 @@ public class TransmitterNetworkRegistry implements ITickHandler
@ForgeSubscribe
public void onChunkLoad(ChunkEvent.Load event)
{
if(event.getChunk() != null)
if(event.getChunk() != null && !event.world.isRemote)
{
int x = event.getChunk().xPosition;
int z = event.getChunk().zPosition;
@ -136,16 +137,19 @@ public class TransmitterNetworkRegistry implements ITickHandler
try {
if(c != null)
{
for(Iterator iter = c.chunkTileEntityMap.values().iterator(); iter.hasNext();)
{
Object obj = iter.next();
if(obj instanceof ITransmitter && !((TileEntity)obj).worldObj.isRemote)
{
((ITransmitter)obj).refreshTransmitterNetwork();
((ITransmitter)obj).chunkLoad();
}
}
synchronized(INSTANCE)
{
for(Iterator iter = c.chunkTileEntityMap.values().iterator(); iter.hasNext();)
{
Object obj = iter.next();
if(obj instanceof ITransmitter)
{
((ITransmitter)obj).refreshTransmitterNetwork();
((ITransmitter)obj).chunkLoad();
}
}
}
}
} catch(Exception e) {
e.printStackTrace();

View file

@ -27,9 +27,7 @@ public class GuiAdvancedElectricMachine extends GuiMekanism
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
{
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
@ -40,6 +38,8 @@ public class GuiAdvancedElectricMachine extends GuiMekanism
{
drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis);
}
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override

View file

@ -59,6 +59,8 @@ public class GuiConfiguration extends GuiMekanism
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
{
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiConfiguration.png"));
@ -145,9 +147,7 @@ public class GuiConfiguration extends GuiMekanism
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
{
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
@ -218,6 +218,8 @@ public class GuiConfiguration extends GuiMekanism
{
drawCreativeTabHoveringText("Strict Input", xAxis, yAxis);
}
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override

View file

@ -89,7 +89,7 @@ public class GuiCredits extends GuiScreen
}
@Override
public void drawScreen(int i, int j, float f)
public void drawScreen(int mouseX, int mouseY, float partialTick)
{
if(updatedRecently && ThreadClientUpdate.modulesBeingDownloaded == 0 && !updateProgress.contains("Error"))
{
@ -135,6 +135,7 @@ public class GuiCredits extends GuiScreen
writeText(EnumColor.GREY + "*Code, textures, and ideas by aidancbrady", size+27);
writeText(EnumColor.GREY + "Recent news: " + EnumColor.DARK_BLUE + (!Mekanism.recentNews.contains("null") ? Mekanism.recentNews : "couldn't access."), size+36);
writeText(EnumColor.GREY + updateProgress, size+45);
super.drawScreen(i, j, f);
super.drawScreen(mouseX, mouseY, partialTick);
}
}

View file

@ -5,7 +5,6 @@ import mekanism.common.inventory.container.ContainerDynamicTank;
import mekanism.common.tileentity.TileEntityDynamicTank;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
@ -16,7 +15,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiDynamicTank extends GuiContainer
public class GuiDynamicTank extends GuiMekanism
{
public TileEntityDynamicTank tileEntity;
@ -38,23 +37,26 @@ public class GuiDynamicTank extends GuiContainer
fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040);
fontRenderer.drawString("Inventory", 8, (ySize - 94) + 2, 0x404040);
fontRenderer.drawString("Volume: " + tileEntity.clientCapacity/16000, 53, 26, 0x00CD00);
fontRenderer.drawString(tileEntity.structure.fluidStored != null ? FluidRegistry.getFluidName(tileEntity.structure.fluidStored) + ":" : "No fluid.", 53, 44, 0x00CD00);
fontRenderer.drawString(tileEntity.structure.fluidStored != null ? tileEntity.structure.fluidStored.getFluid().getName() + ":" : "No fluid.", 53, 44, 0x00CD00);
if(tileEntity.structure.fluidStored != null)
{
fontRenderer.drawString(tileEntity.structure.fluidStored.amount + "mB", 53, 53, 0x00CD00);
}
if(xAxis >= 7 && xAxis <= 39 && yAxis >= 14 && yAxis <= 72)
{
drawCreativeTabHoveringText(tileEntity.structure.fluidStored != null ? FluidRegistry.getFluidName(tileEntity.structure.fluidStored) + ": " + tileEntity.structure.fluidStored.amount + "mB" : "Empty", xAxis, yAxis);
drawCreativeTabHoveringText(tileEntity.structure.fluidStored != null ? tileEntity.structure.fluidStored.getFluid().getLocalizedName() + ": " + tileEntity.structure.fluidStored.amount + "mB" : "Empty", xAxis, yAxis);
}
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
{
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiDynamicTank.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
guiWidth = (width - xSize) / 2;
@ -63,15 +65,15 @@ public class GuiDynamicTank extends GuiContainer
if(tileEntity.getScaledFluidLevel(58) > 0)
{
displayGauge(guiWidth, guiHeight, 7, 14, tileEntity.getScaledFluidLevel(58), tileEntity.structure.fluidStored, 0);
displayGauge(guiWidth, guiHeight, 23, 14, tileEntity.getScaledFluidLevel(58), tileEntity.structure.fluidStored, 1);
displayGauge(7, 14, tileEntity.getScaledFluidLevel(58), tileEntity.structure.fluidStored, 0);
displayGauge(23, 14, tileEntity.getScaledFluidLevel(58), tileEntity.structure.fluidStored, 1);
}
}
/*
* Credit to BuildCraft for both the gauge texture and parts of the code.
*/
public void displayGauge(int width, int height, int xPos, int yPos, int scale, FluidStack fluid, int side /*0-left, 1-right*/)
public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, int side /*0-left, 1-right*/)
{
if(fluid == null)
{
@ -95,7 +97,7 @@ public class GuiDynamicTank extends GuiContainer
}
mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture());
drawTexturedModelRectFromIcon(width + xPos, height + yPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining));
drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining));
start+=16;
if(renderRemaining == 0 || scale == 0)
@ -105,7 +107,6 @@ public class GuiDynamicTank extends GuiContainer
}
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiDynamicTank.png"));
drawTexturedModalRect(width + xPos, height + yPos, 176, side == 0 ? 0 : 54, 16, 54);
drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, side == 0 ? 0 : 54, 16, 54);
}
}

View file

@ -104,6 +104,8 @@ public class GuiElectricChest extends GuiContainer
{
drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(getEnergy()), xAxis, yAxis);
}
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override
@ -135,7 +137,7 @@ public class GuiElectricChest extends GuiContainer
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
{
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiElectricChest.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
@ -143,8 +145,8 @@ public class GuiElectricChest extends GuiContainer
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
int xAxis = (par2 - (width - xSize) / 2);
int yAxis = (par3 - (height - ySize) / 2);
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
if(xAxis >= 179 && xAxis <= 197 && yAxis >= 88 && yAxis <= 106)
{

View file

@ -3,6 +3,7 @@ package mekanism.client.gui;
import mekanism.common.inventory.container.ContainerElectricMachine;
import mekanism.common.tileentity.TileEntityElectricMachine;
import mekanism.common.util.MekanismUtils;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.opengl.GL11;
@ -27,9 +28,7 @@ public class GuiElectricMachine extends GuiMekanism
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
{
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
@ -38,8 +37,12 @@ public class GuiElectricMachine extends GuiMekanism
if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69)
{
GL11.glPushMatrix();
drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis);
GL11.glPopMatrix();
}
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override

View file

@ -5,7 +5,6 @@ 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.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
@ -16,7 +15,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiElectricPump extends GuiContainer
public class GuiElectricPump extends GuiMekanism
{
public TileEntityElectricPump tileEntity;
@ -38,23 +37,27 @@ public class GuiElectricPump extends GuiContainer
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 ? FluidRegistry.getFluidName(tileEntity.fluidTank.getFluid()) + ": " + tileEntity.fluidTank.getFluid().amount : "No fluid.", 51, 35, 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);
if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14 && yAxis <= 72)
{
drawCreativeTabHoveringText(tileEntity.fluidTank.getFluid() != null ? FluidRegistry.getFluidName(tileEntity.fluidTank.getFluid()) + ": " + tileEntity.fluidTank.getFluid().amount + "mB" : "Empty", xAxis, yAxis);
drawCreativeTabHoveringText(tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid().getLocalizedName() + ": " + tileEntity.fluidTank.getFluid().amount + "mB" : "Empty", xAxis, yAxis);
}
if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69)
{
drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis);
}
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
{
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiElectricPump.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
guiWidth = (width - xSize) / 2;
@ -67,14 +70,14 @@ public class GuiElectricPump extends GuiContainer
if(tileEntity.getScaledFluidLevel(58) > 0)
{
displayGauge(guiWidth, guiHeight, 14, 7, tileEntity.getScaledFluidLevel(58), tileEntity.fluidTank.getFluid());
displayGauge(14, 7, tileEntity.getScaledFluidLevel(58), tileEntity.fluidTank.getFluid());
}
}
/*
* Credit to BuildCraft for both the gauge texture and parts of the code.
*/
public void displayGauge(int width, int height, int xPos, int yPos, int scale, FluidStack fluid)
public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid)
{
if(fluid == null)
{
@ -98,7 +101,7 @@ public class GuiElectricPump extends GuiContainer
}
mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture());
drawTexturedModelRectFromIcon(width + yPos, height + xPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining));
drawTexturedModelRectFromIcon(guiWidth + yPos, guiHeight + xPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining));
start+=16;
if(renderRemaining == 0 || scale == 0)
@ -108,6 +111,6 @@ public class GuiElectricPump extends GuiContainer
}
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiElectricPump.png"));
drawTexturedModalRect(width + yPos, height + xPos, 176, 52, 16, 60);
drawTexturedModalRect(guiWidth + yPos, guiHeight + xPos, 176, 52, 16, 60);
}
}

View file

@ -29,8 +29,6 @@ public class GuiEnergyCube extends GuiMekanism
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
@ -41,6 +39,8 @@ public class GuiEnergyCube extends GuiMekanism
fontRenderer.drawString(capacityInfo, 45, 40, 0x00CD00);
fontRenderer.drawString(outputInfo, 45, 49, 0x00CD00);
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 0x404040);
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override
@ -57,7 +57,7 @@ public class GuiEnergyCube extends GuiMekanism
int xAxis = mouseX - guiWidth;
int yAxis = mouseY - guiHeight;
int scale = (int)((tileEntity.electricityStored / tileEntity.tier.MAX_ELECTRICITY) * 72);
drawTexturedModalRect(guiWidth + 65, guiHeight + 17, 176, 0, scale, 10);
int displayInt = tileEntity.getScaledEnergyLevel(72);
drawTexturedModalRect(guiWidth + 65, guiHeight + 17, 176, 0, displayInt, 10);
}
}

View file

@ -32,9 +32,7 @@ public class GuiFactory extends GuiMekanism
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
{
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
@ -51,6 +49,8 @@ public class GuiFactory extends GuiMekanism
{
drawCreativeTabHoveringText("Secondary energy: " + tileEntity.secondaryEnergyStored, xAxis, yAxis);
}
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override

View file

@ -27,17 +27,17 @@ public class GuiGasTank extends GuiMekanism
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
String capacityInfo = tileEntity.gasStored + "/" + tileEntity.MAX_GAS;
String capacityInfo = (tileEntity.getGas() != null ? tileEntity.getGas().amount : 0) + "/" + tileEntity.MAX_GAS;
fontRenderer.drawString("Gas Tank", 43, 6, 0x404040);
fontRenderer.drawString(capacityInfo, 45, 40, 0x404040);
fontRenderer.drawString("Gas: " + tileEntity.gasType.name, 45, 49, 0x404040);
fontRenderer.drawString("Gas: " + (tileEntity.getGas() != null ? tileEntity.getGas().getGas().getLocalizedName() : "None"), 45, 49, 0x404040);
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 0x404040);
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override
@ -51,10 +51,10 @@ public class GuiGasTank extends GuiMekanism
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
int xAxis = mouseX - guiWidth;
int yAxis = mouseY - guiHeight;
int scale = (int)(((double)tileEntity.gasStored / tileEntity.MAX_GAS) * 72);
drawTexturedModalRect(guiWidth + 65, guiHeight + 17, 176, 0, scale, 20);
if(tileEntity.getGas() != null)
{
int scale = (int)(((double)tileEntity.getGas().amount / tileEntity.MAX_GAS) * 72);
drawTexturedModalRect(guiWidth + 65, guiHeight + 17, 176, 0, scale, 20);
}
}
}

View file

@ -34,9 +34,7 @@ public class GuiMetallurgicInfuser extends GuiMekanism
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
{
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
@ -47,6 +45,8 @@ public class GuiMetallurgicInfuser extends GuiMekanism
{
drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis);
}
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override

View file

@ -159,7 +159,7 @@ public class GuiPasswordEnter extends GuiScreen
}
@Override
public void drawScreen(int i, int j, float partialTick)
public void drawScreen(int mouseX, int mouseY, float partialTick)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiPasswordEnter.png"));
@ -170,7 +170,7 @@ public class GuiPasswordEnter extends GuiScreen
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
passwordField.drawTextBox();
super.drawScreen(i, j, partialTick);
super.drawScreen(mouseX, mouseY, partialTick);
fontRenderer.drawString("Password", guiWidth + 64, guiHeight + 5, 0x404040);
fontRenderer.drawString("Enter:", guiWidth + 45, guiHeight + 40, 0x404040);

View file

@ -186,7 +186,7 @@ public class GuiPasswordModify extends GuiScreen
}
@Override
public void drawScreen(int i, int j, float f)
public void drawScreen(int mouseX, int mouseY, float partialTick)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiPasswordModify.png"));
@ -195,7 +195,9 @@ public class GuiPasswordModify extends GuiScreen
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
super.drawScreen(i, j, f);
super.drawScreen(mouseX, mouseY, partialTick);
fontRenderer.drawString("Password", guiWidth + 64, guiHeight + 5, 0x404040);
fontRenderer.drawString(displayText, guiWidth + 37, guiHeight + 19, 0x404040);
fontRenderer.drawString("Enter:", guiWidth + 27, guiHeight + 37, 0x404040);

View file

@ -40,7 +40,7 @@ public class GuiPortableTeleporter extends GuiScreen
}
@Override
public void drawScreen(int i, int j, float f)
public void drawScreen(int mouseX, int mouseY, float partialTick)
{
if(mc.thePlayer.getCurrentEquippedItem() != null && mc.thePlayer.getCurrentEquippedItem().getItem() instanceof ItemPortableTeleporter)
{
@ -74,7 +74,8 @@ public class GuiPortableTeleporter extends GuiScreen
fontRenderer.drawString("Portable Teleporter", guiWidth+39, guiHeight+6, 0x404040);
fontRenderer.drawString(item.getStatusAsString(item.getStatus(itemStack)), guiWidth+53, guiHeight+19, 0x00CD00);
super.drawScreen(i, j, f);
super.drawScreen(mouseX, mouseY, partialTick);
}
@Override
@ -88,12 +89,12 @@ public class GuiPortableTeleporter extends GuiScreen
}
@Override
protected void mouseClicked(int x, int y, int button)
protected void mouseClicked(int mouseX, int mouseY, int button)
{
super.mouseClicked(x, y, button);
super.mouseClicked(mouseX, mouseY, button);
int xAxis = (x - (width - xSize) / 2);
int yAxis = (y - (height - ySize) / 2);
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
if(xAxis > 23 && xAxis < 37 && yAxis > 44 && yAxis < 58)
{

View file

@ -30,10 +30,7 @@ public class GuiRecipeType extends GuiElement
}
@Override
public void renderForeground(int xAxis, int yAxis)
{
}
public void renderForeground(int xAxis, int yAxis) {}
@Override
public void preMouseClicked(int xAxis, int yAxis, int button)

View file

@ -8,7 +8,6 @@ import mekanism.common.network.PacketRobit;
import mekanism.common.network.PacketRobit.RobitPacketType;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.world.World;
@ -18,7 +17,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiRobitCrafting extends GuiContainer
public class GuiRobitCrafting extends GuiMekanism
{
public int entityId;
@ -34,11 +33,15 @@ public class GuiRobitCrafting extends GuiContainer
{
fontRenderer.drawString("Robit Crafting", 8, 6, 0x404040);
fontRenderer.drawString("Inventory", 8, ySize - 96 + 3, 0x404040);
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int mouseX, int mouseY)
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
{
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRobitCrafting.png"));
int guiWidth = (width - xSize) / 2;

View file

@ -9,7 +9,6 @@ import mekanism.common.network.PacketRobit;
import mekanism.common.network.PacketRobit.RobitPacketType;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.opengl.GL11;
@ -18,7 +17,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiRobitInventory extends GuiContainer
public class GuiRobitInventory extends GuiMekanism
{
public EntityRobit robit;
@ -34,11 +33,15 @@ public class GuiRobitInventory extends GuiContainer
{
fontRenderer.drawString("Robit Inventory", 8, 6, 0x404040);
fontRenderer.drawString("Inventory", 8, ySize - 96 + 3, 0x404040);
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int mouseX, int mouseY)
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
{
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRobitInventory.png"));
int guiWidth = (width - xSize) / 2;

View file

@ -11,7 +11,6 @@ import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Keyboard;
@ -21,7 +20,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiRobitMain extends GuiContainer
public class GuiRobitMain extends GuiMekanism
{
public EntityRobit robit;
@ -138,11 +137,15 @@ public class GuiRobitMain extends GuiContainer
{
drawCreativeTabHoveringText("Toggle 'drop pickup' mode", xAxis, yAxis);
}
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int mouseX, int mouseY)
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
{
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRobitMain.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int guiWidth = (width - xSize) / 2;

View file

@ -11,7 +11,6 @@ import mekanism.common.network.PacketRobit.RobitPacketType;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ContainerRepair;
@ -28,7 +27,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiRobitRepair extends GuiContainer implements ICrafting
public class GuiRobitRepair extends GuiMekanism implements ICrafting
{
public int entityId;
private ContainerRepair repairContainer;
@ -118,6 +117,8 @@ public class GuiRobitRepair extends GuiContainer implements ICrafting
}
GL11.glEnable(GL11.GL_LIGHTING);
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override
@ -177,9 +178,10 @@ public class GuiRobitRepair extends GuiContainer implements ICrafting
}
@Override
public void drawScreen(int mouseX, int mouseY, float par3)
public void drawScreen(int mouseX, int mouseY, float partialTick)
{
super.drawScreen(mouseX, mouseY, par3);
super.drawScreen(mouseX, mouseY, partialTick);
GL11.glDisable(GL11.GL_LIGHTING);
itemNameField.drawTextBox();
}
@ -187,6 +189,8 @@ public class GuiRobitRepair extends GuiContainer implements ICrafting
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
{
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRobitRepair.png"));
int guiWidth = (width - xSize) / 2;

View file

@ -9,12 +9,11 @@ import mekanism.common.network.PacketRobit;
import mekanism.common.network.PacketRobit.RobitPacketType;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.opengl.GL11;
public class GuiRobitSmelting extends GuiContainer
public class GuiRobitSmelting extends GuiMekanism
{
public EntityRobit robit;
@ -30,11 +29,15 @@ public class GuiRobitSmelting extends GuiContainer
{
fontRenderer.drawString("Robit Smelting", 8, 6, 0x404040);
fontRenderer.drawString("Inventory", 8, ySize - 96 + 3, 0x404040);
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
{
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRobitSmelting.png"));
int guiWidth = (width - xSize) / 2;

View file

@ -10,7 +10,6 @@ import mekanism.common.network.PacketTileEntity;
import mekanism.common.tileentity.TileEntityTeleporter;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.opengl.GL11;
@ -19,7 +18,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiTeleporter extends GuiContainer
public class GuiTeleporter extends GuiMekanism
{
public TileEntityTeleporter tileEntity;
@ -43,6 +42,8 @@ public class GuiTeleporter extends GuiContainer
{
drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis);
}
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override
@ -94,8 +95,10 @@ public class GuiTeleporter extends GuiContainer
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
{
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int guiWidth = (width - xSize) / 2;

View file

@ -4,7 +4,7 @@ import java.util.Arrays;
import java.util.List;
import mekanism.api.EnumColor;
import mekanism.api.gas.EnumGas;
import mekanism.api.gas.GasRegistry;
import mekanism.common.ISpecialBounds;
import mekanism.common.ObfuscatedNames;
import mekanism.common.util.MekanismUtils;
@ -66,8 +66,8 @@ public class MekanismRenderer
energyIcon = event.map.registerIcon("mekanism:LiquidEnergy");
EnumGas.HYDROGEN.gasIcon = event.map.registerIcon("mekanism:LiquidHydrogen");
EnumGas.OXYGEN.gasIcon = event.map.registerIcon("mekanism:LiquidOxygen");
GasRegistry.getGas("hydrogen").setIcon(event.map.registerIcon("mekanism:LiquidHydrogen"));
GasRegistry.getGas("oxygen").setIcon(event.map.registerIcon("mekanism:LiquidOxygen"));
}
}

View file

@ -4,7 +4,7 @@ import java.util.Arrays;
import java.util.HashMap;
import mekanism.api.Object3D;
import mekanism.api.gas.EnumGas;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasTransmission;
import mekanism.api.gas.ITubeConnection;
import mekanism.client.model.ModelTransmitter;
@ -13,7 +13,6 @@ import mekanism.client.render.MekanismRenderer;
import mekanism.client.render.MekanismRenderer.BooleanArray;
import mekanism.client.render.MekanismRenderer.DisplayInteger;
import mekanism.client.render.MekanismRenderer.Model3D;
import mekanism.common.Mekanism;
import mekanism.common.tileentity.TileEntityGasTank;
import mekanism.common.tileentity.TileEntityPressurizedTube;
import mekanism.common.util.MekanismUtils;
@ -22,7 +21,6 @@ import net.minecraft.block.Block;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import org.lwjgl.opengl.GL11;
@ -36,7 +34,7 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
private boolean[] connectable;
private HashMap<BooleanArray, HashMap<EnumGas, DisplayInteger>> cachedCenterGasses = new HashMap<BooleanArray, HashMap<EnumGas, DisplayInteger>>();
private HashMap<BooleanArray, HashMap<Gas, DisplayInteger>> cachedCenterGasses = new HashMap<BooleanArray, HashMap<Gas, DisplayInteger>>();
private static final double offset = 0.015;
@ -114,10 +112,10 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glPopMatrix();
EnumGas gasType = tileEntity.getTransmitterNetwork().refGas;
Gas gasType = tileEntity.getTransmitterNetwork().refGas;
float scale = tileEntity.getTransmitterNetwork().gasScale;
if(scale > 0 && gasType != null && gasType.hasTexture())
if(scale > 0 && gasType != null && gasType.getIcon() != null)
{
push();
@ -157,7 +155,7 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
}
@SuppressWarnings("incomplete-switch")
private DisplayInteger getListAndRender(ForgeDirection side, EnumGas type, Block block)
private DisplayInteger getListAndRender(ForgeDirection side, Gas type, Block block)
{
if(side == ForgeDirection.UNKNOWN)
{
@ -169,7 +167,7 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
Model3D toReturn = new Model3D();
toReturn.baseBlock = Block.waterStill;
toReturn.setTexture(type.gasIcon);
toReturn.setTexture(type.getIcon());
toReturn.minX = 0.3 + offset;
toReturn.minY = 0.3 + offset;
@ -193,7 +191,7 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
cachedCenterGasses.get(side).put(type, display);
}
else {
HashMap<EnumGas, DisplayInteger> map = new HashMap<EnumGas, DisplayInteger>();
HashMap<Gas, DisplayInteger> map = new HashMap<Gas, DisplayInteger>();
map.put(type, display);
cachedCenterGasses.put(new BooleanArray(connectable), map);
@ -204,7 +202,7 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
Model3D toReturn = new Model3D();
toReturn.baseBlock = Block.waterStill;
toReturn.setTexture(type.gasIcon);
toReturn.setTexture(type.getIcon());
toReturn.setSideRender(side, false);
toReturn.setSideRender(side.getOpposite(), false);

View file

@ -148,7 +148,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
{
if(fluidScale > 0)
{
fluidScale -= .02;
fluidScale = Math.max(0, fluidScale-.02F);
}
else {
refFluid = null;

View file

@ -14,6 +14,7 @@ import java.util.Set;
import java.util.logging.Logger;
import mekanism.api.Object3D;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasNetwork.GasTransferEvent;
import mekanism.api.infuse.InfuseObject;
import mekanism.api.infuse.InfuseRegistry;
@ -1063,6 +1064,9 @@ public class Mekanism
System.out.println("[Mekanism] Detected Tekkit in root directory - hello, fellow user!");
}
GasRegistry.registerHydrogen();
GasRegistry.registerOxygen();
Mekanism.proxy.preInit();
MinecraftForge.EVENT_BUS.register(hooks);
@ -1186,7 +1190,7 @@ public class Mekanism
@ForgeSubscribe
public void onChunkLoad(ChunkEvent.Load event)
{
if(event.getChunk() != null)
if(event.getChunk() != null && !event.world.isRemote)
{
for(Iterator iter = event.getChunk().chunkTileEntityMap.values().iterator(); iter.hasNext();)
{

View file

@ -2,7 +2,7 @@ package mekanism.common.block;
import java.util.Random;
import mekanism.api.IStorageTank;
import mekanism.api.gas.IGasItem;
import mekanism.common.ISustainedInventory;
import mekanism.common.ItemAttacher;
import mekanism.common.Mekanism;
@ -210,9 +210,8 @@ public class BlockGasTank extends BlockContainer
TileEntityGasTank tileEntity = (TileEntityGasTank)world.getBlockTileEntity(x, y, z);
ItemStack itemStack = new ItemStack(Mekanism.GasTank);
IStorageTank storageTank = (IStorageTank)itemStack.getItem();
storageTank.setGasType(itemStack, tileEntity.gasType);
storageTank.setGas(tileEntity.gasType, tileEntity.gasStored, itemStack);
IGasItem storageTank = (IGasItem)itemStack.getItem();
storageTank.setGas(tileEntity.gasStored, itemStack);
ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem();
inventory.setInventory(((ISustainedInventory)tileEntity).getInventory(), itemStack);

View file

@ -1,6 +1,6 @@
package mekanism.common.inventory.container;
import mekanism.api.IStorageTank;
import mekanism.api.gas.IGasItem;
import mekanism.common.Mekanism;
import mekanism.common.RecipeHandler;
import mekanism.common.inventory.slot.SlotMachineUpgrade;

View file

@ -1,7 +1,6 @@
package mekanism.common.inventory.container;
import mekanism.api.IStorageTank;
import mekanism.api.gas.EnumGas;
import mekanism.api.gas.IGasItem;
import mekanism.common.inventory.slot.SlotStorageTank;
import mekanism.common.tileentity.TileEntityGasTank;
import net.minecraft.entity.player.EntityPlayer;
@ -17,8 +16,8 @@ public class ContainerGasTank extends Container
public ContainerGasTank(InventoryPlayer inventory, TileEntityGasTank tentity)
{
tileEntity = tentity;
addSlotToContainer(new SlotStorageTank(tentity, EnumGas.NONE, true, 0, 8, 8));
addSlotToContainer(new SlotStorageTank(tentity, EnumGas.NONE, true, 1, 8, 40));
addSlotToContainer(new SlotStorageTank(tentity, null, true, 0, 8, 8));
addSlotToContainer(new SlotStorageTank(tentity, null, true, 1, 8, 40));
int slotX;
@ -65,7 +64,7 @@ public class ContainerGasTank extends Container
ItemStack slotStack = currentSlot.getStack();
stack = slotStack.copy();
if(slotStack.getItem() instanceof IStorageTank)
if(slotStack.getItem() instanceof IGasItem)
{
if(slotID != 0 && slotID != 1)
{

View file

@ -1,17 +1,17 @@
package mekanism.common.inventory.slot;
import mekanism.api.IStorageTank;
import mekanism.api.gas.EnumGas;
import mekanism.api.gas.Gas;
import mekanism.api.gas.IGasItem;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotStorageTank extends Slot
{
public EnumGas type;
public Gas type;
public boolean acceptsAllGasses;
public SlotStorageTank(IInventory inventory, EnumGas gas, boolean all, int index, int x, int y)
public SlotStorageTank(IInventory inventory, Gas gas, boolean all, int index, int x, int y)
{
super(inventory, index, x, y);
type = gas;
@ -23,13 +23,14 @@ public class SlotStorageTank extends Slot
{
if(acceptsAllGasses)
{
return itemstack.getItem() instanceof IStorageTank;
return itemstack.getItem() instanceof IGasItem;
}
if(itemstack.getItem() instanceof IStorageTank)
if(itemstack.getItem() instanceof IGasItem)
{
return ((IStorageTank)itemstack.getItem()).getGasType(itemstack) == type || ((IStorageTank)itemstack.getItem()).getGasType(itemstack) == EnumGas.NONE;
return ((IGasItem)itemstack.getItem()).getGas(itemstack) == null || ((IGasItem)itemstack.getItem()).getGas(itemstack).getGas() == type;
}
return false;
}
}

View file

@ -3,15 +3,15 @@ package mekanism.common.item;
import java.util.List;
import mekanism.api.EnumColor;
import mekanism.api.IStorageTank;
import mekanism.api.gas.EnumGas;
import mekanism.common.IEnergyCube;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.IGasItem;
import mekanism.common.ISustainedInventory;
import mekanism.common.Mekanism;
import mekanism.common.tileentity.TileEntityGasTank;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
@ -22,7 +22,7 @@ import net.minecraft.world.World;
import org.lwjgl.input.Keyboard;
public class ItemBlockGasTank extends ItemBlock implements IStorageTank, ISustainedInventory
public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedInventory
{
public Block metaBlock;
@ -63,8 +63,7 @@ public class ItemBlockGasTank extends ItemBlock implements IStorageTank, ISustai
if(place)
{
TileEntityGasTank tileEntity = (TileEntityGasTank)world.getBlockTileEntity(x, y, z);
tileEntity.gasType = getGasType(stack);
tileEntity.gasStored = getGas(getGasType(stack), stack);
tileEntity.gasStored = getGas(stack);
((ISustainedInventory)tileEntity).setInventory(getInventory(stack));
}
@ -75,14 +74,14 @@ public class ItemBlockGasTank extends ItemBlock implements IStorageTank, ISustai
@Override
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag)
{
int gas = getGas(getGasType(itemstack), itemstack);
GasStack gasStack = getGas(itemstack);
if(getGasType(itemstack) == EnumGas.NONE)
if(gasStack == null)
{
list.add("No gas stored.");
}
else {
list.add("Stored " + getGasType(itemstack).name + ": " + gas);
list.add("Stored " + gasStack.getGas().getLocalizedName() + ": " + gasStack.amount);
}
if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
@ -101,45 +100,35 @@ public class ItemBlockGasTank extends ItemBlock implements IStorageTank, ISustai
}
@Override
public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag)
{
if(getGasType(itemstack) != EnumGas.NONE && getGas(getGasType(itemstack), itemstack) == 0)
{
setGasType(itemstack, EnumGas.NONE);
}
}
@Override
public int getGas(EnumGas type, Object... data)
public GasStack getGas(Object... data)
{
if(data[0] instanceof ItemStack)
{
ItemStack itemstack = (ItemStack)data[0];
if(getGasType(itemstack) == type || type == EnumGas.NONE)
if(itemstack.stackTagCompound == null)
{
if(itemstack.stackTagCompound == null)
{
return 0;
}
int stored = 0;
if(itemstack.stackTagCompound.getTag("gas") != null)
{
stored = itemstack.stackTagCompound.getInteger("gas");
}
itemstack.setItemDamage((int)Math.max(1, (Math.abs((((float)stored/MAX_GAS)*100)-100))));
return stored;
return null;
}
GasStack stored = GasStack.readFromNBT(itemstack.stackTagCompound.getCompoundTag("stored"));
if(stored == null)
{
itemstack.setItemDamage(100);
}
else {
itemstack.setItemDamage((int)Math.max(1, (Math.abs((((float)stored.amount/getMaxGas(itemstack))*100)-100))));
}
return stored;
}
return 0;
return null;
}
@Override
public void setGas(EnumGas type, int amount, Object... data)
public void setGas(GasStack stack, Object... data)
{
if(data[0] instanceof ItemStack)
{
@ -150,21 +139,17 @@ public class ItemBlockGasTank extends ItemBlock implements IStorageTank, ISustai
itemstack.setTagCompound(new NBTTagCompound());
}
if(getGasType(itemstack) == EnumGas.NONE)
if(stack == null || stack.amount == 0)
{
setGasType(itemstack, type);
itemstack.setItemDamage(100);
itemstack.stackTagCompound.removeTag("stored");
}
if(getGasType(itemstack) == type)
{
int stored = Math.max(Math.min(amount, MAX_GAS), 0);
itemstack.stackTagCompound.setInteger("gas", stored);
itemstack.setItemDamage((int)Math.max(1, (Math.abs((((float)stored/MAX_GAS)*100)-100))));
}
if(getGas(getGasType(itemstack), itemstack) == 0)
{
setGasType(itemstack, EnumGas.NONE);
else {
int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack)));
GasStack gasStack = new GasStack(stack.getGas(), amount);
itemstack.setItemDamage((int)Math.max(1, (Math.abs((((float)amount/getMaxGas(itemstack))*100)-100))));
itemstack.stackTagCompound.setCompoundTag("stored", gasStack.write(new NBTTagCompound()));
}
}
}
@ -172,7 +157,7 @@ public class ItemBlockGasTank extends ItemBlock implements IStorageTank, ISustai
public ItemStack getEmptyItem()
{
ItemStack empty = new ItemStack(this);
setGasType(empty, EnumGas.NONE);
setGas(null, empty);
empty.setItemDamage(100);
return empty;
}
@ -181,34 +166,24 @@ public class ItemBlockGasTank extends ItemBlock implements IStorageTank, ISustai
public void getSubItems(int i, CreativeTabs tabs, List list)
{
ItemStack empty = new ItemStack(this);
setGasType(empty, EnumGas.NONE);
setGas(null, empty);
empty.setItemDamage(100);
list.add(empty);
for(EnumGas type : EnumGas.values())
for(Gas type : GasRegistry.getRegisteredGasses())
{
if(type != EnumGas.NONE)
{
ItemStack filled = new ItemStack(this);
setGasType(filled, type);
setGas(type, ((IStorageTank)filled.getItem()).getMaxGas(type, filled), filled);
list.add(filled);
}
ItemStack filled = new ItemStack(this);
setGas(new GasStack(type, ((IGasItem)filled.getItem()).getMaxGas(filled)), filled);
list.add(filled);
}
}
@Override
public int getMaxGas(EnumGas type, Object... data)
public int getMaxGas(Object... data)
{
if(data[0] instanceof ItemStack)
{
ItemStack itemStack = (ItemStack)data[0];
IStorageTank tank = (IStorageTank)itemStack.getItem();
if(getGasType(itemStack) == EnumGas.NONE || getGasType(itemStack) == type || type == EnumGas.NONE)
{
return MAX_GAS;
}
return MAX_GAS;
}
return 0;
@ -221,68 +196,50 @@ public class ItemBlockGasTank extends ItemBlock implements IStorageTank, ISustai
}
@Override
public int addGas(ItemStack itemstack, EnumGas type, int amount)
public int addGas(ItemStack itemstack, GasStack stack)
{
if(getGasType(itemstack) == type || getGasType(itemstack) == EnumGas.NONE)
if(getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas())
{
int rejects = Math.max((getGas(getGasType(itemstack), itemstack) + amount) - MAX_GAS, 0);
setGas(type, getGas(type, itemstack) + amount - rejects, itemstack);
return rejects;
return 0;
}
return amount;
int toUse = Math.min(getMaxGas(itemstack)-getStored(itemstack), Math.min(getRate(), stack.amount));
setGas(new GasStack(stack.getGas(), getStored(itemstack)+toUse), itemstack);
return toUse;
}
@Override
public int removeGas(ItemStack itemstack, EnumGas type, int amount)
public GasStack removeGas(ItemStack itemstack, int amount)
{
if(getGasType(itemstack) == type)
if(getGas(itemstack) == null)
{
int gasToUse = Math.min(getGas(type, itemstack), amount);
setGas(type, getGas(type, itemstack) - gasToUse, itemstack);
return gasToUse;
return null;
}
return 0;
Gas type = getGas(itemstack).getGas();
int gasToUse = Math.min(getStored(itemstack), Math.min(getRate(), amount));
setGas(new GasStack(type, getStored(itemstack)-gasToUse), itemstack);
return new GasStack(type, gasToUse);
}
private int getStored(ItemStack itemstack)
{
return getGas(itemstack) != null ? getGas(itemstack).amount : 0;
}
@Override
public boolean canReceiveGas(ItemStack itemstack, EnumGas type)
public boolean canReceiveGas(ItemStack itemstack, Gas type)
{
return getGasType(itemstack) == type || getGasType(itemstack) == EnumGas.NONE;
return getGas(itemstack) == null || getGas(itemstack).getGas() == type;
}
@Override
public boolean canProvideGas(ItemStack itemstack, EnumGas type)
public boolean canProvideGas(ItemStack itemstack, Gas type)
{
return getGasType(itemstack) == type;
}
@Override
public EnumGas getGasType(ItemStack itemstack)
{
if(itemstack.stackTagCompound == null)
{
return EnumGas.NONE;
}
if(itemstack.stackTagCompound.getString("type") == null)
{
return EnumGas.NONE;
}
return EnumGas.getFromName(itemstack.stackTagCompound.getString("gasType"));
}
@Override
public void setGasType(ItemStack itemstack, EnumGas type)
{
if(itemstack.stackTagCompound == null)
{
itemstack.setTagCompound(new NBTTagCompound());
}
itemstack.stackTagCompound.setString("gasType", type.name);
return getGas(itemstack) != null && (type == null || getGas(itemstack).getGas() == type);
}
@Override

View file

@ -1,7 +1,10 @@
package mekanism.common.miner;
import java.util.ArrayList;
import java.util.List;
import mekanism.common.util.ListUtils;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -9,6 +12,8 @@ import com.google.common.io.ByteArrayDataInput;
public class MItemStackFilter extends MinerFilter
{
private static List<Integer> metaIgnoreArray = ListUtils.asList(Block.planks.blockID);
public ItemStack itemType;
public MItemStackFilter(ItemStack item)
@ -25,6 +30,11 @@ public class MItemStackFilter extends MinerFilter
{
return false;
}
if(itemStack.itemID == itemType.itemID && metaIgnoreArray.contains(itemType.itemID))
{
return true;
}
return itemType.isItemEqual(itemStack);
}

View file

@ -2,7 +2,8 @@ package mekanism.common.network;
import java.io.DataOutputStream;
import mekanism.api.gas.EnumGas;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.transmitters.ITransmitter;
import mekanism.common.tileentity.TileEntityMechanicalPipe;
import mekanism.common.tileentity.TileEntityPressurizedTube;
@ -23,7 +24,7 @@ public class PacketTransmitterUpdate implements IMekanismPacket
public double power;
public String gasName;
public int gasType;
public float gasScale;
public int fluidType;
@ -47,7 +48,7 @@ public class PacketTransmitterUpdate implements IMekanismPacket
power = (Double)data[2];
break;
case GAS:
gasName = data[2] != null ? ((EnumGas)data[2]).name : "null";
gasType = (Integer)data[2];
gasScale = (Float)data[3];
break;
case FLUID:
@ -92,8 +93,7 @@ public class PacketTransmitterUpdate implements IMekanismPacket
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
String type = dataStream.readUTF();
EnumGas gasType = type.equals("null") ? null : EnumGas.getFromName(type);
Gas gasType = GasRegistry.getGas(dataStream.readInt());
gasScale = dataStream.readFloat();
if(tileEntity != null)
@ -133,7 +133,7 @@ public class PacketTransmitterUpdate implements IMekanismPacket
dataStream.writeDouble(power);
break;
case GAS:
dataStream.writeUTF(gasName);
dataStream.writeInt(gasType);
dataStream.writeFloat(gasScale);
break;
case FLUID:

View file

@ -3,9 +3,7 @@ package mekanism.common.tileentity;
import java.util.ArrayList;
import mekanism.api.EnumColor;
import mekanism.api.IStorageTank;
import mekanism.api.SideData;
import mekanism.api.gas.EnumGas;
import mekanism.common.Mekanism;
import mekanism.common.RecipeHandler;
import mekanism.common.TileComponentEjector;

View file

@ -227,15 +227,21 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
if(silkTouch)
{
ret *= 6;
ret *= 6F;
}
int baseRad = Math.max(radius-10, 0);
ret *= (1 + ((float)baseRad/22F));
int baseHeight = Math.max((maxY-minY)-60, 0);
ret *= (1 + ((float)baseHeight/195F));
return ret;
}
public int getDelay()
{
return (int)Math.pow((9-getSpeedMultiplier()), 2);
return MekanismUtils.getTicks(getSpeedMultiplier(), 100);
}
public void setReplace(Object3D obj)

View file

@ -7,11 +7,13 @@ import java.util.ArrayList;
import mekanism.api.EnumColor;
import mekanism.api.IConfigurable;
import mekanism.api.IEjector;
import mekanism.api.IStorageTank;
import mekanism.api.Object3D;
import mekanism.api.SideData;
import mekanism.api.energy.IStrictEnergyAcceptor;
import mekanism.api.gas.EnumGas;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasUtils;
import mekanism.api.gas.IGasAcceptor;
import mekanism.api.gas.IGasStorage;
import mekanism.api.gas.ITubeConnection;
@ -259,32 +261,10 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
{
if(recipeType == RecipeType.PURIFYING.ordinal())
{
if(inventory[4].getItem() instanceof IStorageTank)
{
if(((IStorageTank)inventory[4].getItem()).getGasType(inventory[4]) == EnumGas.OXYGEN)
{
IStorageTank item = (IStorageTank)inventory[4].getItem();
if(item.canProvideGas(inventory[4], EnumGas.OXYGEN))
{
int received = 0;
int gasNeeded = getMaxSecondaryEnergy() - secondaryEnergyStored;
if(item.getRate() <= gasNeeded)
{
received = item.removeGas(inventory[4], EnumGas.OXYGEN, item.getRate());
}
else if(item.getRate() > gasNeeded)
{
received = item.removeGas(inventory[4], EnumGas.OXYGEN, gasNeeded);
}
setGas(EnumGas.OXYGEN, secondaryEnergyStored + received);
}
}
return;
}
GasStack removed = GasUtils.removeGas(inventory[4], GasRegistry.getGas("oxygen"), getMaxSecondaryEnergy()-secondaryEnergyStored);
setSecondaryEnergy(secondaryEnergyStored - (removed != null ? removed.amount : 0));
return;
}
int fuelTicks = RecipeType.values()[recipeType].getFuelTicks(inventory[4]);
@ -863,71 +843,57 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
}
@Override
public int getGas(EnumGas type, Object... data)
public GasStack getGas(Object... data)
{
if(type == EnumGas.OXYGEN)
if(secondaryEnergyStored == 0)
{
return secondaryEnergyStored;
return null;
}
return 0;
return new GasStack(GasRegistry.getGas("oxygen"), secondaryEnergyStored);
}
@Override
public void setGas(EnumGas type, int amount, Object... data)
public void setGas(GasStack stack, Object... data)
{
if(type == EnumGas.OXYGEN)
if(stack == null)
{
setSecondaryEnergy(amount);
setSecondaryEnergy(0);
}
else if(stack.getGas() == GasRegistry.getGas("oxygen"))
{
setSecondaryEnergy(stack.amount);
}
MekanismUtils.saveChunk(this);
}
@Override
public int getMaxGas(EnumGas type, Object... data)
public int getMaxGas(Object... data)
{
if(type == EnumGas.OXYGEN)
return getMaxSecondaryEnergy();
}
@Override
public int receiveGas(GasStack stack)
{
if(stack.getGas() == GasRegistry.getGas("oxygen"))
{
return getMaxSecondaryEnergy();
int stored = getGas() != null ? getGas().amount : 0;
int toUse = Math.min(getMaxGas()-stored, stack.amount);
setGas(new GasStack(stack.getGas(), stored + toUse));
return toUse;
}
return 0;
}
@Override
public int transferGasToAcceptor(int amount, EnumGas type)
public boolean canReceiveGas(ForgeDirection side, Gas type)
{
if(type == EnumGas.OXYGEN && recipeType == RecipeType.PURIFYING.ordinal())
{
int rejects = 0;
int neededGas = getMaxSecondaryEnergy()-secondaryEnergyStored;
if(amount <= neededGas)
{
secondaryEnergyStored += amount;
}
else if(amount > neededGas)
{
secondaryEnergyStored += neededGas;
rejects = amount-neededGas;
}
return rejects;
}
return amount;
}
@Override
public boolean canReceiveGas(ForgeDirection side, EnumGas type)
{
if(recipeType != RecipeType.PURIFYING.ordinal())
{
return false;
}
return type == EnumGas.OXYGEN;
return type == GasRegistry.getGas("oxygen");
}
@Override

View file

@ -2,11 +2,14 @@ package mekanism.common.tileentity;
import java.util.ArrayList;
import mekanism.api.IStorageTank;
import mekanism.api.Object3D;
import mekanism.api.gas.EnumGas;
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.IGasItem;
import mekanism.api.gas.IGasStorage;
import mekanism.api.gas.ITubeConnection;
import mekanism.common.IRedstoneControl;
@ -21,13 +24,9 @@ import com.google.common.io.ByteArrayDataInput;
public class TileEntityGasTank extends TileEntityContainerBlock implements IGasStorage, IGasAcceptor, ITubeConnection, IRedstoneControl
{
/** The type of gas stored in this tank. */
public EnumGas gasType;
public GasStack gasStored;
/** The maximum amount of gas this tank can hold. */
public int MAX_GAS = 96000;
/** How much gas this tank is currently storing. */
public int gasStored;
public final int MAX_GAS = 96000;
/** How fast this tank can output gas. */
public int output = 16;
@ -38,7 +37,6 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasS
public TileEntityGasTank()
{
super("Gas Tank");
gasType = EnumGas.NONE;
inventory = new ItemStack[2];
controlType = RedstoneControl.DISABLED;
}
@ -46,101 +44,37 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasS
@Override
public void onUpdate()
{
if(inventory[0] != null && gasStored > 0)
if(inventory[0] != null && gasStored != null)
{
if(inventory[0].getItem() instanceof IStorageTank)
setGas(new GasStack(getGas().getGas(), gasStored.amount - GasUtils.addGas(inventory[0], getGas())));
}
if(inventory[1] != null && (gasStored == null || gasStored.amount < getMaxGas()))
{
if(gasStored == null)
{
if(((IStorageTank)inventory[0].getItem()).getGasType(inventory[0]) == gasType || ((IStorageTank)inventory[0].getItem()).getGasType(inventory[0]) == EnumGas.NONE)
{
IStorageTank item = (IStorageTank)inventory[0].getItem();
if(gasType == EnumGas.NONE)
{
gasType = item.getGasType(inventory[0]);
}
if(item.canReceiveGas(inventory[0], gasType))
{
int sendingGas = 0;
if(item.getRate() <= gasStored)
{
sendingGas = item.getRate();
}
else if(item.getRate() > gasStored)
{
sendingGas = gasStored;
}
int rejects = item.addGas(inventory[0], gasType, sendingGas);
setGas(gasType, gasStored - (sendingGas - rejects));
}
}
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)));
}
}
if(inventory[1] != null && gasStored < MAX_GAS)
if(!worldObj.isRemote && gasStored != null && MekanismUtils.canFunction(this))
{
if(inventory[1].getItem() instanceof IStorageTank)
{
if(((IStorageTank)inventory[1].getItem()).getGasType(inventory[1]) == gasType || gasType == EnumGas.NONE)
{
IStorageTank item = (IStorageTank)inventory[1].getItem();
if(gasType == EnumGas.NONE)
{
gasType = item.getGasType(inventory[1]);
}
if(item.canProvideGas(inventory[1], gasType))
{
int received = 0;
int gasNeeded = MAX_GAS - gasStored;
if(item.getRate() <= gasNeeded)
{
received = item.removeGas(inventory[1], gasType, item.getRate());
}
else if(item.getRate() > gasNeeded)
{
received = item.removeGas(inventory[1], gasType, gasNeeded);
}
setGas(gasType, gasStored + received);
}
}
}
}
if(gasStored == 0)
{
gasType = EnumGas.NONE;
}
if(!worldObj.isRemote && gasStored > 0 && MekanismUtils.canFunction(this))
{
setGas(gasType, gasStored - (Math.min(gasStored, output) - GasTransmission.emitGasToNetwork(gasType, Math.min(gasStored, output), this, ForgeDirection.getOrientation(facing))));
GasStack toSend = new GasStack(getGas().getGas(), Math.min(getGas().amount, output));
setGas(new GasStack(getGas().getGas(), getGas().amount - GasTransmission.emitGasToNetwork(toSend, this, ForgeDirection.getOrientation(facing))));
TileEntity tileEntity = Object3D.get(this).getFromSide(ForgeDirection.getOrientation(facing)).getTileEntity(worldObj);
if(tileEntity instanceof IGasAcceptor)
{
if(((IGasAcceptor)tileEntity).canReceiveGas(ForgeDirection.getOrientation(facing).getOpposite(), gasType))
if(((IGasAcceptor)tileEntity).canReceiveGas(ForgeDirection.getOrientation(facing).getOpposite(), getGas().getGas()))
{
int sendingGas = 0;
int added = ((IGasAcceptor)tileEntity).receiveGas(new GasStack(getGas().getGas(), Math.min(getGas().amount, output)));
if(getGas(gasType) >= output)
{
sendingGas = output;
}
else if(getGas(gasType) < output)
{
sendingGas = getGas(gasType);
}
int rejects = ((IGasAcceptor)tileEntity).transferGasToAcceptor(sendingGas, gasType);
setGas(gasType, getGas(gasType) - (sendingGas - rejects));
setGas(new GasStack(getGas().getGas(), getGas().amount - added));
}
}
}
@ -151,12 +85,12 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasS
{
if(slotID == 1)
{
return (itemstack.getItem() instanceof IStorageTank && ((IStorageTank)itemstack.getItem()).getGas(EnumGas.NONE, itemstack) == 0);
return (itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) == null);
}
else if(slotID == 0)
{
return (itemstack.getItem() instanceof IStorageTank &&
((IStorageTank)itemstack.getItem()).getGas(EnumGas.NONE, itemstack) == ((IStorageTank)itemstack.getItem()).getMaxGas(EnumGas.NONE, itemstack));
return (itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null &&
((IGasItem)itemstack.getItem()).getGas(itemstack).amount == ((IGasItem)itemstack.getItem()).getMaxGas(itemstack));
}
return false;
@ -167,11 +101,11 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasS
{
if(slotID == 0)
{
return itemstack.getItem() instanceof IStorageTank && (gasType == EnumGas.NONE || ((IStorageTank)itemstack.getItem()).canReceiveGas(itemstack, gasType));
return itemstack.getItem() instanceof IGasItem && (getGas() == null || ((IGasItem)itemstack.getItem()).canReceiveGas(itemstack, getGas().getGas()));
}
else if(slotID == 1)
{
return itemstack.getItem() instanceof IStorageTank && (gasType == EnumGas.NONE || ((IStorageTank)itemstack.getItem()).canProvideGas(itemstack, gasType));
return itemstack.getItem() instanceof IGasItem && (getGas() == null || ((IGasItem)itemstack.getItem()).canProvideGas(itemstack, getGas().getGas()));
}
return true;
@ -184,66 +118,51 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasS
}
@Override
public int getGas(EnumGas type, Object... data)
public GasStack getGas(Object... data)
{
if(type == gasType)
{
return gasStored;
}
return 0;
return gasStored;
}
@Override
public void setGas(EnumGas type, int amount, Object... data)
public void setGas(GasStack stack, Object... data)
{
if(type == gasType)
if(stack == null || stack.amount == 0)
{
gasStored = Math.max(Math.min(amount, MAX_GAS), 0);
gasStored = null;
}
else {
gasStored = new GasStack(stack.getGas(), Math.max(Math.min(stack.amount, getMaxGas()), 0));
}
MekanismUtils.saveChunk(this);
}
@Override
public int getMaxGas(EnumGas type, Object... data)
public int getMaxGas(Object... data)
{
return MAX_GAS;
}
@Override
public int transferGasToAcceptor(int amount, EnumGas type)
public int receiveGas(GasStack stack)
{
if(type == gasType || gasType == EnumGas.NONE)
if(gasStored == null || (gasStored != null && gasStored.getGas() == stack.getGas()))
{
if(gasType == EnumGas.NONE)
{
gasType = type;
}
int stored = getGas() != null ? getGas().amount : 0;
int toUse = Math.min(getMaxGas()-stored, stack.amount);
int rejects = 0;
int neededGas = MAX_GAS-gasStored;
setGas(new GasStack(stack.getGas(), stored + toUse));
if(amount <= neededGas)
{
gasStored += amount;
}
else if(amount > neededGas)
{
gasStored += neededGas;
rejects = amount-neededGas;
}
return rejects;
return toUse;
}
return amount;
return 0;
}
@Override
public boolean canReceiveGas(ForgeDirection side, EnumGas type)
public boolean canReceiveGas(ForgeDirection side, Gas type)
{
return (type == gasType || gasType == EnumGas.NONE) && side != ForgeDirection.getOrientation(facing);
return (getGas() == null || getGas().getGas() == type) && side != ForgeDirection.getOrientation(facing);
}
@Override
@ -251,8 +170,14 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasS
{
super.handlePacketData(dataStream);
gasStored = dataStream.readInt();
gasType = EnumGas.getFromName(dataStream.readUTF());
if(dataStream.readBoolean())
{
gasStored = new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt());
}
else {
gasStored = null;
}
controlType = RedstoneControl.values()[dataStream.readInt()];
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
@ -263,8 +188,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasS
{
super.readFromNBT(nbtTags);
gasStored = nbtTags.getInteger("gasStored");
gasType = EnumGas.getFromName(nbtTags.getString("gasType"));
gasStored = GasStack.readFromNBT(nbtTags.getCompoundTag("gasStored"));
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
}
@ -273,8 +197,11 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasS
{
super.writeToNBT(nbtTags);
nbtTags.setInteger("gasStored", gasStored);
nbtTags.setString("gasType", gasType.name);
if(gasStored != null)
{
nbtTags.setCompoundTag("gasStored", gasStored.write(new NBTTagCompound()));
}
nbtTags.setInteger("controlType", controlType.ordinal());
}
@ -283,8 +210,16 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasS
{
super.getNetworkedData(data);
data.add(gasStored);
data.add(gasType.name);
if(gasStored != null)
{
data.add(true);
data.add(gasStored.getGas().getID());
data.add(gasStored.amount);
}
else {
data.add(false);
}
data.add(controlType.ordinal());
return data;

View file

@ -3,7 +3,6 @@ package mekanism.common.tileentity;
import java.util.HashSet;
import mekanism.api.Object3D;
import mekanism.api.gas.EnumGas;
import mekanism.api.gas.GasNetwork;
import mekanism.api.gas.GasTransmission;
import mekanism.api.gas.IGasTransmitter;

View file

@ -2,9 +2,12 @@ package mekanism.common.tileentity;
import java.util.Map;
import mekanism.api.IStorageTank;
import mekanism.api.gas.EnumGas;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasUtils;
import mekanism.api.gas.IGasAcceptor;
import mekanism.api.gas.IGasItem;
import mekanism.api.gas.IGasStorage;
import mekanism.api.gas.ITubeConnection;
import mekanism.common.Mekanism;
@ -33,72 +36,64 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac
public int getFuelTicks(ItemStack itemstack)
{
if(itemstack.isItemEqual(new ItemStack(Item.flint))) return 300;
if(itemstack.isItemEqual(new ItemStack(Mekanism.GasTank)) && ((IStorageTank)itemstack.getItem()).getGasType(itemstack) == EnumGas.OXYGEN) return 1;
if(itemstack.isItemEqual(new ItemStack(Mekanism.GasTank)) && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null &&
((IGasItem)itemstack.getItem()).getGas(itemstack).getGas() == GasRegistry.getGas("oxygen")) return 1;
return 0;
}
@Override
public int getGas(EnumGas type, Object... data)
public GasStack getGas(Object... data)
{
if(type == EnumGas.OXYGEN)
if(secondaryEnergyStored == 0)
{
return secondaryEnergyStored;
return null;
}
return 0;
return new GasStack(GasRegistry.getGas("oxygen"), secondaryEnergyStored);
}
@Override
public void setGas(EnumGas type, int amount, Object... data)
public void setGas(GasStack stack, Object... data)
{
if(type == EnumGas.OXYGEN)
if(stack == null)
{
setSecondaryEnergy(amount);
setSecondaryEnergy(0);
}
else if(stack.getGas() == GasRegistry.getGas("oxygen"))
{
setSecondaryEnergy(stack.amount);
}
MekanismUtils.saveChunk(this);
}
@Override
public int getMaxGas(EnumGas type, Object... data)
public int getMaxGas(Object... data)
{
if(type == EnumGas.OXYGEN)
return MAX_SECONDARY_ENERGY;
}
@Override
public int receiveGas(GasStack stack)
{
if(stack.getGas() == GasRegistry.getGas("oxygen"))
{
return MAX_SECONDARY_ENERGY;
int stored = getGas() != null ? getGas().amount : 0;
int toUse = Math.min(getMaxGas()-stored, stack.amount);
setGas(new GasStack(stack.getGas(), stored + toUse));
return toUse;
}
return 0;
}
@Override
public int transferGasToAcceptor(int amount, EnumGas type)
public boolean canReceiveGas(ForgeDirection side, Gas type)
{
if(type == EnumGas.OXYGEN)
{
int rejects = 0;
int neededGas = MAX_SECONDARY_ENERGY-secondaryEnergyStored;
if(amount <= neededGas)
{
secondaryEnergyStored += amount;
}
else if(amount > neededGas)
{
secondaryEnergyStored += neededGas;
rejects = amount-neededGas;
}
return rejects;
}
return amount;
}
@Override
public boolean canReceiveGas(ForgeDirection side, EnumGas type)
{
return type == EnumGas.OXYGEN;
return type == GasRegistry.getGas("oxygen");
}
@Override
@ -106,32 +101,8 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac
{
if(inventory[1] != null && secondaryEnergyStored < MAX_SECONDARY_ENERGY)
{
if(inventory[1].getItem() instanceof IStorageTank)
{
if(((IStorageTank)inventory[1].getItem()).getGasType(inventory[1]) == EnumGas.OXYGEN)
{
IStorageTank item = (IStorageTank)inventory[1].getItem();
if(item.canProvideGas(inventory[1], EnumGas.OXYGEN))
{
int received = 0;
int gasNeeded = MAX_SECONDARY_ENERGY - secondaryEnergyStored;
if(item.getRate() <= gasNeeded)
{
received = item.removeGas(inventory[1], EnumGas.OXYGEN, item.getRate());
}
else if(item.getRate() > gasNeeded)
{
received = item.removeGas(inventory[1], EnumGas.OXYGEN, gasNeeded);
}
setGas(EnumGas.OXYGEN, secondaryEnergyStored + received);
}
}
return;
}
GasStack removed = GasUtils.removeGas(inventory[1], GasRegistry.getGas("oxygen"), MAX_SECONDARY_ENERGY-secondaryEnergyStored);
setSecondaryEnergy(secondaryEnergyStored - (removed != null ? removed.amount : 0));
}
super.handleSecondaryFuel();

View file

@ -162,6 +162,11 @@ public class ListUtils
public static <V> List<V> asList(Set<V> set)
{
return (List<V>) Arrays.asList(set.toArray());
return (List<V>)Arrays.asList(set.toArray());
}
public static <V> List<V> asList(V... values)
{
return (List<V>)Arrays.asList(values);
}
}

View file

@ -2,6 +2,7 @@ package mekanism.common.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import mekanism.api.EnumColor;
import mekanism.api.Object3D;
@ -23,26 +24,8 @@ import buildcraft.api.power.PowerHandler.Type;
public final class TransporterUtils
{
public static ArrayList<EnumColor> colors = buildColors();
public static ArrayList<EnumColor> buildColors()
{
ArrayList<EnumColor> ret = new ArrayList<EnumColor>();
ret.add(EnumColor.DARK_BLUE);
ret.add(EnumColor.DARK_GREEN);
ret.add(EnumColor.DARK_AQUA);
ret.add(EnumColor.DARK_RED);
ret.add(EnumColor.PURPLE);
ret.add(EnumColor.INDIGO);
ret.add(EnumColor.BRIGHT_GREEN);
ret.add(EnumColor.AQUA);
ret.add(EnumColor.RED);
ret.add(EnumColor.PINK);
ret.add(EnumColor.YELLOW);
return ret;
}
public static List<EnumColor> colors = ListUtils.asList(EnumColor.DARK_BLUE, EnumColor.DARK_GREEN, EnumColor.DARK_AQUA, EnumColor.DARK_RED, EnumColor.PURPLE,
EnumColor.INDIGO, EnumColor.BRIGHT_GREEN, EnumColor.AQUA, EnumColor.RED, EnumColor.PINK, EnumColor.YELLOW, EnumColor.BLACK);
/**
* Gets all the transporters around a tile entity.

View file

@ -3,7 +3,8 @@ package mekanism.generators.client.gui;
import java.util.ArrayList;
import mekanism.api.Object3D;
import mekanism.api.gas.EnumGas;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.network.PacketTileEntity;
@ -40,48 +41,48 @@ public class GuiElectrolyticSeparator extends GuiContainer
if(xAxis > 160 && xAxis < 169 && yAxis > 73 && yAxis < 82)
{
String nameToSet = "";
Gas gasToSet = null;
if(tileEntity.outputType == EnumGas.HYDROGEN)
if(tileEntity.outputType == GasRegistry.getGas("hydrogen"))
{
nameToSet = EnumGas.OXYGEN.name;
gasToSet = GasRegistry.getGas("oxygen");
}
else if(tileEntity.outputType == EnumGas.OXYGEN)
else if(tileEntity.outputType == GasRegistry.getGas("oxygen"))
{
nameToSet = EnumGas.NONE.name;
gasToSet = null;
}
else if(tileEntity.outputType == EnumGas.NONE)
else if(tileEntity.outputType == null)
{
nameToSet = EnumGas.HYDROGEN.name;
gasToSet = GasRegistry.getGas("hydrogen");
}
ArrayList data = new ArrayList();
data.add((byte)0);
data.add(nameToSet);
data.add(GasRegistry.getGasID(gasToSet));
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
}
else if(xAxis > 8 && xAxis < 17 && yAxis > 73 && yAxis < 82)
{
String nameToSet = "";
Gas gasToSet = null;
if(tileEntity.dumpType == EnumGas.NONE)
if(tileEntity.dumpType == null)
{
nameToSet = EnumGas.OXYGEN.name;
gasToSet = GasRegistry.getGas("oxygen");
}
else if(tileEntity.dumpType == EnumGas.OXYGEN)
else if(tileEntity.dumpType == GasRegistry.getGas("oxygen"))
{
nameToSet = EnumGas.HYDROGEN.name;
gasToSet = GasRegistry.getGas("hydrogen");
}
else if(tileEntity.dumpType == EnumGas.HYDROGEN)
else if(tileEntity.dumpType == GasRegistry.getGas("hydrogen"))
{
nameToSet = EnumGas.NONE.name;
gasToSet = null;
}
ArrayList data = new ArrayList();
data.add((byte)1);
data.add(nameToSet);
data.add(GasRegistry.getGasID(gasToSet));
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
@ -113,10 +114,10 @@ public class GuiElectrolyticSeparator extends GuiContainer
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
int outputDisplay = tileEntity.outputType == EnumGas.OXYGEN ? 82 : (tileEntity.outputType == EnumGas.HYDROGEN ? 90 : 98);
int outputDisplay = tileEntity.outputType == GasRegistry.getGas("oxygen") ? 82 : (tileEntity.outputType == GasRegistry.getGas("hydrogen") ? 90 : 98);
drawTexturedModalRect(guiWidth + 160, guiHeight + 73, 176, outputDisplay, 8, 8);
int dumpDisplay = tileEntity.dumpType == EnumGas.OXYGEN ? 82 : (tileEntity.dumpType == EnumGas.HYDROGEN ? 90 : 98);
int dumpDisplay = tileEntity.dumpType == GasRegistry.getGas("oxygen") ? 82 : (tileEntity.dumpType == GasRegistry.getGas("hydrogen") ? 90 : 98);
drawTexturedModalRect(guiWidth + 8, guiHeight + 73, 176, dumpDisplay, 8, 8);
int displayInt;

View file

@ -1,6 +1,6 @@
package mekanism.generators.client.render;
import mekanism.api.gas.EnumGas;
import mekanism.api.gas.GasRegistry;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import mekanism.generators.client.model.ModelElectrolyticSeparator;
@ -28,8 +28,8 @@ public class RenderElectrolyticSeparator extends TileEntitySpecialRenderer
{
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, tileEntity.outputType == EnumGas.HYDROGEN ? "ElectrolyticSeparatorHydrogen.png" :
(tileEntity.outputType == EnumGas.OXYGEN ? "ElectrolyticSeparatorOxygen.png" : "ElectrolyticSeparatorNone.png")));
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, tileEntity.outputType == GasRegistry.getGas("hydrogen") ? "ElectrolyticSeparatorHydrogen.png" :
(tileEntity.outputType == GasRegistry.getGas("oxygen") ? "ElectrolyticSeparatorOxygen.png" : "ElectrolyticSeparatorNone.png")));
switch(tileEntity.facing)
{

View file

@ -1,9 +1,9 @@
package mekanism.generators.common.inventory.container;
import mekanism.api.IStorageTank;
import mekanism.api.gas.EnumGas;
import mekanism.common.inventory.slot.SlotStorageTank;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.IGasItem;
import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge;
import mekanism.common.inventory.slot.SlotStorageTank;
import mekanism.common.util.ChargeUtils;
import mekanism.generators.common.tileentity.TileEntityElectrolyticSeparator;
import net.minecraft.entity.player.EntityPlayer;
@ -23,8 +23,8 @@ public class ContainerElectrolyticSeparator extends Container
{
tileEntity = tentity;
addSlotToContainer(new Slot(tentity, 0, 17, 35));
addSlotToContainer(new SlotStorageTank(tentity, EnumGas.HYDROGEN, false, 1, 59, 52));
addSlotToContainer(new SlotStorageTank(tentity, EnumGas.OXYGEN, false, 2, 101, 52));
addSlotToContainer(new SlotStorageTank(tentity, GasRegistry.getGas("hydrogen"), false, 1, 59, 52));
addSlotToContainer(new SlotStorageTank(tentity, GasRegistry.getGas("oxygen"), false, 2, 101, 52));
addSlotToContainer(new SlotDischarge(tentity, 3, 143, 35));
int slotX;
@ -79,23 +79,26 @@ public class ContainerElectrolyticSeparator extends Container
return null;
}
}
else if(slotStack.getItem() instanceof IStorageTank)
else if(slotStack.getItem() instanceof IGasItem)
{
if(((IStorageTank)slotStack.getItem()).getGasType(slotStack) == EnumGas.HYDROGEN)
if(((IGasItem)slotStack.getItem()).getGas(slotStack) != null)
{
if(!mergeItemStack(slotStack, 1, 2, false))
{
return null;
}
if(((IGasItem)slotStack.getItem()).getGas(slotStack).getGas() == GasRegistry.getGas("hydrogen"))
{
if(!mergeItemStack(slotStack, 1, 2, false))
{
return null;
}
}
else if(((IGasItem)slotStack.getItem()).getGas(slotStack).getGas() == GasRegistry.getGas("oxygen"))
{
if(!mergeItemStack(slotStack, 2, 3, false))
{
return null;
}
}
}
else if(((IStorageTank)slotStack.getItem()).getGasType(slotStack) == EnumGas.OXYGEN)
{
if(!mergeItemStack(slotStack, 2, 3, false))
{
return null;
}
}
else if(((IStorageTank)slotStack.getItem()).getGasType(slotStack) == EnumGas.NONE)
else if(((IGasItem)slotStack.getItem()).getGas(slotStack) == null)
{
if(!mergeItemStack(slotStack, 1, 2, false))
{

View file

@ -1,7 +1,7 @@
package mekanism.generators.common.inventory.container;
import mekanism.api.IStorageTank;
import mekanism.api.gas.EnumGas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.IGasItem;
import mekanism.common.inventory.slot.SlotEnergy.SlotCharge;
import mekanism.common.util.ChargeUtils;
import mekanism.generators.common.tileentity.TileEntityHydrogenGenerator;
@ -81,11 +81,11 @@ public class ContainerHydrogenGenerator extends Container
}
}
}
else if(slotStack.getItem() instanceof IStorageTank)
else if(slotStack.getItem() instanceof IGasItem)
{
if(slotID != 0 && slotID != 1)
{
if(((IStorageTank)slotStack.getItem()).getGasType(slotStack) == EnumGas.HYDROGEN)
if(((IGasItem)slotStack.getItem()).getGas(slotStack) != null && ((IGasItem)slotStack.getItem()).getGas(slotStack).getGas() == GasRegistry.getGas("hydrogen"))
{
if(!mergeItemStack(slotStack, 0, 1, false))
{

View file

@ -5,13 +5,15 @@ import ic2.api.energy.tile.IEnergySink;
import java.util.ArrayList;
import java.util.Random;
import mekanism.api.IStorageTank;
import mekanism.api.Object3D;
import mekanism.api.energy.IStrictEnergyAcceptor;
import mekanism.api.gas.EnumGas;
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.IGasItem;
import mekanism.api.gas.ITubeConnection;
import mekanism.common.ISustainedTank;
import mekanism.common.Mekanism;
@ -24,7 +26,6 @@ import mekanism.common.util.MekanismUtils;
import mekanism.generators.common.MekanismGenerators;
import mekanism.generators.common.block.BlockGenerator.GeneratorType;
import mekanism.generators.common.network.PacketElectrolyticSeparatorParticle;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@ -43,7 +44,7 @@ import dan200.computer.api.IComputerAccess;
import dan200.computer.api.ILuaContext;
import dan200.computer.api.IPeripheral;
public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock implements IGasStorage, IEnergySink, IFluidHandler, IPeripheral, ITubeConnection, IStrictEnergyAcceptor, ISustainedTank
public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock implements IEnergySink, IFluidHandler, IPeripheral, ITubeConnection, IStrictEnergyAcceptor, ISustainedTank
{
/** This separator's water slot. */
public FluidTank waterTank = new FluidTank(24000);
@ -61,17 +62,17 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
public int output = 16;
/** The type of gas this block is outputting. */
public EnumGas outputType;
public Gas outputType;
/** Type type of gas this block is dumping. */
public EnumGas dumpType;
public Gas dumpType;
public TileEntityElectrolyticSeparator()
{
super("Electrolytic Separator", GeneratorType.ELECTROLYTIC_SEPARATOR.maxEnergy);
inventory = new ItemStack[4];
outputType = EnumGas.HYDROGEN;
dumpType = EnumGas.NONE;
outputType = GasRegistry.getGas("oxygen");
dumpType = null;
}
@Override
@ -113,58 +114,14 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
{
if(inventory[1] != null && hydrogenStored > 0)
{
if(inventory[1].getItem() instanceof IStorageTank)
{
if(((IStorageTank)inventory[1].getItem()).getGasType(inventory[1]) == EnumGas.HYDROGEN || ((IStorageTank)inventory[1].getItem()).getGasType(inventory[1]) == EnumGas.NONE)
{
IStorageTank item = (IStorageTank)inventory[1].getItem();
if(item.canReceiveGas(inventory[1], EnumGas.HYDROGEN))
{
int sendingGas = 0;
if(item.getRate() <= hydrogenStored)
{
sendingGas = item.getRate();
}
else if(item.getRate() > hydrogenStored)
{
sendingGas = hydrogenStored;
}
int rejects = item.addGas(inventory[1], EnumGas.HYDROGEN, sendingGas);
setGas(EnumGas.HYDROGEN, hydrogenStored - (sendingGas - rejects));
}
}
}
hydrogenStored -= GasUtils.addGas(inventory[0], new GasStack(GasRegistry.getGas("hydrogen"), hydrogenStored));
MekanismUtils.saveChunk(this);
}
if(inventory[2] != null && oxygenStored > 0)
{
if(inventory[2].getItem() instanceof IStorageTank)
{
if(((IStorageTank)inventory[2].getItem()).getGasType(inventory[2]) == EnumGas.OXYGEN || ((IStorageTank)inventory[2].getItem()).getGasType(inventory[2]) == EnumGas.NONE)
{
IStorageTank item = (IStorageTank)inventory[2].getItem();
if(item.canReceiveGas(inventory[2], EnumGas.OXYGEN))
{
int sendingGas = 0;
if(item.getRate() <= oxygenStored)
{
sendingGas = item.getRate();
}
else if(item.getRate() > oxygenStored)
{
sendingGas = oxygenStored;
}
int rejects = item.addGas(inventory[2], EnumGas.OXYGEN, sendingGas);
setGas(EnumGas.OXYGEN, oxygenStored - (sendingGas - rejects));
}
}
}
hydrogenStored -= GasUtils.addGas(inventory[0], new GasStack(GasRegistry.getGas("oxygen"), oxygenStored));
MekanismUtils.saveChunk(this);
}
}
@ -172,13 +129,14 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
{
waterTank.drain(2, true);
setEnergy(getEnergy() - MekanismGenerators.electrolyticSeparatorUsage);
setGas(EnumGas.OXYGEN, oxygenStored + 1);
setGas(EnumGas.HYDROGEN, hydrogenStored + 2);
setStored(GasRegistry.getGas("oxygen"), oxygenStored + 1);
setStored(GasRegistry.getGas("hydrogen"), hydrogenStored + 2);
}
if(outputType != EnumGas.NONE && getGas(outputType) > 0)
if(outputType != null && getStored(outputType) > 0)
{
setGas(outputType, getGas(outputType) - (Math.min(getGas(outputType), output) - GasTransmission.emitGasToNetwork(outputType, Math.min(getGas(outputType), output), this, ForgeDirection.getOrientation(facing))));
GasStack toSend = new GasStack(outputType, Math.min(getStored(outputType), output));
setStored(outputType, getStored(outputType) - GasTransmission.emitGasToNetwork(toSend, this, ForgeDirection.getOrientation(facing)));
TileEntity tileEntity = Object3D.get(this).getFromSide(ForgeDirection.getOrientation(facing)).getTileEntity(worldObj);
@ -186,16 +144,16 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
{
if(((IGasAcceptor)tileEntity).canReceiveGas(ForgeDirection.getOrientation(facing).getOpposite(), outputType))
{
int sendingGas = Math.min(getGas(outputType), output);
int rejects = ((IGasAcceptor)tileEntity).transferGasToAcceptor(Math.min(getGas(outputType), output), outputType);
setGas(outputType, getGas(outputType) - (sendingGas - rejects));
int added = ((IGasAcceptor)tileEntity).receiveGas(new GasStack(outputType, Math.min(getStored(outputType), output)));
setStored(outputType, getStored(outputType) - added);
}
}
}
if(dumpType != EnumGas.NONE && getGas(dumpType) > 0)
if(dumpType != null && getStored(dumpType) > 0)
{
setGas(dumpType, (getGas(dumpType) - 8));
setStored(dumpType, (getStored(dumpType) - 8));
if(new Random().nextInt(3) == 2)
{
@ -205,6 +163,34 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
}
}
public int getStored(Gas gas)
{
if(gas == GasRegistry.getGas("oxygen"))
{
return oxygenStored;
}
else if(gas == GasRegistry.getGas("hydrogen"))
{
return hydrogenStored;
}
return 0;
}
public void setStored(Gas type, int amount)
{
if(type == GasRegistry.getGas("hydrogen"))
{
hydrogenStored = Math.max(Math.min(amount, MAX_GAS), 0);
}
else if(type == GasRegistry.getGas("oxygen"))
{
oxygenStored = Math.max(Math.min(amount, MAX_GAS), 0);
}
MekanismUtils.saveChunk(this);
}
public void spawnParticle()
{
switch(facing)
@ -235,13 +221,10 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
{
return FluidContainerRegistry.isEmptyContainer(itemstack);
}
else if(slotID == 1)
else if(slotID == 1 || slotID == 2)
{
return itemstack.getItem() instanceof IStorageTank && ((IStorageTank)itemstack.getItem()).getGas(EnumGas.HYDROGEN, itemstack) == ((IStorageTank)itemstack.getItem()).getMaxGas(EnumGas.HYDROGEN, itemstack);
}
else if(slotID == 2)
{
return itemstack.getItem() instanceof IStorageTank && ((IStorageTank)itemstack.getItem()).getGas(EnumGas.OXYGEN, itemstack) == ((IStorageTank)itemstack.getItem()).getMaxGas(EnumGas.OXYGEN, itemstack);
return itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null &&
((IGasItem)itemstack.getItem()).getGas(itemstack).amount == ((IGasItem)itemstack.getItem()).getMaxGas(itemstack);
}
return false;
@ -256,11 +239,11 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
}
else if(slotID == 1)
{
return itemstack.getItem() instanceof IStorageTank && (((IStorageTank)itemstack.getItem()).getGasType(itemstack) == EnumGas.HYDROGEN || ((IStorageTank)itemstack.getItem()).getGasType(itemstack) == EnumGas.NONE);
return itemstack.getItem() instanceof IGasItem && (((IGasItem)itemstack.getItem()).getGas(itemstack) == null || ((IGasItem)itemstack.getItem()).getGas(itemstack).getGas() == GasRegistry.getGas("hydrogen"));
}
else if(slotID == 2)
{
return itemstack.getItem() instanceof IStorageTank && (((IStorageTank)itemstack.getItem()).getGasType(itemstack) == EnumGas.OXYGEN || ((IStorageTank)itemstack.getItem()).getGasType(itemstack) == EnumGas.NONE);
return itemstack.getItem() instanceof IGasItem && (((IGasItem)itemstack.getItem()).getGas(itemstack) == null || ((IGasItem)itemstack.getItem()).getGas(itemstack).getGas() == GasRegistry.getGas("oxygen"));
}
else if(slotID == 3)
{
@ -358,12 +341,12 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
if(type == 0)
{
outputType = EnumGas.getFromName(dataStream.readUTF());
outputType = GasRegistry.getGas(dataStream.readInt());
return;
}
else if(type == 1)
{
dumpType = EnumGas.getFromName(dataStream.readUTF());
dumpType = GasRegistry.getGas(dataStream.readInt());
return;
}
}
@ -382,8 +365,8 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
oxygenStored = dataStream.readInt();
hydrogenStored = dataStream.readInt();
outputType = EnumGas.getFromName(dataStream.readUTF());
dumpType = EnumGas.getFromName(dataStream.readUTF());
outputType = GasRegistry.getGas(dataStream.readInt());
dumpType = GasRegistry.getGas(dataStream.readInt());
}
@Override
@ -401,48 +384,12 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
data.add(oxygenStored);
data.add(hydrogenStored);
data.add(outputType.name);
data.add(dumpType.name);
data.add(GasRegistry.getGasID(outputType));
data.add(GasRegistry.getGasID(dumpType));
return data;
}
@Override
public int getMaxGas(EnumGas type, Object... data)
{
return MAX_GAS;
}
@Override
public void setGas(EnumGas type, int amount, Object... data)
{
if(type == EnumGas.HYDROGEN)
{
hydrogenStored = Math.max(Math.min(amount, MAX_GAS), 0);
}
else if(type == EnumGas.OXYGEN)
{
oxygenStored = Math.max(Math.min(amount, MAX_GAS), 0);
}
MekanismUtils.saveChunk(this);
}
@Override
public int getGas(EnumGas type, Object... data)
{
if(type == EnumGas.HYDROGEN)
{
return hydrogenStored;
}
else if(type == EnumGas.OXYGEN)
{
return oxygenStored;
}
return 0;
}
@Override
public double demandedEnergyUnits()
{
@ -498,8 +445,8 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
waterTank.readFromNBT(nbtTags.getCompoundTag("waterTank"));
}
outputType = EnumGas.getFromName(nbtTags.getString("outputType"));
dumpType = EnumGas.getFromName(nbtTags.getString("dumpType"));
outputType = Gas.readFromNBT(nbtTags.getCompoundTag("outputType"));
dumpType = Gas.readFromNBT(nbtTags.getCompoundTag("dumpType"));
}
@Override
@ -515,8 +462,15 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
nbtTags.setTag("waterTank", waterTank.writeToNBT(new NBTTagCompound()));
}
nbtTags.setString("outputType", outputType.name);
nbtTags.setString("dumpType", dumpType.name);
if(outputType != null)
{
nbtTags.setCompoundTag("outputType", outputType.write(new NBTTagCompound()));
}
if(dumpType != null)
{
nbtTags.setCompoundTag("dumpType", dumpType.write(new NBTTagCompound()));
}
}
@Override

View file

@ -2,9 +2,12 @@ package mekanism.generators.common.tileentity;
import java.util.ArrayList;
import mekanism.api.IStorageTank;
import mekanism.api.gas.EnumGas;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasUtils;
import mekanism.api.gas.IGasAcceptor;
import mekanism.api.gas.IGasItem;
import mekanism.api.gas.IGasStorage;
import mekanism.api.gas.ITubeConnection;
import mekanism.common.util.ChargeUtils;
@ -44,27 +47,8 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements
if(inventory[0] != null && hydrogenStored < MAX_HYDROGEN)
{
if(inventory[0].getItem() instanceof IStorageTank)
{
IStorageTank item = (IStorageTank)inventory[0].getItem();
if(item.canProvideGas(inventory[0], EnumGas.HYDROGEN) && item.getGasType(inventory[0]) == EnumGas.HYDROGEN)
{
int received = 0;
int hydrogenNeeded = MAX_HYDROGEN - hydrogenStored;
if(item.getRate() <= hydrogenNeeded)
{
received = item.removeGas(inventory[0], EnumGas.HYDROGEN, item.getRate());
}
else if(item.getRate() > hydrogenNeeded)
{
received = item.removeGas(inventory[0], EnumGas.HYDROGEN, hydrogenNeeded);
}
setGas(EnumGas.HYDROGEN, hydrogenStored + received);
}
}
GasStack removed = GasUtils.removeGas(inventory[0], GasRegistry.getGas("hydrogen"), getMaxGas()-hydrogenStored);
setGas(new GasStack(GasRegistry.getGas("hydrogen"), hydrogenStored - (removed != null ? removed.amount : 0)));
}
if(canOperate())
@ -89,7 +73,7 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements
}
else if(slotID == 0)
{
return (itemstack.getItem() instanceof IStorageTank && ((IStorageTank)itemstack.getItem()).getGas(EnumGas.NONE, itemstack) == 0);
return (itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) == null);
}
return false;
@ -100,7 +84,8 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements
{
if(slotID == 0)
{
return itemstack.getItem() instanceof IStorageTank && ((IStorageTank)itemstack.getItem()).getGasType(itemstack) == EnumGas.HYDROGEN;
return itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null &&
((IGasItem)itemstack.getItem()).getGas(itemstack).getGas() == GasRegistry.getGas("hydrogen");
}
else if(slotID == 1)
{
@ -116,27 +101,31 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements
return ForgeDirection.getOrientation(side) == MekanismUtils.getRight(facing) ? new int[] {1} : new int[] {0};
}
@Override
public void setGas(EnumGas type, int amount, Object... data)
@Override
public GasStack getGas(Object... data)
{
if(type == EnumGas.HYDROGEN)
if(hydrogenStored == 0)
{
hydrogenStored = Math.max(Math.min(amount, MAX_HYDROGEN), 0);
return null;
}
return new GasStack(GasRegistry.getGas("hydrogen"), hydrogenStored);
}
@Override
public void setGas(GasStack stack, Object... data)
{
if(stack == null)
{
hydrogenStored = 0;
}
else if(stack.getGas() == GasRegistry.getGas("hydrogen"))
{
hydrogenStored = Math.max(Math.min(stack.amount, getMaxGas()), 0);
}
MekanismUtils.saveChunk(this);
}
@Override
public int getGas(EnumGas type, Object... data)
{
if(type == EnumGas.HYDROGEN)
{
return hydrogenStored;
}
return 0;
}
@Override
public boolean canOperate()
@ -205,26 +194,19 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements
}
@Override
public int transferGasToAcceptor(int amount, EnumGas type)
public int receiveGas(GasStack stack)
{
if(type == EnumGas.HYDROGEN)
if(stack.getGas() == GasRegistry.getGas("hydrogen"))
{
int rejects = 0;
int neededHydrogen = MAX_HYDROGEN-hydrogenStored;
if(amount <= neededHydrogen)
{
hydrogenStored += amount;
}
else if(amount > neededHydrogen)
{
hydrogenStored += neededHydrogen;
rejects = amount-neededHydrogen;
}
int stored = getGas() != null ? getGas().amount : 0;
int toUse = Math.min(getMaxGas()-stored, stack.amount);
setGas(new GasStack(stack.getGas(), stored + toUse));
return rejects;
return toUse;
}
return amount;
return 0;
}
@Override
@ -244,9 +226,9 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements
}
@Override
public boolean canReceiveGas(ForgeDirection side, EnumGas type)
public boolean canReceiveGas(ForgeDirection side, Gas type)
{
return type == EnumGas.HYDROGEN && side != ForgeDirection.getOrientation(facing);
return type == GasRegistry.getGas("hydrogen") && side != ForgeDirection.getOrientation(facing);
}
@Override
@ -256,13 +238,8 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements
}
@Override
public int getMaxGas(EnumGas type, Object... data)
public int getMaxGas(Object... data)
{
if(type == EnumGas.HYDROGEN)
{
return MAX_HYDROGEN;
}
return 0;
return MAX_HYDROGEN;
}
}

View file

@ -18,6 +18,7 @@ import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
@ -59,7 +60,11 @@ public class GuiMultimeter extends GuiContainer
protected void keyTyped(char par1, int par2)
{
super.keyTyped(par1, par2);
textFieldLimit.textboxKeyTyped(par1, par2);
if(Character.isDigit(par1) || par2 == Keyboard.KEY_DELETE || par2 == Keyboard.KEY_LEFT || par2 == Keyboard.KEY_RIGHT)
{
textFieldLimit.textboxKeyTyped(par1, par2);
}
ArrayList data = new ArrayList();
data.add((byte)3);
@ -88,6 +93,14 @@ public class GuiMultimeter extends GuiContainer
textFieldLimit.drawTextBox();
}
@Override
public void updateScreen()
{
super.updateScreen();
textFieldLimit.updateCursorCounter();
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y)