Fixed bug causing ghost items and crash
This commit is contained in:
parent
4962dd62b3
commit
70bed1ba97
4 changed files with 39 additions and 16 deletions
|
@ -43,19 +43,24 @@ public class HashList<T> implements Iterable<T>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty()
|
||||||
|
{
|
||||||
|
return list.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
public void remove(int index)
|
public void remove(int index)
|
||||||
{
|
{
|
||||||
|
if(isEmpty() || index > size()-1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
list.remove(index);
|
list.remove(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replace(int index, T obj)
|
public void replace(int index, T obj)
|
||||||
{
|
{
|
||||||
if(contains(obj))
|
if(get(index) != null)
|
||||||
{
|
|
||||||
remove(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(index == size()-1)
|
|
||||||
{
|
{
|
||||||
remove(index);
|
remove(index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,13 +174,11 @@ public class TileEntityLogisticalTransporter extends TileEntity implements ITile
|
||||||
|
|
||||||
if(!stack.recalculatePath(this))
|
if(!stack.recalculatePath(this))
|
||||||
{
|
{
|
||||||
stack.calculateIdle(this);
|
if(!stack.calculateIdle(this))
|
||||||
}
|
{
|
||||||
|
TransporterUtils.drop(this, stack);
|
||||||
if(!stack.hasPath())
|
return false;
|
||||||
{
|
}
|
||||||
TransporterUtils.drop(this, stack);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -150,12 +150,22 @@ public class TransporterStack
|
||||||
return true;
|
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;
|
noTarget = true;
|
||||||
originalLocation = Object3D.get(tileEntity);
|
originalLocation = Object3D.get(tileEntity);
|
||||||
initiatedPath = true;
|
initiatedPath = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFinal(TileEntityLogisticalTransporter tileEntity)
|
public boolean isFinal(TileEntityLogisticalTransporter tileEntity)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import mekanism.api.transmitters.ITransmitter;
|
||||||
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
|
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
|
||||||
import mekanism.common.transporter.SlotInfo;
|
import mekanism.common.transporter.SlotInfo;
|
||||||
import mekanism.common.transporter.TransporterStack;
|
import mekanism.common.transporter.TransporterStack;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.inventory.ISidedInventory;
|
import net.minecraft.inventory.ISidedInventory;
|
||||||
|
@ -370,7 +371,16 @@ public final class TransporterUtils
|
||||||
|
|
||||||
public static void drop(TileEntityLogisticalTransporter tileEntity, TransporterStack stack)
|
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 entityItem = new EntityItem(tileEntity.worldObj, tileEntity.xCoord + pos[0], tileEntity.yCoord + pos[1], tileEntity.zCoord + pos[2], stack.itemStack);
|
||||||
|
|
||||||
entityItem.motionX = 0;
|
entityItem.motionX = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue