mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-07-04 02:52:56 +00:00
Make cable collision boxes more accurate for cables
Each cable segment is added to the list, meaning you can get close and snugly with the cables.
This commit is contained in:
parent
d87b0e9435
commit
f34a319b79
@ -218,6 +218,12 @@ public abstract class BlockGeneric extends Block implements
|
|||||||
return FULL_BLOCK_AABB;
|
return FULL_BLOCK_AABB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AxisAlignedBB getSelectedBoundingBox( IBlockState state, World worldIn, BlockPos pos )
|
||||||
|
{
|
||||||
|
return getBoundingBox( state, worldIn, pos ).offset( pos );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final AxisAlignedBB getCollisionBoundingBox( IBlockState state, World world, BlockPos pos )
|
public final AxisAlignedBB getCollisionBoundingBox( IBlockState state, World world, BlockPos pos )
|
||||||
{
|
{
|
||||||
|
@ -37,6 +37,19 @@ import java.util.*;
|
|||||||
public class TileCable extends TileModemBase
|
public class TileCable extends TileModemBase
|
||||||
implements INetwork
|
implements INetwork
|
||||||
{
|
{
|
||||||
|
private static final double MIN = 0.375;
|
||||||
|
private static final double MAX = 1 - MIN;
|
||||||
|
|
||||||
|
private static final AxisAlignedBB BOX_CENTRE = new AxisAlignedBB( MIN, MIN, MIN, MAX, MAX, MAX );
|
||||||
|
private static final AxisAlignedBB[] BOXES = new AxisAlignedBB[]{
|
||||||
|
new AxisAlignedBB( MIN, 0, MIN, MAX, MIN, MAX ), // Down
|
||||||
|
new AxisAlignedBB( MIN, MAX, MIN, MAX, 1, MAX ), // Up
|
||||||
|
new AxisAlignedBB( MIN, MIN, 0, MAX, MAX, MIN ), // North
|
||||||
|
new AxisAlignedBB( MIN, MIN, MAX, MAX, MAX, 1 ), // South
|
||||||
|
new AxisAlignedBB( 0, MIN, MIN, MIN, MAX, MAX ), // West
|
||||||
|
new AxisAlignedBB( MAX, MIN, MIN, 1, MAX, MAX ), // East
|
||||||
|
};
|
||||||
|
|
||||||
// Statics
|
// Statics
|
||||||
|
|
||||||
private static class Peripheral extends ModemPeripheral
|
private static class Peripheral extends ModemPeripheral
|
||||||
@ -415,14 +428,7 @@ public class TileCable extends TileModemBase
|
|||||||
{
|
{
|
||||||
AxisAlignedBB modem = getModemBounds();
|
AxisAlignedBB modem = getModemBounds();
|
||||||
AxisAlignedBB cable = getCableBounds();
|
AxisAlignedBB cable = getCableBounds();
|
||||||
return new AxisAlignedBB(
|
return modem.union( cable );
|
||||||
Math.min( modem.minX, cable.minX ),
|
|
||||||
Math.min( modem.minY, cable.minY ),
|
|
||||||
Math.min( modem.minZ, cable.minZ ),
|
|
||||||
Math.max( modem.maxX, cable.maxX ),
|
|
||||||
Math.max( modem.maxY, cable.maxY ),
|
|
||||||
Math.max( modem.maxZ, cable.maxZ )
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -437,7 +443,15 @@ public class TileCable extends TileModemBase
|
|||||||
}
|
}
|
||||||
if( type == PeripheralType.Cable || type == PeripheralType.WiredModemWithCable )
|
if( type == PeripheralType.Cable || type == PeripheralType.WiredModemWithCable )
|
||||||
{
|
{
|
||||||
bounds.add( getCableBounds() );
|
bounds.add( BOX_CENTRE );
|
||||||
|
BlockPos pos = getPos();
|
||||||
|
for (EnumFacing facing : EnumFacing.VALUES)
|
||||||
|
{
|
||||||
|
if( BlockCable.isCable( worldObj, pos.offset( facing ) ) )
|
||||||
|
{
|
||||||
|
bounds.add( BOXES[ facing.ordinal() ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,12 +9,22 @@ package dan200.computercraft.shared.peripheral.modem;
|
|||||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||||
import dan200.computercraft.shared.common.BlockGeneric;
|
import dan200.computercraft.shared.common.BlockGeneric;
|
||||||
import dan200.computercraft.shared.peripheral.common.TilePeripheralBase;
|
import dan200.computercraft.shared.peripheral.common.TilePeripheralBase;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
|
|
||||||
public abstract class TileModemBase extends TilePeripheralBase
|
public abstract class TileModemBase extends TilePeripheralBase
|
||||||
{
|
{
|
||||||
|
private static final AxisAlignedBB[] BOXES = new AxisAlignedBB[] {
|
||||||
|
new AxisAlignedBB( 0.125, 0.0, 0.125, 0.875, 0.1875, 0.875 ), // Down
|
||||||
|
new AxisAlignedBB( 0.125, 0.8125, 0.125, 0.875, 1.0, 0.875 ), // Up
|
||||||
|
new AxisAlignedBB( 0.125, 0.125, 0.0, 0.875, 0.875, 0.1875 ), // North
|
||||||
|
new AxisAlignedBB( 0.125, 0.125, 0.8125, 0.875, 0.875, 1.0 ), // South
|
||||||
|
new AxisAlignedBB( 0.0, 0.125, 0.125, 0.1875, 0.875, 0.875 ), // West
|
||||||
|
new AxisAlignedBB( 0.8125, 0.125, 0.125, 1.0, 0.875, 0.875 ), // East
|
||||||
|
};
|
||||||
|
|
||||||
protected ModemPeripheral m_modem;
|
protected ModemPeripheral m_modem;
|
||||||
|
|
||||||
protected TileModemBase()
|
protected TileModemBase()
|
||||||
@ -58,34 +68,8 @@ public abstract class TileModemBase extends TilePeripheralBase
|
|||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getBounds()
|
public AxisAlignedBB getBounds()
|
||||||
{
|
{
|
||||||
switch( getDirection() )
|
int direction = getDirection().ordinal();
|
||||||
{
|
return direction >= 0 && direction < BOXES.length ? BOXES[ direction ] : Block.FULL_BLOCK_AABB;
|
||||||
case UP:
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
return new AxisAlignedBB( 0.125, 0.8125, 0.125, 0.875, 1.0, 0.875 );
|
|
||||||
}
|
|
||||||
case DOWN:
|
|
||||||
{
|
|
||||||
return new AxisAlignedBB( 0.125, 0.0, 0.125, 0.875, 0.1875, 0.875 );
|
|
||||||
}
|
|
||||||
case NORTH:
|
|
||||||
{
|
|
||||||
return new AxisAlignedBB( 0.125, 0.125, 0.0, 0.875, 0.875, 0.1875 );
|
|
||||||
}
|
|
||||||
case SOUTH:
|
|
||||||
{
|
|
||||||
return new AxisAlignedBB( 0.125, 0.125, 0.8125, 0.875, 0.875, 1.0 );
|
|
||||||
}
|
|
||||||
case WEST:
|
|
||||||
{
|
|
||||||
return new AxisAlignedBB( 0.0, 0.125, 0.125, 0.1875, 0.875, 0.875 );
|
|
||||||
}
|
|
||||||
case EAST:
|
|
||||||
{
|
|
||||||
return new AxisAlignedBB( 0.8125, 0.125, 0.125, 1.0, 0.875, 0.875 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user