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


Java ClientPlayerActionPacket类代码示例

本文整理汇总了Java中org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerActionPacket的典型用法代码示例。如果您正苦于以下问题:Java ClientPlayerActionPacket类的具体用法?Java ClientPlayerActionPacket怎么用?Java ClientPlayerActionPacket使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ClientPlayerActionPacket类属于org.spacehq.mc.protocol.packet.ingame.client.player包,在下文中一共展示了ClientPlayerActionPacket类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: beginBreak

import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerActionPacket; //导入依赖的package包/类
public void beginBreak() {
    if (this.getSelectedBlock() != null
            && this.currentScreen == this.hud) {
        IChunk chunk = world.getChunk(selectedBlock);
        if(chunk != null) {
            try {
                Block block = chunk.getBlock(selectedBlock.x & (world.getChunkSize() - 1), selectedBlock.y,
                        selectedBlock.z & (world.getChunkSize() - 1));
                if (block != null && block.isSelectable()) {
                    if (this.isRemote()) {
                        mcClientConn.getClient().getSession().send(new ClientPlayerSwingArmPacket(Hand.MAIN_HAND));
                        mcClientConn.getClient().getSession().send(
                                new ClientPlayerActionPacket(PlayerAction.START_DIGGING,
                                        new Position(selectedBlock.x, selectedBlock.y, selectedBlock.z), BlockFace.UP));
                    }
                }
            } catch (CoordinatesOutOfBoundsException ex) {
                ex.printStackTrace();
            }
        }
    }
}
 
开发者ID:mstojcevich,项目名称:Radix,代码行数:23,代码来源:RadixClient.java

示例2: cancelBreak

import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerActionPacket; //导入依赖的package包/类
public void cancelBreak() {
    if (this.getSelectedBlock() != null
            && this.currentScreen == this.hud) {
        IChunk chunk = world.getChunk(selectedBlock);
        if(chunk != null) {
            try {
                Block block = chunk.getBlock(selectedBlock.x & (world.getChunkSize() - 1), selectedBlock.y,
                        selectedBlock.z & (world.getChunkSize() - 1));
                if (block != null && block.isSelectable()) {
                    if (this.isRemote()) {
                        mcClientConn.getClient().getSession().send(
                                new ClientPlayerActionPacket(PlayerAction.CANCEL_DIGGING,
                                        new Position(selectedBlock.x, selectedBlock.y, selectedBlock.z), BlockFace.UP));
                    }
                }
                player.resetBlockBreak();
            } catch (CoordinatesOutOfBoundsException ex) {
                ex.printStackTrace();
            }
        }
    }
}
 
开发者ID:mstojcevich,项目名称:Radix,代码行数:23,代码来源:RadixClient.java

示例3: breakBlock

import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerActionPacket; //导入依赖的package包/类
public void breakBlock() {
    if (this.getSelectedBlock() != null
            && this.currentScreen == this.hud) {
        IChunk chunk = world.getChunk(selectedBlock);
        if(chunk != null) {
            try {
                Block block = chunk.getBlock(selectedBlock.x & (world.getChunkSize() - 1), selectedBlock.y,
                        selectedBlock.z & (world.getChunkSize() - 1));
                if (block != null && block.isSelectable()) {
                    if (this.isRemote()) {
                        mcClientConn.getClient().getSession().send(new ClientPlayerSwingArmPacket(Hand.MAIN_HAND));
                        mcClientConn.getClient().getSession().send(
                                new ClientPlayerActionPacket(PlayerAction.FINISH_DIGGING,
                                        new Position(selectedBlock.x, selectedBlock.y, selectedBlock.z), BlockFace.UP));
                    } else {
                        this.getWorld().removeBlock(this.getSelectedBlock().x,
                                this.getSelectedBlock().y, this.getSelectedBlock().z);
                    }
                    updateSelectedBlock();
                }
            } catch (CoordinatesOutOfBoundsException ex) {
                ex.printStackTrace();
            }
        }
    }
}
 
开发者ID:mstojcevich,项目名称:Radix,代码行数:27,代码来源:RadixClient.java


注:本文中的org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerActionPacket类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。