Jump to content

[UNSOLVED] Experts Only: Individual Block Overlay using OpenGL?


Jaspa_Jones

Recommended Posts

Hi everyone,

 

Basically I'm trying to add a texture overlay to one individual block. Not to a block class, but for example to the block located 50, 50, 50. Whatever type of block it is. My Mod should be able to be installed via a ZIP file, so no changes in original source code.

 

Example: http://www.9minecraft.net/light-level-overlay-mod/

 

--

 

 

My TickHandler:

RenderingRegistry.instance().renderWorldBlock(Minecraft.getMinecraft().renderGlobal.globalRenderBlocks, Minecraft.getMinecraft().renderGlobal.globalRenderBlocks.blockAccess, x, y, z, Block.blocksList[ Minecraft.getMinecraft().theWorld.getBlockId( x, y, z ) ], Mod.instance.blockModel );

 

RenderBlocks.java (I basically disabled normal rendering, and see no more blocks.

public boolean renderBlockByRenderType(Block par1Block, int par2, int par3, int par4)
    {/*
        int l = par1Block.getRenderType();

        if (l == -1)
        {
            return false;
        }
        else
        {
            par1Block.setBlockBoundsBasedOnState(this.blockAccess, par2, par3, par4);
            this.setRenderBoundsFromBlock(par1Block);

            switch (l)
            {
                //regex: ' : \(l == ([\d]+) \?' replace: ';\ncase \1: return' ::: IMPORTANT: REMEMBER THIS ON FIRST line!
                case 0: return this.renderStandardBlock(par1Block, par2, par3, par4);
                case 4: return this.renderBlockFluids(par1Block, par2, par3, par4);
                case 31: return this.renderBlockLog(par1Block, par2, par3, par4);
                case 1: return this.renderCrossedSquares(par1Block, par2, par3, par4);
                case 2: return this.renderBlockTorch(par1Block, par2, par3, par4);
                case 20: return this.renderBlockVine(par1Block, par2, par3, par4);
                case 11: return this.renderBlockFence((BlockFence)par1Block, par2, par3, par4);
                case 39: return this.renderBlockQuartz(par1Block, par2, par3, par4);
                case 5: return this.renderBlockRedstoneWire(par1Block, par2, par3, par4);
                case 13: return this.renderBlockCactus(par1Block, par2, par3, par4);
                case 9: return this.renderBlockMinecartTrack((BlockRailBase)par1Block, par2, par3, par4);
                case 19: return this.renderBlockStem(par1Block, par2, par3, par4);
                case 23: return this.renderBlockLilyPad(par1Block, par2, par3, par4);
                case 6: return this.renderBlockCrops(par1Block, par2, par3, par4);
                case 3: return this.renderBlockFire((BlockFire)par1Block, par2, par3, par4);
                case 8: return this.renderBlockLadder(par1Block, par2, par3, par4);
                case 7: return this.renderBlockDoor(par1Block, par2, par3, par4);
                case 10: return this.renderBlockStairs((BlockStairs)par1Block, par2, par3, par4);
                case 27: return this.renderBlockDragonEgg((BlockDragonEgg)par1Block, par2, par3, par4);
                case 32: return this.renderBlockWall((BlockWall)par1Block, par2, par3, par4);
                case 12: return this.renderBlockLever(par1Block, par2, par3, par4);
                case 29: return this.renderBlockTripWireSource(par1Block, par2, par3, par4);
                case 30: return this.renderBlockTripWire(par1Block, par2, par3, par4);
                case 14: return this.renderBlockBed(par1Block, par2, par3, par4);
                case 15: return this.renderBlockRepeater((BlockRedstoneRepeater)par1Block, par2, par3, par4);
                case 36: return this.renderBlockRedstoneLogic((BlockRedstoneLogic)par1Block, par2, par3, par4);
                case 37: return this.renderBlockComparator((BlockComparator)par1Block, par2, par3, par4);
                case 16: return this.renderPistonBase(par1Block, par2, par3, par4, false);
                case 17: return this.renderPistonExtension(par1Block, par2, par3, par4, true);
                case 18: return this.renderBlockPane((BlockPane)par1Block, par2, par3, par4);
                case 21: return this.renderBlockFenceGate((BlockFenceGate)par1Block, par2, par3, par4);
                case 24: return this.renderBlockCauldron((BlockCauldron)par1Block, par2, par3, par4);
                case 33: return this.renderBlockFlowerpot((BlockFlowerPot)par1Block, par2, par3, par4);
                case 35: return this.renderBlockAnvil((BlockAnvil)par1Block, par2, par3, par4);
                case 25: return this.renderBlockBrewingStand((BlockBrewingStand)par1Block, par2, par3, par4);
                case 26: return this.renderBlockEndPortalFrame((BlockEndPortalFrame)par1Block, par2, par3, par4);
                case 28: return this.renderBlockCocoa((BlockCocoa)par1Block, par2, par3, par4);
                case 34: return this.renderBlockBeacon((BlockBeacon)par1Block, par2, par3, par4);
                case 38: return this.renderBlockHopper((BlockHopper)par1Block, par2, par3, par4);
                default: return FMLRenderAccessLibrary.renderWorldBlock(this, blockAccess, par2, par3, par4, par1Block, l);
            }
        }*/return false;

 

My BlockRenderer:

System.out.println("RENDERING WORLD BLOCK. " + x + " " + y + " " + z + " " + block + " " + modelId);
       
        //renders the basic block
        renderer.renderStandardBlock(block, x, y + 1, z);

 

It prints to the console every frame. It does not render the standard block.

 

Anyone got a clue?

 

Thanks in advance,

 

Jaspa_Jones  :D

Link to comment
Share on other sites

Are you wanting this to just always be there or are you specifically wanting it to happen when you have another block placed already? If you place a block in order to have the overlay, you could use a custom renderer on that placed block and draw your overlay from there. To make it cover the block that is there in the first place, you could set the block bounds to be just ever so slightly larger than a normal block, so it completely covers the normal block that is there already.

 

If you want it to just exist there, I can't really help you.

Read my thoughts on my summer mod work and tell me what you think!

http://www.minecraftforge.net/forum/index.php/topic,8396.0.html

 

I absolutely love her when she smiles

Link to comment
Share on other sites

thats just me but instead of disabling normal block rendering id try only rendering the text/wtv "hovering" over the block

 

like 0.01 meter higher so that you dont have intersection with the normal block

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

Thank you guys for replying!

 

Well basically, I'm writing a mod that features Area Protection and I would like to highlight the protected areas in red. So I would like to make an partly transparent overlay over all the blocks that are protected. No matter what type of block they are.

 

So I do know which blocks (x, y, z) I would like to replace, but the Custom Render function in Forge is (I think) only designed to override block renderers per block type, not per individual block.

 

I would love to not use this Custom Render function and instead draw some overlay in OpenGL for example. I just don't really know where to start with this.

Link to comment
Share on other sites

not to be a dick but i think ForgeEssential is already making something similar. (as am i but thats another story)

 

suggestion: anyone correct me if its not a good idea

 

try to spawn "entities"  kinda like mobs but they dont attack have hp or wtv, they jsut render the area protection

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

Yeah I know, but it's still in Alpha state and for Minecraft 1.4.7. Couldn't wait and started :)

 

That sounds complicated, but I get your idea. Do you have any experience doing things like this? Personally, I've never spawned any mobs. I've tried to stop mobs from moving once, but didn't succeed.

 

Do I need to create a custom mob for this? How can I spawn and kill a mob? And how can I remove its texture?

 

Thanks!

Link to comment
Share on other sites

I have no idea personall i do it with blocks because i want the mayor of the town to be able to change the width/height/length of a plot (plots are "protected area") 

 

i didnt know ForgeEssential was only for 147, mines 152 ready ;)

 

