use of net.minecraft.world.chunk.IChunk in project FrostedHeart by TeamMoegMC.
the class ChunkData method removeChunkAdjust.
/**
* Used on a ServerWorld context to set temperature in certain 3D region in a
* ChunkData instance
* Updates server side cache first. Then send a sync packet to every client.
*/
private static void removeChunkAdjust(IWorld world, ChunkPos chunkPos, ITemperatureAdjust adj) {
if (world != null && !world.isRemote()) {
IChunk chunk = world.getChunk(chunkPos.x, chunkPos.z);
ChunkData data = ChunkData.getCapability(chunk).orElseGet(() -> null);
if (data != null)
data.adjusters.remove(adj);
}
}
use of net.minecraft.world.chunk.IChunk in project LoliServer by Loli-Server.
the class ChunkGenWorker method doWork.
@Override
public boolean doWork() {
/* TODO: Check how many things are pending save, and slow down world gen if to many
AnvilChunkLoader loader = dim.getChunkProvider().chunkLoader instanceof AnvilChunkLoader ? (AnvilChunkLoader)world.getChunkProvider().chunkLoader : null;
if (loader != null && loader.getPendingSaveCount() > 100)
{
if (lastNotifcationTime < System.currentTimeMillis() - 10*1000)
{
listener.sendSuccess(new TranslationTextComponent("commands.forge.gen.progress", total - queue.size(), total), true);
lastNotifcationTime = System.currentTimeMillis();
}
return false;
}
*/
BlockPos next = queue.poll();
if (next != null) {
if (++lastNotification >= notificationFrequency || lastNotifcationTime < System.currentTimeMillis() - 60 * 1000) {
listener.sendSuccess(new TranslationTextComponent("commands.forge.gen.progress", total - queue.size(), total), true);
lastNotification = 0;
lastNotifcationTime = System.currentTimeMillis();
}
int x = next.getX();
int z = next.getZ();
if (!dim.hasChunk(x, z)) {
// Chunk is unloaded
IChunk chunk = dim.getChunk(x, z, ChunkStatus.EMPTY, true);
if (!chunk.getStatus().isOrAfter(ChunkStatus.FULL)) {
chunk = dim.getChunk(x, z, ChunkStatus.FULL);
// There isn't a way to check if the chunk is actually created just if it was loaded
genned++;
}
}
}
if (queue.size() == 0) {
listener.sendSuccess(new TranslationTextComponent("commands.forge.gen.complete", genned, total, dim.dimension().location()), true);
/* TODO: Readd if/when we introduce world unloading, or get Mojang to do it.
if (keepingLoaded != null && !keepingLoaded)
DimensionManager.keepLoaded(dim, false);
*/
return false;
}
return true;
}
use of net.minecraft.world.chunk.IChunk in project ChocolateQuestRepoured by TeamChocoQuest.
the class BlockPlacingHelper method setBlockState.
public static boolean setBlockState(World world, BlockPos pos, BlockState state, @Nullable TileEntity tileEntity, int flags, boolean updateLight) {
if (CQRMain.isPhosphorInstalled || CQRConfig.advanced.instantLightUpdates || updateLight) {
if (!world.setBlock(pos, state, flags)) {
return false;
}
if (tileEntity != null) {
world.setBlockEntity(pos, tileEntity);
tileEntity.updateContainingBlockInfo();
}
return true;
}
if (world.isOutsideBuildHeight(pos)) {
return false;
}
if (!world.isRemote && world.getWorldInfo().getTerrainType() == WorldType.DEBUG_ALL_BLOCK_STATES) {
return false;
}
IChunk chunk = world.getChunk(pos);
ChunkSection blockStorage = chunk.getSections()[pos.getY() >> 4];
if (blockStorage == Chunk.EMPTY_SECTION) {
if (state == Blocks.AIR.defaultBlockState()) {
return false;
}
blockStorage = new ChunkSection(pos.getY() >> 4 << 4);
chunk.getSections()[pos.getY() >> 4] = blockStorage;
}
return setBlockState(world, chunk, blockStorage, pos, state, tileEntity, flags);
}
use of net.minecraft.world.chunk.IChunk in project FastAsyncWorldEdit by IntellectualSites.
the class ForgeWorld method setBiome.
@Override
public boolean setBiome(BlockVector2 position, BiomeType biome) {
checkNotNull(position);
checkNotNull(biome);
IChunk chunk = getWorld().getChunk(position.getBlockX() >> 4, position.getBlockZ() >> 4, ChunkStatus.FULL, false);
BiomeContainer container = chunk == null ? null : chunk.getBiomes();
if (chunk == null || container == null) {
return false;
}
// Temporary, while biome setting is 2D only
for (int i = 0; i < BiomeMath.VERTICAL_BIT_MASK; i++) {
int idx = BiomeMath.computeBiomeIndex(position.getX(), i, position.getZ());
container.biomes[idx] = ForgeAdapter.adapt(biome);
}
chunk.setModified(true);
return true;
}
use of net.minecraft.world.chunk.IChunk in project minecolonies by Minecolonies.
the class Tree method checkIfInColonyAndNotInBuilding.
/**
* Calculates with a colony if the position is inside the colony and if it is inside a building.
*
* @param pos the position.
* @param colony the colony.
* @param world the world to use
* @return return false if not inside the colony or if inside a building.
*/
public static boolean checkIfInColonyAndNotInBuilding(final BlockPos pos, final IColony colony, final IWorldReader world) {
final IChunk chunk = world.getChunk(pos);
if (!(chunk instanceof Chunk)) {
return false;
}
final IColonyTagCapability cap = ((Chunk) chunk).getCapability(CLOSE_COLONY_CAP, null).resolve().orElse(null);
if (cap != null && cap.getOwningColony() != colony.getID()) {
return false;
}
// Dynamic tree's are never part of buildings
if (Compatibility.isDynamicBlock(world.getBlockState(pos).getBlock())) {
return true;
}
for (final IBuilding building : colony.getBuildingManager().getBuildings().values()) {
if (building.isInBuilding(pos)) {
return false;
}
}
return true;
}
Aggregations