Jump to content

Recommended Posts

Posted

Ok I started looking at making mods for VS, I have a simple idea for a mod but it requires creating a new entity (not a creature, and not a block entity) and spawning it when I right click with a new item.

The item thing was easy, by reading and following the simpleitem wiki example I managed to create a new item with its own shape and connect it to a new class so I could add custom behavior, but I've been having issues doing the same with a new entity because even though I have my entity class and my entity json. I can't make a new AssetLocation with the info of my entity to save my life. And since there are no tutorials anywhere on how to make a new custom Entity I need to ask someone how to properly register and spawn a new entity I made? 

Also feel free to take a look at my mod on github https://github.com/Kionashi/clay-finder it only has the item class the entity class and I just want at this point to be able to spawn the entity.  

I would appreciate any help. 
 

Posted (edited)
5 hours ago, Spear and Fang said:

Thank you!

In the end I managed to find the solution and it was kinda embarasing (I was passing the AssetLocation as the parameter of the CreateEntity function instead of the EntityType), seems like C# is not good enforcing Datatypes on their parameters xD

So that kinda solves one issue, but I now have another.

Now I can create the entity without crashing, and even tried to spawn it following your example using 

image.thumb.png.481b2eeabed9014fc0729ce939038014.png

So far doesn't give me any errors nor crashes, but even though It looks like is spawning my entity, the code never reaches the Initialize function on my entity class.  Because I added a log on that function, but doesn't show anything when using the item that spawns the entity.

image.png.52ba16db90d64b4dda7feafa08c28634.png

so I though maybe the entity I was generating wasn't actually generating the correct entity class. But I tried calling the Initialize method directly from the entity I created on my item class, and It actually calls my class's Initialize function

image.thumb.png.d1c344e34864e7282cba020b2867bde4.png

 

image.png.e4eec6c9195873fbcac40cde871517eb.png

Im seeing the log I made on the EntityDoll class so the entity I created is a real instance of my EntityDoll class

 

but of course Im  99% sure that's not how is supposed to work right? when creating or spawning the entity the Initialize function should be called automatically right?

I updated my github repository with the solution to the crash when spawning the entity. I hope someone can help me figure out what am I doing wrong this time. 

Edited by Kionashi
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.