Jump to content

Recommended Posts

Posted

Hi there,

 

Is it possible to render text on item textures like this: http://i.imgur.com/Y0k4yEN.png (made in paint.net). Would this just be the case of using RenderGameOverlay and scaling down the text and making the pos the current hotbar slot? or is there a better way.

 

Thanks for your time.

 

Edit: I'm pretty sure RenderGameOverlay won't work because if I opened my inventory, that guiscreen(I think thats what it is anyway) would be a "higher" "layer". I would also like to draw text on items in my main inventory (Not just hotbar). My guess/assumption is it could be done by overlaying text on the item texture? not sure though.

 

Again, thanks if anyone checked out the thread.

Posted

1. If you want items to render like that for any possible gui (mod or not) then only way would be to ASM vanilla rendering methods.

 

2. If you want to do this per-gui, e.g be ONLY rendering like that in GameOverlay (normal game view) then you would have to use RenderGameOverlay and cancel hotbar rendering, then basically re-render it yourself using vanilla-like methods (I mean - literally copy rendering methods and edit them to display additional stuff).

 

3. You can try tricks like that for any known gui (inventory, creative, furnace, workbench, etc...) by replacing its GUI with OpenGui event (not sure naming), but that will always require you to remake stuff and will be incomatybile with other mods that do similar.

 

