Search in sources :

Example 1 with IProfiler

use of net.minecraft.profiler.IProfiler in project Arclight by IzzelAliz.

the class ServerChunkProviderMixin method func_217233_c.

/**
 * @author IzzelAliz
 * @reason
 */
@Overwrite
private CompletableFuture<Either<IChunk, ChunkHolder.IChunkLoadingError>> func_217233_c(int chunkX, int chunkZ, ChunkStatus requiredStatus, boolean load) {
    ChunkPos chunkpos = new ChunkPos(chunkX, chunkZ);
    long i = chunkpos.asLong();
    int j = 33 + ChunkStatus.getDistance(requiredStatus);
    ChunkHolder chunkholder = this.func_217213_a(i);
    boolean unloading = false;
    if (chunkholder != null) {
        ChunkHolder.LocationType chunkStatus = ChunkHolder.getLocationTypeFromLevel(((ChunkHolderBridge) chunkholder).bridge$getOldTicketLevel());
        ChunkHolder.LocationType currentStatus = ChunkHolder.getLocationTypeFromLevel(chunkholder.getChunkLevel());
        unloading = chunkStatus.isAtLeast(ChunkHolder.LocationType.BORDER) && !currentStatus.isAtLeast(ChunkHolder.LocationType.BORDER);
    }
    if (load && !unloading) {
        this.ticketManager.registerWithLevel(TicketType.UNKNOWN, chunkpos, j, chunkpos);
        if (this.func_217224_a(chunkholder, j)) {
            IProfiler iprofiler = this.world.getProfiler();
            iprofiler.startSection("chunkLoad");
            this.func_217235_l();
            chunkholder = this.func_217213_a(i);
            iprofiler.endSection();
            if (this.func_217224_a(chunkholder, j)) {
                throw new IllegalStateException("No chunk holder after ticket has been added");
            }
        }
    }
    return this.func_217224_a(chunkholder, j) ? ChunkHolder.MISSING_CHUNK_FUTURE : chunkholder.func_219276_a(requiredStatus, this.chunkManager);
}
Also used : IProfiler(net.minecraft.profiler.IProfiler) ChunkHolder(net.minecraft.world.server.ChunkHolder) ChunkPos(net.minecraft.util.math.ChunkPos) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 2 with IProfiler

use of net.minecraft.profiler.IProfiler in project Arclight by IzzelAliz.

the class RecipeManagerMixin method apply.

// @formatter:on
/**
 * @author IzzelAluz
 * @reason
 */
