Allow Visual/Non Visual Boxes to differ for Custom Collsion / Buses.

This commit is contained in:
AlgorithmX2 2014-01-31 11:11:50 -06:00
parent dd37b28190
commit 8460cffd6c
13 changed files with 58 additions and 39 deletions

View file

@ -423,7 +423,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
if ( collisionHandler != null ) if ( collisionHandler != null )
{ {
Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxsFromPool( w, x, y, z ); Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxsFromPool( w, x, y, z, null, true );
MovingObjectPosition br = null; MovingObjectPosition br = null;
double lastDist = 0; double lastDist = 0;
@ -484,7 +484,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
{ {
LookDirection ld = Platform.getPlayerRay( Minecraft.getMinecraft().thePlayer ); LookDirection ld = Platform.getPlayerRay( Minecraft.getMinecraft().thePlayer );
Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxsFromPool( w, x, y, z ); Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxsFromPool( w, x, y, z, Minecraft.getMinecraft().thePlayer, true );
AxisAlignedBB br = null; AxisAlignedBB br = null;
double lastDist = 0; double lastDist = 0;
@ -519,7 +519,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
} }
} }
for (AxisAlignedBB bx : collisionHandler.getSelectedBoundingBoxsFromPool( w, x, y, z )) for (AxisAlignedBB bx : collisionHandler.getSelectedBoundingBoxsFromPool( w, x, y, z, null, false ))
{ {
if ( b == null ) if ( b == null )
b = bx; b = bx;

View file

@ -99,7 +99,7 @@ public class BlockCharger extends AEBaseBlock implements ICustomCollision
} }
@Override @Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z) public Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
{ {
TileCharger tile = getTileEntity( w, x, y, z ); TileCharger tile = getTileEntity( w, x, y, z );
if ( tile != null ) if ( tile != null )

View file

@ -85,7 +85,7 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
} }
@Override @Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z) public Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
{ {
ForgeDirection up = getOrientable( w, x, y, z ).getUp(); ForgeDirection up = getOrientable( w, x, y, z ).getUp();
double xOff = -0.3 * up.offsetX; double xOff = -0.3 * up.offsetX;
@ -97,10 +97,11 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
@Override @Override
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e) public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
{/* {/*
* double xOff = -0.15 * getUp().offsetX; double yOff = -0.15 * getUp().offsetY; double zOff = -0.15 * * double xOff = -0.15 * getUp().offsetX; double yOff = -0.15 *
* getUp().offsetZ; out.add( AxisAlignedBB.getAABBPool().getAABB( xOff + (double) x + 0.15, yOff + (double) y + * getUp().offsetY; double zOff = -0.15 * getUp().offsetZ; out.add(
* 0.15, zOff + (double) z + 0.15,// ahh xOff + (double) x + 0.85, yOff + (double) y + 0.85, zOff + (double) z + * AxisAlignedBB.getAABBPool().getAABB( xOff + (double) x + 0.15, yOff +
* 0.85 ) ); * (double) y + 0.15, zOff + (double) z + 0.15,// ahh xOff + (double) x +
* 0.85, yOff + (double) y + 0.85, zOff + (double) z + 0.85 ) );
*/ */
} }

View file

@ -142,7 +142,7 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
} }
@Override @Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z) public Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
{ {
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) } ); return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) } );
} }

View file

@ -42,7 +42,7 @@ public class BlockWireless extends AEBaseBlock implements ICustomCollision
} }
@Override @Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z) public Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
{ {
TileWireless tile = getTileEntity( w, x, y, z ); TileWireless tile = getTileEntity( w, x, y, z );
if ( tile != null ) if ( tile != null )

View file

@ -7,7 +7,6 @@ import java.util.Locale;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.client.me.SlotME; import appeng.client.me.SlotME;
import appeng.core.Configuration; import appeng.core.Configuration;
@ -53,8 +52,6 @@ public abstract class AEBaseMEGui extends AEBaseGui
currenttip.add( "\u00a77Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( stack.stackSize ) ); currenttip.add( "\u00a77Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( stack.stackSize ) );
} }
} }
else
currenttip.add( StatCollector.translateToLocal( "AppEng.Gui.Whitelisted" ) );
} }
return currenttip; return currenttip;
} }

View file

