More progress on Logistical Sorter
This commit is contained in:
parent
5a748c5ff6
commit
e9c038cd24
6 changed files with 123 additions and 18 deletions
|
@ -31,6 +31,14 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||||
public void onUpdate()
|
public void onUpdate()
|
||||||
{
|
{
|
||||||
super.onUpdate();
|
super.onUpdate();
|
||||||
|
|
||||||
|
if(!worldObj.isRemote)
|
||||||
|
{
|
||||||
|
if(MekanismUtils.canFunction(this))
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -80,6 +88,13 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||||
|
|
||||||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||||
|
|
||||||
|
filters.clear();
|
||||||
|
|
||||||
|
for(int i = 0; i < dataStream.readInt(); i++)
|
||||||
|
{
|
||||||
|
filters.add(TransporterFilter.readFromPacket(dataStream));
|
||||||
|
}
|
||||||
|
|
||||||
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
|
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,6 +104,12 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||||
super.getNetworkedData(data);
|
super.getNetworkedData(data);
|
||||||
|
|
||||||
data.add(controlType.ordinal());
|
data.add(controlType.ordinal());
|
||||||
|
data.add(filters.size());
|
||||||
|
|
||||||
|
for(TransporterFilter filter : filters)
|
||||||
|
{
|
||||||
|
filter.write(data);
|
||||||
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -105,6 +126,12 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInventoryStackLimit()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RedstoneControl getControlType()
|
public RedstoneControl getControlType()
|
||||||
{
|
{
|
||||||
|
|
|
@ -335,14 +335,9 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
||||||
|
|
||||||
transit.clear();
|
transit.clear();
|
||||||
|
|
||||||
int amount = dataStream.readInt();
|
for(int i = 0; i < dataStream.readInt(); i++)
|
||||||
|
|
||||||
for(int i = 0; i < amount; i++)
|
|
||||||
{
|
{
|
||||||
TransporterStack stack = new TransporterStack();
|
transit.add(TransporterStack.readFromPacket(dataStream));
|
||||||
stack.read(dataStream);
|
|
||||||
|
|
||||||
transit.add(stack);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,7 +378,7 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
||||||
|
|
||||||
for(int i = 0; i < tagList.tagCount(); i++)
|
for(int i = 0; i < tagList.tagCount(); i++)
|
||||||
{
|
{
|
||||||
transit.add(TransporterStack.read((NBTTagCompound)tagList.tagAt(i)));
|
transit.add(TransporterStack.readFromNBT((NBTTagCompound)tagList.tagAt(i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,14 +10,20 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
public class ItemStackFilter extends TransporterFilter
|
public class ItemStackFilter extends TransporterFilter
|
||||||
{
|
{
|
||||||
public ItemStack itemStack;
|
public ItemStack itemType;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canFilter(ItemStack itemStack)
|
||||||
|
{
|
||||||
|
return itemType.isItemEqual(itemStack);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(NBTTagCompound nbtTags)
|
public void write(NBTTagCompound nbtTags)
|
||||||
{
|
{
|
||||||
super.write(nbtTags);
|
super.write(nbtTags);
|
||||||
|
|
||||||
itemStack.writeToNBT(nbtTags);
|
itemType.writeToNBT(nbtTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,7 +31,7 @@ public class ItemStackFilter extends TransporterFilter
|
||||||
{
|
{
|
||||||
super.read(nbtTags);
|
super.read(nbtTags);
|
||||||
|
|
||||||
itemStack = ItemStack.loadItemStackFromNBT(nbtTags);
|
itemType = ItemStack.loadItemStackFromNBT(nbtTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -33,9 +39,9 @@ public class ItemStackFilter extends TransporterFilter
|
||||||
{
|
{
|
||||||
super.write(data);
|
super.write(data);
|
||||||
|
|
||||||
data.add(itemStack.itemID);
|
data.add(itemType.itemID);
|
||||||
data.add(itemStack.stackSize);
|
data.add(itemType.stackSize);
|
||||||
data.add(itemStack.getItemDamage());
|
data.add(itemType.getItemDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -43,6 +49,23 @@ public class ItemStackFilter extends TransporterFilter
|
||||||
{
|
{
|
||||||
super.read(dataStream);
|
super.read(dataStream);
|
||||||
|
|
||||||
itemStack = new ItemStack(dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
|
itemType = new ItemStack(dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
int code = 1;
|
||||||
|
code = 31 * code + super.hashCode();
|
||||||
|
code = 31 * code + itemType.itemID;
|
||||||
|
code = 31 * code + itemType.stackSize;
|
||||||
|
code = 31 * code + itemType.getItemDamage();
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object filter)
|
||||||
|
{
|
||||||
|
return super.equals(filter) && filter instanceof ItemStackFilter && ((ItemStackFilter)filter).itemType.isItemEqual(itemType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,21 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
|
||||||
|
import mekanism.common.util.MekanismUtils;
|
||||||
import mekanism.common.util.TransporterUtils;
|
import mekanism.common.util.TransporterUtils;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
public class OreDictFilter extends TransporterFilter
|
public class OreDictFilter extends TransporterFilter
|
||||||
{
|
{
|
||||||
public String oreDictName;
|
public String oreDictName;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canFilter(ItemStack itemStack)
|
||||||
|
{
|
||||||
|
return MekanismUtils.oreDictCheck(itemStack, oreDictName);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(NBTTagCompound nbtTags)
|
public void write(NBTTagCompound nbtTags)
|
||||||
{
|
{
|
||||||
|
@ -42,4 +50,19 @@ public class OreDictFilter extends TransporterFilter
|
||||||
|
|
||||||
oreDictName = dataStream.readUTF();
|
oreDictName = dataStream.readUTF();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
int code = 1;
|
||||||
|
code = 31 * code + super.hashCode();
|
||||||
|
code = 31 * code + oreDictName.hashCode();
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object filter)
|
||||||
|
{
|
||||||
|
return super.equals(filter) && filter instanceof OreDictFilter && ((OreDictFilter)filter).oreDictName.equals(oreDictName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,9 @@ package mekanism.common.transporter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import mekanism.api.EnumColor;
|
import mekanism.api.EnumColor;
|
||||||
|
import mekanism.common.Teleporter.Code;
|
||||||
import mekanism.common.util.TransporterUtils;
|
import mekanism.common.util.TransporterUtils;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
@ -12,6 +14,11 @@ public class TransporterFilter
|
||||||
{
|
{
|
||||||
public EnumColor color;
|
public EnumColor color;
|
||||||
|
|
||||||
|
public boolean canFilter(ItemStack itemStack)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void write(NBTTagCompound nbtTags)
|
public void write(NBTTagCompound nbtTags)
|
||||||
{
|
{
|
||||||
nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color));
|
nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color));
|
||||||
|
@ -39,4 +46,26 @@ public class TransporterFilter
|
||||||
|
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TransporterFilter readFromPacket(ByteArrayDataInput dataStream)
|
||||||
|
{
|
||||||
|
TransporterFilter filter = new TransporterFilter();
|
||||||
|
filter.read(dataStream);
|
||||||
|
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
int code = 1;
|
||||||
|
code = 31 * code + color.ordinal();
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object filter)
|
||||||
|
{
|
||||||
|
return filter instanceof TransporterFilter && ((TransporterFilter)filter).color == color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class TransporterStack
|
||||||
itemStack.writeToNBT(nbtTags);
|
itemStack.writeToNBT(nbtTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readFromNBT(NBTTagCompound nbtTags)
|
public void read(NBTTagCompound nbtTags)
|
||||||
{
|
{
|
||||||
if(nbtTags.hasKey("color"))
|
if(nbtTags.hasKey("color"))
|
||||||
{
|
{
|
||||||
|
@ -114,10 +114,18 @@ public class TransporterStack
|
||||||
itemStack = ItemStack.loadItemStackFromNBT(nbtTags);
|
itemStack = ItemStack.loadItemStackFromNBT(nbtTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TransporterStack read(NBTTagCompound nbtTags)
|
public static TransporterStack readFromNBT(NBTTagCompound nbtTags)
|
||||||
{
|
{
|
||||||
TransporterStack stack = new TransporterStack();
|
TransporterStack stack = new TransporterStack();
|
||||||
stack.readFromNBT(nbtTags);
|
stack.read(nbtTags);
|
||||||
|
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TransporterStack readFromPacket(ByteArrayDataInput dataStream)
|
||||||
|
{
|
||||||
|
TransporterStack stack = new TransporterStack();
|
||||||
|
stack.read(dataStream);
|
||||||
|
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue