Developed and implemented the foundation for Item/Gas/Energy/Fluid/Heat dynamic side configuration.

As of now, only items are supported, and the actual config GUI has not been changed. Only gameplay difference is three new configurator modes.
This commit is contained in:
Aidan C. Brady 2015-03-07 19:09:23 -05:00
parent 35518ad01f
commit d4d7e88c4e
41 changed files with 563 additions and 453 deletions

View file

@ -1,22 +1,24 @@
package mekanism.api.transmitters; package mekanism.api.transmitters;
import mekanism.api.gas.IGasTransmitter; import mekanism.api.gas.IGasTransmitter;
import mekanism.common.util.MekanismUtils;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
public enum TransmissionType public enum TransmissionType
{ {
ENERGY("EnergyNetwork"), ENERGY("EnergyNetwork", "Energy"),
FLUID("FluidNetwork"), FLUID("FluidNetwork", "Fluids"),
GAS("GasNetwork"), GAS("GasNetwork", "Gases"),
ITEM("InventoryNetwork"), ITEM("InventoryNetwork", "Items"),
HEAT("HeatNetwork"); HEAT("HeatNetwork", "Heat");
private String name; private String name;
private String transmission;
private TransmissionType(String n) private TransmissionType(String n, String t)
{ {
name = n; name = n;
transmission = t;
} }
public String getName() public String getName()
@ -24,6 +26,16 @@ public enum TransmissionType
return name; return name;
} }
public String getTransmission()
{
return transmission;
}
public String localize()
{
return MekanismUtils.localize("transmission." + getTransmission());
}
public static boolean checkTransmissionType(TileEntity sideTile, TransmissionType type) public static boolean checkTransmissionType(TileEntity sideTile, TransmissionType type)
{ {
return checkTransmissionType(sideTile, type, null); return checkTransmissionType(sideTile, type, null);

View file

@ -104,7 +104,7 @@ import mekanism.common.Mekanism;
import mekanism.common.MekanismBlocks; import mekanism.common.MekanismBlocks;
import mekanism.common.MekanismItems; import mekanism.common.MekanismItems;
import mekanism.common.base.IElectricChest; import mekanism.common.base.IElectricChest;
import mekanism.common.base.IInvConfiguration; import mekanism.common.base.ISideConfiguration;
import mekanism.common.base.IUpgradeTile; import mekanism.common.base.IUpgradeTile;
import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.entity.EntityBabySkeleton; import mekanism.common.entity.EntityBabySkeleton;
@ -404,7 +404,7 @@ public class ClientProxy extends CommonProxy
case 8: case 8:
return new GuiEnergyCube(player.inventory, (TileEntityEnergyCube)tileEntity); return new GuiEnergyCube(player.inventory, (TileEntityEnergyCube)tileEntity);
case 9: case 9:
return new GuiConfiguration(player, (IInvConfiguration)tileEntity); return new GuiConfiguration(player, (ISideConfiguration)tileEntity);
case 10: case 10:
return new GuiGasTank(player.inventory, (TileEntityGasTank)tileEntity); return new GuiGasTank(player.inventory, (TileEntityGasTank)tileEntity);
case 11: case 11:

View file

@ -7,6 +7,7 @@ import mekanism.common.Mekanism;
import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.item.ItemBlockMachine; import mekanism.common.item.ItemBlockMachine;
import mekanism.common.item.ItemConfigurator; import mekanism.common.item.ItemConfigurator;
import mekanism.common.item.ItemConfigurator.ConfiguratorMode;
import mekanism.common.item.ItemElectricBow; import mekanism.common.item.ItemElectricBow;
import mekanism.common.item.ItemJetpack; import mekanism.common.item.ItemJetpack;
import mekanism.common.item.ItemJetpack.JetpackMode; import mekanism.common.item.ItemJetpack.JetpackMode;
@ -22,13 +23,15 @@ import mekanism.common.network.PacketScubaTankData.ScubaTankPacket;
import mekanism.common.network.PacketWalkieTalkieState.WalkieTalkieStateMessage; import mekanism.common.network.PacketWalkieTalkieState.WalkieTalkieStateMessage;
import mekanism.common.util.LangUtils; import mekanism.common.util.LangUtils;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import org.lwjgl.input.Keyboard;
import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
@ -37,8 +40,6 @@ import cpw.mods.fml.common.gameevent.InputEvent;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import org.lwjgl.input.Keyboard;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class MekanismKeyHandler extends MekKeyHandler public class MekanismKeyHandler extends MekKeyHandler
{ {
@ -75,11 +76,13 @@ public class MekanismKeyHandler extends MekKeyHandler
ItemStack toolStack = player.getCurrentEquippedItem(); ItemStack toolStack = player.getCurrentEquippedItem();
Item item = StackUtils.getItem(toolStack); Item item = StackUtils.getItem(toolStack);
if(player.isSneaking() && item instanceof ItemConfigurator) if(player.isSneaking() && item instanceof ItemConfigurator)
{ {
ItemConfigurator configurator = (ItemConfigurator)item; ItemConfigurator configurator = (ItemConfigurator)item;
configurator.setState(toolStack, (byte) (configurator.getState(toolStack) < 3 ? configurator.getState(toolStack) + 1 : 0)); int toSet = configurator.getState(toolStack).ordinal() < ConfiguratorMode.values().length-1 ? configurator.getState(toolStack).ordinal() + 1 : 0;
configurator.setState(toolStack, ConfiguratorMode.values()[toSet]);
Mekanism.packetHandler.sendToServer(new ConfiguratorStateMessage(configurator.getState(toolStack))); Mekanism.packetHandler.sendToServer(new ConfiguratorStateMessage(configurator.getState(toolStack)));
player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + MekanismUtils.localize("tooltip.configureState") + ": " + configurator.getColor(configurator.getState(toolStack)) + configurator.getStateDisplay(configurator.getState(toolStack)))); player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + MekanismUtils.localize("tooltip.configureState") + ": " + configurator.getColor(configurator.getState(toolStack)) + configurator.getStateDisplay(configurator.getState(toolStack))));
} }

View file

@ -0,0 +1,5 @@
package mekanism.client.gui;
public class GuiConfigTypeTab {
}

View file

@ -5,11 +5,12 @@ import java.util.Map;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.api.EnumColor; import mekanism.api.EnumColor;
import mekanism.api.transmitters.TransmissionType;
import mekanism.client.render.MekanismRenderer; import mekanism.client.render.MekanismRenderer;
import mekanism.client.sound.SoundHandler; import mekanism.client.sound.SoundHandler;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.SideData; import mekanism.common.SideData;
import mekanism.common.base.IInvConfiguration; import mekanism.common.base.ISideConfiguration;
import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.inventory.container.ContainerNull; import mekanism.common.inventory.container.ContainerNull;
import mekanism.common.network.PacketConfigurationUpdate.ConfigurationPacket; import mekanism.common.network.PacketConfigurationUpdate.ConfigurationPacket;
@ -18,17 +19,17 @@ import mekanism.common.network.PacketSimpleGui.SimpleGuiMessage;
import mekanism.common.tile.TileEntityContainerBlock; import mekanism.common.tile.TileEntityContainerBlock;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12; import org.lwjgl.opengl.GL12;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class GuiConfiguration extends GuiMekanism public class GuiConfiguration extends GuiMekanism
{ {
@ -36,9 +37,9 @@ public class GuiConfiguration extends GuiMekanism
public Map<Integer, GuiPos> inputPosMap = new HashMap<Integer, GuiPos>(); public Map<Integer, GuiPos> inputPosMap = new HashMap<Integer, GuiPos>();
public IInvConfiguration configurable; public ISideConfiguration configurable;
public GuiConfiguration(EntityPlayer player, IInvConfiguration tile) public GuiConfiguration(EntityPlayer player, ISideConfiguration tile)
{ {
super(new ContainerNull(player, (TileEntityContainerBlock)tile)); super(new ContainerNull(player, (TileEntityContainerBlock)tile));
@ -108,7 +109,7 @@ public class GuiConfiguration extends GuiMekanism
int x = slotPosMap.get(i).xPos; int x = slotPosMap.get(i).xPos;
int y = slotPosMap.get(i).yPos; int y = slotPosMap.get(i).yPos;
SideData data = configurable.getSideData().get(configurable.getConfiguration()[i]); SideData data = configurable.getConfig().getOutput(TransmissionType.ITEM, i);
if(data.color != EnumColor.GREY) if(data.color != EnumColor.GREY)
{ {
@ -182,7 +183,7 @@ public class GuiConfiguration extends GuiMekanism
int x = slotPosMap.get(i).xPos; int x = slotPosMap.get(i).xPos;
int y = slotPosMap.get(i).yPos; int y = slotPosMap.get(i).yPos;
SideData data = configurable.getSideData().get(configurable.getConfiguration()[i]); SideData data = configurable.getConfig().getOutput(TransmissionType.ITEM, i);
if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14)
{ {
@ -262,13 +263,13 @@ public class GuiConfiguration extends GuiMekanism
if(xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) if(xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20)
{ {
SoundHandler.playSound("gui.button.press"); SoundHandler.playSound("gui.button.press");
Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage(ConfigurationPacket.EJECT, Coord4D.get(tile), 0, 0)); Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage(ConfigurationPacket.EJECT, Coord4D.get(tile), 0, 0, null));
} }
if(xAxis >= 156 && xAxis <= 170 && yAxis >= 21 && yAxis <= 35) if(xAxis >= 156 && xAxis <= 170 && yAxis >= 21 && yAxis <= 35)
{ {
SoundHandler.playSound("gui.button.press"); SoundHandler.playSound("gui.button.press");
Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage(ConfigurationPacket.STRICT_INPUT, Coord4D.get(tile), 0, 0)); Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage(ConfigurationPacket.STRICT_INPUT, Coord4D.get(tile), 0, 0, null));
} }
} }
@ -280,7 +281,7 @@ public class GuiConfiguration extends GuiMekanism
if(xAxis >= 80 && xAxis <= 96 && yAxis >= 49 && yAxis <= 65) if(xAxis >= 80 && xAxis <= 96 && yAxis >= 49 && yAxis <= 65)
{ {
SoundHandler.playSound("gui.button.press"); SoundHandler.playSound("gui.button.press");
Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage(ConfigurationPacket.EJECT_COLOR, Coord4D.get(tile), button, 0)); Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage(ConfigurationPacket.EJECT_COLOR, Coord4D.get(tile), button, 0, null));
} }
for(int i = 0; i < slotPosMap.size(); i++) for(int i = 0; i < slotPosMap.size(); i++)
@ -291,7 +292,7 @@ public class GuiConfiguration extends GuiMekanism
if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14)
{ {
SoundHandler.playSound("gui.button.press"); SoundHandler.playSound("gui.button.press");
Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage(ConfigurationPacket.SIDE_DATA, Coord4D.get(tile), button, i)); Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage(ConfigurationPacket.SIDE_DATA, Coord4D.get(tile), button, i, TransmissionType.ITEM));
} }
} }
@ -303,7 +304,7 @@ public class GuiConfiguration extends GuiMekanism
if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14)
{ {
SoundHandler.playSound("gui.button.press"); SoundHandler.playSound("gui.button.press");
Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage(ConfigurationPacket.INPUT_COLOR, Coord4D.get(tile), button, i)); Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage(ConfigurationPacket.INPUT_COLOR, Coord4D.get(tile), button, i, null));
} }
} }
} }

View file

