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.

Featured Replies

Posted

I have an item and block that interact with each other just fine. I want to add a little bit more functionality by giving the item another 'mode' aka change behavior if the player is sneaking. So I added an if else block into my code to see if player is sneaking, and then do stuff. However in game my debug code will not fire if I'm sneaking and clicking on the block with the item. When I switch to an empty hand, the debug code fires and then it crashes (because the clause with the logic for sneaking is supposed to be using a certain item, not an empty hand). So this is making me wonder if it is possible to right click a block, while sneaking, with a specific item?

 

All code is done within the block's onBlockActivated() method.

When you hold an item in your hand right clicking on a block effectively overrides the items onActivated with the blocks onActivated when you are sneaking the items onActivated effectively overrides the blocks onActivated.

 

So you want a sneak right click interaction you have to put that code in your items onActivated.

 

BTW the method probably isn't actually call onActivated but I don't recall the actual name right now.

Current Project: Armerger 

Planned mods: Light Drafter  | Ore Swords

Looking for help getting a mod off the ground? Coding  | Textures

  • Author

Method is onItemUse(), and it works perfectly, thanks!

 

As a side query, is there any benefit of having the original code in the blocks use method and the sneaking code in the items use method, compared to having all the code in the items use method? Besides for having cleaner looking code?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

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.