Files
CatServer/patches/net/minecraftforge/oredict/OreDictionary.java.patch
2018-07-15 13:26:53 +08:00

76 lines
3.1 KiB
Diff

--- ../src-base/minecraft/net/minecraftforge/oredict/OreDictionary.java
+++ ../src-work/minecraft/net/minecraftforge/oredict/OreDictionary.java
@@ -19,13 +19,7 @@
package net.minecraftforge.oredict;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import net.minecraft.block.BlockPrismarine;
import net.minecraft.util.ResourceLocation;
@@ -352,7 +346,7 @@
{
ShapedRecipes recipe = (ShapedRecipes)obj;
ItemStack output = recipe.getRecipeOutput();
- if (output != null && containsMatch(false, exclusions, output))
+ if (output != null && containsMatch(false, exclusions, output) || output == null)
{
continue;
}
@@ -367,7 +361,7 @@
{
ShapelessRecipes recipe = (ShapelessRecipes)obj;
ItemStack output = recipe.getRecipeOutput();
- if (output != null && containsMatch(false, exclusions, output))
+ if (output != null && containsMatch(false, exclusions, output) || output == null)
{
continue;
}
@@ -433,8 +427,8 @@
{
if (stack == null || stack.getItem() == null) throw new IllegalArgumentException("Stack can not be null!");
- Set<Integer> set = new HashSet<Integer>();
+
// HACK: use the registry name's ID. It is unique and it knows about substitutions. Fallback to a -1 value (what Item.getIDForItem would have returned) in the case where the registry is not aware of the item yet
// IT should be noted that -1 will fail the gate further down, if an entry already exists with value -1 for this name. This is what is broken and being warned about.
// APPARENTLY it's quite common to do this. OreDictionary should be considered alongside Recipes - you can't make them properly until you've registered with the game.
@@ -449,15 +443,22 @@
{
id = GameData.getItemRegistry().getId(registryName);
}
+ Set<Integer> set;
+ int count = 0;
List<Integer> ids = stackToId.get(id);
- if (ids != null) set.addAll(ids);
- ids = stackToId.get(id | ((stack.getItemDamage() + 1) << 16));
- if (ids != null) set.addAll(ids);
+ if (ids != null) count += ids.size();
+ List<Integer> ids2 = stackToId.get(id | ((stack.getItemDamage() + 1) << 16));
+ if (ids2 != null) count += ids2.size();
+ set = new HashSet<Integer>(count);
- Integer[] tmp = set.toArray(new Integer[set.size()]);
- int[] ret = new int[tmp.length];
- for (int x = 0; x < tmp.length; x++)
- ret[x] = tmp[x];
+ boolean fal = ids != null ? set.addAll(ids): false;
+ fal = ids2 != null ? set.addAll(ids2) : false;
+ int[] ret = new int[count];
+ count = 0;
+ for(Iterator<Integer> it = set.iterator(); it.hasNext();)
+ {
+ ret[count++] = it.next();
+ }
return ret;
}