Kionashi Posted July 20, 2025 Report Posted July 20, 2025 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.
Spear and Fang Posted July 22, 2025 Report Posted July 22, 2025 (edited) looks like you are close. Look at this example https://github.com/SpearAndFang/primitive-survival/blob/40ac5de8339559bcde3964b3a09286eb957654ec/PrimitiveSurvival/ModSystem/blockbehavior/rightclickpickupspawnworm.cs#L55-L69 assetlocation came from here https://github.com/SpearAndFang/primitive-survival/blob/40ac5de8339559bcde3964b3a09286eb957654ec/PrimitiveSurvival/assets/primitivesurvival/entities/land/snake-pitviper.json#L2 I know it's a creature above, but assetlocation and spawning is the same. The spawning I basically sourced from here https://github.com/anegostudios/vssurvivalmod/blob/f08bd70b70c49c761aa690bff25776f5831c3a71/Item/ItemArmorStand.cs#L35-L55 Edited July 22, 2025 by Spear and Fang
Kionashi Posted July 22, 2025 Author Report Posted July 22, 2025 (edited) 5 hours ago, Spear and Fang said: looks like you are close. Look at this example https://github.com/SpearAndFang/primitive-survival/blob/40ac5de8339559bcde3964b3a09286eb957654ec/PrimitiveSurvival/ModSystem/blockbehavior/rightclickpickupspawnworm.cs#L55-L69 assetlocation came from here https://github.com/SpearAndFang/primitive-survival/blob/40ac5de8339559bcde3964b3a09286eb957654ec/PrimitiveSurvival/assets/primitivesurvival/entities/land/snake-pitviper.json#L2 I know it's a creature above, but assetlocation and spawning is the same. The spawning I basically sourced from here https://github.com/anegostudios/vssurvivalmod/blob/f08bd70b70c49c761aa690bff25776f5831c3a71/Item/ItemArmorStand.cs#L35-L55 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 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 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. 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 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 July 22, 2025 by Kionashi
Recommended Posts