Search in sources :

Example 6 with ProfilerFiller

use of net.minecraft.util.profiling.ProfilerFiller in project pollen by MoonflowerTeam.

the class LocalTextureTableLoader method reload.

@Override
public CompletableFuture<Void> reload(PreparableReloadListener.PreparationBarrier stage, ResourceManager resourceManager, ProfilerFiller preparationsProfiler, ProfilerFiller reloadProfiler, Executor backgroundExecutor, Executor gameExecutor) {
    return CompletableFuture.supplyAsync(() -> {
        Map<ResourceLocation, GeometryModelTextureTable> textureLocations = new HashMap<>();
        for (ResourceLocation textureTableLocation : resourceManager.listResources(this.folder, name -> name.endsWith(".json"))) {
            ResourceLocation textureTableName = new ResourceLocation(textureTableLocation.getNamespace(), textureTableLocation.getPath().substring(this.folder.length(), textureTableLocation.getPath().length() - 5));
            if (textureTableName.getPath().equals("hash_tables"))
                continue;
            try (Resource resource = resourceManager.getResource(textureTableLocation)) {
                textureLocations.put(textureTableName, GeometryModelParser.parseTextures(new InputStreamReader(resource.getInputStream())));
            } catch (Exception e) {
                LOGGER.error("Failed to load texture table '" + textureTableName + "'", e);
            }
        }
        LOGGER.info("Loaded " + textureLocations.size() + " model texture tables.");
        return textureLocations;
    }, backgroundExecutor).thenAcceptBothAsync(CompletableFuture.supplyAsync(() -> {
        Set<String> hashTables = new HashSet<>();
        for (String domain : resourceManager.getNamespaces()) {
            ResourceLocation hashTableLocation = new ResourceLocation(domain, this.folder + "hash_tables.json");
            if (!resourceManager.hasResource(hashTableLocation))
                continue;
            try (Resource resource = resourceManager.getResource(hashTableLocation)) {
                hashTables.addAll(Arrays.asList(GSON.fromJson(new InputStreamReader(resource.getInputStream()), String[].class)));
            } catch (Exception e) {
                LOGGER.error("Failed to load texture hash table for " + domain, e);
            }
        }
        LOGGER.info("Loaded " + hashTables.size() + " hash tables.");
        return hashTables.toArray(new String[0]);
    }, backgroundExecutor), (textureLocations, hashTables) -> {
        this.textures.clear();
        this.textures.putAll(textureLocations);
        this.hashTables = hashTables;
    }, gameExecutor).thenCompose(stage::wait);
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) Resource(net.minecraft.server.packs.resources.Resource) java.util(java.util) ProfilerFiller(net.minecraft.util.profiling.ProfilerFiller) Executor(java.util.concurrent.Executor) ResourceManager(net.minecraft.server.packs.resources.ResourceManager) CompletableFuture(java.util.concurrent.CompletableFuture) InputStreamReader(java.io.InputStreamReader) GeometryModelParser(gg.moonflower.pollen.pinwheel.api.common.geometry.GeometryModelParser) Consumer(java.util.function.Consumer) Nullable(org.jetbrains.annotations.Nullable) TextureTableLoader(gg.moonflower.pollen.pinwheel.api.client.texture.TextureTableLoader) Logger(org.apache.logging.log4j.Logger) Gson(com.google.gson.Gson) BiConsumer(java.util.function.BiConsumer) PreparableReloadListener(net.minecraft.server.packs.resources.PreparableReloadListener) GeometryModelTextureTable(gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTextureTable) LogManager(org.apache.logging.log4j.LogManager) ApiStatus(org.jetbrains.annotations.ApiStatus) InputStreamReader(java.io.InputStreamReader) ResourceLocation(net.minecraft.resources.ResourceLocation) Resource(net.minecraft.server.packs.resources.Resource) GeometryModelTextureTable(gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTextureTable)

Example 7 with ProfilerFiller

use of net.minecraft.util.profiling.ProfilerFiller in project pollen by MoonflowerTeam.

the class EntitlementManager method init.

