More work on the Logistical Sorter!

This commit is contained in:
Aidan C. Brady 2013-10-25 08:51:13 -04:00
parent 51289b82c2
commit 5a748c5ff6
15 changed files with 283 additions and 123 deletions

View file

@ -21,7 +21,8 @@ public class GuiLogisticalSorter extends GuiMekanism
{
super(new ContainerLogisticalSorter(inventory, tentity));
tileEntity = tentity;
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png")));
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiLogisticalSorter.png")));
}
@Override

View file

@ -4,8 +4,8 @@ import mekanism.api.Object3D;
import mekanism.client.model.ModelTransmitter;
import mekanism.client.model.ModelTransmitter.Size;
import mekanism.client.model.ModelTransporterBox;
import mekanism.common.TransporterStack;
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
import mekanism.common.transporter.TransporterStack;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import mekanism.common.util.TransporterUtils;

View file

@ -831,32 +831,34 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
public static enum MachineType
{
ENRICHMENT_CHAMBER(0, 3, Mekanism.enrichmentChamberUsage*400, TileEntityEnrichmentChamber.class, false),
OSMIUM_COMPRESSOR(1, 4, Mekanism.osmiumCompressorUsage*400, TileEntityOsmiumCompressor.class, false),
COMBINER(2, 5, Mekanism.combinerUsage*400, TileEntityCombiner.class, false),
CRUSHER(3, 6, Mekanism.crusherUsage*400, TileEntityCrusher.class, false),
THEORETICAL_ELEMENTIZER(4, 7, Mekanism.theoreticalElementizerUsage*400, TileEntityTheoreticalElementizer.class, true),
BASIC_FACTORY(5, 11, Mekanism.factoryUsage*3*400, TileEntityFactory.class, false),
ADVANCED_FACTORY(6, 11, Mekanism.factoryUsage*5*400, TileEntityAdvancedFactory.class, false),
ELITE_FACTORY(7, 11, Mekanism.factoryUsage*7*400, TileEntityEliteFactory.class, false),
METALLURGIC_INFUSER(8, 12, Mekanism.metallurgicInfuserUsage*400, TileEntityMetallurgicInfuser.class, true),
PURIFICATION_CHAMBER(9, 15, Mekanism.purificationChamberUsage*400, TileEntityPurificationChamber.class, false),
ENERGIZED_SMELTER(10, 16, Mekanism.energizedSmelterUsage*400, TileEntityEnergizedSmelter.class, false),
TELEPORTER(11, 13, 5000000, TileEntityTeleporter.class, false),
ELECTRIC_PUMP(12, 17, 10000, TileEntityElectricPump.class, true),
ELECTRIC_CHEST(13, -1, 12000, TileEntityElectricChest.class, true),
CHARGEPAD(14, -1, 9000, TileEntityChargepad.class, true),
LOGISTICAL_SORTER(15, 26, 12000, TileEntityLogisticalSorter.class, false);
ENRICHMENT_CHAMBER(0, "EnrichmentChamber", 3, Mekanism.enrichmentChamberUsage*400, TileEntityEnrichmentChamber.class, false),
OSMIUM_COMPRESSOR(1, "OsmiumCompressor", 4, Mekanism.osmiumCompressorUsage*400, TileEntityOsmiumCompressor.class, false),
COMBINER(2, "Combiner", 5, Mekanism.combinerUsage*400, TileEntityCombiner.class, false),
CRUSHER(3, "Crusher", 6, Mekanism.crusherUsage*400, TileEntityCrusher.class, false),
THEORETICAL_ELEMENTIZER(4, "TheoreticalElementizer", 7, Mekanism.theoreticalElementizerUsage*400, TileEntityTheoreticalElementizer.class, true),
BASIC_FACTORY(5, "BasicFactory", 11, Mekanism.factoryUsage*3*400, TileEntityFactory.class, false),
ADVANCED_FACTORY(6, "AdvancedFactory", 11, Mekanism.factoryUsage*5*400, TileEntityAdvancedFactory.class, false),
ELITE_FACTORY(7, "EliteFactory", 11, Mekanism.factoryUsage*7*400, TileEntityEliteFactory.class, false),
METALLURGIC_INFUSER(8, "MetallurgicInfuser", 12, Mekanism.metallurgicInfuserUsage*400, TileEntityMetallurgicInfuser.class, true),
PURIFICATION_CHAMBER(9, "PurificationChamber", 15, Mekanism.purificationChamberUsage*400, TileEntityPurificationChamber.class, false),
ENERGIZED_SMELTER(10, "EnergizedSmelter", 16, Mekanism.energizedSmelterUsage*400, TileEntityEnergizedSmelter.class, false),
TELEPORTER(11, "Teleporter", 13, 5000000, TileEntityTeleporter.class, false),
ELECTRIC_PUMP(12, "ElectricPump", 17, 10000, TileEntityElectricPump.class, true),
ELECTRIC_CHEST(13, "ElectricChest", -1, 12000, TileEntityElectricChest.class, true),
CHARGEPAD(14, "Chargepad", -1, 9000, TileEntityChargepad.class, true),
LOGISTICAL_SORTER(15, "LogisticalSorter", 26, 12000, TileEntityLogisticalSorter.class, false);
public int meta;
public String name;
public int guiId;
public double baseEnergy;
public Class<? extends TileEntity> tileEntityClass;
public boolean hasModel;
private MachineType(int i, int j, double k, Class<? extends TileEntity> tileClass, boolean model)
private MachineType(int i, String s, int j, double k, Class<? extends TileEntity> tileClass, boolean model)
{
meta = i;
name = s;
guiId = j;
baseEnergy = k;
tileEntityClass = tileClass;

View file

@ -12,11 +12,11 @@ import mekanism.api.transmitters.ITransmitter;
import mekanism.client.ClientProxy;
import mekanism.common.Mekanism;
import mekanism.common.PipeUtils;
import mekanism.common.TransporterPathfinder;
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
import mekanism.common.tileentity.TileEntityMechanicalPipe;
import mekanism.common.tileentity.TileEntityPressurizedTube;
import mekanism.common.tileentity.TileEntityUniversalCable;
import mekanism.common.transporter.TransporterPathfinder;
import mekanism.common.util.CableUtils;
import mekanism.common.util.TransporterUtils;
import net.minecraft.block.Block;

View file

@ -89,63 +89,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
@Override
public String getUnlocalizedName(ItemStack itemstack)
{
String name = "";
switch(itemstack.getItemDamage())
{
case 0:
name = "EnrichmentChamber";
break;
case 1:
name = "OsmiumCompressor";
break;
case 2:
name = "Combiner";
break;
case 3:
name = "Crusher";
break;
case 4:
name = "TheoreticalElementizer";
break;
case 5:
name = "BasicFactory";
break;
case 6:
name = "AdvancedFactory";
break;
case 7:
name = "EliteFactory";
break;
case 8:
name = "MetallurgicInfuser";
break;
case 9:
name = "PurificationChamber";
break;
case 10:
name = "EnergizedSmelter";
break;
case 11:
name = "Teleporter";
break;
case 12:
name = "ElectricPump";
break;
case 13:
name = "ElectricChest";
break;
case 14:
name = "Chargepad";
break;
case 15:
name = "LogisticalSorter";
break;
default:
name = "Unknown";
break;
}
return getUnlocalizedName() + "." + name;
return getUnlocalizedName() + "." + MachineType.getFromMetadata(itemstack.getItemDamage()).name;
}
@Override

View file

@ -1,13 +1,119 @@
package mekanism.common.tileentity;
import mekanism.common.block.BlockMachine.MachineType;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
public class TileEntityLogisticalSorter extends TileEntityElectricBlock
import mekanism.common.IRedstoneControl;
import mekanism.common.IRedstoneControl.RedstoneControl;
import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.transporter.TransporterFilter;
import mekanism.common.util.MekanismUtils;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import com.google.common.io.ByteArrayDataInput;
public class TileEntityLogisticalSorter extends TileEntityElectricBlock implements IRedstoneControl
{
public Set<TransporterFilter> filters = new HashSet<TransporterFilter>();
public RedstoneControl controlType = RedstoneControl.DISABLED;
public TileEntityLogisticalSorter()
{
super("LogisticalSorter", MachineType.LOGISTICAL_SORTER.baseEnergy);
inventory = new ItemStack[1];
}
@Override
public void onUpdate()
{
super.onUpdate();
}
@Override
public void writeToNBT(NBTTagCompound nbtTags)
{
super.writeToNBT(nbtTags);
nbtTags.setInteger("controlType", controlType.ordinal());
NBTTagList filterTags = new NBTTagList();
for(TransporterFilter filter : filters)
{
NBTTagCompound tagCompound = new NBTTagCompound();
filter.write(tagCompound);
filterTags.appendTag(tagCompound);
}
if(filterTags.tagCount() != 0)
{
nbtTags.setTag("filters", filterTags);
}
}
@Override
public void readFromNBT(NBTTagCompound nbtTags)
{
super.readFromNBT(nbtTags);
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
if(nbtTags.hasKey("filters"))
{
NBTTagList tagList = nbtTags.getTagList("filters");
for(int i = 0; i < tagList.tagCount(); i++)
{
filters.add(TransporterFilter.readFromNBT((NBTTagCompound)tagList.tagAt(i)));
}
}
}
@Override
public void handlePacketData(ByteArrayDataInput dataStream)
{
super.handlePacketData(dataStream);
controlType = RedstoneControl.values()[dataStream.readInt()];
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
@Override
public ArrayList getNetworkedData(ArrayList data)
{
super.getNetworkedData(data);
data.add(controlType.ordinal());
return data;
}
@Override
public boolean canExtractItem(int slotID, ItemStack itemstack, int side)
{
return false;
}
@Override
public boolean isItemValidForSlot(int slotID, ItemStack itemstack)
{
return false;
}
@Override
public RedstoneControl getControlType()
{
return controlType;
}
@Override
public void setControlType(RedstoneControl type)
{
controlType = type;
}
}

View file

@ -12,9 +12,9 @@ import mekanism.common.ITileNetwork;
import mekanism.common.InventoryNetwork;
import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.TransporterStack;
import mekanism.common.network.PacketDataRequest;
import mekanism.common.network.PacketTileEntity;
import mekanism.common.transporter.TransporterStack;
import mekanism.common.util.TransporterUtils;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;

View file

@ -0,0 +1,48 @@
package mekanism.common.transporter;
import java.util.ArrayList;
import com.google.common.io.ByteArrayDataInput;
import mekanism.common.util.TransporterUtils;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class ItemStackFilter extends TransporterFilter
{
public ItemStack itemStack;
@Override
public void write(NBTTagCompound nbtTags)
{
super.write(nbtTags);
itemStack.writeToNBT(nbtTags);
}
@Override
public void read(NBTTagCompound nbtTags)
{
super.read(nbtTags);
itemStack = ItemStack.loadItemStackFromNBT(nbtTags);
}
@Override
public void write(ArrayList data)
{
super.write(data);
data.add(itemStack.itemID);
data.add(itemStack.stackSize);
data.add(itemStack.getItemDamage());
}
@Override
public void read(ByteArrayDataInput dataStream)
{
super.read(dataStream);
itemStack = new ItemStack(dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
}
}

View file

@ -0,0 +1,45 @@
package mekanism.common.transporter;
import java.util.ArrayList;
import com.google.common.io.ByteArrayDataInput;
import mekanism.common.util.TransporterUtils;
import net.minecraft.nbt.NBTTagCompound;
public class OreDictFilter extends TransporterFilter
{
public String oreDictName;
@Override
public void write(NBTTagCompound nbtTags)
{
super.write(nbtTags);
nbtTags.setString("oreDictName", oreDictName);
}
@Override
public void read(NBTTagCompound nbtTags)
{
super.read(nbtTags);
oreDictName = nbtTags.getString("oreDictName");
}
@Override
public void write(ArrayList data)
{
super.write(data);
data.add(oreDictName);
}
@Override
public void read(ByteArrayDataInput dataStream)
{
super.read(dataStream);
oreDictName = dataStream.readUTF();
}
}

View file

@ -0,0 +1,42 @@
package mekanism.common.transporter;
import java.util.ArrayList;
import mekanism.api.EnumColor;
import mekanism.common.util.TransporterUtils;
import net.minecraft.nbt.NBTTagCompound;
import com.google.common.io.ByteArrayDataInput;
public class TransporterFilter
{
public EnumColor color;
public void write(NBTTagCompound nbtTags)
{
nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color));
}
public void read(NBTTagCompound nbtTags)
{
color = TransporterUtils.colors.get(nbtTags.getInteger("color"));
}
public void write(ArrayList data)
{
data.add(TransporterUtils.colors.indexOf(color));
}
public void read(ByteArrayDataInput dataStream)
{
color = TransporterUtils.colors.get(dataStream.readInt());
}
public static TransporterFilter readFromNBT(NBTTagCompound nbtTags)
{
TransporterFilter filter = new TransporterFilter();
filter.read(nbtTags);
return filter;
}
}

View file

@ -1,4 +1,4 @@
package mekanism.common;
package mekanism.common.transporter;
import java.util.ArrayList;
import java.util.HashMap;
@ -290,8 +290,6 @@ public final class TransporterPathfinder
Destination d = new Destination(start.worldObj, start, stack);
Object3D closest = d.find();
System.out.println(closest);
if(closest == null)
{
return null;

View file

@ -1,4 +1,4 @@
package mekanism.common;
package mekanism.common.transporter;
import java.util.ArrayList;
import java.util.List;

View file

@ -13,6 +13,7 @@ import mekanism.common.PacketHandler;
import mekanism.common.RecipeHandler;
import mekanism.common.Version;
import mekanism.generators.common.block.BlockGenerator;
import mekanism.generators.common.item.ItemBlockGenerator;
import mekanism.generators.common.network.PacketElectrolyticSeparatorParticle;
import mekanism.generators.common.tileentity.TileEntitySolarGenerator;
import net.minecraft.block.Block;

View file

@ -551,21 +551,22 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds
public static enum GeneratorType
{
HEAT_GENERATOR(0, 0, 160000, TileEntityHeatGenerator.class, true),
SOLAR_GENERATOR(1, 1, 96000, TileEntitySolarGenerator.class, false),
ELECTROLYTIC_SEPARATOR(2, 2, 20000, TileEntityElectrolyticSeparator.class, true),
HYDROGEN_GENERATOR(3, 3, 40000, TileEntityHydrogenGenerator.class, true),
BIO_GENERATOR(4, 4, 160000, TileEntityBioGenerator.class, true),
ADVANCED_SOLAR_GENERATOR(5, 1, 200000, TileEntityAdvancedSolarGenerator.class, true),
WIND_TURBINE(6, 5, 200000, TileEntityWindTurbine.class, true);
HEAT_GENERATOR(0, "HeatGenerator", 0, 160000, TileEntityHeatGenerator.class, true),
SOLAR_GENERATOR(1, "SolarGenerator", 1, 96000, TileEntitySolarGenerator.class, false),
ELECTROLYTIC_SEPARATOR(2, "ElectrolyticSeparator", 2, 20000, TileEntityElectrolyticSeparator.class, true),
HYDROGEN_GENERATOR(3, "HydrogenGenerator", 3, 40000, TileEntityHydrogenGenerator.class, true),
BIO_GENERATOR(4, "BioGenerator", 4, 160000, TileEntityBioGenerator.class, true),
ADVANCED_SOLAR_GENERATOR(5, "AdvancedSolarGenerator", 1, 200000, TileEntityAdvancedSolarGenerator.class, true),
WIND_TURBINE(6, "WindTurbine", 5, 200000, TileEntityWindTurbine.class, true);
public int meta;
public String name;
public int guiId;
public double maxEnergy;
public Class<? extends TileEntity> tileEntityClass;
public boolean hasModel;
private GeneratorType(int i, int j, double k, Class<? extends TileEntity> tileClass, boolean model)
private GeneratorType(int i, String name, int j, double k, Class<? extends TileEntity> tileClass, boolean model)
{
meta = i;
guiId = j;

View file

@ -1,4 +1,4 @@
package mekanism.generators.common;
package mekanism.generators.common.item;
import ic2.api.item.IElectricItemManager;
import ic2.api.item.ISpecialElectricItem;
@ -72,35 +72,7 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, IIt
@Override
public String getUnlocalizedName(ItemStack itemstack)
{
String name = "";
switch(itemstack.getItemDamage())
{
case 0:
name = "HeatGenerator";
break;
case 1:
name = "SolarGenerator";
break;
case 2:
name = "ElectrolyticSeparator";
break;
case 3:
name = "HydrogenGenerator";
break;
case 4:
name = "BioGenerator";
break;
case 5:
name = "AdvancedSolarGenerator";
break;
case 6:
name = "WindTurbine";
break;
default:
name = "Unknown";
break;
}
return getUnlocalizedName() + "." + name;
return getUnlocalizedName() + "." + GeneratorType.getFromMetadata(itemstack.getItemDamage()).name;
}
@Override