Work a bit on a new, dynamic ejector system
This commit is contained in:
parent
af48daf73b
commit
b4c2664c5e
11 changed files with 53 additions and 34 deletions
|
@ -91,7 +91,8 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
|
|||
secondaryEnergyPerTick = secondaryPerTick;
|
||||
|
||||
upgradeComponent = upgradeableSecondaryEfficiency() ? new TileComponentAdvancedUpgrade(this, 4) : new TileComponentUpgrade(this, 4);
|
||||
ejectorComponent = new TileComponentEjector(this, configComponent.getOutputs(TransmissionType.ITEM).get(3));
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(3));
|
||||
}
|
||||
|
||||
public void upgrade(RecipeType type)
|
||||
|
@ -126,8 +127,7 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
|
|||
factory.upgradeComponent.readFrom(upgradeComponent);
|
||||
factory.upgradeComponent.setUpgradeSlot(0);
|
||||
factory.ejectorComponent.readFrom(ejectorComponent);
|
||||
factory.ejectorComponent.sideData = factory.configComponent.getOutputs(TransmissionType.ITEM).get(4);
|
||||
factory.ejectorComponent.trackers = new int[factory.ejectorComponent.sideData.availableSlots.length];
|
||||
factory.ejectorComponent.setOutputData(TransmissionType.ITEM, factory.configComponent.getOutputs(TransmissionType.ITEM).get(4));
|
||||
factory.recipeType = type;
|
||||
factory.upgradeComponent.setSupported(Upgrade.GAS, type.fuelEnergyUpgrades());
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ public class TileEntityAdvancedFactory extends TileEntityFactory
|
|||
configComponent.setInputEnergyConfig();
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
ejectorComponent = new TileComponentEjector(this, configComponent.getOutputs(TransmissionType.ITEM).get(4));
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(4));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,8 @@ public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe
|
|||
inventory = new ItemStack[5];
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 3);
|
||||
ejectorComponent = new TileComponentEjector(this, configComponent.getOutputs(TransmissionType.ITEM).get(3));
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(3));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -104,7 +104,8 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
|
|||
inventory = new ItemStack[4];
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 3);
|
||||
ejectorComponent = new TileComponentEjector(this, configComponent.getOutputs(TransmissionType.ITEM).get(2));
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(2));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -59,7 +59,8 @@ public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecip
|
|||
inventory = new ItemStack[4];
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 3);
|
||||
ejectorComponent = new TileComponentEjector(this, configComponent.getOutputs(TransmissionType.ITEM).get(3));
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(3));
|
||||
}
|
||||
|
||||
public void upgrade(RecipeType type)
|
||||
|
@ -94,8 +95,7 @@ public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecip
|
|||
factory.upgradeComponent.readFrom(upgradeComponent);
|
||||
factory.upgradeComponent.setUpgradeSlot(0);
|
||||
factory.ejectorComponent.readFrom(ejectorComponent);
|
||||
factory.ejectorComponent.sideData = factory.configComponent.getOutputs(TransmissionType.ITEM).get(4);
|
||||
factory.ejectorComponent.trackers = new int[factory.ejectorComponent.sideData.availableSlots.length];
|
||||
factory.ejectorComponent.setOutputData(TransmissionType.ITEM, factory.configComponent.getOutputs(TransmissionType.ITEM).get(4));
|
||||
factory.recipeType = type;
|
||||
factory.upgradeComponent.setSupported(Upgrade.GAS, type.fuelEnergyUpgrades());
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ public class TileEntityEliteFactory extends TileEntityFactory
|
|||
configComponent.setInputEnergyConfig();
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
ejectorComponent = new TileComponentEjector(this, configComponent.getOutputs(TransmissionType.ITEM).get(4));
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(4));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,7 +140,8 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
configComponent.setInputEnergyConfig();
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
ejectorComponent = new TileComponentEjector(this, configComponent.getOutputs(TransmissionType.ITEM).get(4));
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(4));
|
||||
}
|
||||
|
||||
public TileEntityFactory(FactoryTier type, MachineType machine)
|
||||
|
@ -195,8 +196,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
factory.upgradeComponent.readFrom(upgradeComponent);
|
||||
factory.ejectorComponent.readFrom(ejectorComponent);
|
||||
factory.configComponent.readFrom(configComponent);
|
||||
factory.ejectorComponent.sideData = factory.configComponent.getOutputs(TransmissionType.ITEM).get(4);
|
||||
factory.ejectorComponent.trackers = new int[factory.ejectorComponent.sideData.availableSlots.length];
|
||||
factory.ejectorComponent.setOutputData(TransmissionType.ITEM, factory.configComponent.getOutputs(TransmissionType.ITEM).get(4));
|
||||
factory.recipeType = recipeType;
|
||||
factory.upgradeComponent.setSupported(Upgrade.GAS, recipeType.fuelEnergyUpgrades());
|
||||
|
||||
|
|
|
@ -104,7 +104,8 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
|||
inventory = new ItemStack[5];
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
ejectorComponent = new TileComponentEjector(this, configComponent.getOutputs(TransmissionType.ITEM).get(3));
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(3));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -56,7 +56,7 @@ public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, Pres
|
|||
|
||||
public TileEntityPRC()
|
||||
{
|
||||
super("prc", "PressurizedReactionChamber", new ResourceLocation("mekanism", "gui/GuiPRC.png"), usage.pressurizedReactionBaseUsage, 100, MachineType.PRESSURIZED_REACTION_CHAMBER.baseEnergy);
|
||||
super("prc", MachineType.PRESSURIZED_REACTION_CHAMBER.name, new ResourceLocation("mekanism", "gui/GuiPRC.png"), usage.pressurizedReactionBaseUsage, 100, MachineType.PRESSURIZED_REACTION_CHAMBER.baseEnergy);
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY, TransmissionType.FLUID, TransmissionType.GAS);
|
||||
|
||||
|
@ -81,7 +81,8 @@ public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, Pres
|
|||
inventory = new ItemStack[4];
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 3);
|
||||
ejectorComponent = new TileComponentEjector(this, configComponent.getOutputs(TransmissionType.ITEM).get(3));
|
||||
ejectorComponent = new TileComponentEjector(this);
|
||||
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(3));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,7 +3,9 @@ package mekanism.common.tile.component;
|
|||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
|
@ -36,19 +38,25 @@ public class TileComponentEjector implements ITileComponent, IEjector
|
|||
|
||||
public int tickDelay = 0;
|
||||
|
||||
public SideData sideData;
|
||||
public Map<TransmissionType, SideData> sideData = new HashMap<TransmissionType, SideData>();
|
||||
|
||||
public int[] trackers;
|
||||
public Map<TransmissionType, int[]> trackers = new HashMap<TransmissionType, int[]>();
|
||||
|
||||
public TileComponentEjector(TileEntityContainerBlock tile, SideData data)
|
||||
public TileComponentEjector(TileEntityContainerBlock tile)
|
||||
{
|
||||
tileEntity = tile;
|
||||
sideData = data;
|
||||
trackers = new int[sideData.availableSlots.length];
|
||||
|
||||
tile.components.add(this);
|
||||
}
|
||||
|
||||
public TileComponentEjector setOutputData(TransmissionType type, SideData data)
|
||||
{
|
||||
sideData.put(type, data);
|
||||
trackers.put(type, new int[data.availableSlots.length]);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void readFrom(TileComponentEjector ejector)
|
||||
{
|
||||
strictInput = ejector.strictInput;
|
||||
|
@ -56,14 +64,13 @@ public class TileComponentEjector implements ITileComponent, IEjector
|
|||
inputColors = ejector.inputColors;
|
||||
tickDelay = ejector.tickDelay;
|
||||
sideData = ejector.sideData;
|
||||
trackers = ejector.trackers;
|
||||
}
|
||||
|
||||
private List<ForgeDirection> getTrackedOutputs(int index, List<ForgeDirection> dirs)
|
||||
private List<ForgeDirection> getTrackedOutputs(TransmissionType type, int index, List<ForgeDirection> dirs)
|
||||
{
|
||||
List<ForgeDirection> sides = new ArrayList<ForgeDirection>();
|
||||
|
||||
for(int i = trackers[index]+1; i <= trackers[index]+6; i++)
|
||||
for(int i = trackers.get(type)[index]+1; i <= trackers.get(type)[index]+6; i++)
|
||||
{
|
||||
for(ForgeDirection side : dirs)
|
||||
{
|
||||
|
@ -109,9 +116,9 @@ public class TileComponentEjector implements ITileComponent, IEjector
|
|||
}
|
||||
}
|
||||
|
||||
for(int index = 0; index < sideData.availableSlots.length; index++)
|
||||
for(int index = 0; index < sideData.get(TransmissionType.ITEM).availableSlots.length; index++)
|
||||
{
|
||||
int slotID = sideData.availableSlots[index];
|
||||
int slotID = sideData.get(TransmissionType.ITEM).availableSlots[index];
|
||||
|
||||
if(tileEntity.inventory[slotID] == null)
|
||||
{
|
||||
|
@ -119,7 +126,7 @@ public class TileComponentEjector implements ITileComponent, IEjector
|
|||
}
|
||||
|
||||
ItemStack stack = tileEntity.inventory[slotID];
|
||||
List<ForgeDirection> outputs = getTrackedOutputs(index, outputSides);
|
||||
List<ForgeDirection> outputs = getTrackedOutputs(TransmissionType.ITEM, index, outputSides);
|
||||
|
||||
for(ForgeDirection side : outputs)
|
||||
{
|
||||
|
@ -142,7 +149,7 @@ public class TileComponentEjector implements ITileComponent, IEjector
|
|||
|
||||
if(stack == null || prev.stackSize != stack.stackSize)
|
||||
{
|
||||
trackers[index] = side.ordinal();
|
||||
trackers.get(TransmissionType.ITEM)[index] = side.ordinal();
|
||||
}
|
||||
|
||||
if(stack == null)
|
||||
|
@ -207,9 +214,12 @@ public class TileComponentEjector implements ITileComponent, IEjector
|
|||
outputColor = TransporterUtils.colors.get(nbtTags.getInteger("ejectColor"));
|
||||
}
|
||||
|
||||
for(int i = 0; i < sideData.availableSlots.length; i++)
|
||||
for(TransmissionType type : sideData.keySet())
|
||||
{
|
||||
trackers[i] = nbtTags.getInteger("tracker" + i);
|
||||
for(int i = 0; i < sideData.get(type).availableSlots.length; i++)
|
||||
{
|
||||
trackers.get(type)[i] = nbtTags.getInteger("tracker" + type.getTransmission() + i);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 6; i++)
|
||||
|
@ -268,9 +278,12 @@ public class TileComponentEjector implements ITileComponent, IEjector
|
|||
nbtTags.setInteger("ejectColor", TransporterUtils.colors.indexOf(outputColor));
|
||||
}
|
||||
|
||||
for(int i = 0; i < sideData.availableSlots.length; i++)
|
||||
for(TransmissionType type : sideData.keySet())
|
||||
{
|
||||
nbtTags.setInteger("tracker" + i, trackers[i]);
|
||||
for(int i = 0; i < sideData.get(type).availableSlots.length; i++)
|
||||
{
|
||||
nbtTags.setInteger("tracker" + type.getTransmission() + i, trackers.get(type)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 6; i++)
|
||||
|
|
|
@ -8,6 +8,7 @@ import mekanism.api.MekanismConfig.general;
|
|||
import mekanism.api.MekanismConfig.generators;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.infuse.InfuseRegistry;
|
||||
import mekanism.common.FuelHandler;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
|
@ -30,7 +31,6 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
|||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.ModAPIManager;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
|
@ -102,7 +102,7 @@ public class MekanismGenerators implements IModule
|
|||
|
||||
for(ItemStack ore : OreDictionary.getOres("dustGold"))
|
||||
{
|
||||
RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 4), GeneratorsItems.Hohlraum.getEmptyItem());
|
||||
RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("CARBON"), 10, MekanismUtils.size(ore, 4), GeneratorsItems.Hohlraum.getEmptyItem());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue