Jump to content

Custom Block Renderer


SethGunnells

Recommended Posts

Hey guys. I'm relatively new to this whole modding scene, but I've got a pretty solid Java background.

 

Here's the skinny: I'm trying to create a block with a custom shape and appearance. I've created a model and texture and it seems to be correct. What I'm now trying to figure out is how to tell Minecraft to use my model when rendering my block. My searches have turned up little information on this subject and what information I've found is either outdated or doesn't seem to agree with anything else I've read. I think it would be helpful if I understood the flow of information in terms of how Minecraft renders blocks, but I can't even begin to attempt to trace through Minecraft's rendering code.

 

The bottom line is this: how do I use a custom model for a block? Thanks for any help.

Link to comment
Share on other sites

you can check out these source files (it's a simple decorative block):

https://github.com/mnn/jaffas/blob/master/src/minecraft/monnef/jaffas/food/block/BlockColumn.java

https://github.com/mnn/jaffas/blob/master/src/minecraft/monnef/jaffas/food/client/TileEntityColumnRenderer.java

https://github.com/mnn/jaffas/blob/master/src/minecraft/monnef/jaffas/food/client/ClientProxy.java#L39

https://github.com/mnn/jaffas/blob/master/src/minecraft/monnef/jaffas/food/client/ModelColumn.java

the model class comes from Techne with just few modifications (if I remember correctly setRotationAngles and render methods).

^source code is working, but some things may be redundant or not done the best way (like manual creation of TE by block).

 

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Link to comment
Share on other sites

  • 2 weeks later...

Ive been messing around with custom model block and just had a question.  Basically the model is like a fence block where it will render differently if certain conditions are met.  Im wondering the best place to put these conditions.  I've gotten it to work but Im just paranoid that I put it in the wrong place, because it seems like I may have put the conditions in a place where each block checks the conditions every second, but I want it only to check when the blocks surrounding it change.

 

I placed the conditions in the renderModelAt function within my TileEntityRenderer and it passes those conditions to the model and renders.  Obviously though the conditions will only change the model when an adjacent block is changed so I wouldn't need to do these checks when that happens, but I am having a hunch that the check is happening continuously though I could be wrong.  Hope I explained that properly.  If anyone could give some advice that would be great.

Link to comment
Share on other sites

renderModelAt is called not every second, but every frame (for each your custom block). I'd move the checks into block's onNeighborBlockChange (and fire block changed when renderer type changes).

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Link to comment
Share on other sites

I'd do this: add a field to fence TE, this field will store which model to render (I mean type like crossing or single rod). this field will be used in renderer instead of the heavy conditions. to the fence block on neighbour change you'd move those conditions and result would be saved in the TE's field. You might need to alert neighbour blocks if your render type changes (it depens on how exactly you have implemented conditions).

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

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

    • Hi! This is my first time creating a mod in Minecraft. It will be for personal use, and the goal is to play creepy/scary music at night. I want it to play without overlapping with Minecraft music (C418, etc.). I have almost finished it, but I don't know how to detect if Minecraft music is playing. I tried accessing a "currentMusic" variable in the MusicManager class via reflection, but it doesn't work.   Class<?> musicManagerClass = musicManager.getClass(); java.lang.reflect.Field currentMusicField = musicManagerClass.getDeclaredField("currentMusic"); currentMusicField.setAccessible(true); currentMusic = (SoundInstance) currentMusicField.get(musicManager); Does anyone know how to do it?
    • Please I need help if anyone can I will leave the log below         [15jun2024 18:11:44.134] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, {MINECRAFT_USERNAME}, --version, 1.16.5, --gameDir, C:\Users\{COMPUTER_USERNAME}\AppData\Roaming\com.modrinth.theseus\profiles\xD, --assetsDir, C:\Users\{COMPUTER_USERNAME}\AppData\Roaming\com.modrinth.theseus\meta\assets, --assetIndex, 1.16, --uuid, {MINECRAFT_UUID}, --accessToken, ????????, --userType, msa, --versionType, release, --width, 854, --height, 480, --launchTarget, fmlclient, --fml.forgeVersion, 36.2.39, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20210115.111550] [15jun2024 18:11:44.136] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 8.1.3+8.1.3+main-8.1.x.c94d18ec starting: java version 1.8.0_412 by Azul Systems, Inc. [15jun2024 18:11:44.525] [main/INFO] [net.minecraftforge.fml.loading.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust [15jun2024 18:11:44.574] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.4 Source=file:/C:/Users/{COMPUTER_USERNAME}/AppData/Roaming/com.modrinth.theseus/meta/libraries/org/spongepowered/mixin/0.8.4/mixin-0.8.4.jar Service=ModLauncher Env=CLIENT [15jun2024 18:11:46.205] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'fmlclient' with arguments [--version, 1.16.5, --gameDir, C:\Users\{COMPUTER_USERNAME}\AppData\Roaming\com.modrinth.theseus\profiles\xD, --assetsDir, C:\Users\{COMPUTER_USERNAME}\AppData\Roaming\com.modrinth.theseus\meta\assets, --uuid, {MINECRAFT_UUID}, --username, {MINECRAFT_USERNAME}, --assetIndex, 1.16, --accessToken, ????????, --userType, msa, --versionType, release, --width, 854, --height, 480] [15jun2024 18:11:46.676] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException [15jun2024 18:11:46.677] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:39) [15jun2024 18:11:46.677] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [15jun2024 18:11:46.677] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [15jun2024 18:11:46.677] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [15jun2024 18:11:46.678] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [15jun2024 18:11:46.678] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: Caused by: java.lang.reflect.InvocationTargetException [15jun2024 18:11:46.678] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [15jun2024 18:11:46.678] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [15jun2024 18:11:46.678] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [15jun2024 18:11:46.679] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at java.lang.reflect.Method.invoke(Method.java:498) [15jun2024 18:11:46.679] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at net.minecraftforge.fml.loading.FMLClientLaunchProvider.lambda$launchService$0(FMLClientLaunchProvider.java:37) [15jun2024 18:11:46.679] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [15jun2024 18:11:46.679] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     ... 4 more [15jun2024 18:11:46.679] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: Caused by: java.lang.NoSuchMethodError: org.apache.logging.log4j.core.impl.ThrowableProxy.formatExtendedStackTraceTo(Ljava/lang/StringBuilder;Ljava/util/List;Lorg/apache/logging/log4j/core/pattern/TextRenderer;Ljava/lang/String;Ljava/lang/String;)V [15jun2024 18:11:46.680] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at cpw.mods.modlauncher.log.TransformingThrowablePatternConverter.generateEnhancedStackTrace(TransformingThrowablePatternConverter.java:87) [15jun2024 18:11:46.680] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraftforge.fml.CrashReportExtender.generateEnhancedStackTrace(CrashReportExtender.java:65) [15jun2024 18:11:46.680] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraftforge.fml.CrashReportExtender.generateEnhancedStackTrace(CrashReportExtender.java:55) [15jun2024 18:11:46.680] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraft.crash.CrashReport.func_71498_d(CrashReport.java:119) [15jun2024 18:11:46.680] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraft.crash.CrashReport.func_71502_e(CrashReport.java:135) [15jun2024 18:11:46.681] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraft.crash.CrashReport.func_230188_h_(CrashReport.java:248) [15jun2024 18:11:46.681] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraft.client.main.Main.main(Main.java:122) [15jun2024 18:11:46.681] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     ... 10 more    
    • the installer fails to download files it needs. below is an excerpt from the logs.   Error checking https://files.minecraftforge.net/: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target  
    • Whenever i load up any forge version, even without mods, it will crash, even if it's a pre-constructed, very popular, public one, it'll still crash, here's the current modpack i'm trying to load's log (popular create mod one, + not enough crashes); https://pastebin.com/gtuAhVJ8 , and without mods; https://pastebin.com/qVJCdxcN
    • Is your issue fixed? if it is fixed please tell me how did you fixed it. Because im getting the same error.
  • Topics

×
×
  • Create New...

Important Information

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