net.minecraft.nbt.NBTTagByte Java Examples

The following examples show how to use net.minecraft.nbt.NBTTagByte. 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: 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 #2
Source File: TileEntitySurgery.java    From Cyberware with MIT License 6 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound compound)
{
	super.readFromNBT(compound);
	
	slots.deserializeNBT(compound.getCompoundTag("inv"));
	slotsPlayer.deserializeNBT(compound.getCompoundTag("inv2"));
	
	NBTTagList list = (NBTTagList) compound.getTag("discard");
	for (int i = 0; i < list.tagCount(); i++)
	{
		this.discardSlots[i] = ((NBTTagByte) list.get(i)).getByte() > 0;
	}
	
	this.essence = compound.getInteger("essence");
	this.maxEssence = compound.getInteger("maxEssence");
	this.lastEntity = compound.getInteger("lastEntity");
	this.missingPower = compound.getBoolean("missingPower");
}
 
Example #3
Source File: TileEntitySurgery.java    From Cyberware with MIT License 6 votes vote down vote up
@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound)
{
	
	compound = super.writeToNBT(compound);

	compound.setInteger("essence", essence);
	compound.setInteger("maxEssence", maxEssence);
	compound.setInteger("lastEntity", lastEntity);
	compound.setBoolean("missingPower", missingPower);
	
	compound.setTag("inv", this.slots.serializeNBT());
	compound.setTag("inv2", this.slotsPlayer.serializeNBT());
	
	NBTTagList list = new NBTTagList();
	for (int i = 0; i < this.discardSlots.length; i++)
	{
		list.appendTag(new NBTTagByte((byte) (this.discardSlots[i] ? 1 : 0)));
	}
	compound.setTag("discard", list);

	return compound;
}
 
Example #4
Source File: NBTStringHelper.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
public static String toString(NBTBase base) {
    switch (GuiNBTNode.NBT_ICON_MAPPING[base.getId() - 1]) {
        case 0: {
            return "(TagCompound)";
        }
        case 1: {
            return "" + ((NBTTagByte) base).func_150290_f();
        }
        case 2: {
            return "" + ((NBTTagShort) base).func_150289_e();
        }
        case 3: {
            return "" + ((NBTTagInt) base).func_150287_d();
        }
        case 4: {
            return "" + ((NBTTagLong) base).func_150291_c();
        }
        case 5: {
            return "" + ((NBTTagFloat) base).func_150288_h();
        }
        case 6: {
            return "" + ((NBTTagDouble) base).func_150286_g();
        }
        case 7: {
            return ((NBTTagString) base).func_150285_a_();
        }
        case 8: {
            return "(TagList)";
        }
        case 9: {
            return base.toString();
        }
        case 10: {
            return base.toString();
        }
    }
    return "?";
}
 
Example #5
Source File: NBTStringHelper.java    From NBTEdit with GNU General Public License v3.0 5 votes vote down vote up
public static String toString(NBTBase base) {
	switch(base.getId()) {
	case 1:
		return "" + ((NBTTagByte)base).func_150290_f();
	case 2:
		return "" + ((NBTTagShort)base).func_150289_e();
	case 3:
		return "" + ((NBTTagInt)base).func_150287_d();
	case 4:
		return "" + ((NBTTagLong)base).func_150291_c();
	case 5:
		return "" + ((NBTTagFloat)base).func_150288_h();
	case 6:
		return "" + ((NBTTagDouble)base).func_150286_g();
	case 7:
		return base.toString();
	case 8:
		return ((NBTTagString)base).func_150285_a_();
	case 9:
		return "(TagList)";
	case 10:
		return "(TagCompound)";
	case 11:
		return base.toString();
	default:
		return "?";
	}
}
 
Example #6
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 #7
Source File: MappingRegistry.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
private boolean isStackLayout(NBTTagCompound nbt) {
	return nbt.hasKey("id") &&
			nbt.hasKey("Count") &&
			nbt.hasKey("Damage") &&
			nbt.getTag("id") instanceof NBTTagShort &&
			nbt.getTag("Count") instanceof NBTTagByte &&
			nbt.getTag("Damage") instanceof NBTTagShort;
}
 
