use of net.minecraft.server.v1_8_R3.Container in project Denizen-For-Bukkit by DenizenScript.
the class PacketOutTradeList_v1_8_R3 method setTradeOffers.
@Override
public void setTradeOffers(List<TradeOffer> tradeOffers) {
try {
PacketDataSerializer serializer = new PacketDataSerializer(Unpooled.buffer());
serializer.a("MC|TrList");
serializer.writeInt(container);
serializer.writeByte((byte) (tradeOffers.size() & 255));
for (TradeOffer tradeOffer : tradeOffers) {
serializer.a(CraftItemStack.asNMSCopy(tradeOffer.getFirstCost()));
serializer.a(CraftItemStack.asNMSCopy(tradeOffer.getProduct()));
boolean hasSecondCost = tradeOffer.hasSecondCost();
serializer.writeBoolean(hasSecondCost);
if (hasSecondCost) {
serializer.a(CraftItemStack.asNMSCopy(tradeOffer.getSecondCost()));
}
serializer.writeBoolean(tradeOffer.isUsedMaxTimes());
serializer.writeInt(tradeOffer.getCurrentUses());
serializer.writeInt(tradeOffer.getMaxUses());
}
internal.a(serializer);
} catch (Exception e) {
e.printStackTrace();
}
}
use of net.minecraft.server.v1_8_R3.Container in project WildChests by BG-Software-LLC.
the class NMSInventory_v1_12_R1 method openPage.
@Override
public void openPage(Player player, com.bgsoftware.wildchests.objects.inventory.CraftWildInventory inventory) {
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
String title = inventory.getTitle();
Container container = createContainer(entityPlayer.inventory, entityPlayer, inventory);
container.windowId = entityPlayer.nextContainerCounter();
TileEntityWildChest tileEntityWildChest = getTileEntity(inventory.getOwner());
entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, tileEntityWildChest.getContainerName(), new ChatComponentText(title), inventory.getSize()));
entityPlayer.activeContainer = container;
entityPlayer.activeContainer.addSlotListener(entityPlayer);
}
use of net.minecraft.server.v1_8_R3.Container in project WildChests by BG-Software-LLC.
the class NMSInventory_v1_8_R3 method openPage.
@Override
public void openPage(Player player, com.bgsoftware.wildchests.objects.inventory.CraftWildInventory inventory) {
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
String title = inventory.getTitle();
Container container = createContainer(entityPlayer.inventory, entityPlayer, inventory);
container.windowId = entityPlayer.nextContainerCounter();
TileEntityWildChest tileEntityWildChest = getTileEntity(inventory.getOwner());
entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, tileEntityWildChest.getContainerName(), new ChatComponentText(title), inventory.getSize()));
entityPlayer.activeContainer = container;
entityPlayer.activeContainer.addSlotListener(entityPlayer);
}
use of net.minecraft.server.v1_8_R3.Container in project mdsal by opendaylight.
the class Mdsal298Test method testUnkeyedDataTreeModification.
@Test
public void testUnkeyedDataTreeModification() throws InterruptedException, ExecutionException {
final DataTreeChangeListener<Container> listener = assertWrittenContainer(Container.QNAME, Container.class, new ContainerBuilder().build());
final DOMDataTreeWriteTransaction domTx = getDomBroker().newWriteOnlyTransaction();
domTx.put(CONFIGURATION, YangInstanceIdentifier.create(CONTAINER_NID).node(Unkeyed.QNAME), Builders.unkeyedListBuilder().withNodeIdentifier(new NodeIdentifier(Unkeyed.QNAME)).withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(new NodeIdentifier(Unkeyed.QNAME)).addChild(ImmutableNodes.leafNode(FOO_QNAME, "foo")).build()).withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(new NodeIdentifier(Unkeyed.QNAME)).addChild(ImmutableNodes.leafNode(FOO_QNAME, "bar")).build()).build());
domTx.commit().get();
final ArgumentCaptor<Collection> captor = ArgumentCaptor.forClass(Collection.class);
verify(listener).onDataTreeChanged(captor.capture());
Collection<DataTreeModification<Container>> capture = captor.getValue();
assertEquals(1, capture.size());
final DataTreeModification<Container> change = capture.iterator().next();
assertEquals(CONTAINER_TID, change.getRootPath());
final DataObjectModification<Container> changedContainer = change.getRootNode();
assertEquals(Item.of(Container.class), changedContainer.getIdentifier());
assertEquals(ModificationType.WRITE, changedContainer.getModificationType());
final Container containerAfter = changedContainer.getDataAfter();
assertEquals(new ContainerBuilder().setUnkeyed(List.of(new UnkeyedBuilder().setFoo("foo").build(), new UnkeyedBuilder().setFoo("bar").build())).build(), containerAfter);
final Collection<? extends DataObjectModification<?>> changedChildren = changedContainer.getModifiedChildren();
assertEquals(0, changedChildren.size());
}
use of net.minecraft.server.v1_8_R3.Container in project mdsal by opendaylight.
the class TestListSquashing method testEmptyUserOrderedList.
@Test
public void testEmptyUserOrderedList() {
final Container cont = new ContainerBuilder().setKeyed(List.of()).setUnkeyed(List.of()).build();
// Empty Lists should become null
assertNull(cont.getKeyed());
assertNull(cont.getUnkeyed());
}
Aggregations