Java 类net.minecraft.nbt.NBTTagByteArray 实例源码

项目:Minecoprocessors    文件:Processor.java   
@Override
public NBTTagCompound writeToNBT() {
  NBTTagCompound c = new NBTTagCompound();
  c.setByteArray(NBT_STACK, stack);
  c.setByteArray(NBT_REGISTERS, registers);
  c.setLong(NBT_FLAGS, packFlags());
  if (error != null) {
    c.setString(NBT_ERROR, error);
  }
  NBTTagList programTag = new NBTTagList();
  for (byte[] b : program) {
    programTag.appendTag(new NBTTagByteArray(b));
  }
  c.setTag(NBT_PROGRAM, programTag);

  NBTTagList labelTag = new NBTTagList();
  for (Label label : labels) {
    labelTag.appendTag(label.toNbt());
  }
  c.setTag(NBT_LABELS, labelTag);

  return c;
}
项目:TaleCraft    文件:NBTHelper.java   
private static void asJson(NBTBase tag, StringBuilder builder) {
    switch(tag.getId()) {
    case NBT.TAG_BYTE: builder.append(((NBTTagByte)tag).getByte()).append('b'); break;
    case NBT.TAG_SHORT: builder.append(((NBTTagShort)tag).getByte()).append('b'); break;
    case NBT.TAG_INT: builder.append(((NBTTagInt)tag).getInt()); break;
    case NBT.TAG_LONG: builder.append(((NBTTagLong)tag).getByte()).append('l'); break;
    case NBT.TAG_FLOAT: builder.append(((NBTTagFloat)tag).getFloat()).append('f'); break;
    case NBT.TAG_DOUBLE: builder.append(((NBTTagDouble)tag).getDouble()).append('d'); break;
    case NBT.TAG_STRING: builder.append('"').append(((NBTTagString)tag).getString()).append('"'); break;
    case NBT.TAG_BYTE_ARRAY: builder.append(Arrays.toString(((NBTTagByteArray)tag).getByteArray())); break;
    case NBT.TAG_INT_ARRAY: builder.append(Arrays.toString(((NBTTagIntArray)tag).getIntArray())); break;
    case NBT.TAG_COMPOUND: asJson((NBTTagCompound) tag, builder); break;
    case NBT.TAG_LIST: asJson((NBTTagList) tag, builder); break;
    }

}
项目:copycore    文件:NbtUtils.java   
/** Creates and returns a primitive NBT tag from a value.
 *  If the value already is an NBT tag, it is returned instead. */
