Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

cadendavidson

Members
  • Joined

  • Last visited

  1. Hello, I'm currently writing an event to allow a player to left-click on any block while holding a block of ice in their main hand, which converts the ice into 2-3 ice cube items from my mod. I'm using Minecraft/Forge version 'net.minecraftforge:forge:1.16.1-32.0.63'. My issue is that the event is essentially fired twice every time, once when the left-click button is pressed and once when it is released. Thus, the player always uses up two ice blocks instead of one. I first made sure the event wasn't being fired twice due to being executed on both the client and the server, as I included the following condition: if (!event.getWorld().isRemote) So the problem is definitely the press-release issue. I can't find anything in the event that specifies whether the click was a press or release. Any thoughts on how I can detect this, and rule out either one or the other? I've included the code for my event below. Thanks! @SubscribeEvent public static void makeIceCubes(PlayerInteractEvent.LeftClickBlock event) { if (!event.getWorld().isRemote) { PlayerEntity playerEntity = event.getPlayer(); ItemStack itemStack = playerEntity.getHeldItemMainhand(); Item heldItem = itemStack.getItem(); if (heldItem.equals(Items.ICE)) { itemStack.shrink(1); World world = event.getWorld(); int iceCubeCount = new Random().nextInt(3) + 1; ItemEntity itemEntity = new ItemEntity(world, playerEntity.getPosX(), playerEntity.getPosY(), playerEntity.getPosZ(), new ItemStack(ModItems.ICE_CUBE.get(), iceCubeCount)); itemEntity.setDefaultPickupDelay(); world.addEntity(itemEntity); } } }

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.