Fixed fortune 1, 2, 3 and silk touch upgrades giving the wrong item. Fixes #1866
This commit is contained in:
@@ -42,9 +42,11 @@ import com.raoulvdberge.refinedstorage.integration.inventorysorter.IntegrationIn
|
||||
import com.raoulvdberge.refinedstorage.integration.oc.DriverNetwork;
|
||||
import com.raoulvdberge.refinedstorage.integration.oc.IntegrationOC;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemProcessor;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
|
||||
import com.raoulvdberge.refinedstorage.network.*;
|
||||
import com.raoulvdberge.refinedstorage.recipe.RecipeCover;
|
||||
import com.raoulvdberge.refinedstorage.recipe.RecipeHollowCover;
|
||||
import com.raoulvdberge.refinedstorage.recipe.RecipeUpgradeWithEnchantedBook;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileNode;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
@@ -284,6 +286,10 @@ public class ProxyCommon {
|
||||
public void registerRecipes(RegistryEvent.Register<IRecipe> e) {
|
||||
e.getRegistry().register(new RecipeCover().setRegistryName(new ResourceLocation(RS.ID, "cover")));
|
||||
e.getRegistry().register(new RecipeHollowCover().setRegistryName(new ResourceLocation(RS.ID, "hollow_cover")));
|
||||
e.getRegistry().register(new RecipeUpgradeWithEnchantedBook("fortune", 1, ItemUpgrade.TYPE_FORTUNE_1).setRegistryName(new ResourceLocation(RS.ID, "fortune_1_upgrade")));
|
||||
e.getRegistry().register(new RecipeUpgradeWithEnchantedBook("fortune", 2, ItemUpgrade.TYPE_FORTUNE_2).setRegistryName(new ResourceLocation(RS.ID, "fortune_2_upgrade")));
|
||||
e.getRegistry().register(new RecipeUpgradeWithEnchantedBook("fortune", 3, ItemUpgrade.TYPE_FORTUNE_3).setRegistryName(new ResourceLocation(RS.ID, "fortune_3_upgrade")));
|
||||
e.getRegistry().register(new RecipeUpgradeWithEnchantedBook("silk_touch", 1, ItemUpgrade.TYPE_SILK_TOUCH).setRegistryName(new ResourceLocation(RS.ID, "silk_touch_upgrade")));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.recipe;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentData;
|
||||
import net.minecraft.item.ItemEnchantedBook;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraftforge.common.crafting.IIngredientFactory;
|
||||
import net.minecraftforge.common.crafting.JsonContext;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class IngredientFactoryEnchantedBook implements IIngredientFactory {
|
||||
@Nonnull
|
||||
@Override
|
||||
public Ingredient parse(JsonContext context, JsonObject json) {
|
||||
String id = JsonUtils.getString(json, "id");
|
||||
int level = JsonUtils.getInt(json, "level", 1);
|
||||
|
||||
Enchantment enchantment = Enchantment.getEnchantmentByLocation(id);
|
||||
|
||||
if (enchantment == null) {
|
||||
throw new JsonSyntaxException("Couldn't find enchantment with id '" + id + "'");
|
||||
}
|
||||
|
||||
return Ingredient.fromStacks(ItemEnchantedBook.getEnchantedItemStack(new EnchantmentData(enchantment, level)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.raoulvdberge.refinedstorage.recipe;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.RSItems;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentData;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemEnchantedBook;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
// MC JSON recipes don't like comparing to NBT, that's why we need a custom recipe class.
|
||||
// We need to compare to NBT for the enchanted book.
|
||||
public class RecipeUpgradeWithEnchantedBook extends ShapedRecipes {
|
||||
private ItemStack enchantedBook;
|
||||
|
||||
public RecipeUpgradeWithEnchantedBook(String enchantmentId, int enchantmentLevel, int upgradeId) {
|
||||
super(RS.ID, 3, 3, NonNullList.from(Ingredient.EMPTY,
|
||||
Ingredient.fromStacks(new ItemStack(RSItems.QUARTZ_ENRICHED_IRON)),
|
||||
Ingredient.fromStacks(ItemEnchantedBook.getEnchantedItemStack(new EnchantmentData(Enchantment.getEnchantmentByLocation(enchantmentId), enchantmentLevel))),
|
||||
Ingredient.fromStacks(new ItemStack(RSItems.QUARTZ_ENRICHED_IRON)),
|
||||
Ingredient.fromStacks(new ItemStack(Blocks.BOOKSHELF)),
|
||||
Ingredient.fromStacks(new ItemStack(RSItems.UPGRADE)),
|
||||
Ingredient.fromStacks(new ItemStack(Blocks.BOOKSHELF)),
|
||||
Ingredient.fromStacks(new ItemStack(RSItems.QUARTZ_ENRICHED_IRON)),
|
||||
Ingredient.fromStacks(new ItemStack(RSItems.QUARTZ_ENRICHED_IRON)),
|
||||
Ingredient.fromStacks(new ItemStack(RSItems.QUARTZ_ENRICHED_IRON))
|
||||
), new ItemStack(RSItems.UPGRADE, 1, upgradeId));
|
||||
|
||||
this.enchantedBook = ItemEnchantedBook.getEnchantedItemStack(new EnchantmentData(Enchantment.getEnchantmentByLocation(enchantmentId), enchantmentLevel));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting inv, World world) {
|
||||
return super.matches(inv, world) && API.instance().getComparer().isEqualNoQuantity(inv.getStackInSlot(1), enchantedBook);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user