Skip to content

Commit

Permalink
Reduce number of item copies. Backport from 1.12 VazkiiMods@8595d27 (#44
Browse files Browse the repository at this point in the history
)
  • Loading branch information
mitchej123 authored Feb 18, 2024
1 parent db3e5b6 commit d5beca8
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions src/main/java/vazkii/botania/api/recipe/RecipePureDaisy.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
*/
package vazkii.botania.api.recipe;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
Expand All @@ -22,8 +18,6 @@

public class RecipePureDaisy {

private static final Map<String, List<ItemStack>> oreMap = new HashMap();

Object input;
Block output;
int outputMeta;
Expand Down Expand Up @@ -53,21 +47,10 @@ public boolean isOreDict(ItemStack stack, String entry) {
if(stack == null || stack.getItem() == null)
return false;

List<ItemStack> ores;
if(oreMap.containsKey(entry))
ores = oreMap.get(entry);
else {
ores = OreDictionary.getOres(entry);
oreMap.put(entry, ores);
}

for(ItemStack ostack : ores) {
ItemStack cstack = ostack.copy();
if(cstack.getItemDamage() == Short.MAX_VALUE)
cstack.setItemDamage(stack.getItemDamage());

if(stack.isItemEqual(cstack))
for(ItemStack ostack : OreDictionary.getOres(entry, false)) {
if(OreDictionary.itemMatches(ostack, stack, false)) {
return true;
}
}

return false;
Expand Down

0 comments on commit d5beca8

Please sign in to comment.