Added energy config readiness to all configurable machines, still yet to actually implement energy management
This commit is contained in:
parent
1bff3a93da
commit
e70650154d
13 changed files with 86 additions and 13 deletions
|
@ -158,7 +158,15 @@ public class GuiSideConfiguration extends GuiMekanism
|
|||
|
||||
String title = currentType.localize() + " " + MekanismUtils.localize("gui.config");
|
||||
fontRendererObj.drawString(title, (xSize/2)-(fontRendererObj.getStringWidth(title)/2), 5, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.eject") + ": " + (configurable.getConfig().isEjecting(currentType) ? "On" : "Off"), 53, 17, 0x00CD00);
|
||||
|
||||
if(configurable.getConfig().canEject(currentType))
|
||||
{
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.eject") + ": " + (configurable.getConfig().isEjecting(currentType) ? "On" : "Off"), 53, 17, 0x00CD00);
|
||||
}
|
||||
else {
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.noEject"), 53, 17, 0x00CD00);
|
||||
}
|
||||
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.slots"), 77, 81, 0x787878);
|
||||
|
||||
for(int i = 0; i < slotPosMap.size(); i++)
|
||||
|
|
|
@ -9,10 +9,26 @@ public class SideData
|
|||
|
||||
/** Int[] of available side slots */
|
||||
public int[] availableSlots;
|
||||
|
||||
/** EnergyState representing this SideData */
|
||||
public EnergyState energyState;
|
||||
|
||||
public SideData(EnumColor colour, int[] slots)
|
||||
{
|
||||
color = colour;
|
||||
availableSlots = slots;
|
||||
}
|
||||
|
||||
public SideData(EnumColor colour, EnergyState state)
|
||||
{
|
||||
color = colour;
|
||||
energyState = state;
|
||||
}
|
||||
|
||||
public static enum EnergyState
|
||||
{
|
||||
INPUT,
|
||||
OUTPUT,
|
||||
OFF;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
|
|||
{
|
||||
super(soundPath, name, MekanismUtils.getResource(ResourceType.GUI, "GuiAdvancedMachine.png"), perTick, ticksRequired, maxEnergy);
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM);
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY);
|
||||
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.GREY, InventoryUtils.EMPTY));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_RED, new int[] {0}));
|
||||
|
@ -78,6 +78,7 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
|
|||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.ORANGE, new int[] {4}));
|
||||
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 4, 5, 3});
|
||||
configComponent.setInputEnergyConfig();
|
||||
|
||||
gasTank = new GasTank(MAX_GAS);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ public class TileEntityAdvancedFactory extends TileEntityFactory
|
|||
{
|
||||
super(FactoryTier.ADVANCED, MachineType.ADVANCED_FACTORY);
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM);
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY);
|
||||
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.GREY, InventoryUtils.EMPTY));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.ORANGE, new int[] {0}));
|
||||
|
@ -26,6 +26,7 @@ public class TileEntityAdvancedFactory extends TileEntityFactory
|
|||
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});
|
||||
configComponent.setInputEnergyConfig();
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
ejectorComponent = new TileComponentEjector(this, configComponent.getOutputs(TransmissionType.ITEM).get(5));
|
||||
|
|
|
@ -29,7 +29,7 @@ public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe
|
|||
{
|
||||
super(soundPath, name, location, perTick, ticksRequired, maxEnergy);
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM);
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY);
|
||||
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.GREY, InventoryUtils.EMPTY));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_RED, new int[] {0}));
|
||||
|
@ -38,6 +38,7 @@ public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe
|
|||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.ORANGE, new int[] {3}));
|
||||
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 0, 4, 3});
|
||||
configComponent.setInputEnergyConfig();
|
||||
|
||||
inventory = new ItemStack[5];
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
|
|||
{
|
||||
super("crystallizer", "ChemicalCrystallizer", MachineType.CHEMICAL_CRYSTALLIZER.baseEnergy);
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM);
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY);
|
||||
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.GREY, InventoryUtils.EMPTY));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.PURPLE, new int[] {0}));
|
||||
|
@ -94,6 +94,7 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
|
|||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_GREEN, new int[] {2}));
|
||||
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {0, 3, 0, 0, 1, 2});
|
||||
configComponent.setInputEnergyConfig();
|
||||
|
||||
inventory = new ItemStack[4];
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import mekanism.common.Mekanism;
|
|||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.SideData.EnergyState;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IFactory.RecipeType;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
|
@ -46,7 +47,7 @@ public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecip
|
|||
{
|
||||
super(soundPath, name, MekanismUtils.getResource(ResourceType.GUI, "GuiBasicMachine.png"), perTick, ticksRequired, maxEnergy);
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM);
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY);
|
||||
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.GREY, InventoryUtils.EMPTY));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_RED, new int[] {0}));
|
||||
|
@ -55,6 +56,7 @@ public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecip
|
|||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.ORANGE, new int[] {3}));
|
||||
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 0, 4, 3});
|
||||
configComponent.setInputEnergyConfig();
|
||||
|
||||
inventory = new ItemStack[4];
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ public class TileEntityEliteFactory extends TileEntityFactory
|
|||
{
|
||||
super(FactoryTier.ELITE, MachineType.ELITE_FACTORY);
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM);
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY);
|
||||
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.GREY, InventoryUtils.EMPTY));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.ORANGE, new int[] {0}));
|
||||
|
@ -26,6 +26,7 @@ public class TileEntityEliteFactory extends TileEntityFactory
|
|||
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});
|
||||
configComponent.setInputEnergyConfig();
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
ejectorComponent = new TileComponentEjector(this, configComponent.getOutputs(TransmissionType.ITEM).get(5));
|
||||
|
|
|
@ -118,7 +118,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
{
|
||||
this(FactoryTier.BASIC, MachineType.BASIC_FACTORY);
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM);
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY);
|
||||
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.GREY, InventoryUtils.EMPTY));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.ORANGE, new int[] {0}));
|
||||
|
@ -128,6 +128,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
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});
|
||||
configComponent.setInputEnergyConfig();
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
ejectorComponent = new TileComponentEjector(this, configComponent.getOutputs(TransmissionType.ITEM).get(5));
|
||||
|
|
|
@ -88,7 +88,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
|||
{
|
||||
super("metalinfuser", "MetallurgicInfuser", MachineType.METALLURGIC_INFUSER.baseEnergy);
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM);
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY);
|
||||
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.GREY, InventoryUtils.EMPTY));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.ORANGE, new int[] {0}));
|
||||
|
@ -98,6 +98,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
|||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_GREEN, new int[] {4}));
|
||||
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 5, 3, 4});
|
||||
configComponent.setInputEnergyConfig();
|
||||
|
||||
inventory = new ItemStack[5];
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, Pres
|
|||
{
|
||||
super("prc", "PressurizedReactionChamber", new ResourceLocation("mekanism", "gui/GuiPRC.png"), usage.pressurizedReactionBaseUsage, 100, MachineType.PRESSURIZED_REACTION_CHAMBER.baseEnergy);
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM);
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY);
|
||||
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.GREY, InventoryUtils.EMPTY));
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.DARK_RED, new int[] {0}));
|
||||
|
@ -68,6 +68,7 @@ public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, Pres
|
|||
configComponent.addOutput(TransmissionType.ITEM, new SideData(EnumColor.ORANGE, new int[] {3}));
|
||||
|
||||
configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 0, 0, 3});
|
||||
configComponent.setInputEnergyConfig();
|
||||
|
||||
inventory = new ItemStack[4];
|
||||
|
||||
|
|
|
@ -8,8 +8,10 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.SideData.EnergyState;
|
||||
import mekanism.common.base.ITileComponent;
|
||||
import mekanism.common.tile.TileEntityContainerBlock;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
|
@ -22,6 +24,7 @@ public class TileComponentConfig implements ITileComponent
|
|||
public Map<Integer, byte[]> sideConfigs = new HashMap<Integer, byte[]>();
|
||||
public Map<Integer, ArrayList<SideData>> sideOutputs = new HashMap<Integer, ArrayList<SideData>>();
|
||||
public Map<Integer, Boolean> ejecting = new HashMap<Integer, Boolean>();
|
||||
public Map<Integer, Boolean> canEject = new HashMap<Integer, Boolean>();
|
||||
|
||||
public List<TransmissionType> transmissions = new ArrayList<TransmissionType>();
|
||||
|
||||
|
@ -35,11 +38,40 @@ public class TileComponentConfig implements ITileComponent
|
|||
{
|
||||
sideOutputs.put(transmission.ordinal(), new ArrayList<SideData>());
|
||||
ejecting.put(transmission.ordinal(), false);
|
||||
canEject.put(transmission.ordinal(), true);
|
||||
}
|
||||
|
||||
tile.components.add(this);
|
||||
}
|
||||
|
||||
public void setCanEject(TransmissionType type, boolean eject)
|
||||
{
|
||||
canEject.put(type.ordinal(), eject);
|
||||
}
|
||||
|
||||
public boolean canEject(TransmissionType type)
|
||||
{
|
||||
return canEject.get(type.ordinal());
|
||||
}
|
||||
|
||||
public void setIOEnergyConfig()
|
||||
{
|
||||
addOutput(TransmissionType.ENERGY, new SideData(EnumColor.GREY, EnergyState.OFF));
|
||||
addOutput(TransmissionType.ENERGY, new SideData(EnumColor.DARK_GREEN, EnergyState.INPUT));
|
||||
addOutput(TransmissionType.ENERGY, new SideData(EnumColor.DARK_RED, EnergyState.OUTPUT));
|
||||
|
||||
setConfig(TransmissionType.ENERGY, new byte[] {1, 1, 2, 1, 1, 1});
|
||||
}
|
||||
|
||||
public void setInputEnergyConfig()
|
||||
{
|
||||
addOutput(TransmissionType.ENERGY, new SideData(EnumColor.GREY, EnergyState.OFF));
|
||||
addOutput(TransmissionType.ENERGY, new SideData(EnumColor.DARK_GREEN, EnergyState.INPUT));
|
||||
|
||||
setConfig(TransmissionType.ENERGY, new byte[] {1, 1, 1, 1, 1, 1});
|
||||
setCanEject(TransmissionType.ENERGY, false);
|
||||
}
|
||||
|
||||
public void setConfig(TransmissionType type, byte[] config)
|
||||
{
|
||||
sideConfigs.put(type.ordinal(), config);
|
||||
|
@ -85,8 +117,11 @@ public class TileComponentConfig implements ITileComponent
|
|||
{
|
||||
for(TransmissionType type : transmissions)
|
||||
{
|
||||
sideConfigs.put(type.ordinal(), nbtTags.getByteArray("config" + type.ordinal()));
|
||||
ejecting.put(type.ordinal(), nbtTags.getBoolean("ejecting" + type.ordinal()));
|
||||
if(nbtTags.getByteArray("config" + type.ordinal()).length > 0)
|
||||
{
|
||||
sideConfigs.put(type.ordinal(), nbtTags.getByteArray("config" + type.ordinal()));
|
||||
ejecting.put(type.ordinal(), nbtTags.getBoolean("ejecting" + type.ordinal()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +131,10 @@ public class TileComponentConfig implements ITileComponent
|
|||
{
|
||||
for(TransmissionType type : transmissions)
|
||||
{
|
||||
dataStream.readBytes(sideConfigs.get(type.ordinal()));
|
||||
byte[] array = new byte[6];
|
||||
dataStream.readBytes(array);
|
||||
|
||||
sideConfigs.put(type.ordinal(), array);
|
||||
ejecting.put(type.ordinal(), dataStream.readBoolean());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -431,6 +431,7 @@ gui.providers=providers
|
|||
gui.structure=Structure
|
||||
gui.dynamicTank=Dynamic Tank
|
||||
gui.visuals=Visuals
|
||||
gui.noEject=Can't Eject
|
||||
|
||||
gui.reactor.injectionRate=Injection Rate
|
||||
|
||||
|
|
Loading…
Reference in a new issue