Examples of BlockChangeMessage


Examples of net.glowstone.net.message.play.game.BlockChangeMessage

public final class BlockChangeCodec implements Codec<BlockChangeMessage> {
    @Override
    public BlockChangeMessage decode(ByteBuf buffer) throws IOException {
        BlockVector pos = GlowBufUtils.readBlockPosition(buffer);
        int type = ByteBufUtils.readVarInt(buffer);
        return new BlockChangeMessage(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), type);
    }
View Full Code Here

Examples of net.glowstone.net.message.play.game.BlockChangeMessage

        chunk.setType(x & 0xf, z & 0xf, y, type);
        chunk.setMetaData(x & 0xf, z & 0xf, y, data);
        if (applyPhysics) {
            // todo: physics
        }
        BlockChangeMessage bcmsg = new BlockChangeMessage(x, y, z, type, data);
        for (GlowPlayer p : getWorld().getRawPlayers()) {
            p.sendBlockChange(bcmsg);
        }

        return true;
View Full Code Here

Examples of net.glowstone.net.message.play.game.BlockChangeMessage

    public void setData(byte data, boolean applyPhyiscs) {
        chunk.setMetaData(x & 0xf, z & 0xf, y & 0x7f, data);
        if (applyPhyiscs) {
            // todo: physics
        }
        BlockChangeMessage bcmsg = new BlockChangeMessage(x, y, z, getTypeId(), data);
        for (GlowPlayer p : getWorld().getRawPlayers()) {
            p.sendBlockChange(bcmsg);
        }
    }
View Full Code Here

Examples of net.lightstone.msg.BlockChangeMessage

    int x = buffer.readInt();
    int y = buffer.readUnsignedByte();
    int z = buffer.readInt();
    int type = buffer.readUnsignedByte();
    int metadata = buffer.readUnsignedByte();
    return new BlockChangeMessage(x, y, z, type, metadata);
  }
View Full Code Here

