Search in sources :

Example 21 with CommonTagCompound

use of com.bergerkiller.bukkit.common.nbt.CommonTagCompound in project BKCommonLib by bergerhealer.

the class PacketTest method testBlockStateChangePacket.

@Test
public void testBlockStateChangePacket() {
    CommonTagCompound metadata = new CommonTagCompound();
    metadata.putValue("Text1", "a");
    metadata.putValue("Text2", "b");
    metadata.putValue("Text3", "c");
    metadata.putValue("Text4", "d");
    PacketPlayOutTileEntityDataHandle packet = PacketPlayOutTileEntityDataHandle.createNew(IntVector3.of(1, 2, 3), BlockStateType.SIGN, metadata.clone());
    assertEquals(IntVector3.of(1, 2, 3), packet.getPosition());
    assertEquals(BlockStateType.SIGN, packet.getType());
    assertEquals(metadata, packet.getData());
}
Also used : PacketPlayOutTileEntityDataHandle(com.bergerkiller.generated.net.minecraft.network.protocol.game.PacketPlayOutTileEntityDataHandle) CommonTagCompound(com.bergerkiller.bukkit.common.nbt.CommonTagCompound) Test(org.junit.Test)

Example 22 with CommonTagCompound

use of com.bergerkiller.bukkit.common.nbt.CommonTagCompound in project BKCommonLib by bergerhealer.

the class ItemMaterialTest method testItemTag.

@Test
public void testItemTag() {
    ItemStack item = ItemUtil.createItem(getFirst("OAK_PLANKS", "LEGACY_WOOD"), 1);
    assertNull(ItemUtil.getMetaTag(item));
    CommonTagCompound tag = ItemUtil.getMetaTag(item, true);
    assertNotNull(tag);
    tag.putValue("test", "awesome!");
    tag = ItemUtil.getMetaTag(item);
    assertNotNull(tag);
    assertTrue(tag.containsKey("test"));
    assertEquals("awesome!", tag.getValue("test"));
}
Also used : CommonTagCompound(com.bergerkiller.bukkit.common.nbt.CommonTagCompound) ItemStack(org.bukkit.inventory.ItemStack) Test(org.junit.Test)

Aggregations

CommonTagCompound (com.bergerkiller.bukkit.common.nbt.CommonTagCompound)22 ItemStack (org.bukkit.inventory.ItemStack)4 Test (org.junit.Test)4 IntVector3 (com.bergerkiller.bukkit.common.bases.IntVector3)2 MapUUID (com.bergerkiller.bukkit.common.map.util.MapUUID)2 PacketPlayOutTileEntityDataHandle (com.bergerkiller.generated.net.minecraft.network.protocol.game.PacketPlayOutTileEntityDataHandle)2 UUID (java.util.UUID)2 MapDisplay (com.bergerkiller.bukkit.common.map.MapDisplay)1 MapSession (com.bergerkiller.bukkit.common.map.MapSession)1 CommonTagList (com.bergerkiller.bukkit.common.nbt.CommonTagList)1 BlockStateType (com.bergerkiller.bukkit.common.resources.BlockStateType)1 BlockRenderOptions (com.bergerkiller.bukkit.common.wrappers.BlockRenderOptions)1 BlockStateChange (com.bergerkiller.bukkit.common.wrappers.BlockStateChange)1 ChatText (com.bergerkiller.bukkit.common.wrappers.ChatText)1 ItemRenderOptions (com.bergerkiller.bukkit.common.wrappers.ItemRenderOptions)1 ClientboundLevelChunkPacketDataHandle (com.bergerkiller.generated.net.minecraft.network.protocol.game.ClientboundLevelChunkPacketDataHandle)1 PacketPlayOutMapChunkHandle (com.bergerkiller.generated.net.minecraft.network.protocol.game.PacketPlayOutMapChunkHandle)1 PacketPlayOutUpdateSignHandle (com.bergerkiller.generated.net.minecraft.network.protocol.game.PacketPlayOutUpdateSignHandle)1 File (java.io.File)1 HashSet (java.util.HashSet)1