summaryrefslogtreecommitdiff
path: root/src/main/java/jp/plusplus/fbs/container/slot/SlotTakeOnlyWithMagicEXP.java
blob: dd6f2a88d233c47f76c61a47b9317c2be9ee0ac6 (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
package jp.plusplus.fbs.container.slot;

import cpw.mods.fml.common.FMLCommonHandler;
import jp.plusplus.fbs.AchievementRegistry;
import jp.plusplus.fbs.alchemy.AlchemyRegistry;
import jp.plusplus.fbs.api.FBSEntityPropertiesAPI;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.SlotFurnace;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.stats.AchievementList;
import net.minecraft.util.MathHelper;

/**
 * Created by plusplus_F on 2015/10/31.
 */
public class SlotTakeOnlyWithMagicEXP extends Slot {
    protected EntityPlayer thePlayer;
    protected int achievement;

    public SlotTakeOnlyWithMagicEXP(EntityPlayer p_i1813_1_, IInventory p_i1813_2_, int p_i1813_3_, int p_i1813_4_, int p_i1813_5_) {
        this(p_i1813_1_, p_i1813_2_, p_i1813_3_, p_i1813_4_, p_i1813_5_, 0);
    }
    public SlotTakeOnlyWithMagicEXP(EntityPlayer p_i1813_1_, IInventory p_i1813_2_, int p_i1813_3_, int p_i1813_4_, int p_i1813_5_, int achievement) {
        super(p_i1813_2_, p_i1813_3_, p_i1813_4_, p_i1813_5_);
        this.thePlayer = p_i1813_1_;
        this.achievement=achievement;
    }

    public boolean isItemValid(ItemStack p_75214_1_) {
        return false;
    }

    public ItemStack decrStackSize(int p_75209_1_) {
        return super.decrStackSize(p_75209_1_);
    }

    public void onPickupFromSlot(EntityPlayer p_82870_1_, ItemStack p_82870_2_) {
        this.onCrafting(p_82870_2_);
        if(achievement==1){
            p_82870_1_.triggerAchievement(AchievementRegistry.alchemy);
        }
        super.onPickupFromSlot(p_82870_1_, p_82870_2_);
    }

    protected void onCrafting(ItemStack p_75210_1_, int p_75210_2_) {
        this.onCrafting(p_75210_1_);
    }

    protected void onCrafting(ItemStack p_75208_1_) {
        p_75208_1_.onCrafting(this.thePlayer.worldObj, this.thePlayer, 1);

        if (!this.thePlayer.worldObj.isRemote) {
            double baseEXP = AlchemyRegistry.GetProductExp(p_75208_1_);

            if(baseEXP>0){
                FBSEntityPropertiesAPI.AddExp(thePlayer, baseEXP, true);
            }
        }
    }
}