Пример #1
0
 @Override
 public void resetHardness(org.getspout.spoutapi.material.Block block) {
   int id = block.getRawId();
   if (block instanceof CustomBlock) {
     id = ((CustomBlock) block).getBlockId();
   }
   int data = block.getRawData();
   if (originalHardness.containsKey(id, data)) {
     setHardness(block, originalHardness.get(id, data));
     originalHardness.remove(id, data);
   }
   updateBlockAttributes(id, (short) data); // invalidate cache
 }
Пример #2
0
 @Override
 public void setFriction(org.getspout.spoutapi.material.Block block, float friction) {
   int id = block.getRawId();
   if (block instanceof CustomBlock) {
     id = ((CustomBlock) block).getBlockId();
   }
   int data = block.getRawData();
   if (!originalFriction.containsKey(id, data)) {
     originalFriction.put(id, data, getFriction(block));
   }
   net.minecraft.server.Block.byId[id].frictionFactor = friction;
   updateBlockAttributes(id, (short) data); // invalidate cache
 }
Пример #3
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;
  }
Пример #4
0
 @Override
 public void setHardness(org.getspout.spoutapi.material.Block block, float hardness) {
   int id = block.getRawId();
   if (block instanceof CustomBlock) {
     id = ((CustomBlock) block).getBlockId();
   }
   int data = block.getRawData();
   if (!originalHardness.containsKey(id, data)) {
     originalHardness.put(id, data, getHardness(block));
   }
   net.minecraft.server.Block b = net.minecraft.server.Block.byId[id];
   if (b instanceof CustomMCBlock) {
     ((CustomMCBlock) b).setHardness(hardness);
   }
   updateBlockAttributes(id, (short) data); // invalidate cache
 }