diff options
Diffstat (limited to 'src/main/java/jp/plusplus/fbs/pottery/usable/PotteryEnchantment.java')
| -rw-r--r-- | src/main/java/jp/plusplus/fbs/pottery/usable/PotteryEnchantment.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/main/java/jp/plusplus/fbs/pottery/usable/PotteryEnchantment.java b/src/main/java/jp/plusplus/fbs/pottery/usable/PotteryEnchantment.java new file mode 100644 index 0000000..451e0ff --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/pottery/usable/PotteryEnchantment.java @@ -0,0 +1,61 @@ +package jp.plusplus.fbs.pottery.usable;
+
+import com.google.common.collect.Maps;
+import cpw.mods.fml.common.registry.GameData;
+import jp.plusplus.fbs.api.IPottery;
+import net.minecraft.block.Block;
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+import javax.annotation.Nullable;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.Random;
+
+/**
+ * Created by plusplus_F on 2016/03/30.
+ */
+public class PotteryEnchantment extends PotteryKeep {
+ private Random rand=new Random();
+
+ @Override
+ public String getUnlocalizedName() {
+ return "pottery.fbs.pot.enchant";
+ }
+
+ @Override
+ public float getPriceScale(ItemStack pottery){
+ return 3.5f;
+ }
+
+ @Override
+ public ItemStack onInventoryClosing(EntityPlayer player, ItemStack pottery, int index, @Nullable ItemStack itemStack){
+ NBTTagCompound nbt=pottery.getTagCompound();
+
+ if(itemStack!=null && !nbt.getBoolean(CHANGED_INDEXES + index)){
+ if(!itemStack.isItemEnchanted() && itemStack.isItemEnchantable()){
+ IPottery ip=(IPottery)((ItemBlock)pottery.getItem()).field_150939_a;
+
+ int lv;
+ switch (ip.getGrade(nbt)){
+ case BAD: lv=5; break;
+ case GOOD: lv=20; break;
+ case GREAT: lv=30; break;
+ case SOULFUL: lv=40; break;
+ default: lv=10; break;
+ }
+ return EnchantmentHelper.addRandomEnchantment(rand, itemStack, lv);
+ }
+ }
+ return itemStack;
+ }
+
+ @Override
+ public boolean canTakeStack(EntityPlayer player, ItemStack pottery, int index, ItemStack itemStack){
+ return !pottery.getTagCompound().getBoolean(CHANGED_INDEXES+index);
+ }
+}
|
