Jump to content

Recommended Posts

Posted

I'm looking for a method to implement "fake" blocks into the client-side of forge and display them to the player; have them be passable (no collision) and surround the chunk coordinates.  I by no means want anyone writing code for me, but I'm relatively new to modding in forge and I'm struggling with finding classes in the jar that help with what I'm trying to accomplish. I'd like to achieve the following:
 

  • Get current chunk player is standing in
    • net.minecraft.world.chunk is where I was looking for this
  • Get the coordinates for each corner of the chunk
    • Seems lost in the above package somewhere, or I could just calculate this on my own?
  • Render the border of the chunk in passable (no collision) glass blocks client-side only.
    • This likely has to do with blockstates, but maybe there is a more best-practice way to achieve something like this? Client-side just has to do with SidedProxy I assume, and making sure the server knows nothing of these blocks.

      Just this information should be enough to hit the ground running with further implementation of my idea, as I build a foundation of where classes are and how events interact within Forge. Anyone willing to give me some basic direction here, it would be wonderfully appreciated.
Posted
9 minutes ago, Toomuchbob said:

Get current chunk player is standing in

World#getChunkFromBlockPos

And use the players position

9 minutes ago, Toomuchbob said:

Get the coordinates for each corner of the chunk

Multiply the chunk coordinates by sixteen and simply calculate from there(will give you one corner)

9 minutes ago, Toomuchbob said:

Render the border of the chunk in passable (no collision) glass blocks client-side only.

Use the RenderTickEvent and Minecraft#getBlockRendererDispatcher() to render your block of choice.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
27 minutes ago, Animefan8888 said:

Use the RenderTickEvent and Minecraft#getBlockRendererDispatcher() to render your block of choice.

How do you know what this does? I can't find any comments explaining this functionality. Is there a decent resource for learning this?

Posted
20 minutes ago, Toomuchbob said:

How do you know what this does?

You can read about a few things forge related. On the docs here. You will want to look at the "events" section if you dont know what these are or how to use them. RenderTickEvent is pretty self explanatory I think. I know about the BlockRenderDispatcher from experience.

22 minutes ago, Toomuchbob said:

I can't find any comments explaining this functionality. 

You won't find much comments on semi-advanced to advanced topics. You kinda need to look at the code and figure out what it does and what it is used for.

34 minutes ago, Toomuchbob said:

Is there a decent resource for learning this?

Events are pretty straightforward as mentioned above you can read about them at the link. However rendering code is most of the time unique so that isn't really covered in tutorials you can pieces things together from some online resources scattered over the internet. But it will mostly be from experimenting and reading the already existing code.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
6 hours ago, diesieben07 said:

No. Multiplication and division are not the proper way to convert between chunk and block coordinates.

block = chunk << 4

chunk = block >> 4

