Fix up Robit pickup AI, and update donator cape list! Thanks ejmiv89! :)

This commit is contained in:
Aidan Brady 2013-11-21 19:06:22 -05:00
parent 6ff12e2c81
commit b7c7f58f2c
2 changed files with 39 additions and 30 deletions

View file

@ -1148,6 +1148,7 @@ public class Mekanism
//Donators //Donators
donators.add("mrgreaper"); donators.add("mrgreaper");
donators.add("ejmiv89");
//Load proxy //Load proxy
proxy.registerRenderInformation(); proxy.registerRenderInformation();

View file

@ -11,15 +11,15 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
/*
* Written by pixlepix (I'm in mekanism! Yay!)
* Boilerplate copied from RobitAIFollow
*/
public class RobitAIPickup extends EntityAIBase public class RobitAIPickup extends EntityAIBase
{ {
//Written by pixlepix (I'm in mekanism! Yay!)
//Boilerplate copied from RobitAIFollow
/** The robit entity. */ /** The robit entity. */
private EntityRobit theRobit; private EntityRobit theRobit;
/** The world the robit is located in. */ /** The world the robit is located in. */
private World theWorld; private World theWorld;
@ -32,8 +32,6 @@ public class RobitAIPickup extends EntityAIBase
/** The ticker for updates. */ /** The ticker for updates. */
private int ticker; private int ticker;
/** Whether or not this robit avoids water. */ /** Whether or not this robit avoids water. */
private boolean avoidWater; private boolean avoidWater;
private EntityItem closest; private EntityItem closest;
@ -56,38 +54,50 @@ public class RobitAIPickup extends EntityAIBase
{ {
return false; return false;
} }
if(!theRobit.getDropPickup()){
if(!theRobit.getDropPickup())
{
return false; return false;
} }
else if(theRobit.worldObj.provider.dimensionId != player.worldObj.provider.dimensionId) else if(theRobit.worldObj.provider.dimensionId != player.worldObj.provider.dimensionId)
{ {
return false; return false;
} }
if(closest!=null&&closest.getDistanceSqToEntity(closest)>100&&this.thePathfinder.getPathToXYZ(closest.posX, closest.posY, closest.posZ)!=null){ 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.getDistanceSqToEntity(entity);
if(distance<100){ double distance=theRobit.getDistanceToEntity(entity);
if(closestDistance==-1||distance<closestDistance){
if(this.thePathfinder.getPathToXYZ(entity.posX, entity.posY, entity.posZ)!=null){ if(distance <= 10)
{
if(closestDistance==-1||distance<closestDistance)
{
if(thePathfinder.getPathToXYZ(entity.posX, entity.posY, entity.posZ)!=null)
{
closest=entity; closest=entity;
closestDistance=distance; closestDistance=distance;
} }
} }
} }
} }
if(closest==null){
if(closest == null)
{
//No valid items //No valid items
return false; return false;
} }
return true; return true;
} }
@ -116,10 +126,10 @@ public class RobitAIPickup extends EntityAIBase
@Override @Override
public void updateTask() public void updateTask()
{ {
System.out.println(6);
theRobit.getLookHelper().setLookPositionWithEntity(closest, 6.0F, theRobit.getVerticalFaceSpeed()/10); theRobit.getLookHelper().setLookPositionWithEntity(closest, 6.0F, theRobit.getVerticalFaceSpeed()/10);
if(!theRobit.getDropPickup()){
if(!theRobit.getDropPickup())
{
return; return;
} }
@ -141,8 +151,6 @@ public class RobitAIPickup extends EntityAIBase
{ {
if((l < 1 || i1 < 1 || l > 3 || i1 > 3) && theWorld.doesBlockHaveSolidTopSurface(x + l, z - 1, y + i1) && !theWorld.isBlockNormalCube(x + l, z, y + i1) && !theWorld.isBlockNormalCube(x + l, z + 1, y + i1)) if((l < 1 || i1 < 1 || l > 3 || i1 > 3) && theWorld.doesBlockHaveSolidTopSurface(x + l, z - 1, y + i1) && !theWorld.isBlockNormalCube(x + l, z, y + i1) && !theWorld.isBlockNormalCube(x + l, z + 1, y + i1))
{ {
System.out.println(7);
theRobit.setLocationAndAngles((x + l) + 0.5F, z, (y + i1) + 0.5F, theRobit.rotationYaw, theRobit.rotationPitch); theRobit.setLocationAndAngles((x + l) + 0.5F, z, (y + i1) + 0.5F, theRobit.rotationYaw, theRobit.rotationPitch);
thePathfinder.clearPathEntity(); thePathfinder.clearPathEntity();
return; return;