use of net.minecraft.server.v1_11_R1.Container in project flytekit-java by flyteorg.
the class ProtoUtilTest method shouldAcceptResourcesWithValidQuantities.
@ParameterizedTest
@ValueSource(strings = { "4", "2.3", "+1", "2Ki", "4m", "5e-3", "3E6" })
void shouldAcceptResourcesWithValidQuantities(String quantity) {
Container container = createContainer(Resources.builder().limits(ImmutableMap.of(Resources.ResourceName.CPU, quantity)).build());
Tasks.Container actual = ProtoUtil.serialize(container);
assertThat(actual, equalTo(Tasks.Container.newBuilder().setImage("busybox").addCommand("bash").addAllArgs(asList("-c", "echo", "hello")).setResources(Tasks.Resources.newBuilder().addLimits(Tasks.Resources.ResourceEntry.newBuilder().setName(Tasks.Resources.ResourceName.CPU).setValue(quantity).build()).build()).build()));
}
use of net.minecraft.server.v1_11_R1.Container in project flytekit-java by flyteorg.
the class ProtoUtil method serialize.
@VisibleForTesting
static Tasks.Container serialize(Container container) {
Tasks.Container.Builder builder = Tasks.Container.newBuilder().setImage(container.image()).addAllCommand(container.command()).addAllArgs(container.args());
container.env().forEach(pair -> builder.addEnv(serialize(pair)));
Resources resources = container.resources();
if (resources != null) {
builder.setResources(serialize(resources));
}
return builder.build();
}
use of net.minecraft.server.v1_11_R1.Container in project TheAPI by TheDevTec.
the class v1_10_R1 method openGUI.
@Override
public void openGUI(Player player, Object container, String legacy, int size, String title, ItemStack[] items) {
EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
int id = ((Container) container).windowId;
net.minecraft.server.v1_10_R1.ItemStack[] nmsItems = new net.minecraft.server.v1_10_R1.ItemStack[items.length];
for (int i = 0; i < items.length; ++i) {
ItemStack is = items[i];
if (is == null || is.getType() == Material.AIR)
continue;
net.minecraft.server.v1_10_R1.ItemStack item = null;
((Container) container).setItem(i, item = (net.minecraft.server.v1_10_R1.ItemStack) asNMSItem(is));
nmsItems[i] = item;
}
BukkitLoader.getPacketHandler().send(player, packetOpenWindow(id, legacy, size, title));
int i = 0;
for (net.minecraft.server.v1_10_R1.ItemStack o : nmsItems) BukkitLoader.getPacketHandler().send(player, packetSetSlot(id, i++, o));
nmsPlayer.activeContainer.transferTo((Container) container, (CraftPlayer) player);
nmsPlayer.activeContainer = (Container) container;
((Container) container).addSlotListener(nmsPlayer);
((Container) container).checkReachable = false;
}
use of net.minecraft.server.v1_11_R1.Container in project TheAPI by TheDevTec.
the class v1_10_R1 method closeGUI.
@Override
public void closeGUI(Player player, Object container, boolean closePacket) {
if (closePacket) {
BukkitLoader.getPacketHandler().send(player, new PacketPlayOutCloseWindow(getContainerId(container)));
}
EntityPlayer nmsPlayer = (EntityPlayer) getPlayer(player);
nmsPlayer.activeContainer = nmsPlayer.defaultContainer;
((Container) container).transferTo(nmsPlayer.activeContainer, (CraftPlayer) player);
}
use of net.minecraft.server.v1_11_R1.Container in project TheAPI by TheDevTec.
the class v1_10_R1 method openAnvilGUI.
@Override
public void openAnvilGUI(Player player, Object con, String title, ItemStack[] items) {
ContainerAnvil container = (ContainerAnvil) con;
EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
int id = container.windowId;
net.minecraft.server.v1_10_R1.ItemStack[] nmsItems = new net.minecraft.server.v1_10_R1.ItemStack[items.length];
for (int i = 0; i < items.length; ++i) {
ItemStack is = items[i];
if (is == null || is.getType() == Material.AIR)
continue;
net.minecraft.server.v1_10_R1.ItemStack item = null;
container.setItem(i, item = (net.minecraft.server.v1_10_R1.ItemStack) asNMSItem(is));
nmsItems[i] = item;
}
BukkitLoader.getPacketHandler().send(player, packetOpenWindow(id, "minecraft:anvil", 0, title));
int i = 0;
for (net.minecraft.server.v1_10_R1.ItemStack o : nmsItems) BukkitLoader.getPacketHandler().send(player, packetSetSlot(id, i++, o));
nmsPlayer.activeContainer.transferTo((Container) container, (CraftPlayer) player);
nmsPlayer.activeContainer = (Container) container;
((Container) container).addSlotListener(nmsPlayer);
container.checkReachable = false;
}
Aggregations