net.minecraft.nbt.NBTTagByteArray Java Examples

The following examples show how to use net.minecraft.nbt.NBTTagByteArray. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GuiEditSingleNBT.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
private static String getValue(NBTBase base) {
    switch (base.getId()) {
        case 7: {
            String s = "";
            for (byte b : ((NBTTagByteArray) base).func_150292_c()) {
                s = s + b + " ";
            }
            return s;
        }
        case 9: {
            return "TagList";
        }
        case 10: {
            return "TagCompound";
        }
        case 11: {
            String i = "";
            for (int a : ((NBTTagIntArray) base).func_150302_c()) {
                i = i + a + " ";
            }
            return i;
        }
    }
    return NBTStringHelper.toString(base);
}
 
Example #2
Source File: Processor.java    From Minecoprocessors with GNU General Public License v3.0 6 votes vote down vote up
@Override
public NBTTagCompound writeToNBT() {
  NBTTagCompound c = new NBTTagCompound();
  c.setByteArray(NBT_STACK, stack);
  c.setByteArray(NBT_REGISTERS, registers);
  c.setByte(NBT_FAULTCODE, faultCode);
  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;
}
 
Example #3
Source File: GuiEditNBT.java    From NBTEdit with GNU General Public License v3.0 6 votes vote down vote up
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));
}
 
Example #4
Source File: GuiEditNBT.java    From NBTEdit with GNU General Public License v3.0 6 votes vote down vote up
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);
	}
}
 
Example #5
Source File: NBTStringHelper.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
public static NBTBase newTag(byte type) {
    switch (type) {
        case 1: {
            return new NBTTagCompound();
        }
        case 2: {
            return new NBTTagByte((byte) 0);
        }
        case 3: {
            return new NBTTagShort();
        }
        case 4: {
            return new NBTTagInt(0);
        }
        case 5: {
            return new NBTTagLong(0L);
        }
        case 6: {
            return new NBTTagFloat(0.0f);
        }
        case 7: {
            return new NBTTagDouble(0.0);
        }
        case 8: {
            return new NBTTagString("");
        }
        case 9: {
            return new NBTTagList();
        }
        case 10: {
            return new NBTTagByteArray(new byte[0]);
        }
        case 11: {
            return new NBTTagIntArray(new int[0]);
        }
    }
    return null;
}
 
Example #6
Source File: GuiEditSingleNBT.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
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));
    }
}
 
Example #7
Source File: DataConverter.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 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
 */
@Nullable
public Object load(@Nullable NBTTagCompound tag, @Nullable 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) {
			return tag.getString(key);
		} else if (saveTag instanceof NBTTagShort) {
			return tag.getShort(key);
		} else if (saveTag instanceof NBTTagByte) {
			if (tag.getBoolean("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;
}
 
Example #8
Source File: DataConverter.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #9
Source File: DataConverter.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #10
Source File: NBTStringHelper.java    From NBTEdit with GNU General Public License v3.0 5 votes vote down vote up
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;
	}
}
 
Example #11
Source File: BackpackSize.java    From WearableBackpacks with MIT License 4 votes vote down vote up
@Override
public NBTTagByteArray serializeNBT() {
	return new NBTTagByteArray(new byte[]{ (byte)_columns, (byte)_rows });
}
 
Example #12
Source File: BackpackSize.java    From WearableBackpacks with MIT License 4 votes vote down vote up
@Override
public void deserializeNBT(NBTTagByteArray nbt) {
	_columns = nbt.getByteArray()[0];
	_rows    = nbt.getByteArray()[1];
}
 
Example #13
Source File: TypeRW.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public boolean checkTagType(NBTBase tag) {
	return tag instanceof NBTTagByteArray;
}