public static NBTBase createTag(Object value) {
    if (value == null)
        throw new IllegalArgumentException("value is null");
    if (value instanceof NBTBase) return (NBTBase)value;
    if (value instanceof Byte)    return new NBTTagByte((Byte)value);
    if (value instanceof Short)   return new NBTTagShort((Short)value);
    if (value instanceof Integer) return new NBTTagInt((Integer)value);
    if (value instanceof Long)    return new NBTTagLong((Long)value);
    if (value instanceof Float)   return new NBTTagFloat((Float)value);
    if (value instanceof Double)  return new NBTTagDouble((Double)value);
    if (value instanceof String)  return new NBTTagString((String)value);
    if (value instanceof byte[])  return new NBTTagByteArray((byte[])value);
    if (value instanceof int[])   return new NBTTagIntArray((int[])value);
    throw new IllegalArgumentException("Can't create an NBT tag of value: " + value);
}
项目:CraftingManager    文件:ConvertNBTTagCompound.java   
public static Object getObject(NBTBase base)
{
    if(base instanceof NBTTagByte)
        return ((NBTTagByte)base).func_150290_f();
    if(base instanceof NBTTagShort)
        return ((NBTTagShort)base).func_150289_e();
    if(base instanceof NBTTagInt)
        return ((NBTTagInt)base).func_150287_d();
    if(base instanceof NBTTagLong)
        return ((NBTTagLong)base).func_150291_c();
    if(base instanceof NBTTagFloat)
        return ((NBTTagFloat)base).func_150288_h();
    if(base instanceof NBTTagDouble)
        return ((NBTTagDouble)base).func_150286_g();
    if(base instanceof NBTTagByteArray)
        return ((NBTTagByteArray)base).func_150292_c();
    if(base instanceof NBTTagString)
        return ((NBTTagString)base).func_150285_a_();
    if(base instanceof NBTTagList)
        return base;
    if(base instanceof NBTTagCompound)
        return ((NBTTagCompound)base);
    if(base instanceof NBTTagIntArray)
        return ((NBTTagIntArray)base).func_150302_c();
    return null;
}
项目:NBTEdit    文件:GuiEditNBT.java   
private static void setValidValue(Node<NamedNBT> node, String value){
    NamedNBT named = node.getObject();
    NBTBase base = named.getNBT();

    if (base instanceof NBTTagByte)
        named.setNBT(new NBTTagByte(ParseHelper.parseByte(value)));
    if (base instanceof NBTTagShort)
        named.setNBT(new NBTTagShort(ParseHelper.parseShort(value)));
    if (base instanceof NBTTagInt)
        named.setNBT(new NBTTagInt(ParseHelper.parseInt(value)));
    if (base instanceof NBTTagLong)
        named.setNBT(new NBTTagLong(ParseHelper.parseLong(value)));
    if(base instanceof NBTTagFloat)
        named.setNBT(new NBTTagFloat(ParseHelper.parseFloat(value)));
    if(base instanceof NBTTagDouble)
        named.setNBT(new NBTTagDouble(ParseHelper.parseDouble(value)));
    if(base instanceof NBTTagByteArray)
        named.setNBT(new NBTTagByteArray(ParseHelper.parseByteArray(value)));
    if(base instanceof NBTTagIntArray)
        named.setNBT(new NBTTagIntArray(ParseHelper.parseIntArray(value)));
    if (base instanceof NBTTagString)
        named.setNBT(new NBTTagString(value));
}
项目:NBTEdit    文件:GuiEditNBT.java   
private static String getValue(NBTBase base){
    switch(base.getId()){
    case 7:
        String s = "";
        for (byte b : ((NBTTagByteArray)base).func_150292_c() /*byteArray*/){
            s += b + " ";
        }
        return s;
    case 9:
        return "TagList";
    case 10:
        return "TagCompound";
    case 11:
        String i = "";
        for (int a : ((NBTTagIntArray)base).func_150302_c() /*intArray*/){
            i += a + " ";
        }
        return i;
    default: 
        return NBTStringHelper.toString(base);
    }
}
项目:CrystalMod    文件:TileWorksiteUserBlocks.java   
@Override
public void readCustomNBT(NBTTagCompound tag) {
    super.readCustomNBT(tag);
    if (tag.hasKey("targetMap")
            && tag.getTag("targetMap") instanceof NBTTagByteArray) {
        targetMap = tag.getByteArray("targetMap");
    }
}
项目:InspiringWorld    文件:NBTArrayBuilder.java   
public NBTTagByteArray buildAsByte()
{
    byte[] bytes = new byte[integers.size()];
    for (int i = 0; i < bytes.length; i++)
        bytes[i] = (byte) integers.get(i);
    return new NBTTagByteArray(bytes);
}
项目:ThermosRebased    文件:ArrayHandler.java   
@Override
public T[] read(final NBTTagByteArray nbt) {
    final WritableBuf buf = new WritableBuf(nbt.func_150292_c());
    final int length = buf.readInt();
    final Class<T> componentType = buf.readClass();
    final T[] array = Array.newArray(componentType, length);
    for (int i = 0; i < length; ++i) {
        buf.readNBT();
    }
    return null;
}
项目:ThermosRebased    文件:ArrayHandler.java   
@Override
public NBTTagByteArray write(final T[] value) {
    final WritableBuf buf = new WritableBuf(Unpooled.buffer());
    buf.writeInt(value.length);
    buf.writeClass(value.getClass().getComponentType());
    for (final T t : value) {
        final NBTBase nbt = ImagineObject.nbt(t);
        if (nbt == null) {
            throw new RuntimeException("Null items not allowed");
        }
        buf.writeNBT(nbt);
    }
    return new NBTTagByteArray(buf.array());
}
项目:ThermosRebased    文件:BooleanArrayHandler.java   
@Override
public boolean[] read(final NBTTagByteArray nbt) {
    final byte[] bytes = nbt.func_150292_c();
    final WritableBuf buf = new WritableBuf(bytes);
    final int length = buf.readInt();
    if (length == 0) {
        return BooleanArrayHandler.EMPTY;
    }
    final int bytesLength = buf.readInt();
    final byte[] z = new byte[bytesLength];
    buf.readBytes(z, 0, bytesLength);
    return bytesToBoolean(z, length);
}
项目:ThermosRebased    文件:BooleanArrayHandler.java   
@Override
public NBTTagByteArray write(final boolean[] value) {
    final int length = value.length;
    final byte[] bytes = booleanToBytes(value);
    final int byteLength = 4 + bytes.length;
    final WritableBuf buf = new WritableBuf(Unpooled.buffer(byteLength, byteLength));
    buf.writeInt(length);
    if (length != 0) {
        buf.writeInt(bytes.length);
        buf.writeBytes(bytes);
    }
    return new NBTTagByteArray(buf.array());
}
项目:NOVA-Core    文件:DataConverter.java   
/**
 * Reads an unknown object withPriority a known name from NBT
 * @param tag - tag to read the value from
 * @param key - name of the value
 * @return object or suggestionValue if nothing is found
 */
