use of net.glowstone.net.message.play.player.DiggingMessage in project Dragonet-Legacy by DragonetMC.
the class PlayerActionPacketTranslator method handleSpecific.
@Override
public Message[] handleSpecific(PlayerActionPacket packet) {
System.out.println("ACTION = " + packet.action + " @ (" + packet.x + ", " + packet.y + ", " + packet.z + ") face=" + packet.face);
Message ret = null;
switch(packet.action) {
case PlayerActionPacket.ACTION_START_BREAK:
ret = new DiggingMessage(DiggingMessage.START_DIGGING, packet.x, packet.y, packet.z, packet.face);
break;
}
return new Message[] { ret };
}
use of net.glowstone.net.message.play.player.DiggingMessage in project Dragonet-Legacy by DragonetMC.
the class RemoveBlockPacketTranslator method handleSpecific.
@Override
public Message[] handleSpecific(RemoveBlockPacket packet) {
if (!(this.getSession().getPlayer() instanceof Player)) {
return null;
}
if (getSession().getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
final GlowPlayer player = getSession().getPlayer();
GlowWorld world = player.getWorld();
GlowBlock block = world.getBlockAt(packet.x, packet.y, packet.z);
PlayerInteractEvent interactEvent = EventFactory.onPlayerInteract(player, Action.LEFT_CLICK_BLOCK, block, BlockFace.UP);
if (interactEvent.isCancelled()) {
player.sendBlockChange(block.getLocation(), block.getType(), block.getData());
return null;
}
block.setType(Material.AIR);
} else {
//Not Creative
DiggingMessage msgFinishBreak = new DiggingMessage(DiggingMessage.FINISH_DIGGING, packet.x, packet.y, packet.z, 1);
return new Message[] { msgFinishBreak };
}
return null;
}
use of net.glowstone.net.message.play.player.DiggingMessage in project Glowstone by GlowstoneMC.
the class DiggingCodec method decode.
@Override
public DiggingMessage decode(ByteBuf buf) throws IOException {
int state = buf.readByte();
BlockVector pos = GlowBufUtils.readBlockPosition(buf);
int face = buf.readByte();
return new DiggingMessage(state, pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), face);
}
Aggregations