List of usage examples for net.minecraftforge.common UsernameCache containsUUID
public static boolean containsUUID(UUID uuid)
From source file:vazkii.botania.common.item.relic.ItemRelic.java
License:Open Source License
public void updateRelic(ItemStack stack, EntityPlayer player) { if (stack == null || !(stack.getItem() instanceof IRelic)) return;/*from w ww . ja v a 2s.c o m*/ boolean rightPlayer = true; if (hasUUID(stack)) { // Sync to username todo is this worth 'optimizing'? if (UsernameCache.containsUUID(getSoulbindUUID(stack))) { bindToUsername(UsernameCache.getLastKnownUsername(getSoulbindUUID(stack)), stack); } else { bindToUsername("", stack); } // UUID trumps username rightPlayer = getSoulbindUUID(stack).equals(player.getUniqueID()); } else { if ("".equals(getSoulbindUsername(stack))) { // New user bindToUUID(player.getUniqueID(), stack); player.addStat(((IRelic) stack.getItem()).getBindAchievement(), 1); } else { if (player.getName().equals(getSoulbindUsername(stack))) { // Old relic, correct owner, convert to UUID bindToUUID(player.getUniqueID(), stack); } else { // Old relic, wrong owner, damage rightPlayer = false; } } } if (!rightPlayer && player.ticksExisted % 10 == 0 && (!(stack.getItem() instanceof ItemRelic) || ((ItemRelic) stack.getItem()).shouldDamageWrongPlayer())) player.attackEntityFrom(damageSource(), 2); }