public Object load(NBTTagCompound tag, String key) {
    if (tag != null && key != null) {
        NBTBase saveTag = tag.getTag(key);

        if (saveTag instanceof NBTTagFloat) {
            return tag.getFloat(key);
        } else if (saveTag instanceof NBTTagDouble) {
            return tag.getDouble(key);
        } else if (saveTag instanceof NBTTagInt) {
            return tag.getInteger(key);
        } else if (saveTag instanceof NBTTagString) {
            if (tag.getBoolean(key + "::nova.isBigInteger")) {
                return new BigInteger(tag.getString(key));
            } else if (tag.getBoolean(key + "::nova.isBigDecimal")) {
                return new BigDecimal(tag.getString(key));
            } else {
                return tag.getString(key);
            }
        } else if (saveTag instanceof NBTTagShort) {
            return tag.getShort(key);
        } else if (saveTag instanceof NBTTagByte) {
            if (tag.getBoolean(key + "::nova.isBoolean")) {
                return tag.getBoolean(key);
            } else {
                return tag.getByte(key);
            }
        } else if (saveTag instanceof NBTTagLong) {
            return tag.getLong(key);
        } else if (saveTag instanceof NBTTagByteArray) {
            return tag.getByteArray(key);
        } else if (saveTag instanceof NBTTagIntArray) {
            return tag.getIntArray(key);
        } else if (saveTag instanceof NBTTagCompound) {
            NBTTagCompound innerTag = tag.getCompoundTag(key);
            return toNova(innerTag);
        }
    }
    return null;
}
项目:NOVA-Core    文件:DataConverter.java   
/**
 * Reads an unknown object withPriority a known name from NBT
 * @param tag - tag to read the value from
 * @param key - name of the value
 * @return object or suggestionValue if nothing is found
 */