technicly they're not mobs, they are entities, like a higher level in hierarchy. their only point as entities is ... to exists i guess. i do knwo they is a tutorial or 2 on the wiki about this. maybe you could try spawning a custom mob and then removing the "mob" part of the mob

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

I think there will be a problem with this. I only want the client to see the protected area highlighted and not the server. Only the Major should have access to this feature of displaying protected areas.

 

The first attempt I did was replacing Block ID's client side which pretty much did the job. However, my console started throwing lots and lots of errors about wrong synchronization between client and server. That's why I would actually prefer to not change anything gameplay related. I would prefer to just like draw another block that is a little bit bigger over the other block like redria7 said using OpenGL. Wouldn't that be a bit more neat and also better?

 

If I would take that route, I just have to know how to draw a block at that particular point and then increase its size a bit. I know how to access OpenGL from Minecraft, but I don't know how to get the right position and draw a solid color cube right there.

Link to comment
Share on other sites

Tile entity my friend. A tile entity with a gui where you can alter size and... do exactly what flame is doing!

Or try the entity. Mobs, players, TE's, all of these are entities. Items on the ground are entities. Creating one wouldn't be impossible. Maybe make something similar to a spawn egg, except instead of spawning a mob, it spawns an entity that has a set size and shape and covers a large area, with no collision etc. Then your mayor can give each person one egg from creative mode, and the players can throw the egg at a location and it locks that location to them.

