Exemplo n.º 1
0
  @Override
  public Set<org.getspout.spoutapi.material.Block> getModifiedBlocks() {
    // hit cache first
    if (cachedBlockData != null) {
      return cachedBlockData;
    }
    Set<org.getspout.spoutapi.material.Block> modified =
        new HashSet<org.getspout.spoutapi.material.Block>();
    TLongFloatIterator i = originalFriction.iterator();
    while (i.hasNext()) {
      i.advance();
      int id = TIntPairHashSet.longToKey1(i.key());
      int data = TIntPairHashSet.longToKey2(i.key());

      org.getspout.spoutapi.material.Block block = MaterialData.getBlock(id, (short) data);
      if (block != null) {
        modified.add(block);
      }
    }

    i = originalHardness.iterator();
    while (i.hasNext()) {
      i.advance();
      int id = TIntPairHashSet.longToKey1(i.key());
      int data = TIntPairHashSet.longToKey2(i.key());
      org.getspout.spoutapi.material.Block block = MaterialData.getBlock(id, (short) data);
      if (block != null) {
        modified.add(block);
      }
    }

    TIntIntIterator j = originalLight.iterator();
    while (j.hasNext()) {
      j.advance();
      org.getspout.spoutapi.material.Block block = MaterialData.getBlock(j.key());
      if (block != null) {
        modified.add(block);
      }
    }

    TIntByteIterator k = originalOpacity.iterator();
    while (k.hasNext()) {
      k.advance();
      org.getspout.spoutapi.material.Block block = MaterialData.getBlock(k.key());
      if (block != null) {
        modified.add(block);
      }
    }
    cachedBlockData = modified; // save to cache
    return modified;
  }
Exemplo n.º 2
0
 private void updateBlockAttributes(int id, short data) {
   org.getspout.spoutapi.material.Block block = MaterialData.getBlock(id, data);
   if (block != null) {
     cachedBlockData = null;
     HashSet<org.getspout.spoutapi.material.Block> toUpdate =
         new HashSet<org.getspout.spoutapi.material.Block>(1);
     toUpdate.add(block);
     SpoutPacket updatePacket = new PacketBlockData(toUpdate);
     for (SpoutPlayer player : SpoutManager.getOnlinePlayers()) {
       if (player.isSpoutCraftEnabled()) player.sendPacket(updatePacket);
     }
   }
 }