Started adding color tags for transport, shouldn't be too hard!
This commit is contained in:
parent
9983ee4a70
commit
61c7b3e4cd
2 changed files with 62 additions and 0 deletions
|
@ -3,6 +3,7 @@ package mekanism.common;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import mekanism.api.EnumColor;
|
||||||
import mekanism.api.Object3D;
|
import mekanism.api.Object3D;
|
||||||
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
|
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -16,6 +17,8 @@ public class TransporterStack
|
||||||
|
|
||||||
public int progress;
|
public int progress;
|
||||||
|
|
||||||
|
public EnumColor color;
|
||||||
|
|
||||||
public boolean initiatedPath = false;
|
public boolean initiatedPath = false;
|
||||||
|
|
||||||
public List<Object3D> pathToTarget = new ArrayList<Object3D>();
|
public List<Object3D> pathToTarget = new ArrayList<Object3D>();
|
||||||
|
@ -31,6 +34,14 @@ public class TransporterStack
|
||||||
|
|
||||||
public void write(TileEntityLogisticalTransporter tileEntity, ArrayList data)
|
public void write(TileEntityLogisticalTransporter tileEntity, ArrayList data)
|
||||||
{
|
{
|
||||||
|
if(color != null)
|
||||||
|
{
|
||||||
|
data.add(color.ordinal());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
data.add(-1);
|
||||||
|
}
|
||||||
|
|
||||||
data.add(progress);
|
data.add(progress);
|
||||||
data.add(noTarget);
|
data.add(noTarget);
|
||||||
|
|
||||||
|
@ -52,6 +63,16 @@ public class TransporterStack
|
||||||
|
|
||||||
public void read(ByteArrayDataInput dataStream)
|
public void read(ByteArrayDataInput dataStream)
|
||||||
{
|
{
|
||||||
|
int c = dataStream.readInt();
|
||||||
|
|
||||||
|
if(c != -1)
|
||||||
|
{
|
||||||
|
color = EnumColor.values()[c];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
color = null;
|
||||||
|
}
|
||||||
|
|
||||||
progress = dataStream.readInt();
|
progress = dataStream.readInt();
|
||||||
noTarget = dataStream.readBoolean();
|
noTarget = dataStream.readBoolean();
|
||||||
|
|
||||||
|
@ -67,6 +88,11 @@ public class TransporterStack
|
||||||
|
|
||||||
public void write(NBTTagCompound nbtTags)
|
public void write(NBTTagCompound nbtTags)
|
||||||
{
|
{
|
||||||
|
if(color != null)
|
||||||
|
{
|
||||||
|
nbtTags.setInteger("color", color.ordinal());
|
||||||
|
}
|
||||||
|
|
||||||
nbtTags.setInteger("progress", progress);
|
nbtTags.setInteger("progress", progress);
|
||||||
originalLocation.write(nbtTags);
|
originalLocation.write(nbtTags);
|
||||||
nbtTags.setBoolean("noTarget", noTarget);
|
nbtTags.setBoolean("noTarget", noTarget);
|
||||||
|
@ -75,6 +101,11 @@ public class TransporterStack
|
||||||
|
|
||||||
public void readFromNBT(NBTTagCompound nbtTags)
|
public void readFromNBT(NBTTagCompound nbtTags)
|
||||||
{
|
{
|
||||||
|
if(nbtTags.hasKey("color"))
|
||||||
|
{
|
||||||
|
color = EnumColor.values()[nbtTags.getInteger("color")];
|
||||||
|
}
|
||||||
|
|
||||||
progress = nbtTags.getInteger("progress");
|
progress = nbtTags.getInteger("progress");
|
||||||
originalLocation = Object3D.read(nbtTags);
|
originalLocation = Object3D.read(nbtTags);
|
||||||
noTarget = nbtTags.getBoolean("noTarget");
|
noTarget = nbtTags.getBoolean("noTarget");
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import mekanism.api.EnumColor;
|
||||||
import mekanism.api.Object3D;
|
import mekanism.api.Object3D;
|
||||||
import mekanism.api.transmitters.ITransmitter;
|
import mekanism.api.transmitters.ITransmitter;
|
||||||
import mekanism.api.transmitters.TransmissionType;
|
import mekanism.api.transmitters.TransmissionType;
|
||||||
|
@ -32,6 +33,8 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
||||||
{
|
{
|
||||||
private static final int SPEED = 5;
|
private static final int SPEED = 5;
|
||||||
|
|
||||||
|
public EnumColor color;
|
||||||
|
|
||||||
public Set<TransporterStack> transit = new HashSet<TransporterStack>();
|
public Set<TransporterStack> transit = new HashSet<TransporterStack>();
|
||||||
|
|
||||||
public boolean needsSync = false;
|
public boolean needsSync = false;
|
||||||
|
@ -321,6 +324,16 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
||||||
@Override
|
@Override
|
||||||
public void handlePacketData(ByteArrayDataInput dataStream)
|
public void handlePacketData(ByteArrayDataInput dataStream)
|
||||||
{
|
{
|
||||||
|
int c = dataStream.readInt();
|
||||||
|
|
||||||
|
if(c != -1)
|
||||||
|
{
|
||||||
|
color = EnumColor.values()[c];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
color = null;
|
||||||
|
}
|
||||||
|
|
||||||
transit.clear();
|
transit.clear();
|
||||||
|
|
||||||
int amount = dataStream.readInt();
|
int amount = dataStream.readInt();
|
||||||
|
@ -337,6 +350,14 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
||||||
@Override
|
@Override
|
||||||
public ArrayList getNetworkedData(ArrayList data)
|
public ArrayList getNetworkedData(ArrayList data)
|
||||||
{
|
{
|
||||||
|
if(color != null)
|
||||||
|
{
|
||||||
|
data.add(color.ordinal());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
data.add(-1);
|
||||||
|
}
|
||||||
|
|
||||||
data.add(transit.size());
|
data.add(transit.size());
|
||||||
|
|
||||||
for(TransporterStack stack : transit)
|
for(TransporterStack stack : transit)
|
||||||
|
@ -352,6 +373,11 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
||||||
{
|
{
|
||||||
super.readFromNBT(nbtTags);
|
super.readFromNBT(nbtTags);
|
||||||
|
|
||||||
|
if(nbtTags.hasKey("color"))
|
||||||
|
{
|
||||||
|
color = EnumColor.values()[nbtTags.getInteger("color")];
|
||||||
|
}
|
||||||
|
|
||||||
if(nbtTags.hasKey("stacks"))
|
if(nbtTags.hasKey("stacks"))
|
||||||
{
|
{
|
||||||
NBTTagList tagList = nbtTags.getTagList("stacks");
|
NBTTagList tagList = nbtTags.getTagList("stacks");
|
||||||
|
@ -368,6 +394,11 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
||||||
{
|
{
|
||||||
super.writeToNBT(nbtTags);
|
super.writeToNBT(nbtTags);
|
||||||
|
|
||||||
|
if(color != null)
|
||||||
|
{
|
||||||
|
nbtTags.setInteger("color", color.ordinal());
|
||||||
|
}
|
||||||
|
|
||||||
NBTTagList stacks = new NBTTagList();
|
NBTTagList stacks = new NBTTagList();
|
||||||
|
|
||||||
for(TransporterStack stack : transit)
|
for(TransporterStack stack : transit)
|
||||||
|
|
Loading…
Reference in a new issue