Jump to content

A Few Questions [Still Learning]


Lunarius Haberdash

Recommended Posts

I've been quickly picking up coding skill over the last few weeks of intense modding and learning, but there's a lot of simple things that I simply haven't had occasion to stumble on yet.

For instance:
1 - Say I wanted a block to cause an effect if something walked on top of it, where would I start with this?

2 - How can one disable the ability to place a block on top of another particular block?

Link to comment
Share on other sites

The general principles that diesieben07 is mentioning are:

 

1) If you want do to something in modding, start by looking at the closest things in vanilla minecraft and see how they accomplish it.

 

2) The approach you take often depends on whether you're making your entirely new thing (block, item, entity) or trying to change an existing one. For your own thing, you can often just extend classes, implement interfaces and override methods as you wish. For vanilla things you need to look for "hooks" such as:

a) Many classes have publicly accessible fields and methods. For example, entity AI is public so you can totally replace it if you wanted.

b) Forge has provided a lot of hooks, especially events but also registries and ore dictiionary, that allow you to intercept and replace vanilla behavior.

c) If you really don't have either of the above, you can use Java reflection to change the access scope of the vanilla fields and methods.

  • Like 1

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

11 hours ago, diesieben07 said:

Take a look at vanilla's magma block, which damages entities walking on it.

 

It depends. Is the block being placed added by your mod?

Oooo, that's right, I forgot about the Magma block.  Thank you!

 

And yes.

 

 

8 hours ago, jabelar said:

The general principles that diesieben07 is mentioning are:

 

1) If you want do to something in modding, start by looking at the closest things in vanilla minecraft and see how they accomplish it.

 

2) The approach you take often depends on whether you're making your entirely new thing (block, item, entity) or trying to change an existing one. For your own thing, you can often just extend classes, implement interfaces and override methods as you wish. For vanilla things you need to look for "hooks" such as:

a) Many classes have publicly accessible fields and methods. For example, entity AI is public so you can totally replace it if you wanted.

b) Forge has provided a lot of hooks, especially events but also registries and ore dictiionary, that allow you to intercept and replace vanilla behavior.

c) If you really don't have either of the above, you can use Java reflection to change the access scope of the vanilla fields and methods.

3

Well, this particular one is my own added block.  Reflection, I'll admit, have been a bit intimidating for me to consider at this point. I  know I have to look at it eventually, but not quite sure I'm there yet. I wasn't familiar with anything that behaved specifically the way I wanted in Vanilla, as you have to enter Cactus's bounding box before it'll damage you.  Magma, on the other hand, handles that nicely.

 

However, I'm not immediately familiar with anything that doesn't let you place a block on top of it either.

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.