public static void init() {
    AddRenderLayersEvent.EVENT.register(context -> {
        for (String skin : context.getSkins()) {
            PlayerRenderer renderer = context.getSkin(skin);
            if (renderer != null)
                renderer.addLayer(new PollenCosmeticLayer<>(context.getSkin(skin)));
        }
    });
    ResourceRegistry.registerReloadListener(PackType.CLIENT_RESOURCES, new PollinatedPreparableReloadListener() {

        @Override
        public ResourceLocation getPollenId() {
            return new ResourceLocation(Pollen.MOD_ID, "entitlements");
        }

        @Override
        public CompletableFuture<Void> reload(PreparationBarrier stage, ResourceManager resourceManager, ProfilerFiller preparationsProfiler, ProfilerFiller reloadProfiler, Executor backgroundExecutor, Executor gameExecutor) {
            return EntitlementManager.reload(false, stage, gameExecutor);
        }
    });
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) Executor(java.util.concurrent.Executor) ResourceLocation(net.minecraft.resources.ResourceLocation) PlayerRenderer(net.minecraft.client.renderer.entity.player.PlayerRenderer) PollinatedPreparableReloadListener(gg.moonflower.pollen.api.registry.resource.PollinatedPreparableReloadListener) ResourceManager(net.minecraft.server.packs.resources.ResourceManager) PollenCosmeticLayer(gg.moonflower.pollen.core.client.render.layer.PollenCosmeticLayer) ProfilerFiller(net.minecraft.util.profiling.ProfilerFiller)

Example 8 with ProfilerFiller

use of net.minecraft.util.profiling.ProfilerFiller in project architectury-api by architectury.

the class MixinClientLevel method tickEntitiesPost.

@Inject(method = "tickEntities", at = @At("RETURN"))
private void tickEntitiesPost(CallbackInfo ci) {
    ProfilerFiller profiler = getProfiler();
    profiler.push("architecturyClientLevelPostTick");
    ClientTickEvent.CLIENT_LEVEL_POST.invoker().tick((ClientLevel) (Object) this);
    profiler.pop();
}
Also used : ProfilerFiller(net.minecraft.util.profiling.ProfilerFiller) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 9 with ProfilerFiller

use of net.minecraft.util.profiling.ProfilerFiller in project architectury-api by architectury.

the class ReloadListenerRegistryImpl method register.

public static void register(PackType type, PreparableReloadListener listener) {
    var bytes = new byte[8];
    RANDOM.nextBytes(bytes);
    var id = new ResourceLocation("architectury:reload_" + StringUtils.leftPad(Math.abs(Longs.fromByteArray(bytes)) + "", 19, '0'));
    ResourceManagerHelper.get(type).registerReloadListener(new IdentifiableResourceReloadListener() {

        @Override
        public ResourceLocation getFabricId() {
            return id;
        }

        @Override
        public String getName() {
            return listener.getName();
        }

        @Override
        public CompletableFuture<Void> reload(PreparationBarrier preparationBarrier, ResourceManager resourceManager, ProfilerFiller profilerFiller, ProfilerFiller profilerFiller2, Executor executor, Executor executor2) {
            return listener.reload(preparationBarrier, resourceManager, profilerFiller, profilerFiller2, executor, executor2);
        }
    });
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) Executor(java.util.concurrent.Executor) ResourceLocation(net.minecraft.resources.ResourceLocation) IdentifiableResourceReloadListener(net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener) ResourceManager(net.minecraft.server.packs.resources.ResourceManager) ProfilerFiller(net.minecraft.util.profiling.ProfilerFiller)

Example 10 with ProfilerFiller

use of net.minecraft.util.profiling.ProfilerFiller in project fabric-carpet by gnembon.

the class Level_movableBEMixin method setBlockStateWithBlockEntity.

/**
 * @author 2No2Name
 */
