Jump to content

[1.10.2] Rotate block-model by small degrees -without- TESR?


Matryoshika

Recommended Posts

I've been coding a couple of "utility" blocks (speeds furnaces, picks up stuff, places stuff, etc). They all look the same (.obj models FYI, with only difference being the colour).

I want to change their yaw, that is, make them rotate around the y-axis, very slowly. That is all I want these to do.

However, I do not see TESR rendering being an option at all, due to the amount of different blocks, each with their own functionality. A player just near a couple of these (7-8), will see a notable decrease in FPS.

 

So, I'm asking this: Is there an option available to render these models, that fills these requirements?

1) Less overhead compared to standard TESR.

2) Gives access (direct or hell, even with reflection if needed) to rotating the model around at least the y-axis.

3) Easily implementable for several different blocks. (For example, being required to pass the type, brings issues with long list of copy/paste'd code with only difference being the passed type, every 20 lines.)

 

I have already tested Forge's own CapabilityAnimation to render these, but that very quickly becomes extremely bulky when being implemented for several blocks. The added requirement of having a block, tile AND an entity, for each damned model... just no. Please spare me. The damned ClientProxy (or the class being initialized FROM it, would be ~amount of blocks*30 lines long. With 5 already made, another 10 planned, and who knows in the future, that'd be a ridiculous copy/paste'd wall of text)

 

If I'm out of luck, and nothing like this exists, I'm thinking of simply removing the TileEntity code, and have the block place down a proper Entity instead, which does the same thing that the TileEntity did, of which I can have it's onUpdate() simply edit the yaw by a degree every ~2-3 seconds. Would there be any significant drawbacks from this?

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Link to comment
Share on other sites

I'm talking about 1 degree every ~2 seconds.

I thought the blockstate was locked at multiples of 90? (or was that 22.5?)

 

If this is that easy, I'm going to cry...

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Link to comment
Share on other sites

I'm talking about 1 degree every ~2 seconds.

I thought the blockstate was locked at multiples of 90? (or was that 22.5?)

 

If this is that easy, I'm going to cry...

 

Blockstates only allow rotating models in increments of 90 degrees. Item/block models allow individual elements to be rotated in increments on 22.5 degrees.

Link to comment
Share on other sites

So I'm taking it that using an Entity instead of TileEntity is the only viable option for animation without the overhead, and with sane amounts of code per implementation?

All this trouble for rotating the yaw of the model =_=

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Link to comment
Share on other sites

Have you actually tried a TESR? Only a few of those around shouldn't impact your FPS a lot.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Have you actually tried a TESR? Only a few of those around shouldn't impact your FPS a lot.

I did.

I got 5 Utility blocks. These are meant to do specific tasks, like picking up EntityItems, from example the (internally named) CropGrower that grows and harvests pretty much anything that implements IGrowable, and more (stems, sugarcane etc), or reversely, the blockplacer that places EntityItems if possible. My point is: These are meant to be commonly used blocks for setups in your base!

I was testing with 8 of the CropGrowers, and my FPS dropped by a considerate amount! Still above 60, but the point is made. I do not want to create a renderer that will be shared by many (5 made, 10 more planned, who knows after that) blocks, which can make the game unplayable for people who are unlucky enough to have bad computers!

 

As far as I've read, TESR's do not bake the model, hence why they are lacking in optimization.

Of course, you can get a baked model and render it after translating it, using

Minecraft::renderModel

in the

renderTileEntityAt

method, however, damage is still done, as the TESR is made to scrap and re-draw every damned frame.

The model itself is a floating crystal. Translucent. About 85% alpha. It also needs to spin. Apart from the translation, there also needs to be GLxx calls to enable blend, do blend, rotate, and after rendering, undo these (blend is needed as I cannot seem to replicate the behaviour of

BlockRenderLayer.TRANSLUCENT

).

Translate + enableBlend + blend + rotate + undo blend + undo rotate + disableBlend = 7 calls to GLxx. That's far from a simple baked model.

 

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Link to comment
Share on other sites

Hi

 

Block models will never work for that type of animation because they aren't updated every frame.  They are compiled once into a render list or vertex buffer and not refreshed unless the blocks are modified (created, destroyed, blockstate changed, etc).

 

You can animate the texture but that's it.

 

I think a TESR is your best option.  If it's causing a massive slowdown it's almost certainly because you've implemented it inefficiently, or perhaps your model is too complicated (too many quads).  If you compile your quads to a vertex buffer, cache it, and draw that in your TESR, it will be just as fast as drawing block models, maybe faster.

 

-TGG

Link to comment
Share on other sites

@TGG

Thank you.

Yes, I know the model of the block cannot be "animated" however, you can -use- that model TO animate.

[spoiler=Example]

Example code: https://github.com/Matryoshika/Underworld/blob/master/src/main/java/se/Matryoshika/Underworld/Content/Rendering/TERenderEnderPortal.java

Example image: tkQK6ru.png

 

 

 

The code inside the spoiler is what I have been using mostly, to render special blocks and TESR's, however, for very common blocks, the overhead would have been too much for my liking, thus why I made this thread.

However, I've hit a wall that sadly means I need to give up the rotational aspect of the blocks. While I can render the .obj-models, they render without any visible edges in the model. Think of a monotone colored model, where the edges blend together too well.

However, you did manage to teach me how to optimize my TESR's, for which I am quite thankful for.

The blocks will be too dull as just blocks, so I will keep the TESR's, just have them work in tandem with the actual block-model.

 

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Link to comment
Share on other sites

Hi

 

However, I've hit a wall that sadly means I need to give up the rotational aspect of the blocks. While I can render the .obj-models, they render without any visible edges in the model. Think of a monotone colored model, where the edges blend together too well.

Yeah that is a problem if you don't use lighting.  The vanilla blocks use a manual lighting method for faces which point east, north, etc.  Vanilla items use a couple of openGL light sources.  So you could try turning on the item lighting which might make your edges show up better.  Alternatively you could change some of the quad textures to be a bit brighter or duller.

A bit more info here...

http://greyminecraftcoder.blogspot.com/2014/12/lighting-18.html

 

However, you did manage to teach me how to optimize my TESR's, for which I am quite thankful for.

The blocks will be too dull as just blocks, so I will keep the TESR's, just have them work in tandem with the actual block-model.

I've used that before and it can work really well; the block model part blends nicely with the scenery and the animated bit is easy to render separately.

I've put an example of something like that in this tutorial project:

https://github.com/TheGreyGhost/MinecraftByExample

(see MBE21)

 

-TGG

 

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Another Minecraft Launcher https://multimc.org/#Download or https://atlauncher.com/downloads
    • Remove these mods and combine OptiFine HD U I6 with Forge 47.2.18 Start with Optifine - without any other mods - if this works, add the mods one by one or in groups until you find the mod, conflicting with Optifine
    • Ok yeah I think this might be where the problem starts. For starters, I think you can get rid of your RecipeType impl and make it a static constant instead. I'm not 100% sure this will fix it but it's posssible. RuneInscribingRecipe public class RuneInscribingRecipe implements Recipe<SimpleContainer> { public static final RecipeType<RuneInscribingRecipe> RECIPE_TYPE = new RecipeType<>(){}; // .... @Override public RecipeType<?> getType() { return RECIPE_TYPE; } // .... } RuneInscriberMenu private Optional<RecipeHolder<RuneInscribingRecipe>> getCurrentRecipe() { SimpleContainer inventory = new SimpleContainer(2); inventory.setItem(BASE_INPUT_SLOT, this.inventory.getStackInSlot(BASE_INPUT_SLOT)); inventory.setItem(TEMPLATE_INPUT_SLOT, this.inventory.getStackInSlot(TEMPLATE_INPUT_SLOT)); List<RecipeHolder<RuneInscribingRecipe>> list = this.blockEntity.getLevel().getRecipeManager().getRecipesFor(RuneInscribingRecipe.RECIPE_TYPE, inventory, this.blockEntity.getLevel()); if (list.isEmpty()) { return Optional.empty(); } return Optional.of(list.get(0)); }   Also, this here is a little suspicious where you're getting the `this.inventory.getStackInSlot` calls. I'd try and make sure those are what you expect they are with either a Debug line in IDE or print statement SimpleContainer inventory = new SimpleContainer(2); inventory.setItem(BASE_INPUT_SLOT, this.inventory.getStackInSlot(BASE_INPUT_SLOT)); System.out.printf("CHECKING BASE INPUT OF RECIPE: %s\n", this.inventory.getStackInSlot(BASE_INPUT_SLOT)); inventory.setItem(TEMPLATE_INPUT_SLOT, this.inventory.getStackInSlot(TEMPLATE_INPUT_SLOT)); System.out.printf("CHECKING TEMPLATE INPUT OF RECIPE: %s\n", this.inventory.getStackInSlot(TEMPLATE_INPUT_SLOT)); ^ See what the result of those print statements are, make sure they're right
    • Upon testing again after adding them, the game still doesn't crash however the resource packs are still unfortunately broken.
    • Hi! Can someone please point me to the correct FAQ or place? I'm not able do DuckDuckGo myself out of this one. As you can hopefully see, chunks are not rendered. I run a forge server, fresh install on a linux VM. Curseforge on the Win11 client with Embeddium, Oculus and Unbound shader. No mods. Forge 47.2.23 on server & client.  No errors, no crashes, no apparent CPU or RAM issues with the VM. This screenshot was captured while creative, but the same happens when flying in survival. Waiting (floating) for a few minutes sooner or (often) later, lets the missing chunks appear. Usually takes 5-10 minutes.  When on a local game, the chunks appear slowly, but they do appear without pause.   This must be something simple, obvious, but I can't find the correct "search words" to find my way out. "Chunks not loading / rendering" didn't help. Browsing several forums neither. 
  • Topics

×
×
  • Create New...

Important Information

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