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

Hey all,

I'd love to have a Creeper keep track of who ignited it (Flint & Steel), but to do that Im pretty sure I'd have to edit how Creepers work, right? Correct me if Im wrong here ofc, but if there aint any way, how would one exactly edit a mob's class?

Edited by Fuffles

  • Author
4 hours ago, ChampionAsh5357 said:

PlayerInteractEvent#EntityInteract with some clever usage of a capability on the creeper probably would work.

Im attempting that but I can not save who did it. I need to have the 'igniter' during the entity death event. For some reason Im unable to add a NBT tag for this

4 hours ago, Fuffles said:

For some reason Im unable to add a NBT tag for this

Would you happen to be able to show your code? This is a very general statement. You should only need to store the UUID of the player.

  • Author
7 hours ago, ChampionAsh5357 said:

Would you happen to be able to show your code? This is a very general statement. You should only need to store the UUID of the player.

 

Quote

public static void onPlayerInteractEvent(PlayerInteractEvent.EntityInteract interactEvent)
    {
        Entity interactee = interactEvent.getTarget();
        if (interactee instanceof CreeperEntity)
        {
            if (interactEvent.getItemStack().getItem() == Items.FLINT_AND_STEEL)
            {
                CompoundNBT nbts = interactee.writeWithoutTypeId(new CompoundNBT());
                nbts.putString("id", interactee.getEntityString());
                UUID interactor = PlayerEntity.getUUID(interactEvent.getPlayer().getGameProfile());
                nbts.putUniqueId("ignitorUUID", interactor);
                ((CreeperEntity)interactee).readAdditional(nbts);
            }
        }
    }
    
    public static void onKillEvent(LivingDeathEvent deathEvent)
    {
        Entity srcEnt = deathEvent.getSource().getTrueSource();
        if (srcEnt instanceof CreeperEntity)
        {
            //check if srcEnt has the tag with a value and then give an advancement to the 'ignitor';
        }
    }

Tried with multiple read/write fns but whenever I got the data per cmd I always got nothing

Edited by Fuffles

4 hours ago, Fuffles said:

CompoundNBT nbts = interactee.writeWithoutTypeId(new CompoundNBT());
                nbts.putString("id", interactee.getEntityString());
                UUID interactor = PlayerEntity.getUUID(interactEvent.getPlayer().getGameProfile());
                nbts.putUniqueId("ignitorUUID", interactor);
                ((CreeperEntity)interactee).readAdditional(nbts);

This is not a capability, the nbt data is only useful when saving or loading a world in this case. What you've done is literally nothing since the data will never be read.

  • Author
11 hours ago, ChampionAsh5357 said:

This is not a capability, the nbt data is only useful when saving or loading a world in this case. What you've done is literally nothing since the data will never be read.

Then how could I store it somehow in the creeper entity?

  • Author

hit a roadblock
Xz7R4vd.png

IgniterStorage code

Quote


[...]
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.Capability.IStorage;

public class IgniterStorage implements IStorage<IBasic>
{
    @Override
    public INBT writeNBT(Capability<IBasic> capability, IBasic instance, Direction side) 
    {
        CompoundNBT nbts = new CompoundNBT();
        nbts.putUniqueId("igniter", instance.getUUID());
        return nbts;
    }

    @Override
    public void readNBT(Capability<IBasic> capability, IBasic instance, Direction side, INBT nbt) 
    {
        instance.setUUID(((CompoundNBT)nbt).getUniqueId("igniter"));
    }
}

  • Author
10 minutes ago, diesieben07 said:

A Class is not an instance of Callable.

And if I may ask what do I replace it with exactly?

  • Author

... okay, I dont know what I expected as a response besides maybe something useful

Edited by Fuffles

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.