Work on contractor bounds

This commit is contained in:
Aidan Brady 2013-08-03 00:53:33 -04:00
parent 5bc0b50219
commit 143b3cfdda
3 changed files with 48 additions and 3 deletions

View file

@ -30,7 +30,7 @@ public class BlockEMContractor extends BlockBase implements ITileEntityProvider
@Override
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
{
if(par1World.isRemote && !par5EntityPlayer.isSneaking())
if(!par5EntityPlayer.isSneaking())
{
TileEntityEMContractor contractor = (TileEntityEMContractor)par1World.getBlockTileEntity(par2, par3, par4);
contractor.incrementFacing();

View file

@ -1,16 +1,61 @@
package resonantinduction.contractor;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.ForgeDirection;
public class TileEntityEMContractor extends TileEntity
{
public static int MAX_REACH = 40;
public ForgeDirection facing = ForgeDirection.UP;
/**
* true = suck, false = push
*/
public boolean suck;
@Override
public void updateEntity()
{
AxisAlignedBB box = null;
if(!worldObj.isRemote)
{
switch(facing)
{
case DOWN:
box = AxisAlignedBB.getBoundingBox(xCoord, Math.max(yCoord-MAX_REACH, 1), zCoord, xCoord+1, yCoord, zCoord+1);
break;
case UP:
box = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord+1, Math.min(yCoord+MAX_REACH, 255), zCoord+1);
break;
case NORTH:
box = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord+MAX_REACH, yCoord+1, zCoord+1);
break;
case SOUTH:
box = AxisAlignedBB.getBoundingBox(xCoord-MAX_REACH, yCoord, zCoord, xCoord, yCoord+1, zCoord+1);
break;
case WEST:
box = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord+1, yCoord+1, zCoord+MAX_REACH);
break;
case EAST:
box = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord-MAX_REACH, xCoord+1, yCoord+1, zCoord);
break;
}
List list = worldObj.getEntitiesWithinAABB(EntityPlayer.class, box);
System.out.println(facing.ordinal());
if(!list.isEmpty())
{
System.out.println("Good!");
}
}
}
public void incrementFacing()

View file

@ -24,12 +24,12 @@ public class RenderEMContractor extends TileEntitySpecialRenderer
switch(((TileEntityEMContractor)t).facing)
{
case UP:
break;
case DOWN:
GL11.glRotatef(180, 0, 0, 1);
GL11.glTranslatef(0, -2, 0);
break;
case UP:
break;
case NORTH:
GL11.glTranslatef(-1, 1, 0);
GL11.glRotatef(-90, 0, 0, 1);