Java Code Examples for net.minecraft.nbt.NBTTagCompound#setShort()

The following examples show how to use net.minecraft.nbt.NBTTagCompound#setShort() . 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: ItemLantern.java    From GardenCollection with MIT License 6 votes vote down vote up
public ItemStack makeItemStack (int count, int meta, boolean hasGlass, String source, int sourceMeta) {
    ItemStack stack = new ItemStack(this, count, meta);
    NBTTagCompound tag = new NBTTagCompound();

    if (hasGlass)
        tag.setBoolean("glass", true);

    if (source != null)
        tag.setString("src", source);

    if (sourceMeta != 0)
        tag.setShort("srcMeta", (short)sourceMeta);

    if (!tag.hasNoTags())
        stack.setTagCompound(tag);

    return stack;
}
 
Example 2
Source File: TileEntityEnderFurnace.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt)
{
    super.writeToNBT(nbt);

    byte flags = 0;

    if (this.fastMode)
    {
        flags |= 0x01;
    }
    if (this.outputToEnderChest)
    {
        flags |= 0x02;
    }

    nbt.setByte("Flags", flags);
    nbt.setShort("BurnTimeRemaining", (short)this.burnTimeRemaining);
    nbt.setShort("BurnTimeFresh", (short)this.burnTimeFresh);
    nbt.setShort("CookTime", (short)this.cookTime);

    return nbt;
}
 
Example 3
Source File: SchematicaSchematic.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void writePaletteToTag(NBTTagCompound nbt)
{
    NBTTagCompound tag = new NBTTagCompound();

    for (int i = 0; i < this.palette.length; ++i)
    {
        Block block = this.palette[i];

        if (block != null)
        {
            ResourceLocation rl = Block.REGISTRY.getNameForObject(block);

            if (rl != null)
            {
                tag.setShort(rl.toString(), (short) (i & 0xFFF));
            }
        }
    }

    nbt.setTag("SchematicaMapping", tag);
}
 
Example 4
Source File: WrathSpawnerLogic.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
    par1NBTTagCompound.setString("EntityId", this.getEntityNameToSpawn());
    par1NBTTagCompound.setBoolean("MobSet", mobSet);
    par1NBTTagCompound.setBoolean("Slothful", slothful);
    par1NBTTagCompound.setShort("Fuel", (short) this.fuel);
    par1NBTTagCompound.setShort("Delay", (short) this.spawnDelay);
    // par1NBTTagCompound.setShort("MinSpawnDelay",
    // (short)this.minSpawnDelay);
    // par1NBTTagCompound.setShort("MaxSpawnDelay",
    // (short)this.maxSpawnDelay);
    // par1NBTTagCompound.setShort("SpawnCount", (short)this.spawnCount);
    par1NBTTagCompound.setShort("MaxNearbyEntities", (short) this.maxNearbyEntities);
    par1NBTTagCompound.setShort("SpawnRange", (short) this.spawnRange);

}
 
Example 5
Source File: TileEntityWrathCage.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
@Override
/**
 * Writes a tile entity to NBT.
 */
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
    super.writeToNBT(par1NBTTagCompound);
    this.spawnLogic.writeToNBT(par1NBTTagCompound);
    par1NBTTagCompound.setShort("Wrath", (short)this.wrath);
    par1NBTTagCompound.setShort("Sloth", (short)this.sloth);
    par1NBTTagCompound.setShort("Special", (short)this.special);
    par1NBTTagCompound.setByte("Mode", this.mode);
}
 
Example 6
Source File: EntityLaser.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
    par1NBTTagCompound.setShort("xTile", (short) this.xTile);
    par1NBTTagCompound.setShort("yTile", (short) this.yTile);
    par1NBTTagCompound.setShort("zTile", (short) this.zTile);
    par1NBTTagCompound.setByte("inTile", (byte) Block.getIdFromBlock(this.inTile));
    par1NBTTagCompound.setByte("inData", (byte) this.inData);
    par1NBTTagCompound.setByte("inGround", (byte) (this.inGround ? 1 : 0));
}
 
