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

Currently working on a mod that requires items which can target and interact with a player from far away. I used the giant items from Twilight Forest for reference but it doesn't seem to work. Posted my code for the item below, anyone got a clue on what's wrong with it since I'm not too sure what's wrong, spent a while working on it but not too sure what to fix. GitHub link to item: https://github.com/SwimmingTuna/LOTM/blob/master/src/main/java/net/swimmingtuna/lotm/item/custom/MindReading.java. A push in the right direction would be appreciated, thank you.

 

 

Mixins (the version of the item that is actually used in that code) are not supported in this forum.

If you want support/help you need to be using the forge and vanilla api.

 

On the java file you link, that doesn't work because your UUIDs are broken. Here's a simple java program to generate valid ones:

package whatever;

import java.util.UUID;

public class UUIDGen {
  public static final void main(String[] args) {
    System.out.println(UUID.randomUUID());
  }
}

When I change your item to use valid UUIDs, and make the callback somewhat more standard, it works for me.

static UUID BeyonderItemEntity = UUID.fromString("4bdfbc79-9e09-4111-8012-199025111273");
static UUID BeyonderItemBlock = UUID.fromString("487c4613-122f-44de-ae1e-70efb1e031d8");

-- snip --

    public InteractionResult interactLivingEntity(ItemStack pStack, Player pPlayer, LivingEntity pInteractionTarget, InteractionHand pUsedHand) {
        if (!pPlayer.level().isClientSide && pUsedHand == InteractionHand.MAIN_HAND) {
            pPlayer.sendSystemMessage(Component.literal("Interacted with " + pInteractionTarget.getClass().getSimpleName()));
        }
        return InteractionResult.sidedSuccess(pPlayer.level().isClientSide);
    }

Including being able to break blocks at extended range.

 

 

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

  • Author
On 1/5/2024 at 2:52 PM, warjort said:

Mixins (the version of the item that is actually used in that code) are not supported in this forum.

If you want support/help you need to be using the forge and vanilla api.

 

On the java file you link, that doesn't work because your UUIDs are broken. Here's a simple java program to generate valid ones:

package whatever;

import java.util.UUID;

public class UUIDGen {
  public static final void main(String[] args) {
    System.out.println(UUID.randomUUID());
  }
}

When I change your item to use valid UUIDs, and make the callback somewhat more standard, it works for me.

static UUID BeyonderItemEntity = UUID.fromString("4bdfbc79-9e09-4111-8012-199025111273");
static UUID BeyonderItemBlock = UUID.fromString("487c4613-122f-44de-ae1e-70efb1e031d8");

-- snip --

    public InteractionResult interactLivingEntity(ItemStack pStack, Player pPlayer, LivingEntity pInteractionTarget, InteractionHand pUsedHand) {
        if (!pPlayer.level().isClientSide && pUsedHand == InteractionHand.MAIN_HAND) {
            pPlayer.sendSystemMessage(Component.literal("Interacted with " + pInteractionTarget.getClass().getSimpleName()));
        }
        return InteractionResult.sidedSuccess(pPlayer.level().isClientSide);
    }

Including being able to break blocks at extended range.

 

 

Completely forgot to thank you for this, this helped so much, pretty much worked as intended, just had to make a lazy field and store the attribute in there to finally make it work. But thank you a bunch, really appreciated

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.