@ -5,8 +5,9 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.SideData; import mekanism.common.SideData;
import mekanism.common.base.IInvConfiguration; import mekanism.common.base.ISideConfiguration;
import mekanism.common.item.ItemConfigurator; import mekanism.common.item.ItemConfigurator;
import mekanism.common.tile.TileEntityContainerBlock; import mekanism.common.tile.TileEntityContainerBlock;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
@ -70,7 +71,7 @@ public abstract class GuiMekanism extends GuiContainer implements IGuiWrapper
element.renderForeground(xAxis, yAxis); element.renderForeground(xAxis, yAxis);
} }
if(tileEntity instanceof IInvConfiguration) if(tileEntity instanceof ISideConfiguration)
{ {
Slot hovering = null; Slot hovering = null;
@ -108,9 +109,9 @@ public abstract class GuiMekanism extends GuiContainer implements IGuiWrapper
{ {
if(slot.slotNumber < tileEntity.getSizeInventory()) if(slot.slotNumber < tileEntity.getSizeInventory())
{ {
IInvConfiguration config = (IInvConfiguration)tileEntity; ISideConfiguration config = (ISideConfiguration)tileEntity;
for(SideData data : config.getSideData()) for(SideData data : config.getConfig().getOutputs(TransmissionType.ITEM))
{ {
for(int id : data.availableSlots) for(int id : data.availableSlots)
{ {

View file

@ -1,12 +1,15 @@
package mekanism.client.render; package mekanism.client.render;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import mekanism.api.EnumColor; import mekanism.api.EnumColor;
import mekanism.api.gas.Gas; import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.OreGas; import mekanism.api.gas.OreGas;
import mekanism.api.transmitters.TransmissionType;
import mekanism.client.render.tileentity.RenderConfigurableMachine; import mekanism.client.render.tileentity.RenderConfigurableMachine;
import mekanism.client.render.tileentity.RenderDynamicTank; import mekanism.client.render.tileentity.RenderDynamicTank;
import mekanism.client.render.tileentity.RenderPortableTank; import mekanism.client.render.tileentity.RenderPortableTank;
@ -52,6 +55,8 @@ public class MekanismRenderer
public static IIcon energyIcon; public static IIcon energyIcon;
public static IIcon heatIcon; public static IIcon heatIcon;
public static Map<TransmissionType, IIcon> overlays = new HashMap<TransmissionType, IIcon>();
private static float lightmapLastX; private static float lightmapLastX;
private static float lightmapLastY; private static float lightmapLastY;
private static boolean optifineBreak = false; private static boolean optifineBreak = false;
@ -73,6 +78,11 @@ public class MekanismRenderer
colors[color.ordinal()] = event.map.registerIcon("mekanism:overlay/overlay_" + color.unlocalizedName); colors[color.ordinal()] = event.map.registerIcon("mekanism:overlay/overlay_" + color.unlocalizedName);
} }
for(TransmissionType type : TransmissionType.values())
{
overlays.put(type, event.map.registerIcon("mekanism:overlay/" + type.getTransmission() + "Overlay"));
}
energyIcon = event.map.registerIcon("mekanism:LiquidEnergy"); energyIcon = event.map.registerIcon("mekanism:LiquidEnergy");
heatIcon = event.map.registerIcon("mekanism:LiquidHeat"); heatIcon = event.map.registerIcon("mekanism:LiquidHeat");

View file

@ -4,13 +4,13 @@ import java.util.HashMap;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.api.EnumColor; import mekanism.api.EnumColor;
import mekanism.api.transmitters.TransmissionType;
import mekanism.client.render.MekanismRenderer; import mekanism.client.render.MekanismRenderer;
import mekanism.client.render.MekanismRenderer.DisplayInteger; import mekanism.client.render.MekanismRenderer.DisplayInteger;
import mekanism.client.render.MekanismRenderer.Model3D; import mekanism.client.render.MekanismRenderer.Model3D;
import mekanism.common.base.IInvConfiguration; import mekanism.common.base.ISideConfiguration;
import mekanism.common.item.ItemConfigurator; import mekanism.common.item.ItemConfigurator;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
@ -18,22 +18,23 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import codechicken.lib.math.MathHelper;
import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class RenderConfigurableMachine extends TileEntitySpecialRenderer public class RenderConfigurableMachine extends TileEntitySpecialRenderer
{ {
private Minecraft mc = FMLClientHandler.instance().getClient(); private Minecraft mc = FMLClientHandler.instance().getClient();
private HashMap<ForgeDirection, HashMap<EnumColor, DisplayInteger>> cachedOverlays = new HashMap<ForgeDirection, HashMap<EnumColor, DisplayInteger>>(); private HashMap<ForgeDirection, HashMap<TransmissionType, DisplayInteger>> cachedOverlays = new HashMap<ForgeDirection, HashMap<TransmissionType, DisplayInteger>>();
public RenderConfigurableMachine() public RenderConfigurableMachine()
{ {
@ -43,10 +44,10 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer
@Override @Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
{ {
renderAModelAt((IInvConfiguration)tileEntity, x, y, z, partialTick); renderAModelAt((ISideConfiguration)tileEntity, x, y, z, partialTick);
} }
public void renderAModelAt(IInvConfiguration configurable, double x, double y, double z, float partialTick) public void renderAModelAt(ISideConfiguration configurable, double x, double y, double z, float partialTick)
{ {
GL11.glPushMatrix(); GL11.glPushMatrix();
@ -56,31 +57,35 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer
ItemStack itemStack = player.getCurrentEquippedItem(); ItemStack itemStack = player.getCurrentEquippedItem();
MovingObjectPosition pos = player.rayTrace(8.0D, 1.0F); MovingObjectPosition pos = player.rayTrace(8.0D, 1.0F);
if(pos != null && itemStack != null && itemStack.getItem() instanceof ItemConfigurator && ((ItemConfigurator)itemStack.getItem()).getState(itemStack) == 0) if(pos != null && itemStack != null && itemStack.getItem() instanceof ItemConfigurator && ((ItemConfigurator)itemStack.getItem()).getState(itemStack).isConfigurating())
{ {
int xPos = MathHelper.floor_double(pos.blockX); int xPos = MathHelper.floor_double(pos.blockX);
int yPos = MathHelper.floor_double(pos.blockY); int yPos = MathHelper.floor_double(pos.blockY);
int zPos = MathHelper.floor_double(pos.blockZ); int zPos = MathHelper.floor_double(pos.blockZ);
Coord4D obj = new Coord4D(xPos, yPos, zPos, tileEntity.getWorldObj().provider.dimensionId); Coord4D obj = new Coord4D(xPos, yPos, zPos, tileEntity.getWorldObj().provider.dimensionId);
TransmissionType type = ((ItemConfigurator)itemStack.getItem()).getState(itemStack).getTransmission();
if(configurable.getConfig().supports(type))
{
if(xPos == tileEntity.xCoord && yPos == tileEntity.yCoord && zPos == tileEntity.zCoord) if(xPos == tileEntity.xCoord && yPos == tileEntity.yCoord && zPos == tileEntity.zCoord)
{ {
EnumColor color = configurable.getSideData().get(configurable.getConfiguration()[MekanismUtils.getBaseOrientation(pos.sideHit, configurable.getOrientation())]).color; EnumColor color = configurable.getConfig().getOutput(type, pos.sideHit, configurable.getOrientation()).color;
push(); push();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.4F); MekanismRenderer.color(color, 0.4F);
bindTexture(MekanismRenderer.getBlocksTexture()); bindTexture(MekanismRenderer.getBlocksTexture());
GL11.glTranslatef((float)x, (float)y, (float)z); GL11.glTranslatef((float)x, (float)y, (float)z);
int display = getOverlayDisplay(world, ForgeDirection.getOrientation(pos.sideHit), color).display; int display = getOverlayDisplay(world, ForgeDirection.getOrientation(pos.sideHit), TransmissionType.ITEM).display;
GL11.glCallList(display); GL11.glCallList(display);
pop(); pop();
} }
} }
}
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
@ -103,26 +108,26 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer
MekanismRenderer.blendOn(); MekanismRenderer.blendOn();
} }
private DisplayInteger getOverlayDisplay(World world, ForgeDirection side, EnumColor color) private DisplayInteger getOverlayDisplay(World world, ForgeDirection side, TransmissionType type)
{ {
if(cachedOverlays.containsKey(side) && cachedOverlays.get(side).containsKey(color)) if(cachedOverlays.containsKey(side) && cachedOverlays.get(side).containsKey(type))
{ {
return cachedOverlays.get(side).get(color); return cachedOverlays.get(side).get(type);
} }
Model3D toReturn = new Model3D(); Model3D toReturn = new Model3D();
toReturn.baseBlock = Blocks.stone; toReturn.baseBlock = Blocks.stone;
toReturn.setTexture(MekanismRenderer.getColorIcon(color)); toReturn.setTexture(MekanismRenderer.overlays.get(type));
DisplayInteger display = DisplayInteger.createAndStart(); DisplayInteger display = DisplayInteger.createAndStart();
if(cachedOverlays.containsKey(side)) if(cachedOverlays.containsKey(side))
{ {
cachedOverlays.get(side).put(color, display); cachedOverlays.get(side).put(type, display);
} }
else { else {
HashMap<EnumColor, DisplayInteger> map = new HashMap<EnumColor, DisplayInteger>(); HashMap<TransmissionType, DisplayInteger> map = new HashMap<TransmissionType, DisplayInteger>();
map.put(color, display); map.put(type, display);
cachedOverlays.put(side, map); cachedOverlays.put(side, map);
} }
@ -205,4 +210,32 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer
return display; return display;
} }
public static class OverlayRenderData
{
public EnumColor color;
public TransmissionType type;
public OverlayRenderData(EnumColor c, TransmissionType t)
{
color = c;
type = t;
}
@Override
public boolean equals(Object data)
{
return data instanceof OverlayRenderData && ((OverlayRenderData)data).color == color &&
((OverlayRenderData)data).type == type;
}
@Override
public int hashCode()
{
int code = 1;
code = 31 * code + color.ordinal();
code = 31 * code + type.ordinal();
return code;
}
}
} }

View file

@ -1,37 +0,0 @@
package mekanism.common.base;
import java.util.ArrayList;
import mekanism.common.SideData;
/**
* Implement this if your TileEntity is capable of being modified by a Configurator in it's 'modify' mode.
* @author AidanBrady
*
*/
public interface IInvConfiguration
{
/**
* Gets an ArrayList of side data this machine contains.
* @return
*/
public ArrayList<SideData> getSideData();
/**
* Gets this machine's configuration as a byte[] -- each byte matching with the index of the defined SideData.
* @return
*/
public byte[] getConfiguration();
/**
* Gets this machine's current orientation.
* @return
*/
public int getOrientation();
/**
* Gets this machine's ejector.
* @return
*/
public IEjector getEjector();
}

View file

@ -0,0 +1,29 @@
package mekanism.common.base;
import mekanism.common.tile.component.TileComponentConfig;
/**
* Implement this if your TileEntity is capable of being modified by a Configurator in it's 'modify' mode.
* @author AidanBrady
*
*/
public interface ISideConfiguration
{
/**
* Gets the tile's configuration component.
* @return the tile's configuration component
*/
public TileComponentConfig getConfig();
/**
* Gets this machine's current orientation.
* @return machine's current orientation
*/
public int getOrientation();
/**
* Gets this machine's ejector.
* @return
*/
public IEjector getEjector();
}

View file

@ -13,6 +13,7 @@ import mekanism.api.MekanismConfig.machines;
import mekanism.api.MekanismConfig.usage; import mekanism.api.MekanismConfig.usage;
import mekanism.api.energy.IEnergizedItem; import mekanism.api.energy.IEnergizedItem;
import mekanism.api.energy.IStrictEnergyStorage; import mekanism.api.energy.IStrictEnergyStorage;
import mekanism.api.transmitters.TransmissionType;
import mekanism.client.ClientProxy; import mekanism.client.ClientProxy;
import mekanism.common.ItemAttacher; import mekanism.common.ItemAttacher;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
@ -22,7 +23,7 @@ import mekanism.common.base.IBoundingBlock;
import mekanism.common.base.IElectricChest; import mekanism.common.base.IElectricChest;
import mekanism.common.base.IFactory; import mekanism.common.base.IFactory;
import mekanism.common.base.IFactory.RecipeType; import mekanism.common.base.IFactory.RecipeType;
import mekanism.common.base.IInvConfiguration; import mekanism.common.base.ISideConfiguration;
import mekanism.common.base.IRedstoneControl; import mekanism.common.base.IRedstoneControl;
import mekanism.common.base.ISpecialBounds; import mekanism.common.base.ISpecialBounds;
import mekanism.common.base.ISustainedData; import mekanism.common.base.ISustainedData;
@ -896,18 +897,15 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
((IUpgradeTile)tileEntity).getComponent().write(itemStack.stackTagCompound); ((IUpgradeTile)tileEntity).getComponent().write(itemStack.stackTagCompound);
} }
if(tileEntity instanceof IInvConfiguration) if(tileEntity instanceof ISideConfiguration)
{ {
IInvConfiguration config = (IInvConfiguration)tileEntity; ISideConfiguration config = (ISideConfiguration)tileEntity;
itemStack.stackTagCompound.setBoolean("hasSideData", true); itemStack.stackTagCompound.setBoolean("hasSideData", true);
itemStack.stackTagCompound.setBoolean("ejecting", config.getEjector().isEjecting()); itemStack.stackTagCompound.setBoolean("ejecting", config.getEjector().isEjecting());
for(int i = 0; i < 6; i++) config.getConfig().write(itemStack.stackTagCompound);
{
itemStack.stackTagCompound.setByte("config"+i, config.getConfiguration()[i]);
}
} }
if(tileEntity instanceof ISustainedData) if(tileEntity instanceof ISustainedData)

View file

@ -7,7 +7,7 @@ import java.util.Set;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.api.EnumColor; import mekanism.api.EnumColor;
import mekanism.common.base.IInvConfiguration; import mekanism.common.base.ISideConfiguration;
import mekanism.common.content.transporter.TransporterStack.Path; import mekanism.common.content.transporter.TransporterStack.Path;
import mekanism.common.tile.TileEntityBin; import mekanism.common.tile.TileEntityBin;
import mekanism.common.util.InventoryUtils; import mekanism.common.util.InventoryUtils;
@ -96,9 +96,9 @@ public class TransporterManager
{ {
ItemStack toInsert = stack.itemStack.copy(); ItemStack toInsert = stack.itemStack.copy();
if(stack.pathType != Path.HOME && inv instanceof IInvConfiguration) if(stack.pathType != Path.HOME && inv instanceof ISideConfiguration)
{ {
IInvConfiguration config = (IInvConfiguration)inv; ISideConfiguration config = (ISideConfiguration)inv;
int tileSide = config.getOrientation(); int tileSide = config.getOrientation();
EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite()); EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite());
@ -242,9 +242,9 @@ public class TransporterManager
return itemStack; return itemStack;
} }
if(tileEntity instanceof IInvConfiguration) if(tileEntity instanceof ISideConfiguration)
{ {
IInvConfiguration config = (IInvConfiguration)tileEntity; ISideConfiguration config = (ISideConfiguration)tileEntity;
int tileSide = config.getOrientation(); int tileSide = config.getOrientation();
EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite()); EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite());

View file

@ -14,7 +14,7 @@ import mekanism.common.Mekanism;
import mekanism.common.Upgrade; import mekanism.common.Upgrade;
import mekanism.common.base.IElectricChest; import mekanism.common.base.IElectricChest;
import mekanism.common.base.IFactory; import mekanism.common.base.IFactory;
import mekanism.common.base.IInvConfiguration; import mekanism.common.base.ISideConfiguration;
import mekanism.common.base.IRedstoneControl; import mekanism.common.base.IRedstoneControl;
import mekanism.common.base.IRedstoneControl.RedstoneControl; import mekanism.common.base.IRedstoneControl.RedstoneControl;
import mekanism.common.base.ISustainedData; import mekanism.common.base.ISustainedData;
@ -270,18 +270,14 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
} }
} }
if(tileEntity instanceof IInvConfiguration) if(tileEntity instanceof ISideConfiguration)
{ {
IInvConfiguration config = (IInvConfiguration)tileEntity; ISideConfiguration config = (ISideConfiguration)tileEntity;
if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("hasSideData")) if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("hasSideData"))
{ {
config.getEjector().setEjecting(stack.stackTagCompound.getBoolean("ejecting")); config.getEjector().setEjecting(stack.stackTagCompound.getBoolean("ejecting"));
config.getConfig().read(stack.stackTagCompound);
for(int i = 0; i < 6; i++)
{
config.getConfiguration()[i] = stack.stackTagCompound.getByte("config"+i);
}
} }
} }

View file

@ -10,8 +10,9 @@ import mekanism.api.EnumColor;
import mekanism.api.IConfigurable; import mekanism.api.IConfigurable;
import mekanism.api.IMekWrench; import mekanism.api.IMekWrench;
import mekanism.api.Range4D; import mekanism.api.Range4D;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.base.IInvConfiguration; import mekanism.common.base.ISideConfiguration;
import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.tile.TileEntityBasicBlock; import mekanism.common.tile.TileEntityBasicBlock;
import mekanism.common.tile.TileEntityElectricChest; import mekanism.common.tile.TileEntityElectricChest;
@ -49,7 +50,7 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag)
{ {
super.addInformation(itemstack, entityplayer, list, flag); super.addInformation(itemstack, entityplayer, list, flag);
list.add(EnumColor.PINK + MekanismUtils.localize("gui.state") + ": " + EnumColor.GREY + getStateDisplay(getState(itemstack))); list.add(EnumColor.PINK + MekanismUtils.localize("gui.state") + ": " + getColor(getState(itemstack)) + getStateDisplay(getState(itemstack)));
} }
@Override @Override
@ -60,23 +61,23 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool
Block block = world.getBlock(x, y, z); Block block = world.getBlock(x, y, z);
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
if(getState(stack) == 0) //Configurate if(getState(stack).isConfigurating()) //Configurate
{ {
if(tile instanceof IInvConfiguration) if(tile instanceof ISideConfiguration && ((ISideConfiguration)tile).getConfig().supports(getState(stack).getTransmission()))
{ {
IInvConfiguration config = (IInvConfiguration)tile; ISideConfiguration config = (ISideConfiguration)tile;
if(!player.isSneaking()) if(!player.isSneaking())
{ {
player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.configurator.viewColor") + ": " + config.getSideData().get(config.getConfiguration()[MekanismUtils.getBaseOrientation(side, config.getOrientation())]).color.getName())); player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.configurator.viewColor") + ": " + config.getConfig().getOutput(getState(stack).getTransmission(), side, config.getOrientation()).color.getName()));
return true; return true;
} }
else { else {
if(getEnergy(stack) >= ENERGY_PER_CONFIGURE) if(getEnergy(stack) >= ENERGY_PER_CONFIGURE)
{ {
setEnergy(stack, getEnergy(stack) - ENERGY_PER_CONFIGURE); setEnergy(stack, getEnergy(stack) - ENERGY_PER_CONFIGURE);
MekanismUtils.incrementOutput(config, MekanismUtils.getBaseOrientation(side, config.getOrientation())); MekanismUtils.incrementOutput(config, getState(stack).getTransmission(), MekanismUtils.getBaseOrientation(side, config.getOrientation()));
player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.configurator.toggleColor") + ": " + config.getSideData().get(config.getConfiguration()[MekanismUtils.getBaseOrientation(side, config.getOrientation())]).color.getName())); player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.configurator.toggleColor") + ": " + config.getConfig().getOutput(getState(stack).getTransmission(), side, config.getOrientation()).color.getName()));
if(config instanceof TileEntityBasicBlock) if(config instanceof TileEntityBasicBlock)
{ {
@ -101,7 +102,7 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool
} }
} }
} }
else if(getState(stack) == 1) //Empty else if(getState(stack) == ConfiguratorMode.EMPTY) //Empty
{ {
if(tile instanceof IInventory) if(tile instanceof IInventory)
{ {
@ -161,7 +162,7 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool
} }
} }
} }
else if(getState(stack) == 2) //Rotate else if(getState(stack) == ConfiguratorMode.ROTATE) //Rotate
{ {
ForgeDirection axis = ForgeDirection.getOrientation(side); ForgeDirection axis = ForgeDirection.getOrientation(side);
List<ForgeDirection> l = Arrays.asList(block.getValidRotations(world, x, y, z)); List<ForgeDirection> l = Arrays.asList(block.getValidRotations(world, x, y, z));
@ -177,7 +178,7 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool
return true; return true;
} }
else if(getState(stack) == 3) //Wrench else if(getState(stack) == ConfiguratorMode.WRENCH) //Wrench
{ {
return false; return false;
} }
@ -186,65 +187,39 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool
return false; return false;
} }
public String getStateDisplay(int state) public String getStateDisplay(ConfiguratorMode mode)
{ {
switch(state) return mode.getName();
{
case 0:
return MekanismUtils.localize("tooltip.configurator.configurate");
case 1:
return MekanismUtils.localize("tooltip.configurator.empty");
case 2:
return MekanismUtils.localize("tooltip.configurator.rotate");
case 3:
return MekanismUtils.localize("tooltip.configurator.wrench");
} }
return "unknown"; public EnumColor getColor(ConfiguratorMode mode)
}
public EnumColor getColor(int state)
{ {
switch(state) return mode.getColor();
{
case 0:
return EnumColor.BRIGHT_GREEN;
case 1:
return EnumColor.AQUA;
case 2:
return EnumColor.YELLOW;
case 3:
return EnumColor.PINK;
} }
return EnumColor.GREY; public void setState(ItemStack itemstack, ConfiguratorMode state)
}
public void setState(ItemStack itemstack, byte state)
{ {
if(itemstack.stackTagCompound == null) if(itemstack.stackTagCompound == null)
{ {
itemstack.setTagCompound(new NBTTagCompound()); itemstack.setTagCompound(new NBTTagCompound());
} }
itemstack.stackTagCompound.setByte("state", state); itemstack.stackTagCompound.setInteger("state", state.ordinal());
} }
public byte getState(ItemStack itemstack) public ConfiguratorMode getState(ItemStack itemstack)
{ {
if(itemstack.stackTagCompound == null) if(itemstack.stackTagCompound == null)
{ {
return 0; return ConfiguratorMode.CONFIGURATE_ITEMS;
} }
byte state = 0;
if(itemstack.stackTagCompound.getTag("state") != null) if(itemstack.stackTagCompound.getTag("state") != null)
{ {
state = itemstack.stackTagCompound.getByte("state"); return ConfiguratorMode.values()[itemstack.stackTagCompound.getInteger("state")];
} }
return state; return ConfiguratorMode.CONFIGURATE_ITEMS;
} }
@Override @Override
@ -267,13 +242,13 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool
@Override @Override
public boolean canUseWrench(EntityPlayer player, int x, int y, int z) public boolean canUseWrench(EntityPlayer player, int x, int y, int z)
{ {
return getState(player.getCurrentEquippedItem()) == 3; return getState(player.getCurrentEquippedItem()) == ConfiguratorMode.WRENCH;
} }
@Override @Override
public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player)
{ {
return getState(player.getCurrentEquippedItem()) == 3; return getState(player.getCurrentEquippedItem()) == ConfiguratorMode.WRENCH;
} }
@Override @Override
@ -284,4 +259,60 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool
@Override @Override
public void toolUsed(ItemStack item, EntityLivingBase user, int x, int y, int z) {} public void toolUsed(ItemStack item, EntityLivingBase user, int x, int y, int z) {}
public static enum ConfiguratorMode
{
CONFIGURATE_ITEMS("configurate", "(" + TransmissionType.ITEM.getName() + ")", EnumColor.BRIGHT_GREEN, true),
CONFIGURATE_FLUIDS("configurate", "(" + TransmissionType.FLUID.getName() + ")", EnumColor.BRIGHT_GREEN, true),
CONFIGURATE_GASES("configurate", "(" + TransmissionType.GAS.getName() + ")", EnumColor.BRIGHT_GREEN, true),
CONFIGURATE_ENERGY("configurate", "(" + TransmissionType.ENERGY.getName() + ")", EnumColor.BRIGHT_GREEN, true),
EMPTY("empty", "", EnumColor.DARK_RED, false),
ROTATE("rotate", "", EnumColor.YELLOW, false),
WRENCH("wrench", "", EnumColor.PINK, false);
private String name;
private String info;
private EnumColor color;
private boolean configurating;
private ConfiguratorMode(String s, String s1, EnumColor c, boolean b)
{
name = s;
info = s1;
color = c;
configurating = b;
}
public String getName()
{
return MekanismUtils.localize("tooltip.configurator." + name) + info;
}
public EnumColor getColor()
{
return color;
}
public boolean isConfigurating()
{
return configurating;
}
public TransmissionType getTransmission()
{
switch(this)
{
case CONFIGURATE_ITEMS:
return TransmissionType.ITEM;
case CONFIGURATE_FLUIDS:
return TransmissionType.FLUID;
case CONFIGURATE_GASES:
return TransmissionType.GAS;
case CONFIGURATE_ENERGY:
return TransmissionType.ENERGY;
}
return null;
}
}
} }

