/** * Sets the width and height of the entity. */ protected void setSize(float width, float height) { if (width != this.width || height != this.height) { float f = this.width; this.width = width; this.height = height; if (this.width < f) { double d0 = (double)width / 2.0D; this.setEntityBoundingBox(new AxisAlignedBB(this.posX - d0, this.posY, this.posZ - d0, this.posX + d0, this.posY + (double)this.height, this.posZ + d0)); return; } AxisAlignedBB axisalignedbb = this.getEntityBoundingBox(); this.setEntityBoundingBox(new AxisAlignedBB(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ, axisalignedbb.minX + (double)this.width, axisalignedbb.minY + (double)this.height, axisalignedbb.minZ + (double)this.width)); if (this.width > f && !this.firstUpdate && !this.world.isRemote) { this.moveEntity(MoverType.SELF, (double)(f - this.width), 0.0D, (double)(f - this.width)); } } }
private void doSplash() { AxisAlignedBB axisalignedbb = this.getEntityBoundingBox().expand(4.0D, 2.0D, 4.0D); List<EntityLivingBase> list = this.world.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); if (!list.isEmpty()) { Tuple<List<BrewEffect>, List<PotionEffect>> tuple = BrewUtils.deSerialize(NBTHelper.fixNBT(getBrew())); for (EntityLivingBase entity : list) { double distance = this.getDistanceSq(entity); if (distance < 16.0D) { for (BrewEffect effect : tuple.getFirst()) { BrewStorageHandler.addEntityBrewEffect(entity, effect.copy()); } for (PotionEffect potioneffect : tuple.getSecond()) { entity.addPotionEffect(new PotionEffect(potioneffect)); } } } } }
public static void drawSelectionBox(EntityPlayer player, AxisAlignedBB box, float partialTicks, float r, float g, float b, float a) { GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.glLineWidth(2.0F); GlStateManager.disableTexture2D(); GlStateManager.depthMask(false); double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks; double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks; double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks; RenderGlobal.drawSelectionBoundingBox(box.expandXyz(0.0020000000949949026D).offset(-d0, -d1, -d2), r, g, b, a); GlStateManager.depthMask(true); GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); }
/** * Returns true if there are no solid, live entities in the specified AxisAlignedBB, excluding the given entity */ public boolean checkNoEntityCollision(AxisAlignedBB bb, @Nullable Entity entityIn) { List<Entity> list = this.getEntitiesWithinAABBExcludingEntity((Entity)null, bb); for (int i = 0; i < list.size(); ++i) { Entity entity = (Entity)list.get(i); if (!entity.isDead && entity.preventEntitySpawning && entity != entityIn && (entityIn == null || entity.isRidingSameEntity(entityIn))) { return false; } } return true; }
public static ItemStack dispenseArmor(IBlockSource blockSource, ItemStack stack) { BlockPos blockpos = blockSource.getBlockPos().offset((EnumFacing)blockSource.getBlockState().getValue(BlockDispenser.FACING)); List<EntityLivingBase> list = blockSource.getWorld().<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(blockpos), Predicates.<EntityLivingBase> and (EntitySelectors.NOT_SPECTATING, new EntitySelectors.ArmoredMob(stack))); if (list.isEmpty()) { return ItemStack.field_190927_a; } else { EntityLivingBase entitylivingbase = (EntityLivingBase)list.get(0); EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(stack); ItemStack itemstack = stack.splitStack(1); entitylivingbase.setItemStackToSlot(entityequipmentslot, itemstack); if (entitylivingbase instanceof EntityLiving) { ((EntityLiving)entitylivingbase).setDropChance(entityequipmentslot, 2.0F); } return stack; } }
@Nullable public <T extends Entity> T findNearestEntityWithinAABB(Class <? extends T > entityType, AxisAlignedBB aabb, T closestTo) { List<T> list = this.<T>getEntitiesWithinAABB(entityType, aabb); T t = null; double d0 = Double.MAX_VALUE; for (int i = 0; i < list.size(); ++i) { T t1 = list.get(i); if (t1 != closestTo && EntitySelectors.NOT_SPECTATING.apply(t1)) { double d1 = closestTo.getDistanceSqToEntity(t1); if (d1 <= d0) { t = t1; d0 = d1; } } } return t; }
@Nullable public static EntityLeashKnot getKnotForPosition(World worldIn, BlockPos pos) { int i = pos.getX(); int j = pos.getY(); int k = pos.getZ(); for (EntityLeashKnot entityleashknot : worldIn.getEntitiesWithinAABB(EntityLeashKnot.class, new AxisAlignedBB((double)i - 1.0D, (double)j - 1.0D, (double)k - 1.0D, (double)i + 1.0D, (double)j + 1.0D, (double)k + 1.0D))) { if (entityleashknot.getHangingPosition().equals(pos)) { return entityleashknot; } } return null; }
public static void blockESPBox(IBlockPos IBlockPos, float red, float green, float blue) { RenderUtils.fixDarkLight(); GlStateManager.resetColor(); double x = IBlockPos.getX() - Minecraft.getMinecraft().getRenderManager().renderPosX; double y = IBlockPos.getY() - Minecraft.getMinecraft().getRenderManager().renderPosY; double z = IBlockPos.getZ() - Minecraft.getMinecraft().getRenderManager().renderPosZ; GL11.glBlendFunc(770, 771); GL11.glEnable(3042); GL11.glLineWidth(1.0F); GL11.glDisable(3553); GL11.glDisable(2929); GL11.glDepthMask(false); GL11.glColor4f(red, green, blue, 0.15F); drawColorBox(new AxisAlignedBB(x, y, z, x + 1.0D, y + 1.0D, z + 1.0D), 0.0F, 1.0F, 0.0F, 0.15F); GL11.glColor4d(0.0D, 0.0D, 0.0D, 0.5D); drawSelectionBoundingBox(new AxisAlignedBB(x, y, z, x + 1.0D, y + 1.0D, z + 1.0D)); GL11.glEnable(3553); GL11.glEnable(2929); GL11.glDepthMask(true); GL11.glDisable(3042); GlStateManager.resetColor(); }
private void attachToNearbyEntities() { if(isAttachedToEntity() || item || attachmentCounter > 0) return; for(Entity entity : world.getEntitiesWithinAABBExcludingEntity(this, new AxisAlignedBB(-10, -10, -10, 10, 10, 10).offset(posX, posY, posZ))) { AxisAlignedBB bb = entity.getEntityBoundingBox(); if(bb != null && entity.width >= 0.3) { if(tryAttach(entity, 0.4, 0.2)) return; } } }
private void transposeItems() { boolean impulse = false; if(world.isAirBlock(pos.offset(getFacingLazy().getOpposite()))) { applyGravity(attractInverse, true); impulse = true; } if(world.isAirBlock(pos.offset(getFacingLazy()))) { if(impulse) { Vector3 spawn = Vector3.create(getPos().offset(getFacingLazy())).add(0.5D); getItemsFiltered(new AxisAlignedBB(getPos()).grow(0.5D)).forEach(entity -> { impulseEntityItem(spawn, entity); }); } applyGravity(repulseInverse, false); } }
@Override @SuppressWarnings("deprecation") public void addCollisionBoxToList (IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_) { if (!p_185477_7_) state = getActualState(state, worldIn, pos); addCollisionBoxToList(pos, entityBox, collidingBoxes, CENTER_AABB); if (state.getValue(NORTH) != Connection.NONE) addCollisionBoxToList(pos, entityBox, collidingBoxes, NORTH_AABB); if (state.getValue(EAST) != Connection.NONE) addCollisionBoxToList(pos, entityBox, collidingBoxes, EAST_AABB); if (state.getValue(SOUTH) != Connection.NONE) addCollisionBoxToList(pos, entityBox, collidingBoxes, SOUTH_AABB); if (state.getValue(WEST) != Connection.NONE) addCollisionBoxToList(pos, entityBox, collidingBoxes, WEST_AABB); if (state.getValue(UP) != Connection.NONE) addCollisionBoxToList(pos, entityBox, collidingBoxes, UP_AABB); if (state.getValue(DOWN) != Connection.NONE) addCollisionBoxToList(pos, entityBox, collidingBoxes, DOWN_AABB); }
@Nullable public static RayTraceResult rayTraceAABB(AxisAlignedBB box, BlockPos pos, Vec3d start, Vec3d end) { double x = pos.getX(); double y = pos.getY(); double z = pos.getZ(); Vec3d a = start.subtract(x, y, z); Vec3d b = end.subtract(x, y, z); RayTraceResult result = box.calculateIntercept(a, b); if(result != null && result.typeOfHit == RayTraceResult.Type.BLOCK) { return result; } return null; }
protected void doBlockCollisions() { AxisAlignedBB axisalignedbb = this.getEntityBoundingBox(); BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain(axisalignedbb.minX + 0.001D, axisalignedbb.minY + 0.001D, axisalignedbb.minZ + 0.001D); BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos1 = BlockPos.PooledMutableBlockPos.retain(axisalignedbb.maxX - 0.001D, axisalignedbb.maxY - 0.001D, axisalignedbb.maxZ - 0.001D); BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos2 = BlockPos.PooledMutableBlockPos.retain(); if (this.world.isAreaLoaded(blockpos$pooledmutableblockpos, blockpos$pooledmutableblockpos1)) { for (int i = blockpos$pooledmutableblockpos.getX(); i <= blockpos$pooledmutableblockpos1.getX(); ++i) { for (int j = blockpos$pooledmutableblockpos.getY(); j <= blockpos$pooledmutableblockpos1.getY(); ++j) { for (int k = blockpos$pooledmutableblockpos.getZ(); k <= blockpos$pooledmutableblockpos1.getZ(); ++k) { blockpos$pooledmutableblockpos2.setPos(i, j, k); IBlockState iblockstate = this.world.getBlockState(blockpos$pooledmutableblockpos2); try { iblockstate.getBlock().onEntityCollidedWithBlock(this.world, blockpos$pooledmutableblockpos2, iblockstate, this); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Colliding entity with block"); CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being collided with"); CrashReportCategory.addBlockInfo(crashreportcategory, blockpos$pooledmutableblockpos2, iblockstate); throw new ReportedException(crashreport); } } } } } blockpos$pooledmutableblockpos.release(); blockpos$pooledmutableblockpos1.release(); blockpos$pooledmutableblockpos2.release(); }
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { switch (((EnumFacing)state.getValue(FACING)).getAxis()) { case X: default: return END_ROD_EW_AABB; case Z: return END_ROD_NS_AABB; case Y: return END_ROD_VERTICAL_AABB; } }
private static void renderOffsetAABB(AxisAlignedBB aabb, double x, double y, double z) { BufferBuilder wr = Tessellator.getInstance().getBuffer(); wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_NORMAL); wr.setTranslation(x, y, z); wr.pos(aabb.minX, aabb.maxY, aabb.minZ).normal(0, 0, -1).endVertex(); wr.pos(aabb.maxX, aabb.maxY, aabb.minZ).normal(0, 0, -1).endVertex(); wr.pos(aabb.maxX, aabb.minY, aabb.minZ).normal(0, 0, -1).endVertex(); wr.pos(aabb.minX, aabb.minY, aabb.minZ).normal(0, 0, -1).endVertex(); wr.pos(aabb.minX, aabb.minY, aabb.maxZ).normal(0, 0, 1).endVertex(); wr.pos(aabb.maxX, aabb.minY, aabb.maxZ).normal(0, 0, 1).endVertex(); wr.pos(aabb.maxX, aabb.maxY, aabb.maxZ).normal(0, 0, 1).endVertex(); wr.pos(aabb.minX, aabb.maxY, aabb.maxZ).normal(0, 0, 1).endVertex(); wr.pos(aabb.minX, aabb.minY, aabb.minZ).normal(0, -1, 0).endVertex(); wr.pos(aabb.maxX, aabb.minY, aabb.minZ).normal(0, -1, 0).endVertex(); wr.pos(aabb.maxX, aabb.minY, aabb.maxZ).normal(0, -1, 0).endVertex(); wr.pos(aabb.minX, aabb.minY, aabb.maxZ).normal(0, -1, 0).endVertex(); wr.pos(aabb.minX, aabb.maxY, aabb.maxZ).normal(0, 1, 0).endVertex(); wr.pos(aabb.maxX, aabb.maxY, aabb.maxZ).normal(0, 1, 0).endVertex(); wr.pos(aabb.maxX, aabb.maxY, aabb.minZ).normal(0, 1, 0).endVertex(); wr.pos(aabb.minX, aabb.maxY, aabb.minZ).normal(0, 1, 0).endVertex(); wr.pos(aabb.minX, aabb.minY, aabb.maxZ).normal(-1, 0, 0).endVertex(); wr.pos(aabb.minX, aabb.maxY, aabb.maxZ).normal(-1, 0, 0).endVertex(); wr.pos(aabb.minX, aabb.maxY, aabb.minZ).normal(-1, 0, 0).endVertex(); wr.pos(aabb.minX, aabb.minY, aabb.minZ).normal(-1, 0, 0).endVertex(); wr.pos(aabb.maxX, aabb.minY, aabb.minZ).normal(1, 0, 0).endVertex(); wr.pos(aabb.maxX, aabb.maxY, aabb.minZ).normal(1, 0, 0).endVertex(); wr.pos(aabb.maxX, aabb.maxY, aabb.maxZ).normal(1, 0, 0).endVertex(); wr.pos(aabb.maxX, aabb.minY, aabb.maxZ).normal(1, 0, 0).endVertex(); wr.setTranslation(0.0D, 0.0D, 0.0D); Tessellator.getInstance().draw(); }
@Override public List<AxisAlignedBB> getOcclusionBoxes(IPartInfo part) { List<AxisAlignedBB> boxes = new ArrayList<>(); boxes.add(BlockPressureTube.BASE_BOUNDS); // boxes.addAll() return boxes; }
protected boolean findInventoryContainingMost(AxisAlignedBB box, Predicate<ItemStack> matcher, Consumer<BlockPos> job) { World world = entity.getEntityWorld(); List<BlockPos> inventories = new ArrayList<>(); Map<BlockPos, Float> countMatching = new HashMap<>(); GeneralTools.traverseBox(world, box, (pos, state) -> InventoryTools.isInventory(world, pos), (pos, state) -> { TileEntity te = world.getTileEntity(pos); IItemHandler handler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP); int cnt = 0; for (int i = 0; i < handler.getSlots(); i++) { ItemStack stack = handler.getStackInSlot(i); if (stack == null) { // There are still bad mods! String badBlock = world.getBlockState(pos).getBlock().getRegistryName().toString(); MeeCreeps.logger.warn("Block " + badBlock + " is returning null for handler.getStackInSlot()! That's a bug!"); } else if (!stack.isEmpty()) { if (matcher.test(stack)) { cnt += stack.getCount(); } } } if (cnt > 0) { inventories.add(pos); countMatching.put(pos, (float) cnt); } }); if (inventories.isEmpty()) { return false; } else { // Sort so that highest score goes first inventories.sort((p1, p2) -> Float.compare(countMatching.get(p2), countMatching.get(p1))); navigateTo(inventories.get(0), job); return true; } }
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_) { if (!p_185477_7_) { state = this.getActualState(state, worldIn, pos); } addCollisionBoxToList(pos, entityBox, collidingBoxes, CLIP_AABB_BY_INDEX[getAABBIndex(state)]); }
/** * Like the old updateEntity(), except more generic. */ public void update() { boolean flag = this.isSpawning(); boolean flag1 = this.isCoolingDown(); ++this.age; if (flag1) { --this.teleportCooldown; } else if (!this.world.isRemote) { List<Entity> list = this.world.<Entity>getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(this.getPos())); if (!list.isEmpty()) { this.teleportEntity((Entity)list.get(0)); } if (this.age % 2400L == 0L) { this.triggerCooldown(); } } if (flag != this.isSpawning() || flag1 != this.isCoolingDown()) { this.markDirty(); } }
@Nullable /** * Returns a boundingBox used to collide the entity with other entities and blocks. This enables the entity to be * pushable on contact, like boats or minecarts. */ public AxisAlignedBB getCollisionBox(Entity entityIn) { return entityIn.canBePushed() ? entityIn.getEntityBoundingBox() : null; }
@Nullable protected RayTraceResult rayTrace(BlockPos pos, Vec3d start, Vec3d end, AxisAlignedBB boundingBox) { Vec3d vec3d = start.subtract((double)pos.getX(), (double)pos.getY(), (double)pos.getZ()); Vec3d vec3d1 = end.subtract((double)pos.getX(), (double)pos.getY(), (double)pos.getZ()); RayTraceResult raytraceresult = boundingBox.calculateIntercept(vec3d, vec3d1); return raytraceresult == null ? null : new RayTraceResult(raytraceresult.hitVec.addVector((double)pos.getX(), (double)pos.getY(), (double)pos.getZ()), raytraceresult.sideHit, pos); }
@Override public boolean isPossible(World world, BlockPos pos, EnumFacing side) { // @todo config for area AxisAlignedBB box = new AxisAlignedBB(pos.add(-10, -5, -10), pos.add(10, 5, 10)); // AxisAlignedBB box = new AxisAlignedBB(pos.add(-2, -2, -2), pos.add(2, 2, 2)); return GeneralTools.traverseBoxTest(box, p -> { if (WorldEntitySpawner.canCreatureTypeSpawnAtLocation(EntityLiving.SpawnPlacementType.ON_GROUND, world, p)) { int light = world.getLightFromNeighbors(p); if (light < 7) { return true; } } return false; }); }
public TubeModule() { double width = getWidth() / 2; double height = getHeight(); // 0..6 = D,U,N,S,W,E boundingBoxes[0] = new AxisAlignedBB(0.5 - width, BBConstants.PRESSURE_PIPE_MIN_POS - height, 0.5 - width, 0.5 + width, BBConstants.PRESSURE_PIPE_MIN_POS, 0.5 + width); boundingBoxes[1] = new AxisAlignedBB(0.5 - width, BBConstants.PRESSURE_PIPE_MAX_POS, 0.5 - width, 0.5 + width, BBConstants.PRESSURE_PIPE_MAX_POS + height, 0.5 + width); boundingBoxes[2] = new AxisAlignedBB(0.5 - width, 0.5 - width, BBConstants.PRESSURE_PIPE_MIN_POS - height, 0.5 + width, 0.5 + width, BBConstants.PRESSURE_PIPE_MIN_POS); boundingBoxes[3] = new AxisAlignedBB(0.5 - width, 0.5 - width, BBConstants.PRESSURE_PIPE_MAX_POS, 0.5 + width, 0.5 + width, BBConstants.PRESSURE_PIPE_MAX_POS + height); boundingBoxes[4] = new AxisAlignedBB(BBConstants.PRESSURE_PIPE_MIN_POS - height, 0.5 - width, 0.5 - width, BBConstants.PRESSURE_PIPE_MIN_POS, 0.5 + width, 0.5 + width); boundingBoxes[5] = new AxisAlignedBB(BBConstants.PRESSURE_PIPE_MAX_POS, 0.5 - width, 0.5 - width, BBConstants.PRESSURE_PIPE_MAX_POS + height, 0.5 + width, 0.5 + width); }
@Nullable public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) { int i = ((Integer)blockState.getValue(LAYERS)).intValue() - 1; float f = 0.125F; AxisAlignedBB axisalignedbb = blockState.getBoundingBox(worldIn, pos); if(Hacks.findMod(Freecam.class).isEnabled()) return NULL_AABB; else return new AxisAlignedBB(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ, axisalignedbb.maxX, (double)((float)i * 0.125F), axisalignedbb.maxZ); }
/** * Calls this.teleport on all mobs deriving from EntityMob * @param areaBounds AxisAlignedBB in which block should act */ private void teleportMobs(AxisAlignedBB areaBounds) { // Gets a list of all the entities in the same chunk as this block List<EntityMob> entityMobList = world.getEntitiesWithinAABB(EntityMob.class, areaBounds); for (EntityMob entity : entityMobList) { teleport(entity); } }
@SuppressWarnings("deprecation") @Nullable @Override public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) { return NULL_AABB; }
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_) { addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_LEGS); addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_WEST); addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_NORTH); addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_EAST); addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_SOUTH); }
/** * Destroys Witch Potions that are currently in the protected area * Only destroys the EntityPotion if it was thrown by an EntityWitch or derivatives * @param chunkBounds AxisAlignedBB in which block should act */ private void killPotions(AxisAlignedBB chunkBounds) { List<EntityPotion> list = world.getEntitiesWithinAABB(EntityPotion.class, chunkBounds); for (EntityPotion potion : list) { if (potion.getThrower() instanceof EntityWitch) { potion.setDead(); } } }
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_) { if (!p_185477_7_) { state = state.getActualState(worldIn, pos); } addCollisionBoxToList(pos, entityBox, collidingBoxes, PILLAR_AABB); if (((Boolean)state.getValue(NORTH)).booleanValue()) { addCollisionBoxToList(pos, entityBox, collidingBoxes, NORTH_AABB); } if (((Boolean)state.getValue(EAST)).booleanValue()) { addCollisionBoxToList(pos, entityBox, collidingBoxes, EAST_AABB); } if (((Boolean)state.getValue(SOUTH)).booleanValue()) { addCollisionBoxToList(pos, entityBox, collidingBoxes, SOUTH_AABB); } if (((Boolean)state.getValue(WEST)).booleanValue()) { addCollisionBoxToList(pos, entityBox, collidingBoxes, WEST_AABB); } }
@Override public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_) { addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_LEGS); addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_WEST); addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_NORTH); addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_EAST); addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_SOUTH); }
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { switch ((EnumFacing)state.getValue(FACING)) { case EAST: default: return HOOK_EAST_AABB; case WEST: return HOOK_WEST_AABB; case SOUTH: return HOOK_SOUTH_AABB; case NORTH: return HOOK_NORTH_AABB; } }
private void renderShadowSingle(IBlockState state, double p_188299_2_, double p_188299_4_, double p_188299_6_, BlockPos p_188299_8_, float p_188299_9_, float p_188299_10_, double p_188299_11_, double p_188299_13_, double p_188299_15_) { if (state.isFullCube()) { Tessellator tessellator = Tessellator.getInstance(); VertexBuffer vertexbuffer = tessellator.getBuffer(); double d0 = ((double)p_188299_9_ - (p_188299_4_ - ((double)p_188299_8_.getY() + p_188299_13_)) / 2.0D) * 0.5D * (double)this.getWorldFromRenderManager().getLightBrightness(p_188299_8_); if (d0 >= 0.0D) { if (d0 > 1.0D) { d0 = 1.0D; } AxisAlignedBB axisalignedbb = state.getBoundingBox(this.getWorldFromRenderManager(), p_188299_8_); double d1 = (double)p_188299_8_.getX() + axisalignedbb.minX + p_188299_11_; double d2 = (double)p_188299_8_.getX() + axisalignedbb.maxX + p_188299_11_; double d3 = (double)p_188299_8_.getY() + axisalignedbb.minY + p_188299_13_ + 0.015625D; double d4 = (double)p_188299_8_.getZ() + axisalignedbb.minZ + p_188299_15_; double d5 = (double)p_188299_8_.getZ() + axisalignedbb.maxZ + p_188299_15_; float f = (float)((p_188299_2_ - d1) / 2.0D / (double)p_188299_10_ + 0.5D); float f1 = (float)((p_188299_2_ - d2) / 2.0D / (double)p_188299_10_ + 0.5D); float f2 = (float)((p_188299_6_ - d4) / 2.0D / (double)p_188299_10_ + 0.5D); float f3 = (float)((p_188299_6_ - d5) / 2.0D / (double)p_188299_10_ + 0.5D); vertexbuffer.pos(d1, d3, d4).tex((double)f, (double)f2).color(1.0F, 1.0F, 1.0F, (float)d0).endVertex(); vertexbuffer.pos(d1, d3, d5).tex((double)f, (double)f3).color(1.0F, 1.0F, 1.0F, (float)d0).endVertex(); vertexbuffer.pos(d2, d3, d5).tex((double)f1, (double)f3).color(1.0F, 1.0F, 1.0F, (float)d0).endVertex(); vertexbuffer.pos(d2, d3, d4).tex((double)f1, (double)f2).color(1.0F, 1.0F, 1.0F, (float)d0).endVertex(); } } }
@Nullable @Override public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess worldIn, BlockPos pos) { AxisAlignedBB bounds = getContent().collisionBounds.get(getSubtype(state)).orElse(null); if (bounds == DEFAULT_AABB_MARKER) return super.getCollisionBoundingBox(state, worldIn, pos); else return bounds; }
public static void drawSelectionBoundingBox(AxisAlignedBB boundingBox) { Tessellator tessellator = Tessellator.getInstance(); VertexBuffer vertexbuffer = tessellator.getBuffer(); vertexbuffer.begin(3, DefaultVertexFormats.POSITION); vertexbuffer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).endVertex(); vertexbuffer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.minZ).endVertex(); vertexbuffer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ).endVertex(); vertexbuffer.pos(boundingBox.minX, boundingBox.minY, boundingBox.maxZ).endVertex(); vertexbuffer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).endVertex(); tessellator.draw(); vertexbuffer.begin(3, DefaultVertexFormats.POSITION); vertexbuffer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).endVertex(); vertexbuffer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ).endVertex(); vertexbuffer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ).endVertex(); vertexbuffer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ).endVertex(); vertexbuffer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).endVertex(); tessellator.draw(); vertexbuffer.begin(1, DefaultVertexFormats.POSITION); vertexbuffer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).endVertex(); vertexbuffer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).endVertex(); vertexbuffer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.minZ).endVertex(); vertexbuffer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ).endVertex(); vertexbuffer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ).endVertex(); vertexbuffer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ).endVertex(); vertexbuffer.pos(boundingBox.minX, boundingBox.minY, boundingBox.maxZ).endVertex(); vertexbuffer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ).endVertex(); tessellator.draw(); }
@Override public AxisAlignedBB getRenderBoundingBox() { if (m_realPlayer == null) { return super.getRenderBoundingBox(); } else { return m_realPlayer.getRenderBoundingBox(); } }
@Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos){ if (state.getBlock() == this){ if (state.getValue(TYPE) == 0){ return AABB_BOTTOM; } if (state.getValue(TYPE) == 1){ return AABB_BOTTOM_2; } if (state.getValue(TYPE) == 2){ return AABB_MID; } if (state.getValue(TYPE) == 3){ return AABB_TOP; } if (state.getValue(TYPE) == 4){ return AABB_NORTH; } if (state.getValue(TYPE) == 5){ return AABB_EAST; } if (state.getValue(TYPE) == 6){ return AABB_SOUTH; } if (state.getValue(TYPE) == 7){ return AABB_WEST; } } return AABB_MID; }
/** * Destroys skeleton arrows in the protected area * Checks whether the arrow was shot by a class deriving from IRangedAttackMob * Sets the arrow on fire for visual effect by default * An arrow already on fire is killed * The effect of this is that the arrow, for one tick, is engulfed in flame, as it looks strange to have the arrow disappear for no reason * @param chunkBounds AxisAlignedBB in which block should act */ private void killArrows(AxisAlignedBB chunkBounds) { List<EntityArrow> list = world.getEntitiesWithinAABB(EntityArrow.class, chunkBounds); for (EntityArrow arrow : list) { if (arrow.shootingEntity instanceof IRangedAttackMob) { if (arrow.isBurning()) { arrow.setDead(); } else { arrow.setFire(1); arrow.addVelocity(-arrow.motionX, 0, -arrow.motionZ); } } } }
/** * Updates the entity bounding box based on current facing */ protected void updateBoundingBox() { if (this.facingDirection != null) { double d0 = (double)this.hangingPosition.getX() + 0.5D; double d1 = (double)this.hangingPosition.getY() + 0.5D; double d2 = (double)this.hangingPosition.getZ() + 0.5D; double d3 = 0.46875D; double d4 = this.offs(this.getWidthPixels()); double d5 = this.offs(this.getHeightPixels()); d0 = d0 - (double)this.facingDirection.getFrontOffsetX() * 0.46875D; d2 = d2 - (double)this.facingDirection.getFrontOffsetZ() * 0.46875D; d1 = d1 + d5; EnumFacing enumfacing = this.facingDirection.rotateYCCW(); d0 = d0 + d4 * (double)enumfacing.getFrontOffsetX(); d2 = d2 + d4 * (double)enumfacing.getFrontOffsetZ(); this.posX = d0; this.posY = d1; this.posZ = d2; double d6 = (double)this.getWidthPixels(); double d7 = (double)this.getHeightPixels(); double d8 = (double)this.getWidthPixels(); if (this.facingDirection.getAxis() == EnumFacing.Axis.Z) { d8 = 1.0D; } else { d6 = 1.0D; } d6 = d6 / 32.0D; d7 = d7 / 32.0D; d8 = d8 / 32.0D; this.setEntityBoundingBox(new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8)); } }
protected AxisAlignedBB getTargetableArea(double targetDistance) { return this.taskOwner.getEntityBoundingBox().expand(targetDistance, 4.0D, targetDistance); }
public static AxisAlignedBB getBoundingBox(BlockPos pos) { return getState(pos).getBoundingBox(WMinecraft.getWorld(), pos) .offset(pos); }