net.minecraft.inventory.Container.getInventory()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中net.minecraft.inventory.Container.getInventory()方法的一些代码示例,展示了Container.getInventory()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Container.getInventory()方法的具体详情如下:
包路径:net.minecraft.inventory.Container
类名称:Container
方法名:getInventory

Container.getInventory介绍

暂无

代码示例

代码示例来源:origin: cabaletta/baritone

public void updateFromOpenWindow(IPlayerContext ctx) {
    items.clear();
    items.addAll(ctx.player().openContainer.getInventory().subList(0, size));
  }
}

代码示例来源:origin: raoulvdberge/refinedstorage

@Override
  protected void handle(MessageCrafterManagerRequestSlotData message, EntityPlayerMP player) {
    if (player.openContainer instanceof ContainerCrafterManager) {
      for (IContainerListener listener : ((ContainerCrafterManager) player.openContainer).getListeners()) {
        ContainerCrafterManager.CrafterManagerListener crafterCrafterManagerListener = (ContainerCrafterManager.CrafterManagerListener) listener;

        if (crafterCrafterManagerListener.getPlayer() == player) {
          crafterCrafterManagerListener.setReceivedContainerData();
          crafterCrafterManagerListener.sendAllContents(player.openContainer, player.openContainer.getInventory());
        }
      }
    }
  }
}

代码示例来源:origin: ExtraCells/ExtraCells2

public GuiBusFluidStorage(PartFluidStorage part, EntityPlayer _player) {
  super(new ResourceLocation("extracells", "textures/gui/storagebusfluid.png"), new ContainerBusFluidStorage(part, _player));
  this.part = part;
  container.setGui(this);
  this.player = _player;
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 6; j++) {
      WidgetFluidSlot fluidSlot = new WidgetFluidSlot(widgetManager, this.part, i * 6 + j, 18 * i + 7, 18 * j + 17);
      fluidSlotList.add(fluidSlot);
      widgetManager.add(fluidSlot);
    }
  }
  NetworkUtil.sendToServer(new PacketPartConfig(this.part, PacketPartConfig.FLUID_STORAGE_INFO));
  this.hasNetworkTool = this.inventorySlots.getInventory().size() > 40;
  this.xSize = this.hasNetworkTool ? 246 : 211;
  this.ySize = 222;
}

代码示例来源:origin: ldtteam/minecolonies

@Override
protected void mouseClicked(final int mouseX, final int mouseY, final int mouseButton) throws IOException
{
  super.mouseClicked(mouseX, mouseY, mouseButton);
  if (building.canRecipeBeAdded() && doneButton.isMouseOver())
  {
    final List<ItemStack> input = new ArrayList<>();
    input.add(inventorySlots.getInventory().get(0));
    final ItemStack primaryOutput =  inventorySlots.getSlot(1).getStack().copy();
    if(!ItemStackUtils.isEmpty(primaryOutput))
    {
      MineColonies.getNetwork().sendToServer(new AddRemoveRecipeMessage(input, 1, primaryOutput, building, false));
    }
  }
}

代码示例来源:origin: ExtraCells/ExtraCells2

public GuiBusFluidIO(PartFluidIO terminal, EntityPlayer player) {
  super(new ResourceLocation("extracells", "textures/gui/busiofluid.png"), new ContainerBusFluidIO(terminal, player));
  ((ContainerBusFluidIO) this.inventorySlots).setGui(this);
  this.part = terminal;
  for (int x = 0; x < 3; x++) {
    for (int y = 0; y < 3; y++) {
      int id = y + x * 3;
      byte configOption = (byte) (((id + 1) % 2) + 1);
      if (id == 4) {
        configOption = 0;
      }
      WidgetFluidSlot fluidSlot = new WidgetFluidSlot(widgetManager, part, id, 61 + x * 18, 21 + y * 18, this, configOption);
      widgetManager.add(fluidSlot);
      fluidSlotList.add(fluidSlot);
    }
  }
  NetworkUtil.sendToServer(new PacketPartConfig(part, PacketPartConfig.FLUID_IO_INFO));
  this.hasNetworkTool = this.inventorySlots.getInventory().size() > 40;
  this.xSize = this.hasNetworkTool ? 246 : 211;
  this.ySize = 184;
}

代码示例来源:origin: cabaletta/baritone

private void updateInventory() {
  int windowId = ctx.player().openContainer.windowId;
  if (enderChestWindowId != null) {
    if (windowId == enderChestWindowId) {
      getCurrent().contents = ctx.player().openContainer.getInventory().subList(0, 27);
    } else {
      getCurrent().save();
      enderChestWindowId = null;
    }
  }
  if (getCurrentContainer() != null) {
    getCurrentContainer().getInventoryFromWindow(windowId).ifPresent(inventory -> inventory.updateFromOpenWindow(ctx));
  }
}

代码示例来源:origin: ExtraCells/ExtraCells2

public GuiFluidPlaneFormation(PartFluidPlaneFormation _part,
  EntityPlayer _player) {
  super(new ResourceLocation("extracells", "textures/gui/paneformation.png"), new ContainerPlaneFormation(_part, _player));
  ((ContainerPlaneFormation) this.inventorySlots).setGui(this);
  this.part = _part;
  this.player = _player;
  widgetManager.add(fluidSlot = new WidgetFluidSlot(widgetManager, this.part, 0, 79, 39));
  NetworkUtil.sendToPlayer(new PacketPartConfig(part, PacketPartConfig.FLUID_PLANE_FORMATION_INFO), player);
  this.hasNetworkTool = this.inventorySlots.getInventory().size() > 40;
  this.xSize = this.hasNetworkTool ? 246 : 211;
  this.ySize = 184;
}

代码示例来源:origin: ldtteam/minecolonies

@Override
protected void mouseClicked(final int mouseX, final int mouseY, final int mouseButton) throws IOException
{
  super.mouseClicked(mouseX, mouseY, mouseButton);
  if (building.canRecipeBeAdded() && doneButton.isMouseOver())
  {
    final List<ItemStack> input = new LinkedList<>();
    for(int i = 1; i <= (completeCrafting ? MAX_CRAFTING_GRID_SIZE : CRAFTING_GRID_SIZE); i++)
    {
      final ItemStack stack = inventorySlots.getInventory().get(i);
      final ItemStack copy = stack.copy();
      ItemStackUtils.setSize(copy, 1);
      input.add(copy);
    }
    final ItemStack primaryOutput =  inventorySlots.getSlot(0).getStack().copy();
    if(!ItemStackUtils.isEmpty(primaryOutput))
    {
      MineColonies.getNetwork().sendToServer(new AddRemoveRecipeMessage(input, completeCrafting ? 3 : 2, primaryOutput, building, false));
    }
  }
}

相关文章