make this a bit nicer

This commit is contained in:
Ellpeck 2016-11-27 13:29:58 +01:00
parent bef2e00b17
commit 694f9f5e8d

View file

@ -21,12 +21,12 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Locale;
import java.util.Properties; import java.util.Properties;
public class SpecialRenderInit{ public class SpecialRenderInit{
public static final HashMap<String, RenderSpecial> SPECIAL_LIST = new HashMap<String, RenderSpecial>(); private static final HashMap<String, RenderSpecial> SPECIAL_LIST = new HashMap<String, RenderSpecial>();
public SpecialRenderInit(){ public SpecialRenderInit(){
new ThreadSpecialFetcher(); new ThreadSpecialFetcher();
@ -61,7 +61,7 @@ public class SpecialRenderInit{
//Add a new Special Renderer to the list //Add a new Special Renderer to the list
if(StackUtil.isValid(stack)){ if(StackUtil.isValid(stack)){
SPECIAL_LIST.put(key, new RenderSpecial(stack)); SPECIAL_LIST.put(key.toLowerCase(Locale.ROOT), new RenderSpecial(stack));
} }
} }
} }
@ -69,15 +69,14 @@ public class SpecialRenderInit{
@SubscribeEvent(priority = EventPriority.HIGHEST) @SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerRender(RenderPlayerEvent.Pre event){ public void onPlayerRender(RenderPlayerEvent.Pre event){
if(!SPECIAL_LIST.isEmpty()){ if(event.getEntityPlayer() != null){
for(Map.Entry<String, RenderSpecial> entry : SPECIAL_LIST.entrySet()){ String name = event.getEntityPlayer().getName();
//Does the player have one of the names from the list? if(name != null){
String playerName = event.getEntityPlayer().getName(); String lower = name.toLowerCase(Locale.ROOT);
if(entry.getKey() != null && playerName != null){ if(SPECIAL_LIST.containsKey(lower)){
if(entry.getKey().equalsIgnoreCase(playerName)){ RenderSpecial render = SPECIAL_LIST.get(lower);
//Render the special Item/Block if(render != null){
entry.getValue().render(event.getEntityPlayer(), event.getPartialRenderTick()); render.render(event.getEntityPlayer(), event.getPartialRenderTick());
break;
} }
} }
} }