Jump to content

Recommended Posts

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.

 

 

Posted (edited)

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.

Posted
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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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