Search in sources :

Example 1 with CapabilityBaseMiscStackSerializable

use of net.tslat.aoa3.capabilities.interfaces.CapabilityBaseMiscStackSerializable in project Advent-Of-Ascension by Tslat.

the class EnergisticShovel method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    if (!world.isRemote) {
        CapabilityBaseMiscStackSerializable cap = getCapability(player.getHeldItem(hand));
        if (cap != null) {
            PlayerDataManager plData = PlayerUtil.getAdventPlayer(player);
            float storeAmount = MathHelper.clamp(2000f - cap.getValue(), 0, Math.min(20, plData.stats().getResourceValue(Enums.Resources.ENERGY)));
            cap.setValue(cap.getValue() + storeAmount);
            plData.stats().consumeResource(Enums.Resources.ENERGY, storeAmount, true);
            return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand));
        }
    }
    return super.onItemRightClick(world, player, hand);
}
Also used : CapabilityBaseMiscStackSerializable(net.tslat.aoa3.capabilities.interfaces.CapabilityBaseMiscStackSerializable) PlayerDataManager(net.tslat.aoa3.utils.player.PlayerDataManager)

Example 2 with CapabilityBaseMiscStackSerializable

use of net.tslat.aoa3.capabilities.interfaces.CapabilityBaseMiscStackSerializable in project Advent-Of-Ascension by Tslat.

the class ExpFlask method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    if (!world.isRemote) {
        CapabilityBaseMiscStackSerializable cap = getCapability(stack);
        if (cap == null || cap.getValue() <= 0)
            return ActionResult.newResult(EnumActionResult.FAIL, stack);
        player.setActiveHand(hand);
    }
    return ActionResult.newResult(EnumActionResult.PASS, stack);
}
Also used : CapabilityBaseMiscStackSerializable(net.tslat.aoa3.capabilities.interfaces.CapabilityBaseMiscStackSerializable) ItemStack(net.minecraft.item.ItemStack)

Example 3 with CapabilityBaseMiscStackSerializable

use of net.tslat.aoa3.capabilities.interfaces.CapabilityBaseMiscStackSerializable in project Advent-Of-Ascension by Tslat.

the class ExpFlask method onUsingTick.

@Override
public void onUsingTick(ItemStack stack, EntityLivingBase entity, int count) {
    if (!entity.world.isRemote && entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) entity;
        CapabilityBaseMiscStackSerializable cap = getCapability(stack);
        if (cap.getValue() > 0) {
            int xpChange = (int) Math.min(1 + ((int) (player.experienceLevel / 15f)), cap.getValue());
            player.addExperience(xpChange);
            cap.setValue(cap.getValue() - xpChange);
            if (cap.getValue() == 0)
                player.resetActiveHand();
        }
    }
}
Also used : CapabilityBaseMiscStackSerializable(net.tslat.aoa3.capabilities.interfaces.CapabilityBaseMiscStackSerializable) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 4 with CapabilityBaseMiscStackSerializable

use of net.tslat.aoa3.capabilities.interfaces.CapabilityBaseMiscStackSerializable in project Advent-Of-Ascension by Tslat.

the class EnergisticPickaxe method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    if (!world.isRemote) {
        CapabilityBaseMiscStackSerializable cap = getCapability(player.getHeldItem(hand));
        if (cap != null) {
            PlayerDataManager plData = PlayerUtil.getAdventPlayer(player);
            float storeAmount = MathHelper.clamp(2000f - cap.getValue(), 0, Math.min(20, plData.stats().getResourceValue(Enums.Resources.ENERGY)));
            cap.setValue(cap.getValue() + storeAmount);
            plData.stats().consumeResource(Enums.Resources.ENERGY, storeAmount, true);
            return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand));
        }
    }
    return super.onItemRightClick(world, player, hand);
}
Also used : CapabilityBaseMiscStackSerializable(net.tslat.aoa3.capabilities.interfaces.CapabilityBaseMiscStackSerializable) PlayerDataManager(net.tslat.aoa3.utils.player.PlayerDataManager)

Example 5 with CapabilityBaseMiscStackSerializable

use of net.tslat.aoa3.capabilities.interfaces.CapabilityBaseMiscStackSerializable in project Advent-Of-Ascension by Tslat.

the class EnergisticAxe method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    if (!world.isRemote) {
        CapabilityBaseMiscStackSerializable cap = getCapability(player.getHeldItem(hand));
        if (cap != null) {
            PlayerDataManager plData = PlayerUtil.getAdventPlayer(player);
            float storeAmount = MathHelper.clamp(2000f - cap.getValue(), 0, Math.min(20, plData.stats().getResourceValue(Enums.Resources.ENERGY)));
            cap.setValue(cap.getValue() + storeAmount);
            plData.stats().consumeResource(Enums.Resources.ENERGY, storeAmount, true);
            return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand));
        }
    }
    return super.onItemRightClick(world, player, hand);
}
Also used : CapabilityBaseMiscStackSerializable(net.tslat.aoa3.capabilities.interfaces.CapabilityBaseMiscStackSerializable) PlayerDataManager(net.tslat.aoa3.utils.player.PlayerDataManager)

Aggregations

CapabilityBaseMiscStackSerializable (net.tslat.aoa3.capabilities.interfaces.CapabilityBaseMiscStackSerializable)7 PlayerDataManager (net.tslat.aoa3.utils.player.PlayerDataManager)3 ItemStack (net.minecraft.item.ItemStack)2 AttributeModifier (net.minecraft.entity.ai.attributes.AttributeModifier)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 WorldServer (net.minecraft.world.WorldServer)1