Jump to content

Recommended Posts

Posted (edited)

I just started with the Forge development, but I was wondering if there was a way, that specific items (Vanilla, non-Vanila) could be rendered twice as big when dropped.

 

What I mean with that is, if I could render dropped items 2x as big?

 

I've looked around, but haven't found anything about overriding renderers, so I'm guessing it would have to be done via lwjgl.

 

Also, how do I check for specific item type, something like `Material.OAK_LOG` from the Bukkit?

I'm currently checking it like this:

int id = Item.getIdFromItem(e.getEntityItem().getItem().getItem());
if(id == 770){
    // Dropped item is a player head!
}

But I'm unsure if it's the correct way to do it.

 

If this post should be split into two, let me know.

Edited by MGlolenstine
Posted
1 minute ago, diesieben07 said:

First of all, do not use numerical IDs. They will change! Use the constants in the Items class.

 

You would have to replace the entity for the items you want to change (EntityJoinWorldEvent) with a custom entity and then have a custom renderer for those entities.

I have no idea how I missed the `Items` class... ?‍♂️ Thanks for the tip!

 

And this event it an interesting one... I was looking for one that would be something like `ItemTossedEvent` or something similar, but I guess this is the way to go!

 

As far as the replacing goes, I'd have to "destroy" the entity and then spawn a new custom one on the same position?

Any hints on how I'd go about getting the same renderer?

 

Thanks for your help!

Posted (edited)
3 minutes ago, diesieben07 said:

EntityJoinWorldEvent is cancellable. If you cancel it, the entity will not be spawned. You can then immediately spawn your replacement in it's place.

Forge uses this to implement IForgeItem#createEntity, which allows items to override their own entity, check out ForgeInternalHandler#onEntityJoinWorld. 

 

The default item renderer is ItemRenderer. You can make your own class which extends it and simply adds the magnification.

This all seems nice :D Thanks for the answer!

 

Just one more question... I wanna do this on the client-side only... Will the replacement of the entity mess up with the pickup? Or do I just replace the item on the pickup?

I'm a still bit wary about these things, probably because I'm new :)

 

Edited by MGlolenstine
Posted (edited)
4 minutes ago, diesieben07 said:

There is no safe way to do this completely client-side, you'd have to override the entire item rendering, which might cause problems with other mods.

Hmm... Would there exist a way to override only one texture? Apparently you can change exactly what I want with a normal resource pack. I could add a resource pack that only changed one item to the mod and then just swap it so that only that one texture changes.

 

Do you think that this would be feasible?

Edited by MGlolenstine
Posted
Just now, diesieben07 said:

Mods are resource packs as well. They have all the features that resource packs also have.

Oh, then that's a lot more feasible than recoding the whole `ItemRenderer` ;)

I'll do that then! Thanks for your help!

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.