Read my thoughts on my summer mod work and tell me what you think!

http://www.minecraftforge.net/forum/index.php/topic,8396.0.html

 

I absolutely love her when she smiles

Link to comment
Share on other sites

no hold on, tile entities are working in MY case because this how i want the player to interact with their lands. you have to use a tool that fits YOUR needs. maybe eggs are a good idea, maybe they're not.

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

My case is very simple:

 

I simply have the locations of blocks which are protected stored. For example:

X, Y, Z

50, 50, 50

50, 51, 51

51, 50, 51

 

Then when the Mayor presses P, these protected blocks will highlight. And when he presses P again they will return to normal. The blocks stay the same, it's just the way the user sees them that changes.

Link to comment
Share on other sites

yeah but the question is, how are these blocks are selected/created, do you have to enter a command? do you have to right click them ? have you tought about air block, block placing etc etc.

 

 

 

 

 

 

 

btw the answer to "do you have to enter a command" better be no

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

*sight*

 

we have forge.... we have user interfaces...... we should be able to make mods that are 100% command free, its way more interactive and fun to interact with beautiful menu then to type

 

"/hur dur create area protected set group=admin 51, 51, 51, 100, 100, 100"

 

i know you're just using whats already there. but i think I'm getting cancer from these.

 

honestly I'm really excited to release my mod because we can finally start getting rid of those sign shop ....

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

no hold on, tile entities are working in MY case because this how i want the player to interact with their lands. you have to use a tool that fits YOUR needs. maybe eggs are a good idea, maybe they're not.

Sorry, tile entity is my thought for this on how it would work easiest. By pointing out that that's exactly what you were doing already I was (not very clearly) pointing out that that method was already being done, so using a different method would probably be a good idea.

I respect the fact that you are willing to help someone doing something similar to what you are doing when you haven't released yet. :)

I plan on going open source the moment I release, but I am trying to hide my more fun features until I release just in case someone else likes the idea and releases first. I'm a little selfish that way.

Read my thoughts on my summer mod work and tell me what you think!

http://www.minecraftforge.net/forum/index.php/topic,8396.0.html

 

I absolutely love her when she smiles

Link to comment
Share on other sites

im a bit.. special.. and very confident/positive that my mod will be one of the best in its genre.

 

But hey, we'll see in 2 month if people like what I've done.

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

plus, people here are usually very new to coding in general. they're not a threat to the popularity of my mod. IF i ahve somethign to fear. it would be people who are working in secret. (kinda like me)

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

im a bit.. special.. and very confident/positive that my mod will be one of the best in its genre.

 

But hey, we'll see in 2 month if people like what I've done.

I'm pretty confident in what I've done, but I also want that reveal moment. Where I have everything finished and I get to just show everything at once. So, you know, a couple spotlighters can say "oh wow" and no one else notices and life continues as normal...

 

I don't think there is really anything to fear: I think most people go into modding because they have a specific idea in mind to start with, but I play my little games.

Read my thoughts on my summer mod work and tell me what you think!

http://www.minecraftforge.net/forum/index.php/topic,8396.0.html

 

I absolutely love her when she smiles

Link to comment
Share on other sites

you have to go out with a bang like:

 

hey i made this its new its fresh nobody has done thsi before.

 

