Fixed oredict issues with Solderer, fixes #1301

This commit is contained in:
raoulvdberge
2017-06-13 18:16:09 +02:00
parent 34578d5525
commit aef0b1d2d3
15 changed files with 97 additions and 143 deletions

View File

@@ -2,6 +2,8 @@
### 1.4.13 ### 1.4.13
- Fixed Portable Grid model (raoulvdberge, CyanideX) - Fixed Portable Grid model (raoulvdberge, CyanideX)
- Fixed ore dictionary causing problems with Solderer (raoulvdberge)
- Fixed ore dictionary items not showing up in JEI for the Solderer (raoulvdberge)
### 1.4.12 ### 1.4.12
- Updated Forge to 2315 (raoulvdberge) - Updated Forge to 2315 (raoulvdberge)

View File

@@ -84,6 +84,8 @@ public final class RSUtils {
private static final Map<Integer, List<ItemStack>> OREDICT_CACHE = new HashMap<>(); private static final Map<Integer, List<ItemStack>> OREDICT_CACHE = new HashMap<>();
private static final Map<Integer, Boolean> OREDICT_EQUIVALENCY_CACHE = new HashMap<>(); private static final Map<Integer, Boolean> OREDICT_EQUIVALENCY_CACHE = new HashMap<>();
private static final NonNullList<Object> EMPTY_NON_NULL_LIST = NonNullList.create();
static { static {
QUANTITY_FORMATTER.setRoundingMode(RoundingMode.DOWN); QUANTITY_FORMATTER.setRoundingMode(RoundingMode.DOWN);
} }
@@ -211,6 +213,10 @@ public final class RSUtils {
return other; return other;
} }
public static <T> NonNullList<T> emptyNonNullList() {
return (NonNullList<T>) EMPTY_NON_NULL_LIST;
}
public static void writeItems(IItemHandler handler, int id, NBTTagCompound tag) { public static void writeItems(IItemHandler handler, int id, NBTTagCompound tag) {
NBTTagList tagList = new NBTTagList(); NBTTagList tagList = new NBTTagList();

View File

@@ -1,6 +1,7 @@
package com.raoulvdberge.refinedstorage.api.solderer; package com.raoulvdberge.refinedstorage.api.solderer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@@ -10,10 +11,10 @@ import javax.annotation.Nonnull;
public interface ISoldererRecipe { public interface ISoldererRecipe {
/** /**
* @param row the row in the solderer that we want the stack for (between 0 - 2) * @param row the row in the solderer that we want the stack for (between 0 - 2)
* @return a stack for the given row, or empty stack for no stack * @return possible stack(s) for the given row, or empty list for no stack
*/ */
@Nonnull @Nonnull
ItemStack getRow(int row); NonNullList<ItemStack> getRow(int row);
/** /**
* @return the stack that this recipe gives back * @return the stack that this recipe gives back

View File

@@ -1,6 +1,7 @@
package com.raoulvdberge.refinedstorage.api.solderer; package com.raoulvdberge.refinedstorage.api.solderer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@@ -37,18 +38,9 @@ public interface ISoldererRegistry {
* *
* @param result the result * @param result the result
* @param duration the duration in ticks * @param duration the duration in ticks
* @param rows the rows of this recipe, has to be 3 rows (empty item stack for empty row) * @param rows the rows of this recipe, has to be 3 rows (empty list for empty row)
* @return a solderer recipe * @return a solderer recipe
*/ */
@Nonnull @Nonnull
ISoldererRecipe createSimpleRecipe(@Nonnull ItemStack result, int duration, ItemStack... rows); ISoldererRecipe createSimpleRecipe(@Nonnull ItemStack result, int duration, NonNullList<ItemStack>... rows);
/**
* Remove existing recipes from the solderer
*
* @param result the result
* @param rows none or the three rows that give the result
* @return a list of removed {@link ISoldererRecipe}s
*/
List<ISoldererRecipe> removeRecipe(@Nonnull ItemStack result, ItemStack... rows);
} }

View File

@@ -4,7 +4,6 @@ import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.RSUtils; import com.raoulvdberge.refinedstorage.RSUtils;
import com.raoulvdberge.refinedstorage.api.network.INetwork; import com.raoulvdberge.refinedstorage.api.network.INetwork;
import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRecipe; import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRecipe;
import com.raoulvdberge.refinedstorage.api.util.IComparer;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase; import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode; import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
@@ -31,8 +30,10 @@ public class NetworkNodeSolderer extends NetworkNode {
@Nonnull @Nonnull
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
for (ISoldererRecipe recipe : API.instance().getSoldererRegistry().getRecipes()) { for (ISoldererRecipe recipe : API.instance().getSoldererRegistry().getRecipes()) {
if (API.instance().getComparer().isEqual(recipe.getRow(slot), stack, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT | IComparer.COMPARE_OREDICT | IComparer.COMPARE_STRIP_NBT)) { for (ItemStack possibility : recipe.getRow(slot)) {
return super.insertItem(slot, stack, simulate); if (API.instance().getComparer().isEqualNoQuantity(possibility, stack)) {
return super.insertItem(slot, stack, simulate);
}
} }
} }
@@ -112,7 +113,7 @@ public class NetworkNodeSolderer extends NetworkNode {
for (int i = 0; i < 3; ++i) { for (int i = 0; i < 3; ++i) {
if (!recipe.getRow(i).isEmpty()) { if (!recipe.getRow(i).isEmpty()) {
ingredients.extractItem(i, recipe.getRow(i).getCount(), false); ingredients.extractItem(i, recipe.getRow(i).get(0).getCount(), false);
} }
} }

View File

@@ -25,8 +25,8 @@ public class SoldererRecipeFluidStorage implements ISoldererRecipe {
@Override @Override
@Nonnull @Nonnull
public ItemStack getRow(int row) { public NonNullList<ItemStack> getRow(int row) {
return rows.get(row); return NonNullList.withSize(1, rows.get(row));
} }
@Override @Override

View File

@@ -1,11 +1,12 @@
package com.raoulvdberge.refinedstorage.apiimpl.solderer; package com.raoulvdberge.refinedstorage.apiimpl.solderer;
import com.raoulvdberge.refinedstorage.RSItems; import com.raoulvdberge.refinedstorage.RSItems;
import com.raoulvdberge.refinedstorage.RSUtils;
import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRecipe; import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRecipe;
import com.raoulvdberge.refinedstorage.item.ItemProcessor; import com.raoulvdberge.refinedstorage.item.ItemProcessor;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.oredict.OreDictionary;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@@ -13,7 +14,7 @@ public class SoldererRecipePrintedProcessor implements ISoldererRecipe {
private int type; private int type;
private boolean fullBlock; private boolean fullBlock;
private ItemStack result; private ItemStack result;
private ItemStack requirement; private NonNullList<ItemStack> requirement;
public SoldererRecipePrintedProcessor(int type, boolean fullBlock) { public SoldererRecipePrintedProcessor(int type, boolean fullBlock) {
this.type = type; this.type = type;
@@ -22,28 +23,28 @@ public class SoldererRecipePrintedProcessor implements ISoldererRecipe {
switch (type) { switch (type) {
case ItemProcessor.TYPE_PRINTED_BASIC: case ItemProcessor.TYPE_PRINTED_BASIC:
this.requirement = fullBlock ? new ItemStack(Blocks.IRON_BLOCK) : new ItemStack(Items.IRON_INGOT); this.requirement = fullBlock ? OreDictionary.getOres("blockIron") : OreDictionary.getOres("ingotIron");
break; break;
case ItemProcessor.TYPE_PRINTED_IMPROVED: case ItemProcessor.TYPE_PRINTED_IMPROVED:
this.requirement = fullBlock ? new ItemStack(Blocks.GOLD_BLOCK) : new ItemStack(Items.GOLD_INGOT); this.requirement = fullBlock ? OreDictionary.getOres("blockGold") : OreDictionary.getOres("ingotGold");
break; break;
case ItemProcessor.TYPE_PRINTED_ADVANCED: case ItemProcessor.TYPE_PRINTED_ADVANCED:
this.requirement = fullBlock ? new ItemStack(Blocks.DIAMOND_BLOCK) : new ItemStack(Items.DIAMOND); this.requirement = fullBlock ? OreDictionary.getOres("blockDiamond") : OreDictionary.getOres("gemDiamond");
break; break;
case ItemProcessor.TYPE_PRINTED_SILICON: case ItemProcessor.TYPE_PRINTED_SILICON:
if (fullBlock) { if (fullBlock) {
throw new IllegalArgumentException("Printed silicon can't be made from block form!"); throw new IllegalArgumentException("Printed silicon can't be made from block form!");
} }
this.requirement = new ItemStack(RSItems.SILICON); this.requirement = OreDictionary.getOres("itemSilicon");
break; break;
} }
} }
@Override @Override
@Nonnull @Nonnull
public ItemStack getRow(int row) { public NonNullList<ItemStack> getRow(int row) {
return row == 1 ? requirement : ItemStack.EMPTY; return row == 1 ? requirement : RSUtils.emptyNonNullList();
} }
@Override @Override

View File

@@ -3,25 +3,27 @@ package com.raoulvdberge.refinedstorage.apiimpl.solderer;
import com.raoulvdberge.refinedstorage.RSItems; import com.raoulvdberge.refinedstorage.RSItems;
import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRecipe; import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRecipe;
import com.raoulvdberge.refinedstorage.item.ItemProcessor; import com.raoulvdberge.refinedstorage.item.ItemProcessor;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraftforge.oredict.OreDictionary;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
public class SoldererRecipeProcessor implements ISoldererRecipe { public class SoldererRecipeProcessor implements ISoldererRecipe {
private int type; private int type;
private ItemStack result; private ItemStack result;
private NonNullList<ItemStack> rows = NonNullList.create(); private List<NonNullList<ItemStack>> rows = new ArrayList<>();
public SoldererRecipeProcessor(int type) { public SoldererRecipeProcessor(int type) {
this.type = type; this.type = type;
this.result = new ItemStack(RSItems.PROCESSOR, 1, type); this.result = new ItemStack(RSItems.PROCESSOR, 1, type);
this.rows.add(createPrintedProcessor()); this.rows.add(NonNullList.withSize(1, createPrintedProcessor()));
this.rows.add(new ItemStack(Items.REDSTONE)); this.rows.add(OreDictionary.getOres("dustRedstone"));
this.rows.add(new ItemStack(RSItems.PROCESSOR, 1, ItemProcessor.TYPE_PRINTED_SILICON)); this.rows.add(NonNullList.withSize(1, new ItemStack(RSItems.PROCESSOR, 1, ItemProcessor.TYPE_PRINTED_SILICON)));
} }
private ItemStack createPrintedProcessor() { private ItemStack createPrintedProcessor() {
@@ -39,7 +41,7 @@ public class SoldererRecipeProcessor implements ISoldererRecipe {
@Override @Override
@Nonnull @Nonnull
public ItemStack getRow(int row) { public NonNullList<ItemStack> getRow(int row) {
return rows.get(row); return rows.get(row);
} }

View File

@@ -25,8 +25,8 @@ public class SoldererRecipeStorage implements ISoldererRecipe {
@Override @Override
@Nonnull @Nonnull
public ItemStack getRow(int row) { public NonNullList<ItemStack> getRow(int row) {
return rows.get(row); return NonNullList.withSize(1, rows.get(row));
} }
@Override @Override

View File

@@ -3,35 +3,37 @@ package com.raoulvdberge.refinedstorage.apiimpl.solderer;
import com.raoulvdberge.refinedstorage.RSItems; import com.raoulvdberge.refinedstorage.RSItems;
import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRecipe; import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRecipe;
import com.raoulvdberge.refinedstorage.item.ItemUpgrade; import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraftforge.oredict.OreDictionary;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
public class SoldererRecipeUpgrade implements ISoldererRecipe { public class SoldererRecipeUpgrade implements ISoldererRecipe {
private ItemStack result; private ItemStack result;
private NonNullList<ItemStack> rows = NonNullList.create(); private List<NonNullList<ItemStack>> rows = new ArrayList<>();
public SoldererRecipeUpgrade(int type) { public SoldererRecipeUpgrade(int type) {
this.result = new ItemStack(RSItems.UPGRADE, 1, type); this.result = new ItemStack(RSItems.UPGRADE, 1, type);
this.rows.add(ItemUpgrade.getRequirement(result)); this.rows.add(ItemUpgrade.getRequirement(result));
this.rows.add(new ItemStack(Items.REDSTONE)); this.rows.add(OreDictionary.getOres("dustRedstone"));
this.rows.add(new ItemStack(RSItems.UPGRADE, 1, 0)); this.rows.add(NonNullList.withSize(1, new ItemStack(RSItems.UPGRADE, 1, 0)));
} }
public SoldererRecipeUpgrade(ItemStack result) { public SoldererRecipeUpgrade(ItemStack result) {
this.result = result; this.result = result;
this.rows.add(ItemUpgrade.getRequirement(result)); this.rows.add(ItemUpgrade.getRequirement(result));
this.rows.add(new ItemStack(Items.REDSTONE)); this.rows.add(OreDictionary.getOres("dustRedstone"));
this.rows.add(new ItemStack(RSItems.UPGRADE, 1, 0)); this.rows.add(NonNullList.withSize(1, new ItemStack(RSItems.UPGRADE, 1, 0)));
} }
@Override @Override
@Nonnull @Nonnull
public ItemStack getRow(int row) { public NonNullList<ItemStack> getRow(int row) {
return rows.get(row); return rows.get(row);
} }

View File

@@ -2,16 +2,14 @@ package com.raoulvdberge.refinedstorage.apiimpl.solderer;
import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRecipe; import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRecipe;
import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRegistry; import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRegistry;
import com.raoulvdberge.refinedstorage.api.util.IComparer;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List; import java.util.List;
public class SoldererRegistry implements ISoldererRegistry { public class SoldererRegistry implements ISoldererRegistry {
@@ -26,21 +24,27 @@ public class SoldererRegistry implements ISoldererRegistry {
@Nullable @Nullable
public ISoldererRecipe getRecipe(@Nonnull IItemHandler ingredients) { public ISoldererRecipe getRecipe(@Nonnull IItemHandler ingredients) {
for (ISoldererRecipe recipe : recipes) { for (ISoldererRecipe recipe : recipes) {
boolean found = true; int rowsFound = 0;
for (int i = 0; i < 3; ++i) { for (int i = 0; i < 3; ++i) {
if (!API.instance().getComparer().isEqual(recipe.getRow(i), ingredients.getStackInSlot(i), IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT | IComparer.COMPARE_OREDICT | IComparer.COMPARE_STRIP_NBT)) { NonNullList<ItemStack> possibilities = recipe.getRow(i);
found = false;
if (possibilities.isEmpty() && ingredients.getStackInSlot(i).isEmpty()) {
rowsFound++;
continue;
} }
ItemStack row = recipe.getRow(i); for (ItemStack possibility : possibilities) {
if (API.instance().getComparer().isEqualNoQuantity(possibility, ingredients.getStackInSlot(i))) {
if (ingredients.getStackInSlot(i).getCount() < row.getCount()) { if (ingredients.getStackInSlot(i).getCount() >= possibility.getCount()) {
found = false; rowsFound++;
}
}
} }
} }
if (found) { if (rowsFound == 3) {
return recipe; return recipe;
} }
} }
@@ -55,21 +59,15 @@ public class SoldererRegistry implements ISoldererRegistry {
@Nonnull @Nonnull
@Override @Override
public ISoldererRecipe createSimpleRecipe(@Nonnull ItemStack result, int duration, ItemStack... rows) { public ISoldererRecipe createSimpleRecipe(@Nonnull ItemStack result, int duration, NonNullList<ItemStack>... rows) {
if (rows.length != 3) { if (rows.length != 3) {
throw new IllegalArgumentException("Solderer recipe expects 3 rows, got " + rows.length + " rows"); throw new IllegalArgumentException("Solderer recipe expects 3 rows, got " + rows.length + " rows");
} }
for (ItemStack row : rows) {
if (row == null) {
throw new IllegalArgumentException("Found a null item stack in recipe creation!");
}
}
return new ISoldererRecipe() { return new ISoldererRecipe() {
@Nonnull @Nonnull
@Override @Override
public ItemStack getRow(int row) { public NonNullList<ItemStack> getRow(int row) {
return rows[row]; return rows[row];
} }
@@ -85,32 +83,4 @@ public class SoldererRegistry implements ISoldererRegistry {
} }
}; };
} }
@Override
public List<ISoldererRecipe> removeRecipe(@Nonnull ItemStack result, ItemStack... rows) {
if (!(rows.length == 0 || rows.length == 3)) {
throw new IllegalArgumentException("Removing a recipe requires either no rows or 3 rows, got " + rows.length + " rows");
}
Iterator<ISoldererRecipe> itr = recipes.iterator();
List<ISoldererRecipe> removed = new LinkedList<>();
while (itr.hasNext()) {
ISoldererRecipe recipe = itr.next();
if (API.instance().getComparer().isEqualNoQuantity(result, recipe.getResult())) {
if (rows.length == 0 || compareRows(recipe, rows)) {
itr.remove();
removed.add(recipe);
}
}
}
return removed;
}
private boolean compareRows(ISoldererRecipe recipe, ItemStack[] rows) {
for (int i = 0; i < 3; ++i) {
if (!API.instance().getComparer().isEqualNoQuantity(recipe.getRow(i), rows[i])) {
return false;
}
}
return true;
}
} }

View File

@@ -13,7 +13,7 @@ public final class RecipeMakerSolderer {
List<RecipeWrapperSolderer> recipes = new ArrayList<>(); List<RecipeWrapperSolderer> recipes = new ArrayList<>();
for (ISoldererRecipe recipe : API.instance().getSoldererRegistry().getRecipes()) { for (ISoldererRecipe recipe : API.instance().getSoldererRegistry().getRecipes()) {
List<ItemStack> inputs = new ArrayList<>(); List<List<ItemStack>> inputs = new ArrayList<>();
inputs.add(recipe.getRow(0)); inputs.add(recipe.getRow(0));
inputs.add(recipe.getRow(1)); inputs.add(recipe.getRow(1));

View File

@@ -13,10 +13,10 @@ import java.util.List;
public class RecipeWrapperSolderer extends BlankRecipeWrapper { public class RecipeWrapperSolderer extends BlankRecipeWrapper {
private IDrawableAnimated progress; private IDrawableAnimated progress;
private List<ItemStack> inputs; private List<List<ItemStack>> inputs;
private ItemStack output; private ItemStack output;
public RecipeWrapperSolderer(IGuiHelper guiHelper, int duration, List<ItemStack> inputs, ItemStack output) { public RecipeWrapperSolderer(IGuiHelper guiHelper, int duration, List<List<ItemStack>> inputs, ItemStack output) {
this.progress = guiHelper.createAnimatedDrawable( this.progress = guiHelper.createAnimatedDrawable(
guiHelper.createDrawable( guiHelper.createDrawable(
new ResourceLocation("refinedstorage", "textures/gui/solderer.png"), new ResourceLocation("refinedstorage", "textures/gui/solderer.png"),
@@ -36,36 +36,14 @@ public class RecipeWrapperSolderer extends BlankRecipeWrapper {
@Override @Override
public void getIngredients(IIngredients ingredients) { public void getIngredients(IIngredients ingredients) {
ingredients.setInputs(ItemStack.class, inputs); ingredients.setInputLists(ItemStack.class, inputs);
ingredients.setOutput(ItemStack.class, output); ingredients.setOutput(ItemStack.class, output);
} }
@Override
public boolean equals(Object obj) {
if (!(obj instanceof RecipeWrapperSolderer)) {
return false;
}
RecipeWrapperSolderer other = (RecipeWrapperSolderer) obj;
for (int i = 0; i < inputs.size(); i++) {
if (!ItemStack.areItemStacksEqual(inputs.get(i), other.inputs.get(i))) {
return false;
}
}
return ItemStack.areItemStacksEqual(output, other.output);
}
@Override @Override
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY); super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
progress.draw(minecraft, 40, 18); progress.draw(minecraft, 40, 18);
} }
@Override
public String toString() {
return inputs + " = " + output;
}
} }

View File

@@ -2,12 +2,12 @@ package com.raoulvdberge.refinedstorage.item;
import com.raoulvdberge.refinedstorage.RS; import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.RSItems; import com.raoulvdberge.refinedstorage.RSItems;
import com.raoulvdberge.refinedstorage.RSUtils;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentData; import net.minecraft.enchantment.EnchantmentData;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -15,6 +15,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary;
import java.util.List; import java.util.List;
@@ -100,22 +101,22 @@ public class ItemUpgrade extends ItemBase {
} }
} }
public static ItemStack getRequirement(ItemStack stack) { public static NonNullList<ItemStack> getRequirement(ItemStack stack) {
switch (stack.getItemDamage()) { switch (stack.getItemDamage()) {
case ItemUpgrade.TYPE_RANGE: case ItemUpgrade.TYPE_RANGE:
return new ItemStack(Items.ENDER_PEARL); return OreDictionary.getOres("enderpearl");
case ItemUpgrade.TYPE_SPEED: case ItemUpgrade.TYPE_SPEED:
return new ItemStack(Items.SUGAR); return NonNullList.withSize(1, new ItemStack(Items.SUGAR));
case ItemUpgrade.TYPE_CRAFTING: case ItemUpgrade.TYPE_CRAFTING:
return new ItemStack(Blocks.CRAFTING_TABLE); return OreDictionary.getOres("workbench");
case ItemUpgrade.TYPE_INTERDIMENSIONAL: case ItemUpgrade.TYPE_INTERDIMENSIONAL:
return new ItemStack(Items.NETHER_STAR); return OreDictionary.getOres("netherStar");
case ItemUpgrade.TYPE_SILK_TOUCH: case ItemUpgrade.TYPE_SILK_TOUCH:
return Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(Enchantment.getEnchantmentByLocation("silk_touch"), 1)); return NonNullList.withSize(1, Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(Enchantment.getEnchantmentByLocation("silk_touch"), 1)));
case ItemUpgrade.TYPE_FORTUNE: case ItemUpgrade.TYPE_FORTUNE:
return Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(Enchantment.getEnchantmentByLocation("fortune"), getFortuneLevel(stack))); return NonNullList.withSize(1, Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(Enchantment.getEnchantmentByLocation("fortune"), getFortuneLevel(stack))));
default: default:
return null; return RSUtils.emptyNonNullList();
} }
} }
} }

View File

@@ -37,6 +37,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent; import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent;
@@ -212,9 +213,6 @@ public class ProxyCommon {
OreDictionary.registerOre("itemSilicon", RSItems.SILICON); OreDictionary.registerOre("itemSilicon", RSItems.SILICON);
OreDictionary.registerOre("ingotQuartzEnrichedIron", RSItems.QUARTZ_ENRICHED_IRON);
OreDictionary.registerOre("blockQuartzEnrichedIron", RSBlocks.QUARTZ_ENRICHED_IRON);
// Processors // Processors
API.instance().getSoldererRegistry().addRecipe(new SoldererRecipePrintedProcessor(ItemProcessor.TYPE_PRINTED_BASIC, false)); API.instance().getSoldererRegistry().addRecipe(new SoldererRecipePrintedProcessor(ItemProcessor.TYPE_PRINTED_BASIC, false));
API.instance().getSoldererRegistry().addRecipe(new SoldererRecipePrintedProcessor(ItemProcessor.TYPE_PRINTED_IMPROVED, false)); API.instance().getSoldererRegistry().addRecipe(new SoldererRecipePrintedProcessor(ItemProcessor.TYPE_PRINTED_IMPROVED, false));
@@ -345,27 +343,27 @@ public class ProxyCommon {
API.instance().getSoldererRegistry().addRecipe(API.instance().getSoldererRegistry().createSimpleRecipe( API.instance().getSoldererRegistry().addRecipe(API.instance().getSoldererRegistry().createSimpleRecipe(
new ItemStack(RSBlocks.GRID, 1, GridType.CRAFTING.getId()), new ItemStack(RSBlocks.GRID, 1, GridType.CRAFTING.getId()),
500, 500,
new ItemStack(Blocks.CRAFTING_TABLE), OreDictionary.getOres("workbench"),
new ItemStack(RSItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED), NonNullList.withSize(1, new ItemStack(RSItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED)),
new ItemStack(RSBlocks.GRID, 1, GridType.NORMAL.getId()) NonNullList.withSize(1, new ItemStack(RSBlocks.GRID, 1, GridType.NORMAL.getId()))
)); ));
// Pattern Grid // Pattern Grid
API.instance().getSoldererRegistry().addRecipe(API.instance().getSoldererRegistry().createSimpleRecipe( API.instance().getSoldererRegistry().addRecipe(API.instance().getSoldererRegistry().createSimpleRecipe(
new ItemStack(RSBlocks.GRID, 1, GridType.PATTERN.getId()), new ItemStack(RSBlocks.GRID, 1, GridType.PATTERN.getId()),
500, 500,
new ItemStack(RSItems.PATTERN), NonNullList.withSize(1, new ItemStack(RSItems.PATTERN)),
new ItemStack(RSItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED), NonNullList.withSize(1, new ItemStack(RSItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED)),
new ItemStack(RSBlocks.GRID, 1, GridType.NORMAL.getId()) NonNullList.withSize(1, new ItemStack(RSBlocks.GRID, 1, GridType.NORMAL.getId()))
)); ));
// Fluid Grid // Fluid Grid
API.instance().getSoldererRegistry().addRecipe(API.instance().getSoldererRegistry().createSimpleRecipe( API.instance().getSoldererRegistry().addRecipe(API.instance().getSoldererRegistry().createSimpleRecipe(
new ItemStack(RSBlocks.GRID, 1, GridType.FLUID.getId()), new ItemStack(RSBlocks.GRID, 1, GridType.FLUID.getId()),
500, 500,
new ItemStack(Items.BUCKET), NonNullList.withSize(1, new ItemStack(Items.BUCKET)),
new ItemStack(RSItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED), NonNullList.withSize(1, new ItemStack(RSItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED)),
new ItemStack(RSBlocks.GRID, 1, GridType.NORMAL.getId()) NonNullList.withSize(1, new ItemStack(RSBlocks.GRID, 1, GridType.NORMAL.getId()))
)); ));
// Wireless Grid // Wireless Grid
@@ -718,18 +716,18 @@ public class ProxyCommon {
API.instance().getSoldererRegistry().addRecipe(API.instance().getSoldererRegistry().createSimpleRecipe( API.instance().getSoldererRegistry().addRecipe(API.instance().getSoldererRegistry().createSimpleRecipe(
new ItemStack(RSBlocks.INTERFACE), new ItemStack(RSBlocks.INTERFACE),
200, 200,
new ItemStack(RSBlocks.IMPORTER), NonNullList.withSize(1, new ItemStack(RSBlocks.IMPORTER)),
new ItemStack(RSBlocks.EXPORTER), NonNullList.withSize(1, new ItemStack(RSBlocks.EXPORTER)),
new ItemStack(RSBlocks.MACHINE_CASING) NonNullList.withSize(1, new ItemStack(RSBlocks.MACHINE_CASING))
)); ));
// Fluid Interface // Fluid Interface
API.instance().getSoldererRegistry().addRecipe(API.instance().getSoldererRegistry().createSimpleRecipe( API.instance().getSoldererRegistry().addRecipe(API.instance().getSoldererRegistry().createSimpleRecipe(
new ItemStack(RSBlocks.FLUID_INTERFACE), new ItemStack(RSBlocks.FLUID_INTERFACE),
200, 200,
new ItemStack(Items.BUCKET), NonNullList.withSize(1, new ItemStack(Items.BUCKET)),
new ItemStack(Items.REDSTONE), OreDictionary.getOres("dustRedstone"),
new ItemStack(RSBlocks.INTERFACE) NonNullList.withSize(1, new ItemStack(RSBlocks.INTERFACE))
)); ));
// Grid Filter // Grid Filter