Re-added special people stuff for 1.11 tempoarily

This commit is contained in:
Ellpeck 2016-11-28 22:04:19 +01:00
parent 5694d4f8da
commit 962d1b3842

View file

@ -47,19 +47,24 @@ public class SpecialRenderInit{
meta = 0; meta = 0;
} }
ItemStack stack = StackUtil.getNull();
//Get the Item from the String
ResourceLocation resLoc = new ResourceLocation(itemName); ResourceLocation resLoc = new ResourceLocation(itemName);
if(Item.REGISTRY.containsKey(resLoc)){ ItemStack stack = findItem(resLoc, meta);
stack = new ItemStack(Item.REGISTRY.getObject(resLoc), 1, meta);
//TODO Remove this block once the transition to 1.11 is done and the special people stuff file has been converted to snake_case
if(!StackUtil.isValid(stack)){
String convertedItemName = "";
for(char c : itemName.toCharArray()){
if(Character.isUpperCase(c)){
convertedItemName += "_";
convertedItemName += Character.toLowerCase(c);
} }
else{ else{
if(Block.REGISTRY.containsKey(resLoc)){ convertedItemName += c;
stack = new ItemStack(Block.REGISTRY.getObject(resLoc), 1, meta);
} }
} }
stack = findItem(new ResourceLocation(convertedItemName), meta);
}
//Add a new Special Renderer to the list
if(StackUtil.isValid(stack)){ if(StackUtil.isValid(stack)){
SPECIAL_LIST.put(key.toLowerCase(Locale.ROOT), new RenderSpecial(stack)); SPECIAL_LIST.put(key.toLowerCase(Locale.ROOT), new RenderSpecial(stack));
} }
@ -67,6 +72,22 @@ public class SpecialRenderInit{
} }
} }
private static ItemStack findItem(ResourceLocation resLoc, int meta){
if(Item.REGISTRY.containsKey(resLoc)){
Item item = Item.REGISTRY.getObject(resLoc);
if(item != null){
return new ItemStack(item, 1, meta);
}
}
else if(Block.REGISTRY.containsKey(resLoc)){
Block block = Block.REGISTRY.getObject(resLoc);
if(block != null){
return new ItemStack(block, 1, meta);
}
}
return StackUtil.getNull();
}
@SubscribeEvent(priority = EventPriority.HIGHEST) @SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerRender(RenderPlayerEvent.Pre event){ public void onPlayerRender(RenderPlayerEvent.Pre event){
if(event.getEntityPlayer() != null){ if(event.getEntityPlayer() != null){