Package org.spoutcraft.api.material

Examples of org.spoutcraft.api.material.Block


    short size = input.readShort();
    for (int i = 0; i < size; i++) {
      int id = input.readInt();
      int data = input.readShort();
      float mod = input.readFloat();
      Block block = MaterialData.getBlock(id, (short) data);
      if (data == -1) {
        block = MaterialData.getCustomBlock(id);
      }
      setStrengthModifier(block, mod);
    }
View Full Code Here


    super.writeData(output);
    output.writeShort(getDurability());
    Block[] mod = getStrengthModifiedBlocks();
    output.writeShort((short) mod.length);
    for (int i = 0; i < mod.length; i++) {
      Block block =  mod[i];
      if (block instanceof CustomBlock) {
        output.writeInt(((CustomBlock)block).getCustomId());
        output.writeShort((short) -1);
      } else {
        output.writeInt(block.getRawId());
        output.writeShort((short) block.getRawData());
      }
      output.writeFloat(getStrengthModifier(block));
    }
  }
View Full Code Here

      ByteBuffer result = ByteBuffer.allocate(data.length).put(data);
      for (int i = 0; i < data.length / 15; i++) {
        int index = i * 15;
        int id = result.get(index);
        short rawData = result.get(index+1);
        Block block = MaterialData.getBlock(id, rawData);
        if (block != null) {
          block.setHardness(result.getFloat(index+2));
          block.setLightLevel(result.getInt(index+6));
          block.setFriction(result.getFloat(index+10));
          block.setOpaque(result.get(index+14) != 0);
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.spoutcraft.api.material.Block

Copyright © 2018 www.massapicom. 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.