Jump to content

[1.9] Is it possible to spawn primer TNT without an EntityLivingBase?


Recommended Posts

Posted

To create Primed TNT I need to have an "Igniter"

 

EntityTNTPrimed(World worldIn, double x, double y, double z, EntityLivingBase igniter)

 

But what happens if I dont have an entity to associate the event with? This needs to be called within onNeighborBlockChange

 

How would I go around this?

Posted

If the TNT wasn't ignited by an entity, just pass

null

.

 

If you look at the doc comment or usages of

EntityTNTPrimed#getTntPlacedBy

(which returns the

EntityLivingBase

passed to the constructor), you'll see that

null

is a valid and expected return value.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Other project I was working with named a paramter like that as "[ x ]OrNull" e.g. "igniterOrNull" to make it clear that it was a parameter that wouldn't throw NPE if you passed in null, as it was intended to handle such things.

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

I didn't know about @Nullable. Not that I'm surprised.

 

The thing I was talking about was a function parameter not a return value on an interface.

 

For example, using the OP's method:

public void EntityTNTPrimed(World worldIn, double x, double y, double z, EntityLivingBase igniterOrNull) {...}

 

Is there a cleaner way of doing it there?  The point I was trying to raise is "MCP could note this kind of stuff and it would be useful." (I just don't care how)

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

Ah, neat.

Learn something new every day.

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

Poked around in C# (my Unity3D project) seeing if it had nullable parameters and it does, but for the simple types (e.g.

someMethod(int? nullableIntVar){}

) but not for the complex types, as complex objects can already be assumed to be capable of being null.  So the project I was working in that had a "[ x ]OrNull" parameter was justified in making the name indicate that the method could handle null values being pased vs. a "this object must not be null" method.

 

I should note that the .NET version for Unity is garbage: 2.0, updating to a newer version is under the "research" category on the roadmap.  I.e. not even on the "long term development" track yet, much less the next two releases.

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.