Jump to content

Recommended Posts

Posted

I have a GuiScreen that shows a rectangle contained in texture file, but instedaded of showing rectangle it only shows a starange symblols like thaumcraft fonts.

 

Erroring GuiScreen:

package com.ec.screen;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ChatLine;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.stream.ChatController;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityTNTPrimed;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Chat;

import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;

import com.ec.handler.PacketMessage;
import com.ec.lib.MainLib;
import com.ec.lib.RefStrings;
import com.ec.tileentity.TileEntityPasswordLock;

public class PasswordChangeScreen extends GuiScreen{
int screenWidth = 196;
int screenHeight = 169;
public static int id = 2;

public static String enteredPassword = "";

public static World world;
public static int x;
public static int y;
public static int z;
public static EntityPlayer player;

public PasswordChangeScreen(World world, int x, int y, int z, EntityPlayer player)
{
	this.world = world;
	this.x = x;
	this.y = y;
	this.z = z;
	this.player = player;
}

@Override
public void drawScreen(int x, int y, float tick)
{
	int screenX = (width - screenWidth) / 2;
	int screenY = (height - screenHeight) / 2;

	GL11.glColor4f(1, 1, 1, 1);
	drawDefaultBackground();

	mc.renderEngine.bindTexture(new ResourceLocation(RefStrings.MODID, "textures/gui/PasswordGui.png"));
	drawTexturedModalRect(screenX, screenY, 0, 0, screenWidth, screenHeight);
	fontRendererObj.drawString(enteredPassword, screenX + 36, screenY + 11, 0);
	this.drawTexturedModalRect(screenX + 110, screenY + 11, 145, 171, 68, 20);

	super.drawScreen(x, y, tick);
}

@Override
public void initGui()
{
	int screenX = (width - screenWidth) / 2;
	int screenY = (height - screenHeight) / 2;

	buttonList.clear();
	GuiButton one;
	GuiButton two;
	GuiButton three;
	GuiButton four;
	GuiButton five;
	GuiButton six;
	GuiButton seven;
	GuiButton eight;
	GuiButton nine;
	GuiButton zero;
	GuiButton erase;
	GuiButton changePassword;
	GuiButton back;

	buttonList.add(one = new GuiButton(1, screenX + 25, screenY + 25, 10, 10, "1"));
	buttonList.add(two = new GuiButton(2, screenX + 45, screenY + 25, 10, 10, "2"));
	buttonList.add(three = new GuiButton(3, screenX + 65, screenY + 25, 10, 10, "3"));
	buttonList.add(four = new GuiButton(4, screenX + 25, screenY + 45, 10, 10, "4"));
	buttonList.add(five = new GuiButton(5, screenX + 45, screenY + 45, 10, 10, "5"));
	buttonList.add(six = new GuiButton(6, screenX + 65, screenY + 45, 10, 10, "6"));
	buttonList.add(seven = new GuiButton(7, screenX + 25, screenY + 65, 10, 10, "7"));
	buttonList.add(eight = new GuiButton(8, screenX + 45, screenY + 65, 10, 10, "8"));
	buttonList.add(nine = new GuiButton(9, screenX + 65, screenY + 65, 10, 10, "9"));
	buttonList.add(zero = new GuiButton(0, screenX + 45, screenY + 85, 10, 10, "0"));
	buttonList.add(erase = new GuiButton(10, screenX + 85, screenY + 45, 15, 20, "Clear"));
	buttonList.add(changePassword = new GuiButton(11, screenX + 125, screenY + 55, 20, 20, "Change password"));
	buttonList.add(back = new GuiButton(12, screenX + 125, screenY + 85, 20, 20, "Back"));
	super.initGui();
}

@Override
public void actionPerformed(GuiButton button)
{
	int screenX = (width - screenWidth) / 2;
	int screenY = (height - screenHeight) / 2;

	TileEntityPasswordLock tile = (TileEntityPasswordLock)world.getTileEntity(x, y, z);

	switch(button.id)
	{
	case 0:
		enteredPassword = enteredPassword + "0";
		break;
	case 1:
		enteredPassword = enteredPassword + "1";
		break;
	case 2:
		enteredPassword = enteredPassword + "2";
		break;
	case 3:
		enteredPassword = enteredPassword + "3";
		break;
	case 4:
		enteredPassword = enteredPassword + "4";
		break;
	case 5:
		enteredPassword = enteredPassword + "5";
		break;
	case 6:
		enteredPassword = enteredPassword + "6";
		break;
	case 7:
		enteredPassword = enteredPassword + "7";
		break;
	case 8:
		enteredPassword = enteredPassword + "8";
		break;
	case 9:
		enteredPassword = enteredPassword + "9";
		break;
	case 10:
		enteredPassword = "";
		break;
	case 11:
		if(enteredPassword.length() == 4)
		{
			MainLib.sendPacketToServer(new PacketMessage("changePassword", x, y, z, enteredPassword));
			mc.displayGuiScreen(null);
		}
		break;
	case 12:
		MainLib.openGui(player, PasswordLockScreen.id, world, x, y, z);
		break;
	default:
		break;
	}
}
}

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

