A few fixes and new mechanics

This commit is contained in:
Aidan Brady 2013-11-21 20:31:28 -05:00
parent 41eda67517
commit 5f2545d8e8
4 changed files with 51 additions and 37 deletions

View file

@ -48,45 +48,34 @@ public class RobitAIPickup extends EntityAIBase
@Override @Override
public boolean shouldExecute() public boolean shouldExecute()
{ {
EntityPlayer player = theRobit.getOwner();
if(player == null)
{
return false;
}
if(!theRobit.getDropPickup()) if(!theRobit.getDropPickup())
{ {
return false; return false;
} }
else if(theRobit.worldObj.provider.dimensionId != player.worldObj.provider.dimensionId) if(closest != null && closest.getDistanceSqToEntity(closest) > 100 && thePathfinder.getPathToXYZ(closest.posX, closest.posY, closest.posZ) != null)
{
return false;
}
if(closest!=null&&closest.getDistanceSqToEntity(closest) > 100 && thePathfinder.getPathToXYZ(closest.posX, closest.posY, closest.posZ)!=null)
{ {
return true; return true;
} }
List items = theRobit.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(theRobit.posX-10, theRobit.posY-10, theRobit.posZ-10, theRobit.posX+10, theRobit.posY+10, theRobit.posZ+10)); List items = theRobit.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(theRobit.posX-10, theRobit.posY-10, theRobit.posZ-10, theRobit.posX+10, theRobit.posY+10, theRobit.posZ+10));
Iterator iter=items.iterator(); Iterator iter = items.iterator();
//Cached for slight performance //Cached for slight performance
double closestDistance=-1; double closestDistance=-1;
while(iter.hasNext()) while(iter.hasNext())
{ {
EntityItem entity=(EntityItem) iter.next(); EntityItem entity = (EntityItem)iter.next();
double distance=theRobit.getDistanceToEntity(entity); double distance = theRobit.getDistanceToEntity(entity);
if(distance <= 10) if(distance <= 10)
{ {
if(closestDistance==-1||distance<closestDistance) if(closestDistance == -1 || distance < closestDistance)
{ {
if(thePathfinder.getPathToXYZ(entity.posX, entity.posY, entity.posZ)!=null) if(thePathfinder.getPathToXYZ(entity.posX, entity.posY, entity.posZ) != null)
{ {
closest=entity; closest = entity;
closestDistance=distance; closestDistance = distance;
} }
} }
} }
@ -105,7 +94,7 @@ public class RobitAIPickup extends EntityAIBase
@Override @Override
public boolean continueExecuting() public boolean continueExecuting()
{ {
return !closest.isDead && !thePathfinder.noPath() && theRobit.getDistanceSqToEntity(closest) > (100) && theRobit.getFollowing() && theRobit.getEnergy() > 0 && closest.worldObj.provider.dimensionId == theRobit.worldObj.provider.dimensionId; return !closest.isDead && !thePathfinder.noPath() && theRobit.getDistanceSqToEntity(closest) > 100 && theRobit.getFollowing() && theRobit.getEnergy() > 0 && closest.worldObj.provider.dimensionId == theRobit.worldObj.provider.dimensionId;
} }
@Override @Override

View file

@ -169,6 +169,25 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
} }
} }
if(tileEntity instanceof TileEntityLogisticalSorter)
{
TileEntityLogisticalSorter transporter = (TileEntityLogisticalSorter)tileEntity;
if(!world.isRemote && !transporter.hasInventory())
{
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity tile = Object3D.get(transporter).getFromSide(dir).getTileEntity(world);
if(tile instanceof IInventory)
{
transporter.setFacing((short)dir.getOpposite().ordinal());
break;
}
}
}
}
tileEntity.setFacing((short)change); tileEntity.setFacing((short)change);
if(tileEntity instanceof IBoundingBlock) if(tileEntity instanceof IBoundingBlock)

View file

@ -8,9 +8,11 @@ import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission; import mekanism.common.PacketHandler.Transmission;
import mekanism.common.item.ItemBlockBasic; import mekanism.common.item.ItemBlockBasic;
import mekanism.common.network.PacketTileEntity; import mekanism.common.network.PacketTileEntity;
import mekanism.common.util.InventoryUtils;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import mekanism.common.util.TransporterUtils; import mekanism.common.util.TransporterUtils;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -174,6 +176,10 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento
setInventorySlotContents(0, null); setInventorySlotContents(0, null);
} }
} }
else if(tile instanceof IInventory)
{
setInventorySlotContents(0, InventoryUtils.putStackInInventory((IInventory)tile, getStack(), 0, false));
}
} }
} }
} }

View file

@ -108,23 +108,6 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
{ {
ChargeUtils.discharge(27, this); ChargeUtils.discharge(27, this);
if(doEject && getTopEject(false, null) != null && getEjectInv() != null)
{
if(getEjectInv() instanceof IInventory)
{
ItemStack remains = InventoryUtils.putStackInInventory((IInventory)getEjectInv(), getTopEject(false, null), ForgeDirection.getOrientation(facing).getOpposite().ordinal(), false);
getTopEject(true, remains);
}
else if(getEjectInv() instanceof TileEntityLogisticalTransporter)
{
if(TransporterUtils.insert(getEjectTile(), (TileEntityLogisticalTransporter)getEjectInv(), getTopEject(false, null), null))
{
getTopEject(true, null);
}
}
}
if(running && getEnergy() >= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_USAGE) && searcher.state == State.FINISHED && oresToMine.size() > 0) if(running && getEnergy() >= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_USAGE) && searcher.state == State.FINISHED && oresToMine.size() > 0)
{ {
setActive(true); setActive(true);
@ -198,6 +181,23 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
} }
} }
if(doEject && getTopEject(false, null) != null && getEjectInv() != null)
{
if(getEjectInv() instanceof IInventory)
{
ItemStack remains = InventoryUtils.putStackInInventory((IInventory)getEjectInv(), getTopEject(false, null), ForgeDirection.getOrientation(facing).getOpposite().ordinal(), false);
getTopEject(true, remains);
}
else if(getEjectInv() instanceof TileEntityLogisticalTransporter)
{
if(TransporterUtils.insert(getEjectTile(), (TileEntityLogisticalTransporter)getEjectInv(), getTopEject(false, null), null))
{
getTopEject(true, null);
}
}
}
if(playersUsing.size() > 0) if(playersUsing.size() > 0)
{ {
for(EntityPlayer player : playersUsing) for(EntityPlayer player : playersUsing)