Search in sources :

Example 1 with Object2ObjectLinkedOpenHashMap

use of it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap 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 2 with Object2ObjectLinkedOpenHashMap

use of it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap in project Rikaishi-Nikui by zhuaidadaya.

the class MinecraftVersionInformation method getVmOptions.

public Object2ObjectLinkedOpenHashMap<String, VmOption> getVmOptions(String search) {
    String filter = search.toLowerCase();
    Object2ObjectLinkedOpenHashMap<String, VmOption> options = new Object2ObjectLinkedOpenHashMap<>();
    for (VmOption option : vmOptions.values()) {
        if (option.getDetail().equals("")) {
            continue;
        }
        if (option.getDetail().toLowerCase().contains(filter) || textFormatter.getText(option.getDescription()).contains(filter) || (textFormatter.getText("vm.options.information.enable").contains(filter) & option.isEnable())) {
            options.put(option.getId(), option);
        }
    }
    return options;
}
Also used : VmOption(com.github.zhuaidadaya.rikaishinikui.handler.option.vm.VmOption) Object2ObjectLinkedOpenHashMap(it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap)

Example 3 with Object2ObjectLinkedOpenHashMap

use of it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap in project Denizen-For-Bukkit by DenizenScript.

the class ItemHelperImpl method removeRecipe.

@Override
public void removeRecipe(NamespacedKey key) {
    ResourceLocation nmsKey = CraftNamespacedKey.toMinecraft(key);
    RecipeManager recipeManager = ((CraftServer) Bukkit.getServer()).getServer().getRecipeManager();
    try {
        Map<ResourceLocation, net.minecraft.world.item.crafting.Recipe<?>> byName = (Map) RECIPE_MANAGER_BY_NAME.get(recipeManager);
        byName.remove(nmsKey);
    } catch (Throwable ex) {
        Debug.echoError(ex);
    }
    for (Object2ObjectLinkedOpenHashMap<ResourceLocation, net.minecraft.world.item.crafting.Recipe<?>> recipeMap : recipeManager.recipes.values()) {
        recipeMap.remove(nmsKey);
    }
}
Also used : Recipe(org.bukkit.inventory.Recipe) ShapedRecipe(org.bukkit.inventory.ShapedRecipe) ResourceLocation(net.minecraft.resources.ResourceLocation) Object2ObjectLinkedOpenHashMap(it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap)

Example 4 with Object2ObjectLinkedOpenHashMap

use of it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap in project Denizen by DenizenScript.

the class ItemHelperImpl method removeRecipe.

@Override
public void removeRecipe(NamespacedKey key) {
    ResourceLocation nmsKey = CraftNamespacedKey.toMinecraft(key);
    RecipeManager recipeManager = ((CraftServer) Bukkit.getServer()).getServer().getRecipeManager();
    try {
        Map<ResourceLocation, net.minecraft.world.item.crafting.Recipe<?>> byName = (Map) RECIPE_MANAGER_BY_NAME.get(recipeManager);
        byName.remove(nmsKey);
    } catch (Throwable ex) {
        Debug.echoError(ex);
    }
    for (Object2ObjectLinkedOpenHashMap<ResourceLocation, net.minecraft.world.item.crafting.Recipe<?>> recipeMap : recipeManager.recipes.values()) {
        recipeMap.remove(nmsKey);
    }
}
Also used : Recipe(org.bukkit.inventory.Recipe) ShapedRecipe(org.bukkit.inventory.ShapedRecipe) ResourceLocation(net.minecraft.resources.ResourceLocation) CraftAttributeMap(org.bukkit.craftbukkit.v1_18_R2.attribute.CraftAttributeMap) Object2ObjectLinkedOpenHashMap(it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap)

Example 5 with Object2ObjectLinkedOpenHashMap

use of it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap in project polymer-core by teampolymer.

the class GhostBlockUtils method initBuffers.

private static IRenderTypeBuffer.Impl initBuffers(IRenderTypeBuffer.Impl original, Supplier<Float> alphaSupplier) {
    BufferBuilder fallback = ObfuscationReflectionHelper.getPrivateValue(IRenderTypeBuffer.Impl.class, original, "builder");
    Map<RenderType, BufferBuilder> layerBuffers = ObfuscationReflectionHelper.getPrivateValue(IRenderTypeBuffer.Impl.class, original, "fixedBuffers");
    Map<RenderType, BufferBuilder> remapped = new Object2ObjectLinkedOpenHashMap<>();
    Map<RenderType, RenderType> remappedTypes = new IdentityHashMap<>();
    for (Map.Entry<RenderType, BufferBuilder> e : layerBuffers.entrySet()) {
        remapped.put(GhostRenderType.remap(remappedTypes, e.getKey(), alphaSupplier), e.getValue());
    }
    return new GhostBuffers(fallback, remapped, remappedTypes, alphaSupplier);
}
Also used : BufferBuilder(net.minecraft.client.renderer.BufferBuilder) IRenderTypeBuffer(net.minecraft.client.renderer.IRenderTypeBuffer) IdentityHashMap(java.util.IdentityHashMap) Object2ObjectLinkedOpenHashMap(it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap) IdentityHashMap(java.util.IdentityHashMap) Object2ObjectLinkedOpenHashMap(it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap) Map(java.util.Map) RenderType(net.minecraft.client.renderer.RenderType)

Aggregations

Object2ObjectLinkedOpenHashMap (it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap)5 Map (java.util.Map)2 ResourceLocation (net.minecraft.resources.ResourceLocation)2 Recipe (org.bukkit.inventory.Recipe)2 ShapedRecipe (org.bukkit.inventory.ShapedRecipe)2 VmOption (com.github.zhuaidadaya.rikaishinikui.handler.option.vm.VmOption)1 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 IInventoryBridge (io.izzel.arclight.common.bridge.inventory.IInventoryBridge)1 RecipeManagerBridge (io.izzel.arclight.common.bridge.item.crafting.RecipeManagerBridge)1 HashMap (java.util.HashMap)1 IdentityHashMap (java.util.IdentityHashMap)1 Optional (java.util.Optional)1 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)1 IRenderTypeBuffer (net.minecraft.client.renderer.IRenderTypeBuffer)1 RenderType (net.minecraft.client.renderer.RenderType)1 IInventory (net.minecraft.inventory.IInventory)1 IRecipe (net.minecraft.item.crafting.IRecipe)1