View file

@ -1,19 +1,21 @@
package mekanism.common.network; package mekanism.common.network;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList; import java.util.ArrayList;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.api.Range4D; import mekanism.api.Range4D;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.PacketHandler; import mekanism.common.PacketHandler;
import mekanism.common.base.IInvConfiguration; import mekanism.common.base.ISideConfiguration;
import mekanism.common.base.ITileNetwork; import mekanism.common.base.ITileNetwork;
import mekanism.common.network.PacketConfigurationUpdate.ConfigurationUpdateMessage; import mekanism.common.network.PacketConfigurationUpdate.ConfigurationUpdateMessage;
import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.tile.TileEntityBasicBlock; import mekanism.common.tile.TileEntityBasicBlock;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import mekanism.common.util.TransporterUtils; import mekanism.common.util.TransporterUtils;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@ -22,8 +24,6 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
public class PacketConfigurationUpdate implements IMessageHandler<ConfigurationUpdateMessage, IMessage> public class PacketConfigurationUpdate implements IMessageHandler<ConfigurationUpdateMessage, IMessage>
{ {
@Override @Override
@ -31,9 +31,9 @@ public class PacketConfigurationUpdate implements IMessageHandler<ConfigurationU
{ {
TileEntity tile = message.coord4D.getTileEntity(PacketHandler.getPlayer(context).worldObj); TileEntity tile = message.coord4D.getTileEntity(PacketHandler.getPlayer(context).worldObj);
if(tile instanceof IInvConfiguration) if(tile instanceof ISideConfiguration)
{ {
IInvConfiguration config = (IInvConfiguration)tile; ISideConfiguration config = (ISideConfiguration)tile;
if(message.packetType == ConfigurationPacket.EJECT) if(message.packetType == ConfigurationPacket.EJECT)
{ {
@ -43,15 +43,15 @@ public class PacketConfigurationUpdate implements IMessageHandler<ConfigurationU
{ {
if(message.clickType == 0) if(message.clickType == 0)
{ {
MekanismUtils.incrementOutput((IInvConfiguration)tile, message.configIndex); MekanismUtils.incrementOutput((ISideConfiguration)tile, message.transmission, message.configIndex);
} }
else if(message.clickType == 1) else if(message.clickType == 1)
{ {
MekanismUtils.decrementOutput((IInvConfiguration)tile, message.configIndex); MekanismUtils.decrementOutput((ISideConfiguration)tile, message.transmission, message.configIndex);
} }
else if(message.clickType == 2) else if(message.clickType == 2)
{ {
((IInvConfiguration)tile).getConfiguration()[message.configIndex] = 0; ((ISideConfiguration)tile).getConfig().getConfig(message.transmission)[message.configIndex] = 0;
} }
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(message.coord4D, ((ITileNetwork)tile).getNetworkedData(new ArrayList())), new Range4D(message.coord4D)); Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(message.coord4D, ((ITileNetwork)tile).getNetworkedData(new ArrayList())), new Range4D(message.coord4D));
@ -110,13 +110,15 @@ public class PacketConfigurationUpdate implements IMessageHandler<ConfigurationU
public int inputSide; public int inputSide;
public TransmissionType transmission;
public int clickType; public int clickType;
public ConfigurationPacket packetType; public ConfigurationPacket packetType;
public ConfigurationUpdateMessage() {} public ConfigurationUpdateMessage() {}
public ConfigurationUpdateMessage(ConfigurationPacket type, Coord4D coord, int click, int extra) public ConfigurationUpdateMessage(ConfigurationPacket type, Coord4D coord, int click, int extra, TransmissionType trans)
{ {
packetType = type; packetType = type;
@ -131,6 +133,7 @@ public class PacketConfigurationUpdate implements IMessageHandler<ConfigurationU
{ {
clickType = click; clickType = click;
configIndex = extra; configIndex = extra;
transmission = trans;
} }
if(packetType == ConfigurationPacket.INPUT_COLOR) if(packetType == ConfigurationPacket.INPUT_COLOR)

View file

@ -1,16 +1,15 @@
package mekanism.common.network; package mekanism.common.network;
import io.netty.buffer.ByteBuf;
import mekanism.common.PacketHandler; import mekanism.common.PacketHandler;
import mekanism.common.item.ItemConfigurator; import mekanism.common.item.ItemConfigurator;
import mekanism.common.item.ItemConfigurator.ConfiguratorMode;
import mekanism.common.network.PacketConfiguratorState.ConfiguratorStateMessage; import mekanism.common.network.PacketConfiguratorState.ConfiguratorStateMessage;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
public class PacketConfiguratorState implements IMessageHandler<ConfiguratorStateMessage, IMessage> public class PacketConfiguratorState implements IMessageHandler<ConfiguratorStateMessage, IMessage>
{ {
@Override @Override
@ -20,7 +19,7 @@ public class PacketConfiguratorState implements IMessageHandler<ConfiguratorStat
if(itemstack != null && itemstack.getItem() instanceof ItemConfigurator) if(itemstack != null && itemstack.getItem() instanceof ItemConfigurator)
{ {
((ItemConfigurator)itemstack.getItem()).setState(itemstack, (byte)message.state); ((ItemConfigurator)itemstack.getItem()).setState(itemstack, message.state);
} }
return null; return null;
@ -28,11 +27,11 @@ public class PacketConfiguratorState implements IMessageHandler<ConfiguratorStat
public static class ConfiguratorStateMessage implements IMessage public static class ConfiguratorStateMessage implements IMessage
{ {
public byte state; public ConfiguratorMode state;
public ConfiguratorStateMessage() {} public ConfiguratorStateMessage() {}
public ConfiguratorStateMessage(byte s) public ConfiguratorStateMessage(ConfiguratorMode s)
{ {
state = s; state = s;
} }
@ -40,13 +39,13 @@ public class PacketConfiguratorState implements IMessageHandler<ConfiguratorStat
@Override @Override
public void toBytes(ByteBuf dataStream) public void toBytes(ByteBuf dataStream)
{ {
dataStream.writeByte(state); dataStream.writeInt(state.ordinal());
} }
@Override @Override
public void fromBytes(ByteBuf dataStream) public void fromBytes(ByteBuf dataStream)
{ {
state = dataStream.readByte(); state = ConfiguratorMode.values()[dataStream.readInt()];
} }
} }
} }

View file

@ -12,6 +12,7 @@ import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank; import mekanism.api.gas.GasTank;
import mekanism.api.gas.IGasHandler; import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.ITubeConnection; import mekanism.api.gas.ITubeConnection;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.MekanismBlocks; import mekanism.common.MekanismBlocks;
import mekanism.common.MekanismItems; import mekanism.common.MekanismItems;
@ -23,6 +24,7 @@ import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.inputs.AdvancedMachineInput; import mekanism.common.recipe.inputs.AdvancedMachineInput;
import mekanism.common.recipe.machines.AdvancedMachineRecipe; import mekanism.common.recipe.machines.AdvancedMachineRecipe;
import mekanism.common.recipe.outputs.ItemStackOutput; import mekanism.common.recipe.outputs.ItemStackOutput;
import mekanism.common.tile.component.TileComponentConfig;
import mekanism.common.tile.component.TileComponentEjector; import mekanism.common.tile.component.TileComponentEjector;
import mekanism.common.tile.component.TileComponentUpgrade; import mekanism.common.tile.component.TileComponentUpgrade;
import mekanism.common.util.ChargeUtils; import mekanism.common.util.ChargeUtils;
@ -66,14 +68,16 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
{ {
super(soundPath, name, MekanismUtils.getResource(ResourceType.GUI, "GuiAdvancedMachine.png"), perTick, ticksRequired, maxEnergy); super(soundPath, name, MekanismUtils.getResource(ResourceType.GUI, "GuiAdvancedMachine.png"), perTick, ticksRequired, maxEnergy);
sideOutputs.add(new SideData(EnumColor.GREY, InventoryUtils.EMPTY)); configComponent = new TileComponentConfig(this, TransmissionType.ITEM);
sideOutputs.add(new SideData(EnumColor.DARK_RED, new int[] {0}));
sideOutputs.add(new SideData(EnumColor.PURPLE, new int[] {1}));
sideOutputs.add(new SideData(EnumColor.DARK_BLUE, new int[] {2}));
sideOutputs.add(new SideData(EnumColor.DARK_GREEN, new int[] {3}));
sideOutputs.add(new SideData(EnumColor.ORANGE, new int[] {4}));
sideConfig = new byte[] {2, 1, 0, 4, 5, 3}; configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.GREY, InventoryUtils.EMPTY));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_RED, new int[] {0}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.PURPLE, new int[] {1}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_BLUE, new int[] {2}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_GREEN, new int[] {3}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.ORANGE, new int[] {4}));
configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 4, 5, 3});
gasTank = new GasTank(MAX_GAS); gasTank = new GasTank(MAX_GAS);
@ -83,7 +87,7 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
secondaryEnergyPerTick = secondaryPerTick; secondaryEnergyPerTick = secondaryPerTick;
upgradeComponent = new TileComponentUpgrade(this, 4); upgradeComponent = new TileComponentUpgrade(this, 4);
ejectorComponent = new TileComponentEjector(this, sideOutputs.get(3)); ejectorComponent = new TileComponentEjector(this, configComponent.getOutputs(TransmissionType.ITEM).get(3));
} }
public void upgrade(RecipeType type) public void upgrade(RecipeType type)
@ -100,7 +104,6 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
factory.redstone = redstone; factory.redstone = redstone;
factory.redstoneLastTick = redstoneLastTick; factory.redstoneLastTick = redstoneLastTick;
factory.doAutoSync = doAutoSync; factory.doAutoSync = doAutoSync;
factory.components = components;
//Electric //Electric
factory.electricityStored = electricityStored; factory.electricityStored = electricityStored;
@ -111,7 +114,6 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
factory.sound = sound; factory.sound = sound;
//Machine //Machine
factory.sideConfig = sideConfig;
factory.progress[0] = operatingTicks; factory.progress[0] = operatingTicks;
factory.updateDelay = updateDelay; factory.updateDelay = updateDelay;
factory.isActive = isActive; factory.isActive = isActive;
@ -122,7 +124,7 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
factory.upgradeComponent.setUpgradeSlot(0); factory.upgradeComponent.setUpgradeSlot(0);
factory.upgradeComponent.tileEntity = factory; factory.upgradeComponent.tileEntity = factory;
factory.ejectorComponent = ejectorComponent; factory.ejectorComponent = ejectorComponent;
factory.ejectorComponent.sideData = factory.sideOutputs.get(5); factory.ejectorComponent.sideData = factory.configComponent.getOutputs(TransmissionType.ITEM).get(5);
factory.ejectorComponent.tileEntity = factory; factory.ejectorComponent.tileEntity = factory;
factory.ejectorComponent.trackers = new int[factory.ejectorComponent.sideData.availableSlots.length]; factory.ejectorComponent.trackers = new int[factory.ejectorComponent.sideData.availableSlots.length];
factory.recipeType = type; factory.recipeType = type;

View file

@ -1,10 +1,13 @@
package mekanism.common.tile; package mekanism.common.tile;
import mekanism.api.EnumColor; import mekanism.api.EnumColor;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.SideData; import mekanism.common.SideData;
import mekanism.common.Tier.FactoryTier; import mekanism.common.Tier.FactoryTier;
import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.tile.component.TileComponentConfig;
import mekanism.common.tile.component.TileComponentEjector; import mekanism.common.tile.component.TileComponentEjector;
import mekanism.common.tile.component.TileComponentUpgrade;
import mekanism.common.util.InventoryUtils; import mekanism.common.util.InventoryUtils;
public class TileEntityAdvancedFactory extends TileEntityFactory public class TileEntityAdvancedFactory extends TileEntityFactory
@ -13,13 +16,18 @@ public class TileEntityAdvancedFactory extends TileEntityFactory
{ {
super(FactoryTier.ADVANCED, MachineType.ADVANCED_FACTORY); super(FactoryTier.ADVANCED, MachineType.ADVANCED_FACTORY);
sideOutputs.add(new SideData(EnumColor.GREY, InventoryUtils.EMPTY)); configComponent = new TileComponentConfig(this, TransmissionType.ITEM);
sideOutputs.add(new SideData(EnumColor.ORANGE, new int[] {0}));
sideOutputs.add(new SideData(EnumColor.DARK_GREEN, new int[] {1}));
sideOutputs.add(new SideData(EnumColor.PURPLE, new int[] {4}));
sideOutputs.add(new SideData(EnumColor.DARK_RED, new int[] {5, 6, 7, 8, 9}));
sideOutputs.add(new SideData(EnumColor.DARK_BLUE, new int[] {10, 11, 12, 13, 14}));
ejectorComponent = new TileComponentEjector(this, sideOutputs.get(5)); configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.GREY, InventoryUtils.EMPTY));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.ORANGE, new int[] {0}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_GREEN, new int[] {1}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.PURPLE, new int[] {4}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_RED, new int[] {5, 6, 7, 8, 9}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_BLUE, new int[] {10, 11, 12, 13, 14}));
configComponent.setConfig(TransmissionType.ITEM, new byte[] {5, 4, 0, 3, 2, 1});
upgradeComponent = new TileComponentUpgrade(this, 0);
ejectorComponent = new TileComponentEjector(this, configComponent.getOutputs(TransmissionType.ITEM).get(5));
} }
} }

