use of net.minecraft.util.ActionResult in project ICBM-Classic by BuiltBrokenModding.
the class ItemAntidote method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
ItemStack itemstack = playerIn.getHeldItem(handIn);
playerIn.setActiveHand(handIn);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);
}
use of net.minecraft.util.ActionResult in project ImmersiveEngineering by BluSunrize.
the class ItemBlockClothDevice method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
if (itemStackIn.getMetadata() != BlockTypes_ClothDevice.BALLOON.getMeta())
return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand);
if (playerIn.isSneaking())
increaseOffset(itemStackIn);
else {
Vec3d pos = playerIn.getPositionVector().addVector(0, playerIn.getEyeHeight(), 0).add(playerIn.getLookVec());
BlockPos bPos = new BlockPos(pos);
NBTTagCompound nbt = itemStackIn.getTagCompound();
int offset = nbt == null ? 0 : nbt.getByte("offset");
bPos = bPos.up(offset);
if (worldIn.isAirBlock(bPos)) {
if (!worldIn.isRemote) {
worldIn.setBlockState(bPos, IEContent.blockClothDevice.getStateFromMeta(BlockTypes_ClothDevice.BALLOON.getMeta()));
itemStackIn.stackSize--;
if (itemStackIn.stackSize <= 0)
playerIn.setHeldItem(hand, null);
}
return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
}
return new ActionResult(EnumActionResult.PASS, itemStackIn);
}
use of net.minecraft.util.ActionResult in project Railcraft by Railcraft.
the class ItemFilterBeeGenome method onItemRightClick.
@Optional.Method(modid = ForestryPlugin.FORESTRY_ID)
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
NBTTagCompound nbt = InvTools.getItemDataRailcraft(stack, "filter");
if (nbt != null) {
try {
EnumBeeChromosome chromosome = EnumBeeChromosome.SPECIES;
try {
chromosome = EnumBeeChromosome.valueOf(nbt.getString("chromosome"));
} catch (IllegalArgumentException ignored) {
}
chromosome = EnumTools.next(chromosome, EnumBeeChromosome.values());
nbt.setString("chromosome", chromosome.name());
} catch (Throwable throwable) {
Game.logErrorAPI(Mod.FORESTRY.modId, throwable, EnumBeeChromosome.class);
}
}
return new ActionResult<>(EnumActionResult.SUCCESS, stack.copy());
}
use of net.minecraft.util.ActionResult in project RecurrentComplex by Ivorforce.
the class ItemBlockSelectorFloating method onItemRightClick.
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
ItemStack itemStackIn = playerIn.getHeldItem(hand);
if (worldIn.isRemote) {
BlockPos position = getHoveredBlock(playerIn, getSelectionRange(itemStackIn));
sendClickToServer(itemStackIn, worldIn, playerIn, position);
}
return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
}
use of net.minecraft.util.ActionResult in project Railcraft by Railcraft.
the class ItemFluidContainer method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
RayTraceResult mop = rayTrace(world, player, false);
//noinspection ConstantConditions
if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) {
BlockPos pos = mop.getBlockPos();
if (!world.isBlockModifiable(player, pos))
return new ActionResult<>(EnumActionResult.FAIL, stack);
pos = pos.offset(mop.sideHit);
if (!player.canPlayerEdit(pos, mop.sideHit, stack))
return new ActionResult<>(EnumActionResult.FAIL, stack);
if (tryPlaceContainedLiquid(world, pos) && !player.capabilities.isCreativeMode) {
ItemStack empty = getContainerItem(stack);
if (InvTools.isEmpty(empty)) {
empty = stack.copy();
empty.stackSize = 0;
}
return new ActionResult<>(EnumActionResult.SUCCESS, empty);
}
}
return new ActionResult<>(EnumActionResult.PASS, stack);
}
Aggregations