public Object load(NBTTagCompound tag, String key) {
    if (tag != null && key != null) {
        NBTBase saveTag = tag.getTag(key);

        if (saveTag instanceof NBTTagFloat) {
            return tag.getFloat(key);
        } else if (saveTag instanceof NBTTagDouble) {
            return tag.getDouble(key);
        } else if (saveTag instanceof NBTTagInt) {
            return tag.getInteger(key);
        } else if (saveTag instanceof NBTTagString) {
            if (tag.getBoolean(key + "::nova.isBigInteger")) {
                return new BigInteger(tag.getString(key));
            } else if (tag.getBoolean(key + "::nova.isBigDecimal")) {
                return new BigDecimal(tag.getString(key));
            } else {
                return tag.getString(key);
            }
        } else if (saveTag instanceof NBTTagShort) {
            return tag.getShort(key);
        } else if (saveTag instanceof NBTTagByte) {
            if (tag.getBoolean(key + "::nova.isBoolean")) {
                return tag.getBoolean(key);
            } else {
                return tag.getByte(key);
            }
        } else if (saveTag instanceof NBTTagLong) {
            return tag.getLong(key);
        } else if (saveTag instanceof NBTTagByteArray) {
            return tag.getByteArray(key);
        } else if (saveTag instanceof NBTTagIntArray) {
            return tag.getIntArray(key);
        } else if (saveTag instanceof NBTTagCompound) {
            NBTTagCompound innerTag = tag.getCompoundTag(key);
            return toNova(innerTag);
        }
    }
    return null;
}
项目:copycore    文件:NbtUtils.java   
/** Returns the primitive value of a tag, casted to the return type. */
public static <T> T getTagValue(NBTBase tag) {
    if (tag == null)
        throw new IllegalArgumentException("tag is null");
    if (tag instanceof NBTTagByte)      return (T)(Object)((NBTTagByte)tag).func_150290_f();
    if (tag instanceof NBTTagShort)     return (T)(Object)((NBTTagShort)tag).func_150289_e();
    if (tag instanceof NBTTagInt)       return (T)(Object)((NBTTagInt)tag).func_150287_d();
    if (tag instanceof NBTTagLong)      return (T)(Object)((NBTTagLong)tag).func_150291_c();
    if (tag instanceof NBTTagFloat)     return (T)(Object)((NBTTagFloat)tag).func_150288_h();
    if (tag instanceof NBTTagDouble)    return (T)(Object)((NBTTagDouble)tag).func_150286_g();
    if (tag instanceof NBTTagString)    return (T)((NBTTagString)tag).func_150285_a_();
    if (tag instanceof NBTTagByteArray) return (T)((NBTTagByteArray)tag).func_150292_c();
    if (tag instanceof NBTTagIntArray)  return (T)((NBTTagIntArray)tag).func_150302_c();
    throw new IllegalArgumentException(NBTBase.NBTTypes[tag.getId()] + " isn't a primitive NBT tag");
}
项目:projectzulu1.7.10-pre-1.3a    文件:NBTWriter.java   
private static NBTBase createChildTag(byte childtag, String... values) {
    switch (childtag) {
    /* Container Tags */
    case 9:
        return new NBTTagList();
    case 10:
        return new NBTTagCompound();
        /* Value Tags: operations[2] should contain value */
    case 1:
        return new NBTTagByte(Byte.parseByte(values[0].trim()));
    case 2:
        return new NBTTagShort(Short.parseShort(values[0].trim()));
    case 3:
        return new NBTTagInt(Integer.parseInt(values[0].trim()));
    case 4:
        return new NBTTagLong(Long.parseLong(values[0].trim()));
    case 5:
        return new NBTTagFloat(Float.parseFloat(values[0].trim()));
    case 6:
        return new NBTTagDouble(Double.parseDouble(values[0].trim()));
    case 7:
        byte[] byteArray = new byte[values.length];
        for (int i = 2; i < values.length; i++) {
            byteArray[i - 2] = (byte) ParsingHelper.parseFilteredInteger(values[i], 0, "ByteArray");
        }
        return new NBTTagByteArray(byteArray);
    case 8:
        return new NBTTagString("");
    case 11:
        int[] intArray = new int[values.length - 2];
        for (int i = 2; i < values.length; i++) {
            intArray[i - 2] = (int) ParsingHelper.parseFilteredInteger(values[i], 0, "ByteArray");
        }
        return new NBTTagIntArray(intArray);
    default:
        ProjectZuluLog.severe("Unrecognised childtag tagId %s", childtag);
        throw new IllegalArgumentException();
    }
}
项目:DynIMC    文件:NBTTagCompoundDeserializer.java   
private NBTTagByteArray getByteArray(JsonArray jsonArray) {
    byte[] byteArray = new byte[jsonArray.size()];

    for (int i = 0; i < jsonArray.size(); i++) {
        final JsonElement element = jsonArray.get(i);
        final String str = element.getAsString();
        byteArray[i] = str.startsWith("0x") ? Byte.parseByte(str.substring(2), 0x10) : element.getAsByte();
    }

    return new NBTTagByteArray(byteArray);
}
项目:NBTEdit    文件:NBTStringHelper.java   
public static NBTBase newTag(byte type){
    switch (type)
    {
    case 0:
        return new NBTTagEnd();
    case 1:
        return new NBTTagByte((byte) 0);
    case 2:
        return new NBTTagShort();
    case 3:
        return new NBTTagInt(0);
    case 4:
        return new NBTTagLong(0);
    case 5:
        return new NBTTagFloat(0);
    case 6:
        return new NBTTagDouble(0);
    case 7:
        return new NBTTagByteArray(new byte[0]);
    case 8:
        return new NBTTagString("");
    case 9:
        return new NBTTagList();
    case 10:
        return new NBTTagCompound();
    case 11:
        return new NBTTagIntArray(new int[0]);
    default:
        return null;
    }
}
项目:RuneCraftery    文件:NBTTagCompound.java   
public byte[] func_74770_j(String p_74770_1_) {
   try {
      return !this.field_74784_a.containsKey(p_74770_1_)?new byte[0]:((NBTTagByteArray)this.field_74784_a.get(p_74770_1_)).field_74754_a;
   } catch (ClassCastException var3) {
      throw new ReportedException(this.func_82581_a(p_74770_1_, 7, var3));
   }
}
项目:RuneCraftery    文件:NBTBase.java   
public static NBTBase func_74733_a(byte p_74733_0_, String p_74733_1_) {
   switch(p_74733_0_) {
   case 0:
      return new NBTTagEnd();
   case 1:
      return new NBTTagByte(p_74733_1_);
   case 2:
      return new NBTTagShort(p_74733_1_);
   case 3:
      return new NBTTagInt(p_74733_1_);
   case 4:
      return new NBTTagLong(p_74733_1_);
   case 5:
      return new NBTTagFloat(p_74733_1_);
   case 6:
      return new NBTTagDouble(p_74733_1_);
   case 7:
      return new NBTTagByteArray(p_74733_1_);
   case 8:
      return new NBTTagString(p_74733_1_);
   case 9:
      return new NBTTagList(p_74733_1_);
   case 10:
      return new NBTTagCompound(p_74733_1_);
   case 11:
      return new NBTTagIntArray(p_74733_1_);
   default:
      return null;
   }
}
项目:projectzulu1.7.10    文件:NBTWriter.java   
private static NBTBase createChildTag(byte childtag, String... values) {
    switch (childtag) {
    /* Container Tags */
    case 9:
        return new NBTTagList();
    case 10:
        return new NBTTagCompound();
        /* Value Tags: operations[2] should contain value */
    case 1:
        return new NBTTagByte(Byte.parseByte(values[0].trim()));
    case 2:
        return new NBTTagShort(Short.parseShort(values[0].trim()));
    case 3:
        return new NBTTagInt(Integer.parseInt(values[0].trim()));
    case 4:
        return new NBTTagLong(Long.parseLong(values[0].trim()));
    case 5:
        return new NBTTagFloat(Float.parseFloat(values[0].trim()));
    case 6:
        return new NBTTagDouble(Double.parseDouble(values[0].trim()));
    case 7:
        byte[] byteArray = new byte[values.length];
        for (int i = 2; i < values.length; i++) {
            byteArray[i - 2] = (byte) ParsingHelper.parseFilteredInteger(values[i], 0, "ByteArray");
        }
        return new NBTTagByteArray(byteArray);
    case 8:
        return new NBTTagString("");
    case 11:
        int[] intArray = new int[values.length - 2];
        for (int i = 2; i < values.length; i++) {
            intArray[i - 2] = (int) ParsingHelper.parseFilteredInteger(values[i], 0, "ByteArray");
        }
        return new NBTTagIntArray(intArray);
    default:
        ProjectZuluLog.severe("Unrecognised childtag tagId %s", childtag);
        throw new IllegalArgumentException();
    }
}
项目:SevenCommons    文件:ArrayConversions.java   
private static MethodHandle writeByteArr() {
    if (WR_BYTE_ARR == null) {
        try {
            WR_BYTE_ARR = MethodHandles.publicLookup()
                    .findConstructor(NBTTagByteArray.class, methodType(void.class, String.class, byte[].class))
                    .bindTo("")
                    .asType(methodType(NBTBase.class, byte[].class));
        } catch (ReflectiveOperationException e) {
            throw Throwables.propagate(e);
        }
    }
    return WR_BYTE_ARR;
}
项目:SevenCommons    文件:ArrayConversions.java   
private static MethodHandle readByteArr() {
    if (RE_BYTE_ARR == null) {
        try {
            RE_BYTE_ARR = MethodHandles.publicLookup()
                    .findGetter(NBTTagByteArray.class, MCPNames.field(MCPNames.F_NBT_BYTE_ARR_DATA), byte[].class);
        } catch (ReflectiveOperationException e) {
            throw Throwables.propagate(e);
        }
    }
    return RE_BYTE_ARR;
}
项目:MinecraftScripting    文件:TAG_Base.java   
/**
 * Called to create a script visible NBT Tag.
 */