View file

@ -1,45 +1,38 @@
package mekanism.common.tile; package mekanism.common.tile;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList; import java.util.ArrayList;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.general;
import mekanism.api.Range4D; import mekanism.api.Range4D;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.SideData;
import mekanism.common.Upgrade; import mekanism.common.Upgrade;
import mekanism.common.base.IEjector; import mekanism.common.base.IEjector;
import mekanism.common.base.IElectricMachine; import mekanism.common.base.IElectricMachine;
import mekanism.common.base.IInvConfiguration;
import mekanism.common.base.IRedstoneControl; import mekanism.common.base.IRedstoneControl;
import mekanism.common.base.ISideConfiguration;
import mekanism.common.base.IUpgradeTile; import mekanism.common.base.IUpgradeTile;
import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.recipe.inputs.MachineInput; import mekanism.common.recipe.inputs.MachineInput;
import mekanism.common.recipe.machines.MachineRecipe; import mekanism.common.recipe.machines.MachineRecipe;
import mekanism.common.recipe.outputs.MachineOutput; import mekanism.common.recipe.outputs.MachineOutput;
import mekanism.common.tile.component.TileComponentConfig;
import mekanism.common.tile.component.TileComponentEjector; import mekanism.common.tile.component.TileComponentEjector;
import mekanism.common.tile.component.TileComponentUpgrade; import mekanism.common.tile.component.TileComponentUpgrade;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import cpw.mods.fml.common.Optional.Interface; import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.Method; import cpw.mods.fml.common.Optional.Method;
import io.netty.buffer.ByteBuf;
import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft") @Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
public abstract class TileEntityBasicMachine<INPUT extends MachineInput<INPUT>, OUTPUT extends MachineOutput<OUTPUT>, RECIPE extends MachineRecipe<INPUT, OUTPUT, RECIPE>> extends TileEntityNoisyElectricBlock implements IElectricMachine<INPUT, OUTPUT, RECIPE>, IPeripheral, IInvConfiguration, IUpgradeTile, IRedstoneControl public abstract class TileEntityBasicMachine<INPUT extends MachineInput<INPUT>, OUTPUT extends MachineOutput<OUTPUT>, RECIPE extends MachineRecipe<INPUT, OUTPUT, RECIPE>> extends TileEntityNoisyElectricBlock implements IElectricMachine<INPUT, OUTPUT, RECIPE>, IPeripheral, ISideConfiguration, IUpgradeTile, IRedstoneControl
{ {
/** This machine's side configuration. */
public byte[] sideConfig;
/** An arraylist of SideData for this machine. */
public ArrayList<SideData> sideOutputs = new ArrayList<SideData>();
/** How much energy this machine uses per tick, un-upgraded. */ /** How much energy this machine uses per tick, un-upgraded. */
public double BASE_ENERGY_PER_TICK; public double BASE_ENERGY_PER_TICK;
@ -77,6 +70,7 @@ public abstract class TileEntityBasicMachine<INPUT extends MachineInput<INPUT>,
public TileComponentUpgrade upgradeComponent; public TileComponentUpgrade upgradeComponent;
public TileComponentEjector ejectorComponent; public TileComponentEjector ejectorComponent;
public TileComponentConfig configComponent;
/** /**
* The foundation of all machines - a simple tile entity with a facing, active state, initialized state, sound effect, and animated texture. * The foundation of all machines - a simple tile entity with a facing, active state, initialized state, sound effect, and animated texture.
@ -136,14 +130,6 @@ public abstract class TileEntityBasicMachine<INPUT extends MachineInput<INPUT>,
operatingTicks = nbtTags.getInteger("operatingTicks"); operatingTicks = nbtTags.getInteger("operatingTicks");
clientActive = isActive = nbtTags.getBoolean("isActive"); clientActive = isActive = nbtTags.getBoolean("isActive");
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
if(nbtTags.hasKey("sideDataStored"))
{
for(int i = 0; i < 6; i++)
{
sideConfig[i] = nbtTags.getByte("config"+i);
}
}
} }
@Override @Override
@ -154,13 +140,6 @@ public abstract class TileEntityBasicMachine<INPUT extends MachineInput<INPUT>,
nbtTags.setInteger("operatingTicks", operatingTicks); nbtTags.setInteger("operatingTicks", operatingTicks);
nbtTags.setBoolean("isActive", isActive); nbtTags.setBoolean("isActive", isActive);
nbtTags.setInteger("controlType", controlType.ordinal()); nbtTags.setInteger("controlType", controlType.ordinal());
nbtTags.setBoolean("sideDataStored", true);
for(int i = 0; i < 6; i++)
{
nbtTags.setByte("config"+i, sideConfig[i]);
}
} }
@Override @Override
@ -173,11 +152,6 @@ public abstract class TileEntityBasicMachine<INPUT extends MachineInput<INPUT>,
ticksRequired = dataStream.readInt(); ticksRequired = dataStream.readInt();
controlType = RedstoneControl.values()[dataStream.readInt()]; controlType = RedstoneControl.values()[dataStream.readInt()];
for(int i = 0; i < 6; i++)
{
sideConfig[i] = dataStream.readByte();
}
if(updateDelay == 0 && clientActive != isActive) if(updateDelay == 0 && clientActive != isActive)
{ {
updateDelay = general.UPDATE_DELAY; updateDelay = general.UPDATE_DELAY;
@ -195,7 +169,6 @@ public abstract class TileEntityBasicMachine<INPUT extends MachineInput<INPUT>,
data.add(isActive); data.add(isActive);
data.add(ticksRequired); data.add(ticksRequired);
data.add(controlType.ordinal()); data.add(controlType.ordinal());
data.add(sideConfig);
return data; return data;
} }
@ -275,19 +248,13 @@ public abstract class TileEntityBasicMachine<INPUT extends MachineInput<INPUT>,
@Override @Override
public int[] getAccessibleSlotsFromSide(int side) public int[] getAccessibleSlotsFromSide(int side)
{ {
return sideOutputs.get(sideConfig[MekanismUtils.getBaseOrientation(side, facing)]).availableSlots; return configComponent.getOutput(TransmissionType.ITEM, side, facing).availableSlots;
} }
@Override @Override
public ArrayList<SideData> getSideData() public TileComponentConfig getConfig()
{ {
return sideOutputs; return configComponent;
}
@Override
public byte[] getConfiguration()
{
return sideConfig;
} }
@Override @Override

View file

@ -3,45 +3,46 @@ package mekanism.common.tile;
import java.util.Map; import java.util.Map;
import mekanism.api.EnumColor; import mekanism.api.EnumColor;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.MekanismItems; import mekanism.common.MekanismItems;
import mekanism.common.SideData; import mekanism.common.SideData;
import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.inputs.ItemStackInput;
import mekanism.common.recipe.machines.ChanceMachineRecipe; import mekanism.common.recipe.machines.ChanceMachineRecipe;
import mekanism.common.recipe.outputs.ChanceOutput; import mekanism.common.recipe.outputs.ChanceOutput;
import mekanism.common.tile.component.TileComponentConfig;
import mekanism.common.tile.component.TileComponentEjector; import mekanism.common.tile.component.TileComponentEjector;
import mekanism.common.tile.component.TileComponentUpgrade; import mekanism.common.tile.component.TileComponentUpgrade;
import mekanism.common.util.ChargeUtils; import mekanism.common.util.ChargeUtils;
import mekanism.common.util.InventoryUtils; import mekanism.common.util.InventoryUtils;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import cpw.mods.fml.common.Optional.Method; import cpw.mods.fml.common.Optional.Method;
import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IComputerAccess;
public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe<RECIPE>> extends TileEntityBasicMachine<ItemStackInput, ChanceOutput, RECIPE> public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe<RECIPE>> extends TileEntityBasicMachine<ItemStackInput, ChanceOutput, RECIPE>
{ {
public TileEntityChanceMachine(String soundPath, String name, ResourceLocation location, double perTick, int ticksRequired, double maxEnergy) public TileEntityChanceMachine(String soundPath, String name, ResourceLocation location, double perTick, int ticksRequired, double maxEnergy)
{ {
super(soundPath, name, location, perTick, ticksRequired, maxEnergy); super(soundPath, name, location, perTick, ticksRequired, maxEnergy);
sideOutputs.add(new SideData(EnumColor.GREY, InventoryUtils.EMPTY)); configComponent = new TileComponentConfig(this, TransmissionType.ITEM);
sideOutputs.add(new SideData(EnumColor.DARK_RED, new int[] {0}));
sideOutputs.add(new SideData(EnumColor.DARK_GREEN, new int[] {1}));
sideOutputs.add(new SideData(EnumColor.DARK_BLUE, new int[] {2, 4}));
sideOutputs.add(new SideData(EnumColor.ORANGE, new int[] {3}));
sideConfig = new byte[] {2, 1, 0, 0, 4, 3}; configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.GREY, InventoryUtils.EMPTY));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_RED, new int[] {0}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_GREEN, new int[] {1}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_BLUE, new int[] {2, 4}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.ORANGE, new int[] {3}));
configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 0, 4, 3});
inventory = new ItemStack[5]; inventory = new ItemStack[5];
upgradeComponent = new TileComponentUpgrade(this, 3); upgradeComponent = new TileComponentUpgrade(this, 3);
ejectorComponent = new TileComponentEjector(this, sideOutputs.get(3)); ejectorComponent = new TileComponentEjector(this, configComponent.getOutputs(TransmissionType.ITEM).get(3));
} }
@Override @Override

View file

@ -16,13 +16,14 @@ import mekanism.api.gas.GasTransmission;
import mekanism.api.gas.IGasHandler; import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.IGasItem; import mekanism.api.gas.IGasItem;
import mekanism.api.gas.ITubeConnection; import mekanism.api.gas.ITubeConnection;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.SideData; import mekanism.common.SideData;
import mekanism.common.Upgrade; import mekanism.common.Upgrade;
import mekanism.common.base.IDropperHandler; import mekanism.common.base.IDropperHandler;
import mekanism.common.base.IEjector; import mekanism.common.base.IEjector;
import mekanism.common.base.IInvConfiguration;
import mekanism.common.base.IRedstoneControl; import mekanism.common.base.IRedstoneControl;
import mekanism.common.base.ISideConfiguration;
import mekanism.common.base.ISustainedData; import mekanism.common.base.ISustainedData;
import mekanism.common.base.IUpgradeTile; import mekanism.common.base.IUpgradeTile;
import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.block.BlockMachine.MachineType;
@ -30,6 +31,7 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.inputs.GasInput; import mekanism.common.recipe.inputs.GasInput;
import mekanism.common.recipe.machines.CrystallizerRecipe; import mekanism.common.recipe.machines.CrystallizerRecipe;
import mekanism.common.tile.component.TileComponentConfig;
import mekanism.common.tile.component.TileComponentEjector; import mekanism.common.tile.component.TileComponentEjector;
import mekanism.common.tile.component.TileComponentUpgrade; import mekanism.common.tile.component.TileComponentUpgrade;
import mekanism.common.util.ChargeUtils; import mekanism.common.util.ChargeUtils;
@ -43,14 +45,10 @@ import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidRegistry;
public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock implements IGasHandler, ITubeConnection, IRedstoneControl, IInvConfiguration, IUpgradeTile, ISustainedData, IDropperHandler public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock implements IGasHandler, ITubeConnection, IRedstoneControl, ISideConfiguration, IUpgradeTile, ISustainedData, IDropperHandler
{ {
public static final int MAX_GAS = 10000; public static final int MAX_GAS = 10000;
public byte[] sideConfig = new byte[] {0, 3, 0, 0, 1, 2};
public ArrayList<SideData> sideOutputs = new ArrayList<SideData>();
public GasTank inputTank = new GasTank(MAX_GAS); public GasTank inputTank = new GasTank(MAX_GAS);
public int updateDelay; public int updateDelay;
@ -80,20 +78,27 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
/** This machine's current RedstoneControl type. */ /** This machine's current RedstoneControl type. */
public RedstoneControl controlType = RedstoneControl.DISABLED; public RedstoneControl controlType = RedstoneControl.DISABLED;
public TileComponentUpgrade upgradeComponent;
public TileComponentEjector ejectorComponent; public TileComponentEjector ejectorComponent;
public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 3); public TileComponentConfig configComponent;
public TileEntityChemicalCrystallizer() public TileEntityChemicalCrystallizer()
{ {
super("crystallizer", "ChemicalCrystallizer", MachineType.CHEMICAL_CRYSTALLIZER.baseEnergy); super("crystallizer", "ChemicalCrystallizer", MachineType.CHEMICAL_CRYSTALLIZER.baseEnergy);
sideOutputs.add(new SideData(EnumColor.GREY, InventoryUtils.EMPTY)); configComponent = new TileComponentConfig(this, TransmissionType.ITEM);
sideOutputs.add(new SideData(EnumColor.PURPLE, new int[] {0}));
sideOutputs.add(new SideData(EnumColor.DARK_BLUE, new int[] {1})); configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.GREY, InventoryUtils.EMPTY));
sideOutputs.add(new SideData(EnumColor.DARK_GREEN, new int[] {2})); configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.PURPLE, new int[] {0}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_BLUE, new int[] {1}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_GREEN, new int[] {2}));
configComponent.setConfig(TransmissionType.ITEM, new byte[] {0, 3, 0, 0, 1, 2});
inventory = new ItemStack[4]; inventory = new ItemStack[4];
ejectorComponent = new TileComponentEjector(this, sideOutputs.get(2));
upgradeComponent = new TileComponentUpgrade(this, 3);
ejectorComponent = new TileComponentEjector(this, configComponent.getOutputs(TransmissionType.ITEM).get(2));
} }
@Override @Override
@ -218,12 +223,6 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
isActive = dataStream.readBoolean(); isActive = dataStream.readBoolean();
operatingTicks = dataStream.readInt(); operatingTicks = dataStream.readInt();
for(int i = 0; i < 6; i++)
{
sideConfig[i] = dataStream.readByte();
}
controlType = RedstoneControl.values()[dataStream.readInt()]; controlType = RedstoneControl.values()[dataStream.readInt()];
if(dataStream.readBoolean()) if(dataStream.readBoolean())
@ -245,7 +244,6 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
data.add(isActive); data.add(isActive);
data.add(operatingTicks); data.add(operatingTicks);
data.add(sideConfig);
data.add(controlType.ordinal()); data.add(controlType.ordinal());
if(inputTank.getGas() != null) if(inputTank.getGas() != null)
@ -271,14 +269,6 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
inputTank.read(nbtTags.getCompoundTag("rightTank")); inputTank.read(nbtTags.getCompoundTag("rightTank"));
if(nbtTags.hasKey("sideDataStored"))
{
for(int i = 0; i < 6; i++)
{
sideConfig[i] = nbtTags.getByte("config"+i);
}
}
} }
@Override @Override
@ -293,11 +283,6 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
nbtTags.setTag("rightTank", inputTank.write(new NBTTagCompound())); nbtTags.setTag("rightTank", inputTank.write(new NBTTagCompound()));
nbtTags.setBoolean("sideDataStored", true); nbtTags.setBoolean("sideDataStored", true);
for(int i = 0; i < 6; i++)
{
nbtTags.setByte("config"+i, sideConfig[i]);
}
} }
@Override @Override
@ -434,32 +419,13 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
@Override @Override
public int[] getAccessibleSlotsFromSide(int side) public int[] getAccessibleSlotsFromSide(int side)
{ {
if(side == MekanismUtils.getLeft(facing).ordinal()) return configComponent.getOutput(TransmissionType.ITEM, side, facing).availableSlots;
{
return new int[] {0};
}
else if(side == MekanismUtils.getRight(facing).ordinal())
{
return new int[] {1};
}
else if(side == 0 || side == 1)
{
return new int[2];
}
return InventoryUtils.EMPTY;
} }
@Override @Override
public ArrayList<SideData> getSideData() public TileComponentConfig getConfig()
{ {
return sideOutputs; return configComponent;
}
@Override
public byte[] getConfiguration()
{
return sideConfig;
} }
@Override @Override