@Overwrite
@SuppressWarnings("unchecked")
protected void apply(Map<ResourceLocation, JsonObject> splashList, IResourceManager resourceManagerIn, IProfiler profilerIn) {
    this.someRecipesErrored = false;
    Map<IRecipeType<?>, Object2ObjectLinkedOpenHashMap<ResourceLocation, IRecipe<?>>> map = Maps.newHashMap();
    for (IRecipeType<?> type : Registry.RECIPE_TYPE) {
        map.put(type, new Object2ObjectLinkedOpenHashMap<>());
    }
    for (Map.Entry<ResourceLocation, JsonObject> entry : splashList.entrySet()) {
        ResourceLocation resourcelocation = entry.getKey();
        if (resourcelocation.getPath().startsWith("_"))
            // Forge: filter anything beginning with "_" as it's used for metadata.
            continue;
        try {
            if (!CraftingHelper.processConditions(entry.getValue(), "conditions")) {
                LOGGER.info("Skipping loading recipe {} as it's conditions were not met", resourcelocation);
                continue;
            }
            IRecipe<?> irecipe = deserializeRecipe(resourcelocation, entry.getValue());
            if (irecipe == null) {
                LOGGER.info("Skipping loading recipe {} as it's serializer returned null", resourcelocation);
                continue;
            }
            map.computeIfAbsent(irecipe.getType(), (p_223391_0_) -> new Object2ObjectLinkedOpenHashMap<>()).putAndMoveToFirst(resourcelocation, irecipe);
        } catch (IllegalArgumentException | JsonParseException jsonparseexception) {
            LOGGER.error("Parsing error loading recipe {}", resourcelocation, jsonparseexception);
        }
    }
    this.recipes = (Map) map;
    LOGGER.info("Loaded {} recipes", (int) map.size());
}
Also used : JsonParseException(com.google.gson.JsonParseException) JsonObject(com.google.gson.JsonObject) Util(net.minecraft.util.Util) IResourceManager(net.minecraft.resources.IResourceManager) HashMap(java.util.HashMap) Overwrite(org.spongepowered.asm.mixin.Overwrite) IRecipeType(net.minecraft.item.crafting.IRecipeType) RecipeManager(net.minecraft.item.crafting.RecipeManager) Mixin(org.spongepowered.asm.mixin.Mixin) Map(java.util.Map) IProfiler(net.minecraft.profiler.IProfiler) IRecipe(net.minecraft.item.crafting.IRecipe) IInventoryBridge(io.izzel.arclight.common.bridge.inventory.IInventoryBridge) ImmutableMap(com.google.common.collect.ImmutableMap) World(net.minecraft.world.World) RecipeManagerBridge(io.izzel.arclight.common.bridge.item.crafting.RecipeManagerBridge) Final(org.spongepowered.asm.mixin.Final) Maps(com.google.common.collect.Maps) Registry(net.minecraft.util.registry.Registry) Logger(org.apache.logging.log4j.Logger) Object2ObjectLinkedOpenHashMap(it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap) IInventory(net.minecraft.inventory.IInventory) ResourceLocation(net.minecraft.util.ResourceLocation) Shadow(org.spongepowered.asm.mixin.Shadow) Optional(java.util.Optional) CraftingHelper(net.minecraftforge.common.crafting.CraftingHelper) IRecipeType(net.minecraft.item.crafting.IRecipeType) JsonObject(com.google.gson.JsonObject) JsonParseException(com.google.gson.JsonParseException) ResourceLocation(net.minecraft.util.ResourceLocation) Object2ObjectLinkedOpenHashMap(it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap) HashMap(java.util.HashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Object2ObjectLinkedOpenHashMap(it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 3 with IProfiler

use of net.minecraft.profiler.IProfiler in project Mekanism by mekanism.

the class RenderTickHandler method onBlockHover.

@SubscribeEvent
public void onBlockHover(DrawHighlightEvent.HighlightBlock event) {
    PlayerEntity player = minecraft.player;
    if (player == null) {
        return;
    }
    BlockRayTraceResult rayTraceResult = event.getTarget();
    if (!rayTraceResult.getType().equals(Type.MISS)) {
        World world = player.getCommandSenderWorld();
        BlockPos pos = rayTraceResult.getBlockPos();
        IRenderTypeBuffer renderer = event.getBuffers();
        ActiveRenderInfo info = event.getInfo();
        MatrixStack matrix = event.getMatrix();
        IProfiler profiler = world.getProfiler();
        BlockState blockState = world.getBlockState(pos);
        boolean shouldCancel = false;
        profiler.push(ProfilerConstants.MEKANISM_OUTLINE);
        if (!blockState.isAir(world, pos) && world.getWorldBorder().isWithinBounds(pos)) {
            BlockPos actualPos = pos;
            BlockState actualState = blockState;
            if (blockState.getBlock() instanceof BlockBounding) {
                TileEntityBoundingBlock tile = WorldUtils.getTileEntity(TileEntityBoundingBlock.class, world, pos);
                if (tile != null) {
                    actualPos = tile.getMainPos();
                    actualState = world.getBlockState(actualPos);
                }
            }
            AttributeCustomSelectionBox customSelectionBox = Attribute.get(actualState, AttributeCustomSelectionBox.class);
            if (customSelectionBox != null) {
                WireFrameRenderer renderWireFrame = null;
                if (customSelectionBox.isJavaModel()) {
                    // If we use a TER to render the wire frame, grab the tile
                    TileEntity tile = WorldUtils.getTileEntity(world, actualPos);
                    if (tile != null) {
                        TileEntityRenderer<TileEntity> tileRenderer = TileEntityRendererDispatcher.instance.getRenderer(tile);
                        if (tileRenderer instanceof IWireFrameRenderer) {
                            IWireFrameRenderer wireFrameRenderer = (IWireFrameRenderer) tileRenderer;
                            if (wireFrameRenderer.hasSelectionBox(actualState)) {
                                renderWireFrame = (buffer, matrixStack, state, red, green, blue, alpha) -> {
                                    if (wireFrameRenderer.isCombined()) {
                                        renderQuadsWireFrame(state, buffer, matrixStack.last().pose(), world.random, red, green, blue, alpha);
                                    }
                                    wireFrameRenderer.renderWireFrame(tile, event.getPartialTicks(), matrixStack, buffer, red, green, blue, alpha);
                                };
                            }
                        }
                    }
                } else {
                    // Otherwise, skip getting the tile and just grab the model
                    renderWireFrame = (buffer, matrixStack, state, red, green, blue, alpha) -> renderQuadsWireFrame(state, buffer, matrixStack.last().pose(), world.random, red, green, blue, alpha);
                }
                if (renderWireFrame != null) {
                    matrix.pushPose();
                    Vector3d viewPosition = info.getPosition();
                    matrix.translate(actualPos.getX() - viewPosition.x, actualPos.getY() - viewPosition.y, actualPos.getZ() - viewPosition.z);
                    renderWireFrame.render(renderer.getBuffer(RenderType.lines()), matrix, actualState, 0, 0, 0, 0.4F);
                    matrix.popPose();
                    shouldCancel = true;
                }
            }
        }
        profiler.pop();
        ItemStack stack = player.getMainHandItem();
        if (stack.isEmpty() || !(stack.getItem() instanceof ItemConfigurator)) {
            // If we are not holding a configurator, look if we are in the offhand
            stack = player.getOffhandItem();
            if (stack.isEmpty() || !(stack.getItem() instanceof ItemConfigurator)) {
                if (shouldCancel) {
                    event.setCanceled(true);
                }
                return;
            }
        }
        profiler.push(ProfilerConstants.CONFIGURABLE_MACHINE);
        ConfiguratorMode state = ((ItemConfigurator) stack.getItem()).getMode(stack);
        if (state.isConfigurating()) {
            TransmissionType type = Objects.requireNonNull(state.getTransmission(), "Configurating state requires transmission type");
            TileEntity tile = WorldUtils.getTileEntity(world, pos);
            if (tile instanceof ISideConfiguration) {
                ISideConfiguration configurable = (ISideConfiguration) tile;
                TileComponentConfig config = configurable.getConfig();
                if (config.supports(type)) {
                    Direction face = rayTraceResult.getDirection();
                    DataType dataType = config.getDataType(type, RelativeSide.fromDirections(configurable.getDirection(), face));
                    if (dataType != null) {
                        Vector3d viewPosition = info.getPosition();
                        matrix.pushPose();
                        matrix.translate(pos.getX() - viewPosition.x, pos.getY() - viewPosition.y, pos.getZ() - viewPosition.z);
                        MekanismRenderer.renderObject(getOverlayModel(face, type), matrix, renderer.getBuffer(Atlases.translucentCullBlockSheet()), MekanismRenderer.getColorARGB(dataType.getColor(), 0.6F), MekanismRenderer.FULL_LIGHT, OverlayTexture.NO_OVERLAY, FaceDisplay.FRONT);
                        matrix.popPose();
                    }
                }
            }
        }
        profiler.pop();
        if (shouldCancel) {
            event.setCanceled(true);
        }
    }
}
Also used : AttributeCustomSelectionBox(mekanism.common.block.attribute.AttributeCustomSelectionBox) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) World(net.minecraft.world.World) TileComponentConfig(mekanism.common.tile.component.TileComponentConfig) Direction(net.minecraft.util.Direction) AbstractClientPlayerEntity(net.minecraft.client.entity.player.AbstractClientPlayerEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) TileEntityBoundingBlock(mekanism.common.tile.TileEntityBoundingBlock) TileEntity(net.minecraft.tileentity.TileEntity) IRenderTypeBuffer(net.minecraft.client.renderer.IRenderTypeBuffer) IWireFrameRenderer(mekanism.client.render.tileentity.IWireFrameRenderer) IWireFrameRenderer(mekanism.client.render.tileentity.IWireFrameRenderer) BlockBounding(mekanism.common.block.BlockBounding) DataType(mekanism.common.tile.component.config.DataType) BlockPos(net.minecraft.util.math.BlockPos) ActiveRenderInfo(net.minecraft.client.renderer.ActiveRenderInfo) ISideConfiguration(mekanism.common.tile.interfaces.ISideConfiguration) ItemConfigurator(mekanism.common.item.ItemConfigurator) BlockRayTraceResult(net.minecraft.util.math.BlockRayTraceResult) ConfiguratorMode(mekanism.common.item.ItemConfigurator.ConfiguratorMode) IProfiler(net.minecraft.profiler.IProfiler) BlockState(net.minecraft.block.BlockState) Vector3d(net.minecraft.util.math.vector.Vector3d) TransmissionType(mekanism.common.lib.transmitter.TransmissionType) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 4 with IProfiler

use of net.minecraft.profiler.IProfiler in project minecolonies by ldtteam.

the class TextureReloadListener method prepare.

@NotNull
@Override
protected TexturePacks prepare(@NotNull final IResourceManager manager, @NotNull final IProfiler profiler) {
    final Set<String> set = new HashSet<>();
    final List<ResourceLocation> resLocs = new ArrayList<>(manager.listResources("textures/entity/citizen", f -> true));
    for (final ResourceLocation res : resLocs) {
        if (!res.getPath().contains("png")) {
            final String folder = res.getPath().replace("textures/entity/citizen", "").replace("/", "");
            if (!folder.isEmpty()) {
                set.add(folder);
            }
        }
    }
    final TexturePacks packs = new TexturePacks();
    packs.packs = new ArrayList<>(set);
    return packs;
}
Also used : IProfiler(net.minecraft.profiler.IProfiler) ReloadListener(net.minecraft.client.resources.ReloadListener) IResourceManager(net.minecraft.resources.IResourceManager) FMLConstructModEvent(net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent) Set(java.util.Set) Log(com.ldtteam.blockout.Log) Dist(net.minecraftforge.api.distmarker.Dist) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) List(java.util.List) MOD(net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD) Minecraft(net.minecraft.client.Minecraft) SimpleReloadableResourceManager(net.minecraft.resources.SimpleReloadableResourceManager) ResourceLocation(net.minecraft.util.ResourceLocation) Mod(net.minecraftforge.fml.common.Mod) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent) NotNull(org.jetbrains.annotations.NotNull) Constants(com.minecolonies.api.util.constant.Constants) ResourceLocation(net.minecraft.util.ResourceLocation) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with IProfiler