public static TAG_Base createFromNative(NBTBase base) {
    if (base instanceof NBTTagByte)
        return new TAG_Byte((NBTTagByte)base);
    if (base instanceof NBTTagByteArray)
        return new TAG_Byte_Array((NBTTagByteArray)base);
    if (base instanceof NBTTagCompound)
        return new TAG_Compound((NBTTagCompound)base);
    if (base instanceof NBTTagDouble)
        return new TAG_Double((NBTTagDouble)base);
    if (base instanceof NBTTagFloat)
        return new TAG_Float((NBTTagFloat)base);
    if (base instanceof NBTTagInt)
        return new TAG_Int((NBTTagInt)base);
    if (base instanceof NBTTagIntArray)
        return new TAG_Int_Array((NBTTagIntArray)base);
    if (base instanceof NBTTagList)
        return new TAG_List((NBTTagList)base);
    if (base instanceof NBTTagLong)
        return new TAG_Long((NBTTagLong)base);
    if (base instanceof NBTTagShort)
        return new TAG_Short((NBTTagShort)base);
    if (base instanceof NBTTagString)
        return new TAG_String((NBTTagString)base);
    return null;

}
项目:ThermosRebased    文件:ByteArrayHandler.java   
@Override
public byte[] read(final NBTTagByteArray nbt) {
    return nbt.func_150292_c();
}
项目:ThermosRebased    文件:ByteArrayHandler.java   
@Override
public NBTTagByteArray write(final byte[] value) {
    return new NBTTagByteArray(value);
}
项目:NeptuneCommon    文件:NeptuneNBTFactory.java   
@Override
public ByteArrayTag newByteArrayTag(byte[] value) {
    return (ByteArrayTag) new NBTTagByteArray(value);
}
项目:NeptuneMod    文件:NeptuneNBTFactory.java   
@Override
public ByteArrayTag newByteArrayTag(byte[] value) {
    return (ByteArrayTag) new NBTTagByteArray(value);
}
项目:Runes-of-Wizardry    文件:NBTJson.java   
private NBTBase deserializeType(byte type, JsonElement tag, JsonDeserializationContext context){
    NBTBase value;
    //there may be a better way
    switch(type){
    case 0:
        value= context.deserialize(tag, NBTTagEnd.class);
        break;
    case 1:
        value = context.deserialize(tag, NBTTagByte.class);
        break;
    case 2:
        value = context.deserialize(tag, NBTTagShort.class);
        break;
    case 3:
        value = context.deserialize(tag, NBTTagInt.class);
        break;
    case 4:
        value = context.deserialize(tag, NBTTagLong.class);
        break;
    case 5:
        value = context.deserialize(tag, NBTTagFloat.class);
        break;
    case 6:
        value = context.deserialize(tag, NBTTagDouble.class);
        break;
    case 7:
        value = context.deserialize(tag, NBTTagByteArray.class);
        break;
    case 8:
        value = context.deserialize(tag, NBTTagString.class);
        break;
    case 9:
        value = context.deserialize(tag, NBTTagList.class);
        break;
    case 10:
        value = context.deserialize(tag, NBTTagCompound.class);
        break;
    case 11:
        value = context.deserialize(tag, NBTTagIntArray.class);
        break;
    default: value = context.deserialize(tag, NBTBase.class);
    }
    return value;
}
项目:WearableBackpacks    文件:BackpackSize.java   
@Override
public NBTTagByteArray serializeNBT() {
    return new NBTTagByteArray(new byte[]{ (byte)_columns, (byte)_rows });
}
项目:WearableBackpacks    文件:BackpackSize.java   
@Override
public void deserializeNBT(NBTTagByteArray nbt) {
    _columns = nbt.getByteArray()[0];
    _rows    = nbt.getByteArray()[1];
}
项目:RuneCraftery    文件:NBTTagCompound.java   
public void func_74773_a(String p_74773_1_, byte[] p_74773_2_) {
   this.field_74784_a.put(p_74773_1_, new NBTTagByteArray(p_74773_1_, p_74773_2_));
}
项目:AestusCraft    文件:NativesNBTHandler.java   
@SuppressWarnings("unchecked")
@Override
public <T> T readFromTag(NBTBase tag)
{
    if (tag instanceof NBTTagByte)
    {
        return (T) (Object) ((NBTTagByte) tag).data;
    }

    if (tag instanceof NBTTagShort)
    {
        return (T) (Object) ((NBTTagShort) tag).data;
    }

    if (tag instanceof NBTTagInt)
    {
        return (T) (Object) ((NBTTagInt) tag).data;
    }

    if (tag instanceof NBTTagLong)
    {
        return (T) (Object) ((NBTTagLong) tag).data;
    }

    if (tag instanceof NBTTagFloat)
    {
        return (T) (Object) ((NBTTagFloat) tag).data;
    }

    if (tag instanceof NBTTagDouble)
    {
        return (T) (Object) ((NBTTagDouble) tag).data;
    }

    if (tag instanceof NBTTagString)
    {
        return (T) ((NBTTagString) tag).data;
    }

    if (tag instanceof NBTTagByteArray)
    {
        return (T) ((NBTTagByteArray) tag).byteArray;
    }

    if (tag instanceof NBTTagIntArray)
    {
        return (T) ((NBTTagIntArray) tag).intArray;
    }

    return null;
}
项目:AestusCraft    文件:NativesNBTHandler.java   
@Override
public NBTBase writeToTag(String name, Object value)
{
    if (value instanceof Byte)
    {
        return new NBTTagByte(name, (Byte) value);
    }

    if (value instanceof Short)
    {
        return new NBTTagShort(name, (Short) value);
    }

    if (value instanceof Integer)
    {
        return new NBTTagInt(name, (Integer) value);
    }

    if (value instanceof Long)
    {
        return new NBTTagLong(name, (Long) value);
    }

    if (value instanceof Float)
    {
        return new NBTTagFloat(name, (Float) value);
    }

    if (value instanceof Double)
    {
        return new NBTTagDouble(name, (Double) value);
    }

    if (value instanceof String)
    {
        return new NBTTagString(name, (String) value);
    }

    if (value instanceof byte[])
    {
        return new NBTTagByteArray(name, (byte[]) value);
    }

    if (value instanceof int[])
    {
        return new NBTTagIntArray(name, (int[]) value);
    }

    return null;
}
项目:OpenModsLib    文件:TypeRW.java   
@Override
public boolean checkTagType(NBTBase tag) {
    return tag instanceof NBTTagByteArray;
}
项目:MinecraftScripting    文件:TAG_Byte_Array.java   
public TAG_Byte_Array(byte[] data) {
    super(new NBTTagByteArray(data));

    this.arr = (NBTTagByteArray)base;
}
项目:MinecraftScripting    文件:TAG_Byte_Array.java   
public TAG_Byte_Array(NBTTagByteArray arr) {
    super(arr);

    this.arr = arr;
}
项目:MinecraftScripting    文件:TAG_Byte_Array.java   
public TAG_Base copy() {
    return new TAG_Byte_Array((NBTTagByteArray)arr.copy());
}