Jump to content

Recommended Posts

Posted

Hi,

I was wondering if anyone could help me with making my entity use an obj model instead of the model that I made with Tabula.

if you can please tell me in detail what I need to do of if you know someone that already showed how, please link it to me.

 

Thank you very much if anyone can help :)

Posted

OBJ models for entities are not supported/implemented.

You would either need a custom wavefront parser/uploader or you would register the OBJ model for an item and render the resulting IBakedModel in the same way RenderEntityItem does that.

Posted
3 minutes ago, V0idWa1k3r said:

OBJ models for entities are not supported/implemented.

You would either need a custom wavefront parser/uploader or you would register the OBJ model for an item and render the resulting IBakedModel in the same way RenderEntityItem does that.

Actually I'm trying to create 2 types of entities with obj models: a throwable and a mob.

 

Do you know how I should make the custom wavefront parser/uploader?

I have never used IBakedModel before.. what do I do?

 

thank you

Posted
6 minutes ago, Thegametutor101 said:

Do you know how I should make the custom wavefront parser/uploader?

 

Look up the wavefront format on a wikipedia, write a parser. This is not so much of a minecraft issue as a general coding issue.

 

6 minutes ago, Thegametutor101 said:

 I have never used IBakedModel before.. what do I do?

 

 

12 minutes ago, V0idWa1k3r said:

egister the OBJ model for an item and render the resulting IBakedModel in the same way RenderEntityItem does that.

 

Posted
23 minutes ago, V0idWa1k3r said:

Look up the wavefront format on a wikipedia, write a parser. This is not so much of a minecraft issue as a general coding issue.

I found this piece of code but I don't know if this would work or what I would even do with it:

https://github.com/syoyo/tinyobjloader/blob/master/tiny_obj_loader.h

I would really appreciate it if you could explain a little more, please.

 

24 minutes ago, V0idWa1k3r said:

egister the OBJ model for an item and render the resulting IBakedModel in the same way RenderEntityItem does that.

If I understand this correctly you mean that once my OBJ item model is registered I use the IBakedModel to render said OBJ item model through the RenderEntityItem? I don't know how to do that nor how to access or use an IBakedModel.

Can you please show me how or explain a littles more?

 

Thank you

Posted
6 minutes ago, Thegametutor101 said:

I found this piece of code but I don't know if this would work or what I would even do with it:

 

This is a header file for C++. Why would you search for an obj parser for C++ I have no clue.

 

6 minutes ago, Thegametutor101 said:

If I understand this correctly you mean that once my OBJ item model is registered I use the IBakedModel to render said OBJ item model through the RenderEntityItem?

No. Register the OBJ model as a model for one of your items, then do the same RenderEntityItem does for rendering the resulting IBakedModel. I don't think a better explanation is possible.

 

7 minutes ago, Thegametutor101 said:

Can you please show me how

 

39 minutes ago, V0idWa1k3r said:

in the same way RenderEntityItem does that.

I gave you the class name that does the rendering. All you have to do is open said class's sources using the IDE of your choice and see how it is done there.

Posted
33 minutes ago, V0idWa1k3r said:

This is a header file for C++. Why would you search for an obj parser for C++ I have no clue.

 

No. Register the OBJ model as a model for one of your items, then do the same RenderEntityItem does for rendering the resulting IBakedModel. I don't think a better explanation is possible.



I gave you the class name that does the rendering. All you have to do is open said class's sources using the IDE of your choice and see how it is done there.

I'm trying this but I don't know if this is correct.

BTW, I'm new so if you can help me I am happy, but please just don't be arrogant.

RenderThrowablePokeball.PNG

Posted
6 minutes ago, Thegametutor101 said:

BTW, I'm new so if you can help me I am happy, but please just don't be arrogant.

 

I am not being arrogant, you are just making mistakes that make no sense. The purpose of you being here is to learn and first step to learning is understanding your wrongs.