For those who are wondering why, the problem is shifting right does not always produce the same results as dividing by 2. Since right shifting rounds toward negative infinity and integer division rounds to zero, some values (like -1 in two's complement) will just not work as expected when divided.

  • Like 1

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted
21 hours ago, Animefan8888 said:

You can read about a few things forge related. On the docs here. You will want to look at the "events" section if you dont know what these are or how to use them. RenderTickEvent is pretty self explanatory I think. I know about the BlockRenderDispatcher from experience.

I assume you meant BlockRendererDispatcher, as I can't seem to find a BlockRenderDispatcher class. Is there a decent way to start learning forge modding?  Tutorials are mostly bad or only cover new items and blocks. I actually made what I want to accomplish in Bukkit a few years ago without much hassle; Forge is much more robust, but also much more difficult because of this, and with little to no documentation, very difficult to learn.

Posted
1 hour ago, Toomuchbob said:

Is there a decent way to start learning forge modding?

A good way to do this is to kinda sit on the forums and read anything that sounds interesting or anything at all. Because people that help on here tend to have been modding for many years with forge or have worked on forge itself either with PRs on github or actually work on it like LexManos. 

1 hour ago, Toomuchbob said:

I assume you meant BlockRendererDispatcher, as I can't seem to find a BlockRenderDispatcher class.

Indeed.

1 hour ago, Toomuchbob said:

I actually made what I want to accomplish in Bukkit a few years ago without much hassle

Bukkit as a API is much simpler to use because you cant do too much with it, also you are only ever interacting with the Server side of things, except for sending packets. There is also the limiting factor of not having access to all the Minecraft classes in it of it self.

1 hour ago, Toomuchbob said:

and with little to no documentation

Most of this is actually in vanilla's code base. Forge has plenty of documentation on it's own stuff, but I will say it is difficult to learn how to do stuff like this without documentation or with out knowing where to look.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
On 9/25/2018 at 9:26 PM, Animefan8888 said:

"Use the RenderTickEvent..."

From what I can gather from old posts about Tick events, this doesn't update every frame, but rather by the servers tick rate (20Hz), will I run into rendering issues or is this no longer the case?

 

Posted
12 minutes ago, Toomuchbob said:

From what I can gather from old posts about Tick events, this doesn't update every frame, but rather by the servers tick rate (20Hz), will I run into rendering issues or is this no longer the case?

 

RenderTick != Tick

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.

Posted

I've been reading through BlockRendererDispatcher and it's going completely over my head. Without any prior forge modding experience, a lot of this is overwhelming. Can someone provide me with some "cliffs notes", so to speak, as to what is going on in that class?

Posted
1 hour ago, Toomuchbob said:

I've been reading through BlockRendererDispatcher and it's going completely over my head. Without any prior forge modding experience, a lot of this is overwhelming. Can someone provide me with some "cliffs notes", so to speak, as to what is going on in that class?

Pretty much nothing honestly, I’ve been reading over it a lot recently and, correct me if I’m wrong, it basically just determines if the block is a block or a fluid.

if it’s a block it then passes it to BlockModelRenderer (which passes it to Forge’s optimised renderer - look at ForgeBlockModelRenderer).

if it’s a fluid then it passes it to BlockFluidRenderer. (The code in here is still technica but not as absolutely impenetrable as Forges block renderer is (to me at least))

 

this answer is based heavily on my own “research” and experience. Please feel free to ask about specific parts of the code

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
6 hours ago, Cadiboo said:

Pretty much nothing honestly, I’ve been reading over it a lot recently and, correct me if I’m wrong, it basically just determines if the block is a block or a fluid.

if it’s a block it then passes it to BlockModelRenderer (which passes it to Forge’s optimised renderer - look at ForgeBlockModelRenderer).

if it’s a fluid then it passes it to BlockFluidRenderer. (The code in here is still technica but not as absolutely impenetrable as Forges block renderer is (to me at least))

 

this answer is based heavily on my own “research” and experience. Please feel free to ask about specific parts of the code

I guess this has to eventually go back to a list of all blocks in the game somewhere, and I'm just telling it what blocks to render?
 

public BlockRendererDispatcher(BlockModelShapes p_i46577_1_, BlockColors p_i46577_2_)
public BlockRendererDispatcher(BlockModelShapes p_i46577_1_, BlockColors p_i46577_2_)

It's hard to track down stuff in minecraft's code until you become familiar with it, that much is obvious. I can't find what these two arguments are asking for, and it's likely because I don't understand what BlockRendererDispatcher really does. Maybe I'm thinking about it wrong, but I figured I'd just be telling it to render a certain kind of block, but instead it's asking for Shapes and Colors, and I don't get why.

Posted

What exactly are you doing? You don't need to construct a new instance of BlockRendererDispatcher. All you need to do is call BlockRendererDispatcher#renderBlock. You can get an instance of BlockRendererDispatcher from MInecraft#getBlockRendererDispatcher and you can get an instance of Minecraft from Minecraft.getMinecraft(). That's it.

However there is an issue with BlockRendererDispatcher#renderBlock where it asks the block for an extended blockstate. If it is a mod block that uses a TileEntity and extended state to pass some properties from the tile entity to the blockstate this will crash the game if the mod assumes that there is a tile entity at the position passed. That's why usually when people want to render blocks that aren't really there a fake world is used.

Posted
4 minutes ago, V0idWa1k3r said:

What exactly are you doing? You don't need to construct a new instance of BlockRendererDispatcher. All you need to do is call BlockRendererDispatcher#renderBlock. You can get an instance of BlockRendererDispatcher from MInecraft#getBlockRendererDispatcher and you can get an instance of Minecraft from Minecraft.getMinecraft(). That's it.

However there is an issue with BlockRendererDispatcher#renderBlock where it asks the block for an extended blockstate. If it is a mod block that uses a TileEntity and extended state to pass some properties from the tile entity to the blockstate this will crash the game if the mod assumes that there is a tile entity at the position passed. That's why usually when people want to render blocks that aren't really there a fake world is used.

I haven't "done" anything yet. I'm trying to understand how this stuff works before I put it into practice. 

Posted

Well, BlockRendererDispatcher is a dispatcher. When the time comes to redraw a region the game iterates over blocks and sends the blockstates and positions it iterated through to the BlockRendererDispatcher along with the world the rendering is going in + the buffer for the vertices. That's all 4 arguments to the BlockRendererDispatcher#renderBlock. The dispatcher then decides how to render the block. It gets the EnumBlockRenderType from the state passed and checks against it. If it is INVISIBLE the block isn't rendered at all. If it is MODEL then the dispatcher gets the model for the blockstate it was passed and passes the rendering to BlockModelRenderer. If the render type is a LIQUID then it passes the rendering to a BlockFluidRenderer. Otherwise no rendering is done.

BlockModelRenderer gets the model and iterates it's quads by side. It checks whether the quad should be rendered and if it is uploads it to the buffer(before that it applies lighting and color multiplier to the quad though). Oh and it also decides whether to render the quads "smooth"(read: with ambient occlusion) or "flat".

BlockFluidRenderer is only used for water and lava since forge added fluids actually have a fluid model(kinda). Then it calculates the sides that should be rendered, the heights of the corners of the fluid interpolates the texture and uploads the resulting quads to the buffer.

That's about how it all works. Since all methods are public you can invoke any part of the process yourself and render models/quads/blockstates to a custom BufferBuilder.

Posted

This has really got me stumped. So much so that I don't even know what kind of question to ask at this point. I've always had a much better understanding of things by simply doing them and learning from existing examples. But I can't get anything working because I apparently picked something much more complex that other stuff (or I simply understand the other stuff more because there are examples of it). Scoring the internet for anyone just rendering a client-side block, can't find even a hint of an example.  I guess just venting my frustrations as I continue to pick away at it.

Posted
22 hours ago, Toomuchbob said:

This has really got me stumped. So much so that I don't even know what kind of question to ask at this point. I've always had a much better understanding of things by simply doing them and learning from existing examples. But I can't get anything working because I apparently picked something much more complex that other stuff (or I simply understand the other stuff more because there are examples of it). Scoring the internet for anyone just rendering a client-side block, can't find even a hint of an example.  I guess just venting my frustrations as I continue to pick away at it.

You should be able to subscribe to the RenderWorldLast event translate (and scale?) to world coordinates & then just call BlockRenderDispatcher#renderBlock. Don't forget to translate (and scale?) back to 0, 0, 0!

Take a look at https://github.com/Cadiboo/WIPTechAlpha/blob/c179d852e43f08d6e9f34db62bd2a59c36475e6b/src/main/java/cadiboo/wiptech/client/ClientEventSubscriber.java#L509-L579 but don't just do what I did. I directly drew the cube with buffer Builder. you should use BlockRenderDispatcher#renderBlock

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
54 minutes ago, Animefan8888 said:

RenderTickEvent

Why RenderTick & not RenderWorldLast? he's rendering blocks into the world, I thought it would be better to run it along with the other world rendering

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
14 hours ago, Cadiboo said:

Why RenderTick & not RenderWorldLast? he's rendering blocks into the world, I thought it would be better to run it along with the other world rendering

Nevermind it is probably better to do it in RenderWorldLastEvent. But I'm not sure haven't been able to sit down and look at stuff in a while. School just started up and today is my first day off since.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

  • 3 months later...
Posted

I took a break from this after a month or so of getting nowhere while I focused on a new job I got. I'm back, and trying to figure this stuff out and well, I'm still just as lost as I was before.  I've managed to wrap my head around the blockRendererDispatcher (I think) But I'm completely thrown off by @Cadiboo's example code, where s/he doesn't use any of the methods discussed in previous posts on this thread. If I could even figure out how to render a single block somewhere in the world I feel like I'd have some footing, but I can't even find examples of that.

Posted

BlockRendererDispatcher renders the block for you, what you need to do is set up the correct translations and start & end the BufferBuilder. What exactly do you want an example of?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
58 minutes ago, Cadiboo said:

BlockRendererDispatcher renders the block for you, what you need to do is set up the correct translations and start & end the BufferBuilder. What exactly do you want an example of?

Rendering a block (lets say iron ore) somewhere in the world. Doesn't matter where or what. But just an example I can load and see the block in the world rendered, and start figuring out from there. 

Posted (edited)
4 hours ago, Toomuchbob said:

Rendering a block (lets say iron ore) somewhere in the world. Doesn't matter where or what. But just an example I can load and see the block in the world rendered, and start figuring out from there. 

https://gist.github.com/Cadiboo/7e46eb6e59d94c29d12dfdb087ea8b9f

This took me about 2 hours longer than it should have, I forgot to call draw on the tessellator instead of the bufferBuilder... It draws a trail of iron ore behind the render view entity.

 

This method renders everything each frame, which may/may not be what you want. It is the most compatible way to achieve this, but also one of the most performance intensive

Edited by Cadiboo

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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