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);
}
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);
}
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();
}
}
}
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);
}
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);
}
Aggregations