Jump to content

Recommended Posts

Posted

For my next trick, I would like to add a new type of boat. Made from my netherworld rubies, it will be enchantable and able to sail upon lava.

 

Almost from the start, I have hit a snag. There's an enum within EntityBoat that looks like something I should extend so I don't need to copy-pasta an entire vanilla class.

 

Looking in EnumHelper, there's no public method specifically for adding a boat enum. The general-purpose addEnum method used by all public methods looks like my way out. However, at least in 1.10.2, it is private  :(

 

There are several directions I can go from here. I am leaning toward using reflection to access the private method inside EnumHelper. What do you guys do when faced with extending an enum not specifically supported by the public methods in EnumHelper?

 

Here's my stub of a new boat class:

public class RubyBoat extends ItemBoat {

  static final EntityBoat.Type TYPE;
  static final int ORDINAL;

  static {
    TYPE = EnumHelper.addEnum (EntityBoat.Type.class, "RUBY", String.class, "ruby");
    ORDINAL = TYPE.ordinal ();
  }

  public RubyBoat(String n) {
    super (TYPE);
    // TODO: Continue from here
  }
}

 

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted (edited)

I was confused for a bit then realized that this is the ItemBoat class not the EntityBoat class.

 

You have a custom entity. Your entity is different than the EntityBoat class and does not have types.

 

Your Item does not need to extend ItemBoat at all. Just make a new one. What the item class does with that type is pass it to EntityBoat#setBoatType() which your boat isn't going to be paying attention to. So you could either make your own item class that doesn't inherit ItemBoat or pass in literally any type you want your entity is going to ignore it anyway.

 

Edit:

Checking my own code when I did a custom minecart...

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/ores/OresBase.java#L161

 

...it's null, that field is never assigned a value.

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)
13 hours ago, Draco18s said:

Your entity is different than the EntityBoat class and does not have types.

So I should copy-pasta EntityBoat into a new class rather than trying to inject a new value into vanilla EntityBoat's enum? Perhaps my lava-going boat is different enough to need that, but I was hoping to re-use at least some of the code.

Edited by jeffryfisher

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

You don't need to copy anything at all. The value is meaningless for you.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
On 6/3/2017 at 10:32 AM, Draco18s said:

You don't need to copy anything at all.

I think I'll need an entity to sail on lava (and water). If I can't work with the vanilla EntityBoat, then I won't be able to extend it. That'll leave me copying most of its code, but then maybe I was destined to do that anyway.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

What part of "ignore the fuck out of that enum and pretend it doesn't exist" isn't making sense to you?

You can extend the vanilla classes left right and center and that enum can be ignored.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.