Example 7
Source File: TileGuidanceComputerHatch.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void readDataFromNetwork(ByteBuf in, byte packetId,
		NBTTagCompound nbt) {
	if(packetId == redstoneState)
		nbt.setByte("state", in.readByte());
	else {

		nbt.setShort("status", in.readShort());

	}
}
 
Example 8
Source File: DataConverter.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Saves an unknown object to NBT
 * @param tag - NBTTagCompound to queueSave the tag too
 * @param key - name to queueSave the object as
 * @param value - the actual object
 * @return the tag when done saving too i
 */
public NBTTagCompound save(NBTTagCompound tag, String key, Object value) {
	if (value instanceof Boolean) {
		tag.setBoolean(key + "::nova.isBoolean", true);
		tag.setBoolean(key, (boolean) value);
	} else if (value instanceof Byte) {
		tag.setBoolean(key + "::nova.isBoolean", false);
		tag.setByte(key, (byte) value);
	} else if (value instanceof Short) {
		tag.setShort(key, (short) value);
	} else if (value instanceof Integer) {
		tag.setInteger(key, (int) value);
	} else if (value instanceof Long) {
		tag.setLong(key, (long) value);
	} else if (value instanceof Character) {
		tag.setInteger(key, (Character) value);
	} else if (value instanceof Float) {
		tag.setFloat(key, (float) value);
	} else if (value instanceof Double) {
		tag.setDouble(key, (double) value);
	} else if (value instanceof BigInteger) {
		tag.setBoolean(key + "::nova.isBigInteger", true);
		tag.setString(key, ((BigInteger) value).toString());
	} else if (value instanceof BigDecimal) {
		tag.setBoolean(key + "::nova.isBigDecimal", true);
		tag.setString(key, ((BigDecimal) value).toString());
	} else if (value instanceof String) {
		tag.setString(key, (String) value);
	} else if (value instanceof Data) {
		NBTTagCompound innerTag = new NBTTagCompound();
		toNative(innerTag, (Data) value);
		tag.setTag(key, innerTag);
	}
	return tag;
}
 
Example 9
Source File: EntityREP.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public void writeEntityToNBT(NBTTagCompound tag) {
    tag.setShort("xTile", (short) xTileREP);
    tag.setShort("yTile", (short) yTileREP);
    tag.setShort("zTile", (short) zTileREP);
    tag.setShort("inTile", (short) Block.getIdFromBlock(inTileREP));
    tag.setByte("shake", (byte) shakeREP);
    tag.setByte("inGround", (byte) (inGroundREP ? 1 : 0));
}
 
Example 10
Source File: MCNetworkRail.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void writeToNBT(NBTTagCompound tag){
    getPos().writeToNBT(tag);
    tag.setByte("c", (byte)curDir.ordinal());
    if(railType != null) {
        tag.setString("t", railType);
        tag.setShort("r", EnumSetUtils.toShort(validRailDirs));
    }
}
 
Example 11
Source File: EntityWirelessTracker.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public void writeEntityToNBT(NBTTagCompound nbttagcompound)
{        
    nbttagcompound.setBoolean("attached", attached);
    nbttagcompound.setShort("attachCount", (short) attachmentCounter);
    nbttagcompound.setBoolean("item", item);
    nbttagcompound.setShort("freq", (short) freq);
    if(attachedPlayerName != null)
    {
        nbttagcompound.setString("player", attachedPlayerName);
        nbttagcompound.setFloat("attachedX", attachedX);
        nbttagcompound.setFloat("attachedY", attachedY);
        nbttagcompound.setFloat("attachedZ", attachedZ);
        nbttagcompound.setFloat("attachedYaw", attachedYaw);
    }
}
 
