public static IBlockAccess getCache(Collection<BlockPos> area, World world) { if (area.size() == 0) return world; int minX, minY, minZ, maxX, maxY, maxZ; Iterator<BlockPos> iterator = area.iterator(); BlockPos p = iterator.next(); minX = maxX = p.getX(); minY = maxY = p.getY(); minZ = maxZ = p.getZ(); while (iterator.hasNext()) { p = iterator.next(); minX = Math.min(minX, p.getX()); minY = Math.min(minY, p.getY()); minZ = Math.min(minZ, p.getZ()); maxX = Math.max(maxX, p.getX()); maxY = Math.max(maxY, p.getY()); maxZ = Math.max(maxZ, p.getZ()); } return new ChunkCache(world, new BlockPos(minX, minY, minZ), new BlockPos(maxX, maxY, maxZ), 0); }
/** * Returns path to given BlockPos */ public PathEntity getPathToPos(BlockPos pos) { if (!this.canNavigate()) { return null; } else { float f = this.getPathSearchRange(); this.worldObj.theProfiler.startSection("pathfind"); BlockPos blockpos = new BlockPos(this.theEntity); int i = (int)(f + 8.0F); ChunkCache chunkcache = new ChunkCache(this.worldObj, blockpos.add(-i, -i, -i), blockpos.add(i, i, i), 0); PathEntity pathentity = this.pathFinder.createEntityPathTo(chunkcache, this.theEntity, pos, f); this.worldObj.theProfiler.endSection(); return pathentity; } }
/** * Returns the path to the given EntityLiving. Args : entity */ public PathEntity getPathToEntityLiving(Entity entityIn) { if (!this.canNavigate()) { return null; } else { float f = this.getPathSearchRange(); this.worldObj.theProfiler.startSection("pathfind"); BlockPos blockpos = (new BlockPos(this.theEntity)).up(); int i = (int)(f + 16.0F); ChunkCache chunkcache = new ChunkCache(this.worldObj, blockpos.add(-i, -i, -i), blockpos.add(i, i, i), 0); PathEntity pathentity = this.pathFinder.createEntityPathTo(chunkcache, this.theEntity, entityIn, f); this.worldObj.theProfiler.endSection(); return pathentity; } }
/** * Returns path to given BlockPos */ @Nullable public Path getPathToPos(BlockPos pos) { if (!this.canNavigate()) { return null; } else if (this.currentPath != null && !this.currentPath.isFinished() && pos.equals(this.targetPos)) { return this.currentPath; } else { this.targetPos = pos; float f = this.getPathSearchRange(); this.worldObj.theProfiler.startSection("pathfind"); BlockPos blockpos = new BlockPos(this.theEntity); int i = (int)(f + 8.0F); ChunkCache chunkcache = new ChunkCache(this.worldObj, blockpos.add(-i, -i, -i), blockpos.add(i, i, i), 0); Path path = this.pathFinder.findPath(chunkcache, this.theEntity, this.targetPos, f); this.worldObj.theProfiler.endSection(); return path; } }
public static World getWorld(IBlockAccess world) { if (world instanceof World) return (World) world; if (world instanceof ChunkCache) try { Field f = (Field) reflectionCache.get(20); if (f == null) { Class c = Class.forName("net.minecraft.world.ChunkCache"); f = c.getDeclaredField(getNameDynamic(KEY_FIELD_CHUNKCACHE_WORLDOBJ)); f.setAccessible(true); reflectionCache.put(20, f); } return (World) f.get(world); } catch (Throwable t) { t.printStackTrace(); } return null; }
protected Node getNodeForPassableBlock(World world, ChunkCache cache, BlockPos pos, PathFinderSettings settings) { int fallCount = 0; Node node = null; while (node == null) { fallCount = fallCount + 1; BlockPos posBelow = pos.add(0, -fallCount, 0); IBlockState stateBelow = cache.getBlockState(posBelow); if(!this.isValidPosition(posBelow)) { node = new Node.Doom(world, pos); } else if(!this.isPassableBlock(cache, posBelow, stateBelow)) { if (this.canStandOnBlock(cache, posBelow, stateBelow, settings)) { node = new Node.Fall(world, pos); } else if(this.isSwimmableLiquid(stateBelow)) { node = settings.canSwim() ? new Node.Swim(world, pos) : new Node.Doom(world, pos); } } } if(node instanceof Node.Doom) { return node; } else { return fallCount <= settings.maxFallHeight() ? node : new Node.Doom(world, pos); } }
/** * Returns path to given BlockPos */ public PathEntity getPathToPos(BlockPos pos) { if (!this.canNavigate()) { return null; } else if (this.currentPath != null && !this.currentPath.isFinished() && pos.equals(this.field_188564_r)) { return this.currentPath; } else { this.field_188564_r = pos; float f = this.getPathSearchRange(); this.worldObj.profiler.startSection("pathfind"); BlockPos blockpos = new BlockPos(this.theEntity); int i = (int)(f + 8.0F); ChunkCache chunkcache = new ChunkCache(this.worldObj, blockpos.add(-i, -i, -i), blockpos.add(i, i, i), 0); PathEntity pathentity = this.pathFinder.findPathToPos(chunkcache, this.theEntity, this.field_188564_r, f); this.worldObj.profiler.endSection(); return pathentity; } }
/** * Returns the path to the given EntityLiving. Args : entity */ public PathEntity getPathToEntityLiving(Entity entityIn) { if (!this.canNavigate()) { return null; } else { BlockPos blockpos = new BlockPos(entityIn); if (this.currentPath != null && !this.currentPath.isFinished() && blockpos.equals(this.field_188564_r)) { return this.currentPath; } else { this.field_188564_r = blockpos; float f = this.getPathSearchRange(); this.worldObj.profiler.startSection("pathfind"); BlockPos blockpos1 = (new BlockPos(this.theEntity)).up(); int i = (int)(f + 16.0F); ChunkCache chunkcache = new ChunkCache(this.worldObj, blockpos1.add(-i, -i, -i), blockpos1.add(i, i, i), 0); PathEntity pathentity = this.pathFinder.findPathToEntity(chunkcache, this.theEntity, entityIn, f); this.worldObj.profiler.endSection(); return pathentity; } } }
public static int getMixedBrightnessForBlockWithColor(IBlockAccess blockAccess, int x, int y, int z) { int l; Block block = blockAccess.getBlock(x, y, z); if (blockAccess instanceof World) l = CLWorldHelper.getLightBrightnessForSkyBlocksWithColor((World) blockAccess, x, y, z, block.getLightValue(blockAccess, x, y, z)); else l = CLChunkCacheHelper.getLightBrightnessForSkyBlocksWithColor((ChunkCache) blockAccess, x, y, z, block.getLightValue(blockAccess, x, y, z)); if (l == 0 && block instanceof BlockSlab) { --y; block = blockAccess.getBlock(x, y, z); if (blockAccess instanceof World) return CLWorldHelper.getLightBrightnessForSkyBlocksWithColor((World) blockAccess, x, y, z, block.getLightValue(blockAccess, x, y, z)); else return CLChunkCacheHelper.getLightBrightnessForSkyBlocksWithColor((ChunkCache) blockAccess, x, y, z, block.getLightValue(blockAccess, x, y, z)); } else { return l; } }
public static int getLightBrightnessForSkyBlocksWithColor(ChunkCache instance, int x, int y, int z, int lightValue) { int skyBrightness = instance.getSkyBlockTypeBrightness(EnumSkyBlock.Sky, x, y, z); int blockBrightness = instance.getSkyBlockTypeBrightness(EnumSkyBlock.Block, x, y, z); lightValue = ((lightValue & 15) | ((lightValue & 480) >> 1) | ((lightValue & 15360) >> 2) | ((lightValue & 491520) >> 3)); blockBrightness = ((blockBrightness & 15) | ((blockBrightness & 480) >> 1) | ((blockBrightness & 15360) >> 2) | ((blockBrightness & 491520) >> 3)); if (blockBrightness < lightValue) { blockBrightness = lightValue; } return skyBrightness << 20 | blockBrightness << 4; }
/** * Returns the tile of the specified class, returns null if it is the wrong type or does not exist. * Avoids creating new tile entities when using a ChunkCache (off the main thread). * see {@link BlockFlowerPot#getActualState(IBlockState, IBlockAccess, BlockPos)} */ @Nullable public static <T extends TileEntity> T getTileEntitySafely(IBlockAccess world, BlockPos pos, Class<T> tileClass) { TileEntity te; if (world instanceof ChunkCache) { ChunkCache chunkCache = (ChunkCache) world; te = chunkCache.getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK); } else { te = world.getTileEntity(pos); } if (tileClass.isInstance(te)) { return tileClass.cast(te); } else { return null; } }
public PathEntity func_72865_a(Entity p_72865_1_, Entity p_72865_2_, float p_72865_3_, boolean p_72865_4_, boolean p_72865_5_, boolean p_72865_6_, boolean p_72865_7_) { this.field_72984_F.func_76320_a("pathfind"); int var8 = MathHelper.func_76128_c(p_72865_1_.field_70165_t); int var9 = MathHelper.func_76128_c(p_72865_1_.field_70163_u + 1.0D); int var10 = MathHelper.func_76128_c(p_72865_1_.field_70161_v); int var11 = (int)(p_72865_3_ + 16.0F); int var12 = var8 - var11; int var13 = var9 - var11; int var14 = var10 - var11; int var15 = var8 + var11; int var16 = var9 + var11; int var17 = var10 + var11; ChunkCache var18 = new ChunkCache(this, var12, var13, var14, var15, var16, var17, 0); PathEntity var19 = (new PathFinder(var18, p_72865_4_, p_72865_5_, p_72865_6_, p_72865_7_)).func_75856_a(p_72865_1_, p_72865_2_, p_72865_3_); this.field_72984_F.func_76319_b(); return var19; }
public PathEntity func_72844_a(Entity p_72844_1_, int p_72844_2_, int p_72844_3_, int p_72844_4_, float p_72844_5_, boolean p_72844_6_, boolean p_72844_7_, boolean p_72844_8_, boolean p_72844_9_) { this.field_72984_F.func_76320_a("pathfind"); int var10 = MathHelper.func_76128_c(p_72844_1_.field_70165_t); int var11 = MathHelper.func_76128_c(p_72844_1_.field_70163_u); int var12 = MathHelper.func_76128_c(p_72844_1_.field_70161_v); int var13 = (int)(p_72844_5_ + 8.0F); int var14 = var10 - var13; int var15 = var11 - var13; int var16 = var12 - var13; int var17 = var10 + var13; int var18 = var11 + var13; int var19 = var12 + var13; ChunkCache var20 = new ChunkCache(this, var14, var15, var16, var17, var18, var19, 0); PathEntity var21 = (new PathFinder(var20, p_72844_6_, p_72844_7_, p_72844_8_, p_72844_9_)).func_75859_a(p_72844_1_, p_72844_2_, p_72844_3_, p_72844_4_, p_72844_5_); this.field_72984_F.func_76319_b(); return var21; }
public static IBlockAccess getCache(Collection<ChunkPosition> area, World world){ if(area.size() == 0) return world; int minX, minY, minZ, maxX, maxY, maxZ; Iterator<ChunkPosition> iterator = area.iterator(); ChunkPosition p = iterator.next(); minX = maxX = p.chunkPosX; minY = maxY = p.chunkPosY; minZ = maxZ = p.chunkPosZ; while(iterator.hasNext()) { p = iterator.next(); minX = Math.min(minX, p.chunkPosX); minY = Math.min(minY, p.chunkPosY); minZ = Math.min(minZ, p.chunkPosZ); maxX = Math.max(maxX, p.chunkPosX); maxY = Math.max(maxY, p.chunkPosY); maxZ = Math.max(maxZ, p.chunkPosZ); } return new ChunkCache(world, minX, minY, minZ, maxX, maxY, maxZ, 0); }
private PathEntity worldObjgetEntityPathToXYZ(Entity par1Entity, int par2, int par3, int par4, float par5, boolean par6, boolean par7, boolean par8, boolean par9) { int l = MathHelper.floor_double(par1Entity.posX); int i1 = MathHelper.floor_double(par1Entity.posY); int j1 = MathHelper.floor_double(par1Entity.posZ); int k1 = (int) (par5 + 8.0F); int l1 = l - k1; int i2 = i1 - k1; int j2 = j1 - k1; int k2 = l + k1; int l2 = i1 + k1; int i3 = j1 + k1; ChunkCache chunkcache = new ChunkCache(worldObj, l1, i2, j2, k2, l2, i3, 0); PathEntity pathentity = (new PathFinder(chunkcache, par6, par7, par8, par9)).createEntityPathTo(par1Entity, par2, par3, par4, par5); return pathentity; }
@Override public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { TileEntity te = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos); boolean working = false; if (te instanceof PurifierTileEntity) { working = ((PurifierTileEntity)te).isWorking(); } return state.withProperty(WORKING, working); }
public TileEntity getTileEntitySafely(IBlockAccess blockAccess, BlockPos pos) { if (blockAccess instanceof ChunkCache) { return ((ChunkCache) blockAccess).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK); } else { return blockAccess.getTileEntity(pos); } }
private ChunkCacheOF makeChunkCacheOF() { BlockPos blockpos = this.position.add(-1, -1, -1); ChunkCache chunkcache = this.createRegionRenderCache(this.world, blockpos, this.position.add(16, 16, 16), 1); if (Reflector.MinecraftForgeClient_onRebuildChunk.exists()) { Reflector.call(Reflector.MinecraftForgeClient_onRebuildChunk, new Object[] {this.world, this.position, chunkcache}); } ChunkCacheOF chunkcacheof = new ChunkCacheOF(chunkcache, blockpos, 1); return chunkcacheof; }
public ChunkCacheOF(ChunkCache p_i22_1_, BlockPos p_i22_2_, int p_i22_3_) { this.chunkCache = p_i22_1_; this.posX = p_i22_2_.getX() - p_i22_3_; this.posY = p_i22_2_.getY() - p_i22_3_; this.posZ = p_i22_2_.getZ() - p_i22_3_; }
@Nullable /** * Returns path to given BlockPos */ public Path getPathToPos(BlockPos pos) { if (!this.canNavigate()) { return null; } else if (this.currentPath != null && !this.currentPath.isFinished() && pos.equals(this.targetPos)) { return this.currentPath; } else { this.targetPos = pos; float f = this.getPathSearchRange(); this.worldObj.theProfiler.startSection("pathfind"); BlockPos blockpos = new BlockPos(this.theEntity); int i = (int)(f + 8.0F); ChunkCache chunkcache = new ChunkCache(this.worldObj, blockpos.add(-i, -i, -i), blockpos.add(i, i, i), 0); Path path = this.pathFinder.findPath(chunkcache, this.theEntity, this.targetPos, f); this.worldObj.theProfiler.endSection(); return path; } }
@Nullable /** * Returns the path to the given EntityLiving. Args : entity */ public Path getPathToEntityLiving(Entity entityIn) { if (!this.canNavigate()) { return null; } else { BlockPos blockpos = new BlockPos(entityIn); if (this.currentPath != null && !this.currentPath.isFinished() && blockpos.equals(this.targetPos)) { return this.currentPath; } else { this.targetPos = blockpos; float f = this.getPathSearchRange(); this.worldObj.theProfiler.startSection("pathfind"); BlockPos blockpos1 = (new BlockPos(this.theEntity)).up(); int i = (int)(f + 16.0F); ChunkCache chunkcache = new ChunkCache(this.worldObj, blockpos1.add(-i, -i, -i), blockpos1.add(i, i, i), 0); Path path = this.pathFinder.findPath(chunkcache, this.theEntity, entityIn, f); this.worldObj.theProfiler.endSection(); return path; } } }
public static ChunkCache getRegionRenderCache(World world, BlockPos pos) { int x = pos.getX() & ~0xF; int y = pos.getY() & ~0xF; int z = pos.getZ() & ~0xF; return regionCache.getUnchecked(Pair.of(world, new BlockPos(x, y, z))); }
private void resetChunkCache() { int i = 1; ChunkCache cache = createRegionRenderCache(this.world, this.position.add(-1, -1, -1), this.position.add(16, 16, 16), 1); net.minecraftforge.client.MinecraftForgeClient.onRebuildChunk(this.world, this.position, cache); this.region = cache; }
/** * Returns the path to the given EntityLiving. Args : entity */ @Nullable public Path getPathToEntityLiving(Entity entityIn) { if (!this.canNavigate()) { return null; } else { BlockPos blockpos = new BlockPos(entityIn); if (this.currentPath != null && !this.currentPath.isFinished() && blockpos.equals(this.targetPos)) { return this.currentPath; } else { this.targetPos = blockpos; float f = this.getPathSearchRange(); this.worldObj.theProfiler.startSection("pathfind"); BlockPos blockpos1 = (new BlockPos(this.theEntity)).up(); int i = (int)(f + 16.0F); ChunkCache chunkcache = new ChunkCache(this.worldObj, blockpos1.add(-i, -i, -i), blockpos1.add(i, i, i), 0); Path path = this.pathFinder.findPath(chunkcache, this.theEntity, entityIn, f); this.worldObj.theProfiler.endSection(); return path; } } }
public static void onPreRenderWorld(WorldRenderer worldRenderer, int pass) { if(worldRendererRB != null) { worldRenderPass = pass; MinecraftForge.EVENT_BUS.post(new RenderWorldEvent.Pre(worldRenderer, (ChunkCache)worldRendererRB.field_147845_a, worldRendererRB, pass)); } }
public static void onPostRenderWorld(WorldRenderer worldRenderer, int pass) { if(worldRendererRB != null) { MinecraftForge.EVENT_BUS.post(new RenderWorldEvent.Post(worldRenderer, (ChunkCache)worldRendererRB.field_147845_a, worldRendererRB, pass)); worldRenderPass = -1; } }
public RenderWorldEvent(WorldRenderer renderer, ChunkCache chunkCache, RenderBlocks renderBlocks, int pass) { this.renderer = renderer; this.chunkCache = chunkCache; this.renderBlocks = renderBlocks; this.pass = pass; }
public T getWorldTile(IBlockAccess world, BlockPos pos) { if (world instanceof ChunkCache) return (T) ((ChunkCache) world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK); else return (T) world.getTileEntity(pos); }
public boolean checkWorldTile(IBlockAccess world, BlockPos pos) { if (world instanceof ChunkCache) return tileClass.isInstance(((ChunkCache) world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK)); else return tileClass.isInstance(world.getTileEntity(pos)); }
public boolean isWordTileCore(IBlockAccess world, BlockPos pos) { if (world instanceof ChunkCache) return ((ChunkCache) world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) instanceof ITileMultiblockCore; else return world.getTileEntity(pos) instanceof ITileMultiblockCore; }
@Nullable public static TileEntity getTileSafe(IBlockAccess worldIn, BlockPos pos, EnumFacing facing) { TileEntity target = worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos.offset(facing), Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos.offset(facing)); return target; }
@Nullable public static TileEntity getTileSafe(IBlockAccess worldIn, BlockPos pos) { TileEntity target = worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos); return target; }
public static TileGenericPipe getPipeSafe(IBlockAccess worldIn, BlockPos pos, EnumFacing facing ) { TileEntity target = worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos.offset(facing), Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos.offset(facing)); if(target instanceof TileGenericPipe) return (TileGenericPipe) target; return null; }
public Node getNodeForPosition(World world, ChunkCache cache, BlockPos pos, IBlockState state, PathFinderSettings settings) { Node node; if (!this.isValidPosition(pos)) { node = new Node.Doom(world, pos); } else if (this.isPassableBlock(cache, pos, state)) { node = this.getNodeForPassableBlock(world, cache, pos, settings); } else if (this.isSwimmableLiquid(state)) { node = this.getNodeForLiquid(world, pos, settings); } else { node = this.getNodeForBlock(world, cache, pos, state, settings); } return node; }