Java Code Examples for net.minecraft.util.EnumActionResult#PASS
The following examples show how to use
net.minecraft.util.EnumActionResult#PASS .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GTItemSprayCan.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public EnumActionResult onItemUseFirst(EntityPlayer playerIn, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand handIn) { if (!playerIn.isSneaking() && handIn == EnumHand.MAIN_HAND) { ItemStack playerStack = playerIn.getHeldItemMainhand(); NBTTagCompound nbt = StackUtil.getNbtData(playerStack); if (nbt.hasKey(COLOR)) { EnumDyeColor dye = EnumDyeColor.byDyeDamage(nbt.getInteger(COLOR)); if (colorBlock(world.getBlockState(pos), world, pos, null, dye)) { if (playerStack.getItemDamage() < playerStack.getMaxDamage()) { playerStack.damageItem(1, playerIn); if (!IC2.platform.isSimulating()) { IC2.audioManager.playOnce(playerIn, Ic2Sounds.painterUse); } } else { playerIn.setHeldItem(handIn, GTMaterialGen.get(GTItems.sprayCanEmpty)); if (!IC2.platform.isSimulating()) { playerIn.playSound(SoundEvents.ENTITY_ITEM_BREAK, 1.0F, 1.0F); } } return EnumActionResult.SUCCESS; } } } return EnumActionResult.PASS; }
Example 2
Source File: ItemSakuraDiamond.java From Sakura_mod with MIT License | 6 votes |
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack itemstack = playerIn.getHeldItem(handIn); RayTraceResult raytraceresult = this.rayTrace(worldIn, playerIn, false); if (raytraceresult != null && raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK && worldIn.getBlockState(raytraceresult.getBlockPos()).getBlock() == Blocks.END_PORTAL_FRAME) { return new ActionResult<ItemStack>(EnumActionResult.PASS, itemstack); } if (worldIn.isRemote) { int j = worldIn.rand.nextInt(2) * 2 - 1; int k = worldIn.rand.nextInt(2) * 2 - 1; double d0 = playerIn.getPosition().getX() + 0.25D * j; double d1 = playerIn.getPosition().getY() + 1D; double d2 = playerIn.getPosition().getZ() + 0.25D * k; double d3 = worldIn.rand.nextFloat() * j * 0.1D; double d4 = (worldIn.rand.nextFloat() * 0.055D) + 0.015D; double d5 = worldIn.rand.nextFloat() * k * 0.1D; SakuraMain.proxy.spawnParticle(SakuraParticleType.LEAVESSAKURA, d0, d1, d2, d3, -d4, d5); } return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack); }
Example 3
Source File: SoftHammerBehaviour.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { if (world.isRemote || world.isAirBlock(pos)) { return EnumActionResult.PASS; } ItemStack stack = player.getHeldItem(hand); TileEntity tileEntity = world.getTileEntity(pos); if (tileEntity != null) { IControllable controllable = tileEntity.getCapability(GregtechTileCapabilities.CAPABILITY_CONTROLLABLE, side); if (controllable != null) { if (controllable.isWorkingEnabled()) { controllable.setWorkingEnabled(false); } else { controllable.setWorkingEnabled(true); } GTUtility.doDamageItem(stack, cost, false); return EnumActionResult.SUCCESS; } } return EnumActionResult.PASS; }
Example 4
Source File: HandItem.java From pycode-minecraft with MIT License | 6 votes |
@Override public EnumActionResult onItemUse(ItemStack stackIn, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (world.isRemote) { return EnumActionResult.PASS; } if (stackIn.stackSize != 0) { float yaw = player.getHorizontalFacing().getHorizontalAngle(); NBTTagCompound compound = stackIn.getTagCompound(); HandEntity entity = new HandEntity(world, compound, pos.getX() + .5, pos.getY() + 1.0, pos.getZ() + .5, yaw); world.spawnEntityInWorld(entity); --stackIn.stackSize; return EnumActionResult.SUCCESS; } else { return EnumActionResult.FAIL; } }
Example 5
Source File: CoverPlaceBehavior.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { TileEntity tileEntity = world.getTileEntity(pos); ICoverable coverable = tileEntity == null ? null : tileEntity.getCapability(GregtechTileCapabilities.CAPABILITY_COVERABLE, null); if (coverable == null) { return EnumActionResult.PASS; } EnumFacing coverSide = ICoverable.rayTraceCoverableSide(coverable, player); if (coverable.getCoverAtSide(coverSide) != null || !coverable.canPlaceCoverOnSide(coverSide)) { return EnumActionResult.PASS; } if (!world.isRemote) { ItemStack itemStack = player.getHeldItem(hand); boolean result = coverable.placeCoverOnSide(coverSide, itemStack, coverDefinition); if (result && !player.capabilities.isCreativeMode) { itemStack.shrink(1); } return result ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; } return EnumActionResult.SUCCESS; }
Example 6
Source File: ItemPearlBelt.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@NotNull @Override public ActionResult<ItemStack> onItemRightClick(@NotNull World world, @NotNull EntityPlayer player, @NotNull EnumHand hand) { player.openGui(Wizardry.instance, 1, world, (int) player.posX, (int) player.posY, (int) player.posZ); return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand)); }
Example 7
Source File: WrenchBehaviour.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { if (!world.isRemote && !world.isAirBlock(pos)) { ItemStack stack = player.getHeldItem(hand); TileEntity tileEntity = world.getTileEntity(pos); if (tileEntity instanceof MetaTileEntityHolder) //machines handle wrench click manually return EnumActionResult.PASS; if (world.getBlockState(pos).getBlock().rotateBlock(world, pos, side)) { GTUtility.doDamageItem(stack, this.cost, false); return EnumActionResult.SUCCESS; } } return EnumActionResult.PASS; }
Example 8
Source File: ColorSprayBehaviour.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (!player.canPlayerEdit(pos, side, stack)) { return EnumActionResult.FAIL; } if (!tryPaintBlock(world, pos, side)) { return EnumActionResult.PASS; } useItemDurability(player, hand, stack, empty.copy()); return EnumActionResult.SUCCESS; }
Example 9
Source File: ItemBroom.java From Sakura_mod with MIT License | 5 votes |
/** * Called when a Block is right-clicked with this Item */ @Override public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack itemstack = player.getHeldItem(hand); if (!player.canPlayerEdit(pos.offset(facing), facing, itemstack)) { return EnumActionResult.FAIL; } IBlockState iblockstate = worldIn.getBlockState(pos); Block block = iblockstate.getBlock(); if (facing != EnumFacing.DOWN && worldIn.getBlockState(pos.up()).getMaterial() == Material.AIR && ((worldIn.getBlockState(pos).getMaterial() == Material.GROUND||worldIn.getBlockState(pos).getMaterial() ==Material.GRASS) && !(block instanceof BlockFarmland||block instanceof BlockGrassPath))) { IBlockState iblockstate1 = Blocks.GRASS_PATH.getDefaultState(); worldIn.playSound(player, pos, SoundEvents.BLOCK_GRASS_STEP, SoundCategory.BLOCKS, 1.2F, 1.2F); worldIn.playSound(player, pos, SoundEvents.BLOCK_GRASS_PLACE, SoundCategory.BLOCKS, 1.2F, 1.2F); if (!worldIn.isRemote) { worldIn.setBlockState(pos, iblockstate1, 11); itemstack.damageItem(1, player); } return EnumActionResult.SUCCESS; } return EnumActionResult.PASS; }
Example 10
Source File: ItemWrench.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (!world.isRemote && player.isSneaking()) { return EnumActionResult.SUCCESS; } return EnumActionResult.PASS; }
Example 11
Source File: ItemSyringe.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@Nonnull @Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (getItemUseAction(stack) == EnumAction.BOW) { if (world.isRemote && (Minecraft.getMinecraft().currentScreen != null)) { return new ActionResult<>(EnumActionResult.FAIL, stack); } else { player.setActiveHand(hand); return new ActionResult<>(EnumActionResult.PASS, stack); } } else return new ActionResult<>(EnumActionResult.FAIL, stack); }
Example 12
Source File: LighterBehaviour.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (!player.canPlayerEdit(pos, side, stack)) { return EnumActionResult.FAIL; } if (!tryIgniteBlock(world, pos.offset(side))) { return EnumActionResult.PASS; } useItemDurability(player, hand, stack, ItemStack.EMPTY); return EnumActionResult.SUCCESS; }
Example 13
Source File: IItemBehaviour.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
default EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { return EnumActionResult.PASS; }
Example 14
Source File: ItemRelayWire.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
@Override public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { IBlockState clickedState = worldIn.getBlockState(pos); Block block = clickedState.getBlock(); TileEntity currentTile = worldIn.getTileEntity(pos); ItemStack stack = player.getHeldItem(hand); if (currentTile instanceof IVSNodeProvider && !worldIn.isRemote) { ICapabilityLastRelay inst = stack .getCapability(ValkyrienSkiesControl.lastRelayCapability, null); if (inst != null) { if (!inst.hasLastRelay()) { inst.setLastRelay(pos); // Draw a wire in the player's hand after this } else { BlockPos lastPos = inst.getLastRelay(); double distanceSq = lastPos.distanceSq(pos); TileEntity lastPosTile = worldIn.getTileEntity(lastPos); // System.out.println(lastPos.toString()); if (!lastPos.equals(pos) && lastPosTile != null && currentTile != null) { if (distanceSq < VSConfig.relayWireLength * VSConfig.relayWireLength) { IVSNode lastPosNode = ((IVSNodeProvider) lastPosTile).getNode(); IVSNode currentPosNode = ((IVSNodeProvider) currentTile).getNode(); if (lastPosNode != null && currentPosNode != null) { if (currentPosNode.isLinkedToNode(lastPosNode)) { player.sendMessage( new TextComponentString("These nodes are already linked!")); } else if (currentPosNode.canLinkToOtherNode(lastPosNode)) { currentPosNode.makeConnection(lastPosNode); stack.damageItem(1, player); } else { // Tell the player what they did wrong player.sendMessage(new TextComponentString(TextFormatting.RED + I18n.format("message.vs_control.error_relay_wire_limit", VSConfig.networkRelayLimit))); } inst.setLastRelay(null); } } else { player.sendMessage( new TextComponentString(TextFormatting.RED + I18n.format("message.vs_control.error_relay_wire_length"))); inst.setLastRelay(null); } } else { inst.setLastRelay(pos); } } } } if (currentTile instanceof IVSNodeProvider) { return EnumActionResult.SUCCESS; } return EnumActionResult.PASS; }
Example 15
Source File: ItemSoybeans.java From TofuCraftReload with MIT License | 4 votes |
@Override public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack item = playerIn.getHeldItem(hand); if(item.getItem() == this &&!item.isEmpty()) { if (side != EnumFacing.UP) { return EnumActionResult.PASS; } else if (playerIn.canPlayerEdit(pos, side, item) && playerIn.canPlayerEdit(pos.up(), side, item)) { IBlockState soil = worldIn.getBlockState(pos); if (soil != null && worldIn.isAirBlock(pos.up())) { boolean isPlanted = false; if (soil.getBlock() == BlockLoader.TOFUFARMLAND||soil.getBlock().canSustainPlant(soil, worldIn, pos, EnumFacing.UP, this)) { worldIn.setBlockState(pos.up(), BlockLoader.SOYBEAN.getDefaultState()); isPlanted = true; } else if (soil.getBlock() == Blocks.WOOL) { worldIn.setBlockState(pos.up(), BlockLoader.SPROUTS.getDefaultState()); isPlanted = true; } /*TcAchievementMgr.achieve(playerIn, Key.sproutPlanting);*//* }*/ if (isPlanted) { item.shrink(1); return EnumActionResult.SUCCESS; } else { return EnumActionResult.PASS; } } else { return EnumActionResult.PASS; } //return EnumActionResult.PASS; } return EnumActionResult.PASS; } else { return EnumActionResult.PASS; } }
Example 16
Source File: CoverBehavior.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
public EnumActionResult onScrewdriverClick(EntityPlayer playerIn, EnumHand hand, CuboidRayTraceResult hitResult) { return EnumActionResult.PASS; }
Example 17
Source File: ItemRiceSeeds.java From Sakura_mod with MIT License | 4 votes |
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack itemstack = playerIn.getHeldItem(handIn); RayTraceResult raytraceresult = this.rayTrace(worldIn, playerIn, true); if (raytraceresult == null) { return new ActionResult<ItemStack>(EnumActionResult.PASS, itemstack); } if (raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK) { BlockPos blockpos = raytraceresult.getBlockPos(); if (!worldIn.isBlockModifiable(playerIn, blockpos) || !playerIn.canPlayerEdit(blockpos.offset(raytraceresult.sideHit), raytraceresult.sideHit, itemstack)) { return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemstack); } BlockPos blockpos1 = blockpos.up(); IBlockState iblockstate = worldIn.getBlockState(blockpos); if (iblockstate.getMaterial() == Material.WATER && iblockstate.getValue(BlockLiquid.LEVEL).intValue() == 0 && worldIn.isAirBlock(blockpos1)) { // special case for handling block placement with water lilies net.minecraftforge.common.util.BlockSnapshot blocksnapshot = net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(worldIn, blockpos1); worldIn.setBlockState(blockpos1, BlockLoader.RICECROP.getDefaultState()); if (net.minecraftforge.event.ForgeEventFactory.onPlayerBlockPlace(playerIn, blocksnapshot, net.minecraft.util.EnumFacing.UP, handIn).isCanceled()) { blocksnapshot.restore(true, false); return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemstack); } worldIn.setBlockState(blockpos1, BlockLoader.RICECROP.getDefaultState(), 11); if (playerIn instanceof EntityPlayerMP) { CriteriaTriggers.PLACED_BLOCK.trigger((EntityPlayerMP) playerIn, blockpos1, itemstack); } if (!playerIn.capabilities.isCreativeMode) { itemstack.shrink(1); } playerIn.addStat(StatList.getObjectUseStats(this)); worldIn.playSound(playerIn, blockpos, SoundEvents.BLOCK_WATERLILY_PLACE, SoundCategory.BLOCKS, 1.0F, 1.0F); return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack); } } return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemstack); }
Example 18
Source File: ItemNigari.java From TofuCraftReload with MIT License | 4 votes |
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { if (worldIn.isRemote) return new ActionResult<ItemStack>(EnumActionResult.PASS, ItemStack.EMPTY); RayTraceResult var4 = this.rayTrace(worldIn, playerIn, true); ItemStack itemStackIn = playerIn.getHeldItem(handIn); if (var4 == null) { return new ActionResult<ItemStack>(EnumActionResult.PASS, itemStackIn); } else { if (var4.typeOfHit == RayTraceResult.Type.BLOCK) { BlockPos targetPos = var4.getBlockPos(); Block var11 = worldIn.getBlockState(targetPos).getBlock(); Block var13 = null; if (var11 == BlockLoader.SOYMILK) { var13 = BlockLoader.KINUTOFU; } else if (var11 == BlockLoader.SOYMILKHELL) { var13 = BlockLoader.TOFUHELL; } else if (var11 == BlockLoader.ZUNDASOYMILK) { var13 = BlockLoader.TOFUZUNDA; } if (var13 != null) { worldIn.playSound(playerIn, targetPos.add(0.5, 0.5, 0.5), var13.getSoundType(var13.getDefaultState(), worldIn, targetPos, playerIn).getBreakSound(), SoundCategory.BLOCKS, (var13.getSoundType(var13.getDefaultState(), worldIn, targetPos, playerIn).getVolume() + 1.0F) / 2.0F, var13.getSoundType(var13.getDefaultState(), worldIn, targetPos, playerIn).getPitch() * 0.8F); worldIn.setBlockState(targetPos, var13.getDefaultState()); if (!playerIn.capabilities.isCreativeMode) { itemStackIn.shrink(1); ItemStack container = new ItemStack(this.getContainerItem()); if (itemStackIn.getCount() <= 0) { return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, container); } if (!playerIn.inventory.addItemStackToInventory(container)) { playerIn.dropItem(container, false); } } } } return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn); } }
Example 19
Source File: ItemComponentBox.java From Cyberware with MIT License | 4 votes |
@Override public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) { playerIn.openGui(Cyberware.INSTANCE, 6, worldIn, 0, 0, 0); return new ActionResult(EnumActionResult.PASS, itemStackIn); }
Example 20
Source File: ItemRiceSeed.java From TofuCraftReload with MIT License | 4 votes |
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack itemstack = playerIn.getHeldItem(handIn); RayTraceResult raytraceresult = this.rayTrace(worldIn, playerIn, true); if (raytraceresult == null) { return new ActionResult<ItemStack>(EnumActionResult.PASS, itemstack); } else { if (raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK) { BlockPos blockpos = raytraceresult.getBlockPos(); if (!worldIn.isBlockModifiable(playerIn, blockpos) || !playerIn.canPlayerEdit(blockpos.offset(raytraceresult.sideHit), raytraceresult.sideHit, itemstack)) { return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemstack); } BlockPos blockpos1 = blockpos.up(); IBlockState iblockstate = worldIn.getBlockState(blockpos); if (iblockstate.getMaterial() == Material.WATER && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.isAirBlock(blockpos1)) { // special case for handling block placement with water lilies net.minecraftforge.common.util.BlockSnapshot blocksnapshot = net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(worldIn, blockpos1); worldIn.setBlockState(blockpos1, BlockLoader.RICECROP.getDefaultState()); if (net.minecraftforge.event.ForgeEventFactory.onPlayerBlockPlace(playerIn, blocksnapshot, net.minecraft.util.EnumFacing.UP, handIn).isCanceled()) { blocksnapshot.restore(true, false); return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemstack); } worldIn.setBlockState(blockpos1, BlockLoader.RICECROP.getDefaultState(), 11); if (playerIn instanceof EntityPlayerMP) { CriteriaTriggers.PLACED_BLOCK.trigger((EntityPlayerMP)playerIn, blockpos1, itemstack); } if (!playerIn.capabilities.isCreativeMode) { itemstack.shrink(1); } playerIn.addStat(StatList.getObjectUseStats(this)); worldIn.playSound(playerIn, blockpos, SoundEvents.BLOCK_WATERLILY_PLACE, SoundCategory.BLOCKS, 1.0F, 1.0F); return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack); } } return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemstack); } }