use of net.minecraft.profiler.IProfiler in project minecolonies by Minecolonies.

the class TextureReloadListener method prepare.

@NotNull
@Override
protected TexturePacks prepare(@NotNull final IResourceManager manager, @NotNull final IProfiler profiler) {
    final Set<String> set = new HashSet<>();
    final List<ResourceLocation> resLocs = new ArrayList<>(manager.listResources("textures/entity/citizen", f -> true));
    for (final ResourceLocation res : resLocs) {
        if (!res.getPath().contains("png")) {
            final String folder = res.getPath().replace("textures/entity/citizen", "").replace("/", "");
            if (!folder.isEmpty()) {
                set.add(folder);
            }
        }
    }
    final TexturePacks packs = new TexturePacks();
    packs.packs = new ArrayList<>(set);
    return packs;
}
Also used : IProfiler(net.minecraft.profiler.IProfiler) ReloadListener(net.minecraft.client.resources.ReloadListener) IResourceManager(net.minecraft.resources.IResourceManager) FMLConstructModEvent(net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent) Set(java.util.Set) Log(com.ldtteam.blockout.Log) Dist(net.minecraftforge.api.distmarker.Dist) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) List(java.util.List) MOD(net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD) Minecraft(net.minecraft.client.Minecraft) SimpleReloadableResourceManager(net.minecraft.resources.SimpleReloadableResourceManager) ResourceLocation(net.minecraft.util.ResourceLocation) Mod(net.minecraftforge.fml.common.Mod) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent) NotNull(org.jetbrains.annotations.NotNull) Constants(com.minecolonies.api.util.constant.Constants) ResourceLocation(net.minecraft.util.ResourceLocation) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

IProfiler (net.minecraft.profiler.IProfiler)6 IResourceManager (net.minecraft.resources.IResourceManager)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)3 Log (com.ldtteam.blockout.Log)2 Constants (com.minecolonies.api.util.constant.Constants)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Set (java.util.Set)2 Minecraft (net.minecraft.client.Minecraft)2 ReloadListener (net.minecraft.client.resources.ReloadListener)2 World (net.minecraft.world.World)2 Overwrite (org.spongepowered.asm.mixin.Overwrite)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Maps (com.google.common.collect.Maps)1 JsonObject (com.google.gson.JsonObject)1 JsonParseException (com.google.gson.JsonParseException)1 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 IInventoryBridge (io.izzel.arclight.common.bridge.inventory.IInventoryBridge)1