blob: 214cd008195cac04b24f9a452c6a45845ae421ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
package jp.plusplus.fbs;
import jp.plusplus.fbs.alchemy.AlchemyRegistry;
import jp.plusplus.fbs.alchemy.ItemAlchemyIntermediateMaterial;
import jp.plusplus.fbs.alchemy.characteristic.CharacteristicBase;
import jp.plusplus.fbs.alchemy.characteristic.CharacteristicQuality;
import jp.plusplus.fbs.item.ItemCore;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Created by plusplus_F on 2016/02/23.
*/
public class RecipePotionBless implements IRecipe {
public static final int LV=2;
private ItemStack result;
@Override
public boolean matches(InventoryCrafting p_77569_1_, World p_77569_2_) {
result = null;
int size = p_77569_1_.getSizeInventory();
//装備と祝福ポーションを探す
ItemStack tool = null;
ItemStack pot=null;
for (int i = 0; i < size; i++) {
ItemStack itemStack = p_77569_1_.getStackInSlot(i);
if (itemStack == null) continue;
Item item = itemStack.getItem();
if (item.isItemTool(itemStack) && item.getItemEnchantability(itemStack)>0) {
if (tool != null) return false;
tool=itemStack;
if(tool.isItemEnchanted()){
Map m= EnchantmentHelper.getEnchantments(tool);
if(m.containsKey(Enchantment.unbreaking.effectId)){
return false;
}
}
} else if (item== ItemCore.potionBless) {
if(pot==null) pot=itemStack;
else return false;
} else {
return false;
}
}
if (tool == null || pot==null) return false;
result = new ItemStack(tool.getItem(), tool.stackSize, tool.getItemDamage());
if(tool.hasTagCompound()) result.setTagCompound((NBTTagCompound)tool.getTagCompound().copy());
else result.setTagCompound(new NBTTagCompound());
Map m=null;
if(result.isItemEnchanted()) m=EnchantmentHelper.getEnchantments(result);
else m=new LinkedHashMap();
m.put(Enchantment.unbreaking.effectId, LV);
EnchantmentHelper.setEnchantments(m, result);
return true;
}
@Override
public ItemStack getCraftingResult(InventoryCrafting p_77572_1_) {
return result;
}
@Override
public int getRecipeSize() {
return 2;
}
@Override
public ItemStack getRecipeOutput() {
return result;
}
}
|