@Override public boolean matches(World world, BlockPos pos) { IBlockState state = world.getBlockState(pos); return !state.getBlock().isAir(state, world, pos) && state.getCollisionBoundingBox(world, pos) != null; }
boolean isAir = world.getBlockState(pos).getCollisionBoundingBox(world, pos) == null; if(isAir) air++;
public boolean canEject() { IBlockState stateBelow = world.getBlockState(pos.down()); Block blockBelow = stateBelow.getBlock(); return blockBelow.isAir(stateBelow, world, pos.down()) || stateBelow.getCollisionBoundingBox(world, pos.down()) == null; }
public default AxisAlignedBB getCollisionBoundingBox(World world, BlockPos pos, IBlockState state) { return state.getCollisionBoundingBox(world, pos); }
@Override @Nullable public AxisAlignedBB getCollisionBoundingBox(@Nonnull IBlockAccess worldIn, @Nonnull BlockPos pos1) { return state.getCollisionBoundingBox(worldIn, pos1); }
@Override public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, Entity entityIn, boolean isActualState) { addCollisionBoxToList(pos, entityBox, collidingBoxes, state.getCollisionBoundingBox(worldIn, pos)); }
private float getDistance(World world, BlockPos pos) { IBlockState state = world.getBlockState(pos); AxisAlignedBB aabb = state.getCollisionBoundingBox(world, pos); return aabb == null ? 1 : 1 - Math.min((float) aabb.maxY, 1); } }
private float getDistance(World world, BlockPos pos) { IBlockState state = world.getBlockState(pos); AxisAlignedBB aabb = state.getCollisionBoundingBox(world, pos); return aabb == null ? 1 : 1 - Math.min((float) aabb.maxY, 1); }
@Override public boolean bindTo(EntityPlayer player, ItemStack wand, BlockPos pos, EnumFacing side) { Vector3 thisVec = Vector3.fromTileEntityCenter(this); Vector3 blockVec = new Vector3(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); AxisAlignedBB axis = player.world.getBlockState(pos).getCollisionBoundingBox(player.world, pos); if(axis != null) axis = axis.offset(pos); else axis = new AxisAlignedBB(pos, pos.add(1, 1, 1)); if(!blockVec.isInside(axis)) blockVec = new Vector3(axis.minX + (axis.maxX - axis.minX) / 2, axis.minY + (axis.maxY - axis.minY) / 2, axis.minZ + (axis.maxZ - axis.minZ) / 2); Vector3 diffVec = blockVec.subtract(thisVec); Vector3 diffVec2D = new Vector3(diffVec.x, diffVec.z, 0); Vector3 rotVec = new Vector3(0, 1, 0); double angle = rotVec.angle(diffVec2D) / Math.PI * 180.0; if(blockVec.x < thisVec.x) angle = -angle; rotationX = (float) angle + 90; rotVec = new Vector3(diffVec.x, 0, diffVec.z); angle = diffVec.angle(rotVec) * 180F / Math.PI; if(blockVec.y < thisVec.y) angle = -angle; rotationY = (float) angle; checkForReceiver(); return true; }
private boolean isFullBlock(BlockPos pos) { IBlockState state = world.getBlockState(pos); AxisAlignedBB aabb = state.getCollisionBoundingBox(world, pos); return Block.FULL_BLOCK_AABB.equals(aabb); }
public boolean isPartialBlock(BlockPos pos) { IBlockState state = world.getBlockState(pos); if (state.getBlock() != Blocks.AIR) { AxisAlignedBB bb = state.getCollisionBoundingBox(world, pos); if (bb == null) { return false; } if (bb.maxY <= 0.75d && bb.minX < 0.35 && bb.maxX > 0.65 && bb.minZ < 0.35 && bb.maxZ > 0.65) { return true; } } return false; }
Vector3 sourceVec = new Vector3(coords.getX() + 0.5, coords.getY() + 0.5, coords.getZ() + 0.5); AxisAlignedBB axis = entity.world.getBlockState(coords).getCollisionBoundingBox(entity.world, coords).offset(coords); if(axis == null) axis = new AxisAlignedBB(coords, coords.add(1, 1, 1));
private boolean isBlockFullCube(BlockPos pos) { AxisAlignedBB axisalignedbb = world.getBlockState(pos).getCollisionBoundingBox(world, pos); return world.getBlockState(pos).getMaterial() != Material.SAND && axisalignedbb != Block.NULL_AABB && axisalignedbb.getAverageEdgeLength() >= 1.0D; }
private boolean entityFits(Entity entityIn, int x, int y, int z) { BlockPos.MutableBlockPos mutableblockpos = new BlockPos.MutableBlockPos(); for (int i = x; i < x + entitySizeX; ++i) { for (int j = y; j < y + entitySizeY; ++j) { for (int k = z; k < z + entitySizeZ; ++k) { IBlockState bs = blockaccess.getBlockState(mutableblockpos.setPos(i, j, k)); if (bs.getMaterial() != Material.AIR) { AxisAlignedBB bb = bs.getCollisionBoundingBox(entityIn.world, mutableblockpos); if (bb != null) { return false; } } } } } return true; }
@Override public boolean isAutomationEnabled() { if(world.getBlockState(pos).getValue(BlockChute.ENABLED)) { BlockPos below = pos.down(); IBlockState state = world.getBlockState(below); Block block = state.getBlock(); return block.isAir(state, world, below) || state.getCollisionBoundingBox(world, below) == null; } return false; }
private static boolean canLandAtLocation(@Nonnull EntityLiving ent, int x, int y, int z) { World world = ent.getEntityWorld(); ent.setPosition(x + 0.5, y, z + 0.5); if (!SpawnUtil.isSpaceAvailableForSpawn(world, ent, false, false)) { return false; } BlockPos below = new BlockPos(x, y, z).down(); IBlockState bs = world.getBlockState(below); if (!bs.getMaterial().isSolid()) { return false; } AxisAlignedBB collides = bs.getCollisionBoundingBox(world, below); return collides != null; }
public static boolean placeAt(ItemStack stack, EntityPlayer player, EnumHand hand, World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, IBlockPlacementInfo stateProvider, int meta, IMultipart multipartBlock, IBlockPlacementLogic blockLogic, IPartPlacementLogic partLogic) { IBlockState state = stateProvider.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, player, hand); AxisAlignedBB bb = state.getCollisionBoundingBox(world, pos); if ((bb == null || world.checkNoEntityCollision(bb.offset(pos))) && blockLogic.place(stack, player, world, pos, facing, hitX, hitY, hitZ, state)) { return true; } bb = multipartBlock.getCollisionBoundingBox(world, pos, state); return (bb == null || world.checkNoEntityCollision(bb.offset(pos))) && partLogic.placePart(stack, player, hand, world, pos, facing, hitX, hitY, hitZ, multipartBlock, state); }
@Override public Object execute(SpellContext context) throws SpellRuntimeException { Vector3 positionVal = this.getParamValue(context, position); if(positionVal == null) throw new SpellRuntimeException(SpellRuntimeException.NULL_VECTOR); BlockPos pos = positionVal.toBlockPos(); IBlockState state = context.caster.getEntityWorld().getBlockState(pos); Block block = state.getBlock(); if(block.isAir(state, context.caster.getEntityWorld(), pos) || block.isReplaceable(context.caster.getEntityWorld(), pos)) return 0.0; else if(state.getCollisionBoundingBox(context.caster.getEntityWorld(), pos) == Block.NULL_AABB) return 1.0; return 2.0; }
private boolean tryPlace(EntityPlayer player, ItemStack stack, EnumHand hand, World world, BlockPos pos){ IBlockState iblockstate = world.getBlockState(pos); if(iblockstate.getBlock() == this.block){ BlockSlabs theBlock = (BlockSlabs)this.block; IBlockState newState = theBlock.fullBlockState; AxisAlignedBB bound = newState.getCollisionBoundingBox(world, pos); if(bound != Block.NULL_AABB && world.checkNoEntityCollision(bound.offset(pos)) && world.setBlockState(pos, newState, 11)){ SoundType soundtype = theBlock.fullBlockState.getBlock().getSoundType(theBlock.fullBlockState, world, pos, player); world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume()+1.0F)/2.0F, soundtype.getPitch()*0.8F); player.setHeldItem(hand, StackUtil.shrink(stack, 1)); } return true; } return false; }
private boolean canMobsSpawnInPos(World world, BlockPos pos) { if(world.isSideSolid(pos.down(), EnumFacing.UP) && !world.isBlockNormalCube(pos, false) && !world.isBlockNormalCube(pos.up(), false) && !world.getBlockState(pos).getMaterial().isLiquid()) { IBlockState state = world.getBlockState(pos); if(ModuleLoader.isFeatureEnabled(BlackAsh.class) && state.getBlock() == BlackAsh.black_ash || world.getBlockState(pos.down(2)).getBlock() == BlackAsh.black_ash) return false; int lightLevel = world.getLightFor(EnumSkyBlock.BLOCK, pos); return lightLevel < 8 && (world.isAirBlock(pos) || state.getCollisionBoundingBox(world, pos) == null); } return false; }