Search in sources :

Example 1 with ChunkProviderServer

use of net.minecraft.world.gen.ChunkProviderServer in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class PhysicsObject method replaceOuterChunksWithAir.

//Experimental, could fix issues with random shit generating inside of Ships
private void replaceOuterChunksWithAir() {
    for (int x = ownedChunks.minX - 1; x <= ownedChunks.maxX + 1; x++) {
        for (int z = ownedChunks.minZ - 1; z <= ownedChunks.maxZ + 1; z++) {
            if (x == ownedChunks.minX - 1 || x == ownedChunks.maxX + 1 || z == ownedChunks.minZ - 1 || z == ownedChunks.maxZ + 1) {
                //This is satisfied for the chunks surrounding a Ship, do fill it with empty space
                Chunk chunk = new Chunk(worldObj, x, z);
                ChunkProviderServer provider = (ChunkProviderServer) worldObj.getChunkProvider();
                chunk.isModified = true;
                provider.id2ChunkMap.put(ChunkPos.chunkXZ2Int(x, z), chunk);
            }
        }
    }
}
Also used : ChunkProviderServer(net.minecraft.world.gen.ChunkProviderServer) SPacketUnloadChunk(net.minecraft.network.play.server.SPacketUnloadChunk) Chunk(net.minecraft.world.chunk.Chunk)

Example 2 with ChunkProviderServer

use of net.minecraft.world.gen.ChunkProviderServer in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class PhysicsObject method injectChunkIntoWorld.

public void injectChunkIntoWorld(Chunk chunk, int x, int z, boolean putInId2ChunkMap) {
    ChunkProviderServer provider = (ChunkProviderServer) worldObj.getChunkProvider();
    //TileEntities will break if you don't do this
    chunk.isChunkLoaded = true;
    chunk.isModified = true;
    claimedChunks[x - ownedChunks.minX][z - ownedChunks.minZ] = chunk;
    if (putInId2ChunkMap) {
        provider.id2ChunkMap.put(ChunkPos.chunkXZ2Int(x, z), chunk);
    }
    PlayerChunkMap map = ((WorldServer) worldObj).getPlayerChunkMap();
    PlayerChunkMapEntry entry = new PlayerChunkMapEntry(map, x, z) {

        @Override
        public boolean hasPlayerMatchingInRange(double range, Predicate<EntityPlayerMP> predicate) {
            return true;
        }
    };
    long i = map.getIndex(x, z);
    map.playerInstances.put(i, entry);
    map.playerInstanceList.add(entry);
    entry.sentToPlayers = true;
    entry.players = watchingPlayers;
    claimedChunksEntries[x - ownedChunks.minX][z - ownedChunks.minZ] = entry;
//		MinecraftForge.EVENT_BUS.post(new ChunkEvent.Load(chunk));
}
Also used : ChunkProviderServer(net.minecraft.world.gen.ChunkProviderServer) WorldServer(net.minecraft.world.WorldServer) PlayerChunkMapEntry(net.minecraft.server.management.PlayerChunkMapEntry) PlayerChunkMap(net.minecraft.server.management.PlayerChunkMap) Predicate(com.google.common.base.Predicate)

Example 3 with ChunkProviderServer

use of net.minecraft.world.gen.ChunkProviderServer in project RFToolsDimensions by McJty.

the class RfToolsDimensionManager method touchSpawnChunk.

private void touchSpawnChunk(World world, int id) {
    // Make sure world generation kicks in for at least one chunk so that our matter receiver
    // is generated and registered.
    WorldServer worldServerForDimension = world.getMinecraftServer().getWorld(id);
    ChunkProviderServer providerServer = worldServerForDimension.getChunkProvider();
    if (!providerServer.chunkExists(0, 0)) {
        try {
            providerServer.provideChunk(0, 0);
            providerServer.chunkGenerator.populate(0, 0);
        } catch (Exception e) {
            Logging.logError("Something went wrong during creation of the dimension!");
            e.printStackTrace();
        // We catch this exception to make sure our dimension tab is at least ok.
        }
    }
}
Also used : ChunkProviderServer(net.minecraft.world.gen.ChunkProviderServer) WorldServer(net.minecraft.world.WorldServer)

Example 4 with ChunkProviderServer

use of net.minecraft.world.gen.ChunkProviderServer in project SpongeCommon by SpongePowered.

the class MixinWorldServer method updateWorldGenerator.

