Jump to content

Recommended Posts

Posted

Hi,

I am working on a battery icon on a screen that displays the amount of energy is stored in the related BlockEntity.

To do this I made a widget and overrided the render method to fit my needs. 

I use a separate texture so I don't have to include it in every texture for screens that are supposed to be using it.
My problem is that instead of rendering the texture in the scale of itself it renders in the scale of the background (AKA the gui for that menu without the display).
I'm not sure what causes this or how to deal with it.
Looking at how it gets blitted the code for drawing it is working as intended.

 

I will provide some images and code below for context

https://imgur.com/a/dqHJaZS
The first Image is the texture file for reference
The second image is a screenshot from ingame (The blocky mess next to the arrow is what is supposed to be the display)

 

The render method 

@Override
    public void render(@NotNull PoseStack stack, int MouseX, int MouseY, float p_94672_){
        RenderSystem.setShader(GameRenderer::getPositionTexShader);
        RenderSystem.setShaderTexture(0,RL);
        Minecraft.getInstance().getTextureManager().bindForSetup(RL);

        RenderSystem.clearColor(1.0F, 1.0F, 1.0F, 1.0F);

        //blits the battery Background
        Minecraft.getInstance().screen.blit(stack,x,y,0,0,this.width,this.height);

        int energy = menu.getEnergy();
        int maxEnergy = menu.getMaxEnergy();
        int chargeLevel = (int) Math.ceil((float)energy/maxEnergy*16);

        //blits the charge
        Minecraft.getInstance().screen.blit(stack,x+2,y+18-chargeLevel,this.width+(chargeLevel/4-1)*9,16-chargeLevel,9,chargeLevel);


    }

The where the widget gets added (In the screen class)

@Override
public void render(@NotNull PoseStack stack, int mouseX, int mouseY, float Ptick) {
	this.addRenderableWidget(new BatteryDisplay(this.getGuiLeft()+82,this.getGuiTop()+37,this.menu));
	//...
}

Thanks for the help!

Posted (edited)

You say you have different textures and yet you only setShaderTexture() once?

Other parts of your code look confused as well. e.g.

Why are you doing that bindForSetup()

You can replace Minecraft.getInstance().screen.blit() with this.blit() - the current minecraft screen is your Screen instance.

You should add widgets in your init(), but I don't see any calls to super.render() which is where the widgets would get drawn. See Screen.render()

I also don't see a call to renderBackground()

 

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted
  On 9/1/2022 at 11:33 PM, warjort said:

You say you have different textures and yet you only setShaderTexture() once?

Other parts of your code look confused as well. e.g.

Why are you doing that bindForSetup()

You can replace Minecraft.getInstance().screen.blit() with this.blit() - the current minecraft screen is your Screen instance.

You should add widgets in your init(), but I don't see any calls to super.render() which is where the widgets would get drawn. See Screen.render()

I also don't see a call to renderBackground()

 

Expand  

I probably needed to explain some more things because, yeah, from reading my post it is quite confusing.

  • I called the setShaderTexture() twice. Once in the renderBackground() method for the screen and once for the render method for the display class.
  • I did bindForSetup because I didn't know what it did and I saw it being used in another widget so I thought it would be useful (I removed it now though!).
  • I used this.blit() initially but because it wasn't working I thought somehow Minecraft.getInstance().screen.blit() would be something different so I just tried that as a solution (also replaced that now).
  • I now added the widget in the init method for the screen and the super.render() method was already being called in the screen render method however I replaced it in with "//..." because otherwise the post would be pretty long as I'm doing a lot of other things in the method as well. Looking back at it that wasn't very helpful.
  • Just like previously renderBackground() was also being called but I removed it from the post

So now to be clear and state the actual problem. Everything is working completely as intended except that the texture is render in an improper scale

(1 pixel correlates for many more when rendered for some reason)


Thanks again

Posted

Can you put your code on github so we can see all the relevant context.  It should compile and run.

You don't even show your updated code, let alone the other relevant code you missed from your first post.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted
  On 9/2/2022 at 6:38 PM, warjort said:

Can you put your code on github so we can see all the relevant context.  It should compile and run.

You don't even show your updated code, let alone the other relevant code you missed from your first post.

Expand  

Here you go. Github

Posted

Your issue is you are using the blit method designed for 256x256 images.

Since yours is a "nonstandard" size, you need to tell it the size of the image, e.g.

this.blit(stack,x,y,0,0,this.width,this.height, 49, 20);

 

  • Thanks 1

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted

Usually, textures should be at the 'minimum' size of 256x256, keeping the space when the content is too small, and expanding only when the content is too large to fit.

