Work on that Rotary Condensentrator!
This commit is contained in:
parent
e06b8614a2
commit
98e864cd8d
16 changed files with 760 additions and 75 deletions
|
@ -13,23 +13,23 @@ public interface IGasItem extends IGasStorage
|
|||
* Gets the rate of transfer this item can handle.
|
||||
* @return
|
||||
*/
|
||||
public int getRate();
|
||||
public int getRate(ItemStack itemstack);
|
||||
|
||||
/**
|
||||
* Adds a defined about of a certain gas to a Storage Tank.
|
||||
* @param itemstack - the itemstack of a Storage Tank to add gas to
|
||||
* Adds a defined amount of a certain gas to an item.
|
||||
* @param itemstack - the itemstack to add gas to
|
||||
* @param type - the type of gas to add
|
||||
* @param amount - the amount of gas to add
|
||||
* @return used gas
|
||||
* @return the gas that was accepted by the item
|
||||
*/
|
||||
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 itemstack - the itemstack to remove gas from
|
||||
* @param type - the type of gas to remove
|
||||
* @param amount - the amount of gas to remove
|
||||
* @return removed gas
|
||||
* @return the gas that was removed by the item
|
||||
*/
|
||||
public GasStack removeGas(ItemStack itemstack, int amount);
|
||||
|
||||
|
@ -42,9 +42,9 @@ public interface IGasItem extends IGasStorage
|
|||
public boolean canReceiveGas(ItemStack itemstack, Gas type);
|
||||
|
||||
/**
|
||||
* Whether or not this energized item can give a gas receiver a certain amount of gas.
|
||||
* Whether or not this item can give a gas receiver a certain type of gas.
|
||||
* @param itemstack - the itemstack to check
|
||||
* @param type - the type of gas the tank can possibly provide
|
||||
* @param type - the type of gas the tank can provide
|
||||
* @return if the item can provide gas
|
||||
*/
|
||||
public boolean canProvideGas(ItemStack itemstack, Gas type);
|
||||
|
|
|
@ -304,6 +304,7 @@ public class ClientProxy extends CommonProxy
|
|||
return new GuiCrusher(player.inventory, (TileEntityElectricMachine)tileEntity);
|
||||
case 7:
|
||||
//return new GuiRotaryCondensentrator(player.inventory, (TileEntityRotaryCondensentrator)tileEntity); TODO
|
||||
return null;
|
||||
case 8:
|
||||
return new GuiEnergyCube(player.inventory, (TileEntityEnergyCube)tileEntity);
|
||||
case 9:
|
||||
|
|
|
@ -70,7 +70,7 @@ public class GuiElectricPump extends GuiMekanism
|
|||
|
||||
if(tileEntity.getScaledFluidLevel(58) > 0)
|
||||
{
|
||||
displayGauge(14, 7, tileEntity.getScaledFluidLevel(58), tileEntity.fluidTank.getFluid());
|
||||
displayGauge(7, 14, tileEntity.getScaledFluidLevel(58), tileEntity.fluidTank.getFluid());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class GuiElectricPump extends GuiMekanism
|
|||
}
|
||||
|
||||
mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture());
|
||||
drawTexturedModelRectFromIcon(guiWidth + yPos, guiHeight + xPos + 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)
|
||||
|
@ -111,6 +111,6 @@ public class GuiElectricPump extends GuiMekanism
|
|||
}
|
||||
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiElectricPump.png"));
|
||||
drawTexturedModalRect(guiWidth + yPos, guiHeight + xPos, 176, 52, 16, 60);
|
||||
drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, 52, 16, 60);
|
||||
}
|
||||
}
|
||||
|
|
127
common/mekanism/client/gui/GuiRotaryCondensentrator.java
Normal file
127
common/mekanism/client/gui/GuiRotaryCondensentrator.java
Normal file
|
@ -0,0 +1,127 @@
|
|||
package mekanism.client.gui;
|
||||
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.common.inventory.container.ContainerRotaryCondensentrator;
|
||||
import mekanism.common.tileentity.TileEntityRotaryCondensentrator;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiRotaryCondensentrator extends GuiMekanism
|
||||
{
|
||||
public TileEntityRotaryCondensentrator tileEntity;
|
||||
|
||||
private int guiWidth;
|
||||
private int guiHeight;
|
||||
|
||||
public GuiRotaryCondensentrator(InventoryPlayer inventory, TileEntityRotaryCondensentrator tentity)
|
||||
{
|
||||
super(new ContainerRotaryCondensentrator(inventory, tentity));
|
||||
tileEntity = tentity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040);
|
||||
fontRenderer.drawString("Inventory", 8, (ySize - 94) + 2, 0x404040);
|
||||
fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00);
|
||||
fontRenderer.drawString(tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid().getName() + ": " + tileEntity.fluidTank.getFluid().amount : "No fluid.", 51, 35, 0x00CD00);
|
||||
fontRenderer.drawString(tileEntity.getVoltage() + "v", 51, 44, 0x00CD00);
|
||||
|
||||
if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14 && yAxis <= 72)
|
||||
{
|
||||
drawCreativeTabHoveringText(tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid().getLocalizedName() + ": " + tileEntity.fluidTank.getFluid().amount + "mB" : "Empty", xAxis, yAxis);
|
||||
}
|
||||
|
||||
if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80)
|
||||
{
|
||||
drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis);
|
||||
}
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
|
||||
{
|
||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"));
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
guiWidth = (width - xSize) / 2;
|
||||
guiHeight = (height - ySize) / 2;
|
||||
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
||||
int displayInt;
|
||||
|
||||
displayInt = tileEntity.getScaledEnergyLevel(52);
|
||||
drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 36, displayInt, 4);
|
||||
|
||||
if(tileEntity.getScaledFluidLevel(58) > 0)
|
||||
{
|
||||
displayGauge(26, 14, tileEntity.getScaledFluidLevel(58), tileEntity.fluidTank.getFluid(), null);
|
||||
}
|
||||
|
||||
if(tileEntity.getScaledGasLevel(58) > 0)
|
||||
{
|
||||
displayGauge(134, 14, tileEntity.getScaledGasLevel(58), null, tileEntity.gasTank);
|
||||
}
|
||||
}
|
||||
|
||||
public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, GasStack gas)
|
||||
{
|
||||
if(fluid == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int start = 0;
|
||||
|
||||
while(true)
|
||||
{
|
||||
int renderRemaining = 0;
|
||||
|
||||
if(scale > 16)
|
||||
{
|
||||
renderRemaining = 16;
|
||||
scale -= 16;
|
||||
}
|
||||
else {
|
||||
renderRemaining = scale;
|
||||
scale = 0;
|
||||
}
|
||||
|
||||
mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture());
|
||||
|
||||
if(fluid != null)
|
||||
{
|
||||
drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining));
|
||||
}
|
||||
else if(gas != null)
|
||||
{
|
||||
drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, gas.getGas().getIcon(), 16, 16 - (16 - renderRemaining));
|
||||
}
|
||||
|
||||
start+=16;
|
||||
|
||||
if(renderRemaining == 0 || scale == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"));
|
||||
drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, 40, 16, 60);
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@ import mekanism.common.inventory.container.ContainerRobitInventory;
|
|||
import mekanism.common.inventory.container.ContainerRobitMain;
|
||||
import mekanism.common.inventory.container.ContainerRobitRepair;
|
||||
import mekanism.common.inventory.container.ContainerRobitSmelting;
|
||||
import mekanism.common.inventory.container.ContainerRotaryCondensentrator;
|
||||
import mekanism.common.inventory.container.ContainerTeleporter;
|
||||
import mekanism.common.tileentity.TileEntityAdvancedElectricMachine;
|
||||
import mekanism.common.tileentity.TileEntityAdvancedFactory;
|
||||
|
@ -263,7 +264,7 @@ public class CommonProxy
|
|||
case 6:
|
||||
return new ContainerElectricMachine(player.inventory, (TileEntityElectricMachine)tileEntity);
|
||||
case 7:
|
||||
//return new ContainerRotaryCondensentrator(player.inventory, (TileEntityRotaryCondensentrator)tileEntity); TODO
|
||||
return new ContainerRotaryCondensentrator(player.inventory, (TileEntityRotaryCondensentrator)tileEntity);
|
||||
case 8:
|
||||
return new ContainerEnergyCube(player.inventory, (TileEntityEnergyCube)tileEntity);
|
||||
case 9:
|
||||
|
|
|
@ -7,6 +7,7 @@ import mekanism.api.IConfigurable;
|
|||
import mekanism.api.IUpgradeManagement;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.energy.IEnergizedItem;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.client.ClientProxy;
|
||||
import mekanism.common.IActiveState;
|
||||
import mekanism.common.IBoundingBlock;
|
||||
|
@ -77,22 +78,23 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
|
||||
/**
|
||||
* Block class for handling multiple machine block IDs.
|
||||
* 0: Enrichment Chamber
|
||||
* 1: Osmium Compressor
|
||||
* 2: Combiner
|
||||
* 3: Crusher
|
||||
* 4: Digital Miner
|
||||
* 5: Basic Factory
|
||||
* 6: Advanced Factory
|
||||
* 7: Elite Factory
|
||||
* 8: Metallurgic Infuser
|
||||
* 9: Purification Chamber
|
||||
* 10: Energized Smelter
|
||||
* 11: Teleporter
|
||||
* 12: Electric Pump
|
||||
* 13: Electric Chest
|
||||
* 14: Chargepad
|
||||
* 15: Logistical Sorter
|
||||
* 0:0: Enrichment Chamber
|
||||
* 0:1: Osmium Compressor
|
||||
* 0:2: Combiner
|
||||
* 0:3: Crusher
|
||||
* 0:4: Digital Miner
|
||||
* 0:5: Basic Factory
|
||||
* 0:6: Advanced Factory
|
||||
* 0:7: Elite Factory
|
||||
* 0:8: Metallurgic Infuser
|
||||
* 0:9: Purification Chamber
|
||||
* 0:10: Energized Smelter
|
||||
* 0:11: Teleporter
|
||||
* 0:12: Electric Pump
|
||||
* 0:13: Electric Chest
|
||||
* 0:14: Chargepad
|
||||
* 0:15: Logistical Sorter
|
||||
* 1:0: Rotary Condensentrator
|
||||
* @author AidanBrady
|
||||
*
|
||||
*/
|
||||
|
@ -223,7 +225,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
|
|||
{
|
||||
TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if(MekanismUtils.isActive(world, x, y, z) && !(tileEntity instanceof TileEntityChargepad) && !(tileEntity instanceof TileEntityLogisticalSorter) && !(tileEntity instanceof TileEntityCrusher))
|
||||
if(MekanismUtils.isActive(world, x, y, z) && ((IActiveState)tileEntity).renderUpdate())
|
||||
{
|
||||
float xRandom = (float)x + 0.5F;
|
||||
float yRandom = (float)y + 0.0F + random.nextFloat() * 6.0F / 16.0F;
|
||||
|
@ -920,6 +922,12 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
|
|||
factoryItem.setRecipeType(((TileEntityFactory)tileEntity).recipeType, itemStack);
|
||||
}
|
||||
|
||||
if(tileEntity instanceof TileEntityRotaryCondensentrator)
|
||||
{
|
||||
IGasItem gasItem = (IGasItem)itemStack.getItem();
|
||||
gasItem.setGas(((TileEntityRotaryCondensentrator)tileEntity).getGas(), itemStack);
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ public class ContainerAdvancedElectricMachine extends Container
|
|||
addSlotToContainer(new SlotOutput(tentity, 2, 116, 35));
|
||||
addSlotToContainer(new SlotDischarge(tentity, 3, 31, 35));
|
||||
addSlotToContainer(new SlotMachineUpgrade(tentity, 4, 180, 11));
|
||||
|
||||
int slotX;
|
||||
|
||||
for(slotX = 0; slotX < 3; ++slotX)
|
||||
|
@ -82,7 +83,7 @@ public class ContainerAdvancedElectricMachine extends Container
|
|||
}
|
||||
else if(ChargeUtils.canBeDischarged(slotStack))
|
||||
{
|
||||
if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3)
|
||||
if(slotID != 3)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 3, 4, false))
|
||||
{
|
||||
|
@ -98,7 +99,7 @@ public class ContainerAdvancedElectricMachine extends Container
|
|||
}
|
||||
else if(tileEntity.getFuelTicks(slotStack) > 0)
|
||||
{
|
||||
if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3)
|
||||
if(slotID != 1)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 1, 2, false))
|
||||
{
|
||||
|
@ -114,9 +115,9 @@ public class ContainerAdvancedElectricMachine extends Container
|
|||
}
|
||||
else if(RecipeHandler.getOutput(slotStack, false, tileEntity.getRecipes()) != null)
|
||||
{
|
||||
if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3)
|
||||
if(slotID != 0)
|
||||
{
|
||||
if (!mergeItemStack(slotStack, 0, 1, false))
|
||||
if(!mergeItemStack(slotStack, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -130,7 +131,7 @@ public class ContainerAdvancedElectricMachine extends Container
|
|||
}
|
||||
else if(slotStack.getItem() instanceof ItemMachineUpgrade)
|
||||
{
|
||||
if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3 && slotID != 4)
|
||||
if(slotID != 4)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 4, 5, false))
|
||||
{
|
||||
|
|
|
@ -75,8 +75,7 @@ public class ContainerElectricPump extends Container
|
|||
return null;
|
||||
}
|
||||
}
|
||||
else if(slotID == 2)
|
||||
{
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package mekanism.common.inventory.container;
|
||||
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge;
|
||||
import mekanism.common.inventory.slot.SlotOutput;
|
||||
import mekanism.common.inventory.slot.SlotStorageTank;
|
||||
import mekanism.common.tileentity.TileEntityRotaryCondensentrator;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
@ -17,10 +20,12 @@ public class ContainerRotaryCondensentrator extends Container
|
|||
public ContainerRotaryCondensentrator(InventoryPlayer inventory, TileEntityRotaryCondensentrator tentity)
|
||||
{
|
||||
tileEntity = tentity;
|
||||
addSlotToContainer(new SlotStorageTank(tentity, null, true, 0, 8, 8));
|
||||
addSlotToContainer(new SlotStorageTank(tentity, null, true, 1, 8, 40));
|
||||
addSlotToContainer(new Slot(tentity, 0, 146, 20));
|
||||
addSlotToContainer(new SlotOutput(tentity, 1, 146, 51));
|
||||
addSlotToContainer(new SlotStorageTank(tentity, null, true, 0, 5, 25));
|
||||
addSlotToContainer(new SlotStorageTank(tentity, null, true, 1, 5, 56));
|
||||
addSlotToContainer(new Slot(tentity, 2, 155, 25));
|
||||
addSlotToContainer(new SlotOutput(tentity, 3, 155, 56));
|
||||
addSlotToContainer(new SlotDischarge(tentity, 4, 155, 5));
|
||||
|
||||
int slotX;
|
||||
|
||||
for(slotX = 0; slotX < 3; ++slotX)
|
||||
|
@ -66,39 +71,81 @@ public class ContainerRotaryCondensentrator extends Container
|
|||
ItemStack slotStack = currentSlot.getStack();
|
||||
stack = slotStack.copy();
|
||||
|
||||
if(FluidContainerRegistry.isEmptyContainer(slotStack) || FluidContainerRegistry.isFilledContainer(slotStack))
|
||||
if(ChargeUtils.canBeDischarged(slotStack))
|
||||
{
|
||||
if(slotID != 0 && slotID != 1)
|
||||
if(slotID != 4)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 4, 5, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(FluidContainerRegistry.isEmptyContainer(slotStack) || FluidContainerRegistry.isFilledContainer(slotStack))
|
||||
{
|
||||
if(slotID != 2 && slotID != 3)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 0, 1, false))
|
||||
if(!mergeItemStack(slotStack, 2, 3, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true))
|
||||
if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(slotStack.getItem() instanceof IGasItem)
|
||||
{
|
||||
if(slotID != 0 && slotID != 1)
|
||||
{
|
||||
if(((IGasItem)slotStack.getItem()).canProvideGas(slotStack, tileEntity.gasTank != null ? tileEntity.gasTank.getGas() : null))
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(((IGasItem)slotStack.getItem()).canReceiveGas(slotStack, tileEntity.gasTank != null ? tileEntity.gasTank.getGas() : null))
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 1, 2, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(slotID >= 2 && slotID <= 8)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(slotID > 28)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 2, 28, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true))
|
||||
if(slotID >= 5 && slotID <= 31)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 32, inventorySlots.size(), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(slotID > 31)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 5, 31, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI
|
|||
public int MAX_GAS = 96000;
|
||||
|
||||
/** How fast this tank can transfer gas. */
|
||||
public int TRANSFER_RATE = 16;
|
||||
public static final int TRANSFER_RATE = 16;
|
||||
|
||||
public ItemBlockGasTank(int id, Block block)
|
||||
{
|
||||
|
@ -190,7 +190,7 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getRate()
|
||||
public int getRate(ItemStack itemstack)
|
||||
{
|
||||
return TRANSFER_RATE;
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI
|
|||
return 0;
|
||||
}
|
||||
|
||||
int toUse = Math.min(getMaxGas(itemstack)-getStored(itemstack), Math.min(getRate(), stack.amount));
|
||||
int toUse = Math.min(getMaxGas(itemstack)-getStored(itemstack), Math.min(getRate(itemstack), stack.amount));
|
||||
setGas(new GasStack(stack.getGas(), getStored(itemstack)+toUse), itemstack);
|
||||
|
||||
return toUse;
|
||||
|
@ -219,7 +219,7 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI
|
|||
|
||||
Gas type = getGas(itemstack).getGas();
|
||||
|
||||
int gasToUse = Math.min(getStored(itemstack), Math.min(getRate(), amount));
|
||||
int gasToUse = Math.min(getStored(itemstack), Math.min(getRate(itemstack), amount));
|
||||
setGas(new GasStack(type, getStored(itemstack)-gasToUse), itemstack);
|
||||
|
||||
return new GasStack(type, gasToUse);
|
||||
|
|
|
@ -12,6 +12,9 @@ import mekanism.api.IConfigurable;
|
|||
import mekanism.api.IUpgradeManagement;
|
||||
import mekanism.api.energy.EnergizedItemManager;
|
||||
import mekanism.api.energy.IEnergizedItem;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.common.IElectricChest;
|
||||
import mekanism.common.IFactory;
|
||||
import mekanism.common.IRedstoneControl;
|
||||
|
@ -32,6 +35,7 @@ import mekanism.common.tileentity.TileEntityElectricBlock;
|
|||
import mekanism.common.tileentity.TileEntityElectricChest;
|
||||
import mekanism.common.tileentity.TileEntityFactory;
|
||||
import mekanism.common.tileentity.TileEntityLogisticalSorter;
|
||||
import mekanism.common.tileentity.TileEntityRotaryCondensentrator;
|
||||
import mekanism.common.transporter.TransporterFilter;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.TransporterUtils;
|
||||
|
@ -78,7 +82,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
* @author AidanBrady
|
||||
*
|
||||
*/
|
||||
public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItemElectric, ISpecialElectricItem, IUpgradeManagement, IFactory, ISustainedInventory, ISustainedTank, IElectricChest, IEnergyContainerItem
|
||||
public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItemElectric, ISpecialElectricItem, IUpgradeManagement, IFactory, ISustainedInventory, ISustainedTank, IElectricChest, IEnergyContainerItem, IGasItem
|
||||
{
|
||||
public Block metaBlock;
|
||||
|
||||
|
@ -144,6 +148,13 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
|
|||
}
|
||||
}
|
||||
|
||||
GasStack gasStack = getGas(itemstack);
|
||||
|
||||
if(gasStack != null)
|
||||
{
|
||||
list.add(EnumColor.YELLOW + "Stored " + gasStack.getGas().getLocalizedName() + ": " + EnumColor.GREY + gasStack.amount);
|
||||
}
|
||||
|
||||
if(supportsUpgrades(itemstack))
|
||||
{
|
||||
list.add(EnumColor.PURPLE + "Energy: " + EnumColor.GREY + "x" + (getEnergyMultiplier(itemstack)+1));
|
||||
|
@ -297,6 +308,11 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
|
|||
((TileEntityElectricChest)tileEntity).password = getPassword(stack);
|
||||
}
|
||||
|
||||
if(tileEntity instanceof TileEntityRotaryCondensentrator)
|
||||
{
|
||||
((TileEntityRotaryCondensentrator)tileEntity).setGas(getGas(stack));
|
||||
}
|
||||
|
||||
((ISustainedInventory)tileEntity).setInventory(getInventory(stack));
|
||||
|
||||
tileEntity.electricityStored = getEnergy(stack);
|
||||
|
@ -403,6 +419,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
|
|||
public boolean onEntityItemUpdate(EntityItem entityItem)
|
||||
{
|
||||
onUpdate(entityItem.getEntityItem(), null, entityItem, 0, false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -479,9 +496,10 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
|
|||
{
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
int meta = ((ItemStack)data[0]).getItemDamage();
|
||||
MachineType type = MachineType.get((ItemStack)data[0]);
|
||||
|
||||
if(meta != 11 && meta != 12 && meta != 13 && meta != 14 && meta != 15)
|
||||
if(type != MachineType.TELEPORTER && type != MachineType.ELECTRIC_PUMP && type != MachineType.ELECTRIC_CHEST && type != MachineType.CHARGEPAD && type != MachineType.LOGISTICAL_SORTER &&
|
||||
type != MachineType.ROTARY_CONDENSENTRATOR)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -616,7 +634,8 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
|
|||
@Override
|
||||
public boolean hasTank(Object... data)
|
||||
{
|
||||
return data[0] instanceof ItemStack && ((ItemStack)data[0]).getItem() instanceof ISustainedTank && MachineType.get((ItemStack)data[0]) == MachineType.ELECTRIC_PUMP;
|
||||
return data[0] instanceof ItemStack && ((ItemStack)data[0]).getItem() instanceof ISustainedTank && (MachineType.get((ItemStack)data[0]) == MachineType.ELECTRIC_PUMP
|
||||
|| MachineType.get((ItemStack)data[0]) == MachineType.ROTARY_CONDENSENTRATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -895,4 +914,131 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
|
|||
{
|
||||
return IC2ItemManager.getManager(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxGas(Object... data)
|
||||
{
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
if(MachineType.get((ItemStack)data[0]) == MachineType.ROTARY_CONDENSENTRATOR)
|
||||
{
|
||||
return TileEntityRotaryCondensentrator.MAX_GAS;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRate(ItemStack itemstack)
|
||||
{
|
||||
return ItemBlockGasTank.TRANSFER_RATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addGas(ItemStack itemstack, GasStack stack)
|
||||
{
|
||||
if(MachineType.get(itemstack) != MachineType.ROTARY_CONDENSENTRATOR || (getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int toUse = Math.min(getMaxGas(itemstack)-getStored(itemstack), Math.min(getRate(itemstack), stack.amount));
|
||||
setGas(new GasStack(stack.getGas(), getStored(itemstack)+toUse), itemstack);
|
||||
|
||||
return toUse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasStack removeGas(ItemStack itemstack, int amount)
|
||||
{
|
||||
if(MachineType.get(itemstack) != MachineType.ROTARY_CONDENSENTRATOR || getGas(itemstack) == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Gas type = getGas(itemstack).getGas();
|
||||
|
||||
int gasToUse = Math.min(getStored(itemstack), Math.min(getRate(itemstack), 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, Gas type)
|
||||
{
|
||||
return MachineType.get(itemstack) == MachineType.ROTARY_CONDENSENTRATOR && (getGas(itemstack) == null || getGas(itemstack).getGas() == type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideGas(ItemStack itemstack, Gas type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasStack getGas(Object... data)
|
||||
{
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
ItemStack itemstack = (ItemStack)data[0];
|
||||
|
||||
if(MachineType.get(itemstack) != MachineType.ROTARY_CONDENSENTRATOR || itemstack.stackTagCompound == null)
|
||||
{
|
||||
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 null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGas(GasStack stack, Object... data)
|
||||
{
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
ItemStack itemstack = (ItemStack)data[0];
|
||||
|
||||
if(MachineType.get(itemstack) != MachineType.ROTARY_CONDENSENTRATOR)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(itemstack.stackTagCompound == null)
|
||||
{
|
||||
itemstack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if(stack == null || stack.amount == 0)
|
||||
{
|
||||
itemstack.setItemDamage(100);
|
||||
itemstack.stackTagCompound.removeTag("stored");
|
||||
}
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -241,7 +241,7 @@ public class TileEntityChargepad extends TileEntityElectricBlock implements IAct
|
|||
@Override
|
||||
public boolean renderUpdate()
|
||||
{
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -475,7 +475,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
|||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
if(fluidTank.getFluid() != null && fluidTank.getFluid().getFluid() != resource.getFluid() && from == ForgeDirection.getOrientation(1))
|
||||
if(fluidTank.getFluid() != null && fluidTank.getFluid().getFluid() == resource.getFluid() && from == ForgeDirection.getOrientation(1))
|
||||
{
|
||||
return drain(from, resource.amount, doDrain);
|
||||
}
|
||||
|
@ -509,6 +509,6 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
|||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return true;
|
||||
return from == ForgeDirection.getOrientation(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasS
|
|||
}
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote && gasStored != null && MekanismUtils.canFunction(this))
|
||||
if(!worldObj.isRemote && getGas() != null && MekanismUtils.canFunction(this))
|
||||
{
|
||||
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))));
|
||||
|
|
|
@ -1,13 +1,368 @@
|
|||
package mekanism.common.tileentity;
|
||||
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.GasTransmission;
|
||||
import mekanism.api.gas.IGasAcceptor;
|
||||
import mekanism.api.gas.IGasStorage;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.common.IActiveState;
|
||||
import mekanism.common.ISustainedTank;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock implements IActiveState, ISustainedTank, IFluidHandler, IGasStorage, IGasAcceptor, ITubeConnection
|
||||
{
|
||||
public GasStack gasTank;
|
||||
|
||||
public FluidTank fluidTank;
|
||||
|
||||
public static final int MAX_GAS = 10000;
|
||||
|
||||
public int updateDelay;
|
||||
|
||||
/** 0: gas -> fluid; 1: fluid -> gas */
|
||||
public int mode;
|
||||
|
||||
public int gasOutput = 16;
|
||||
|
||||
public boolean isActive;
|
||||
|
||||
public boolean clientActive;
|
||||
|
||||
public TileEntityRotaryCondensentrator()
|
||||
{
|
||||
super("RotaryCondensentrator", MachineType.ROTARY_CONDENSENTRATOR.baseEnergy);
|
||||
fluidTank = new FluidTank(10000);
|
||||
inventory = new ItemStack[5];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
if(worldObj.isRemote)
|
||||
{
|
||||
if(updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if(updateDelay > 0)
|
||||
{
|
||||
updateDelay--;
|
||||
|
||||
if(updateDelay == 0 && clientActive != isActive)
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())));
|
||||
}
|
||||
}
|
||||
|
||||
ChargeUtils.discharge(4, this);
|
||||
|
||||
if(mode == 1 && getGas() != null)
|
||||
{
|
||||
GasStack toSend = new GasStack(getGas().getGas(), Math.min(getGas().amount, gasOutput));
|
||||
setGas(new GasStack(getGas().getGas(), getGas().amount - GasTransmission.emitGasToNetwork(toSend, this, MekanismUtils.getLeft(facing))));
|
||||
|
||||
TileEntity tileEntity = Object3D.get(this).getFromSide(MekanismUtils.getLeft(facing)).getTileEntity(worldObj);
|
||||
|
||||
if(tileEntity instanceof IGasAcceptor)
|
||||
{
|
||||
if(((IGasAcceptor)tileEntity).canReceiveGas(MekanismUtils.getLeft(facing).getOpposite(), getGas().getGas()))
|
||||
{
|
||||
int added = ((IGasAcceptor)tileEntity).receiveGas(new GasStack(getGas().getGas(), Math.min(getGas().amount, gasOutput)));
|
||||
|
||||
setGas(new GasStack(getGas().getGas(), getGas().amount - added));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(ByteArrayDataInput dataStream)
|
||||
{
|
||||
super.handlePacketData(dataStream);
|
||||
|
||||
mode = dataStream.readInt();
|
||||
|
||||
if(dataStream.readInt() == 1)
|
||||
{
|
||||
fluidTank.setFluid(new FluidStack(dataStream.readInt(), dataStream.readInt()));
|
||||
}
|
||||
else {
|
||||
fluidTank.setFluid(null);
|
||||
}
|
||||
|
||||
if(dataStream.readBoolean())
|
||||
{
|
||||
gasTank = new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt());
|
||||
}
|
||||
else {
|
||||
gasTank = null;
|
||||
}
|
||||
|
||||
|
||||
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList getNetworkedData(ArrayList data)
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(mode);
|
||||
|
||||
if(fluidTank.getFluid() != null)
|
||||
{
|
||||
data.add(1);
|
||||
data.add(fluidTank.getFluid().fluidID);
|
||||
data.add(fluidTank.getFluid().amount);
|
||||
}
|
||||
else {
|
||||
data.add(0);
|
||||
}
|
||||
|
||||
if(gasTank != null)
|
||||
{
|
||||
data.add(true);
|
||||
data.add(gasTank.getGas().getID());
|
||||
data.add(gasTank.amount);
|
||||
}
|
||||
else {
|
||||
data.add(false);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
mode = nbtTags.getInteger("mode");
|
||||
gasTank = GasStack.readFromNBT(nbtTags.getCompoundTag("gasTank"));
|
||||
|
||||
if(nbtTags.hasKey("fluidTank"))
|
||||
{
|
||||
fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setInteger("mode", mode);
|
||||
|
||||
if(gasTank != null)
|
||||
{
|
||||
nbtTags.setCompoundTag("gasTank", gasTank.write(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
if(fluidTank.getFluid() != null)
|
||||
{
|
||||
nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
public int getScaledFluidLevel(int i)
|
||||
{
|
||||
return fluidTank.getFluid() != null ? fluidTank.getFluid().amount*i / 10000 : 0;
|
||||
}
|
||||
|
||||
public int getScaledGasLevel(int i)
|
||||
{
|
||||
return gasTank != null ? gasTank.amount*i / MAX_GAS : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active)
|
||||
{
|
||||
isActive = active;
|
||||
|
||||
if(clientActive != active && updateDelay == 0)
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())));
|
||||
|
||||
updateDelay = 10;
|
||||
clientActive = active;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive()
|
||||
{
|
||||
return isActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean lightUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTubeConnect(ForgeDirection side)
|
||||
{
|
||||
return side == MekanismUtils.getLeft(facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveGas(GasStack stack)
|
||||
{
|
||||
if(gasTank == null || (gasTank != null && gasTank.getGas() == stack.getGas()))
|
||||
{
|
||||
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 boolean canReceiveGas(ForgeDirection side, Gas type)
|
||||
{
|
||||
return mode == 0 && (getGas() == null || getGas().getGas() == type) && side == MekanismUtils.getLeft(facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasStack getGas(Object... data)
|
||||
{
|
||||
return gasTank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGas(GasStack stack, Object... data)
|
||||
{
|
||||
if(stack == null || stack.amount == 0)
|
||||
{
|
||||
gasTank = null;
|
||||
}
|
||||
else {
|
||||
gasTank = new GasStack(stack.getGas(), Math.max(Math.min(stack.amount, getMaxGas()), 0));
|
||||
}
|
||||
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxGas(Object... data)
|
||||
{
|
||||
return MAX_GAS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFluidStack(FluidStack fluidStack, Object... data)
|
||||
{
|
||||
fluidTank.setFluid(fluidStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getFluidStack(Object... data)
|
||||
{
|
||||
return fluidTank.getFluid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTank(Object... data)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
if(canFill(from, resource.getFluid()))
|
||||
{
|
||||
return fluidTank.fill(resource, doFill);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
if(fluidTank.getFluid() != null && fluidTank.getFluid().getFluid() == resource.getFluid())
|
||||
{
|
||||
return drain(from, resource.amount, doDrain);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return mode == 1 && from == MekanismUtils.getRight(facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return mode == 0 && from == MekanismUtils.getRight(facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||
{
|
||||
if(from == MekanismUtils.getRight(facing))
|
||||
{
|
||||
return new FluidTankInfo[] {fluidTank.getInfo()};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
if(canDrain(from, null))
|
||||
{
|
||||
return fluidTank.drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 5.3 KiB |
Loading…
Add table
Reference in a new issue