View file

@ -5,6 +5,7 @@ import java.util.ArrayList;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.api.EnumColor; import mekanism.api.EnumColor;
import mekanism.api.Range4D; import mekanism.api.Range4D;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.MekanismBlocks; import mekanism.common.MekanismBlocks;
import mekanism.common.MekanismItems; import mekanism.common.MekanismItems;
@ -16,6 +17,7 @@ import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.inputs.ItemStackInput;
import mekanism.common.recipe.machines.BasicMachineRecipe; import mekanism.common.recipe.machines.BasicMachineRecipe;
import mekanism.common.recipe.outputs.ItemStackOutput; import mekanism.common.recipe.outputs.ItemStackOutput;
import mekanism.common.tile.component.TileComponentConfig;
import mekanism.common.tile.component.TileComponentEjector; import mekanism.common.tile.component.TileComponentEjector;
import mekanism.common.tile.component.TileComponentUpgrade; import mekanism.common.tile.component.TileComponentUpgrade;
import mekanism.common.util.ChargeUtils; import mekanism.common.util.ChargeUtils;
@ -44,18 +46,20 @@ public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecip
{ {
super(soundPath, name, MekanismUtils.getResource(ResourceType.GUI, "GuiBasicMachine.png"), perTick, ticksRequired, maxEnergy); super(soundPath, name, MekanismUtils.getResource(ResourceType.GUI, "GuiBasicMachine.png"), perTick, ticksRequired, maxEnergy);
sideOutputs.add(new SideData(EnumColor.GREY, InventoryUtils.EMPTY)); configComponent = new TileComponentConfig(this, TransmissionType.ITEM);
sideOutputs.add(new SideData(EnumColor.DARK_RED, new int[] {0}));
sideOutputs.add(new SideData(EnumColor.DARK_GREEN, new int[] {1}));
sideOutputs.add(new SideData(EnumColor.DARK_BLUE, new int[] {2}));
sideOutputs.add(new SideData(EnumColor.ORANGE, new int[] {3}));
sideConfig = new byte[] {2, 1, 0, 0, 4, 3}; configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.GREY, InventoryUtils.EMPTY));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_RED, new int[] {0}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_GREEN, new int[] {1}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_BLUE, new int[] {2}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.ORANGE, new int[] {3}));
configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 0, 4, 3});
inventory = new ItemStack[4]; inventory = new ItemStack[4];
upgradeComponent = new TileComponentUpgrade(this, 3); upgradeComponent = new TileComponentUpgrade(this, 3);
ejectorComponent = new TileComponentEjector(this, sideOutputs.get(3)); ejectorComponent = new TileComponentEjector(this, configComponent.getOutputs(TransmissionType.ITEM).get(3));
} }
public void upgrade(RecipeType type) public void upgrade(RecipeType type)
@ -72,7 +76,6 @@ public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecip
factory.redstone = redstone; factory.redstone = redstone;
factory.redstoneLastTick = redstoneLastTick; factory.redstoneLastTick = redstoneLastTick;
factory.doAutoSync = doAutoSync; factory.doAutoSync = doAutoSync;
factory.components = components;
//Electric //Electric
factory.electricityStored = electricityStored; factory.electricityStored = electricityStored;
@ -83,7 +86,6 @@ public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecip
factory.sound = sound; factory.sound = sound;
//Machine //Machine
factory.sideConfig = sideConfig;
factory.progress[0] = operatingTicks; factory.progress[0] = operatingTicks;
factory.updateDelay = updateDelay; factory.updateDelay = updateDelay;
factory.isActive = isActive; factory.isActive = isActive;
@ -94,7 +96,7 @@ public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecip
factory.upgradeComponent.setUpgradeSlot(0); factory.upgradeComponent.setUpgradeSlot(0);
factory.upgradeComponent.tileEntity = factory; factory.upgradeComponent.tileEntity = factory;
factory.ejectorComponent = ejectorComponent; factory.ejectorComponent = ejectorComponent;
factory.ejectorComponent.sideData = factory.sideOutputs.get(5); factory.ejectorComponent.sideData = factory.configComponent.getOutputs(TransmissionType.ITEM).get(5);
factory.ejectorComponent.tileEntity = factory; factory.ejectorComponent.tileEntity = factory;
factory.ejectorComponent.trackers = new int[factory.ejectorComponent.sideData.availableSlots.length]; factory.ejectorComponent.trackers = new int[factory.ejectorComponent.sideData.availableSlots.length];
factory.recipeType = type; factory.recipeType = type;

