use of net.minecraft.util.ActionResult in project takumicraft by TNTModders.
the class ItemTakumiBoltStone method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
Vec3d vec3d = playerIn.getLookVec();
vec3d = vec3d.normalize().scale(5);
EntityLightningBolt bolt = new EntityLightningBolt(worldIn, playerIn.posX + vec3d.x, playerIn.posY + vec3d.y, playerIn.posZ + vec3d.z, false);
worldIn.addWeatherEffect(bolt);
worldIn.spawnEntity(bolt);
if (!playerIn.isCreative()) {
playerIn.getHeldItem(handIn).shrink(1);
}
return new ActionResult<>(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn));
}
use of net.minecraft.util.ActionResult in project takumicraft by TNTModders.
the class ItemTakumiChocolateBall method onItemRightClick.
/**
* Called when the equipped item is right clicked.
*/
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
ItemStack itemstack = playerIn.getHeldItem(handIn);
if (!playerIn.capabilities.isCreativeMode) {
itemstack.shrink(1);
}
worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!worldIn.isRemote) {
EntityTakumiChocolateBall entitysnowball = new EntityTakumiChocolateBall(worldIn, playerIn);
entitysnowball.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
worldIn.spawnEntity(entitysnowball);
}
playerIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult<>(EnumActionResult.SUCCESS, itemstack);
}
use of net.minecraft.util.ActionResult in project Random-Things by lumien231.
the class ItemDungeonChestGenerator method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
ItemStack par1ItemStack = par3EntityPlayer.getHeldItem(hand);
if (!par2World.isRemote && par3EntityPlayer.isSneaking()) {
NBTTagCompound nbt = par1ItemStack.getTagCompound();
if (nbt == null) {
par1ItemStack.setTagCompound(new NBTTagCompound());
par1ItemStack.getTagCompound().setInteger("tableIndex", 0);
} else {
int currentCategory = par1ItemStack.getTagCompound().getInteger("tableIndex");
if (currentCategory + 1 < LootTableList.getAll().size()) {
currentCategory++;
} else {
currentCategory = 0;
}
par1ItemStack.getTagCompound().setInteger("tableIndex", currentCategory);
}
return new ActionResult<>(EnumActionResult.SUCCESS, par1ItemStack);
}
return new ActionResult<>(EnumActionResult.FAIL, par1ItemStack);
}
use of net.minecraft.util.ActionResult in project Random-Things by lumien231.
the class ItemRedstoneActivator method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
ItemStack me = playerIn.getHeldItem(handIn);
int currentDurationIndex = getDurationIndex(me);
int nextDurationIndex;
if (playerIn.isSneaking()) {
nextDurationIndex = currentDurationIndex - 1;
nextDurationIndex = nextDurationIndex < 0 ? durations.length - 1 : nextDurationIndex;
} else {
nextDurationIndex = currentDurationIndex + 1;
nextDurationIndex = nextDurationIndex >= durations.length ? 0 : nextDurationIndex;
}
setDurationIndex(me, nextDurationIndex);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, me);
}
use of net.minecraft.util.ActionResult in project Random-Things by lumien231.
the class ItemSpectreKey method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
ItemStack par1ItemStack = par3EntityPlayer.getHeldItem(hand);
par3EntityPlayer.setActiveHand(hand);
return new ActionResult<>(EnumActionResult.SUCCESS, par1ItemStack);
}
Aggregations