public boolean setBlockStateWithBlockEntity(BlockPos blockPos_1, BlockState blockState_1, BlockEntity newBlockEntity, int int_1) {
    if (isOutsideBuildHeight(blockPos_1) || !this.isClientSide && isDebug())
        return false;
    LevelChunk worldChunk_1 = this.getChunkAt(blockPos_1);
    Block block_1 = blockState_1.getBlock();
    BlockState blockState_2;
    if (newBlockEntity != null && block_1 instanceof EntityBlock) {
        blockState_2 = ((WorldChunkInterface) worldChunk_1).setBlockStateWithBlockEntity(blockPos_1, blockState_1, newBlockEntity, (int_1 & 64) != 0);
        if (newBlockEntity instanceof LidBlockEntity) {
            scheduleTick(blockPos_1, block_1, 5);
        }
    } else {
        blockState_2 = worldChunk_1.setBlockState(blockPos_1, blockState_1, (int_1 & 64) != 0);
    }
    if (blockState_2 == null) {
        return false;
    } else {
        BlockState blockState_3 = this.getBlockState(blockPos_1);
        if (blockState_3 != blockState_2 && (blockState_3.getLightBlock((BlockGetter) this, blockPos_1) != blockState_2.getLightBlock((BlockGetter) this, blockPos_1) || blockState_3.getLightEmission() != blockState_2.getLightEmission() || blockState_3.useShapeForLightOcclusion() || blockState_2.useShapeForLightOcclusion())) {
            ProfilerFiller profiler = getProfiler();
            profiler.push("queueCheckLight");
            this.getChunkSource().getLightEngine().checkBlock(blockPos_1);
            profiler.pop();
        }
        if (blockState_3 == blockState_1) {
            if (blockState_2 != blockState_3) {
                this.setBlocksDirty(blockPos_1, blockState_2, blockState_3);
            }
            if ((int_1 & 2) != 0 && (!this.isClientSide || (int_1 & 4) == 0) && (this.isClientSide || worldChunk_1.getFullStatus() != null && worldChunk_1.getFullStatus().isOrAfter(ChunkHolder.FullChunkStatus.TICKING))) {
                this.sendBlockUpdated(blockPos_1, blockState_2, blockState_1, int_1);
            }
            if (!this.isClientSide && (int_1 & 1) != 0) {
                this.updateNeighborsAt(blockPos_1, blockState_2.getBlock());
                if (blockState_1.hasAnalogOutputSignal()) {
                    updateNeighbourForOutputSignal(blockPos_1, block_1);
                }
            }
            if ((int_1 & 16) == 0) {
                int int_2 = int_1 & -34;
                // prepare
                blockState_2.updateIndirectNeighbourShapes(this, blockPos_1, int_2);
                // updateNeighbours
                blockState_1.updateNeighbourShapes(this, blockPos_1, int_2);
                // prepare
                blockState_1.updateIndirectNeighbourShapes(this, blockPos_1, int_2);
            }
            this.onBlockStateChange(blockPos_1, blockState_2, blockState_3);
        }
        return true;
    }
}
Also used : LidBlockEntity(net.minecraft.world.level.block.entity.LidBlockEntity) LevelChunk(net.minecraft.world.level.chunk.LevelChunk) BlockState(net.minecraft.world.level.block.state.BlockState) EntityBlock(net.minecraft.world.level.block.EntityBlock) EntityBlock(net.minecraft.world.level.block.EntityBlock) Block(net.minecraft.world.level.block.Block) ProfilerFiller(net.minecraft.util.profiling.ProfilerFiller)

Aggregations

ProfilerFiller (net.minecraft.util.profiling.ProfilerFiller)10 ResourceLocation (net.minecraft.resources.ResourceLocation)5 ResourceManager (net.minecraft.server.packs.resources.ResourceManager)5 CompletableFuture (java.util.concurrent.CompletableFuture)3 Executor (java.util.concurrent.Executor)3 Gson (com.google.gson.Gson)2 GeometryModelTextureTable (gg.moonflower.pollen.pinwheel.api.common.texture.GeometryModelTextureTable)2 java.util (java.util)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Minecraft (net.minecraft.client.Minecraft)2 Stopwatch (com.google.common.base.Stopwatch)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 JsonParseException (com.google.gson.JsonParseException)1 BufferBuilder (com.mojang.blaze3d.vertex.BufferBuilder)1 VertexConsumer (com.mojang.blaze3d.vertex.VertexConsumer)1 Blueprint (com.teamabnormals.blueprint.core.Blueprint)1 DataUtil (com.teamabnormals.blueprint.core.util.DataUtil)1 ConfiguredModifier (com.teamabnormals.blueprint.core.util.modification.ConfiguredModifier)1