Jump to content

[1.12.2] MultiPart Entity Interaction Help


Electric

Recommended Posts

By following the EnderDragon's format, I have successfully created a multipart entity, complete with several different bounding boxes. After a player right clicks the entity, I would like to be able to detect which bounding box is being interacted with, but I am not sure if this is possible. IEntityMultiPart does supply the following method, which detects the bounding box, but it is only triggered with a left click. Any ideas?

public boolean attackEntityFromPart(MultiPartEntityPart consolePart, DamageSource source, float damage)
Link to comment
Share on other sites

2 minutes ago, Electric said:

By following the EnderDragon's format, I have successfully created a multipart entity, complete with several different bounding boxes. After a player right clicks the entity, I would like to be able to detect which bounding box is being interacted with, but I am not sure if this is possible. IEntityMultiPart does supply the following method, which detects the bounding box, but it is only triggered with a left click. Any ideas?

Make your own class that extends MultiPartEntity part and override the interact method(processInitialInteract). And use that as the instance for your parts.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

I have tried the interact method, but I'm still not sure how to detect which part is being right clicked. Printing out items such as getCollisionBoundingBox and getEntityBoundingBox always return the same thing, regardless of which part on the entity is being clicked. I'm not sure how to differentiate between the boxes within the processInteract method.

Link to comment
Share on other sites

2 hours ago, Electric said:

I have tried the interact method, but I'm still not sure how to detect which part is being right clicked. Printing out items such as getCollisionBoundingBox and getEntityBoundingBox always return the same thing, regardless of which part on the entity is being clicked. I'm not sure how to differentiate between the boxes within the processInteract method.

Post your code

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Here is my Entity class:

Spoiler

public class EntityConsoleBrachacki extends EntityLiving implements IEntityMultiPart {

    protected final EntityAILookIdle aiLookIdle = new EntityAILookIdle(this);
    /** An array containing all body parts of this dragon */
    public MultiPartEntityPart[] consolePartArray;
    /** The head bounding box of a dragon */
    public MultiPartEntityPart consolePartRotor = new MultiPartEntityPart(this, "rotor", 1.0F, 3.0F);
    public MultiPartEntityPart consolePartFront = new MultiPartEntityPart(this, "front", 1.0F, 1.0F);
    public MultiPartEntityPart consolePartBack = new MultiPartEntityPart(this, "back", 1.0F, 1.0F);

    public static ITardisConsole getHandler(Entity entity) {
        if (entity.hasCapability(TARDIS_CONSOLE, EnumFacing.DOWN))
            return entity.getCapability(TARDIS_CONSOLE, EnumFacing.DOWN);
        return null;
    }

    public EntityConsoleBrachacki(World worldIn) {
        super(worldIn);
        this.consolePartArray = new MultiPartEntityPart[] {this.consolePartRotor, this.consolePartFront, this.consolePartBack};
        this.isImmuneToFire = true;
        setSize(4.0F, 1.5F);
        tasks.removeTask(aiLookIdle);

    }

//    @Override
//    public boolean shouldRenderInPass(int pass)
//    {
//        return pass == 0;
//    }

    @Override
    protected boolean canDespawn()
    {
        return false;
    }

    public void onLivingUpdate()
    {
        super.onLivingUpdate();

        this.consolePartRotor.onUpdate();
        this.consolePartRotor.setLocationAndAngles(this.posX + 1.5, this.posY, this.posZ, 0, 0);
    }

    public void onEntityUpdate() {
        super.onEntityUpdate();
    }

    /**
     * Returns the <b>solid</b> collision bounding box for this entity. Used to make (e.g.) boats solid. Return null if
     * this entity is not solid.
     *
     * For general purposes, use {@link #width} and {@link #height}.
     *
     * see getEntityBoundingBox
     * omg this updates in real time
     */
    @Nullable
    public AxisAlignedBB getCollisionBoundingBox()
    {
        return this.getEntityBoundingBox();

    }

    @Override
    public void onCollideWithPlayer(EntityPlayer entityIn) {}

    @Override
    public boolean hitByEntity(Entity entityIn) { return true; }

    @Override
    public boolean canBePushed() { return false; }

    @Override
    protected void collideWithEntity(Entity p_82167_1_) {}

    @Override
    protected void collideWithNearbyEntities() { }

    @Override
    public boolean processInteract(EntityPlayer player, EnumHand hand) {

        System.out.println(this.getCollisionBoundingBox());
        System.out.println(this.getEntityBoundingBox());
        System.out.println(this.getParts());
        
        return true;
    }

    /**
     * Makes the entity despawn if requirements are reached
     * I don't know if this is needed
     */
    @Override
    protected void despawnEntity()
    {
    }

    /**
     * Return the Entity parts making up this Entity (currently only for dragons)
     */
    @Override
    public Entity[] getParts()
    {
        return this.consolePartArray;
    }

    @Override
    public World getWorld() {
        return this.world;
    }

    /**
     * Run when one of the parts is hit by a player :D
     */
    @Override
    public boolean attackEntityFromPart(MultiPartEntityPart consolePart, DamageSource source, float damage) {
        System.out.println(consolePart.partName);
        return false;
    }
}

 

 

Link to comment
Share on other sites

