use of net.minecraft.block.BlockFenceGate in project Railcraft by Railcraft.
the class PostConnectionHelper method connect.
public static ConnectStyle connect(IBlockAccess world, BlockPos pos, IBlockState state, EnumFacing side) {
try {
Block block = state.getBlock();
if (block instanceof IPostConnection && ((IPostConnection) block).connectsToPost(world, pos, state, side) == ConnectStyle.NONE)
return ConnectStyle.NONE;
} catch (Error error) {
Game.log().api(Railcraft.NAME, error, IPostConnection.class);
return ConnectStyle.NONE;
}
BlockPos otherPos = pos.offset(side);
if (world.isAirBlock(otherPos))
return ConnectStyle.NONE;
IBlockState otherState = WorldPlugin.getBlockState(world, otherPos);
Block otherBlock = otherState.getBlock();
EnumFacing oppositeSide = side.getOpposite();
try {
if (otherBlock instanceof IPostConnection)
return ((IPostConnection) otherBlock).connectsToPost(world, otherPos, otherState, oppositeSide);
} catch (Error error) {
Game.log().api(Railcraft.NAME, error, IPostConnection.class);
}
if (otherBlock instanceof BlockPostBase)
return ConnectStyle.TWO_THIN;
if (noConnect.contains(otherBlock))
return ConnectStyle.NONE;
if (canConnect.contains(otherBlock))
return ConnectStyle.TWO_THIN;
if (otherBlock instanceof BlockFenceGate) {
return otherState.getValue(BlockFenceGate.FACING).getAxis() != side.getAxis() ? ConnectStyle.TWO_THIN : ConnectStyle.NONE;
}
if (otherBlock instanceof BlockWallSign) {
return otherState.getValue(BlockWallSign.FACING) == side ? ConnectStyle.SINGLE_THICK : ConnectStyle.NONE;
}
if (otherBlock instanceof BlockLantern)
return ConnectStyle.SINGLE_THICK;
if (world.isSideSolid(pos, oppositeSide, false))
return ConnectStyle.TWO_THIN;
return ConnectStyle.NONE;
}
use of net.minecraft.block.BlockFenceGate in project Galacticraft by micdoodle8.
the class BlockWallGC method canConnectTo.
// @Override
// public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos)
// {
// boolean flag = this.canConnectTo(world, pos.north());
// boolean flag1 = this.canConnectTo(world, pos.south());
// boolean flag2 = this.canConnectTo(world, pos.west());
// boolean flag3 = this.canConnectTo(world, pos.east());
// float f = 0.25F;
// float f1 = 0.75F;
// float f2 = 0.25F;
// float f3 = 0.75F;
// float f4 = 1.0F;
//
// if (flag)
// {
// f2 = 0.0F;
// }
// if (flag1)
// {
// f3 = 1.0F;
// }
// if (flag2)
// {
// f = 0.0F;
// }
// if (flag3)
// {
// f1 = 1.0F;
// }
//
// if (flag && flag1 && !flag2 && !flag3)
// {
// f4 = 0.8125F;
// f = 0.3125F;
// f1 = 0.6875F;
// }
// else if (!flag && !flag1 && flag2 && flag3)
// {
// f4 = 0.8125F;
// f2 = 0.3125F;
// f3 = 0.6875F;
// }
// this.setBlockBounds(f, 0.0F, f2, f1, f4, f3);
// }
// @Override
// public AxisAlignedBB getCollisionBoundingBox(World world, BlockPos pos, IBlockState state)
// {
// this.setBlockBoundsBasedOnState(world, pos);
// this.maxY = 1.5D;
// return super.getCollisionBoundingBox(world, pos, state);
// }
private boolean canConnectTo(IBlockAccess world, BlockPos pos) {
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
return block == Blocks.BARRIER ? false : block != this && !(block instanceof BlockFenceGate) ? block.getMaterial(state).isOpaque() && block.isFullCube(state) ? block.getMaterial(state) != Material.GOURD : false : true;
}
Aggregations