unless you're doign somethign dull like "obsidian tools" generally people will like what you've done

 

compatibility is important too. If your mod isnt compatible with the "mainstream" mods you will have problem ;)

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

I understand that you really think I shouldn't use commands. Well, I was planning to extend the Mod of course and this would be my first step into the next direction. I like to take small steps. Also, I'm not that new to programming. I'm just not that used to making Minecraft Mods (yet).

 

Now I hope my question is a bit more clear and it would be nice if someone could point me into the right direction. I've heard about TileEntities, adding Mobs, Drawing blocks over blocks, etc. I don't really know which way to go. I mean, I'd probably find out. It's just that I prefer asking for advice prior to reinventing the wheel :)

Link to comment
Share on other sites

I, uh, may have obsidian tools.

BUT

That is one of the things I did when I was learning how to mod. And I made it interesting. Kind of.

I have lots of other stuff that is part of my pack. And I plan on calling it a mini mod pack because I'll have several independent mod sections that can be turned on and off through config if someone cares enough.

Anyway, I'll let this thread continue. I've hijacked it long enough.

Read my thoughts on my summer mod work and tell me what you think!

http://www.minecraftforge.net/forum/index.php/topic,8396.0.html

 

I absolutely love her when she smiles

Link to comment
Share on other sites

I'm not that new to programming.

i wasn't necessarily referring to you, sorry :P

 

Tile Entity are basically extra information about a block, for example, sign have a tile entity that contains the text they are suppose to show

,beacon block contains information about their state (on off) and which buff they are giving

 

it is important to note that you cant place tile entities on block that dont support them, aka dirt, stone air, flower etc, etc

 

in my case i am using a new block called the plotblock. its tile entity contains the information about the width/height/length of the plot, this way i can use these information to draw a frame to visualize what are the limits that the plot owner can build in (as well as extra information like the cost of the plot etc etc)

 

the difference between using TE (tile entities) and entities is that tile entities are tied to a bloc. while entities are free to be placed anywhere.

you could technicly make an invisible entity that has information about the width/height/length of the protected area and x, y,z  and use this entity to draw a big box that represents the limit of the area.

 

for TE they're are good tutorial on the wiki about how why when to use them. as for entitiy i am not sure as i am not using them (yet).

 