View file

@ -1,10 +1,13 @@
package mekanism.common.tile; package mekanism.common.tile;
import mekanism.api.EnumColor; import mekanism.api.EnumColor;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.SideData; import mekanism.common.SideData;
import mekanism.common.Tier.FactoryTier; import mekanism.common.Tier.FactoryTier;
import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.tile.component.TileComponentConfig;
import mekanism.common.tile.component.TileComponentEjector; import mekanism.common.tile.component.TileComponentEjector;
import mekanism.common.tile.component.TileComponentUpgrade;
import mekanism.common.util.InventoryUtils; import mekanism.common.util.InventoryUtils;
public class TileEntityEliteFactory extends TileEntityFactory public class TileEntityEliteFactory extends TileEntityFactory
@ -13,13 +16,18 @@ public class TileEntityEliteFactory extends TileEntityFactory
{ {
super(FactoryTier.ELITE, MachineType.ELITE_FACTORY); super(FactoryTier.ELITE, MachineType.ELITE_FACTORY);
sideOutputs.add(new SideData(EnumColor.GREY, InventoryUtils.EMPTY)); configComponent = new TileComponentConfig(this, TransmissionType.ITEM);
sideOutputs.add(new SideData(EnumColor.ORANGE, new int[] {0}));
sideOutputs.add(new SideData(EnumColor.DARK_GREEN, new int[] {1}));
sideOutputs.add(new SideData(EnumColor.PURPLE, new int[] {4}));
sideOutputs.add(new SideData(EnumColor.DARK_RED, new int[] {5, 6, 7, 8, 9, 10, 11}));
sideOutputs.add(new SideData(EnumColor.DARK_BLUE, new int[] {12, 13, 14, 15, 16, 17, 18}));
ejectorComponent = new TileComponentEjector(this, sideOutputs.get(5)); configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.GREY, InventoryUtils.EMPTY));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.ORANGE, new int[] {0}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_GREEN, new int[] {1}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.PURPLE, new int[] {4}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_RED, new int[] {5, 6, 7, 8, 9, 10, 11}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_BLUE, new int[] {12, 13, 14, 15, 16, 17, 18}));
configComponent.setConfig(TransmissionType.ITEM, new byte[] {5, 4, 0, 3, 2, 1});
upgradeComponent = new TileComponentUpgrade(this, 0);
ejectorComponent = new TileComponentEjector(this, configComponent.getOutputs(TransmissionType.ITEM).get(5));
} }
} }

View file

