More work, fixing client crashes

This commit is contained in:
Aidan C. Brady 2013-10-21 23:03:54 -04:00
parent b4e53a5c54
commit ed5c30fb0a
4 changed files with 49 additions and 21 deletions

View file

@ -52,12 +52,15 @@ public class RenderLogisticalTransporter extends TileEntitySpecialRenderer
GL11.glEnable(GL11.GL_CULL_FACE);
entityItem.age = 0;
entityItem.hoverStart = 0;
for(TransporterStack stack : tileEntity.transit)
{
entityItem.setEntityItemStack(stack.itemStack);
Object3D offset = new Object3D(0, 0, 0).step(ForgeDirection.getOrientation(stack.getSide(tileEntity)));
double progress = (double)stack.progress / 100D * 0.5D;
double progress = ((double)stack.progress / 100D) * 0.5D;
renderer.doRenderItem(entityItem, x + 0.5 + offset.xCoord*progress, y + 1.5 + offset.yCoord*progress, z + 0.5 + offset.zCoord*progress, 0, 0);
}

View file

@ -24,7 +24,7 @@ public final class TransporterPathfinder
public TileEntityLogisticalTransporter start;
public Set<Object3D> possibleDestinations = new HashSet<Object3D>();
public Object3D lastFound;
public IdleDest(World world, TileEntityLogisticalTransporter tileEntity)
{
@ -34,7 +34,7 @@ public final class TransporterPathfinder
public void loop(TileEntityLogisticalTransporter pointer)
{
if(pointer == null)
if(pointer == null || lastFound != null)
{
return;
}
@ -56,7 +56,8 @@ public final class TransporterPathfinder
if(!found)
{
possibleDestinations.add(Object3D.get(pointer));
lastFound = Object3D.get(pointer);
return;
}
}
@ -64,17 +65,7 @@ public final class TransporterPathfinder
{
loop(start);
Object3D furthest = null;
for(Object3D obj : possibleDestinations)
{
if(furthest == null || obj.distanceTo(Object3D.get(start)) > furthest.distanceTo(Object3D.get(start)))
{
furthest = obj;
}
}
return furthest;
return lastFound;
}
}
@ -303,6 +294,7 @@ public final class TransporterPathfinder
System.out.println("Target found: " + closest);
Path p = new Path(d.worldObj, d.finalNode, Object3D.get(start), closest);
System.out.println("Path:"+p.getPath());
return p.getPath();
}
@ -317,6 +309,7 @@ public final class TransporterPathfinder
}
Path p = new Path(start.worldObj, prevHome, Object3D.get(start), null);
System.out.println("Idle:" + p.getPath());
return p.getPath();
}
}

View file

@ -32,16 +32,36 @@ public class TransporterStack
{
data.add(progress);
data.add(noTarget);
getNext(tileEntity).write(data);
if(noTarget && pathToTarget.indexOf(Object3D.get(tileEntity)) > 0)
{
data.add(true);
getNext(tileEntity).write(data);
}
else {
data.add(false);
}
getPrev(tileEntity).write(data);
data.add(itemStack.itemID);
data.add(itemStack.stackSize);
data.add(itemStack.getItemDamage());
}
public void read(ByteArrayDataInput dataStream)
{
progress = dataStream.readInt();
noTarget = dataStream.readBoolean();
clientNext = Object3D.read(dataStream);
if(dataStream.readBoolean())
{
clientNext = Object3D.read(dataStream);
}
clientPrev = Object3D.read(dataStream);
itemStack = new ItemStack(dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
}
public void write(NBTTagCompound nbtTags)
@ -49,6 +69,7 @@ public class TransporterStack
nbtTags.setInteger("progress", progress);
originalLocation.write(nbtTags);
nbtTags.setBoolean("noTarget", noTarget);
itemStack.writeToNBT(nbtTags);
}
public void read(NBTTagCompound nbtTags)
@ -56,6 +77,7 @@ public class TransporterStack
progress = nbtTags.getInteger("progress");
originalLocation = Object3D.read(nbtTags);
noTarget = nbtTags.getBoolean("noTarget");
itemStack = ItemStack.loadItemStackFromNBT(nbtTags);
}
public boolean hasPath()
@ -82,10 +104,9 @@ public class TransporterStack
public void calculateIdle(TileEntityLogisticalTransporter tileEntity)
{
Object3D prevDest = pathToTarget.get(0);
pathToTarget = TransporterPathfinder.getIdlePath(tileEntity, originalLocation, pathToTarget.get(pathToTarget.size()-1));
noTarget = true;
originalLocation = prevDest;
originalLocation = Object3D.get(tileEntity);
initiatedPath = true;
}
@ -131,9 +152,12 @@ public class TransporterStack
{
return Object3D.get(tileEntity).sideDifference(getPrev(tileEntity)).ordinal();
}
else {
else if(progress > 50)
{
return Object3D.get(tileEntity).sideDifference(getNext(tileEntity)).ordinal();
}
return 0;
}
public Object3D getDest()

View file

@ -55,9 +55,14 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
stack.progress++;
if(stack.progress > 50)
{
System.out.println(stack.getNext(this));
}
if(stack.progress > 100)
{
if(stack.hasPath() && !stack.noTarget)
if(stack.hasPath())
{
int currentIndex = stack.pathToTarget.indexOf(Object3D.get(this));
Object3D next = stack.pathToTarget.get(currentIndex-1);
@ -150,6 +155,7 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
for(TransporterStack stack : transit)
{
System.out.println(Object3D.get(this) + " " + stack.progress);
System.out.println(stack.pathToTarget);
}
if(!transit.isEmpty())
@ -302,6 +308,8 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<Inven
isActive = dataStream.readBoolean();
}
else {
transit.clear();
int amount = dataStream.readInt();
for(int i = 0; i < amount; i++)