Example 12
Source File: EntityItemAbducted.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
public void writeEntityToNBT(NBTTagCompound p_70014_1_)
{
    p_70014_1_.setShort("Age", (short)this.age);
    p_70014_1_.setInteger("Lifespan", lifespan);


    if (this.getEntityItem() != null)
    {
        p_70014_1_.setTag("Item", this.getEntityItem().writeToNBT(new NBTTagCompound()));
    }
}
 
Example 13
Source File: TileEntityCreationStation.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void writeModeMaskToModule()
{
    // Cache the value locally, because taking out the memory card will trigger an update that will overwrite the
    // value stored in the field in the TE.
    int modeMask = this.modeMask;
    ItemStack stack = this.itemHandlerMemoryCards.extractItem(this.selectedModule, 1, false);

    if (stack.isEmpty() == false)
    {
        // Furnace modes are stored in the TileEntity itself, other modes are on the modules
        NBTTagCompound tag = NBTUtils.getCompoundTag(stack, null, "CreationStation", true);
        tag.setShort("ConfigMask", (short) (modeMask & ~(MODE_BIT_LEFT_FAST | MODE_BIT_RIGHT_FAST)));
        this.itemHandlerMemoryCards.insertItem(this.selectedModule, stack, false);
    }
}
 
Example 14
Source File: ItemBuildersWand.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void setSelectedFixedBlockType(NBTTagCompound tag, EntityPlayer player, World world, BlockPos pos)
{
    IBlockState state = world.getBlockState(pos);
    tag.setString("BlockName", ForgeRegistries.BLOCKS.getKey(state.getBlock()).toString());
    tag.setByte("BlockMeta", (byte)state.getBlock().getMetaFromState(state));

    ItemStack stackTmp = state.getBlock().getPickBlock(state, EntityUtils.getRayTraceFromPlayer(world, player, false), world, pos, player);
    int itemMeta = stackTmp.isEmpty() == false ? stackTmp.getMetadata() : 0;

    tag.setShort("ItemMeta", (short)itemMeta);
}
 
Example 15
Source File: EntitySpecialArrow.java    From Artifacts with MIT License 5 votes vote down vote up
public void writeEntityToNBT(NBTTagCompound tag)
{
	super.writeEntityToNBT(tag);
	tag.setShort("xTile", (short)this.xTile);
	tag.setShort("yTile", (short)this.yTile);
	tag.setShort("zTile", (short)this.zTile);
       tag.setByte("inTile", (byte)Block.getIdFromBlock(this.inTile));
	tag.setByte("inData", (byte)this.inData);
	tag.setByte("inGround", (byte)(this.inGround ? 1 : 0));
	tag.setByte("effect", this.effect.ID);
}
 
Example 16
Source File: TileEntityLargePot.java    From GardenCollection with MIT License 5 votes vote down vote up
@Override
public void writeToNBT (NBTTagCompound tag) {
    super.writeToNBT(tag);

    if (carving != 0)
        tag.setShort("Carv", (short) carving);
}
 
Example 17
Source File: EntityGnome.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void writeEntityToNBT(NBTTagCompound nbt)
{
	super.writeEntityToNBT(nbt);
	
	// Write id+data of carried block to NBT

       IBlockState state = this.getCarried();

       if (state != null)
       {
           nbt.setShort("carried", (short)Block.getIdFromBlock(state.getBlock()));
           nbt.setShort("carriedData", (short)state.getBlock().getMetaFromState(state));
       }
}
 
Example 18
Source File: Label.java    From Minecoprocessors with GNU General Public License v3.0 4 votes vote down vote up
public NBTTagCompound toNbt() {
  NBTTagCompound c = new NBTTagCompound();
  c.setShort(NBT_ADDRESS, address);
  c.setString(NBT_NAME, name);
  return c;
}
 
Example 19
Source File: SyncableShort.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void writeToNBT(NBTTagCompound tag, String name) {
	tag.setShort(name, value);
}
 
Example 20
Source File: SyncableFlags.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void writeToNBT(NBTTagCompound tag, String name) {
	tag.setShort(name, (short)value);
}