net.minecraft.world.ChunkCache Java Examples
The following examples show how to use
net.minecraft.world.ChunkCache.
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: Light.java From EmergingTechnology with MIT License | 6 votes |
@Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { int bulbTypeId = 0; boolean powered = false; TileEntity tileEntity = worldIn instanceof ChunkCache ? ((ChunkCache) worldIn).getTileEntity(pos, EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos); if (tileEntity instanceof LightTileEntity) { LightTileEntity lightTileEntity = (LightTileEntity) tileEntity; int id = lightTileEntity.getBulbTypeId(); bulbTypeId = LightHelper.getBulbColourFromBulbId(id); powered = lightTileEntity.getEnergy() > 0; } return state.withProperty(POWERED, powered).withProperty(BULBTYPE, bulbTypeId); }
Example #2
Source File: BlockEnderUtilities.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
/** * 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; } }
Example #3
Source File: ProgWidgetAreaItemBase.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
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); }
Example #4
Source File: BlockFastFurnace.java From YouTubeModdingTutorial with MIT License | 5 votes |
@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); if (te instanceof TileFastFurnace) { return state.withProperty(STATE, ((TileFastFurnace) te).getState()); } return super.getActualState(state, world, pos); }
Example #5
Source File: SpatialDetector.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
public SpatialDetector(BlockPos start, World worldIn, int maximum, boolean checkCorners) { firstBlock = start; worldObj = worldIn; maxSize = maximum; corners = checkCorners; BlockPos minPos = new BlockPos(start.getX() - 128, 0, start.getZ() - 128); BlockPos maxPos = new BlockPos(start.getX() + 128, 255, start.getZ() + 128); cache = new ChunkCache(worldIn, minPos, maxPos, 0); }
Example #6
Source File: AccessHelper.java From Logistics-Pipes-2 with MIT License | 5 votes |
@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; }
Example #7
Source File: AccessHelper.java From Logistics-Pipes-2 with MIT License | 5 votes |
@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; }
Example #8
Source File: AccessHelper.java From Logistics-Pipes-2 with MIT License | 5 votes |
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; }
Example #9
Source File: BlockMachine.java From Production-Line with MIT License | 5 votes |
/** * Get the actual Block state of this Block at the given position. This applies properties not visible in the * metadata, such as fence connections. * */ @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { // safety check #see https://mcforge-cn.readthedocs.io/zh/latest/blockstates/states/ TileFacing tile = (TileFacing) (worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos)); if (tile.facing != null) { state = state.withProperty(PROPERTY_FACING, tile.facing); } state = state.withProperty(PROPERTY_ACTIVE, tile.active); return state; }
Example #10
Source File: EntityPathNavigateDrone.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public PathEntity getEntityPathToXYZ(EntityDrone par1Entity, int par2, int par3, int par4, float par5, boolean par6, boolean par7, boolean par8, boolean par9){ if(!par1Entity.isBlockValidPathfindBlock(par2, par3, par4)) return null; PathEntity pathentity = null; int l = MathHelper.floor_double(par1Entity.posX); int i1 = MathHelper.floor_double(par1Entity.posY); int j1 = MathHelper.floor_double(par1Entity.posZ); if(!forceTeleport || l == par2 && i1 == par3 && j1 == par4) { 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(par1Entity.worldObj, l1, i2, j2, k2, l2, i3, 0); pathentity = new PathFinderDrone(par1Entity, chunkcache, par6, par7, pathThroughLiquid, par9).createEntityPathTo(par1Entity, par2, par3, par4, par5); if(pathentity != null) { PathPoint finalPoint = pathentity.getFinalPathPoint(); if(finalPoint == null || finalPoint.xCoord != par2 || finalPoint.yCoord != par3 || finalPoint.zCoord != par4) pathentity = null; } } teleportCounter = pathentity != null ? -1 : 0; telX = par2; telY = par3; telZ = par4; par1Entity.setStandby(false); return pathentity; }
Example #11
Source File: AchievementHandler.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public static void checkFor9x9(EntityPlayer player, int x, int y, int z){ ChunkCache cache = new ChunkCache(player.worldObj, x - 8, y, z - 8, x + 8, y, z + 8, 0); ForgeDirection[] dirs = {ForgeDirection.NORTH, ForgeDirection.WEST}; for(ForgeDirection dir : dirs) { int wallLength = 1; int minX = x; int minZ = z; int maxX = x; int maxZ = z; int newX = x + dir.offsetX; int newZ = z + dir.offsetZ; while(wallLength < 9 && cache.getBlock(newX, y, newZ) == Blocks.cobblestone) { wallLength++; minX = Math.min(minX, newX); minZ = Math.min(minZ, newZ); maxX = Math.max(maxX, newX); maxZ = Math.max(maxZ, newZ); newX += dir.offsetX; newZ += dir.offsetZ; } newX = x - dir.offsetX; newZ = z - dir.offsetZ; while(wallLength < 9 && cache.getBlock(newX, y, newZ) == Blocks.cobblestone) { wallLength++; minX = Math.min(minX, newX); minZ = Math.min(minZ, newZ); maxX = Math.max(maxX, newX); maxZ = Math.max(maxZ, newZ); newX -= dir.offsetX; newZ -= dir.offsetZ; } if(wallLength == 9) { if(checkFor9x9(cache, x, y, z, minX, minZ, maxX, maxZ)) { giveAchievement(player, "dw9x9"); return; } } } }
Example #12
Source File: PhysicsObject.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
/** * @return the cachedSurroundingChunks */ public ChunkCache getCachedSurroundingChunks() { return cachedSurroundingChunks.getCachedChunks(); }