@ -17,6 +17,7 @@ import mekanism.api.gas.GasTransmission;
import mekanism.api.gas.IGasHandler; import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.IGasItem; import mekanism.api.gas.IGasItem;
import mekanism.api.gas.ITubeConnection; import mekanism.api.gas.ITubeConnection;
import mekanism.api.transmitters.TransmissionType;
import mekanism.api.util.StackUtils; import mekanism.api.util.StackUtils;
import mekanism.client.sound.IResettableSound; import mekanism.client.sound.IResettableSound;
import mekanism.client.sound.TileSound; import mekanism.client.sound.TileSound;
@ -28,13 +29,14 @@ import mekanism.common.Tier.FactoryTier;
import mekanism.common.Upgrade; import mekanism.common.Upgrade;
import mekanism.common.base.IEjector; import mekanism.common.base.IEjector;
import mekanism.common.base.IFactory.RecipeType; import mekanism.common.base.IFactory.RecipeType;
import mekanism.common.base.IInvConfiguration;
import mekanism.common.base.IRedstoneControl; import mekanism.common.base.IRedstoneControl;
import mekanism.common.base.ISideConfiguration;
import mekanism.common.base.IUpgradeTile; import mekanism.common.base.IUpgradeTile;
import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.recipe.machines.AdvancedMachineRecipe; import mekanism.common.recipe.machines.AdvancedMachineRecipe;
import mekanism.common.recipe.machines.BasicMachineRecipe; import mekanism.common.recipe.machines.BasicMachineRecipe;
import mekanism.common.tile.component.TileComponentConfig;
import mekanism.common.tile.component.TileComponentEjector; import mekanism.common.tile.component.TileComponentEjector;
import mekanism.common.tile.component.TileComponentUpgrade; import mekanism.common.tile.component.TileComponentUpgrade;
import mekanism.common.util.ChargeUtils; import mekanism.common.util.ChargeUtils;
@ -53,17 +55,11 @@ import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft") @Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
public class TileEntityFactory extends TileEntityNoisyElectricBlock implements IPeripheral, IInvConfiguration, IUpgradeTile, IRedstoneControl, IGasHandler, ITubeConnection public class TileEntityFactory extends TileEntityNoisyElectricBlock implements IPeripheral, ISideConfiguration, IUpgradeTile, IRedstoneControl, IGasHandler, ITubeConnection
{ {
/** This Factory's tier. */ /** This Factory's tier. */
public FactoryTier tier; public FactoryTier tier;
/** This machine's side configuration. */
public byte[] sideConfig = new byte[] {5, 4, 0, 3, 2, 1};
/** An arraylist of SideData for this machine. */
public ArrayList<SideData> sideOutputs = new ArrayList<SideData>();
/** An int[] used to track all current operations' progress. */ /** An int[] used to track all current operations' progress. */
public int[] progress; public int[] progress;
@ -114,21 +110,27 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
/** This machine's current RedstoneControl type. */ /** This machine's current RedstoneControl type. */
public RedstoneControl controlType = RedstoneControl.DISABLED; public RedstoneControl controlType = RedstoneControl.DISABLED;
public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 0); public TileComponentUpgrade upgradeComponent;
public TileComponentEjector ejectorComponent; public TileComponentEjector ejectorComponent;
public TileComponentConfig configComponent;
public TileEntityFactory() public TileEntityFactory()
{ {
this(FactoryTier.BASIC, MachineType.BASIC_FACTORY); this(FactoryTier.BASIC, MachineType.BASIC_FACTORY);
sideOutputs.add(new SideData(EnumColor.GREY, InventoryUtils.EMPTY)); configComponent = new TileComponentConfig(this, TransmissionType.ITEM);
sideOutputs.add(new SideData(EnumColor.ORANGE, new int[] {0}));
sideOutputs.add(new SideData(EnumColor.DARK_GREEN, new int[] {1}));
sideOutputs.add(new SideData(EnumColor.PURPLE, new int[] {4}));
sideOutputs.add(new SideData(EnumColor.DARK_RED, new int[] {5, 6, 7}));
sideOutputs.add(new SideData(EnumColor.DARK_BLUE, new int[] {8, 9, 10}));
ejectorComponent = new TileComponentEjector(this, sideOutputs.get(5)); configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.GREY, InventoryUtils.EMPTY));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.ORANGE, new int[] {0}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_GREEN, new int[] {1}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.PURPLE, new int[] {4}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_RED, new int[] {5, 6, 7}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_BLUE, new int[] {8, 9, 10}));
configComponent.setConfig(TransmissionType.ITEM, new byte[] {5, 4, 0, 3, 2, 1});
upgradeComponent = new TileComponentUpgrade(this, 0);
ejectorComponent = new TileComponentEjector(this, configComponent.getOutputs(TransmissionType.ITEM).get(5));
} }
public TileEntityFactory(FactoryTier type, MachineType machine) public TileEntityFactory(FactoryTier type, MachineType machine)
@ -157,7 +159,6 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
factory.redstone = redstone; factory.redstone = redstone;
factory.redstoneLastTick = redstoneLastTick; factory.redstoneLastTick = redstoneLastTick;
factory.doAutoSync = doAutoSync; factory.doAutoSync = doAutoSync;
factory.components = components;
//Electric //Electric
factory.electricityStored = electricityStored; factory.electricityStored = electricityStored;
@ -168,7 +169,6 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
factory.sound = sound; factory.sound = sound;
//Factory //Factory
factory.sideConfig = sideConfig;
for(int i = 0; i < tier.processes; i++) for(int i = 0; i < tier.processes; i++)
{ {
@ -189,7 +189,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
factory.upgradeComponent.tileEntity = factory; factory.upgradeComponent.tileEntity = factory;
factory.ejectorComponent = ejectorComponent; factory.ejectorComponent = ejectorComponent;
factory.ejectorComponent.tileEntity = factory; factory.ejectorComponent.tileEntity = factory;
factory.ejectorComponent.sideData = factory.sideOutputs.get(5); factory.ejectorComponent.sideData = factory.configComponent.getOutputs(TransmissionType.ITEM).get(5);
factory.ejectorComponent.trackers = new int[factory.ejectorComponent.sideData.availableSlots.length]; factory.ejectorComponent.trackers = new int[factory.ejectorComponent.sideData.availableSlots.length];
for(int i = 0; i < tier.processes+5; i++) for(int i = 0; i < tier.processes+5; i++)
@ -676,11 +676,6 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
progress[i] = dataStream.readInt(); progress[i] = dataStream.readInt();
} }
for(int i = 0; i < 6; i++)
{
sideConfig[i] = dataStream.readByte();
}
if(dataStream.readBoolean()) if(dataStream.readBoolean())
{ {
gasTank.setGas(new GasStack(dataStream.readInt(), dataStream.readInt())); gasTank.setGas(new GasStack(dataStream.readInt(), dataStream.readInt()));
@ -727,14 +722,6 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
progress[i] = nbtTags.getInteger("progress" + i); progress[i] = nbtTags.getInteger("progress" + i);
} }
if(nbtTags.hasKey("sideDataStored"))
{
for(int i = 0; i < 6; i++)
{
sideConfig[i] = nbtTags.getByte("config"+i);
}
}
gasTank.read(nbtTags.getCompoundTag("gasTank")); gasTank.read(nbtTags.getCompoundTag("gasTank"));
} }
@ -754,13 +741,6 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
nbtTags.setInteger("progress" + i, progress[i]); nbtTags.setInteger("progress" + i, progress[i]);
} }
nbtTags.setBoolean("sideDataStored", true);
for(int i = 0; i < 6; i++)
{
nbtTags.setByte("config"+i, sideConfig[i]);
}
nbtTags.setTag("gasTank", gasTank.write(new NBTTagCompound())); nbtTags.setTag("gasTank", gasTank.write(new NBTTagCompound()));
} }
@ -776,7 +756,6 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
data.add(sorting); data.add(sorting);
data.add(upgraded); data.add(upgraded);
data.add(progress); data.add(progress);
data.add(sideConfig);
if(gasTank.getGas() != null) if(gasTank.getGas() != null)
{ {
@ -909,7 +888,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
@Override @Override
public int[] getAccessibleSlotsFromSide(int side) public int[] getAccessibleSlotsFromSide(int side)
{ {
return sideOutputs.get(sideConfig[MekanismUtils.getBaseOrientation(side, facing)]).availableSlots; return configComponent.getOutput(TransmissionType.ITEM, side, facing).availableSlots;
} }
@Override @Override
@ -919,15 +898,9 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
} }
@Override @Override
public ArrayList<SideData> getSideData() public TileComponentConfig getConfig()
{ {
return sideOutputs; return configComponent;
}
@Override
public byte[] getConfiguration()
{
return sideConfig;
} }
@Override @Override

View file

@ -1,5 +1,7 @@
package mekanism.common.tile; package mekanism.common.tile;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList; import java.util.ArrayList;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
@ -9,6 +11,7 @@ import mekanism.api.MekanismConfig.usage;
import mekanism.api.Range4D; import mekanism.api.Range4D;
import mekanism.api.infuse.InfuseObject; import mekanism.api.infuse.InfuseObject;
import mekanism.api.infuse.InfuseRegistry; import mekanism.api.infuse.InfuseRegistry;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.InfuseStorage; import mekanism.common.InfuseStorage;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.MekanismItems; import mekanism.common.MekanismItems;
@ -16,8 +19,8 @@ import mekanism.common.PacketHandler;
import mekanism.common.SideData; import mekanism.common.SideData;
import mekanism.common.Upgrade; import mekanism.common.Upgrade;
import mekanism.common.base.IEjector; import mekanism.common.base.IEjector;
import mekanism.common.base.IInvConfiguration;
import mekanism.common.base.IRedstoneControl; import mekanism.common.base.IRedstoneControl;
import mekanism.common.base.ISideConfiguration;
import mekanism.common.base.IUpgradeTile; import mekanism.common.base.IUpgradeTile;
import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.network.PacketTileEntity.TileEntityMessage;
@ -25,33 +28,24 @@ import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.RecipeHandler.Recipe; import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.InfusionInput; import mekanism.common.recipe.inputs.InfusionInput;
import mekanism.common.recipe.machines.MetallurgicInfuserRecipe; import mekanism.common.recipe.machines.MetallurgicInfuserRecipe;
import mekanism.common.tile.component.TileComponentConfig;
import mekanism.common.tile.component.TileComponentEjector; import mekanism.common.tile.component.TileComponentEjector;
import mekanism.common.tile.component.TileComponentUpgrade; import mekanism.common.tile.component.TileComponentUpgrade;
import mekanism.common.util.ChargeUtils; import mekanism.common.util.ChargeUtils;
import mekanism.common.util.InventoryUtils; import mekanism.common.util.InventoryUtils;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.common.Optional.Interface; import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.Method; import cpw.mods.fml.common.Optional.Method;
import io.netty.buffer.ByteBuf;
import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft") @Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock implements IPeripheral, IInvConfiguration, IUpgradeTile, IRedstoneControl public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock implements IPeripheral, ISideConfiguration, IUpgradeTile, IRedstoneControl
{ {
/** This machine's side configuration. */
public byte[] sideConfig = new byte[] {2, 1, 0, 5, 3, 4};
/** An arraylist of SideData for this machine. */
public ArrayList<SideData> sideOutputs = new ArrayList<SideData>();
/** The maxiumum amount of infuse this machine can store. */ /** The maxiumum amount of infuse this machine can store. */
public int MAX_INFUSE = 1000; public int MAX_INFUSE = 1000;
@ -86,22 +80,29 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
/** This machine's current RedstoneControl type. */ /** This machine's current RedstoneControl type. */
public RedstoneControl controlType = RedstoneControl.DISABLED; public RedstoneControl controlType = RedstoneControl.DISABLED;
public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 4); public TileComponentUpgrade upgradeComponent;
public TileComponentEjector ejectorComponent; public TileComponentEjector ejectorComponent;
public TileComponentConfig configComponent;
public TileEntityMetallurgicInfuser() public TileEntityMetallurgicInfuser()
{ {
super("metalinfuser", "MetallurgicInfuser", MachineType.METALLURGIC_INFUSER.baseEnergy); super("metalinfuser", "MetallurgicInfuser", MachineType.METALLURGIC_INFUSER.baseEnergy);
sideOutputs.add(new SideData(EnumColor.GREY, InventoryUtils.EMPTY)); configComponent = new TileComponentConfig(this, TransmissionType.ITEM);
sideOutputs.add(new SideData(EnumColor.ORANGE, new int[] {0}));
sideOutputs.add(new SideData(EnumColor.PURPLE, new int[] {1})); configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.GREY, InventoryUtils.EMPTY));
sideOutputs.add(new SideData(EnumColor.DARK_RED, new int[] {2})); configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.ORANGE, new int[] {0}));
sideOutputs.add(new SideData(EnumColor.DARK_BLUE, new int[] {3})); configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.PURPLE, new int[] {1}));
sideOutputs.add(new SideData(EnumColor.DARK_GREEN, new int[] {4})); configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_RED, new int[] {2}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_BLUE, new int[] {3}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_GREEN, new int[] {4}));
configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 5, 3, 4});
inventory = new ItemStack[5]; inventory = new ItemStack[5];
ejectorComponent = new TileComponentEjector(this, sideOutputs.get(4));
upgradeComponent = new TileComponentUpgrade(this, 3);
ejectorComponent = new TileComponentEjector(this, configComponent.getOutputs(TransmissionType.ITEM).get(4));
} }
@Override @Override
@ -295,14 +296,6 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
infuseStored.amount = nbtTags.getInteger("infuseStored"); infuseStored.amount = nbtTags.getInteger("infuseStored");
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
infuseStored.type = InfuseRegistry.get(nbtTags.getString("type")); infuseStored.type = InfuseRegistry.get(nbtTags.getString("type"));
if(nbtTags.hasKey("sideDataStored"))
{
for(int i = 0; i < 6; i++)
{
sideConfig[i] = nbtTags.getByte("config"+i);
}
}
} }
@Override @Override
@ -324,11 +317,6 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
} }
nbtTags.setBoolean("sideDataStored", true); nbtTags.setBoolean("sideDataStored", true);
for(int i = 0; i < 6; i++)
{
nbtTags.setByte("config"+i, sideConfig[i]);
}
} }
@Override @Override
@ -348,11 +336,6 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
controlType = RedstoneControl.values()[dataStream.readInt()]; controlType = RedstoneControl.values()[dataStream.readInt()];
infuseStored.type = InfuseRegistry.get(PacketHandler.readString(dataStream)); infuseStored.type = InfuseRegistry.get(PacketHandler.readString(dataStream));
for(int i = 0; i < 6; i++)
{
sideConfig[i] = dataStream.readByte();
}
if(updateDelay == 0 && clientActive != isActive) if(updateDelay == 0 && clientActive != isActive)
{ {
updateDelay = general.UPDATE_DELAY; updateDelay = general.UPDATE_DELAY;
@ -379,7 +362,6 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
data.add("null"); data.add("null");
} }
data.add(sideConfig);
return data; return data;
} }
@ -443,7 +425,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
@Override @Override
public int[] getAccessibleSlotsFromSide(int side) public int[] getAccessibleSlotsFromSide(int side)
{ {
return sideOutputs.get(sideConfig[MekanismUtils.getBaseOrientation(side, facing)]).availableSlots; return configComponent.getOutput(TransmissionType.ITEM, side, facing).availableSlots;
} }
@Override @Override
@ -473,15 +455,9 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
} }
@Override @Override
public ArrayList<SideData> getSideData() public TileComponentConfig getConfig()
{ {
return sideOutputs; return configComponent;
}
@Override
public byte[] getConfiguration()
{
return sideConfig;
} }
@Override @Override

View file