There is no inherent benefit to sizing textures to exactly fit their contents. It may even be a hindrance if you choose to add more to the texture in the future, as you would need to re-adjust the dimensions in the blit call, and it would break that texture if modified by a resource pack.

  • Thanks 1

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

    • Unlock an Instant $100 OFF with the Exclusive Temu Coupon Code ALF401700! Whether you're a first-time shopper or a loyal returning customer, this verified Temu promo code ALF401700 is your gateway to incredible savings on thousands of products. By applying code ALF401700 at checkout, youโ€™ll receive a guaranteed $100 discount on your purchase, plus enjoy additional savings of up to 50% OFF on selected items. This special coupon is designed to maximize your discounts, making your shopping experience at Temu more affordable than ever. Why Choose Temu Coupon Code ALF401700 in 2025? First-Time Shoppers: Score a massive 50% off your first order plus a flat $100 OFF using promo code ALF401700. Returning Customers: Donโ€™t miss out! Use ALF401700 to claim a generous $100 OFF on your next purchase. Massive Clearance Sales: With Temuโ€™s ongoing 2025 clearance events, this code unlocks up to 90% OFF on select deals. Global Reach: Whether you shop from the USA, Canada, Europe, Asia, or beyond, Temu coupon ALF401700 works worldwide. 2025โ€™s Top Temu Discounts Powered by ALF401700: Temu $100 OFF New User Promo โ€” ALF401700 Temu Exclusive Discount for Returning Shoppers โ€” ALF401700 Memorial Day Special: $100 OFF Using ALF401700 Country-Specific Offers: USA, Japan, Mexico, Chile, Colombia, Malaysia, Philippines, South Korea, Saudi Arabia, Qatar, Germany, France, Israel โ€” all accept code ALF401700 Free Gift Unlocks โ€” Apply ALF401700 Without Referrals Stackable Bundles: Combine ALF401700 for $100 OFF with up to 50% sitewide discounts 100% OFF Flash Deals during Temu Events with ALF401700 How to Redeem Your Temu Coupon Code ALF401700: Visit the official Temu website or open the Temu app. Select your favorite products and add them to your cart. Enter the promo code ALF401700 in the discount code field at checkout. Watch your total instantly drop by $100 and enjoy any additional percentage discounts automatically applied. Complete your order and enjoy huge savings! Key Benefits of Using ALF401700 Temu Promo Code: Verified and Tested: This code is active and guaranteed to work for 2025. Applicable for All Users: New or existing customers get to enjoy the perks. Works Across Multiple Countries: Perfect for international shoppers. No Minimum Purchase Required: Use it anytime to save $100. Perfect for Big and Small Orders: Whether buying essentials or splurging, save big with ALF401700. Temu Coupon Code ALF401700 by Region: ๐Ÿ‡บ๐Ÿ‡ธ United States โ€” Save $100 OFF ๐Ÿ‡จ๐Ÿ‡ฆ Canada โ€” Instant $100 Discount ๐Ÿ‡ฌ๐Ÿ‡ง United Kingdom โ€” Exclusive $100 OFF ๐Ÿ‡ฏ๐Ÿ‡ต Japan โ€” Hot $100 OFF Deal ๐Ÿ‡ฒ๐Ÿ‡ฝ Mexico โ€” Get $100 OFF ๐Ÿ‡จ๐Ÿ‡ฑ Chile โ€” 2025 Special Discount ๐Ÿ‡ฐ๐Ÿ‡ท South Korea โ€” Massive Savings ๐Ÿ‡ต๐Ÿ‡ญ Philippines โ€” Extra $100 OFF ๐Ÿ‡ธ๐Ÿ‡ฆ Saudi Arabia โ€” Verified Promo ๐Ÿ‡ถ๐Ÿ‡ฆ Qatar โ€” Top Discount ๐Ÿ‡ฉ๐Ÿ‡ช Germany โ€” Exclusive Savings ๐Ÿ‡ซ๐Ÿ‡ท France โ€” Coupon Works ๐Ÿ‡ฎ๐Ÿ‡ฑ Israel โ€” Huge Discount Final Words: Make 2025 your year of unbeatable savings with the Temu coupon code ALF401700. Act now to claim your $100 OFF plus unlock additional discounts on thousands of products. Whether shopping for fashion, electronics, home essentials, or gifts, this is the best Temu promo code to maximize your budget. Download the Temu app today, enter ALF401700 at checkout, and watch the savings roll in!
    • Verified users can now unlock a $100 OFF Temu Coupon Code using the verified promo code [ALF401700]. This Temu $100 OFF code works for both new and existing customers and can be used to redeem up to 50% off your next order. Our exclusive Temu coupon code [ALF401700] delivers a flat $100 OFF on top of existing deals. First-time customers using code ALF401700 can save an extra 100% off select items. Returning users also qualify for an automatic $100 OFF discount just by applying this code at checkout. But waitโ€”thereโ€™s more. With our Temu coupon codes for 2025, users can score up to 90% OFF on clearance items. Whether youโ€™re shopping in the USA, Canada, UK, or elsewhere, Temu promo code ALF401700 unlocks extra discounts tailored to your account. Some users are saving 100% on items using this 2025 Temu promo code. ๐Ÿ”ฅ Temu Coupon Highlights Using Code [ALF401700]: Temu new user code โ€“ ALF401700: Save 50% off your first order + $100 OFF. Temu promo for existing customers โ€“ ALF401700: Enjoy flat $100 OFF instantly. Global availability: Works in the USA, UK, Canada, Germany, France, Japan, Chile, Colombia, Malaysia, Mexico, South Korea, Philippines, Saudi Arabia, Qatar, Pakistan, and more. Top 2025 Coupon Deal: Get $200 OFF plus 100% bonus discounts using code ALF401700. Top-Ranked Temu Deals for 2025 (Coupon Code: ALF401700): โœ… Temu $100 OFF Memorial Day Sale โ€” Use ALF401700 โœ… Temu First Order Coupon โ€” Use ALF401700 for 50% + $100 OFF โœ… Temu USA Coupon Code โ€” Save $100 instantly with ALF401700 โœ… Temu Japan, Germany, Chile Codes โ€” All support ALF401700 โœ… Temu Reddit Discount โ€“ $100 OFF: Valid for both new and old users โœ… Temu Coupon Bundle 2025 โ€” $100 OFF + up to 50% slash โœ… 100% OFF Free Gift Code โ€” Use ALF401700, no invite needed โœ… Temu Sign-Up Bonus Promo โ€” Get a welcome $100 OFF instantly โœ… Free Temu Code for New Users โ€” Use ALF401700, no referral required  Temu Clearance Codes 2025 โ€” Use ALF401700 for 85โ€“100% discounts Why ALF401700 is the Best Temu Code in 2025 Using Temu code ALF401700 is your ticket to massive savings, free shipping, first-order discounts, and stackable coupon bundles. Whether you're browsing electronics, fashion, home goods, or beauty products, this verified Temu discount code offers real savingsโ€”up to 90% OFF + $100 OFF on qualified orders. ๐Ÿ’ก Pro Tip: Apply ALF401700 during checkout in the Temu app or website to activate your instant $100 discount, even if youโ€™re not a new user. Temu $100 OFF Code by Country (All Use ALF401700): ๐Ÿ‡บ๐Ÿ‡ธ Temu USA โ€“ ALF401700 ๐Ÿ‡ฏ๐Ÿ‡ต Temu Japan โ€“ ALF401700 ๐Ÿ‡ฒ๐Ÿ‡ฝ Temu Mexico โ€“ ALF401700 ๐Ÿ‡จ๐Ÿ‡ฑ Temu Chile โ€“ ALF401700 ๐Ÿ‡จ๐Ÿ‡ด Temu Colombia โ€“ ALF401700 ๐Ÿ‡ฒ๐Ÿ‡พ Temu Malaysia โ€“ ALF401700 ๐Ÿ‡ต๐Ÿ‡ญ Temu Philippines โ€“ ALF401700 ๐Ÿ‡ฐ๐Ÿ‡ท Temu Korea โ€“ ALF401700 ๐Ÿ‡ต๐Ÿ‡ฐ Temu Pakistan โ€“ ALF401700 ๐Ÿ‡ซ๐Ÿ‡ฎ Temu Finland โ€“ ALF401700 ๐Ÿ‡ธ๐Ÿ‡ฆ Temu Saudi Arabia โ€“ ALF401700 ๐Ÿ‡ถ๐Ÿ‡ฆ Temu Qatar โ€“ ALF401700 ๐Ÿ‡ซ๐Ÿ‡ท Temu France โ€“ ALF401700 ๐Ÿ‡ฉ๐Ÿ‡ช Temu Germany โ€“ ALF401700 ๐Ÿ‡ฎ๐Ÿ‡ฑ Temu Israel โ€“ ALF401700 Temu Coupon Code [ALF401700] Summary for SEO: Temu $100 OFF Code  Temu First Order Discount Code 2025  Temu Verified Promo Code ALF401700  Temu 50% OFF + $100 Bonus  Temu 100% OFF Code 2025  Temu App Promo ALF401700  Temu Working Discount Code 2025 
    • Hey there, nothing to do with the code, I am just suggesting you use Intelij IDEA. Trust me, it is the best.
    • Hey there, nothing to do with the code, I am just suggesting you use Intelij IDEA. Trust me, it is the best.
    • You can check the config of Geckolib and Mowzie's Mobs - maybe there is a way to disable some render features
  • Topics

ร—
ร—
  • Create New...

Important Information

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