Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.9] Adding numbers/bars/icons to item inventory icon.


Notunknown
 Share

Recommended Posts

I want to add additional information to the icon of an item - such as an electric bow which has a durability bar, energy bar (in blue) and a number showing the number of arrows left in the players inventory (which is colored if the next arrow used is a potion effect, or glows if the next arrow used is a glowing arrow).

 

That is an extreme example, but demonstrates what I am after. How can I do this?

Link to comment
Share on other sites

Item#showDurabilityBar

Item#getDurabilityForDisplay

Item#isDamageable

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.

Link to comment
Share on other sites

Item#showDurabilityBar

Item#getDurabilityForDisplay

Item#isDamageable

 

I know about those - but that is for the green durability bar. This is about adding a second durability bar above this. And some numbers above that, which are colored depending on non-tool specific information.

Link to comment
Share on other sites

EnderIO does simlar things (p455w0rd already said), but it uses ASM.

So, there's no way (besides ASMing

RenderItem.renderItemOverlayIntoGUI

) to do this.

 

@Forge: why forge hasn't added any hooks for this?

 

Well, EnderIO is for 1.7.10. That is two major versions (and an overhaul of rendering) ago.

Link to comment
Share on other sites

Well, EnderIO is for 1.7.10. That is two major versions (and an overhaul of rendering) ago.

 

EnderIO has an experimental 1.8.9 version, the source of which is available on GitHub.

 

I think the proper way to do this is with a custom

IModel

and

ItemOverrideList

, like Forge's

ModelDynBucket

.

 

For a limited number of variants (e.g. a single bar with 10 steps), you can do what RFTools does: manually create the textures and then use them with standard models.

 

Edit: Added a missing word.

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.

Link to comment
Share on other sites

Well, EnderIO is for 1.7.10. That is two major versions (and an overhaul of rendering) ago.

 

EnderIO has an experimental 1.8.9 version, the source of which is available on GitHub.

 

I think the proper way to do this is with a custom

IModel

and

ItemOverrideList

, like Forge's

ModelDynBucket

.

 

For a limited number of variants (e.g. a single bar with 10 steps), you can do what RFTools does: manually create the textures and then use them standard models.

 

The bar is the easy part (relatively), what about numbers (like an arrow counter on a bow)?

Link to comment
Share on other sites

The bar is the easy part (relatively), what about numbers (like an arrow counter on a bow)?

 

You'll need an

IModel

and

ItemOverrideList

as I said in my previous post. Probably an

ICustomModelLoader

as well.

 

You'll also need a texture for each digit so you can generate the

BakedQuad

s for the number.

 

I don't know that much about the rendering system, so I can't help you much more than this.

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.

Link to comment
Share on other sites

The bar is the easy part (relatively), what about numbers (like an arrow counter on a bow)?

 

You'll need an

IModel

and

ItemOverrideList

as I said in my previous post. Probably an

ICustomModelLoader

as well.

 

You'll also need a texture for each digit so you can generate the

BakedQuad

s for the number.

 

I don't know that much about the rendering system, so I can't help you much more than this.

 

Hmm. I was hoping that there would be a way around doing this, at least when it comes to adding extra bars/numbers.

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
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.

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I know this chat is outdated but can you guys help me with this because i'm having the same problem and i am unable to get into the files because i am on mac
    • You only ever set the block on the client. See HoneycombItem.useOn() for the "correct" logic.
    • public InteractionResult use(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand hand, BlockHitResult blockHitResult) { ItemStack itemstack = player.getItemInHand(hand); boolean successfullyDyed = false; if (level.isClientSide) { if(player.getAbilities().mayBuild == true){ if(itemstack.getItem() == Items.RED_DYE){ level.setBlock(blockPos,blockState.setValue(TYPE,0),0); successfullyDyed = true; } else if(itemstack.getItem() == Items.ORANGE_DYE){ level.setBlock(blockPos,blockState.setValue(TYPE,1),0); successfullyDyed = true; } else if(itemstack.getItem() == Items.YELLOW_DYE){ level.setBlock(blockPos,blockState.setValue(TYPE,2),0); successfullyDyed = true; } else if(itemstack.getItem() == Items.GREEN_DYE){ level.setBlock(blockPos,blockState.setValue(TYPE,3),0); successfullyDyed = true; } else if(itemstack.getItem() == Items.BLUE_DYE){ level.setBlock(blockPos,blockState.setValue(TYPE,4),0); successfullyDyed = true; } else if(itemstack.getItem() == Items.PURPLE_DYE){ level.setBlock(blockPos,blockState.setValue(TYPE,5),0); successfullyDyed = true; } else{ player.displayClientMessage(Component.translatable("block.thingamajigs.lava_lamp.wrong_dye"), true); return InteractionResult.CONSUME; } // update THIS block, no matter what happens if(successfullyDyed == true){ level.updateNeighborsAt(blockPos,this); level.playSound(null, blockPos, SoundEvents.DYE_USE, SoundSource.BLOCKS, 1.0F, 1.0F); return InteractionResult.SUCCESS; } if(!player.isCreative()) { if (itemstack.getCount() > 1) { itemstack.setCount(itemstack.getCount() - 1); } else { itemstack.setCount(0); } } } } return InteractionResult.CONSUME; } Hey there, I was working on a block's 'use' method, however the behavior is not quite what I wanted. In-game, the block will flash to the desired state, then revert back to the state it was in previously, and won't actually update. I was wondering if perhaps I was updating the block wrong? The only state I am trying to update is an Integer value called 'TYPE' from 0-5 by using dyes.
    • Your log doesn't show any mods getting loaded besides the core mods. Maybe you have that broken browser plugin that downloads jar files as .jar.zip ? Forge will only load mods if they end with .jar
    • I don't see a crash. I see the server successfully starting then shutting down 40 seconds later. [25Sep2022 02:07:36.925] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer/]: Done (16.794s)! For help, type "help" [25Sep2022 02:07:36.929] [Server thread/DEBUG] [net.minecraftforge.common.ForgeI18n/CORE]: Loading I18N data entries: 208 [25Sep2022 02:07:36.932] [Server thread/INFO] [net.minecraftforge.server.permission.PermissionAPI/]: Successfully initialized permission handler forge:default_handler [25Sep2022 02:08:15.588] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: Stopping the server Maybe you started the server from the command line then closed the window?
  • Topics

×
×
  • Create New...

Important Information

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