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

x33g5p2x  于2022-01-30 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(149)

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

Slot.onSlotChanged介绍

暂无

代码示例

代码示例来源:origin: Vazkii/Botania

@Nonnull
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
  ItemStack itemstack = ItemStack.EMPTY;
  Slot slot = inventorySlots.get(slotIndex);
  if(slot != null && slot.getHasStack()) {
    ItemStack itemstack1 = slot.getStack();
    itemstack = itemstack1.copy();
    if(slotIndex < 16) {
      if(!mergeItemStack(itemstack1, 16, 52, true))
        return ItemStack.EMPTY;
    } else {
      int i = itemstack.getItemDamage();
      if(i < 16) {
        Slot slot1 = inventorySlots.get(i);
        if(slot1.isItemValid(itemstack) && !mergeItemStack(itemstack1, i, i + 1, true))
          return ItemStack.EMPTY;
      }
    }
    if(itemstack1.isEmpty())
      slot.putStack(ItemStack.EMPTY);
    else slot.onSlotChanged();
    if(itemstack1.getCount() == itemstack.getCount())
      return ItemStack.EMPTY;
    slot.onTake(player, itemstack1);
  }
  return itemstack;
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

@Override
  public void onSlotChanged() {
    super.onSlotChanged();
    if (!isOpening) {
      updateRecipes();
      updateSelectedRecipe();
    }
  }
};

代码示例来源:origin: Vazkii/Botania

@Nonnull
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
  ItemStack itemstack = ItemStack.EMPTY;
  Slot slot = inventorySlots.get(slotIndex);
  if(slot != null && slot.getHasStack()) {
    ItemStack itemstack1 = slot.getStack();
    itemstack = itemstack1.copy();
    int boxStart = 7;
    int boxEnd = boxStart + 24;
    int invEnd = boxEnd + 36;
    
    if(slotIndex < boxEnd) {
      if(!mergeItemStack(itemstack1, boxEnd, invEnd, true))
        return ItemStack.EMPTY;
    } else {
      if(!itemstack1.isEmpty() && (itemstack1.getItem() instanceof IBauble || itemstack1.getItem() instanceof IManaItem) && !mergeItemStack(itemstack1, boxStart, boxEnd, false))
        return ItemStack.EMPTY;
    }
    if(itemstack1.isEmpty())
      slot.putStack(ItemStack.EMPTY);
    else slot.onSlotChanged();
    if(itemstack1.getCount() == itemstack.getCount())
      return ItemStack.EMPTY;
    slot.onTake(player, itemstack1);
  }
  return itemstack;
}

代码示例来源:origin: Esteemed-Innovation/Esteemed-Innovation

@Override
  public void onSlotChanged() {
    ContainerSteamAnvil.this.onCraftMatrixChanged(hammer);
    super.onSlotChanged();
  }
});

代码示例来源:origin: Esteemed-Innovation/Esteemed-Innovation

@Override
  public void onSlotChanged() {
    ContainerSteamAnvil.this.onCraftMatrixChanged(hammer);
    super.onSlotChanged();
  }
});

代码示例来源:origin: SonarSonic/Calculator

@Override
  public void onSlotChanged() {
    super.onSlotChanged();
    locator.createOwner();
  }
}

代码示例来源:origin: WayofTime/BloodMagic

@Override
public void onSlotChanged() {
  super.onSlotChanged();
  container.resetItemInventory(getStack());
  for (int i = 1; i <= 9; i++) {
    Slot slot = container.getSlot(i);
    slot.onSlotChanged();
  }
}

代码示例来源:origin: OpenMods/OpenModsLib

@Override
  public void onSlotChanged() {
    super.onSlotChanged();
    // hackish, but required
    if (inventory instanceof GenericInventory) ((GenericInventory)inventory).onInventoryChanged(getSlotIndex());
  }
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

d.onSlotChanged();
  d.onSlotChanged();
d.onSlotChanged();

代码示例来源:origin: Chisel-Team/Chisel

@Override
  public void onSlotChanged() {
    super.onSlotChanged();
    container.onChiselSlotChanged();
    container.getInventoryChisel().updateItems();
  }
}

代码示例来源:origin: WayofTime/BloodMagic

@Override
public void onSlotChanged() {
  super.onSlotChanged();
  if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
    containerHolding.saveInventory(player);
  }
}

代码示例来源:origin: PrinceOfAmber/Cyclic

@Override
 public void onSlotChanged() {
  if (this.getHasStack() && this.getStack().getCount() == 0) {
   this.putStack((ItemStack) null);
  }
  super.onSlotChanged();
 }
}

代码示例来源:origin: vadis365/TheErebus

@Override
public ItemStack transferStackInSlot(EntityPlayer player, int par2) {
  ItemStack is = ItemStack.EMPTY;
  Slot slot = (Slot) inventorySlots.get(par2);
  if (slot != null && slot.getHasStack()) {
    ItemStack is1 = slot.getStack();
    is = is1.copy();
    if (par2 < 72) {
      if (!mergeItemStack(is1, 72, inventorySlots.size(), true))
        return ItemStack.EMPTY;
    } else if (!mergeItemStack(is1, 0, 72, false))
      return ItemStack.EMPTY;
    if (is1.getCount() == 0)
      slot.putStack(ItemStack.EMPTY);
    else
      slot.onSlotChanged();
  }
  return is;
}

代码示例来源:origin: ForestryMC/Binnie