Like here, in the screenshot attached you are using a wavefront object MODEL file as your TEXTURE location. This makes no sense and you should understand that just by looking at it and thinking "So I need to bind a texture, which is an image file in it's nature but here I am telling the game to bind an obj model file(which is just a text file) as a texture". I do understand that you are new to modding(in which case you should probably start with something simpler than implementing a feature that is not supported) but these are just mistakes that need a bit of logic to understand and you should always apply logic to programming, otherwise you are not really programming, are you? I am sorry if I sound arrogant, I just wish for people to learn, otherwise they will keep coming back here with every tiny thing.

You also keep doing only half of what I am telling you to do.

44 minutes ago, V0idWa1k3r said:

Register the OBJ model as a model for one of your items

 

 

Posted

That's actually really well said.. thank you :) and I am honestly trying to do what you tell me to I really have a hard time understanding, sorry.

 

I am already rendering the OBJ model in game for my pm:pokeball. Are you telling me to do something else as well?

 

I know the texture should be a .png file but I don't know how I should do this because I have the blockstates json file calling my obj file in the models/item and that uses the mtl file but the textures were directly injected into the mtl file and I have no Idea how to do it otherwise..

 

You are right though I should try something less big to start..I just wanted to try and understand how to do it and then I will try putting my focus toward other parts of the mod.

Posted

So basically what you want to do is a little workaround the issue of not being able to render the OBJ models for an entity by using forge.

 

Forge has a system for loading the OBJ models for item/block models. In actuality it converts the OBJ vertices into a format that the game understands but that's an implementation detail.

 

You also know that the game can render items in various forms, like when you toss an item on the ground it renders in the world as a 3D model. 

 

If said item were to have an OBJ model assigned as it's model then when you toss the item said OBJ model would render in world, which is kinda what you want in the end.

 

So, the logical place to look would be RenderEntityItem which is the class responsible for actually rendering the item in the world to see how it is doing it.

 

The problem however is the fact that it gets the model to render in world from the ItemStack, which contains the item. There are ways around that, sure, you can have independent IBakedModel instances but that is complicated, so the simple option is to have an item that is assigned the OBJ model you want to use and simply do the same RenderEntityItem does but instead of getting the ItemStack from the entity pass it a constant ItemStack that contains the item that has the model assigned.

 

As for which texture to use - minecraft stiches all item/block textures together into a singular image for performance reasons. So you would just use that image as your texture and I am pretty sure RenderEntityItem has a reference to that image.

Posted (edited)
On 5/7/2019 at 3:54 PM, V0idWa1k3r said:

So, the logical place to look would be RenderEntityItem which is the class responsible for actually rendering the item in the world to see how it is doing it.

Thank you for the explanation!

On 5/7/2019 at 3:54 PM, V0idWa1k3r said:

The problem however is the fact that it gets the model to render in world from the ItemStack, which contains the item. There are ways around that, sure, you can have independent IBakedModel instances but that is complicated, so the simple option is to have an item that is assigned the OBJ model you want to use and simply do the same RenderEntityItem does but instead of getting the ItemStack from the entity pass it a constant ItemStack that contains the item that has the model assigned. 

I think I understand, is this what I am supposed to do?:

ItemStack itemstack = new ItemStack(Pokeballs.POKEBALL);

 

On 5/7/2019 at 3:54 PM, V0idWa1k3r said:

As for which texture to use - minecraft stiches all item/block textures together into a singular image for performance reasons. So you would just use that image as your texture and I am pretty sure RenderEntityItem has a reference to that image.

I tried looking in the RenderEntityItem class and I'm not sure if this is the "AllinOne" texture:

    protected ResourceLocation getEntityTexture(EntityItem entity)
    {
        return TextureMap.LOCATION_BLOCKS_TEXTURE;
    }

 

Edited by Thegametutor101
Posted
6 minutes ago, Thegametutor101 said:

