Fixed bug causing ghost items and crash

This commit is contained in:
Aidan C. Brady 2013-10-29 18:54:36 -04:00
parent 4962dd62b3
commit 70bed1ba97
4 changed files with 39 additions and 16 deletions

View file

@ -43,19 +43,24 @@ public class HashList<T> implements Iterable<T>
}
}
public boolean isEmpty()
{
return list.isEmpty();
}
public void remove(int index)
{
if(isEmpty() || index > size()-1)
{
return;
}
list.remove(index);
}
public void replace(int index, T obj)
{
if(contains(obj))
{
remove(obj);
}
if(index == size()-1)
if(get(index) != null)
{
remove(index);
}

View file

@ -174,13 +174,11 @@ public class TileEntityLogisticalTransporter extends TileEntity implements ITile
if(!stack.recalculatePath(this))
{
stack.calculateIdle(this);
}
if(!stack.hasPath())
{
TransporterUtils.drop(this, stack);
return false;
if(!stack.calculateIdle(this))
{
TransporterUtils.drop(this, stack);
return false;
}
}
return true;

View file

@ -150,12 +150,22 @@ public class TransporterStack
return true;
}
public void calculateIdle(TileEntityLogisticalTransporter tileEntity)
public boolean calculateIdle(TileEntityLogisticalTransporter tileEntity)
{
pathToTarget = TransporterPathfinder.getIdlePath(tileEntity, this);
List<Object3D> newPath = TransporterPathfinder.getIdlePath(tileEntity, this);
if(newPath == null)
{
return false;
}
pathToTarget = newPath;
noTarget = true;
originalLocation = Object3D.get(tileEntity);
initiatedPath = true;
return true;
}
public boolean isFinal(TileEntityLogisticalTransporter tileEntity)

View file

@ -9,6 +9,7 @@ import mekanism.api.transmitters.ITransmitter;
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
import mekanism.common.transporter.SlotInfo;
import mekanism.common.transporter.TransporterStack;
import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
@ -370,7 +371,16 @@ public final class TransporterUtils
public static void drop(TileEntityLogisticalTransporter tileEntity, TransporterStack stack)
{
float[] pos = TransporterUtils.getStackPosition(tileEntity, stack, 0);
float[] pos = null;
if(stack.pathToTarget != null)
{
pos = TransporterUtils.getStackPosition(tileEntity, stack, 0);
}
else {
pos = new float[] {0, 0, 0};
}
EntityItem entityItem = new EntityItem(tileEntity.worldObj, tileEntity.xCoord + pos[0], tileEntity.yCoord + pos[1], tileEntity.zCoord + pos[2], stack.itemStack);
entityItem.motionX = 0;