Examples of net.lightstone.msg.BlockChangeMessage

      Chunk chunk = world.getChunks().getChunk(chunkX, chunkZ);
      int oldType = chunk.getType(localX, localZ, y);
      chunk.setType(localX, localZ, y, Blocks.TYPE_AIR);

      // TODO this should also be somewhere else as well... perhaps in the chunk.setType() method itself?
      BlockChangeMessage bcmsg = new BlockChangeMessage(x, y, z, 0, 0);
      SoundEffectMessage soundMsg = new SoundEffectMessage(SoundEffectMessage.DIG_SOUND, x, y, z, oldType);
      for (Player p: world.getPlayers()) {
        p.getSession().send(bcmsg);
        if(p != player && player.isWithinDistance(p)) {
          p.getSession().send(soundMsg);
View Full Code Here

Examples of org.spout.vanilla.protocol.msg.world.block.BlockChangeMessage

    short data = event.getChunk().getBlockData(event.getX(), event.getY(), event.getZ());
    short id = getMinecraftId(material);
    int x = event.getX() + event.getChunk().getBlockX();
    int y = event.getY() + event.getChunk().getBlockY();
    int z = event.getZ() + event.getChunk().getBlockZ();
    BlockChangeMessage BCM = new BlockChangeMessage(x, y, z, id, getMinecraftData(material, data), getRepositionManager());
    getSession().send(BCM);
  }
View Full Code Here

Examples of org.spout.vanilla.protocol.msg.world.block.BlockChangeMessage

//TODO Re-write this
public final class PlayerBlockPlacementHandler extends MessageHandler<PlayerBlockPlacementMessage> {
  private void refreshClient(Player player, Block clickedBlock, BlockFace clickedFace, RepositionManager rm) {
    // refresh the client just in case it assumed something
    player.getNetwork().getSession().send(new BlockChangeMessage(clickedBlock, rm));
    player.getNetwork().getSession().send(new BlockChangeMessage(clickedBlock.translate(clickedFace), rm));
    Slot held = PlayerUtil.getHeldSlot(player);
    if (held != null) {
      held.set(held.get());
    }
  }
View Full Code Here

Examples of org.spout.vanilla.protocol.msg.world.block.BlockChangeMessage

    int x = buffer.readInt();
    int y = buffer.readUnsignedByte();
    int z = buffer.readInt();
    short type = buffer.readShort();
    int metadata = buffer.readUnsignedByte();
    return new BlockChangeMessage(x, y, z, type, metadata, NullRepositionManager.getInstance());
  }
View Full Code Here

Examples of org.spout.vanilla.protocol.msg.world.block.BlockChangeMessage

    // Don't block protections if dropping an item, silly Notch...
    if (state != PlayerDiggingMessage.STATE_DROP_ITEM && state != PlayerDiggingMessage.STATE_SHOOT_ARROW_EAT_FOOD) {
      Collection<Protection> protections = player.getEngine().getServiceManager().getRegistration(ProtectionService.class).getProvider().getAllProtections(point);
      for (Protection p : protections) {
        if (p.contains(point) && !human.isOp()) {
          player.getNetwork().getSession().send(new BlockChangeMessage(x, y, z, minecraftID, block.getBlockData() & 0xF, rm));
          player.sendMessage(ChatStyle.DARK_RED + "This area is a protected spawn point!");
          return;
        }
      }
    }

    if (state == PlayerDiggingMessage.STATE_DROP_ITEM && x == 0 && y == 0 && z == 0) {
      human.dropItem();
      return;
    }

    boolean isInteractable = true;
    if (blockMaterial == VanillaMaterials.AIR) {
      isInteractable = false;
    }
    // TODO VanillaPlayerInteractBlockEvent and add in Results to it (to
    // more indepthly take away durability).
    switch (state) {
      case PlayerDiggingMessage.STATE_START_DIGGING:
        if (!isProtected(player, rm, x, y, z, block, minecraftID)) {
          final PlayerInteractBlockEvent event = new PlayerInteractBlockEvent(player, block, point, clickedFace, Action.LEFT_CLICK);
          if (player.getEngine().getEventManager().callEvent(event).isCancelled()) {
            if (human.isCreative() || blockMaterial.getHardness() == 0.0f) {
              session.send(new BlockChangeMessage(block, player.getNetwork().getRepositionManager()));
              Sign sign = block.get(Sign.class);
              if (sign != null) {
                session.send(new SignMessage(block.getX(), block.getY(), block.getZ(), sign.getText(), player.getNetwork().getRepositionManager()));
              }
            }
          } else {
            // Perform interactions
            if (heldItem == null) {
              // interacting using fist
            } else if (!isInteractable) {
              // interacting with nothing using item
              heldItem.getMaterial().onInteract(player, Action.LEFT_CLICK);
            } else {
              // interacting with block using item
              heldItem.getMaterial().onInteract(player, block, Action.LEFT_CLICK, clickedFace);
            }

            if (isInteractable) {
              Block neigh = block.translate(clickedFace);
              boolean fire = neigh.getMaterial().equals(VanillaMaterials.FIRE);
              if (fire) {
                // put out fire
                if (VanillaMaterials.FIRE.onDestroy(neigh, new PlayerBreakCause(player, neigh))) {
                  GeneralEffects.RANDOM_FIZZ.playGlobal(block.getPosition());
                }
              } else if (human.isSurvival() && blockMaterial.getHardness() != 0.0f) {
                ItemStack currentItem = PlayerUtil.getHeldSlot(player).get();
                if (currentItem != null) {
                  player.get(Digging.class).startDigging(new Point(w, x, y, z), currentItem.getMaterial());
                } else {
                  player.get(Digging.class).startDigging(new Point(w, x, y, z), VanillaMaterials.AIR);
                }
              } else {
                // insta-break
                if (breakBlock(blockMaterial, block, human, session)) {
                  GeneralEffects.BREAKBLOCK.playGlobal(block.getPosition(), blockMaterial, player);
                }
              }
            }
          }
        }
        break;
      case PlayerDiggingMessage.STATE_CANCEL_DIGGING:
        if (!isProtected(player, rm, x, y, z, block, minecraftID)) {
          player.get(Digging.class).stopDigging(new Point(w, x, y, z), false);
        }
        break;
      case PlayerDiggingMessage.STATE_DONE_DIGGING:
        if (!isProtected(player, rm, x, y, z, block, minecraftID)) {
          Digging diggingComponent = player.get(Digging.class);

          if (!diggingComponent.stopDigging(new Point(w, x, y, z), true) || !isInteractable) {
            if (!diggingComponent.isDigging()) {
              session.send(new BlockChangeMessage(block, player.getNetwork().getRepositionManager()));
              Sign sign = block.get(Sign.class);
              if (sign != null) {
                session.send(new SignMessage(block.getX(), block.getY(), block.getZ(), sign.getText(), player.getNetwork().getRepositionManager()));
              }
            }
View Full Code Here

Examples of org.spout.vanilla.protocol.msg.world.block.BlockChangeMessage

    if (heldItem != null) {
      heldItem.getMaterial().getItemFlags(heldItem, flags);
    }
    if (!blockMaterial.destroy(block, flags, new PlayerBreakCause((Player) human.getOwner(), block))) {
      RepositionManager rm = session.getPlayer().getNetwork().getRepositionManager();
      session.send(new BlockChangeMessage(block, rm));
      Sign sign = block.get(Sign.class);
      if (sign != null) {
        session.send(new SignMessage(block.getX(), block.getY(), block.getZ(), sign.getText(), rm));
      }
      return false;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.