Skip to content

Commit 9fc88a3

Browse files
Cleanup item/crafting
1 parent 20e0db6 commit 9fc88a3

15 files changed

+126
-1483
lines changed

patches/minecraft/net/minecraft/item/crafting/CraftingManager.java.patch

Lines changed: 3 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
--- before/net/minecraft/item/crafting/CraftingManager.java
22
+++ after/net/minecraft/item/crafting/CraftingManager.java
3-
@@ -6,6 +6,7 @@
4-
import com.google.gson.JsonParseException;
5-
import com.google.gson.JsonSyntaxException;
6-
import java.io.BufferedReader;
7-
+import java.io.Closeable;
8-
import java.io.IOException;
9-
import java.io.Reader;
10-
import java.net.URI;
11-
@@ -35,7 +36,7 @@
3+
@@ -35,7 +35,7 @@
124
{
135
private static final Logger LOGGER = LogManager.getLogger();
146
private static int nextAvailableId;
@@ -17,111 +9,7 @@
179

1810
public static boolean init()
1911
{
20-
@@ -54,7 +55,7 @@
21-
register("shulkerboxcoloring", new ShulkerBoxRecipes.ShulkerBoxColoring());
22-
return parseJsonRecipes();
23-
}
24-
- catch (Throwable throwable)
25-
+ catch (Throwable var1)
26-
{
27-
return false;
28-
}
29-
@@ -63,18 +64,14 @@
30-
private static boolean parseJsonRecipes()
31-
{
32-
FileSystem filesystem = null;
33-
- Gson gson = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
34-
+ Gson gson = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create();
35-
+ boolean flag1;
36-
37-
try
38-
{
39-
URL url = CraftingManager.class.getResource("/assets/.mcassetsroot");
40-
41-
- if (url == null)
42-
- {
43-
- LOGGER.error("Couldn't find .mcassetsroot");
44-
- return false;
45-
- }
46-
- else
47-
+ if (url != null)
48-
{
49-
URI uri = url.toURI();
50-
Path path;
51-
@@ -88,7 +85,8 @@
52-
if (!"jar".equals(uri.getScheme()))
53-
{
54-
LOGGER.error("Unsupported scheme " + uri + " trying to list all recipes");
55-
- return false;
56-
+ boolean flag2 = false;
57-
+ return flag2;
58-
}
59-
60-
filesystem = FileSystems.newFileSystem(uri, Collections.emptyMap());
61-
@@ -110,18 +108,25 @@
62-
63-
try
64-
{
65-
- bufferedreader = Files.newBufferedReader(path1);
66-
- register(s, parseRecipeJson(JsonUtils.fromJson(gson, bufferedreader, JsonObject.class)));
67-
- }
68-
- catch (JsonParseException jsonparseexception)
69-
- {
70-
- LOGGER.error("Parsing error loading recipe " + resourcelocation, (Throwable)jsonparseexception);
71-
- return false;
72-
- }
73-
- catch (IOException ioexception)
74-
- {
75-
- LOGGER.error("Couldn't read recipe " + resourcelocation + " from " + path1, (Throwable)ioexception);
76-
- return false;
77-
+ boolean flag;
78-
+
79-
+ try
80-
+ {
81-
+ bufferedreader = Files.newBufferedReader(path1);
82-
+ register(s, parseRecipeJson((JsonObject)JsonUtils.fromJson(gson, bufferedreader, JsonObject.class)));
83-
+ }
84-
+ catch (JsonParseException jsonparseexception)
85-
+ {
86-
+ LOGGER.error("Parsing error loading recipe " + resourcelocation, (Throwable)jsonparseexception);
87-
+ flag = false;
88-
+ return flag;
89-
+ }
90-
+ catch (IOException ioexception)
91-
+ {
92-
+ LOGGER.error("Couldn't read recipe " + resourcelocation + " from " + path1, (Throwable)ioexception);
93-
+ flag = false;
94-
+ return flag;
95-
+ }
96-
}
97-
finally
98-
{
99-
@@ -132,16 +137,22 @@
100-
101-
return true;
102-
}
103-
+
104-
+ LOGGER.error("Couldn't find .mcassetsroot");
105-
+ flag1 = false;
106-
}
107-
catch (IOException | URISyntaxException urisyntaxexception)
108-
{
109-
LOGGER.error("Couldn't get a list of all recipe files", (Throwable)urisyntaxexception);
110-
- return false;
111-
+ flag1 = false;
112-
+ return flag1;
113-
}
114-
finally
115-
{
116-
- IOUtils.closeQuietly(filesystem);
117-
+ IOUtils.closeQuietly((Closeable)filesystem);
118-
}
119-
+
120-
+ return flag1;
121-
}
122-
123-
private static IRecipe parseRecipeJson(JsonObject json)
124-
@@ -162,12 +173,14 @@
12+
@@ -162,12 +162,14 @@
12513
}
12614
}
12715

