mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-24 22:04:49 +00:00
Energy Cubes and Gas Tanks now have configurable item inputs and gas/energy outputs, fixed Portable Tank item output
This commit is contained in:
1 parent
0a135a6936
commit
a22b33a629
24 files changed
+287
-118
No files matched your search
@@ -5,24 +5,27 @@ import java.util.List;
|
||||
import mekanism.api.energy.IStrictEnergyStorage;
|
||||
import mekanism.api.util.ListUtils;
|
||||
import mekanism.client.gui.element.GuiEnergyGauge;
|
||||
import mekanism.client.gui.element.GuiEnergyInfo;
|
||||
import mekanism.client.gui.element.GuiRedstoneControl;
|
||||
import mekanism.client.gui.element.GuiSlot;
|
||||
import mekanism.client.gui.element.GuiEnergyGauge.IEnergyInfoHandler;
|
||||
import mekanism.client.gui.element.GuiEnergyInfo;
|
||||
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;
|
||||
import mekanism.client.gui.element.GuiRedstoneControl;
|
||||
import mekanism.client.gui.element.GuiSideConfigurationTab;
|
||||
import mekanism.client.gui.element.GuiSlot;
|
||||
import mekanism.client.gui.element.GuiSlot.SlotOverlay;
|
||||
import mekanism.client.gui.element.GuiSlot.SlotType;
|
||||
import mekanism.client.gui.element.GuiTransporterConfigTab;
|
||||
import mekanism.common.inventory.container.ContainerEnergyCube;
|
||||
import mekanism.common.tile.TileEntityEnergyCube;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiEnergyCube extends GuiMekanism
|
||||
{
|
||||
@@ -33,6 +36,8 @@ public class GuiEnergyCube extends GuiMekanism
|
||||
super(tentity, new ContainerEnergyCube(inventory, tentity));
|
||||
tileEntity = tentity;
|
||||
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png")));
|
||||
guiElements.add(new GuiSideConfigurationTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png")));
|
||||
guiElements.add(new GuiTransporterConfigTab(this, 34, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png")));
|
||||
guiElements.add(new GuiEnergyGauge(new IEnergyInfoHandler()
|
||||
{
|
||||
@Override
|
||||
@@ -51,8 +56,8 @@ public class GuiEnergyCube extends GuiMekanism
|
||||
LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t");
|
||||
}
|
||||
}, this, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png")));
|
||||
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"), 16, 34).with(SlotOverlay.MINUS));
|
||||
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"), 142, 34).with(SlotOverlay.PLUS));
|
||||
guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"), 16, 34).with(SlotOverlay.MINUS));
|
||||
guiElements.add(new GuiSlot(SlotType.OUTPUT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"), 142, 34).with(SlotOverlay.PLUS));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,6 +4,11 @@ import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.client.gui.element.GuiRedstoneControl;
|
||||
import mekanism.client.gui.element.GuiSideConfigurationTab;
|
||||
import mekanism.client.gui.element.GuiSlot;
|
||||
import mekanism.client.gui.element.GuiSlot.SlotOverlay;
|
||||
import mekanism.client.gui.element.GuiSlot.SlotType;
|
||||
import mekanism.client.gui.element.GuiTransporterConfigTab;
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.inventory.container.ContainerGasTank;
|
||||
@@ -29,6 +34,10 @@ public class GuiGasTank extends GuiMekanism
|
||||
super(tentity, new ContainerGasTank(inventory, tentity));
|
||||
tileEntity = tentity;
|
||||
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png")));
|
||||
guiElements.add(new GuiSideConfigurationTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png")));
|
||||
guiElements.add(new GuiTransporterConfigTab(this, 34, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png")));
|
||||
guiElements.add(new GuiSlot(SlotType.OUTPUT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png"), 7, 7).with(SlotOverlay.PLUS));
|
||||
guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png"), 7, 39).with(SlotOverlay.MINUS));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,8 +63,6 @@ public class GuiGasTank extends GuiMekanism
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
|
||||
{
|
||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png"));
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
@@ -70,6 +77,8 @@ public class GuiGasTank extends GuiMekanism
|
||||
int scale = (int)(((double)tileEntity.gasTank.getStored() / tileEntity.MAX_GAS) * 72);
|
||||
drawTexturedModalRect(guiWidth + 65, guiHeight + 17, 176, 0, scale, 10);
|
||||
}
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,13 +9,11 @@ import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.client.gui.element.GuiConfigTypeTab;
|
||||
import mekanism.client.gui.element.GuiElement;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.base.ISideConfiguration;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.inventory.container.ContainerNull;
|
||||
import mekanism.common.network.PacketConfigurationUpdate.ConfigurationPacket;
|
||||
import mekanism.common.network.PacketConfigurationUpdate.ConfigurationUpdateMessage;
|
||||
@@ -220,7 +218,7 @@ public class GuiSideConfiguration extends GuiMekanism
|
||||
{
|
||||
if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20)
|
||||
{
|
||||
int guiId = MachineType.get(tile.getBlockType(), tile.getBlockMetadata()).guiId;
|
||||
int guiId = Mekanism.proxy.getGuiId(tile.getBlockType(), tile.getBlockMetadata());
|
||||
SoundHandler.playSound("gui.button.press");
|
||||
Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tile), 0, guiId));
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ public class GuiTransporterConfig extends GuiMekanism
|
||||
{
|
||||
if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20)
|
||||
{
|
||||
int guiId = MachineType.get(tile.getBlockType(), tile.getBlockMetadata()).guiId;
|
||||
int guiId = Mekanism.proxy.getGuiId(tile.getBlockType(), tile.getBlockMetadata());
|
||||
SoundHandler.playSound("gui.button.press");
|
||||
Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tile), 0, guiId));
|
||||
}
|
||||
|
||||
@@ -80,5 +80,7 @@ public class RenderEnergyCube extends TileEntitySpecialRenderer
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
MekanismRenderer.machineRenderer.renderAModelAt(tileEntity, x, y, z, partialTick);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package mekanism.client.render.tileentity;
|
||||
|
||||
import mekanism.client.model.ModelGasTank;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.common.tile.TileEntityGasTank;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -40,5 +40,7 @@ public class RenderGasTank extends TileEntitySpecialRenderer
|
||||
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||
model.render(0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
MekanismRenderer.machineRenderer.renderAModelAt(tileEntity, x, y, z, partialTick);
|
||||
}
|
||||
}
|
||||
@@ -107,6 +107,7 @@ import mekanism.common.tile.TileEntitySolarEvaporationController;
|
||||
import mekanism.common.tile.TileEntitySolarNeutronActivator;
|
||||
import mekanism.common.tile.TileEntityStructuralGlass;
|
||||
import mekanism.common.tile.TileEntityTeleporter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -639,6 +640,24 @@ public class CommonProxy implements IGuiProvider
|
||||
{
|
||||
return context.getServerHandler().playerEntity;
|
||||
}
|
||||
|
||||
public int getGuiId(Block block, int metadata)
|
||||
{
|
||||
if(MachineType.get(block, metadata) != null)
|
||||
{
|
||||
return MachineType.get(block, metadata).guiId;
|
||||
}
|
||||
else if(block == MekanismBlocks.GasTank)
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
else if(block == MekanismBlocks.EnergyCube)
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void renderLaser(World world, Pos3D from, Pos3D to, ForgeDirection direction, double energy) {}
|
||||
}
|
||||
@@ -18,11 +18,11 @@ public class SideData
|
||||
/** The name of this SideData */
|
||||
public String name;
|
||||
|
||||
/** Int[] of available side slots, can be used for items, gases, or items */
|
||||
/** int[] of available side slots, can be used for items, gases, or items */
|
||||
public int[] availableSlots;
|
||||
|
||||
/** EnergyState representing this SideData */
|
||||
public EnergyState energyState;
|
||||
/** IOState representing this SideData */
|
||||
public IOState ioState;
|
||||
|
||||
public SideData(String n, EnumColor colour, int[] slots)
|
||||
{
|
||||
@@ -31,11 +31,11 @@ public class SideData
|
||||
availableSlots = slots;
|
||||
}
|
||||
|
||||
public SideData(String n, EnumColor colour, EnergyState state)
|
||||
public SideData(String n, EnumColor colour, IOState state)
|
||||
{
|
||||
name = n;
|
||||
color = colour;
|
||||
energyState = state;
|
||||
ioState = state;
|
||||
}
|
||||
|
||||
public String localize()
|
||||
@@ -87,7 +87,7 @@ public class SideData
|
||||
return (GasTank)tanks[0];
|
||||
}
|
||||
|
||||
public static enum EnergyState
|
||||
public static enum IOState
|
||||
{
|
||||
INPUT,
|
||||
OUTPUT,
|
||||
|
||||
@@ -1,12 +1,23 @@
|
||||
package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.gas.*;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.GasTank;
|
||||
import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.*;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IFactory.RecipeType;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
@@ -26,8 +37,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedMachineRecipe<RECIPE>> extends TileEntityBasicMachine<AdvancedMachineInput, ItemStackOutput, RECIPE> implements IGasHandler, ITubeConnection
|
||||
{
|
||||
/** How much secondary energy (fuel) this machine uses per tick, not including upgrades. */
|
||||
@@ -68,7 +77,7 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Energy", EnumColor.DARK_GREEN, new int[] {3}));
|
||||
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 4, 0, 3});
|
||||
configComponent.setInputEnergyConfig();
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
gasTank = new GasTank(MAX_GAS);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public class TileEntityAdvancedFactory extends TileEntityFactory
|
||||
configComponent.fillConfig(TransmissionType.GAS, 1);
|
||||
configComponent.setCanEject(TransmissionType.GAS, false);
|
||||
|
||||
configComponent.setInputEnergyConfig();
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
|
||||
@@ -33,7 +33,7 @@ public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Output", EnumColor.DARK_BLUE, new int[] {2, 4}));
|
||||
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 0, 0, 3});
|
||||
configComponent.setInputEnergyConfig();
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
inventory = new ItemStack[5];
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
|
||||
configComponent.setConfig(TransmissionType.GAS, new byte[] {0, 0, 0, 0, 1, 0});
|
||||
configComponent.setCanEject(TransmissionType.GAS, false);
|
||||
|
||||
configComponent.setInputEnergyConfig();
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
inventory = new ItemStack[4];
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecip
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Output", EnumColor.DARK_BLUE, new int[] {2}));
|
||||
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 0, 0, 3});
|
||||
configComponent.setInputEnergyConfig();
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
inventory = new ItemStack[4];
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public class TileEntityEliteFactory extends TileEntityFactory
|
||||
configComponent.fillConfig(TransmissionType.GAS, 1);
|
||||
configComponent.setCanEject(TransmissionType.GAS, false);
|
||||
|
||||
configComponent.setInputEnergyConfig();
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
|
||||
@@ -1,15 +1,27 @@
|
||||
package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.Tier.EnergyCubeTier;
|
||||
import mekanism.common.base.IEjector;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.ISideConfiguration;
|
||||
import mekanism.common.integration.IComputerIntegration;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.tile.component.TileComponentConfig;
|
||||
import mekanism.common.tile.component.TileComponentEjector;
|
||||
import mekanism.common.util.CableUtils;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -17,10 +29,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class TileEntityEnergyCube extends TileEntityElectricBlock implements IComputerIntegration, IRedstoneControl
|
||||
public class TileEntityEnergyCube extends TileEntityElectricBlock implements IComputerIntegration, IRedstoneControl, ISideConfiguration
|
||||
{
|
||||
/** This Energy Cube's tier. */
|
||||
public EnergyCubeTier tier = EnergyCubeTier.BASIC;
|
||||
@@ -32,6 +41,9 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo
|
||||
public RedstoneControl controlType;
|
||||
|
||||
public int prevScale;
|
||||
|
||||
public TileComponentEjector ejectorComponent;
|
||||
public TileComponentConfig configComponent;
|
||||
|
||||
/**
|
||||
* A block used to store and transfer electricity.
|
||||
@@ -39,9 +51,22 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo
|
||||
public TileEntityEnergyCube()
|
||||
{
|
||||
super("EnergyCube", 0);
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY);
|
||||
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Charge", EnumColor.DARK_BLUE, new int[] {0}));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Discharge", EnumColor.DARK_RED, new int[] {1}));
|
||||
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {0, 0, 0, 0, 2, 1});
|
||||
configComponent.setCanEject(TransmissionType.ITEM, false);
|
||||
configComponent.setIOConfig(TransmissionType.ENERGY);
|
||||
configComponent.setEjecting(TransmissionType.ENERGY, true);
|
||||
|
||||
inventory = new ItemStack[2];
|
||||
controlType = RedstoneControl.DISABLED;
|
||||
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -100,16 +125,13 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo
|
||||
@Override
|
||||
public EnumSet<ForgeDirection> getConsumingSides()
|
||||
{
|
||||
EnumSet set = EnumSet.allOf(ForgeDirection.class);
|
||||
set.removeAll(getOutputtingSides());
|
||||
|
||||
return set;
|
||||
return configComponent.getSidesForData(TransmissionType.ENERGY, facing, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<ForgeDirection> getOutputtingSides()
|
||||
{
|
||||
return EnumSet.of(ForgeDirection.getOrientation(facing));
|
||||
return configComponent.getSidesForData(TransmissionType.ENERGY, facing, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -127,7 +149,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side)
|
||||
{
|
||||
return side <= 1 ? new int[] {0} : new int[] {1};
|
||||
return configComponent.getOutput(TransmissionType.ITEM, side, facing).availableSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -255,4 +277,22 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEjector getEjector()
|
||||
{
|
||||
return ejectorComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentConfig getConfig()
|
||||
{
|
||||
return configComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrientation()
|
||||
{
|
||||
return facing;
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
configComponent.fillConfig(TransmissionType.GAS, 1);
|
||||
configComponent.setCanEject(TransmissionType.GAS, false);
|
||||
|
||||
configComponent.setInputEnergyConfig();
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
|
||||
@@ -1,23 +1,38 @@
|
||||
package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.gas.*;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.GasTank;
|
||||
import mekanism.api.gas.GasTransmission;
|
||||
import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.base.IEjector;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.ISideConfiguration;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.tile.component.TileComponentConfig;
|
||||
import mekanism.common.tile.component.TileComponentEjector;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TileEntityGasTank extends TileEntityContainerBlock implements IGasHandler, ITubeConnection, IRedstoneControl
|
||||
public class TileEntityGasTank extends TileEntityContainerBlock implements IGasHandler, ITubeConnection, IRedstoneControl, ISideConfiguration
|
||||
{
|
||||
public enum GasMode
|
||||
{
|
||||
@@ -40,14 +55,30 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
|
||||
/** This machine's current RedstoneControl type. */
|
||||
public RedstoneControl controlType;
|
||||
|
||||
public TileComponentEjector ejectorComponent;
|
||||
public TileComponentConfig configComponent;
|
||||
|
||||
public TileEntityGasTank()
|
||||
{
|
||||
super("GasTank");
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.GAS);
|
||||
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Fill", EnumColor.DARK_BLUE, new int[] {0}));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Empty", EnumColor.DARK_RED, new int[] {1}));
|
||||
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 0, 0, 0});
|
||||
configComponent.setCanEject(TransmissionType.ITEM, false);
|
||||
configComponent.setIOConfig(TransmissionType.GAS);
|
||||
configComponent.setEjecting(TransmissionType.GAS, true);
|
||||
|
||||
inventory = new ItemStack[2];
|
||||
dumping = GasMode.IDLE;
|
||||
controlType = RedstoneControl.DISABLED;
|
||||
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,16 +97,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
if(!worldObj.isRemote && gasTank.getGas() != null && MekanismUtils.canFunction(this) && dumping != GasMode.DUMPING)
|
||||
{
|
||||
GasStack toSend = new GasStack(gasTank.getGas().getGas(), Math.min(gasTank.getStored(), output));
|
||||
|
||||
TileEntity tileEntity = Coord4D.get(this).getFromSide(ForgeDirection.getOrientation(facing)).getTileEntity(worldObj);
|
||||
|
||||
if(tileEntity instanceof IGasHandler)
|
||||
{
|
||||
if(((IGasHandler)tileEntity).canReceiveGas(ForgeDirection.getOrientation(facing).getOpposite(), gasTank.getGas().getGas()))
|
||||
{
|
||||
gasTank.draw(((IGasHandler)tileEntity).receiveGas(ForgeDirection.getOrientation(facing).getOpposite(), toSend, true), true);
|
||||
}
|
||||
}
|
||||
gasTank.draw(GasTransmission.emit(new ArrayList(configComponent.getSidesForData(TransmissionType.GAS, facing, 2).clone()), toSend, this), true);
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote && dumping == GasMode.DUMPING)
|
||||
@@ -134,7 +156,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side)
|
||||
{
|
||||
return side == 1 ? new int[]{0} : new int[]{1};
|
||||
return configComponent.getOutput(TransmissionType.ITEM, side, facing).availableSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -170,7 +192,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
@Override
|
||||
public boolean canReceiveGas(ForgeDirection side, Gas type)
|
||||
{
|
||||
if(side != ForgeDirection.getOrientation(facing))
|
||||
if(configComponent.getSidesForData(TransmissionType.GAS, facing, 1).contains(side))
|
||||
{
|
||||
return gasTank.canReceive(type);
|
||||
}
|
||||
@@ -292,4 +314,22 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEjector getEjector()
|
||||
{
|
||||
return ejectorComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentConfig getConfig()
|
||||
{
|
||||
return configComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrientation()
|
||||
{
|
||||
return facing;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
@@ -9,7 +13,12 @@ import mekanism.api.Range4D;
|
||||
import mekanism.api.infuse.InfuseObject;
|
||||
import mekanism.api.infuse.InfuseRegistry;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.*;
|
||||
import mekanism.common.InfuseStorage;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IEjector;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.ISideConfiguration;
|
||||
@@ -31,9 +40,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock implements IComputerIntegration, ISideConfiguration, IUpgradeTile, IRedstoneControl
|
||||
{
|
||||
/** The maxiumum amount of infuse this machine can store. */
|
||||
@@ -87,7 +93,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("Energy", EnumColor.DARK_GREEN, new int[] {4}));
|
||||
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {1, 0, 0, 4, 2, 3});
|
||||
configComponent.setInputEnergyConfig();
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
inventory = new ItemStack[5];
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, Pres
|
||||
configComponent.addOutput(TransmissionType.GAS, new SideData("Output", EnumColor.DARK_BLUE, new int[] {2}));
|
||||
configComponent.setConfig(TransmissionType.GAS, new byte[] {0, 0, 0, 0, 1, 2});
|
||||
|
||||
configComponent.setInputEnergyConfig();
|
||||
configComponent.setInputConfig(TransmissionType.ENERGY);
|
||||
|
||||
inventory = new ItemStack[4];
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.IConfigurable;
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.base.IActiveState;
|
||||
import mekanism.common.base.IFluidContainerManager;
|
||||
@@ -21,9 +23,14 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class TileEntityPortableTank extends TileEntityContainerBlock implements IActiveState, IConfigurable, IFluidHandler, ISustainedTank, IFluidContainerManager, ITankManager
|
||||
{
|
||||
@@ -152,13 +159,13 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements
|
||||
{
|
||||
if(inventory[0].getItem() instanceof IFluidContainerItem)
|
||||
{
|
||||
if(editMode == ContainerEditMode.FILL)
|
||||
if(editMode == ContainerEditMode.FILL && fluidTank.getFluidAmount() > 0)
|
||||
{
|
||||
int prev = fluidTank.getFluidAmount();
|
||||
|
||||
fluidTank.drain(FluidContainerUtils.insertFluid(fluidTank, inventory[0]), true);
|
||||
|
||||
if(prev == fluidTank.getFluidAmount() || fluidTank.getFluidAmount() == 0)
|
||||
if(prev == fluidTank.getFluidAmount())
|
||||
{
|
||||
if(inventory[1] == null)
|
||||
{
|
||||
@@ -295,17 +302,7 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements
|
||||
@Override
|
||||
public boolean canExtractItem(int slotID, ItemStack itemstack, int side)
|
||||
{
|
||||
if(slotID == 1)
|
||||
{
|
||||
return (itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) == null);
|
||||
}
|
||||
else if(slotID == 0)
|
||||
{
|
||||
return (itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null &&
|
||||
((IGasItem)itemstack.getItem()).getGas(itemstack).amount == ((IGasItem)itemstack.getItem()).getMaxGas(itemstack));
|
||||
}
|
||||
|
||||
return false;
|
||||
return slotID == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -313,7 +310,23 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements
|
||||
{
|
||||
if(slotID == 0)
|
||||
{
|
||||
return FluidContainerRegistry.isContainer(itemstack);
|
||||
if(itemstack.getItem() instanceof IFluidContainerItem)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(FluidContainerRegistry.isFilledContainer(itemstack))
|
||||
{
|
||||
FluidStack stack = FluidContainerRegistry.getFluidForFilledItem(itemstack);
|
||||
|
||||
if(fluidTank.getFluid() == null || fluidTank.getFluid().isFluidEqual(stack))
|
||||
{
|
||||
return editMode == ContainerEditMode.EMPTY || editMode == ContainerEditMode.BOTH;
|
||||
}
|
||||
}
|
||||
else if(FluidContainerRegistry.isEmptyContainer(itemstack))
|
||||
{
|
||||
return editMode == ContainerEditMode.FILL || editMode == ContainerEditMode.BOTH;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.Map;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.SideData.EnergyState;
|
||||
import mekanism.common.SideData.IOState;
|
||||
import mekanism.common.base.ITileComponent;
|
||||
import mekanism.common.tile.TileEntityContainerBlock;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
@@ -93,22 +93,22 @@ public class TileComponentConfig implements ITileComponent
|
||||
setConfig(type, new byte[] {sideData, sideData, sideData, sideData, sideData, sideData});
|
||||
}
|
||||
|
||||
public void setIOEnergyConfig()
|
||||
public void setIOConfig(TransmissionType type)
|
||||
{
|
||||
addOutput(TransmissionType.ENERGY, new SideData("None", EnumColor.GREY, EnergyState.OFF));
|
||||
addOutput(TransmissionType.ENERGY, new SideData("Input", EnumColor.DARK_GREEN, EnergyState.INPUT));
|
||||
addOutput(TransmissionType.ENERGY, new SideData("Output", EnumColor.DARK_RED, EnergyState.OUTPUT));
|
||||
addOutput(type, new SideData("None", EnumColor.GREY, IOState.OFF));
|
||||
addOutput(type, new SideData("Input", EnumColor.DARK_GREEN, IOState.INPUT));
|
||||
addOutput(type, new SideData("Output", EnumColor.DARK_RED, IOState.OUTPUT));
|
||||
|
||||
setConfig(TransmissionType.ENERGY, new byte[] {1, 1, 2, 1, 1, 1});
|
||||
setConfig(type, new byte[] {1, 1, 2, 1, 1, 1});
|
||||
}
|
||||
|
||||
public void setInputEnergyConfig()
|
||||
public void setInputConfig(TransmissionType type)
|
||||
{
|
||||
addOutput(TransmissionType.ENERGY, new SideData("None", EnumColor.GREY, EnergyState.OFF));
|
||||
addOutput(TransmissionType.ENERGY, new SideData("Input", EnumColor.DARK_GREEN, EnergyState.INPUT));
|
||||
addOutput(type, new SideData("None", EnumColor.GREY, IOState.OFF));
|
||||
addOutput(type, new SideData("Input", EnumColor.DARK_GREEN, IOState.INPUT));
|
||||
|
||||
setConfig(TransmissionType.ENERGY, new byte[] {1, 1, 1, 1, 1, 1});
|
||||
setCanEject(TransmissionType.ENERGY, false);
|
||||
fillConfig(type, 1);
|
||||
setCanEject(type, false);
|
||||
}
|
||||
|
||||
public void setConfig(TransmissionType type, byte[] config)
|
||||
@@ -156,29 +156,10 @@ public class TileComponentConfig implements ITileComponent
|
||||
{
|
||||
for(TransmissionType type : transmissions)
|
||||
{
|
||||
try {//TODO remove soon
|
||||
if(nbtTags.getByteArray("config" + type.ordinal()).length > 0)
|
||||
{
|
||||
sideConfigs.put(type.ordinal(), nbtTags.getByteArray("config" + type.ordinal()));
|
||||
ejecting.put(type.ordinal(), nbtTags.getBoolean("ejecting" + type.ordinal()));
|
||||
}
|
||||
} catch(Exception e) {
|
||||
try {
|
||||
byte[] bytes = new byte[6];
|
||||
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
bytes[i] = nbtTags.getByte("config"+i);
|
||||
|
||||
if(bytes[i] > 0)
|
||||
{
|
||||
bytes[i]--;
|
||||
}
|
||||
}
|
||||
|
||||
sideConfigs.put(TransmissionType.ITEM.ordinal(), bytes);
|
||||
ejecting.put(TransmissionType.ITEM.ordinal(), nbtTags.getBoolean("ejecting"));
|
||||
} catch(Exception e1) {}
|
||||
if(nbtTags.getByteArray("config" + type.ordinal()).length > 0)
|
||||
{
|
||||
sideConfigs.put(type.ordinal(), nbtTags.getByteArray("config" + type.ordinal()));
|
||||
ejecting.put(type.ordinal(), nbtTags.getBoolean("ejecting" + type.ordinal()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,12 @@ package mekanism.common.util;
|
||||
|
||||
import ic2.api.item.ElectricItem;
|
||||
import ic2.api.item.IElectricItem;
|
||||
import ic2.api.item.IElectricItemManager;
|
||||
import ic2.api.item.ISpecialElectricItem;
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.api.energy.EnergizedItemManager;
|
||||
import mekanism.api.energy.IEnergizedItem;
|
||||
import mekanism.api.energy.IStrictEnergyStorage;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.tile.TileEntityContainerBlock;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -130,6 +131,46 @@ public final class ChargeUtils
|
||||
*/
|
||||
public static boolean canBeOutputted(ItemStack itemstack, boolean chargeSlot)
|
||||
{
|
||||
return true; //this is too much of a hassle to manage
|
||||
if(itemstack.getItem() instanceof IEnergizedItem)
|
||||
{
|
||||
IEnergizedItem energized = (IEnergizedItem)itemstack.getItem();
|
||||
|
||||
if(chargeSlot)
|
||||
{
|
||||
return energized.getEnergy(itemstack) == energized.getMaxEnergy(itemstack);
|
||||
}
|
||||
else {
|
||||
return energized.getEnergy(itemstack) == 0;
|
||||
}
|
||||
}
|
||||
else if(itemstack.getItem() instanceof IEnergyContainerItem)
|
||||
{
|
||||
IEnergyContainerItem energyContainer = (IEnergyContainerItem)itemstack.getItem();
|
||||
|
||||
if(chargeSlot)
|
||||
{
|
||||
return energyContainer.receiveEnergy(itemstack, 1, true) > 0;
|
||||
}
|
||||
else {
|
||||
return energyContainer.extractEnergy(itemstack, 1, true) > 0;
|
||||
}
|
||||
}
|
||||
else if(itemstack.getItem() instanceof ISpecialElectricItem)
|
||||
{
|
||||
IElectricItemManager manager = ((ISpecialElectricItem)itemstack.getItem()).getManager(itemstack);
|
||||
|
||||
if(manager != null)
|
||||
{
|
||||
if(chargeSlot)
|
||||
{
|
||||
return manager.charge(itemstack, 1, 3, true, true) > 0;
|
||||
}
|
||||
else {
|
||||
return manager.discharge(itemstack, 1, 3, true, true, true) > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user