Jump to content

Creating a "hang to wall" item


Malharhak

Recommended Posts

Hi,

 

I've just finished some of the first forge tutorials to get started. Now the first mod I want to make is a simple thing : I have a few objects that I would like the player to be able to hang to walls (like paintings, but standard block size and no random texture).

 

So I looked a little bit at Minecraft's code and saw the EntityPainting and EntityHanging, but I have no idea how they actually work, the code is pretty obscure.

More specifically I didn't find anywhere in these classes where the texture is set. Also, I assume they are not created the same way a standard block so I'm not sure what I exactly need to do to make it work.

 

Edit : I also couldn't find where the actual painting Item is in the code. I initially wanted to look at how it's done but the only thing I found is the EntityPaiting, which I assume is the result of the painting item being placed.

 

Could anyone point me in the right direction to get started doing that ?

 

Thanks !

Link to comment
Share on other sites

Hi

 

There are a few links on this site that might help you with the background information.

http://greyminecraftcoder.blogspot.com.au/p/list-of-topics.html

especially - Important classes continued, and the section on Blocks and Items.

 

You have a few choices on how you can have a picture that you hang on the wall - you could make a transparent block with just one wall showing the object, you could have it in a picture frame like you can frame items, or you could use an entity like EntityPainting.

 

EntityPainting is rendered in RenderPainting.  The trick is that func_77010_a is turning each pixel of the texture into a little cube.  The texture comes from field_110807_a which is a single file containing all the pictures.  I think that's probably not what you want.

 

ItemHangingEntity is the item used by a painting.

 

What would I recommend?

Copy ItemHangingEntity to your own class, similarly for EntityPainting.  Adapt the methods to your new classes and the textures you want.  Create an EntityRenderer class for your EntityPainting and add custom render methods.  Register all your new classes.

It's fairly complicated, this tutorial might help

http://www.wuppy29.com/minecraft/modding-tutorials/wuppys-minecraft-forge-modding-tutorials-for-1-6-entity-part-1-registry/

and part2 as well.

 

-TGG

 

 

 

 

 

Link to comment
Share on other sites

If you want to make a block that clings to the side of something, you'll need to change its block bounds. If you override the setBlockBoundsBasedOnState method in Block, you can set block bounds for distinct blocks in the world by using setBlockBounds(minx, minY, minZ, maxX, maxY, maxZ)

 

Changing the block bounds will make your block less like a cube, depending on what you set them to.

 

"Thinking that coding is the nerdy IT guy at work rebooting your computer is like thinking that music is what happens when the piano tuner comes round." - Ed Rex

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.