15 minutes ago, Electric said:

Here is my Entity class:

Well you didn't do what I said.

 

12 hours ago, Animefan8888 said:

Make your own class that extends MultiPartEntity part and override the interact method(processInitialInteract). And use that as the instance for your parts.

 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

I'm slightly confused on what you mean by that. Do I need to have my entity extend MultiPartEntityPart or make a whole new class that extends it? And if its the latter, how am I supposed to reference it for my own entity's parts? I tried this but I am lost:

Spoiler

public class EntityTest extends MultiPartEntityPart {


    public EntityTest(IEntityMultiPart parent, String partName, float width, float height) {
        super(parent, partName, width, height);
    }

    @Override
    public boolean processInitialInteract(EntityPlayer player, EnumHand hand)
    {
        System.out.println(partName);
        return false;
    }

 

 

Link to comment
Share on other sites

11 minutes ago, Electric said:

And if its the latter, how am I supposed to reference it for my own entity's parts? I tried this but I am lost:

Yes I meant the latter. Instead of doing new MultiPartEntity do new EntityTest.

  • Thanks 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When i try to launch Minecraft Java 1.20.1 forge with mods (82 mods),on start it loaded all mods,but at end Java just crashed.  p.s i allocated 8GB ram for minecraft and i didn't runned another instance.Log file pp.s I use ATlauncher   Environment: Organising filesystem [24/04/2024 23:40:08 PM] ATLauncher Version: 3.4.36.3 [11ae0b2334c236e93ee8128de980952b2a1b8900] [24/04/2024 23:40:08 PM] App Arguments: ["--install-method=aur","--no-launcher-update"] [24/04/2024 23:40:08 PM] JVM Arguments: ["-Dawt.useSystemAAFontSettings=on","-Dswing.aatext=true"] [24/04/2024 23:40:08 PM] Java Version: Java 22 (22) [24/04/2024 23:40:08 PM] Java Path: /usr/lib/jvm/java-22-openjdk [24/04/2024 23:40:08 PM] 64 Bit Java: true [24/04/2024 23:40:08 PM] RAM Available: 14931MB [24/04/2024 23:40:08 PM] Launcher Directory: **USERSDIR** [24/04/2024 23:40:08 PM] GPU: IvyBridge GT2 [HD Graphics 4000] (Intel Corporation (0x8086)) unknown 256MB VRAM [24/04/2024 23:40:08 PM] CPU: Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz 4 cores/8 threads [24/04/2024 23:40:08 PM] Operating System: EndeavourOS (unknown (unknown) build 6.8.7-arch1-1) [24/04/2024 23:40:08 PM] Bitness: 64 [24/04/2024 23:40:08 PM] Uptime: 15889 [24/04/2024 23:40:08 PM] Manufacturer: GNU/Linux
    • If you have nvidia graphics, don't touch your amd drivers, otherwise it might fix it but keep running on integrated graphics, which will result in terrible performance. For nvidia graphics, you need to tell windows and nvidia control panel that anything Minecraft related (the launcher, java, etc...) should prefer high performance graphics so that it actually uses your nvidia gpu
    • In the ever-evolving landscape of technology, the rise of cryptocurrencies and digital assets has introduced both unparalleled opportunities and unprecedented challenges. As these digital currencies become increasingly prevalent, so too does the risk of theft and loss. Yet, amidst the complexity and uncertainty, there exists a beacon of hope: ADRIAN LAMO HACKER. Technology has indeed become more sophisticated and enhanced, presenting new challenges in the realm of asset recovery. However, just as any other currency can be stolen or lost, crypto and digital assets are not beyond redemption. With the right expertise and guidance, recovery is possible and achievable. Contact ADRIAN LAMO HACKER via the website: https://adrianlamohackpro.online/ , a trusted, honest, and certified agency specializing in the retrieval of stolen or lost digital assets. In my own experience, I found myself in dire straits after falling victim to cybercriminals who absconded with a significant portion of my crypto holdings. It was a daunting situation, but I refused to succumb to despair. Upon engaging ADRIAN LAMO HACKER, their professionalism, and integrity immediately struck me, as an unwavering commitment to their clients. They deeply understand blockchain technology and utilize advanced methodologies to trace and recover lost or stolen funds. Their approach is meticulous, their expertise unparalleled, and their results speak for themselves. In a matter of days, ADRIAN LAMO HACKER successfully traced and recovered over 90% of my stolen funds, a feat I once believed to be unattainable. Their fees were fair and transparent, and communication throughout the process was nothing short of excellent. They kept me informed every step of the way, providing reassurance and guidance when I needed it most. For anyone who has fallen victim to crypto theft or loss, I wholeheartedly recommend ADRIAN LAMO HACKER. They are not just experts in their field; they are guardians of justice in the digital realm. With their assistance, you can reclaim what's rightfully yours and emerge stronger than ever before. So, if you find yourself grappling with the devastation of lost or stolen digital assets, don't despair. Reach out to ADRIAN LAMO HACKER via website: https://adrianlamohackpro.online/  / Telegram: @ADRIANLAMOHACKERTECH and let them guide you toward a brighter tomorrow.
  • Topics

×
×
  • Create New...

Important Information

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