mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-16 18:45:09 +00:00
Fix potential desync between Forge's Villager profession and vanilla's int based system.
This commit is contained in:
1 parent
fbe628d058
commit
8fefac110e
2 files changed
+37
-5
No files matched your search
@@ -277,6 +277,29 @@ public class VillagerRegistry
|
||||
entity.setProfession(rand.nextInt(entries.size()));
|
||||
}
|
||||
|
||||
public static void onSetProfession(EntityVillager entity, VillagerProfession prof)
|
||||
{
|
||||
int network = INSTANCE.professions.getId(prof);
|
||||
if (network == -1 || prof != INSTANCE.professions.getObjectById(network))
|
||||
{
|
||||
throw new RuntimeException("Attempted to set villager profession to unregistered profession: " + network + " " + prof);
|
||||
}
|
||||
|
||||
if (network != entity.getProfession())
|
||||
entity.setProfession(network);
|
||||
}
|
||||
public static void onSetProfession(EntityVillager entity, int network)
|
||||
{
|
||||
VillagerProfession prof = INSTANCE.professions.getObjectById(network);
|
||||
if (prof == null || INSTANCE.professions.getId(prof) != network)
|
||||
{
|
||||
throw new RuntimeException("Attempted to set villager profession to unregistered profession: " + network + " " + prof);
|
||||
}
|
||||
|
||||
if (prof != entity.getProfessionForge())
|
||||
entity.setProfession(prof);
|
||||
}
|
||||
|
||||
//TODO: Figure out a good generic system for this. Put on hold for Patches.
|
||||
|
||||
private static class VanillaTrades
|
||||
|
||||
Reference in new issue
Block a user