@ -14,6 +14,7 @@ import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank; import mekanism.api.gas.GasTank;
import mekanism.api.gas.IGasHandler; import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.ITubeConnection; import mekanism.api.gas.ITubeConnection;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.SideData; import mekanism.common.SideData;
import mekanism.common.Upgrade; import mekanism.common.Upgrade;
import mekanism.common.base.IDropperHandler; import mekanism.common.base.IDropperHandler;
@ -24,6 +25,7 @@ import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.inputs.PressurizedInput; import mekanism.common.recipe.inputs.PressurizedInput;
import mekanism.common.recipe.machines.PressurizedRecipe; import mekanism.common.recipe.machines.PressurizedRecipe;
import mekanism.common.recipe.outputs.PressurizedProducts; import mekanism.common.recipe.outputs.PressurizedProducts;
import mekanism.common.tile.component.TileComponentConfig;
import mekanism.common.tile.component.TileComponentEjector; import mekanism.common.tile.component.TileComponentEjector;
import mekanism.common.tile.component.TileComponentUpgrade; import mekanism.common.tile.component.TileComponentUpgrade;
import mekanism.common.util.ChargeUtils; import mekanism.common.util.ChargeUtils;
@ -57,18 +59,20 @@ public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, Pres
{ {
super("prc", "PressurizedReactionChamber", new ResourceLocation("mekanism", "gui/GuiPRC.png"), usage.pressurizedReactionBaseUsage, 100, MachineType.PRESSURIZED_REACTION_CHAMBER.baseEnergy); super("prc", "PressurizedReactionChamber", new ResourceLocation("mekanism", "gui/GuiPRC.png"), usage.pressurizedReactionBaseUsage, 100, MachineType.PRESSURIZED_REACTION_CHAMBER.baseEnergy);
sideOutputs.add(new SideData(EnumColor.GREY, InventoryUtils.EMPTY)); configComponent = new TileComponentConfig(this, TransmissionType.ITEM);
sideOutputs.add(new SideData(EnumColor.DARK_RED, new int[] {0}));
sideOutputs.add(new SideData(EnumColor.DARK_GREEN, new int[] {1}));
sideOutputs.add(new SideData(EnumColor.DARK_BLUE, new int[] {2}));
sideOutputs.add(new SideData(EnumColor.ORANGE, new int[] {3}));
sideConfig = new byte[] {2, 1, 0, 0, 0, 3}; configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.GREY, InventoryUtils.EMPTY));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_RED, new int[] {0}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_GREEN, new int[] {1}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_BLUE, new int[] {2}));
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.ORANGE, new int[] {3}));
configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 0, 0, 3});
inventory = new ItemStack[4]; inventory = new ItemStack[4];
upgradeComponent = new TileComponentUpgrade(this, 3); upgradeComponent = new TileComponentUpgrade(this, 3);
ejectorComponent = new TileComponentEjector(this, sideOutputs.get(3)); ejectorComponent = new TileComponentEjector(this, configComponent.getOutputs(TransmissionType.ITEM).get(3));
} }
@Override @Override

View file

@ -0,0 +1,116 @@
package mekanism.common.tile.component;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.SideData;
import mekanism.common.base.ITileComponent;
import mekanism.common.tile.TileEntityContainerBlock;
import mekanism.common.util.MekanismUtils;
import net.minecraft.nbt.NBTTagCompound;
public class TileComponentConfig implements ITileComponent
{
public TileEntityContainerBlock tileEntity;
public List<byte[]> sideConfigs = new ArrayList<byte[]>();
public List<ArrayList<SideData>> sideOutputs = new ArrayList<ArrayList<SideData>>();
public List<TransmissionType> transmissions = new ArrayList<TransmissionType>();
public TileComponentConfig(TileEntityContainerBlock tile, TransmissionType... types)
{
tileEntity = tile;
transmissions = Arrays.asList(types);
tile.components.add(this);
}
public void setConfig(TransmissionType type, byte[] config)
{
sideConfigs.set(type.ordinal(), config);
}
public void addOutput(TransmissionType type, SideData data)
{
if(sideOutputs.get(type.ordinal()) == null)
{
sideOutputs.set(type.ordinal(), new ArrayList<SideData>());
}
sideOutputs.get(type.ordinal()).add(data);
}
public ArrayList<SideData> getOutputs(TransmissionType type)
{
return sideOutputs.get(type.ordinal());
}
public byte[] getConfig(TransmissionType type)
{
return sideConfigs.get(type.ordinal());
}
public SideData getOutput(TransmissionType type, int side, int facing)
{
return getOutputs(type).get(getConfig(type)[MekanismUtils.getBaseOrientation(side, facing)]);
}
public SideData getOutput(TransmissionType type, int side)
{
return getOutputs(type).get(getConfig(type)[side]);
}
public boolean supports(TransmissionType type)
{
return transmissions.contains(type);
}
@Override
public void tick() {}
@Override
public void read(NBTTagCompound nbtTags)
{
if(nbtTags.getBoolean("sideDataStored"))
{
for(TransmissionType type : transmissions)
{
sideConfigs.set(type.ordinal(), nbtTags.getByteArray("config" + type.ordinal()));
}
}
}
@Override
public void read(ByteBuf dataStream)
{
for(TransmissionType type : transmissions)
{
dataStream.readBytes(sideConfigs.get(type.ordinal()));
}
}
@Override
public void write(NBTTagCompound nbtTags)
{
for(TransmissionType type : transmissions)
{
nbtTags.setByteArray("config" + type.ordinal(), sideConfigs.get(type.ordinal()));
}
nbtTags.setBoolean("sideDataStored", true);
}
@Override
public void write(ArrayList data)
{
for(TransmissionType type : transmissions)
{
data.add(sideConfigs.get(type.ordinal()));
}
}
}

View file

@ -1,29 +1,29 @@
package mekanism.common.tile.component; package mekanism.common.tile.component;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.api.EnumColor; import mekanism.api.EnumColor;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.SideData; import mekanism.common.SideData;
import mekanism.common.base.IEjector; import mekanism.common.base.IEjector;
import mekanism.common.base.IInvConfiguration;
import mekanism.common.base.ILogisticalTransporter; import mekanism.common.base.ILogisticalTransporter;
import mekanism.common.base.ISideConfiguration;
import mekanism.common.base.ITileComponent; import mekanism.common.base.ITileComponent;
import mekanism.common.content.transporter.TransporterManager; import mekanism.common.content.transporter.TransporterManager;
import mekanism.common.tile.TileEntityContainerBlock; import mekanism.common.tile.TileEntityContainerBlock;
import mekanism.common.util.InventoryUtils; import mekanism.common.util.InventoryUtils;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import mekanism.common.util.TransporterUtils; import mekanism.common.util.TransporterUtils;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import io.netty.buffer.ByteBuf;
public class TileComponentEjector implements ITileComponent, IEjector public class TileComponentEjector implements ITileComponent, IEjector
{ {
public TileEntityContainerBlock tileEntity; public TileEntityContainerBlock tileEntity;
@ -91,11 +91,11 @@ public class TileComponentEjector implements ITileComponent, IEjector
List<ForgeDirection> outputSides = new ArrayList<ForgeDirection>(); List<ForgeDirection> outputSides = new ArrayList<ForgeDirection>();
IInvConfiguration configurable = (IInvConfiguration)tileEntity; ISideConfiguration configurable = (ISideConfiguration)tileEntity;
for(int i = 0; i < configurable.getConfiguration().length; i++) for(int i = 0; i < configurable.getConfig().getConfig(TransmissionType.ITEM).length; i++)
{ {
if(configurable.getConfiguration()[i] == configurable.getSideData().indexOf(sideData)) if(configurable.getConfig().getConfig(TransmissionType.ITEM)[i] == configurable.getConfig().getOutputs(TransmissionType.ITEM).indexOf(sideData))
{ {
outputSides.add(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(i, tileEntity.facing))); outputSides.add(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(i, tileEntity.facing)));
} }

View file

@ -2,7 +2,7 @@ package mekanism.common.util;
import mekanism.api.EnumColor; import mekanism.api.EnumColor;
import mekanism.api.util.StackUtils; import mekanism.api.util.StackUtils;
import mekanism.common.base.IInvConfiguration; import mekanism.common.base.ISideConfiguration;
import mekanism.common.content.transporter.Finder; import mekanism.common.content.transporter.Finder;
import mekanism.common.content.transporter.InvStack; import mekanism.common.content.transporter.InvStack;
import mekanism.common.tile.TileEntityBin; import mekanism.common.tile.TileEntityBin;
@ -366,9 +366,9 @@ public final class InventoryUtils
return ((TileEntityLogisticalSorter)tileEntity).canSendHome(itemStack); return ((TileEntityLogisticalSorter)tileEntity).canSendHome(itemStack);
} }
if(!force && tileEntity instanceof IInvConfiguration) if(!force && tileEntity instanceof ISideConfiguration)
{ {
IInvConfiguration config = (IInvConfiguration)tileEntity; ISideConfiguration config = (ISideConfiguration)tileEntity;
int tileSide = config.getOrientation(); int tileSide = config.getOrientation();
EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite()); EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite());

View file

@ -23,6 +23,7 @@ import mekanism.api.MekanismConfig.client;
import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.general;
import mekanism.api.gas.Gas; import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack; import mekanism.api.gas.GasStack;
import mekanism.api.transmitters.TransmissionType;
import mekanism.api.util.UnitDisplayUtils; import mekanism.api.util.UnitDisplayUtils;
import mekanism.api.util.UnitDisplayUtils.ElectricUnit; import mekanism.api.util.UnitDisplayUtils.ElectricUnit;
import mekanism.api.util.UnitDisplayUtils.TemperatureUnit; import mekanism.api.util.UnitDisplayUtils.TemperatureUnit;
@ -39,9 +40,9 @@ import mekanism.common.Version;
import mekanism.common.base.IActiveState; import mekanism.common.base.IActiveState;
import mekanism.common.base.IFactory; import mekanism.common.base.IFactory;
import mekanism.common.base.IFactory.RecipeType; import mekanism.common.base.IFactory.RecipeType;
import mekanism.common.base.IInvConfiguration;
import mekanism.common.base.IModule; import mekanism.common.base.IModule;
import mekanism.common.base.IRedstoneControl; import mekanism.common.base.IRedstoneControl;
import mekanism.common.base.ISideConfiguration;
import mekanism.common.base.IUpgradeTile; import mekanism.common.base.IUpgradeTile;
import mekanism.common.inventory.container.ContainerElectricChest; import mekanism.common.inventory.container.ContainerElectricChest;
import mekanism.common.item.ItemBlockBasic; import mekanism.common.item.ItemBlockBasic;
@ -580,20 +581,21 @@ public final class MekanismUtils
/** /**
* Increments the output type of a machine's side. * Increments the output type of a machine's side.
* @param config - configurable machine * @param config - configurable machine
* @param type - the TransmissionType to modify
* @param side - side to increment output of * @param side - side to increment output of
*/ */
public static void incrementOutput(IInvConfiguration config, int side) public static void incrementOutput(ISideConfiguration config, TransmissionType type, int side)
{ {
int max = config.getSideData().size()-1; int max = config.getConfig().getOutputs(type).size()-1;
int current = config.getSideData().indexOf(config.getSideData().get(config.getConfiguration()[side])); int current = config.getConfig().getOutputs(type).indexOf(config.getConfig().getOutputs(type).get(config.getConfig().getConfig(type)[side]));
if(current < max) if(current < max)
{ {
config.getConfiguration()[side] = (byte)(current+1); config.getConfig().getConfig(type)[side] = (byte)(current+1);
} }
else if(current == max) else if(current == max)
{ {
config.getConfiguration()[side] = 0; config.getConfig().getConfig(type)[side] = 0;
} }
TileEntity tile = (TileEntity)config; TileEntity tile = (TileEntity)config;
@ -605,20 +607,21 @@ public final class MekanismUtils
/** /**
* Decrements the output type of a machine's side. * Decrements the output type of a machine's side.
* @param config - configurable machine * @param config - configurable machine
* @param type - the TransmissionType to modify
* @param side - side to increment output of * @param side - side to increment output of
*/ */
public static void decrementOutput(IInvConfiguration config, int side) public static void decrementOutput(ISideConfiguration config, TransmissionType type, int side)
{ {
int max = config.getSideData().size()-1; int max = config.getConfig().getOutputs(type).size()-1;
int current = config.getSideData().indexOf(config.getSideData().get(config.getConfiguration()[side])); int current = config.getConfig().getOutputs(type).indexOf(config.getConfig().getOutputs(type).get(config.getConfig().getConfig(type)[side]));
if(current > 0) if(current > 0)
{ {
config.getConfiguration()[side] = (byte)(current-1); config.getConfig().getConfig(type)[side] = (byte)(current-1);
} }
else if(current == 0) else if(current == 0)
{ {
config.getConfiguration()[side] = (byte)max; config.getConfig().getConfig(type)[side] = (byte)max;
} }
TileEntity tile = (TileEntity)config; TileEntity tile = (TileEntity)config;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB