Jump to content

[1.12.2] How to make lava-proof boat?


lightningdragonx5

Recommended Posts

This is my first time trying this out, so of course I have no idea if my approach is correct or not.

 

I want to make a boat that is lava proof. Basically, like a vanilla boat but it can be used on lava without sinking or being instantly destroyed.

 

I tried copy-pasting all of the code from EntityBoat, replacing all instances of "EntityBoat" with my class name (e.g. "EntityLavaBoat"), making it immune to fire (this.isImmuneToFire = true), and changing the "checkInWater" method so that it also returns true if in lava. The resulting boat floats on lava (good) and is not destroyed by it (good). However, for some reason it can't be steered on either water or lava (pushing it seems to work but that's it). (Note that it can still be ridden, just not moved by the rider.)

 

I tried just extending EntityBoat but all of the fields and important methods in that class are private. The most I can do is make the boat immune to fire in the constructor, which does stop it from being destroyed by lava. However, that doesn't stop the boat from sinking.

 

How would I go about doing this properly?

Edited by lightningdragonx5
Link to comment
Share on other sites

Your problem is that steering takes place in the player class:

    /**
     * Adds a value to a mounted movement statistic field - by minecart, boat, or pig.
     */
    private void addMountedMovementStat(double p_71015_1_, double p_71015_3_, double p_71015_5_)
    {
        if (this.isRiding())
        {
            int i = Math.round(MathHelper.sqrt(p_71015_1_ * p_71015_1_ + p_71015_3_ * p_71015_3_ + p_71015_5_ * p_71015_5_) * 100.0F);

            if (i > 0)
            {
                if (this.getRidingEntity() instanceof EntityMinecart)
                {
                    this.addStat(StatList.MINECART_ONE_CM, i);
                }
                else if (this.getRidingEntity() instanceof EntityBoat)
                {
                    this.addStat(StatList.BOAT_ONE_CM, i);
                }
                else if (this.getRidingEntity() instanceof EntityPig)
                {
                    this.addStat(StatList.PIG_ONE_CM, i);
                }
                else if (this.getRidingEntity() instanceof AbstractHorse)
                {
                    this.addStat(StatList.HORSE_ONE_CM, i);
                }
            }
        }
    }

I'm guessing you could inherit from EntityBoat and do some fancy reflection thing to access the things even though they're private, but I don't know anything about reflection yet so I can't help you with that.

Link to comment
Share on other sites

You could probably just make an entity that extends entity boat, add "this.isImmuneToFire = true" to the constructor and add lava to everywhere water is referenced

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

14 hours ago, crackedEgg said:

you can look at this code I use to steer the parachute and adopt it to steer the boat

EntityParachute.java

ParachuteInputEvent.java

Thanks for this, helped a lot. Was able to get it to steer, so it functionally works just fine now.

 

11 hours ago, Cadiboo said:

You could probably just make an entity that extends entity boat, add "this.isImmuneToFire = true" to the constructor and add lava to everywhere water is referenced

Already tried this, it stopped the boat from being destroyed but it didn't let me steer initially until I added steering code (provided above). Once that was done it worked fine.

Edited by lightningdragonx5
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.