@@ -138,19 +26,7 @@
13826
{
13927
if (REGISTRY.containsKey(name))
14028
{
141-
@@ -216,9 +229,9 @@
142-
}
143-
}
144-
145-
- NonNullList<ItemStack> nonnulllist = NonNullList.withSize(craftMatrix.getSizeInventory(), ItemStack.EMPTY);
146-
+ NonNullList<ItemStack> nonnulllist = NonNullList.<ItemStack>withSize(craftMatrix.getSizeInventory(), ItemStack.EMPTY);
147-
148-
- for (int i = 0; i < nonnulllist.size(); i++)
149-
+ for (int i = 0; i < nonnulllist.size(); ++i)
150-
{
151-
nonnulllist.set(i, craftMatrix.getStackInSlot(i));
152-
}
153-
@@ -232,11 +245,13 @@
29+
@@ -232,11 +234,13 @@
15430
return REGISTRY.getObject(name);
15531
}
15632

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,14 @@
11
--- before/net/minecraft/item/crafting/FurnaceRecipes.java
22
+++ after/net/minecraft/item/crafting/FurnaceRecipes.java
3-
@@ -15,8 +15,8 @@
4-
public class FurnaceRecipes
5-
{
6-
private static final FurnaceRecipes SMELTING_BASE = new FurnaceRecipes();
7-
- private final Map<ItemStack, ItemStack> smeltingList = Maps.newHashMap();
8-
- private final Map<ItemStack, Float> experienceList = Maps.newHashMap();
9-
+ private final Map<ItemStack, ItemStack> smeltingList = Maps.<ItemStack, ItemStack>newHashMap();
10-
+ private final Map<ItemStack, Float> experienceList = Maps.<ItemStack, Float>newHashMap();
11-
12-
public static FurnaceRecipes instance()
13-
{
14-
@@ -35,11 +35,7 @@
15-
this.addSmelting(Items.RABBIT, new ItemStack(Items.COOKED_RABBIT), 0.35F);
16-
this.addSmelting(Items.MUTTON, new ItemStack(Items.COOKED_MUTTON), 0.35F);
17-
this.addSmeltingRecipeForBlock(Blocks.COBBLESTONE, new ItemStack(Blocks.STONE), 0.1F);
18-
- this.addSmeltingRecipe(
19-
- new ItemStack(Blocks.STONEBRICK, 1, BlockStoneBrick.DEFAULT_META),
20-
- new ItemStack(Blocks.STONEBRICK, 1, BlockStoneBrick.CRACKED_META),
21-
- 0.1F
22-
- );
23-
+ this.addSmeltingRecipe(new ItemStack(Blocks.STONEBRICK, 1, BlockStoneBrick.DEFAULT_META), new ItemStack(Blocks.STONEBRICK, 1, BlockStoneBrick.CRACKED_META), 0.1F);
24-
this.addSmelting(Items.CLAY_BALL, new ItemStack(Items.BRICK), 0.3F);
25-
this.addSmeltingRecipeForBlock(Blocks.CLAY, new ItemStack(Blocks.HARDENED_CLAY), 0.35F);
26-
this.addSmeltingRecipeForBlock(Blocks.CACTUS, new ItemStack(Items.DYE, 1, EnumDyeColor.GREEN.getDyeDamage()), 0.2F);
27-
@@ -55,11 +51,7 @@
28-
{
29-
if (itemfishfood$fishtype.canCook())
30-
{
31-
- this.addSmeltingRecipe(
32-
- new ItemStack(Items.FISH, 1, itemfishfood$fishtype.getMetadata()),
33-
- new ItemStack(Items.COOKED_FISH, 1, itemfishfood$fishtype.getMetadata()),
34-
- 0.35F
35-
- );
36-
+ this.addSmeltingRecipe(new ItemStack(Items.FISH, 1, itemfishfood$fishtype.getMetadata()), new ItemStack(Items.COOKED_FISH, 1, itemfishfood$fishtype.getMetadata()), 0.35F);
37-
}
38-
}
39-
40-
@@ -121,8 +113,9 @@
3+
@@ -121,6 +121,7 @@
414

425
public void addSmeltingRecipe(ItemStack input, ItemStack stack, float experience)
436
{
447
+ if (getSmeltingResult(input) != ItemStack.EMPTY) { net.minecraftforge.fml.common.FMLLog.log.info("Ignored smelting recipe with conflicting input: {} = {}", input, stack); return; }
458
this.smeltingList.put(input, stack);
46-
- this.experienceList.put(stack, experience);
47-
+ this.experienceList.put(stack, Float.valueOf(experience));
48-
}
49-
50-
public ItemStack getSmeltingResult(ItemStack stack)
51-
@@ -140,8 +133,7 @@
52-
53-
private boolean compareItemStacks(ItemStack stack1, ItemStack stack2)
54-
{
55-
- return stack2.getItem() == stack1.getItem()
56-
- && (stack2.getMetadata() == 32767 || stack2.getMetadata() == stack1.getMetadata());
57-
+ return stack2.getItem() == stack1.getItem() && (stack2.getMetadata() == 32767 || stack2.getMetadata() == stack1.getMetadata());
9+
this.experienceList.put(stack, experience);
5810
}
59-
60-
public Map<ItemStack, ItemStack> getSmeltingList()
61-
@@ -151,11 +143,14 @@
11+
@@ -151,6 +152,9 @@
6212

6313
public float getSmeltingExperience(ItemStack stack)
6414
{
@@ -68,9 +18,3 @@
6818
for (Entry<ItemStack, Float> entry : this.experienceList.entrySet())
6919
{
7020
if (this.compareItemStacks(stack, entry.getKey()))
71-
{
72-
- return entry.getValue();
73-
+ return ((Float)entry.getValue()).floatValue();
74-
}
75-
}
76-

patches/minecraft/net/minecraft/item/crafting/IRecipe.java.patch

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- before/net/minecraft/item/crafting/IRecipe.java
22
+++ after/net/minecraft/item/crafting/IRecipe.java
3-
@@ -4,25 +4,25 @@
3+
@@ -4,21 +4,21 @@
44
import net.minecraft.item.ItemStack;
55
import net.minecraft.util.NonNullList;
66
import net.minecraft.world.World;
@@ -27,11 +27,6 @@
2727

2828
default NonNullList<Ingredient> getIngredients()
2929
{
30-
- return NonNullList.create();
31-
+ return NonNullList.<Ingredient>create();
32-
}
33-
34-
default boolean isDynamic()
3530
@@ -30,7 +30,6 @@
3631
return false;
3732
}

patches/minecraft/net/minecraft/item/crafting/Ingredient.java.patch

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- before/net/minecraft/item/crafting/Ingredient.java
22
+++ after/net/minecraft/item/crafting/Ingredient.java
3-
@@ -8,31 +8,52 @@
3+
@@ -8,11 +8,11 @@
44
import net.minecraft.client.util.RecipeItemHelper;
55
import net.minecraft.item.Item;
66
import net.minecraft.item.ItemStack;
@@ -9,15 +9,12 @@
99

1010
public class Ingredient implements Predicate<ItemStack>
1111
{
12-
- public static final Ingredient EMPTY = new Ingredient()
1312
+ //Because Mojang caches things... we need to invalidate them.. so... here we go..
1413
+ private static final java.util.Set<Ingredient> INSTANCES = java.util.Collections.newSetFromMap(new java.util.WeakHashMap<Ingredient, Boolean>());
15-
+ public static final Ingredient EMPTY = new Ingredient(new ItemStack[0])
14+
public static final Ingredient EMPTY = new Ingredient()
1615
{
17-
- @Override
18-
public boolean apply(@Nullable ItemStack p_apply_1_)
19-
{
20-
return p_apply_1_.isEmpty();
16+
@Override
17+
@@ -22,17 +22,39 @@
2118
}
2219
};
2320
private final ItemStack[] matchingStacks;
@@ -59,7 +56,7 @@
5956
}
6057

6158
public boolean apply(@Nullable ItemStack p_apply_1_)
62-
@@ -64,9 +85,9 @@
59+
@@ -64,9 +86,9 @@
6360
{
6461
if (this.matchingStacksPacked == null)
6562
{
@@ -71,7 +68,7 @@
7168
{
7269
this.matchingStacksPacked.add(RecipeItemHelper.pack(itemstack));
7370
}
74-
@@ -77,6 +98,18 @@
71+
@@ -77,6 +99,18 @@
7572
return this.matchingStacksPacked;
7673
}
7774

@@ -90,16 +87,7 @@
9087
public static Ingredient fromItem(Item p_193367_0_)
9188
{
9289
return fromStacks(new ItemStack(p_193367_0_, 1, 32767));
93-
@@ -86,7 +119,7 @@
94-
{
95-
ItemStack[] aitemstack = new ItemStack[items.length];
96-
97-
- for (int i = 0; i < items.length; i++)
98-
+ for (int i = 0; i < items.length; ++i)
99-
{
100-
aitemstack[i] = new ItemStack(items[i]);
101-
}
102-
@@ -108,5 +141,23 @@
90+
@@ -108,5 +142,23 @@
10391
}
10492

10593
return EMPTY;

0 commit comments

Comments
 (0)