Example #8
Source File: GolemUpgrade.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void addUpgrade(NBTTagCompound compound) {
    NBTTagCompound upgrades = compound.getCompoundTag(UPGRADE_COMPOUND);
    if(!compound.hasKey(UPGRADE_COMPOUND)) {
        compound.setTag(UPGRADE_COMPOUND, upgrades);
    }

    NBTBase data = createUpgradeData();
    upgrades.setTag(getTagName(), data == null ? new NBTTagByte((byte)1) : data);
}
 
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: 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 #11
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 #12
Source File: CyberwareUserDataImpl.java    From Cyberware with MIT License 5 votes vote down vote up
@Override
public NBTTagCompound serializeNBT()
{
	NBTTagCompound compound = new NBTTagCompound();
	NBTTagList list = new NBTTagList();
	
	for (EnumSlot slot : EnumSlot.values())
	{
		NBTTagList list2 = new NBTTagList();
		for (ItemStack cyberware : getInstalledCyberware(slot))
		{
			NBTTagCompound temp = new NBTTagCompound();
			if (cyberware != null)
			{
				temp = cyberware.writeToNBT(temp);
			}
			list2.appendTag(temp);
		}
		list.appendTag(list2);
	}
	
	compound.setTag("cyberware", list);
	
	NBTTagList essentialList = new NBTTagList();
	for (int i = 0; i < this.missingEssentials.length; i++)
	{
		essentialList.appendTag(new NBTTagByte((byte) (this.missingEssentials[i] ? 1 : 0)));
	}
	compound.setTag("discard", essentialList);
	compound.setTag("powerBuffer", writeMap(this.powerBuffer));
	compound.setTag("powerBufferLast", writeMap(this.powerBufferLast));
	compound.setInteger("powerCap", this.powerCap);
	compound.setInteger("storedPower", this.storedPower);
	compound.setInteger("missingEssence", missingEssence);
	compound.setTag("hud", hudData);
	compound.setInteger("color", hudColor);
	compound.setBoolean("hasOpenedRadialMenu", hasOpenedRadialMenu);
	return compound;
}
 
Example #13
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 #14
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 #15
Source File: CyberwareUserDataImpl.java    From Cyberware with MIT License 4 votes vote down vote up
@Override
public void deserializeNBT(NBTTagCompound tag)
{
	powerBuffer = readMap((NBTTagList) tag.getTag("powerBuffer"));
	powerCap = tag.getInteger("powerCap");
	powerBufferLast = readMap((NBTTagList) tag.getTag("powerBufferLast"));

	storedPower = tag.getInteger("storedPower");
	if (tag.hasKey("essence"))
	{
		missingEssence = getMaxEssence() - tag.getInteger("essence");
	}
	else
	{
		missingEssence = tag.getInteger("missingEssence");
	}
	hudData = tag.getCompoundTag("hud");
	hasOpenedRadialMenu = tag.getBoolean("hasOpenedRadialMenu");
	NBTTagList essentialList = (NBTTagList) tag.getTag("discard");
	for (int i = 0; i < essentialList.tagCount(); i++)
	{
		this.missingEssentials[i] = ((NBTTagByte) essentialList.get(i)).getByte() > 0;
	}
	
	NBTTagList list = (NBTTagList) tag.getTag("cyberware");
	for (int i = 0; i < list.tagCount(); i++)
	{
		EnumSlot slot = EnumSlot.values()[i];
		
		NBTTagList list2 = (NBTTagList) list.get(i);
		ItemStack[] cyberware = new ItemStack[LibConstants.WARE_PER_SLOT];

		for (int j = 0; j < list2.tagCount() && j < cyberware.length; j++)
		{
			
			cyberware[j] = ItemStack.loadItemStackFromNBT(list2.getCompoundTagAt(j));
		}
		
		setInstalledCyberware(null, slot, cyberware);
	}
	
	int color = 0x00FFFF;

	if (tag.hasKey("color"))
	{
		color = tag.getInteger("color");
	}
	this.setHudColor(color);


	updateCapacity();
}
 
Example #16
Source File: SettingBoolean.java    From WearableBackpacks with MIT License 4 votes vote down vote up
@Override
public Boolean read(NBTBase tag) { return (((NBTTagByte)tag).getByte() != 0); }
 
Example #17
Source File: SettingBoolean.java    From WearableBackpacks with MIT License 4 votes vote down vote up
@Override
public NBTBase write(Boolean value) { return new NBTTagByte(value ? (byte)1 : (byte)0); }
 
Example #18
Source File: TypeRW.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public boolean checkTagType(NBTBase tag) {
	return tag instanceof NBTTagByte;
}
 
Example #19
Source File: TypeRW.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public boolean checkTagType(NBTBase tag) {
	return tag instanceof NBTTagByte;
}