I think I understand, is this what I am supposed to do?:



 

Sure, just don't construct it every frame.

 

7 minutes ago, Thegametutor101 said:

I tried looking in the RenderEntityItem class and I'm not sure if this is the "AllinOne" texture:



 

Yes it is.

 

Quote

here is the full RenderEntityItem class:

Please don't post copyrighted code on the forums. We can all see this class in our IDE, there is 0 reason to post it here.

Posted
4 minutes ago, V0idWa1k3r said:

Sure, just don't construct it every frame.

ok!

 

4 minutes ago, V0idWa1k3r said:

Please don't post copyrighted code on the forums. We can all see this class in our IDE, there is 0 reason to post it here.

oh..sorry about that.

Posted
7 hours ago, V0idWa1k3r said:

This indicates that you haven't registered your renderer.

Indeed I forgot to do it so now it is registered both the entity and the render in the Main's Init method.

	@EventHandler
	public static void init(FMLInitializationEvent event) {
		ThrowableRegistryHandler.registerThrowableEntities();
		ThrowableRenderHandler.registerThrowableEntityRenders();
		
		ApricornSmelting.init();
		AluminiumSmelting.init();
	}

I loaded the mod and it still doesnt work..same white cube

Posted
24 minutes ago, V0idWa1k3r said:

This is too late to register the renderer. Register it earlier

I put it in the preInit now and it gave me this crash report:

 


[19:31:23] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: ---- Minecraft Crash Report ----
// Don't do that.

Time: 5/10/19 7:31 PM
Description: Initializing game

