/** * Given the actual facade bounding box, and the bounding boxes of all parts, determine the biggest union of AABB * that intersect with the facade's bounding * box. This AABB will need to be "cut out" when the facade is rendered. */ @Nullable private static AEAxisAlignedBB getCutOutBox( AxisAlignedBB facadeBox, List<AxisAlignedBB> partBoxes ) { AEAxisAlignedBB b = null; for( AxisAlignedBB bb : partBoxes ) { if( bb.intersects( facadeBox ) ) { if( b == null ) { b = AEAxisAlignedBB.fromBounds( bb ); } else { b.maxX = Math.max( b.maxX, bb.maxX ); b.maxY = Math.max( b.maxY, bb.maxY ); b.maxZ = Math.max( b.maxZ, bb.maxZ ); b.minX = Math.min( b.minX, bb.minX ); b.minY = Math.min( b.minY, bb.minY ); b.minZ = Math.min( b.minZ, bb.minZ ); } } } return b; }
@SuppressWarnings( "deprecation" ) @Override public void addCollisionBoxToList( final IBlockState state, final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, @Nullable final Entity e, boolean p_185477_7_ ) { final ICustomCollision collisionHandler = this.getCustomCollision( w, pos ); if( collisionHandler != null && bb != null ) { final List<AxisAlignedBB> tmp = new ArrayList<>(); collisionHandler.addCollidingBlockToList( w, pos, bb, tmp, e ); for( final AxisAlignedBB b : tmp ) { final AxisAlignedBB offset = b.offset( pos.getX(), pos.getY(), pos.getZ() ); if( bb.intersects( offset ) ) { out.add( offset ); } } } else { super.addCollisionBoxToList( state, w, pos, bb, out, e, p_185477_7_ ); } }
@SubscribeEvent public void onSpawn(LivingSpawnEvent.CheckSpawn event) { if(event.getResult() != Result.ALLOW && event.getEntityLiving() instanceof IMob) { AxisAlignedBB aabb = new AxisAlignedBB(event.getX() - RANGE, event.getY() - RANGE, event.getZ() - RANGE, event.getX() + RANGE, event.getY() + RANGE, event.getZ() + RANGE); for(EntityPlayer player : event.getWorld().playerEntities) { if(hasEffect(player) && player.getEntityBoundingBox().intersects(aabb)) { event.setResult(Result.DENY); return; } } } }
@SubscribeEvent public void onSpawn(LivingSpawnEvent.CheckSpawn event) { if(event.getResult() != Result.ALLOW && event.getEntityLiving() instanceof IMob) { AxisAlignedBB aabb = new AxisAlignedBB(event.getX() - RANGE, event.getY() - RANGE, event.getZ() - RANGE, event.getX() + RANGE, event.getY() + RANGE, event.getZ() + RANGE); for(EntityPlayer player : event.getWorld().playerEntities) { if(hasEffect(player) && !hasEffect(player, ModPotions.emptiness) && player.getEntityBoundingBox().intersects(aabb)) { event.setResult(Result.ALLOW); return; } } } }
private boolean check(EntityItem item) { if (!item.isDead && aabb.intersects(item.getEntityBoundingBox())) { drops.add(item); return true; } return false; }
@Override public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean b) { int facing = ((TileDynamoBase) world.getTileEntity(pos)).facing; AxisAlignedBB base, coil; base = boundingBox[facing].offset(pos); coil = boundingBox[facing + 6].offset(pos); if (coil.intersects(entityBox)) { collidingBoxes.add(coil); } if (base.intersects(entityBox)) { collidingBoxes.add(base); } }
public List<PhysicsWrapperEntity> getNearbyPhysObjects(AxisAlignedBB toCheck) { ArrayList<PhysicsWrapperEntity> ships = new ArrayList<PhysicsWrapperEntity>(); AxisAlignedBB expandedCheck = toCheck.expand(6, 6, 6); for (PhysicsWrapperEntity wrapper : physicsEntities) { if (wrapper.wrapping.getCollisionBoundingBox().intersects(expandedCheck)) { ships.add(wrapper); } } return ships; }
private void checkRedraw(AxisAlignedBB updateRange) { if (updateRange.intersects(candidateBounds)) { Minecraft.getMinecraft().addScheduledTask(this::updateCache); } }
@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); } }
@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, state)) { AxisAlignedBB offsetBox = axisAlignedBB.aabb().offset(pos); if (offsetBox.intersects(entityBox)) collidingBoxes.add(offsetBox); } }
private List<EntityPlayer> getPlayersWithinAABB() { List<EntityPlayer> players = new ArrayList<>(); for (EntityPlayer player : world.playerEntities) { if (player.getEntityBoundingBox().intersects(new AxisAlignedBB(pos, pos.add(1, 1, 1)).grow(playerRange, playerRange, playerRange))) { players.add(player); } } return players; }
@Override public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_) { EnumFacing orientation = state.getValue(FACING); List<AxisAlignedBB> boundingBoxes = boundingBoxesForDirections.get(orientation); if (boundingBoxes == null) { return; } for (AxisAlignedBB boundingBoxBase : boundingBoxes) { AxisAlignedBB boundingBox = boundingBoxBase.offset(pos.getX(), pos.getY(), pos.getZ()); if (entityBox.intersects(boundingBox)) { collidingBoxes.add(boundingBox); } } }
@Override public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, Entity entity, boolean uselessParameter) { super.addCollisionBoxToList(state, world, pos, entityBox, collidingBoxes, entity, uselessParameter); AxisAlignedBB aabb = WorldHelper.getDirectionalBoundingBox(state.getValue(FACING), HEATER_AABB, true).offset(pos); if (aabb.intersects(entityBox)) { collidingBoxes.add(aabb); } } }
@Override protected double getAttackReachSqr(EntityLivingBase attackTarget) { if (attackTarget.getEntityBoundingBox().intersects(this.dinosaur.getEntityBoundingBox().expand(1.3, 1.3, 1.3))) { return 1024.0; } double grownWidth = this.attacker.width + 1.0; return grownWidth * grownWidth; } }
@Override public void addCollisionBoxesToList(List arraylist, AxisAlignedBB axisalignedbb) { DoubleCoordinates pos = getLPPosition(); LPPositionSet<DoubleCoordinates> set = new LPPositionSet<>(DoubleCoordinates.class); set.addFrom(LineTubeRenderer.tubeLine.get(orientation.getRenderOrientation()).bounds().toAABB()); set.stream().forEach(o -> o.add(pos)); AxisAlignedBB box = set.toABB(); if (box != null && (axisalignedbb == null || axisalignedbb.intersects(box))) { arraylist.add(box); } }
@Override public boolean isLadder(IBlockState state, IBlockAccess world, BlockPos pos, EntityLivingBase entity) { return anyMatch(world, pos, i -> i.getPart().isLadder(i.wrapAsNeeded(world), pos, i, entity) && Optional.ofNullable(i.getPart().getCollisionBoundingBox(i.getPartWorld(), pos, i.getState()).offset(pos)) .map(it -> it.intersects(entity.getEntityBoundingBox().grow(0.01 / 16F))).orElse(false)); }
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); } }
@Override public void updateTask() { if (this.dinosaur.getEntityBoundingBox().intersects(this.mate.getEntityBoundingBox().expand(0.5D, 0.5D, 0.5D))) { this.dinosaur.setAnimation(EntityAnimation.MATING.get()); this.dinosaur.getMetabolism().decreaseEnergy(1000); } }
@Override @SuppressWarnings("squid:S3655") public void updateTask() { //noinspection ConstantConditions VehicleBase vehicle = npc.getVehicle().get(); double distance = npc.getDistanceSq(vehicle.getPosition()); if (npc.getEntityBoundingBox().grow(MOUNT_REACH).intersects(vehicle.getEntityBoundingBox())) { npc.startRiding(vehicle); } else { moveToPosition(vehicle.getPosition(), distance); npc.addAITask(TASK_MOVE); } }
@Override public boolean shouldContinueExecuting() { return !(this.entity.getEntityBoundingBox() != null && this.owner.getEntityBoundingBox() != null && this.entity.getEntityBoundingBox().expand(2, 2, 2).intersects(this.owner.getEntityBoundingBox())) && !this.entity.getNavigator().noPath() && this.owner.isEntityAlive() && this.entity.getOrder() == DinosaurEntity.Order.FOLLOW; }