@ -89,6 +89,12 @@ public class BusRenderHelper implements IPartRenderHelper
return az; return az;
} }
@Override
public boolean isBBCollision()
{
return false;
}
}; };
BoundBoxCalculator bbc = new BoundBoxCalculator(); BoundBoxCalculator bbc = new BoundBoxCalculator();
@ -157,9 +163,8 @@ public class BusRenderHelper implements IPartRenderHelper
list[4] = West; list[4] = West;
list[5] = East; list[5] = East;
blk.getRendererInstance().setTemporaryRenderIcons( list[mapRotation( ForgeDirection.UP ).ordinal()], blk.getRendererInstance().setTemporaryRenderIcons( list[mapRotation( ForgeDirection.UP ).ordinal()], list[mapRotation( ForgeDirection.DOWN ).ordinal()],
list[mapRotation( ForgeDirection.DOWN ).ordinal()], list[mapRotation( ForgeDirection.SOUTH ).ordinal()], list[mapRotation( ForgeDirection.SOUTH ).ordinal()], list[mapRotation( ForgeDirection.NORTH ).ordinal()], list[mapRotation( ForgeDirection.EAST ).ordinal()],
list[mapRotation( ForgeDirection.NORTH ).ordinal()], list[mapRotation( ForgeDirection.EAST ).ordinal()],
list[mapRotation( ForgeDirection.WEST ).ordinal()] ); list[mapRotation( ForgeDirection.WEST ).ordinal()] );
} }

View file

@ -9,7 +9,7 @@ import net.minecraft.world.World;
public interface ICustomCollision public interface ICustomCollision
{ {
Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z); Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z, Entity thePlayer, boolean b);
void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e); void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e);

View file