java.lang.NullPointerException: Initializing game
	at net.minecraftforge.client.ItemModelMesherForge.register(ItemModelMesherForge.java:80)
	at net.minecraft.client.renderer.RenderItem.registerItem(RenderItem.java:88)
	at net.minecraft.client.renderer.RenderItem.registerBlock(RenderItem.java:93)
	at net.minecraft.client.renderer.RenderItem.registerBlock(RenderItem.java:98)
	at net.minecraft.client.renderer.RenderItem.registerItems(RenderItem.java:470)
	at net.minecraft.client.renderer.RenderItem.<init>(RenderItem.java:77)
	at pixelmonMod.entities.throwableEntities.pokeballEntities.renders.RenderThrowablePokeball.<init>(RenderThrowablePokeball.java:24)
	at pixelmonMod.entities.throwableEntities.throwableHandlers.ThrowableRenderHandler$1.createRenderFor(ThrowableRenderHandler.java:20)
	at net.minecraftforge.fml.client.registry.RenderingRegistry.register(RenderingRegistry.java:77)
	at net.minecraftforge.fml.client.registry.RenderingRegistry.loadEntityRenderers(RenderingRegistry.java:70)
	at net.minecraft.client.renderer.entity.RenderManager.<init>(RenderManager.java:236)
	at net.minecraft.client.Minecraft.init(Minecraft.java:564)
	at net.minecraft.client.Minecraft.run(Minecraft.java:421)
	at net.minecraft.client.main.Main.main(Main.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
	at GradleStart.main(GradleStart.java:25)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Client thread
Stacktrace:
	at net.minecraftforge.client.ItemModelMesherForge.register(ItemModelMesherForge.java:80)
	at net.minecraft.client.renderer.RenderItem.registerItem(RenderItem.java:88)
	at net.minecraft.client.renderer.RenderItem.registerBlock(RenderItem.java:93)
	at net.minecraft.client.renderer.RenderItem.registerBlock(RenderItem.java:98)
	at net.minecraft.client.renderer.RenderItem.registerItems(RenderItem.java:470)
	at net.minecraft.client.renderer.RenderItem.<init>(RenderItem.java:77)
	at pixelmonMod.entities.throwableEntities.pokeballEntities.renders.RenderThrowablePokeball.<init>(RenderThrowablePokeball.java:24)
	at pixelmonMod.entities.throwableEntities.throwableHandlers.ThrowableRenderHandler$1.createRenderFor(ThrowableRenderHandler.java:20)
	at net.minecraftforge.fml.client.registry.RenderingRegistry.register(RenderingRegistry.java:77)
	at net.minecraftforge.fml.client.registry.RenderingRegistry.loadEntityRenderers(RenderingRegistry.java:70)
	at net.minecraft.client.renderer.entity.RenderManager.<init>(RenderManager.java:236)
	at net.minecraft.client.Minecraft.init(Minecraft.java:564)

-- Initialization --
Details:
Stacktrace:
	at net.minecraft.client.Minecraft.run(Minecraft.java:421)
	at net.minecraft.client.main.Main.main(Main.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
	at GradleStart.main(GradleStart.java:25)

-- System Details --
Details:
	Minecraft Version: 1.12.2
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 1.8.0_211, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 782979512 bytes (746 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
	JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
	FML: MCP 9.42 Powered by Forge 14.23.5.2768 5 mods loaded, 5 mods active
	States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

	| State | ID        | Version      | Source                           | Signature |
	|:----- |:--------- |:------------ |:-------------------------------- |:--------- |
	| UCH   | minecraft | 1.12.2       | minecraft.jar                    | None      |
	| UCH   | mcp       | 9.42         | minecraft.jar                    | None      |
	| UCH   | FML       | 8.0.99.99    | forgeSrc-1.12.2-14.23.5.2768.jar | None      |
	| UCH   | forge     | 14.23.5.2768 | forgeSrc-1.12.2-14.23.5.2768.jar | None      |
	| UCH   | pm        | 0.0.1        | bin                              | None      |

	Loaded coremods (and transformers): 
	GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.5.13397 Compatibility Profile Context 15.200.1055.0' Renderer: 'AMD Radeon(TM) R3 Graphics'
	Launched Version: 1.12.2
	LWJGL: 2.9.4
	OpenGL: AMD Radeon(TM) R3 Graphics GL version 4.5.13397 Compatibility Profile Context 15.200.1055.0, ATI Technologies Inc.
	GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

	Using VBOs: Yes
	Is Modded: Definitely; Client brand changed to 'fml,forge'
	Type: Client (map_client.txt)
	Resource Packs: 
	Current Language: English (US)
	Profiler Position: N/A (disabled)
	CPU: 4x AMD A4-6210 APU with AMD Radeon R3 Graphics 
[19:31:24] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Dan\Desktop\Minecraft Modding\PixelmonMod\run\.\crash-reports\crash-2019-05-10_19.31.23-client.txt
AL lib: (EE) alc_cleanup: 1 device not closed
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release

 

Posted

Well, you haven't provided your up-to-date code so I can't tell you what's wrong.

Although if I were to guess you are doing something strange yet again, like creating a new instance of RenderItem for whatever reason.

Posted
4 minutes ago, V0idWa1k3r said:

Well, you haven't provided your up-to-date code so I can't tell you what's wrong.

Although if I were to guess you are doing something strange yet again, like creating a new instance of RenderItem for whatever reason.

Main

ItemThrowablePokeball   (Creates The item pokeball)

BaseEntityThrowablePokeball  (Base for all throwablePokeballs)

EntityThrowablePokeball   (the Throwable Pokeball entity itself)

RenderThrowablePokeball    (Rendering the Pokeball being thrown)

ThrowableRenderHandler    (Registers the rendering for the throwables)

ThrowableRegistryHandler   (Registers the Throwable Entities)

Posted
On 5/10/2019 at 7:52 PM, V0idWa1k3r said:

Take the one provided by Minecraft. Don't do it in the costructor or you will crash later with an NPE.

so I don't create an object of the RenderItem class?? I tried this but it crashed..

public class RenderThrowablePokeball extends Render<EntityThrowablePokeball>{
	
	public ItemStack itemstack = new ItemStack(Pokeballs.POKEBALL);
	 /* private final RenderItem itemRenderer = new RenderItem(null, null, null); */

	public RenderThrowablePokeball(RenderManager renderManager) {
		super(renderManager);
	}

	@Override
	protected ResourceLocation getEntityTexture(EntityThrowablePokeball entity) {
		return TextureMap.LOCATION_BLOCKS_TEXTURE;
	}
	
	@Override
	public void doRender(EntityThrowablePokeball entity, double x, double y, double z, float entityYaw, float partialTicks) {
		GL11.glPushMatrix();
		bindEntityTexture(entity);
		bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
		GL11.glTranslated(x, y, z);
		//this.model.render(entity, 0.0F, 0.0F, -0.1F, entity.rotationYaw, entity.rotationPitch, 0.0625F);
		GL11.glPopMatrix();
		IBakedModel ibakedmodel = this.itemRenderer.getItemModelWithOverrides(itemstack, entity.world, (EntityLivingBase)null);
		super.doRender(entity, x, y, z, entityYaw, partialTicks);
	}

}

 

Posted

This code won't even compile.

I told you exactly what you need to do

On 5/11/2019 at 2:52 AM, V0idWa1k3r said:

Take the one provided by Minecraft. Don't do it in the costructor or you will crash later with an NPE.

 

Posted
4 minutes ago, V0idWa1k3r said:

Take the one provided by Minecraft. Don't do it in the costructor or you will crash later with an NPE.

I'm really sorry then I don't understand what you are telling me to do.. can you show me an example please?

Posted

Which point do you not understand?

"Take the one provided by Minecraft" - Minecraft.class has a ItemRenderer instance that you can obtain via a getter that is called getItemRenderer, you could've found this in less than a minute by yusing your IDE. Start doing that by the way, and IDE is more than just a fancy text editor. Understanding the functionalities of your IDE will save you a lot of time and trouble later on.

"Don't do it in the constructor" - exactly as it says, don't write the return value of this method onto a field to use later or you will crash. Do it in your render method.

An example of what do you need? How to invoke a method?

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Im trying to build my mod using shade since i use the luaj library however i keep getting this error Reason: Task ':reobfJar' uses this output of task ':shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. So i try adding reobfJar.dependsOn shadowJar  Could not get unknown property 'reobfJar' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. my gradle file plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'org.spongepowered.mixin' version '0.7.+' } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' apply plugin: 'com.github.johnrengelman.shadow' version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) //jarJar.enable() println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' arg "-mixin.config=derp.mixin.json" mods { "${mod_id}" { source sourceSets.main } } } client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { flatDir { dirs './libs' } maven { url = "https://jitpack.io" } } configurations { shade implementation.extendsFrom shade } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'org.luaj:luaj-jse-3.0.2' implementation fg.deobf("com.github.Virtuoel:Pehkui:${pehkui_version}") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' minecraftLibrary 'luaj:luaj-jse:3.0.2' shade 'luaj:luaj-jse:3.0.2' } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "TweakOrder" : 0, "MixinConfigs" : "derp.mixin.json" ]) } rename 'mixin.refmap.json', 'derp.mixin-refmap.json' } shadowJar { archiveClassifier = '' configurations = [project.configurations.shade] finalizedBy 'reobfShadowJar' } assemble.dependsOn shadowJar reobf { re shadowJar {} } publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } }  
    • All versions of Minecraft Forge suddenly black screen even without mods (tried reinstalling original Minecraft, Java, updating drivers doesn't work)
    • When i join minecraft all ok, when i join world all working fine, but when i open indentity menu, i get this The game crashed whilst unexpected error Error: java.lang.NullPointerException: Cannot invoke "top.ribs.scguns.common.Gun$Projectile.getDamage()" because "this.projectile" is null crash report here https://paste.ee/p/0vKaf
  • Topics

×
×
  • Create New...

Important Information

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