Jump to content

How to create a simple single texture gui


Recommended Posts

Hi, I was looking for a solution for this seemingly straightforward task but it requires a lot of bits of knowledge in parts of the game I'm not super familiar with.

I have an algorithm for generating a 128 * 128 grid of float values from an algorithm of mine.

I would like a simple GUI that will simply plonk this (as a texture) on to the screen, and also ideally display the players position in the corner.

How this gui is opened and closed is not important to me, a command, or a keystroke, whichever would be simplest.

Ideally for performance I imagine the texture should only be generated once and then saved but I could be wrong.

How might I go about doing this, both in terms of creating and placing the texture on to a gui and to somehow get the gui appearing in game.

Link to comment
Share on other sites

Have a look at DynamicTexture/NativeImage for creating dynamic textures.

You can see how to register the result (give it a ResourceLocation) with the TextureManager in for example PackSelectionScreen.loadPackIcon()

Once that is done, you can blit() it onto the screen like any other texture.

Look at for example BookViewScreen.render() for the some blit() code, which also renders some text - font.draw().


From your description, it sounds like the code for minecraft Map items would be more relevant, e.g. MapRenderer?

But that is more complex since it handles rendering the map in the player's hand.


How to show screens is a question that has been asked a million times in these forums. So you can use search for all the alternatives.

But it is basically Minecraft.getInstance().setScreen() from your chosen interaction method.


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.

Link to comment
Share on other sites

Ok thankyou very much, a few questions.

From a brief look around I assume that NativeImage is essentially a representation of raw pixel data and DynamicTexture is essentially a class that wraps this into a minecraft usable texture.

Would my process then to when my GUI is rendered for the first time, create a new DynamicTexture from a new NativeImage of the width and height I want, fill it in and then store the result it to my gui's class? kinda like this?

(how do you make it be code again)