GuiScreen#drawTexturedModalRect uses fixed rate for uv vs xy, so it wouldn't be useful as you think.

Instead, make your own method replacing that; Usually setting uv to 0~1 is appropriate.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

I used it this way:

x - where I want to draw it on screen X

y - where I want to draw it on screen Y

u - position of rectangle in texture - X

v - position of rectangle in texture - Y

width

height

 

And, what do 0~1 mean? Did you mean I have to make a mathod where u and v will be always 0 and 1?

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted
  On 4/7/2015 at 7:21 AM, Enginecrafter said:

And, what do 0~1 mean? Did you mean I have to make a mathod where u and v will be always 0 and 1?

 

He means from 0.0D to 1.0D, a floating point number.

You need to calculate the u and v appropriate to the texture resolution you use, that means, u-position on texture is 16px, v-position is 32px, your texture is 128x64px:

u = 16 / 128 = 0.125D

v = 32 / 64 = 0.5D

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

  Quote

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

What do you mean?

How can I do it? Is this method correct or I didn't understood it correctly?

 

Code:

http://pastebin.com/947L7sEp

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

If you look at Gui#drawTexturedModalRect, it multiplies u and v by a static value, fitting a texture of size 256x256.

If you want to draw a texture with a different size, you need to copy this method and adjust it to fit your texture resolution.

If you do have a texture using this resolution, you're fine to use it, but be careful that in this case u and v are the exact pixel values.

 

But your problem seems to be a different one: You don't bind your texture anywhere when drawing your rectangle, to do so, you need to call

this.mc.getTextureManager().bindTexture(TEXTURE_RESOURCE_LOCATION);

before you draw your rectangle.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

  Quote

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

I binded my texture in MainLib.createScreenBase(some parameters)

http://pastebin.com/WgGJ3MRu

 

And, what is z-value?

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

1. Please do not create a new ResourceLocation instance every frame, use a static (final) field for it.

2. The z value (or correctly, the z-index) is the "layer" your texture draws on. It is recommended to use the field provided in your Gui instance.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

  Quote

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

I created new basic gui to test this and it worked, but on the advanced gui(the original gui) isn't still working. They are both using the same gui texture.

 

My function to render rectangle contained in texture on gui

http://pastebin.com/WDhYeED2

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