@Override
public void updateWorldGenerator() {
    // Get the default generator for the world type
    DataContainer generatorSettings = this.getProperties().getGeneratorSettings();
    SpongeWorldGenerator newGenerator = createWorldGenerator(generatorSettings);
    // by the base generation populator
    if (newGenerator.getBaseGenerationPopulator() instanceof IChunkGenerator) {
        // from a mod chunk provider extending a provider that we mixed into
        if (WorldGenConstants.isValid((IChunkGenerator) newGenerator.getBaseGenerationPopulator(), IPopulatorProvider.class)) {
            ((IPopulatorProvider) newGenerator.getBaseGenerationPopulator()).addPopulators(newGenerator);
        }
    } else if (newGenerator.getBaseGenerationPopulator() instanceof IPopulatorProvider) {
        // If its not a chunk provider but is a populator provider then we call it as well
        ((IPopulatorProvider) newGenerator.getBaseGenerationPopulator()).addPopulators(newGenerator);
    }
    for (WorldGeneratorModifier modifier : this.getProperties().getGeneratorModifiers()) {
        modifier.modifyWorldGenerator(this.getProperties(), generatorSettings, newGenerator);
    }
    this.spongegen = createChunkGenerator(newGenerator);
    this.spongegen.setGenerationPopulators(newGenerator.getGenerationPopulators());
    this.spongegen.setPopulators(newGenerator.getPopulators());
    this.spongegen.setBiomeOverrides(newGenerator.getBiomeSettings());
    ChunkProviderServer chunkProviderServer = this.getChunkProvider();
    chunkProviderServer.chunkGenerator = this.spongegen;
}
Also used : DataContainer(org.spongepowered.api.data.DataContainer) WorldGeneratorModifier(org.spongepowered.api.world.gen.WorldGeneratorModifier) IChunkGenerator(net.minecraft.world.gen.IChunkGenerator) IPopulatorProvider(org.spongepowered.common.interfaces.world.gen.IPopulatorProvider) IMixinChunkProviderServer(org.spongepowered.common.interfaces.world.gen.IMixinChunkProviderServer) ChunkProviderServer(net.minecraft.world.gen.ChunkProviderServer) SpongeWorldGenerator(org.spongepowered.common.world.gen.SpongeWorldGenerator)

Example 5 with ChunkProviderServer

use of net.minecraft.world.gen.ChunkProviderServer in project SpongeCommon by SpongePowered.

the class MixinWorldServer method doChunkGC.

// Chunk GC
@Override
public void doChunkGC() {
    this.chunkGCTickCount++;
    ChunkProviderServer chunkProviderServer = this.getChunkProvider();
    int chunkLoadCount = this.getChunkProvider().getLoadedChunkCount();
    if (chunkLoadCount >= this.chunkGCLoadThreshold && this.chunkGCLoadThreshold > 0) {
        chunkLoadCount = 0;
    } else if (this.chunkGCTickCount >= this.chunkGCTickInterval && this.chunkGCTickInterval > 0) {
        this.chunkGCTickCount = 0;
    } else {
        return;
    }
    for (net.minecraft.world.chunk.Chunk chunk : chunkProviderServer.getLoadedChunks()) {
        IMixinChunk spongeChunk = (IMixinChunk) chunk;
        if (chunk.unloadQueued || spongeChunk.isPersistedChunk() || !this.provider.canDropChunk(chunk.x, chunk.z)) {
            continue;
        }
        // If a player is currently using the chunk, skip it
        if (((IMixinPlayerChunkMap) this.getPlayerChunkMap()).isChunkInUse(chunk.x, chunk.z)) {
            continue;
        }
        // If we reach this point the chunk leaked so queue for unload
        chunkProviderServer.queueUnload(chunk);
        SpongeHooks.logChunkGCQueueUnload(chunkProviderServer.world, chunk);
    }
}
Also used : IMixinChunk(org.spongepowered.common.interfaces.IMixinChunk) IMixinChunkProviderServer(org.spongepowered.common.interfaces.world.gen.IMixinChunkProviderServer) ChunkProviderServer(net.minecraft.world.gen.ChunkProviderServer) Chunk(net.minecraft.world.chunk.Chunk) IMixinPlayerChunkMap(org.spongepowered.common.interfaces.server.management.IMixinPlayerChunkMap)

Aggregations

ChunkProviderServer (net.minecraft.world.gen.ChunkProviderServer)18 WorldServer (net.minecraft.world.WorldServer)9 Chunk (net.minecraft.world.chunk.Chunk)7 ChunkPos (net.minecraft.util.math.ChunkPos)3 IHasMass (com.builtbroken.mc.api.IHasMass)2 Collection (java.util.Collection)2 Block (net.minecraft.block.Block)2 Entity (net.minecraft.entity.Entity)2 TileEntity (net.minecraft.tileentity.TileEntity)2 ChatComponentText (net.minecraft.util.ChatComponentText)2 World (net.minecraft.world.World)2 IChunkGenerator (net.minecraft.world.gen.IChunkGenerator)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 IMixinChunkProviderServer (org.spongepowered.common.interfaces.world.gen.IMixinChunkProviderServer)2 EntitySelector (com.builtbroken.mc.prefab.entity.selector.EntitySelector)1 Predicate (com.google.common.base.Predicate)1 BufferedImage (java.awt.image.BufferedImage)1 File (java.io.File)1 Random (java.util.Random)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1