Jump to content

[1.15.2] Modifying Vanilla Mobs


Fuffles

Recommended Posts

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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"));
    }
}

Link to comment
Share on other sites

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.