2017-12-12 07:54:12 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.recipe;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
|
|
|
|
|
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
|
|
|
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
|
|
|
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
|
|
|
|
import net.minecraft.block.Block;
|
2021-02-26 22:15:48 +01:00
|
|
|
import net.minecraft.block.state.BlockState;
|
2017-12-12 07:54:12 +01:00
|
|
|
import net.minecraft.enchantment.Enchantment;
|
|
|
|
import net.minecraft.enchantment.EnchantmentHelper;
|
|
|
|
import net.minecraft.init.Items;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2018-06-24 02:44:47 +02:00
|
|
|
import net.minecraft.item.crafting.Ingredient;
|
2017-12-12 07:54:12 +01:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
|
|
|
|
public class EnchBookConversion extends LensConversionRecipe {
|
|
|
|
|
2019-02-27 19:53:05 +01:00
|
|
|
public EnchBookConversion() {
|
|
|
|
super(Ingredient.fromItem(Items.ENCHANTED_BOOK), ItemStack.EMPTY, 155000, ActuallyAdditionsAPI.lensDefaultConversion);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-02-26 22:15:48 +01:00
|
|
|
public void transformHook(ItemStack stack, BlockState state, BlockPos pos, IAtomicReconstructor tile) {
|
2019-05-02 09:10:29 +02:00
|
|
|
for (Map.Entry<Enchantment, Integer> e : EnchantmentHelper.getEnchantments(stack).entrySet()) {
|
2019-02-27 19:53:05 +01:00
|
|
|
ItemStack book = new ItemStack(Items.ENCHANTED_BOOK);
|
|
|
|
Map<Enchantment, Integer> ench = ImmutableMap.of(e.getKey(), e.getValue());
|
|
|
|
EnchantmentHelper.setEnchantments(ench, book);
|
|
|
|
Block.spawnAsEntity(tile.getWorldObject(), pos, book);
|
|
|
|
}
|
|
|
|
}
|
2017-12-12 07:54:12 +01:00
|
|
|
|
|
|
|
}
|