public class SpecialRendererGui extends Screen {

DynamicTexture TEXTURE = new DynamicTexture( new NativeImage( 128,128, true ));

protected SpecialRendererGui(ITextComponent text) {

super(text); //what is this text component for

//for x,y in range 128... bla bla bla


public void render(PoseStack render_buffer) {

//I'm struggling to figure out what to do here?

} }

I am having difficulty deciphering the blit function and how it's exactly getting ahold of the necessary data?

Also do you know what the boolean in the NativeImage constructor does, it doesn't have a parameter name and seems to be used to differentiate a Malloc or Calloc which I didn't know java had? Is that about whether I want to set my data to black by default?

Also from personal experience what do you think will be the simplest and easiest way to implement the screen popping up? through a command? a key? an item?

Also pure curiosity questions, in digging through the client code I came across a package insider of client.renderer.debug, do you know what they are they look interesting and maybe kinda useful.

Link to comment
Share on other sites

You need to do more research by looking at how vanilla does things. And as I said before, you will find many answers to some of your questions already in these forums.A

Also BookViewScreen is just one example of a vanilla screen you can look at. Pick one that most closely resembles what you are trying to do.

I am not going to spoon feed the code to you. It is your responsibility to write your mod.


I will tell you (since it is probably not obvious if you haven't seen it before) that blit() like other render methods gets some of its "parameters" from the static RenderSystem calls that change the opengl rendering state. e.g. RenderSystem.setShaderTexture() specifies which texture to use in later calls.


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.

Link to comment
Share on other sites

whoa dude, not asking you to spoon feed code to me. Asking some about some specific functionality of some classes because you seem more experienced and knowledgeable. Mostly pure curiosity questions cos I wanna learn more about how the system works.

The exact functionality of blit is a little mysterious as like you said, information was being passed from other places and I can't seem to find other classes that use it along with DynamicTextures much (I was thinking maybe the debug screen but I've been looking for that for a while and can't find it anywhere). I tend to find all the render functions a bit abstract and I'm not that familiar with the set up of openGL nor Minecraft's abstractions of it so I was just trying to grasp what the underlying methodology was.

My questions about the texture allocation and the client.renderer.debug package were pure curiosity questions that were related but not directly relevant. In both cases I feel like there's not really enough in the minecraft source code alone for me to go off of so If you can shed any light that wld be amazing but if not that's cool, they're more curiosities.

As for my question about the simplest and easiest way to get this rendering in game. That was more of a request for a personal recomendation of which would be easiest. I could implement all 3 by digging through the source code, and I will if I have to, but I don't want all 3, am just curious which would be easiest in your opinion.

I realise that my request to open a gui in the simplest way possible is a little weird but cos it's for a debugging tool, again it's not the means that's important to me but the simplicity and tho I don't know the minecraft code that well I know it can sometimes be very difficult to do straightforward things so thought you might be able to give your opinion.



Link to comment
Share on other sites

For future people curious about this.

The debug screen is called DebugScreenOverlay and is not itself a screen rather than a GuiComponent (I'm still figuring out the functional difference). 

The system I managed to use I think worked like this:


this tells minecraft you want to use a shader that draws textures, idk what the difference between this and other methods in GameRenderer are but this works

RenderSystem.setShaderColor( _red, _green, _blue, _alpha);

I guess you can colour textures as you render them if you need?

RenderSystem.setShaderTexture(0, TEXTURE_LOCATION);


register the texture you want, idk what that 0 does. It doesn't seem to be the gl texture id so who knows.

this.blit(render_buffer, x, y, U, V, RESOLOUTION, RESOLOUTION);

draw the texture to the appropriate place.

I ended up going with a command which was super straightforward.

I'm yet to figure out what that debug package is about, it seems to mostly seems to be classes that are never used, I assume for the devs but I wonder if there's a cool way to get it working properly.

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.

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.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • 东南亚Go-Stop游戏厅♨BCGAME55·COM @ 东南亚Go-Stop网站Book Makedonia东南亚Go-Stop转播Win Casino Go-Stop网站Ryberia Go-Stop方法[本社的Tele @JBOX7] 东南亚Go-Stop Bar西亚东南亚Go-Poon 格伦纳丁GO-Stop扑克大赛刚果民主Goostop Coopon[总经销的Kakao Talk JBOX7] 东南亚 Gomino Saition网站] 制作方法[东南亚 G 赌场 [赌场总公司] 东南亚Go Stop 转播 帕劳 东南亚Go Stop总经销 苏里南Go Stop 视频 罗马尼亚Go Stop战略 尼泊尔东南亚Go Stop方法西非Go Stop赌场尼日利亚Go Stop Tour[TOTO总公司咨询]东南亚Go Stop连接冈比亚东南亚 GOSTOP SITE Estonia GOSTOP MALLET MALLATION GOSTOP招募[TOTOTOTO总经销购买]东南亚 GOSTOP比赛 NIGOSTOP TANGE GOSTOP TALLIGOTION GOSTOP总经销 Holdumba厄瓜多尔Go Stop赌场酒吧新西兰Go Stop总经销[Bakara总经销]东南亚Go Stop转播巴登巴登东南亚Go Stop游戏场台湾Go Stop社区塞内加尔Go Stop招募[赛马总经销]东南亚Go Stop视频葡萄牙东南亚Go Stop方法 Falls View赌场Kosogos游戏场Cipross Gosing地址[BCGME BC Game总经销咨询]设置通知推荐订阅点赞
    • 全球LAPT推荐™BCGAME55·COM℡ 全球LAPT YouTube 意大利全球LAPT总经销匈牙利LAPT赌场酒吧 新加坡LAPT Holdom Pub[本文的Tele @JBOX7] 全球LAPT淘汰赛塞尔维亚全球LAPT推荐赞比亚LAPT扑克大赛 西非的LAPT游戏厅[总经销的Kakao Talk JBOX7] 缅甸的环球网游 马里网游 加拿大网 制作地址:非洲网吧 制作。 LAPT战略也门LAPT Bakara Pub [赌场总公司] 全世界LAPT招募不丹LAPT Holdomba阿富汗LAPT游戏场 Tubalu LAPT战略 [体育总公司] 全世界LAPT比赛 Ibiza Gran Cagino 全世界 LAPT Bakara Pub Armenia LAFT 旅行[TOTOTO总公司咨询] 全世界 LAPT KUPONG叙利亚 LAST 连接 TUKET 土耳其 土耳其 TUKET社区旅行 [TOMET] 社区埃及LAPT地址[YAMATO总公司]全球LAPT方法利比亚全球LAPT总经销厄立特里亚LAPT连接列支敦士登LAPT战略[巴卡拉总经销]全球LAPT联赛黑塞哥维那全球LAPT赛亚特兰蒂斯卡吉诺LAPT视频刚果(刚果)(赛马总经销)]全球LAPT赌城冈比亚全球LAPT比赛尼加拉瓜LAPT战略多哥LAPCA游戏总经销点赞设定]
    • 世界杯搏击网站♥BCGAME55·COM‡世界杯搏击企业欧洲世界杯搏击YouTube度假村世界赌场搏击Holdom Pub Falls View赌场搏击地址[本社文义通 @JBOX7]世界杯搏击YouTube北非世界杯搏击总经销卢森堡搏击巴卡拉波普 刚果(Kakao Talk JBOX7] 推荐世界杯Holdom Barwago世界杯台湾格斗高尔夫球场异种格斗视频制作方法] 巴登巴登世界杯搏击赛场吉尔吉斯斯坦搏击赛场Suncity搏击赛场[赌场总部]世界杯搏击赛场梵蒂冈时局世界杯搏击赛场库彭博茨瓦纳搏击赛场黎巴嫩搏击赛场][体育总部]世界杯搏击扑克大赛圣马力诺世界杯终极格斗视频巴登巴登巴登终极格斗赛场立陶宛终极格斗联赛[兔本社咨询]世界杯终极格斗联赛 NATHUDUDUBBA世界杯UTHUDUDUTUTBBBE 购买世界杯终极格斗大赛 异种格斗赌场酒吧阿富汗世界杯异种格斗Cash游戏Suri Nam异种格斗登录白俄罗斯异种格斗总经销[Yamato总公司]世界杯异种格斗Coopoon加拿大世界杯异种格斗转播卢旺达异种格斗游戏场东南亚异种格斗Coopoon[Bakara总经销] [赛马总经销]世界杯 东南亚搏击战略游戏Coopoon[Bakara总经销]澳大利亚世界杯搏击转播 圣玛丽诺 圣卡拉波普 西非地区搏击 Bakpojokpoon]
    • Major异种格斗Coopoon▲BCGAME55·COM↖Major异种格斗网站特立尼达Major异种格斗网站西非异种格斗比赛凯撒帕里斯卡吉诺异种格斗巡回赛[本社咨询的Tele @JBOX7] Major异种格斗游戏场也门Major异种格斗社区Leoal Sweet赌场异种格斗企业玻利维亚的Kakao Talk JBOX7] Major 制作Major 杂技比赛 土耳其YObaser 奥赛场。 搏击网站西班牙Major搏击网站Coupoon Benesian赌场搏击亚洲战略[赌场总公司] Major搏击联盟以色列Major搏击赌场俱乐部乌拉圭Major搏击战略挪威Major搏击Bakara Pub [体育总公司] Major搏击扑克大赛 Cesaspaliscagino Major招募巴西Honger格斗视频柬埔寨终极格斗团聊天室[TOTOTOTOB咨询] Major中国Mazer终极格斗比赛 终极格斗大赛 凯尔特人棒球赛 认证赛 终极格斗视频认证] [Major] 搏击转播 希腊Major 搏击视频 萨摩亚 搏击赛 比利时Major 搏击总经销商 山多总公司] Major 世界搏击中心 Major World Casino Major Major 的搏击总经销南亚搏击缓存游戏 安提瓜和巴布达搏击网站[Bakara总经销] Mazo Lizer Baghwaghite Baghilvily Mazer Net Warnet Warnets.
    • 手机奥林匹克YouTube♪BCGAME55·COM↔手机奥林匹克Cash游戏Polsview Casino 手机奥林匹克游戏中非奥林匹克淘汰赛尼日利亚奥林匹克游戏[本社的Tele @JBOX7] 手机奥林匹克竞赛 Sun City Mobile 奥运会比赛 伊拉克奥林匹克网站 东亚奥林匹克Holdumba[总经销的Kakao Talk JBOX7] 手机奥运会比赛萨尔瓦多MGM Cash Casino 奥运会网站 MGM Casino[各种官方网站 Office Casicaltournia Mobile Office Officalsulections]推荐] 京畿[赌场总公司] 手机奥林匹克旅行 沙特阿拉伯 手机奥林匹克旅行 韩国奥林匹克总经销 刚果民主奥林匹克竞赛 [体育总公司] 手机奥林匹克游戏场 不丹手机奥林匹克地址 特朗普泰姬陵 赌场奥林匹克影像 Wincasino奥运会影像征集[TOTO总公司咨询]手机奥林匹克游戏 Grena Mobile Olication Communication National Offication National Offication National Communication Love[TOTOTOTOTO总经总经销] Mobile Kongo Mobile Korea Mobal Offoria Mobile Offection. Marina Bay奥运Coopoon非洲奥运转播[巴卡拉总经销] 移动奥运招募 阿塞拜疆移动奥运招募 哈萨克斯坦奥林匹克Holdemba坦桑尼亚奥林匹克赌场[赛马总经销] 移动奥运战略 乌兹别克斯坦移动奥运社区厄立特里亚奥林匹克总部 西亚奥运转播[BCGAME BC GAME 游戏总经销咨询] 设置通知推荐订阅点赞
  • Topics

  • Create New...

Important Information

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