use of net.minecraft.world.SimpleContainer in project MinecraftForge by MinecraftForge.
the class ContainerTypeTest method onRightClick.
private void onRightClick(PlayerInteractEvent.RightClickBlock event) {
if (!event.getWorld().isClientSide && event.getHand() == InteractionHand.MAIN_HAND) {
if (event.getWorld().getBlockState(event.getPos()).getBlock() == Blocks.SPONGE) {
String text = "Hello World!";
NetworkHooks.openGui((ServerPlayer) event.getPlayer(), new MenuProvider() {
@Override
public AbstractContainerMenu createMenu(int p_createMenu_1_, Inventory p_createMenu_2_, Player p_createMenu_3_) {
SimpleContainer inv = new SimpleContainer(9);
for (int i = 0; i < inv.getContainerSize(); i++) {
inv.setItem(i, new ItemStack(Items.DIAMOND));
}
return new TestContainer(p_createMenu_1_, inv, text);
}
@Override
public Component getDisplayName() {
return new TextComponent("Test");
}
}, extraData -> {
extraData.writeUtf(text);
});
}
}
}
Aggregations