@ -2,6 +2,7 @@ package appeng.parts;
import java.util.List; import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import appeng.api.parts.IPartCollsionHelper; import appeng.api.parts.IPartCollsionHelper;
@ -15,15 +16,22 @@ public class BusCollisionHelper implements IPartCollsionHelper
final private ForgeDirection y; final private ForgeDirection y;
final private ForgeDirection z; final private ForgeDirection z;
public BusCollisionHelper(List<AxisAlignedBB> boxes, ForgeDirection x, ForgeDirection y, ForgeDirection z) { final private Entity entity;
final private boolean isVisual;
public BusCollisionHelper(List<AxisAlignedBB> boxes, ForgeDirection x, ForgeDirection y, ForgeDirection z, Entity e, boolean visual) {
this.boxes = boxes; this.boxes = boxes;
this.x = x; this.x = x;
this.y = y; this.y = y;
this.z = z; this.z = z;
entity = e;
isVisual = visual;
} }
public BusCollisionHelper(List<AxisAlignedBB> boxes, ForgeDirection s) { public BusCollisionHelper(List<AxisAlignedBB> boxes, ForgeDirection s, Entity e, boolean visual) {
this.boxes = boxes; this.boxes = boxes;
entity = e;
isVisual = visual;
switch (s) switch (s)
{ {
@ -66,6 +74,12 @@ public class BusCollisionHelper implements IPartCollsionHelper
} }
} }
@Override
public boolean isBBCollision()
{
return !isVisual;
}
@Override @Override
public void addBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) public void addBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
{ {

View file

@ -366,13 +366,13 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
return null; return null;
} }
public Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(boolean ignoreCableConnections) public Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(boolean ignoreCableConnections, Entity e, boolean visual)
{ {
List<AxisAlignedBB> boxes = new LinkedList<AxisAlignedBB>(); List<AxisAlignedBB> boxes = new LinkedList<AxisAlignedBB>();
for (ForgeDirection s : ForgeDirection.values()) for (ForgeDirection s : ForgeDirection.values())
{ {
IPartCollsionHelper bch = new BusCollisionHelper( boxes, s ); IPartCollsionHelper bch = new BusCollisionHelper( boxes, s, e, visual );
IPart part = getPart( s ); IPart part = getPart( s );
if ( part != null ) if ( part != null )
@ -543,8 +543,7 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
if ( part != null ) if ( part != null )
{ {
setSide( s ); setSide( s );
BusCollisionHelper bch = new BusCollisionHelper( boxes, BusRenderHelper.instance.ax, BusRenderHelper.instance.ay, BusCollisionHelper bch = new BusCollisionHelper( boxes, BusRenderHelper.instance.ax, BusRenderHelper.instance.ay, BusRenderHelper.instance.az, null, true );
BusRenderHelper.instance.az );
part.getBoxes( bch ); part.getBoxes( bch );
} }
} }
@ -937,7 +936,7 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
{ {
List<AxisAlignedBB> boxes = new LinkedList<AxisAlignedBB>(); List<AxisAlignedBB> boxes = new LinkedList<AxisAlignedBB>();
IPartCollsionHelper bch = new BusCollisionHelper( boxes, side ); IPartCollsionHelper bch = new BusCollisionHelper( boxes, side, null, true );
p.getBoxes( bch ); p.getBoxes( bch );
for (AxisAlignedBB bb : boxes) for (AxisAlignedBB bb : boxes)
{ {
@ -957,7 +956,7 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
{ {
List<AxisAlignedBB> boxes = new LinkedList<AxisAlignedBB>(); List<AxisAlignedBB> boxes = new LinkedList<AxisAlignedBB>();
IPartCollsionHelper bch = new BusCollisionHelper( boxes, side ); IPartCollsionHelper bch = new BusCollisionHelper( boxes, side, null, true );
p.getBoxes( bch ); p.getBoxes( bch );
for (AxisAlignedBB bb : boxes) for (AxisAlignedBB bb : boxes)
{ {

View file

@ -95,7 +95,11 @@ public class PartDenseCable extends PartCable
@Override @Override
public void getBoxes(IPartCollsionHelper bch) public void getBoxes(IPartCollsionHelper bch)
{ {
bch.addBox( 3.0, 3.0, 3.0, 13.0, 13.0, 13.0 ); boolean noLadder = !bch.isBBCollision();
double min = noLadder ? 3.0 : 4.9;
double max = noLadder ? 13.0 : 11.1;
bch.addBox( min, min, min, max, max, max );
if ( Platform.isServer() ) if ( Platform.isServer() )
{ {
@ -113,22 +117,22 @@ public class PartDenseCable extends PartCable
switch (of) switch (of)
{ {
case DOWN: case DOWN:
bch.addBox( 3.0, 0.0, 3.0, 13.0, 3.0, 13.0 ); bch.addBox( min, 0.0, min, max, min, max );
break; break;
case EAST: case EAST:
bch.addBox( 13.0, 3.0, 3.0, 16.0, 13.0, 13.0 ); bch.addBox( max, min, min, 16.0, max, max );
break; break;
case NORTH: case NORTH:
bch.addBox( 3.0, 3.0, 0.0, 13.0, 13.0, 3.0 ); bch.addBox( min, min, 0.0, max, max, min );
break; break;
case SOUTH: case SOUTH:
bch.addBox( 3.0, 3.0, 13.0, 13.0, 13.0, 16.0 ); bch.addBox( min, min, max, max, max, 16.0 );
break; break;
case UP: case UP:
bch.addBox( 3.0, 13.0, 3.0, 13.0, 16.0, 13.0 ); bch.addBox( min, max, min, max, 16.0, max );
break; break;
case WEST: case WEST:
bch.addBox( 0.0, 3.0, 3.0, 3.0, 13.0, 13.0 ); bch.addBox( 0.0, min, min, min, max, max );
break; break;
default: default:
continue; continue;

View file

@ -111,13 +111,12 @@ public class TileCrank extends AEBaseTile implements ICustomCollision
} }
@Override @Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z) public Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
{ {
double xOff = -0.15 * getUp().offsetX; double xOff = -0.15 * getUp().offsetX;
double yOff = -0.15 * getUp().offsetY; double yOff = -0.15 * getUp().offsetY;
double zOff = -0.15 * getUp().offsetZ; double zOff = -0.15 * getUp().offsetZ;
return Arrays return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( xOff + 0.15, yOff + 0.15, zOff + 0.15, xOff + 0.85, yOff + 0.85, zOff + 0.85 ) } );
.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( xOff + 0.15, yOff + 0.15, zOff + 0.15, xOff + 0.85, yOff + 0.85, zOff + 0.85 ) } );
} }
@Override @Override

View file

@ -174,15 +174,15 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
} }
@Override @Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z) public Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z, Entity e, boolean visual)
{ {
return cb.getSelectedBoundingBoxsFromPool( false ); return cb.getSelectedBoundingBoxsFromPool( false, e, visual );
} }
@Override @Override
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e) public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
{ {
for (AxisAlignedBB bx : getSelectedBoundingBoxsFromPool( w, x, y, z )) for (AxisAlignedBB bx : getSelectedBoundingBoxsFromPool( w, x, y, z, e, false ))
out.add( AxisAlignedBB.getAABBPool().getAABB( bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ ) ); out.add( AxisAlignedBB.getAABBPool().getAABB( bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ ) );
} }