Java Code Examples for net.minecraft.util.math.AxisAlignedBB#intersects()
The following examples show how to use
net.minecraft.util.math.AxisAlignedBB#intersects() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TileLandingPad.java From AdvancedRocketry with MIT License | 6 votes |
@SubscribeEvent public void onRocketLand(RocketLandedEvent event) { EntityRocketBase rocket = (EntityRocketBase)event.getEntity(); AxisAlignedBB bbCache = new AxisAlignedBB(this.getPos().add(-1,0,-1), this.getPos().add(1,2,1)); if(bbCache.intersects(rocket.getEntityBoundingBox())) { if(!world.isRemote) for(IInfrastructure infrastructure : getConnectedInfrastructure()) { rocket.linkInfrastructure(infrastructure); } ItemStack stack = getStackInSlot(0); if(stack.getItem() == LibVulpesItems.itemLinker && ItemLinker.getDimId(stack) != -1 && event.getEntity() instanceof EntityRocket) { ((EntityRocket)rocket).setOverriddenCoords(ItemLinker.getDimId(stack), ItemLinker.getMasterX(stack) + 0.5f, Configuration.orbit, ItemLinker.getMasterZ(stack) + 0.5f); } } }
Example 2
Source File: TileLandingPad.java From AdvancedRocketry with MIT License | 6 votes |
@SubscribeEvent public void onRocketLaunch(RocketPreLaunchEvent event) { ItemStack stack = getStackInSlot(0); if(stack.getItem() == LibVulpesItems.itemLinker && ItemLinker.getDimId(stack) != -1) { EntityRocketBase rocket = (EntityRocketBase)event.getEntity(); AxisAlignedBB bbCache = new AxisAlignedBB(this.getPos().add(-1,0,-1), this.getPos().add(1,2,1)); if(bbCache.intersects(rocket.getEntityBoundingBox())) { if(event.getEntity() instanceof EntityRocket) { ((EntityRocket)rocket).setOverriddenCoords(ItemLinker.getDimId(stack), ItemLinker.getMasterX(stack) + 0.5f, Configuration.orbit, ItemLinker.getMasterZ(stack) + 0.5f); } } } }
Example 3
Source File: TileLandingPad.java From AdvancedRocketry with MIT License | 6 votes |
@SubscribeEvent public void onRocketDismantle(RocketDismantleEvent event) { if(!world.isRemote && world.provider.getDimension() == Configuration.spaceDimId) { EntityRocketBase rocket = (EntityRocketBase)event.getEntity(); AxisAlignedBB bbCache = new AxisAlignedBB(this.getPos().add(-1,0,-1), this.getPos().add(1,2,1)); if(bbCache.intersects(rocket.getEntityBoundingBox())) { ISpaceObject spaceObj = SpaceObjectManager.getSpaceManager().getSpaceStationFromBlockCoords(pos); if(spaceObj instanceof SpaceObject) { ((SpaceObject)spaceObj).setPadStatus(pos, false); } } } }
Example 4
Source File: BlockMachine.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean isActualState) { for (Cuboid6 axisAlignedBB : getCollisionBox(worldIn, pos)) { AxisAlignedBB offsetBox = axisAlignedBB.aabb().offset(pos); if (offsetBox.intersects(entityBox)) collidingBoxes.add(offsetBox); } }
Example 5
Source File: BlockPipe.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean isActualState) { for (Cuboid6 axisAlignedBB : getCollisionBox(worldIn, pos)) { AxisAlignedBB offsetBox = axisAlignedBB.aabb().offset(pos); if (offsetBox.intersects(entityBox)) collidingBoxes.add(offsetBox); } }
Example 6
Source File: BlockFluidMana.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
public static void run(World world, BlockPos pos, Block block, Entity entity, Predicate<Entity> test, Consumer<Entity> process) { if (!(block instanceof IFluidBlock)) return; float height; IBlockState up = world.getBlockState(pos.up()); if (up.getMaterial().isLiquid() || up.getBlock() instanceof IFluidBlock) height = 1f; else height = ((IFluidBlock) block).getFilledPercentage(world, pos) * 0.875f; AxisAlignedBB bb = new AxisAlignedBB(pos).contract(0, 1 - height, 0); AxisAlignedBB entityBox = entity.getCollisionBoundingBox(); if ((entityBox == null || entityBox.intersects(bb)) && test.test(entity)) process.accept(entity); }
Example 7
Source File: BlockFluidLethe.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
public static void run(World world, BlockPos pos, Block block, Entity entity, Predicate<Entity> test, Consumer<Entity> process) { if (!(block instanceof IFluidBlock)) return; float height; IBlockState up = world.getBlockState(pos.up()); if (up.getMaterial().isLiquid() || up.getBlock() instanceof IFluidBlock) height = 1f; else height = ((IFluidBlock) block).getFilledPercentage(world, pos) * 0.875f; AxisAlignedBB bb = new AxisAlignedBB(pos).contract(0, 1 - height, 0); AxisAlignedBB entityBox = entity.getCollisionBoundingBox(); if ((entityBox == null || entityBox.intersects(bb)) && test.test(entity)) process.accept(entity); }
Example 8
Source File: MobileAABB.java From AdvancedRocketry with MIT License | 5 votes |
@Override public boolean intersects(AxisAlignedBB aabb) { //if(chunk == null || true) // return super.intersectsWith(aabb); boolean collides = false; double diffX = 0;//((this.maxX - this.minX) - chunk.sizeX)/2f; double diffZ = 0;//((this.maxX - this.minX) - chunk.sizeX)/2f; out: for(int x = 0; x < chunk.blocks.length; x++) { for(int y = 0; y < chunk.blocks[0].length; y++) { for(int z = 0; z < chunk.blocks[0][0].length; z++) { Block block = chunk.blocks[x][y][z]; if(!block.getDefaultState().getMaterial().isSolid()) continue; AxisAlignedBB bb = block.getDefaultState().getCollisionBoundingBox(chunk.world, new BlockPos(x,y,z)); if(bb == null) continue; bb = bb.offset(this.minX + x + diffX, this.minY + y, this.minZ + z + diffZ); if(bb.intersects(aabb)) { collides = true; break out; } } } } return collides; }