Hello, I've been trying to increase the radius of a vanilla village by 2. I've looked around through the vanilla code and I couldn't find anything that'll allow me to access the field, edit it and permanently keep the value of the int double it's value. Mainly due to this line of code in the Village.class update method.
You might have heard this thrown around but use Reflection. It'll allow you to access fields and methods that you otherwise wouldn't have been able to before. I don't exactly know how to use Reflection but maybe somebody here who does will give you an example on how to do it.
Rollback Post to RevisionRollBack
If you would like to get a hold of me somehow, then my discord is @Alex Couch#5275.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
But doesn't MapGenVillage have nothing to do with village radius?
You're right, I misread your post.
You may be able to update the radius at the end of each world tick (WorldTickEvent with TickEvent.Phase.END); though entities are ticked between the radius being updated and the end of the world tick, so they'd still use the original value.
What's the overall goal of modifying the radius? There may be some other way to do what you want.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I dislike it when the villagers don't use the house around the edges of village. I'm hoping that if I increase the village radius the villagers will start to use the houses around the outskirts since they'll be able to move farther away from the village center.
I dislike it when the villagers don't use the house around the edges of village. I'm hoping that if I increase the village radius the villagers will start to use the houses around the outskirts since they'll be able to move farther away from the village center.
In that case, setting the field at the end of the world tick won't work.
You'd probably need to replace the AI tasks that use the village radius with custom tasks that use your radius value. You could use the Capability system to store this radius for each Village.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
So this would require me to remake the villager.class? Or just override that particular AI task?
Just the AI tasks. When a villager spawns (EntityJoinWorldEvent), remove the AI tasks that you want to replace and add the new ones.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Quote from Choonster >>
You'd probably need to replace the AI tasks that use the village radius with custom tasks that use your radius value.
That would be EntityAIMoveTowardsRestriction.
It uses EntityCreature.isWithinHomeDistanceCurrentPosition() to determine if it should run or not.
That uses maximumHomeDistance.
maximumHomeDistance is set/updated regularly in updateAITasks in EntityVillager. It is set to the villageRadius.
So if you replace this AI task you should be able to replace the condition that uses isWithinHomeDistanceCurrentPosition with your own condition that calls getMaximumHomeDistance directly and compares that distance in the same way but with an amount added to it.
Doing this will likely accomplish what you want.
I was hoping someone would come out with a way of replacing a Village object on VillageCollection.villageList. I looked into it once before and didn't end up finding a way to do it.
But if this suggestion by Choonster does the trick, great.
Hello, I've been trying to increase the radius of a vanilla village by 2. I've looked around through the vanilla code and I couldn't find anything that'll allow me to access the field, edit it and permanently keep the value of the int double it's value. Mainly due to this line of code in the Village.class update method.
Is there a way I could increase the radius?
Thanks.
You might have heard this thrown around but use Reflection. It'll allow you to access fields and methods that you otherwise wouldn't have been able to before. I don't exactly know how to use Reflection but maybe somebody here who does will give you an example on how to do it.
If you would like to get a hold of me somehow, then my discord is @Alex Couch#5275.
Yes, I've even used reflection in my mod, however since this line of code:
I can't increase the villageRadius past 32.
It gets called repeatedly in the update method.
either use ASM to exclude that line from the update method or try to create your own implementation and replace every village instance on creation
(asm would be the safest way to ensure that even other mods will reflect the change)
Thanks, I'll try that out... Nice mods by the way.
I explained how to do something similar here.
ASM should generally be avoided if at all possible.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Thanks
But doesn't MapGenVillage have nothing to do with village radius?
You're right, I misread your post.
You may be able to update the radius at the end of each world tick (WorldTickEvent with TickEvent.Phase.END); though entities are ticked between the radius being updated and the end of the world tick, so they'd still use the original value.
What's the overall goal of modifying the radius? There may be some other way to do what you want.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I dislike it when the villagers don't use the house around the edges of village. I'm hoping that if I increase the village radius the villagers will start to use the houses around the outskirts since they'll be able to move farther away from the village center.
In that case, setting the field at the end of the world tick won't work.
You'd probably need to replace the AI tasks that use the village radius with custom tasks that use your radius value. You could use the Capability system to store this radius for each Village.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
So this would require me to remake the villager.class? Or just override that particular AI task?
Just the AI tasks. When a villager spawns (EntityJoinWorldEvent), remove the AI tasks that you want to replace and add the new ones.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
That would be EntityAIMoveTowardsRestriction.
It uses EntityCreature.isWithinHomeDistanceCurrentPosition() to determine if it should run or not.
That uses maximumHomeDistance.
maximumHomeDistance is set/updated regularly in updateAITasks in EntityVillager. It is set to the villageRadius.
So if you replace this AI task you should be able to replace the condition that uses isWithinHomeDistanceCurrentPosition with your own condition that calls getMaximumHomeDistance directly and compares that distance in the same way but with an amount added to it.
Doing this will likely accomplish what you want.
I was hoping someone would come out with a way of replacing a Village object on VillageCollection.villageList. I looked into it once before and didn't end up finding a way to do it.
But if this suggestion by Choonster does the trick, great.
If you plan on replacing this AI task and aren't sure how to go about it, this might help.
Thanks Guys, my problem is solved.
As you can see the villagers are spread out more evenly.