Got more things working!
This commit is contained in:
parent
c7dcea6a06
commit
89eda12200
6 changed files with 76 additions and 42 deletions
|
@ -35,7 +35,7 @@ public class RenderLogisticalTransporter extends TileEntitySpecialRenderer
|
|||
|
||||
public void renderAModelAt(TileEntityLogisticalTransporter tileEntity, double x, double y, double z, float partialTick)
|
||||
{
|
||||
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalTransporter" + (tileEntity.isActive ? "Active" : "") + ".png"));
|
||||
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalTransporter.png"));
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
|
||||
GL11.glScalef(1.0F, -1F, -1F);
|
||||
|
|
|
@ -294,7 +294,7 @@ public final class TransporterPathfinder
|
|||
return p.getPath();
|
||||
}
|
||||
|
||||
public static List<Object3D> getIdlePath(TileEntityLogisticalTransporter start, Object3D home, Object3D prevHome)
|
||||
public static List<Object3D> getIdlePath(TileEntityLogisticalTransporter start)
|
||||
{
|
||||
IdleDest d = new IdleDest(start.worldObj, start);
|
||||
Object3D farthest = d.find();
|
||||
|
@ -304,7 +304,7 @@ public final class TransporterPathfinder
|
|||
return null;
|
||||
}
|
||||
|
||||
Path p = new Path(start.worldObj, prevHome, Object3D.get(start), null);
|
||||
Path p = new Path(start.worldObj, farthest, Object3D.get(start), null);
|
||||
return p.getPath();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ public class TransporterStack
|
|||
|
||||
public boolean noTarget = false;
|
||||
|
||||
public boolean clientFirstTick = true;
|
||||
|
||||
public void write(TileEntityLogisticalTransporter tileEntity, ArrayList data)
|
||||
{
|
||||
data.add(progress);
|
||||
|
@ -72,7 +74,7 @@ public class TransporterStack
|
|||
itemStack.writeToNBT(nbtTags);
|
||||
}
|
||||
|
||||
public void read(NBTTagCompound nbtTags)
|
||||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
progress = nbtTags.getInteger("progress");
|
||||
originalLocation = Object3D.read(nbtTags);
|
||||
|
@ -80,6 +82,14 @@ public class TransporterStack
|
|||
itemStack = ItemStack.loadItemStackFromNBT(nbtTags);
|
||||
}
|
||||
|
||||
public static TransporterStack read(NBTTagCompound nbtTags)
|
||||
{
|
||||
TransporterStack stack = new TransporterStack();
|
||||
stack.readFromNBT(nbtTags);
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
public boolean hasPath()
|
||||
{
|
||||
return pathToTarget != null;
|
||||
|
@ -104,7 +114,7 @@ public class TransporterStack
|
|||
|
||||
public void calculateIdle(TileEntityLogisticalTransporter tileEntity)
|
||||
{
|
||||
pathToTarget = TransporterPathfinder.getIdlePath(tileEntity, originalLocation, pathToTarget.get(pathToTarget.size()-1));
|
||||
pathToTarget = TransporterPathfinder.getIdlePath(tileEntity);
|
||||
noTarget = true;
|
||||
originalLocation = Object3D.get(tileEntity);
|
||||
initiatedPath = true;
|
||||
|
|
|
@ -59,13 +59,6 @@ public class ItemConfigurator extends ItemEnergized
|
|||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())));
|
||||
return true;
|
||||
}
|
||||
else if(world.getBlockTileEntity(x, y, z) instanceof TileEntityLogisticalTransporter)
|
||||
{
|
||||
TileEntityLogisticalTransporter tileEntity = (TileEntityLogisticalTransporter)world.getBlockTileEntity(x, y, z);
|
||||
tileEntity.isActive = !tileEntity.isActive;
|
||||
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())));
|
||||
return true;
|
||||
}
|
||||
else if(world.getBlockTileEntity(x, y, z) instanceof TileEntityElectricPump)
|
||||
{
|
||||
TileEntityElectricPump tileEntity = (TileEntityElectricPump)world.getBlockTileEntity(x, y, z);
|
||||
|
|
|
@ -18,6 +18,7 @@ import mekanism.common.util.TransporterUtils;
|
|||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
@ -29,16 +30,27 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
|
||||
public class TileEntityLogisticalTransporter extends TileEntityTransmitter<InventoryNetwork> implements ITileNetwork
|
||||
{
|
||||
/** This transporter's active state. */
|
||||
public boolean isActive = false;
|
||||
|
||||
public Set<TransporterStack> transit = new HashSet<TransporterStack>();
|
||||
|
||||
public boolean needsSync = false;
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
if(worldObj.isRemote)
|
||||
{
|
||||
for(TransporterStack stack : transit)
|
||||
{
|
||||
if(stack.clientFirstTick)
|
||||
{
|
||||
stack.clientFirstTick = false;
|
||||
}
|
||||
else {
|
||||
stack.progress++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Set<TransporterStack> remove = new HashSet<TransporterStack>();
|
||||
|
||||
for(TransporterStack stack : transit)
|
||||
|
@ -66,6 +78,7 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
|||
{
|
||||
if(next != null && next.getTileEntity(worldObj) instanceof TileEntityLogisticalTransporter)
|
||||
{
|
||||
needsSync = true;
|
||||
TileEntityLogisticalTransporter nextTile = (TileEntityLogisticalTransporter)next.getTileEntity(worldObj);
|
||||
nextTile.entityEntering(stack);
|
||||
remove.add(stack);
|
||||
|
@ -78,6 +91,7 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
|||
{
|
||||
if(next != null && next.getTileEntity(worldObj) instanceof IInventory)
|
||||
{
|
||||
needsSync = true;
|
||||
IInventory inventory = (IInventory)next.getTileEntity(worldObj);
|
||||
|
||||
if(inventory != null)
|
||||
|
@ -104,6 +118,9 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
|||
remove.add(stack);
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
stack.progress = 50;
|
||||
}
|
||||
}
|
||||
else if(stack.progress == 50)
|
||||
{
|
||||
|
@ -152,12 +169,18 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
|||
System.out.println(Object3D.get(this) + " " + stack.progress);
|
||||
}
|
||||
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Object3D.get(this), getItemPacket(new ArrayList())), Object3D.get(this), 50D);
|
||||
if(needsSync)
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())), Object3D.get(this), 50D);
|
||||
needsSync = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean recalculate(TransporterStack stack)
|
||||
{
|
||||
needsSync = true;
|
||||
|
||||
if(!stack.recalculatePath(this))
|
||||
{
|
||||
stack.calculateIdle(this);
|
||||
|
@ -174,6 +197,7 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
|||
|
||||
public boolean insert(Object3D original, ItemStack itemStack)
|
||||
{
|
||||
needsSync = true;
|
||||
TransporterStack stack = new TransporterStack();
|
||||
stack.itemStack = itemStack;
|
||||
stack.originalLocation = original;
|
||||
|
@ -192,6 +216,7 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
|||
{
|
||||
stack.progress = 0;
|
||||
transit.add(stack);
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())), Object3D.get(this), 50D);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -294,36 +319,22 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
|||
@Override
|
||||
public void handlePacketData(ByteArrayDataInput dataStream)
|
||||
{
|
||||
if(dataStream.readInt() == 0)
|
||||
transit.clear();
|
||||
|
||||
int amount = dataStream.readInt();
|
||||
|
||||
for(int i = 0; i < amount; i++)
|
||||
{
|
||||
isActive = dataStream.readBoolean();
|
||||
}
|
||||
else {
|
||||
transit.clear();
|
||||
TransporterStack stack = new TransporterStack();
|
||||
stack.read(dataStream);
|
||||
|
||||
int amount = dataStream.readInt();
|
||||
|
||||
for(int i = 0; i < amount; i++)
|
||||
{
|
||||
TransporterStack stack = new TransporterStack();
|
||||
stack.read(dataStream);
|
||||
|
||||
transit.add(stack);
|
||||
}
|
||||
transit.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList getNetworkedData(ArrayList data)
|
||||
{
|
||||
data.add(0);
|
||||
data.add(isActive);
|
||||
return data;
|
||||
}
|
||||
|
||||
public ArrayList getItemPacket(ArrayList data)
|
||||
{
|
||||
data.add(1);
|
||||
data.add(transit.size());
|
||||
|
||||
for(TransporterStack stack : transit)
|
||||
|
@ -338,8 +349,16 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
|||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
isActive = nbtTags.getBoolean("isActive");
|
||||
|
||||
if(nbtTags.hasKey("stacks"))
|
||||
{
|
||||
NBTTagList tagList = nbtTags.getTagList("stacks");
|
||||
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
transit.add(TransporterStack.read((NBTTagCompound)tagList.tagAt(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -347,7 +366,19 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
|
|||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setBoolean("isActive", isActive);
|
||||
NBTTagList stacks = new NBTTagList();
|
||||
|
||||
for(TransporterStack stack : transit)
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
stack.write(tagCompound);
|
||||
stacks.appendTag(tagCompound);
|
||||
}
|
||||
|
||||
if(stacks.tagCount() != 0)
|
||||
{
|
||||
nbtTags.setTag("stacks", stacks);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 6.3 KiB |
Loading…
Reference in a new issue