So basically - yeah: ASM (1) or not-fully-gratifying-simple-solution (2) or crazy-works-of-a-mad-man (3) (you don't want this).

 

EDIT

Additional note, since all that is not strongly backed by MC source. It might be that 2D item rendering methods are defined in instance object (meaning, they are not static). In that case you could replace (game startup) given object with your own extension that applies changes to some methods.

  Quote

1.7.10 is no longer supported by forge, you are on your own.

Posted

Thanks for the detailed reply!

 

So to sum up what I'm trying to do: I want to render the remaining durability "on top" of every item that the player has that has durability. I think making this work on EVERY gui is a little overkill for a small tweak (visually anyway) that this is, so I would probably be happy for it just to render when the player is looking at their own inventory. So the two situations would be:

 

1: Looking in your own inventory (not even player inventories attached to other guis).

2: Rendering the damage of items on the hotbar in the GameOverlay.

 

For situation 2, I pretty much know how to achieve that, would handling situation 1 be the same as your 3rd method?

 

Again, thanks for the time.

 

Edit: Wording

Posted

Solution 3 is writing new classes and replacing things when the player opens a GUI.  You'd have to write a new ChestGUI, new WorkbenchGUI, FurnaceGui, InventoryGUI, and so on.

 

Solution 1 will always show the additional text, doesn't matter who's gui, where it is, anything.

 

Just because of what you're trying to do, I actually would recommend looking into ASMing the item renderer function.  It's not only the simplest, but most effective.

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 1/9/2016 at 8:05 PM, Ernio said:

2. If you want to do this per-gui, e.g be ONLY rendering like that in GameOverlay (normal game view) then you would have to use RenderGameOverlay and cancel hotbar rendering, then basically re-render it yourself using vanilla-like methods (I mean - literally copy rendering methods and edit them to display additional stuff).

 

3. You can try tricks like that for any known gui (inventory, creative, furnace, workbench, etc...) by replacing its GUI with OpenGui event (not sure naming), but that will always require you to remake stuff and will be incomatybile with other mods that do similar.

 

2. Tells you quite well what to do (been there, done that).

 

3. Also tells you quite well what to do. To be more helpful: You want to extends GuiInventory.class and:

- Normally I'd say: "drawSlot" - but it's private, so that gives us bigger problems with hackier solutions:

- Override "public void drawScreen(int mouseX, int mouseY, float partialTicks)". drawScreen handles a lot of stuff, which also includes calling this thing:

for (int i1 = 0; i1 < this.inventorySlots.inventorySlots.size(); ++i1)
        {
            Slot slot = (Slot)this.inventorySlots.inventorySlots.get(i1);
            this.drawSlot(slot); /////////////////////////////////////////////// THIS THING!

            if (this.isMouseOverSlot(slot, mouseX, mouseY) && slot.canBeHovered())
            {
                this.theSlot = slot;
                GlStateManager.disableLighting();
                GlStateManager.disableDepth();
                int j1 = slot.xDisplayPosition;
                k1 = slot.yDisplayPosition;
                GlStateManager.colorMask(true, true, true, false);
                this.drawGradientRect(j1, k1, j1 + 16, k1 + 16, -2130706433, -2130706433);
                GlStateManager.colorMask(true, true, true, true);
                GlStateManager.enableLighting();
                GlStateManager.enableDepth();
            }
        }

 

So in your extending class you will want to literally copy drawScreen method from super class (mind that GuiInventory extends InventoryEffectRenderer extends GuiContainer which requires you to ALSO copy code from InventoryEffectRenderer#drawScreen).

 

Then on stage of calling this.drawSlot, you will simply make a call to custom-made method that will be (literally) a copy of vanilla method (the private one) with small change as to what to render (add your string rendering there).

 

As said - to actually replace Gui with another Gui you need to use proper event in which you will open your custom extension instead of vanilla. (search in client events, I don't remember exact event names, but somewhere aroung OpenGuiEvent).

 

That's it. Similar logic goes with (2.) - look how GuiIngame (GuiIngameForge? I don't remember now.) handles hotbar.

 

 

*Insta-read Draco's post*

Goddamit, well-said (true that). But alredy wrote that shit above so here it goes. :D

 

EDIT

Oh and P.S: If you decide to go with ASM - yeah, you want to manipulate GuiContainer#drawSlot or replace call to it in GuiContainer#drawScreen with call to your custom method. (I mean, that would do nicely for all containers in game :D, but there are more cases).

  Quote

1.7.10 is no longer supported by forge, you are on your own.

Posted

Thanks both of you for your help.

 

I have briefly looked into ASM and I feel it's a little overkill for what I'm trying to achieve (Also past my Java knowledge)

 

I decided to implement the feature on the GameOverlay: http://i.imgur.com/AduYrDh.png and it works great but with one problem. The text renders behind the items (You probably noticed that though). is there a way in the RenderGameOverlay to specify zIndex?

 

And again, thanks for everybodys help. It will be really helpful in future if I want to implement something that requires ASM.

Posted

You can use GlStateManager to translate the text like so:

 

GlStateManager.pushMatrix();
GlStateManager.translatef(0, 0, 50);
// draw text
GlStateManager.popMatrix();

 

To those whom it may concern, perhaps there could be an ItemStackRenderEvent fired every time an ItemStack is rendered, no matter what inventory.

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

Posted
  On 1/9/2016 at 11:13 PM, ADonkeyTaboggan said:

I have briefly looked into ASM and I feel it's a little overkill for what I'm trying to achieve (Also past my Java knowledge)

 

ASM is very powerful and very hard to think in terms of writing.  Everyone who does it inserts as extremely few bytes as possible, usually an INVOKE_VIRTUAL call to a static method that you can write in regular Java.

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 1/10/2016 at 1:30 AM, shadowfacts said:

To those whom it may concern, perhaps there could be an ItemStackRenderEvent fired every time an ItemStack is rendered, no matter what inventory.

 

I can't seem to find a reference to this event?

Posted
  On 1/10/2016 at 3:38 AM, ADonkeyTaboggan said:

  Quote

To those whom it may concern, perhaps there could be an ItemStackRenderEvent fired every time an ItemStack is rendered, no matter what inventory.

 

I can't seem to find a reference to this event?

 

That's because it doesn't exist. shadowfacts was suggesting it be added to Forge.

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

Oh whoops, I read his reply incorrectly. However it does sound like a great idea for rendering to all itemstacks easily.

 

Also using GlStateManager.translate solved my problem with the text rendering.. Thanks everyone for their input.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Without Network protocol fix mod, I get kicked with a Network Protocol error when on LAN. Also, both of these issues are caused by a Null Pointer Exception/Screen cannot be null in a "Client Bound Player Combat Kill Packet".
    • You need a new "items" folder at  resources/assets/yourmodid/ there you add for every item model a .json file with the exact item/block name and fill it like this if it's an item: { "model": { "type": "minecraft:model", "model": "yourmodid:item/youritem" } } and so if its a block: { "model": { "type": "minecraft:model", "model": "yourmodid:block/youritem" } } There is also a generator for it you can do namy crazy things with it which replaces the previous hard coded Item Properties implementaion method (Bow pulling animation for example). https://misode.github.io/assets/item/
    • Hello! I'm playing a modpack (custom made) with some friends, and we have the server running on BisectHosting. We encountered a bug with an entity from The Box Of Horrors mod, that would crash the game whenever someone nearby it would log in. We tried to fix it by: 1) Editing the player.dat files to change the location of the affected players (something I had done successfully previously) 2) Updating the version of the mod we had (0.0.8.2) to the latest alpha version (0.0.8.3 However, after doing both of those, none of us are able to join the server, and we get the following errors: Server side: https://pastebin.com/J5sc3VQN Client side: Internal Server Error (that's basically all I've gotten) Please help! I've tried restoring the player data to how it was before I made the changes (Bisect allows you to restore deleted files) and deleting all of my player data files and I still get the same error. Deleting Box Of Horrors causes the error: Failed to load datapacks, cannot continue with server load.
    • Hey there! I'm trying to create a simple mod for Forge 1.21.1 that adds a few custom banner patterns that don't require any banner pattern items. To be completely honest, this is my first time modding for Minecraft, so after setting up the project in Intellij, I copied the parts of the source code from this mod on CurseForge that dealt with adding and registering banner patterns, including the lang and banner_pattern .json files. From what I understand, to add a banner pattern that doesn't require a banner pattern item, I only needed to create the registries for each pattern like in here and then register it in the main java class like here on Line 54. Additionally, in the lang/en_us.json file, add in the names for each respective banner color, and in the data/minecraft/tags/banner_pattern/no_items_required.json file, add each banner pattern that does not require a banner pattern item to make a banner. The project is able to compile when loading in Forge which makes me assume that the file structure I have is correct, but on loading a Minecraft world, this error appears in console and the loom is subsequently blank. [Worker-Main-1/ERROR] [minecraft/TagLoader]: Couldn't load tag minecraft:no_item_required as it is missing following references: *lists every added entry in no_item_required.json* The message clearly states something went wrong regarding when trying to load in the registries from the mod, but I have no clue what could be wrong with the code I have. Attached below are screenshots of what I currently have. Java Main Class Banner Registry Class File Structure Error in Console upon loading a Minecraft world What the loom shows without minecraft:no_item_required    The original mod I copied still functions completely, so if anyone can figure out why the registries for the mod I'm making isn't working, that would be greatly appreciated!    
    • Please someone help me to know how can I fix this generation error in the trees! I already uninstalled and reinstalled several mods in my modpack and can't figure out what is causing it.    
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.