Started by
CaptainShark
on
Topic category: Help with Minecraft modding (Java Edition)
Currently messing around with a villager related mod but it relies on 4 types.
I have 4 new chests, a farmer, butcher, shepherd and then an "all villager types" chest.
How do I use a procedure to work with just the one type of villager, for example a farmer?
Villager profession is saved in nbt tag under name "Profession". Here something about it: https://www.digminecraft.com/data_tags/villager.php
Testing to see if I got it working by doing the following. It ends up crashing the game when right clicking a villager though.
Global Trigger: Player right click on Entity.
Is event target/entity sub type of villager
IF - (and) - Is event target/entity tagged in entity tags as {VillagerData:{Profession:cleric}}
DO - Spawn at x y z living entity iron golem
I am guessing I have done it wrong lol?
"tagged in entity tags" uses mob id "minecraft:villager" or sth like this.
You need something I don't think there's possible in mcreator (at least for now):
Ah that would explain why right clicking any mob when using a compound was crashing the game.
For the time being I will just let any villagers work with the blocks. With coding can that all be done inside each elements Code Editor on Mcreator or would I also need other sites/modding programs? I don't mind having to code but I am new to it so will probably make a test workspace purely for simple code testing, it's just knowing where to start/what I need to begin it all.
As a test I have it so right clicking a villager summons a fox. I am under the impression I need to change this part of the code. In the code editor at "If (entity instanceof Villager) but I can't seem to work out what to change it to so that it's only ( for example ) a farmer that can trigger the spawn
Normally I'd check this myself but i don't have time for this and i understand you have some code writing knowledge, let's try something basic.
You can try this:
First use if statement to check if entity from dependencies is instance of Villager (you can use built in mcreator is sub type of entity)
Then in if use code snippet:
If minecraft won't crush there's hope to work without source code editing. If it works, it should give you access to all Villager data.
Under it use another if but with code snippet:
This snippet should return true if clicked villager is a farmer. You can replace FARMER with any profession but it has to have all letters uppercase.
In this if body you can do whatever you want it to do.
Sorry, ill show in pseudocode:
Again me, i forgot about casting.
Im first snippet:
Sorry for spam 😅
Currently my code writing knowledge is very little lol. Some basic stuff I worked out like how to change recipes in the code since it's a pretty short and straight forward code that gets generated ( so I had an example basically ). When the built in code gets quite lengthy I get confused on where exactly to add new parts as well as how to add them in.
I so far have just guessed a few parts like "if statements" being the green text "IF"
I've tried to look up some tutorials but the search results are mostly for "without coding" or for more advanced tutorials so currently I have just been noting down a bunch of things I want to learn to code on a notepad to eventually post on this forum. I suppose it's just all part of the overwhelming "where to start" part of learning to code aha. No worries about the spam, spams better than me being confused for hours and hours lmao
I am thinking about making a plugin which would add possibility to get and set villager professions and other vanilla mob data.
I've not touched plugins/things that add more triggers and all sorts out of fear they might stop getting updated and then mods I make would all completely break down, assuming that is what would happen, mcreator plugins do seem quite handy though
I think my best bet at the moment is to gather up all the things I am attempting at the moment, posting them and seeing if people have examples. I feel like if there are examples I can then sort of dumb it down a little/word it I understand it better and then save it for future references.
After small think, i think you can use one code snippet in one if statement:
In pseudocode code:
It really should do the work.
Professions are the same like on site i gave before but they are uppercase.
Eventually, you can use this, it's not official forge documentation, but it's pretty helpful for self written code. However you have to know how to read docs.
Here villager professions:
https://nekoyue.github.io/ForgeJavaDocs-NG/javadoc/1.18.2/net/minecraft/world/entity/npc/VillagerProfession.html
And here main page of it:
https://nekoyue.github.io/ForgeJavaDocs-NG/
About plugins, they might be discontinued and i think that if you want to make mods, it's good to know at least java basics.
Ps. Personally i am learning C++, not Java XD. However i have java man (friend learning java) and i spam him if i wanna ask sth about java 😇.
https://imgur.com/a/hmdn8VA
I am imaging it's a case of just "IF" then pasting "((Villager) entity).getVillagerData().getProfession() == VillagerProfession.FARMER" ( if i even understood that correctly aha. But I am not sure which part/line/section to add that statement in. Having a Java friend certainly sounds quite helpful. In terms of learning to code minecraft is this villager idea a lot more complex than some more basic starting ideas? I will also most likely make a post about all the things I am trying to learn later on in a fairly more in depth explanation
In code blocks you use one if
use AND statement to have two conditions so its
"((Villager) entity).getVillagerData().getProfession() == VillagerProfession.FARMER)" use in code snippet that can connect to if.
It should work and should allow you to continue working in mcreator's procedure blocks.