net.minecraft.client.Minecraft.getSession()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(201)

本文整理了Java中net.minecraft.client.Minecraft.getSession()方法的一些代码示例,展示了Minecraft.getSession()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Minecraft.getSession()方法的具体详情如下:
包路径:net.minecraft.client.Minecraft
类名称:Minecraft
方法名:getSession

Minecraft.getSession介绍

暂无

代码示例

代码示例来源:origin: Vazkii/Quark

private static void load(Properties props) {
  List<String> allPatrons = new ArrayList(props.size());
  
  String name = Minecraft.getMinecraft().getSession().getUsername().toLowerCase();
  props.forEach((k, v) -> {
    String key = (String) k;
    String value = (String) v;
    
    int tier = Integer.parseInt(value);
    if(tier < 10)
      allPatrons.add(key);
    
    if(key.toLowerCase().equals(name))
      localPatronTier = tier;
  });
  
  if(!allPatrons.isEmpty())
    featuredPatron = allPatrons.get((int) (Math.random() * allPatrons.size()));
}

代码示例来源:origin: MrCrayfish/MrCrayfishFurnitureMod

@Override
public void initialize(Minecraft minecraftInstance)
{
  Minecraft.getMinecraft().getSession().getUsername();
}

代码示例来源:origin: OpenMods/OpenData

@Override
public void first() {
  try {
    String username = Minecraft.getMinecraft().getSession().getUsername();
    if (!Strings.isNullOrEmpty(username)) Sanitizers.addPlayerName(username);
  } catch (Throwable t) {
    Log.warn(t, "Failed to get player username");
  }
}

代码示例来源:origin: Darkhax-Minecraft/Bookshelf

/**
 * Gets the UUID for the client side player.
 *
 * @return The UUID for the client side player. May be null.
 */
@SideOnly(Side.CLIENT)
public static UUID getClientUUID () {
  
  return fixStrippedUUID(Minecraft.getMinecraft().getSession().getPlayerID());
}

代码示例来源:origin: montoyo/mcef

@Override
public boolean handleQuery(IBrowser b, long queryId, String query, boolean persistent, IJSQueryCallback cb) {
  if(b != null && query.equalsIgnoreCase("username")) {
    if(b.getURL().startsWith("mod://")) {
      //Only allow MCEF URLs to get the player's username to keep his identity secret
      mc.addScheduledTask(() -> {
        //Add this to a scheduled task because this is NOT called from the main Minecraft thread...
        try {
          String name = mc.getSession().getUsername();
          cb.success(name);
        } catch(Throwable t) {
          cb.failure(500, "Internal error.");
          Log.warning("Could not get username from JavaScript:");
          t.printStackTrace();
        }
      });
    } else
      cb.failure(403, "Can't access username from external page");
    
    return true;
  }
  
  return false;
}

代码示例来源:origin: Vazkii/Quark

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
  super.drawScreen(mouseX, mouseY, partialTicks);
  
  String s = null;
  if(mayRequireRestart)
    s = I18n.translateToLocal("quark.config.needrestart");
  else if(qEnabled && !GlobalConfig.enableQButton)
    s = I18n.translateToLocal("quark.config.qdisabled");
  
  if(s != null)
    drawCenteredString(mc.fontRenderer, s, width / 2, backButton.y + 22, 0xFFFF00);
  
  if(ContributorRewardHandler.localPatronTier == 0) {
    if(ContributorRewardHandler.featuredPatron.isEmpty())
      s = I18n.translateToLocal("quarkmisc.patronPlugNone");
    else s = I18n.translateToLocalFormatted("quarkmisc.patronPlug", ContributorRewardHandler.featuredPatron);
  } else s = "\u2665 " + I18n.translateToLocalFormatted("quarkmisc.supportMessage", mc.getSession().getUsername()) + " \u2665";
  
  drawCenteredString(mc.fontRenderer, s, width / 2, 27, 0xff8f80);
}

代码示例来源:origin: TeamLapen/Vampirism

random.setSeed((long) (this.mc.getSession().getPlayerID().hashCode() + k1 + x + (l1 + y) * 16));
int j4 = random.nextInt(1 + l1 + y) + (l1 + y) / 2;
TextureAtlasSprite textureatlassprite = this.getTexture(Blocks.SAND);

相关文章