... and where do you call your drawRect method (which is useless, since it's the exact copy of drawTexturedModalRect)?

 

A fundamental question: What do you want to achieve with your advanced GUI that is different from a basic one?

Also I suggest you setup a Github repo and host your mod code there so we can help you better.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

  Quote

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

The advanced gui is "advanced", because it uses lot of buttons, sends packets and so on.

I want ot create something like password lock that when correct password is entered, changes block on location that is set using my item "remote manipulator" and the block sets remote block's metadata to 1. Once the remote receiver has metadata 1 it emits redstone signal.

And, I don't want to create GitHub because I must update it every time I post something.

 

And there I call the function:

@Override
public void drawScreen(int x, int y , float tick)
{
	int[] screenPos = MainLib.createScreenBase(new int[]{width, height, 194, 168}, this, res);
	MainLib.drawRectangle(new int[]{screenPos[0], screenPos[1], 0, 177, 68, 20}, this.zLevel);
	super.drawScreen(x, y, tick);
}

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

Enginecrafter, the advantages of having your project in Git is that for instance you can develop your mod from everywhere where there is IDE and if your hard disk fails you will have not lost your project. I myself would be lost nowadays without Github repo.

If my post helped you, please press that "Thank You"-button to show your appreciation.

 

Also if you don't know Java, I would suggest you read the official tutorials by Oracle to get an idea of how to do this. Thanks, and good modding!

 

Also if you haven't, set up a Git repo for your mod not only for convinience but also to make it easier to help you.

Posted

Sorry, I have never worked with GitHub.

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

And, Have I to copy-paste all my code to GitHub?

Or there is a "simple way"?

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

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

    • Okay so I went to a different version of that mod and it booted right up, thank you
    • C:\Users\bruiser\curseforge\minecraft\Instances\Fazbear Remnants\essential\loader\stage1\launchwrapper\stage2.forge_1.12.2.jar: The process cannot access the file because it is being used by another process. Restart your system and test it again If there is no change, delete the mentioned essential folder or remove the mod essential
    • Does it work with newer versions? For 1.16.5 also make a test with Embeddium + Oculus as Optifine replacement
    • Looking for the best Temu coupon code $100 off? You’re in the right place! We’ve got the ultimate deal that helps you save big on your favorite items. Our exclusive ACS670886 Temu coupon code is perfect for shoppers in the USA, Canada, and Europe. Whether you're a new or existing customer, this code ensures you get maximum benefits. By using the Temu coupon $100 off, you can unlock exciting savings on Temu’s vast collection. Don’t miss this chance to claim your Temu 100 off coupon code today! What Is The Coupon Code For Temu $100 Off? Both new and existing customers can enjoy incredible benefits with our Temu coupon $100 off on the Temu app and website. This $100 off Temu coupon ensures huge savings for everyone! ACS670886 – Get a flat $100 off on selected purchases. ACS670886 – Unlock a $100 coupon pack for multiple uses. ACS670886 – Enjoy a $100 flat discount if you're a new customer. ACS670886 – Existing customers can claim an extra $100 promo code. ACS670886 – This $100 coupon is valid for shoppers in the USA and Canada. Temu Coupon Code $100 Off For New Users In 2025 New users can maximize their savings by applying our Temu coupon $100 off on the Temu app. This Temu coupon code $100 off unlocks amazing deals for first-time shoppers. ACS670886 – Get a flat $100 discount for new users. ACS670886 – Receive a $100 coupon bundle as a welcome offer. ACS670886 – Unlock up to $100 in coupons for multiple uses. ACS670886 – Enjoy free shipping to 68 countries. ACS670886 – Get an extra 30% off on any purchase as a first-time user. How To Redeem The Temu Coupon $100 Off For New Customers? Using the Temu $100 coupon is easy! Follow these steps to redeem your Temu $100 off coupon code for new users: Sign up on the Temu app or website. Browse and add your favorite items to the cart. Enter ACS670886 at checkout. See the $100 discount applied instantly. Complete your purchase and enjoy your savings! Temu Coupon $100 Off For Existing Customers Existing customers can also benefit from our exclusive Temu $100 coupon codes for existing users. Use this Temu coupon $100 off for existing customers free shipping deal and save more! ACS670886 – Get an extra $100 discount for existing users. ACS670886 – Enjoy a $100 coupon bundle for multiple purchases. ACS670886 – Receive a free gift with express shipping across the USA/Canada. ACS670886 – Grab an extra 30% off on top of existing discounts. ACS670886 – Avail free shipping to 68 countries. How To Use The Temu Coupon Code $100 Off For Existing Customers? Redeeming your Temu coupon code $100 off as an existing user is simple. Just follow these steps: Log in to your Temu account. Select your desired products and add them to your cart. Apply ACS670886 at checkout. Your Temu coupon $100 off code will be applied automatically. Confirm your order and enjoy massive savings! Latest Temu Coupon $100 Off First Order First-time buyers get the best deals with our Temu coupon code $100 off first order. This Temu coupon code first order ensures maximum savings. ACS670886 – Flat $100 discount for the first order. ACS670886 – Special $100 Temu coupon code for new customers. ACS670886 – Get up to $100 in coupons for multiple uses. ACS670886 – Free shipping to 68 countries. ACS670886 – Extra 30% off on any first-time purchase. How To Find The Temu Coupon Code $100 Off? Finding a Temu coupon $100 off is easy! Check out the Temu coupon $100 off Reddit section or follow these tips: Subscribe to the Temu newsletter for exclusive deals. Follow Temu’s official social media pages for the latest updates. Visit trusted coupon sites for verified and working codes. Is Temu $100 Off Coupon Legit? Yes, our Temu $100 Off Coupon Legit and verified! Wondering if the Temu 100 off coupon legit? Here’s why: The ACS670886 code is officially tested and confirmed. Valid for all customers in the USA, Canada, and Europe. No expiration date—use it anytime! How Does Temu $100 Off Coupon Work? The Temu coupon code $100 off first-time user works instantly upon applying at checkout. Simply enter the Temu coupon codes 100 off, and the discount is automatically deducted. How To Earn Temu $100 Coupons As A New Customer? To earn a Temu coupon code $100 off, sign up on Temu, make your first purchase, and refer friends. This 100 off Temu coupon code can be unlocked through special promotions. What Are The Advantages Of Using The Temu Coupon $100 Off? $100 discount on the first order $100 coupon bundle for multiple uses 70% discount on popular items Extra 30% off for existing customers Up to 90% off on selected products Free gifts for new users Free delivery to 68 countries Temu $100 Discount Code And Free Gift For New And Existing Customers Enjoy the Temu $100 off coupon code and get amazing benefits! Our $100 off Temu coupon code ensures huge savings. ACS670886 – $100 discount for the first order. ACS670886 – Extra 30% off on any item. ACS670886 – Free gift for new Temu users. ACS670886 – Up to 70% discount on all Temu items. ACS670886 – Free shipping in 68 countries including the USA and UK. Final Note: Use The Latest Temu Coupon Code $100 Off Using the Temu coupon code $100 off is the smartest way to save on Temu! Don’t wait—grab your discount now. Our Temu coupon $100 off is available for all customers, ensuring maximum savings. Get yours today! FAQs Of Temu $100 Off Coupon Q: How can I get the Temu $100 off coupon? A: Use code ACS670886 at checkout to claim your $100 discount. Q: Is the Temu $100 coupon valid for existing customers? A: Yes! Existing users can also apply ACS670886 and enjoy savings. Q: Does the Temu $100 off coupon have an expiration date? A: No, ACS670886 is valid indefinitely. Q: Can I use the Temu coupon on multiple orders? A: Yes! ACS670886 allows multiple redemptions. Q: Is the Temu $100 coupon applicable worldwide? A: Yes, it’s valid in the USA, Canada, Europe, and 68 other countries.
    • I tried both Vanilla and Optfine like you said, and both gave the same result. So I believe the issue is most likely with Minecraft in general and not Forge
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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