本文整理汇总了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();
}
}
}
}
示例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();
}
}
}
}
示例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();
}
}
}
}