@redria7, ahaha, sorry xD, but you understand what i mean?

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

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

    • rp.crazyheal.xyz mods  
    • I'm developing a dimension, but it's kinda resource intensive so some times during player teleporting it lags behind making the player phase down into the void, so im trying to implement some kind of pregeneration to force the game loading a small set of chunks in the are the player will teleport to. Some of the things i've tried like using ServerLevel and ServerChunkCache methods like getChunk() dont actually trigger chunk generation if the chunk isn't already on persistent storage (already generated) or placing tickets, but that doesn't work either. Ideally i should be able to check when the task has ended too. I've peeked around some pregen engines, but they're too complex for my current understanding of the system of which I have just a basic understanding (how ServerLevel ,ServerChunkCache  and ChunkMap work) of. Any tips or other classes I should be looking into to understand how to do this correctly?
    • https://mclo.gs/4UC49Ao
    • Way back in the Forge 1.17 days, work started for adding JPMS (Java Platform Module Support) to ModLauncher and ForgeModLoader. This has been used internally by Forge and some libraries for a while now, but mods (those with mods.toml specifically) have not been able to take advantage of it. As of Forge 1.21.1 and 1.21.3, this is now possible!   What is JPMS and what does it mean for modders? JPMS is the Java Platform Module System, introduced in Java 9. It allows you to define modules, which are collections of packages and resources that can be exported or hidden from other modules. This allows for much more fine-tuned control over visibility, cleaner syntax for service declarations and support for sealed types across packages. For example, you might have a mod with a module called `com.example.mod` that exports `com.example.mod.api` and `com.example.mod.impl` to other mods, but hides `com.example.mod.internal` from them. This would allow you to have a clean API for other mods to use, while keeping your internal implementation details hidden from IDE hints, helping prevent accidental usage of internals that might break without prior notice. This is particularly useful if you'd like to use public records with module-private constructors or partially module-private record components, as you can create a sealed interface that only your record implements, having the interface be exported and the record hidden. It's also nice for declaring and using services, as you'll get compile-time errors from the Java compiler for typos and the like, rather than deferring to runtime errors. In more advanced cases, you can also have public methods that are only accessible to specific other modules -- handy if you want internal interactions between multiple of your own mods.   How do I bypass it? We understand there may be drama in implementing a system that prevents mods from accessing each other's internals when necessary (like when a mod is abandoned or you need to fix a compat issue) -- after all, we are already modding a game that doesn't have explicit support for Java mods yet. We have already thought of this and are offering APIs from day one to selectively bypass module restrictions. Let me be clear: Forge mods are not required to use JPMS. If you don't want to use it, you don't have to. The default behaviour is to have fully open, fully exported automatic modules. In Java, you can use the `Add-Opens` and `Add-Exports` manifest attributes to selectively bypass module restrictions of other mods at launch time, and we've added explicit support for these when loading your Forge mods. At compile-time, you can use existing solutions such as the extra-java-module-info Gradle plugin to deal with non-modular dependencies and add extra opens and exports to other modules. Here's an example on how to make the internal package `com.example.examplemod.internal` open to your mod in your build.gradle: tasks.named('jar', Jar) { manifest { attributes([ 'Add-Opens' : 'com.example.examplemod/com.example.examplemod.internal' 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors // (...) ]) } } With the above in your mod's jar manifest, you can now reflectively access the classes inside that internal package. Multiple entries are separated with a space, as per Java's official spec. You can also use Add-Exports to directly call without reflection, however you'd need to use the Gradle plugin mentioned earlier to be able to compile. The syntax for Add-Exports is the same as Add-Opens, and instructions for the compile-time step with the Gradle plugin are detailed later in this post. Remember to prefer the opens and exports keywords inside module-info.java for sources you control. The Add-Opens/Add-Exports attributes are only intended for forcing open other mods.   What else is new with module support? Previously, the runtime module name was always forced to the first mod ID in your `mods.toml` file and all packages were forced fully open and exported. Module names are now distinguished from mod IDs, meaning the module name in your module-info.java can be different from the mod ID in your `mods.toml`. This allows you to have a more descriptive module name that doesn't have to be the same as your mod ID, however we strongly recommend including your mod ID as part of your module name to aid troubleshooting. The `Automatic-Module-Name` manifest attribute is now also honoured, allowing you to specify a module name for your mod without needing to create a `module-info.java` file. This is particularly useful for mods that don't care about JPMS features but want to have a more descriptive module name and easier integration with other mods that do use JPMS.   How do I use it? The first step is to create a `module-info.java` file in your mod's source directory. This file should be in the same package as your main mod class, and should look something like this: open module com.example.examplemod { requires net.minecraftforge.eventbus; requires net.minecraftforge.fmlcore; requires net.minecraftforge.forge; requires net.minecraftforge.javafmlmod; requires net.minecraftforge.mergetool.api; requires org.slf4j; requires logging; } For now, we're leaving the whole module open to reflection, which is a good starting point. When we know we want to close something off, we can remove the open modifier from the module and open or export individual packages instead. Remember that you need to be open to Forge (module name net.minecraftforge.forge), otherwise it can't call your mod's constructor. Next is fixing modules in Gradle. While Forge and Java support modules properly, Gradle does not put automatic modules on the module path by default, meaning that the logging module (from com.mojang:logging) is not found. To fix this, add the Gradle plugin and add a compile-time module definition for that Mojang library: plugins { // (...) id 'org.gradlex.extra-java-module-info' version "1.9" } // (...) extraJavaModuleInfo { failOnMissingModuleInfo = false automaticModule("com.mojang:logging", "logging") } The automatic module override specified in your build.gradle should match the runtime one to avoid errors. You can do the same for any library or mod dependency that is missing either a module-info or explicit Automatic-Module-Name, however be aware that you may need to update your mod once said library adds one. That's all you need to get started with module support in your mods. You can learn more about modules and how to use them at dev.java.
    • Faire la mise à jour grâce à ce lien m'a aider personnellement, merci à @Paint_Ninja. https://www.amd.com/en/support 
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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