Search in sources :

Example 1 with PortableQIODashboardContainer

use of mekanism.common.inventory.container.item.PortableQIODashboardContainer in project Mekanism by mekanism.

the class CommonWorldTickHandler method tickEnd.

private void tickEnd(ServerWorld world) {
    if (!world.isClientSide) {
        RadiationManager.INSTANCE.tickServerWorld(world);
        if (flushTagAndRecipeCaches) {
            // Loop all open containers and if it is a portable qio dashboard force refresh the window's recipes
            for (ServerPlayerEntity player : world.players()) {
                if (player.containerMenu instanceof PortableQIODashboardContainer) {
                    PortableQIODashboardContainer qioDashboard = (PortableQIODashboardContainer) player.containerMenu;
                    for (byte index = 0; index < IQIOCraftingWindowHolder.MAX_CRAFTING_WINDOWS; index++) {
                        qioDashboard.getCraftingWindow(index).invalidateRecipe();
                    }
                }
            }
            flushTagAndRecipeCaches = false;
        }
        if (chunkRegenMap == null || !MekanismConfig.world.enableRegeneration.get()) {
            return;
        }
        ResourceLocation dimensionName = world.dimension().location();
        // Credit to E. Beef
        if (chunkRegenMap.containsKey(dimensionName)) {
            Queue<ChunkPos> chunksToGen = chunkRegenMap.get(dimensionName);
            long startTime = System.nanoTime();
            while (System.nanoTime() - startTime < maximumDeltaTimeNanoSecs && !chunksToGen.isEmpty()) {
                ChunkPos nextChunk = chunksToGen.poll();
                if (nextChunk == null) {
                    break;
                }
                Random fmlRandom = new Random(world.getSeed());
                long xSeed = fmlRandom.nextLong() >> 2 + 1L;
                long zSeed = fmlRandom.nextLong() >> 2 + 1L;
                fmlRandom.setSeed((xSeed * nextChunk.x + zSeed * nextChunk.z) ^ world.getSeed());
                if (GenHandler.generate(world, fmlRandom, nextChunk.x, nextChunk.z)) {
                    Mekanism.logger.info("Regenerating ores at chunk {}", nextChunk);
                }
            }
            if (chunksToGen.isEmpty()) {
                chunkRegenMap.remove(dimensionName);
            }
        }
    }
}
Also used : PortableQIODashboardContainer(mekanism.common.inventory.container.item.PortableQIODashboardContainer) Random(java.util.Random) ResourceLocation(net.minecraft.util.ResourceLocation) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) ChunkPos(net.minecraft.util.math.ChunkPos)

Aggregations

Random (java.util.Random)1 PortableQIODashboardContainer (mekanism.common.inventory.container.item.PortableQIODashboardContainer)1 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 ChunkPos (net.minecraft.util.math.ChunkPos)1