mirror of
https://github.com/GTNewHorizons/GTNHLib.git
synced 2026-11-26 14:53:14 +00:00
Move villager names from WAWLA (#228)
This commit is contained in:
1 parent
957d40c5f5
commit
3d12c667b4
5 files changed
+298
No files matched your search
@@ -0,0 +1,43 @@
|
||||
package com.gtnewhorizon.gtnhlib.client;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import cpw.mods.fml.common.registry.VillagerRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
// Moved from wawla's net.darkhax.wawla.util.Utilities
|
||||
public class VillagerNames {
|
||||
|
||||
/**
|
||||
* Lists of names for the vanilla villagers.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static String[] vanillaVillagers = { "farmer", "librarian", "priest", "blacksmith", "butcher" };
|
||||
|
||||
/**
|
||||
* Retrieves a unique string related to the texture name of a villager. This allows for villagers to be
|
||||
* differentiated based on their profession rather than their ID.
|
||||
*
|
||||
* @param id : The ID of the villager being looked up.
|
||||
* @return String: The texture name, minus file path and extension.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static String getVillagerName(int id) {
|
||||
|
||||
ResourceLocation skin = VillagerRegistry.getVillagerSkin(id, null);
|
||||
|
||||
if (id >= 0 && id <= 4) {
|
||||
return vanillaVillagers[id];
|
||||
}
|
||||
|
||||
if (skin != null) {
|
||||
return skin.getResourceDomain() + "."
|
||||
+ skin.getResourcePath().substring(
|
||||
skin.getResourcePath().lastIndexOf("/") + 1,
|
||||
skin.getResourcePath().length() - 4);
|
||||
}
|
||||
|
||||
return "misingno";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user