当前位置: 首页>>代码示例>>Java>>正文


Java SPacketChangeGameState.getValue方法代码示例

本文整理汇总了Java中net.minecraft.network.play.server.SPacketChangeGameState.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java SPacketChangeGameState.getValue方法的具体用法?Java SPacketChangeGameState.getValue怎么用?Java SPacketChangeGameState.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.network.play.server.SPacketChangeGameState的用法示例。


在下文中一共展示了SPacketChangeGameState.getValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleChangeGameState

import net.minecraft.network.play.server.SPacketChangeGameState; //导入方法依赖的package包/类
public void handleChangeGameState(SPacketChangeGameState packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    EntityPlayer entityplayer = this.gameController.player;
    int i = packetIn.getGameState();
    float f = packetIn.getValue();
    int j = MathHelper.floor(f + 0.5F);

    if (i >= 0 && i < SPacketChangeGameState.MESSAGE_NAMES.length && SPacketChangeGameState.MESSAGE_NAMES[i] != null)
    {
        entityplayer.addChatComponentMessage(new TextComponentTranslation(SPacketChangeGameState.MESSAGE_NAMES[i], new Object[0]), false);
    }

    if (i == 1)
    {
        this.clientWorldController.getWorldInfo().setRaining(true);
        this.clientWorldController.setRainStrength(0.0F);
    }
    else if (i == 2)
    {
        this.clientWorldController.getWorldInfo().setRaining(false);
        this.clientWorldController.setRainStrength(1.0F);
    }
    else if (i == 3)
    {
        this.gameController.playerController.setGameType(GameType.getByID(j));
    }
    else if (i == 4)
    {
        if (j == 0)
        {
            this.gameController.player.connection.sendPacket(new CPacketClientStatus(CPacketClientStatus.State.PERFORM_RESPAWN));
            this.gameController.displayGuiScreen(new GuiDownloadTerrain(this));
        }
        else if (j == 1)
        {
            this.gameController.displayGuiScreen(new GuiWinGame());
        }
    }
    else if (i == 5)
    {
        GameSettings gamesettings = this.gameController.gameSettings;

        if (f == 0.0F)
        {
            this.gameController.displayGuiScreen(new GuiScreenDemo());
        }
        else if (f == 101.0F)
        {
            this.gameController.ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("demo.help.movement", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindForward.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindLeft.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindBack.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindRight.getKeyCode())}));
        }
        else if (f == 102.0F)
        {
            this.gameController.ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("demo.help.jump", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindJump.getKeyCode())}));
        }
        else if (f == 103.0F)
        {
            this.gameController.ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("demo.help.inventory", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindInventory.getKeyCode())}));
        }
    }
    else if (i == 6)
    {
        this.clientWorldController.playSound(entityplayer, entityplayer.posX, entityplayer.posY + (double)entityplayer.getEyeHeight(), entityplayer.posZ, SoundEvents.ENTITY_ARROW_HIT_PLAYER, SoundCategory.PLAYERS, 0.18F, 0.45F);
    }
    else if (i == 7)
    {
        this.clientWorldController.setRainStrength(f);
    }
    else if (i == 8)
    {
        this.clientWorldController.setThunderStrength(f);
    }
    else if (i == 10)
    {
        this.clientWorldController.spawnParticle(EnumParticleTypes.MOB_APPEARANCE, entityplayer.posX, entityplayer.posY, entityplayer.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
        this.clientWorldController.playSound(entityplayer, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_ELDER_GUARDIAN_CURSE, SoundCategory.HOSTILE, 1.0F, 1.0F);
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:79,代码来源:NetHandlerPlayClient.java

示例2: handleChangeGameState

import net.minecraft.network.play.server.SPacketChangeGameState; //导入方法依赖的package包/类
public void handleChangeGameState(SPacketChangeGameState packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    EntityPlayer entityplayer = this.gameController.thePlayer;
    int i = packetIn.getGameState();
    float f = packetIn.getValue();
    int j = MathHelper.floor_float(f + 0.5F);

    if (i >= 0 && i < SPacketChangeGameState.MESSAGE_NAMES.length && SPacketChangeGameState.MESSAGE_NAMES[i] != null)
    {
        entityplayer.addChatComponentMessage(new TextComponentTranslation(SPacketChangeGameState.MESSAGE_NAMES[i], new Object[0]));
    }

    if (i == 1)
    {
        this.clientWorldController.getWorldInfo().setRaining(true);
        this.clientWorldController.setRainStrength(0.0F);
    }
    else if (i == 2)
    {
        this.clientWorldController.getWorldInfo().setRaining(false);
        this.clientWorldController.setRainStrength(1.0F);
    }
    else if (i == 3)
    {
        this.gameController.playerController.setGameType(GameType.getByID(j));
    }
    else if (i == 4)
    {
        if (j == 0)
        {
            this.gameController.thePlayer.connection.sendPacket(new CPacketClientStatus(CPacketClientStatus.State.PERFORM_RESPAWN));
            this.gameController.displayGuiScreen(new GuiDownloadTerrain(this));
        }
        else if (j == 1)
        {
            this.gameController.displayGuiScreen(new GuiWinGame());
        }
    }
    else if (i == 5)
    {
        GameSettings gamesettings = this.gameController.gameSettings;

        if (f == 0.0F)
        {
            this.gameController.displayGuiScreen(new GuiScreenDemo());
        }
        else if (f == 101.0F)
        {
            this.gameController.ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("demo.help.movement", new Object[] {gamesettings.keyBindForward.getDisplayName(), gamesettings.keyBindLeft.getDisplayName(), gamesettings.keyBindBack.getDisplayName(), gamesettings.keyBindRight.getDisplayName()}));
        }
        else if (f == 102.0F)
        {
            this.gameController.ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("demo.help.jump", new Object[] {gamesettings.keyBindJump.getDisplayName()}));
        }
        else if (f == 103.0F)
        {
            this.gameController.ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("demo.help.inventory", new Object[] {gamesettings.keyBindInventory.getDisplayName()}));
        }
    }
    else if (i == 6)
    {
        this.clientWorldController.playSound(entityplayer, entityplayer.posX, entityplayer.posY + (double)entityplayer.getEyeHeight(), entityplayer.posZ, SoundEvents.ENTITY_ARROW_HIT_PLAYER, SoundCategory.PLAYERS, 0.18F, 0.45F);
    }
    else if (i == 7)
    {
        this.clientWorldController.setRainStrength(f);
    }
    else if (i == 8)
    {
        this.clientWorldController.setThunderStrength(f);
    }
    else if (i == 10)
    {
        this.clientWorldController.spawnParticle(EnumParticleTypes.MOB_APPEARANCE, entityplayer.posX, entityplayer.posY, entityplayer.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
        this.clientWorldController.playSound(entityplayer, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_ELDER_GUARDIAN_CURSE, SoundCategory.HOSTILE, 1.0F, 1.0F);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:79,代码来源:NetHandlerPlayClient.java


注:本文中的net.minecraft.network.play.server.SPacketChangeGameState.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。