net.minecraft.world.chunk.Chunk Java Examples
The following examples show how to use
net.minecraft.world.chunk.Chunk.
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: ActivationRange.java From Thermos with GNU General Public License v3.0 | 6 votes |
/** * Initializes an entities type on construction to specify what group this * entity is in for activation ranges. * * @param entity * @return group id */ public static byte initializeEntityActivationType(Entity entity) { Chunk chunk = null; // Cauldron start - account for entities that dont extend EntityMob, EntityAmbientCreature, EntityCreature if ( entity instanceof EntityMob || entity instanceof EntitySlime || entity.isCreatureType(EnumCreatureType.monster, false)) // Cauldron - account for entities that dont extend EntityMob { return 1; // Monster } else if ( entity instanceof EntityCreature || entity instanceof EntityAmbientCreature || entity.isCreatureType(EnumCreatureType.creature, false) || entity.isCreatureType(EnumCreatureType.waterCreature, false) || entity.isCreatureType(EnumCreatureType.ambient, false)) { return 2; // Animal // Cauldron end } else { return 3; // Misc } }
Example #2
Source File: SchematicWorldRenderingNotifier.java From litematica with GNU Lesser General Public License v3.0 | 6 votes |
public static void markSchematicChunkForRenderUpdate(BlockPos pos) { World world = SchematicWorldHandler.getSchematicWorld(); if (world != null) { Long2ObjectMap<Chunk> schematicChunks = ((IMixinChunkProviderClient) (Object) world.getChunkProvider()).getLoadedChunks(); Long2ObjectMap<Chunk> clientChunks = ((IMixinChunkProviderClient) (Object) Minecraft.getMinecraft().world.getChunkProvider()).getLoadedChunks(); long key = ChunkPos.asLong(pos.getX() >> 4, pos.getZ() >> 4); if (schematicChunks.containsKey(key) && clientChunks.containsKey(key)) { RenderGlobal rg = LitematicaRenderer.getInstance().getWorldRenderer(); rg.markBlockRangeForRenderUpdate(pos.getX() - 1, pos.getY() - 1, pos.getZ() - 1,pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1); } } }
Example #3
Source File: SchematicWorldRenderingNotifier.java From litematica with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void updateBetweenY(int minY, int maxY) { World world = SchematicWorldHandler.getSchematicWorld(); if (world != null) { RenderGlobal rg = LitematicaRenderer.getInstance().getWorldRenderer(); Long2ObjectMap<Chunk> schematicChunks = ((IMixinChunkProviderClient) (Object) world.getChunkProvider()).getLoadedChunks(); Long2ObjectMap<Chunk> clientChunks = ((IMixinChunkProviderClient) (Object) Minecraft.getMinecraft().world.getChunkProvider()).getLoadedChunks(); for (Chunk chunk : schematicChunks.values()) { // Only mark chunks that are actually rendered (if the schematic world contains more chunks) if (chunk.isEmpty() == false && clientChunks.containsKey(ChunkPos.asLong(chunk.x, chunk.z))) { rg.markBlockRangeForRenderUpdate((chunk.x << 4) - 1, minY, (chunk.z << 4) - 1, (chunk.x << 4) + 16, maxY, (chunk.z << 4) + 16); } } } }
Example #4
Source File: ChunkManager.java From mapwriter with MIT License | 6 votes |
public static MwChunk copyToMwChunk(Chunk chunk) { byte[][] msbArray = new byte[16][]; byte[][] lsbArray = new byte[16][]; byte[][] metaArray = new byte[16][]; byte[][] lightingArray = new byte[16][]; ExtendedBlockStorage[] storageArrays = chunk.getBlockStorageArray(); if (storageArrays != null) { for (ExtendedBlockStorage storage : storageArrays) { if (storage != null) { int y = (storage.getYLocation() >> 4) & 0xf; lsbArray[y] = storage.getBlockLSBArray(); msbArray[y] = (storage.getBlockMSBArray() != null) ? storage.getBlockMSBArray().data : null; metaArray[y] = (storage.getMetadataArray() != null) ? storage.getMetadataArray().data : null; lightingArray[y] = (storage.getBlocklightArray() != null) ? storage.getBlocklightArray().data : null; } } } return new MwChunk(chunk.xPosition, chunk.zPosition, chunk.worldObj.provider.dimensionId, msbArray, lsbArray, metaArray, lightingArray, chunk.getBiomeArray()); }
Example #5
Source File: TileChunkLoadHook.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 6 votes |
@SubscribeEvent public void onChunkLoad(ChunkEvent.Load event) { IChunk chunk = event.getChunk(); Map<BlockPos, TileEntity> tiles = null; if (chunk instanceof ChunkPrimerWrapper) { chunk = ((ChunkPrimerWrapper) chunk).func_217336_u(); } if (chunk instanceof Chunk) { tiles = ((Chunk) chunk).getTileEntityMap(); } if (chunk instanceof ChunkPrimer) { tiles = ((ChunkPrimer) chunk).getTileEntities(); } if (tiles != null) { for (TileEntity tile : tiles.values()) { if (tile instanceof IChunkLoadTile) { ((IChunkLoadTile) tile).onChunkLoad(); } } } }
Example #6
Source File: SemiBlockManager.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
private void setSemiBlock(World world, int x, int y, int z, ISemiBlock semiBlock, Chunk chunk){ if(semiBlock != null && !registeredTypes.containsValue(semiBlock.getClass())) throw new IllegalStateException("ISemiBlock \"" + semiBlock + "\" was not registered!"); ChunkPosition pos = new ChunkPosition(x, y, z); if(semiBlock != null) { semiBlock.initialize(world, pos); addingBlocks.add(semiBlock); } else { ISemiBlock removedBlock = getOrCreateMap(chunk).get(pos); if(removedBlock != null) { removedBlock.invalidate(); for(EntityPlayerMP player : syncList.get(chunk)) { NetworkHandler.sendTo(new PacketSetSemiBlock(pos, null), player); } } } chunk.setChunkModified(); }
Example #7
Source File: ChunkGeneratorUnderWorld.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@Nonnull @Override public Chunk generateChunk(int x, int z) { ChunkPrimer chunkprimer = new ChunkPrimer(); // Get a list of blocks to check lighting for, as a "side effect" of // actually generating the clouds List<Pair<BlockPos, BlockPos>> litBlocks = generate(x, z, chunkprimer); Chunk chunk = new Chunk(world, chunkprimer, x, z); litBlocks.forEach(pair -> { BlockPos lower = pair.getFirst(); BlockPos upper = pair.getSecond(); for (int i = 0; i < 15; i++) { if (lower.getY() + i > upper.getY()) return; chunk.setLightFor(EnumSkyBlock.BLOCK, lower.up(i), 15 - i); } }); return chunk; }
Example #8
Source File: WorldOverlayRenderer.java From NotEnoughItems with MIT License | 6 votes |
private static int getSpawnMode(Chunk chunk, int x, int y, int z) { World world = chunk.getWorld(); BlockPos pos = new BlockPos(x, y, z); if (!SpawnerAnimals.canCreatureTypeSpawnAtLocation(SpawnPlacementType.ON_GROUND, world, pos) || chunk.getLightFor(EnumSkyBlock.BLOCK, pos) >= 8) return 0; c.set(x+0.2, y+0.01, z+0.2, x+0.8, y+1.8, z+0.8); AxisAlignedBB aabb = c.aabb(); if (!world.checkNoEntityCollision(aabb) || !world.getCollidingBoundingBoxes(dummyEntity, aabb).isEmpty() || world.isAnyLiquid(aabb)) return 0; if (chunk.getLightFor(EnumSkyBlock.SKY, pos) >= 8) return 1; return 2; }
Example #9
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public Chunk loadChunk(World world, int x, int z, boolean generate) { ChunkProviderServer provider = (ChunkProviderServer) world.getChunkProvider(); if (generate) { return provider.provideChunk(x, z); } else { return provider.loadChunk(x, z); } }
Example #10
Source File: ChunkManager.java From mapwriter with MIT License | 5 votes |
public synchronized void saveChunks() { for (Map.Entry<Chunk, Integer> entry : this.chunkMap.entrySet()) { int flags = entry.getValue(); if ((flags & VIEWED_FLAG) != 0) { this.addSaveChunkTask(entry.getKey()); } } }
Example #11
Source File: SpongeQueue_1_12.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) { Map<BlockPos, TileEntity> tiles = chunk.getTileEntityMap(); pos.setPos(x, y, z); TileEntity tile = tiles.get(pos); return tile != null ? getTag(tile) : null; }
Example #12
Source File: CaveFinderHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
private void addSearcher(Chunk chunk, Block block) { stopPool2Tasks(); ChunkSearcher searcher = new ChunkSearcher(chunk, block); searchers.put(chunk, searcher); searcher.startSearching(pool1); }
Example #13
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) { Map<BlockPos, TileEntity> tiles = chunk.getTileEntityMap(); pos.setPos(x, y, z); TileEntity tile = tiles.get(pos); return tile != null ? getTag(tile) : null; }
Example #14
Source File: MultiblockControllerBase.java From BeefCore with MIT License | 5 votes |
/** * Driver for the update loop. If the machine is assembled, runs * the game logic update method. * @see erogenousbeef.core.multiblock.MultiblockControllerBase#update() //TODO Fix this Javadoc */ public final void updateMultiblockEntity() { if(connectedParts.isEmpty()) { // This shouldn't happen, but just in case... MultiblockRegistry.addDeadController(this.worldObj, this); return; } if(this.assemblyState != AssemblyState.Assembled) { // Not assembled - don't run game logic return; } if(worldObj.isRemote) { updateClient(); } else if(updateServer()) { // If this returns true, the server has changed its internal data. // If our chunks are loaded (they should be), we must mark our chunks as dirty. if(minimumCoord != null && maximumCoord != null && this.worldObj.checkChunksExist(minimumCoord.x, minimumCoord.y, minimumCoord.z, maximumCoord.x, maximumCoord.y, maximumCoord.z)) { int minChunkX = minimumCoord.x >> 4; int minChunkZ = minimumCoord.z >> 4; int maxChunkX = maximumCoord.x >> 4; int maxChunkZ = maximumCoord.z >> 4; for(int x = minChunkX; x <= maxChunkX; x++) { for(int z = minChunkZ; z <= maxChunkZ; z++) { // Ensure that we save our data, even if the our save delegate is in has no TEs. Chunk chunkToSave = this.worldObj.getChunkFromChunkCoords(x, z); chunkToSave.setChunkModified(); } } } } // Else: Server, but no need to save data. }
Example #15
Source File: CaveFinderHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
private void addSearchersInRange(ChunkPos center, int chunkRange, Block block) { ArrayList<Chunk> chunksInRange = getChunksInRange(center, chunkRange); for(Chunk chunk : chunksInRange) { if(searchers.containsKey(chunk)) continue; addSearcher(chunk, block); } }
Example #16
Source File: MoveBlocks.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
/** * @param world * @param oldPos * @param newPos * @param physicsObjectOptional Used when we're using this to copy from world to physics object; * should be empty when other way around. */ public static void copyBlockToPos(World world, BlockPos oldPos, BlockPos newPos, Optional<PhysicsObject> physicsObjectOptional) { // To avoid any updates crap, just edit the chunk data array directly. // These look switched, but trust me they aren't IBlockState oldState = world.getBlockState(newPos); IBlockState newState = world.getBlockState(oldPos); // A hacky way to set the block state within the chunk while avoiding any block updates. Chunk chunkToSet = world.getChunk(newPos); int storageIndex = newPos.getY() >> 4; // Check that we're placing the block in a valid position if (storageIndex < 0 || storageIndex >= chunkToSet.storageArrays.length) { // Invalid position, abort! return; } if (chunkToSet.storageArrays[storageIndex] == Chunk.NULL_BLOCK_STORAGE) { chunkToSet.storageArrays[storageIndex] = new ExtendedBlockStorage(storageIndex << 4, true); } chunkToSet.storageArrays[storageIndex] .set(newPos.getX() & 15, newPos.getY() & 15, newPos.getZ() & 15, newState); // Only want to send the update to clients and nothing else, so we use flag 2. world.notifyBlockUpdate(newPos, oldState, newState, 2); // Pretty messy to put this here but it works. Basically the ship keeps track of which of its chunks are // actually being used for performance reasons. if (physicsObjectOptional.isPresent()) { int minChunkX = physicsObjectOptional.get() .getOwnedChunks() .minX(); int minChunkZ = physicsObjectOptional.get() .getOwnedChunks() .minZ(); } // Now that we've copied the block to the position, copy the tile entity copyTileEntityToPos(world, oldPos, newPos, physicsObjectOptional); }
Example #17
Source File: FindEntityCommand.java From seppuku with GNU General Public License v3.0 | 5 votes |
@Override public void exec(String input) { if (!this.clamp(input, 2, 2)) { this.printUsage(); return; } final Minecraft mc = Minecraft.getMinecraft(); final BlockPos pos = mc.player.getPosition(); final Chunk chunk = mc.world.getChunk(pos); final Biome biome = chunk.getBiome(pos, mc.world.getBiomeProvider()); System.out.println(biome.getSpawnableList(EnumCreatureType.CREATURE)); }
Example #18
Source File: VanillaChunkHashMap.java From Thermos with GNU General Public License v3.0 | 5 votes |
@Override public void add(long key, Object value) { if(value instanceof Chunk) { Chunk c = (Chunk) value; chunkt_TH.put(c); vanilla.put(V2B(key), c); } }
Example #19
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) { Map<BlockPos, TileEntity> tiles = chunk.getTileEntityMap(); pos.set(x, y, z); TileEntity tile = tiles.get(pos); return tile != null ? getTag(tile) : null; }
Example #20
Source File: SpongeQueue_1_11.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public ExtendedBlockStorage[] getCachedSections(World world, int cx, int cz) { Chunk chunk = world.getChunkProvider().getLoadedChunk(cx, cz); if (chunk != null) { return chunk.getBlockStorageArray(); } return null; }
Example #21
Source File: WizardryChunkCapability.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
public static WizardryChunk get(Chunk chunk) { WizardryChunk cap = chunk.getCapability(capability(), null); if (cap == null) throw new IllegalStateException("Missing capability: " + chunk.getWorld().getWorldInfo().getWorldName() + "/" + chunk.getWorld().provider.getDimensionType().getName() + "/(" + chunk.x + ","+ chunk.z + ")"); return cap; }
Example #22
Source File: StructureFeatureMixin.java From fabric-carpet with MIT License | 5 votes |
private StructureStart forceStructureStart(IWorld worldIn, ChunkGenerator <? extends ChunkGeneratorConfig > generator, Random rand, long packedChunkPos) { ChunkPos chunkpos = new ChunkPos(packedChunkPos); StructureStart structurestart; Chunk ichunk = worldIn.getChunk(chunkpos.x, chunkpos.z, ChunkStatus.STRUCTURE_STARTS, false); if (ichunk != null) { structurestart = ichunk.getStructureStart(this.getName()); if (structurestart != null && structurestart != StructureStart.DEFAULT) { return structurestart; } } Biome biome_1 = generator.getBiomeSource().getBiomeForNoiseGen((chunkpos.getStartX() + 9) >> 2, 0, (chunkpos.getStartZ() + 9) >> 2 ); StructureStart structurestart1 = getStructureStartFactory().create((StructureFeature)(Object)this, chunkpos.x, chunkpos.z, BlockBox.empty(),0,generator.getSeed()); structurestart1.initialize(generator, ((ServerWorld)worldIn).getStructureManager() , chunkpos.x, chunkpos.z, biome_1); structurestart = structurestart1.hasChildren() ? structurestart1 : StructureStart.DEFAULT; if (structurestart.hasChildren()) { worldIn.getChunk(chunkpos.x, chunkpos.z).setStructureStart(this.getName(), structurestart); } //long2objectmap.put(packedChunkPos, structurestart); return structurestart; }
Example #23
Source File: ThreadedAnvilChunkStorage_scarpetChunkCreationMixin.java From fabric-carpet with MIT License | 5 votes |
@Inject(method = "method_19534", require = 0, at = @At( value = "INVOKE", target = "Lnet/minecraft/server/world/ThreadedAnvilChunkStorage;convertToFullChunk(Lnet/minecraft/server/world/ChunkHolder;)Ljava/util/concurrent/CompletableFuture;", shift = At.Shift.AFTER )) private void onChunkGenerated(ChunkHolder chunkHolder, Chunk chunk, CallbackInfoReturnable<CompletableFuture> cir) { if (CHUNK_GENERATED.isNeeded()) world.getServer().execute( () -> CHUNK_GENERATED.onChunkGenerated(world, chunk) ); }
Example #24
Source File: DroneAILogistics.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public boolean shouldExecute(){ manager.clearLogistics(); Set<ChunkPosition> area = widget.getCachedAreaSet(); if(area.size() == 0) return false; int minX = Integer.MAX_VALUE, maxX = Integer.MIN_VALUE, minZ = Integer.MAX_VALUE, maxZ = Integer.MIN_VALUE; for(ChunkPosition pos : area) { minX = Math.min(minX, pos.chunkPosX); maxX = Math.max(maxX, pos.chunkPosX); minZ = Math.min(minZ, pos.chunkPosZ); maxZ = Math.max(maxZ, pos.chunkPosZ); } for(int x = minX; x < maxX + 16; x += 16) { for(int z = minZ; z < maxZ + 16; z += 16) { Chunk chunk = drone.getWorld().getChunkFromBlockCoords(x, z); Map<ChunkPosition, ISemiBlock> map = SemiBlockManager.getInstance(drone.getWorld()).getSemiBlocks().get(chunk); if(map != null) { for(Map.Entry<ChunkPosition, ISemiBlock> entry : map.entrySet()) { if(entry.getValue() instanceof SemiBlockLogistics && area.contains(entry.getKey())) { SemiBlockLogistics logisticsBlock = (SemiBlockLogistics)entry.getValue(); manager.addLogisticFrame(logisticsBlock); } } } } } curTask = null; return doLogistics(); }
Example #25
Source File: SpongeQueue_1_12.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public void setHeightMap(FaweChunk chunk, byte[] heightMap) { Chunk forgeChunk = (Chunk) chunk.getChunk(); if (forgeChunk != null) { int[] otherMap = forgeChunk.getHeightMap(); for (int i = 0; i < heightMap.length; i++) { int newHeight = heightMap[i] & 0xFF; int currentHeight = otherMap[i]; if (newHeight > currentHeight) { otherMap[i] = newHeight; } } } }
Example #26
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
public boolean hasEntities(Chunk nmsChunk) { ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists(); for (int i = 0; i < entities.length; i++) { ClassInheritanceMultiMap<Entity> slice = entities[i]; if (slice != null && !slice.isEmpty()) { return true; } } return false; }
Example #27
Source File: PhysRenderChunk.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
RenderLayerDisplayList(Chunk chunk, int yMin, int yMax, PhysRenderChunk parent) { chunkToRender = chunk; this.yMin = yMin; this.yMax = yMax; this.parent = parent; markDirty(); glCallListCutout = GLAllocation.generateDisplayLists(4); glCallListCutoutMipped = glCallListCutout + 1; glCallListSolid = glCallListCutout + 2; glCallListTranslucent = glCallListCutout + 3; }
Example #28
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public void setHeightMap(FaweChunk chunk, byte[] heightMap) { Chunk forgeChunk = (Chunk) chunk.getChunk(); if (forgeChunk != null) { int[] otherMap = forgeChunk.getHeightMap(); for (int i = 0; i < heightMap.length; i++) { int newHeight = heightMap[i] & 0xFF; int currentHeight = otherMap[i]; if (newHeight > currentHeight) { otherMap[i] = newHeight; } } } }
Example #29
Source File: ChunkLoaderManager.java From ChickenChunks with MIT License | 5 votes |
@SuppressWarnings("unchecked") public static void cleanChunks(WorldServer world) { int dim = CommonUtils.getDimension(world); int viewdist = ServerUtils.mc().getConfigurationManager().getViewDistance(); HashSet<ChunkCoordIntPair> loadedChunks = new HashSet<ChunkCoordIntPair>(); for (EntityPlayer player : ServerUtils.getPlayersInDimension(dim)) { int playerChunkX = (int) player.posX >> 4; int playerChunkZ = (int) player.posZ >> 4; for (int cx = playerChunkX - viewdist; cx <= playerChunkX + viewdist; cx++) for (int cz = playerChunkZ - viewdist; cz <= playerChunkZ + viewdist; cz++) loadedChunks.add(new ChunkCoordIntPair(cx, cz)); } ImmutableSetMultimap<ChunkCoordIntPair, Ticket> persistantChunks = world.getPersistentChunks(); PlayerManager manager = world.getPlayerManager(); for (Chunk chunk : (List<Chunk>) world.theChunkProviderServer.loadedChunks) { ChunkCoordIntPair coord = chunk.getChunkCoordIntPair(); if (!loadedChunks.contains(coord) && !persistantChunks.containsKey(coord) && world.theChunkProviderServer.chunkExists(coord.chunkXPos, coord.chunkZPos)) { PlayerInstance instance = manager.getOrCreateChunkWatcher(coord.chunkXPos, coord.chunkZPos, false); if (instance == null) { world.theChunkProviderServer.unloadChunksIfNotNearSpawn(coord.chunkXPos, coord.chunkZPos); } else { while (instance.playersWatchingChunk.size() > 0) instance.removePlayer((EntityPlayerMP) instance.playersWatchingChunk.get(0)); } } } if (ServerUtils.getPlayersInDimension(dim).isEmpty() && world.getPersistentChunks().isEmpty() && !DimensionManager.shouldLoadSpawn(dim)) { DimensionManager.unloadWorld(dim); } }
Example #30
Source File: ChunkFinder.java From LookingGlass with GNU General Public License v3.0 | 5 votes |
public static boolean isBlockNormalCubeDefault(Chunk chunk, int par1, int par2, int par3, boolean par4) { if (par1 >= -30000000 && par3 >= -30000000 && par1 < 30000000 && par3 < 30000000) { if (chunk != null && !chunk.isEmpty()) { Block block = chunk.getBlock(par1 & 15, par2, par3 & 15); return block.isNormalCube(); } } return par4; }