private ItemStack shiftClick(final EntityPlayer player, final int slotnumber) {
  final TransferRequest request = this.getShiftClickRequest(player, slotnumber);
  TransferResult transferResult = request.transfer(player, true);
  if (transferResult.isSuccess()) {
    NonNullList<ItemStack> results = transferResult.getRemaining();
    if (results.size() == 1) {
      final ItemStack itemstack = results.get(0);
      final Slot shiftClickedSlot = this.inventorySlots.get(slotnumber);
      shiftClickedSlot.putStack(itemstack);
      shiftClickedSlot.onSlotChanged();
    }
  }
  return ItemStack.EMPTY;
}

代码示例来源:origin: SonarSonic/Calculator

@Override
public void onSlotChanged() {
  super.onSlotChanged();
  if (player != null) {
    /*
    int[] unblocked = entity.unblockedList();
    if (entity.isBlocked(entity.lastResearch) && entity.lastResearch != 0) {
      if (CalculatorRecipes.recipes().discovery(unblocked, entity.lastResearch)) {
        FontHelper.sendMessage(FontHelper.translate("research.recipeNew"), entity.getWorld(), player);
      }
    }
    */
    entity.markBlockForUpdate();
    entity.getWorld().addBlockEvent(entity.getPos(), entity.getBlockType(), 1, 0);
  }
}

代码示例来源:origin: CoFH/ThermalDynamics

@Override
public ItemStack slotClick(int slotId, int mouseButton, ClickType modifier, EntityPlayer player) {
  Slot slot = slotId < 0 ? null : this.inventorySlots.get(slotId);
  if (slot instanceof SlotFalseCopy) {
    if (mouseButton == 2) {
      slot.putStack(ItemStack.EMPTY);
      slot.onSlotChanged();
    } else {
      slot.putStack(player.inventory.getItemStack().isEmpty() ? ItemStack.EMPTY : player.inventory.getItemStack().copy());
    }
    return player.inventory.getItemStack();
  }
  return super.slotClick(slotId, mouseButton, modifier, player);
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int slotClickedIndex) {
  @Nonnull ItemStack slotStackCopy = ItemStack.EMPTY;
  Slot theSlot = this.getSlot(slotClickedIndex);
  if (theSlot != null && theSlot.getHasStack()) {
    @Nonnull ItemStack slotStack = theSlot.getStack();
    slotStackCopy = slotStack.copy();
    if (slotStack.getCount() == 0) {
      theSlot.putStack(ItemStack.EMPTY);
    } else {
      theSlot.onSlotChanged();
    }
    if (slotStack.getCount() == slotStackCopy.getCount()) {
      return ItemStack.EMPTY;
    }
    theSlot.onTake(par1EntityPlayer, slotStack);
  }
  return slotStackCopy;
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int slotClickedIndex) {
  Slot slot = this.getSlot(slotClickedIndex);
  if (slot == null || !slot.getHasStack()) {
    return ItemStack.EMPTY;
  }
  @Nonnull ItemStack stackFromSlot = slot.getStack();
  if (slotClickedIndex < tileEntitySlots) {
    this.mergeItemStack(stackFromSlot, tileEntitySlots, tileEntitySlots + playerSlots, false);
  } else {
    this.mergeItemStack(stackFromSlot, 0, tileEntitySlots, true);
  }
  if (stackFromSlot.getCount() == 0) {
    slot.putStack(ItemStack.EMPTY);
  } else {
    slot.onSlotChanged();
  }
  return ItemStack.EMPTY;
}

代码示例来源:origin: ForestryMC/ForestryMC

private static boolean shiftItemStackToRangeOpenSlots(List<Slot> inventorySlots, ItemStack stackToShift, int start, int count) {
  if (stackToShift.isEmpty()) {
    return false;
  }
  boolean changed = false;
  for (int slotIndex = start; !stackToShift.isEmpty() && slotIndex < start + count; slotIndex++) {
    Slot slot = inventorySlots.get(slotIndex);
    ItemStack stackInSlot = slot.getStack();
    if (stackInSlot.isEmpty()) {
      int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
      stackInSlot = stackToShift.copy();
      stackInSlot.setCount(Math.min(stackToShift.getCount(), max));
      stackToShift.shrink(stackInSlot.getCount());
      slot.putStack(stackInSlot);
      slot.onSlotChanged();
      changed = true;
    }
  }
  return changed;
}

代码示例来源:origin: SleepyTrousers/EnderIO

public boolean executeMoveItems(int fromSlot, int toSlotStart, int toSlotEnd, int amount) {
 if ((fromSlot >= toSlotStart && fromSlot < toSlotEnd) || toSlotEnd <= toSlotStart || amount <= 0) {
  return false;
 }
 Slot srcSlot = getSlot(fromSlot);
 ItemStack src = srcSlot.getStack();
 if (!src.isEmpty()) {
  ItemStack toMove = src.copy();
  toMove.setCount(Math.min(src.getCount(), amount));
  int remaining = src.getCount() - toMove.getCount();
  if (mergeItemStack(toMove, toSlotStart, toSlotEnd, false)) {
   remaining += toMove.getCount();
   if (remaining == 0) {
    srcSlot.putStack(ItemStack.EMPTY);
   } else {
    src.setCount(remaining);
    srcSlot.onSlotChanged();
   }
   return true;
  }
 }
 return false;
}

相关文章