本文整理汇总了Java中net.minecraft.inventory.Slot.getStack方法的典型用法代码示例。如果您正苦于以下问题:Java Slot.getStack方法的具体用法?Java Slot.getStack怎么用?Java Slot.getStack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.inventory.Slot
的用法示例。
在下文中一共展示了Slot.getStack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
/**
* Take a stack from the specified inventory slot.
*/
@Override
@Nullable
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
ItemStack itemstack = ItemStack.EMPTY;
Slot slot = this.inventorySlots.get(index);
if (slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (index == 0) {
if (!this.mergeItemStack(itemstack1, 1, 28, true))
return ItemStack.EMPTY;
slot.onSlotChange(itemstack1, itemstack);
} else if (index >= 1 && index < 28) {
if (!this.mergeItemStack(itemstack1, 0, 1, false))
return ItemStack.EMPTY;
} else if (!this.mergeItemStack(itemstack1, 1, 28, false))
return ItemStack.EMPTY;
if (itemstack1.isEmpty())
slot.putStack(ItemStack.EMPTY);
else
slot.onSlotChanged();
if (itemstack1.getCount() ==itemstack.getCount())
return ItemStack.EMPTY;
slot.onTake(playerIn, itemstack1);
}
return itemstack;
}
示例2: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
{
ItemStack newStack = null;
Slot slot = (Slot)this.inventorySlots.get(index);
if (slot != null && slot.getHasStack())
{
ItemStack containedStack = slot.getStack();
newStack = containedStack.copy();
if (index < TileEntityWickerBasket.INV_SIZE)
{
if (!this.mergeItemStack(containedStack, TileEntityWickerBasket.INV_SIZE, this.inventorySlots.size(), true))
{
return null;
}
}
else if (!this.mergeItemStack(containedStack, 0, TileEntityWickerBasket.INV_SIZE, false))
{
return null;
}
if (containedStack.getCount() == 0)
{
slot.putStack((ItemStack)null);
}
else
{
slot.onSlotChanged();
}
}
return newStack;
}
示例3: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
@Nonnull
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
Slot srcSlot = inventorySlots.get(slot);
if (srcSlot == null || !srcSlot.getHasStack()) {
return ItemStack.EMPTY;
}
ItemStack srcStack = srcSlot.getStack();
ItemStack copyOfSrcStack = srcStack.copy();
if (slot < playerSlotsStart) {
if (!mergeItemStack(srcStack, playerSlotsStart, playerSlotsStart + 36, false))
return ItemStack.EMPTY;
} else {
if (!mergeItemStack(srcStack, 0, playerSlotsStart, false))
return ItemStack.EMPTY;
}
srcSlot.onSlotChange(srcStack, copyOfSrcStack);
if (srcStack.isEmpty()) {
srcSlot.putStack(ItemStack.EMPTY);
} else {
srcSlot.onSlotChanged();
}
srcSlot.onTake(player, srcStack);
return copyOfSrcStack;
}
示例4: updateDragSplitting
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
private void updateDragSplitting()
{
ItemStack itemstack = this.mc.player.inventory.getItemStack();
if (!itemstack.func_190926_b() && this.dragSplitting)
{
if (this.dragSplittingLimit == 2)
{
this.dragSplittingRemnant = itemstack.getMaxStackSize();
}
else
{
this.dragSplittingRemnant = itemstack.func_190916_E();
for (Slot slot : this.dragSplittingSlots)
{
ItemStack itemstack1 = itemstack.copy();
ItemStack itemstack2 = slot.getStack();
int i = itemstack2.func_190926_b() ? 0 : itemstack2.func_190916_E();
Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack1, i);
int j = Math.min(itemstack1.getMaxStackSize(), slot.getItemStackLimit(itemstack1));
if (itemstack1.func_190916_E() > j)
{
itemstack1.func_190920_e(j);
}
this.dragSplittingRemnant -= itemstack1.func_190916_E() - i;
}
}
}
}
示例5: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int fromSlot)
{
ItemStack previous = null;
Slot slot = (Slot) this.inventorySlots.get(fromSlot);
if (slot != null && slot.getHasStack())
{
ItemStack current = slot.getStack();
previous = current.copy();
// Custom behaviour //
if (fromSlot < 3)
{
// From TE Inventory to Player Inventory
if (!this.mergeItemStack(current, startPlayerIndex, endPlayerIndex, true))
return null;
}
else
{
// From Player Inventory to TE Inventory
if (!this.mergeItemStack(current, startContainerIndex, endContainerIndex, false))
return null;
}
// Custom behaviour //
if (current.stackSize == 0)
slot.putStack(null);
else
slot.onSlotChanged();
if (current.stackSize == previous.stackSize)
return null;
slot.onPickupFromSlot(entityPlayer, current);
}
return previous;
}
示例6: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
final Slot slot = inventorySlots.get(slotIndex);
ItemStack copy = ItemStack.EMPTY;
if (slot != null && slot.getHasStack()) {
final ItemStack original = slot.getStack();
copy = original.copy();
if (slotIndex == 0) {
if (!mergeItemStack(original, 19, 55, true)) return ItemStack.EMPTY;
slot.onSlotChange(original, copy);
} else if (slotIndex > 19) {
if (original.getCount() == 1 && !mergeItemStack(original, 0, 1, false)) return ItemStack.EMPTY;
slot.onSlotChange(original, copy);
} else {
if (!mergeItemStack(original, 19, 55, true)) return ItemStack.EMPTY;
slot.onSlotChange(original, copy);
}
if (original.getCount() == 0) {
slot.putStack(ItemStack.EMPTY);
} else {
slot.onSlotChanged();
}
if (original.getCount() == copy.getCount()) return ItemStack.EMPTY;
slot.onTake(player, original);
}
return copy;
}
示例7: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) {
ItemStack previous = ItemStack.EMPTY;
Slot slot = (Slot) this.inventorySlots.get(fromSlot);
if (slot != null && slot.getHasStack()) {
ItemStack current = slot.getStack();
previous = current.copy();
if(playerInventory)
if (fromSlot < handler.getSlots()) {
if (!this.mergeItemStack(current, handler.getSlots(), totalSize, true))
return ItemStack.EMPTY;
} else {
if (!this.mergeItemStack(current, 0, handler.getSlots(), false))
return ItemStack.EMPTY;
}
if (current.getCount() == 0)
slot.putStack(ItemStack.EMPTY);
else
slot.onSlotChanged();
if (current.getCount() == previous.getCount())
return null;
slot.onTake(playerIn, current);
}
return previous;
}
示例8: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int index)
{
Slot slot = this.inventorySlots.get(index);
if(slot == null || !slot.getHasStack())
return ItemStack.EMPTY;
ItemStack originalItem = slot.getStack();
ItemStack copyItem = originalItem.copy();
if(index >= 36) //Item is in our container, try placing in player's inventory.
{
if(!this.mergeItemStack(originalItem, 0, 36, true))
return ItemStack.EMPTY;
}
else
{
if(!this.mergeItemStack(originalItem, 36, this.inventorySlots.size(), false))
return ItemStack.EMPTY;
}
if(copyItem.getCount() == 0)
slot.putStack(ItemStack.EMPTY);
else
slot.onSlotChanged();
if(originalItem.getCount() == 0)
slot.putStack(ItemStack.EMPTY);
else
slot.onSlotChanged();
if(copyItem.getCount() == originalItem.getCount())
return ItemStack.EMPTY;
slot.onTake(player, copyItem);
return originalItem;
}
示例9: drawSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
/**
* Draws the given slot: any item in it, the slot's background, the hovered highlight, etc.
*/
private void drawSlot(Slot slotIn)
{
int i = slotIn.xDisplayPosition;
int j = slotIn.yDisplayPosition;
ItemStack itemstack = slotIn.getStack();
boolean flag = false;
boolean flag1 = slotIn == this.clickedSlot && !this.draggedStack.func_190926_b() && !this.isRightMouseClick;
ItemStack itemstack1 = this.mc.player.inventory.getItemStack();
String s = null;
if (slotIn == this.clickedSlot && !this.draggedStack.func_190926_b() && this.isRightMouseClick && !itemstack.func_190926_b())
{
itemstack = itemstack.copy();
itemstack.func_190920_e(itemstack.func_190916_E() / 2);
}
else if (this.dragSplitting && this.dragSplittingSlots.contains(slotIn) && !itemstack1.func_190926_b())
{
if (this.dragSplittingSlots.size() == 1)
{
return;
}
if (Container.canAddItemToSlot(slotIn, itemstack1, true) && this.inventorySlots.canDragIntoSlot(slotIn))
{
itemstack = itemstack1.copy();
flag = true;
Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack, slotIn.getStack().func_190926_b() ? 0 : slotIn.getStack().func_190916_E());
int k = Math.min(itemstack.getMaxStackSize(), slotIn.getItemStackLimit(itemstack));
if (itemstack.func_190916_E() > k)
{
s = TextFormatting.YELLOW.toString() + k;
itemstack.func_190920_e(k);
}
}
else
{
this.dragSplittingSlots.remove(slotIn);
this.updateDragSplitting();
}
}
this.zLevel = 100.0F;
this.itemRender.zLevel = 100.0F;
if (itemstack.func_190926_b() && slotIn.canBeHovered())
{
String s1 = slotIn.getSlotTexture();
if (s1 != null)
{
TextureAtlasSprite textureatlassprite = this.mc.getTextureMapBlocks().getAtlasSprite(s1);
GlStateManager.disableLighting();
this.mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
this.drawTexturedModalRect(i, j, textureatlassprite, 16, 16);
GlStateManager.enableLighting();
flag1 = true;
}
}
if (!flag1)
{
if (flag)
{
drawRect(i, j, i + 16, j + 16, -2130706433);
}
GlStateManager.enableDepth();
this.itemRender.renderItemAndEffectIntoGUI(this.mc.player, itemstack, i, j);
this.itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, itemstack, i, j, s);
}
this.itemRender.zLevel = 0.0F;
this.zLevel = 0.0F;
}
示例10: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
ItemStack itemstack = ItemStack.EMPTY;
Slot slot = this.inventorySlots.get(index);
if (slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if(index >= 0 && index < 36) {
if(!itemstack1.isEmpty() && itemstack1.getItem() instanceof ItemBlueprint) {
Slot sb = this.inventorySlots.get(this.slotBlueprint.slotNumber);
if(!sb.getHasStack()) {
if(!this.mergeItemStack(itemstack1, sb.slotNumber, sb.slotNumber + 1, false)) {
return ItemStack.EMPTY;
}
}
}
}
if (index >= 0 && index < 27) {
if (!this.mergeItemStack(itemstack1, 27, 36, false)) {
return ItemStack.EMPTY;
}
} else if (index >= 27 && index < 36) {
if (!this.mergeItemStack(itemstack1, 0, 27, false)) {
return ItemStack.EMPTY;
}
} else if (!this.mergeItemStack(itemstack1, 0, 36, false)) {
return ItemStack.EMPTY;
}
if (itemstack1.getCount() == 0) {
slot.putStack(ItemStack.EMPTY);
} else {
slot.onSlotChanged();
}
if (itemstack1.getCount() == itemstack.getCount()) {
return ItemStack.EMPTY;
}
slot.onTake(playerIn, itemstack1);
}
return itemstack;
}
示例11: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
@Nonnull
public ItemStack transferStackInSlot (EntityPlayer player, int slotIndex) {
@Nonnull ItemStack itemStack = ItemStack.EMPTY;
Slot slot = inventorySlots.get(slotIndex);
// Assume inventory and hotbar slot IDs are contiguous
int inventoryStart = playerSlots.get(0).slotNumber;
int hotbarStart = hotbarSlots.get(0).slotNumber;
int hotbarEnd = hotbarSlots.get(hotbarSlots.size() - 1).slotNumber + 1;
if (slot != null && slot.getHasStack()) {
@Nonnull ItemStack slotStack = slot.getStack();
itemStack = slotStack.copy();
// Try merge output into inventory and signal change
if (slotIndex == outputSlot.slotNumber) {
if (!mergeItemStack(slotStack, inventoryStart, hotbarEnd, true))
return ItemStack.EMPTY;
slot.onSlotChange(slotStack, itemStack);
}
// Try merge stacks within inventory and hotbar spaces
else if (slotIndex >= inventoryStart && slotIndex < hotbarEnd) {
boolean merged = false;
if (TileBloomeryFurnace.isItemFuel(slotStack))
merged = mergeItemStack(slotStack, fuelSlot.slotNumber, fuelSlot.slotNumber + 1, false);
else if (TileBloomeryFurnace.isItemPrimaryInput(slotStack))
merged = mergeItemStack(slotStack, primarySlot.slotNumber, primarySlot.slotNumber + 1, false);
else if (TileBloomeryFurnace.isItemSecondaryInput(slotStack))
merged = mergeItemStack(slotStack, secondarySlot.slotNumber, secondarySlot.slotNumber + 1, false);
if (!merged) {
if (slotIndex >= inventoryStart && slotIndex < hotbarStart) {
if (!mergeItemStack(slotStack, hotbarStart, hotbarEnd, false))
return ItemStack.EMPTY;
} else if (slotIndex >= hotbarStart && slotIndex < hotbarEnd && !this.mergeItemStack(slotStack, inventoryStart, hotbarStart, false))
return ItemStack.EMPTY;
}
}
// Try merge stack into inventory
else if (!mergeItemStack(slotStack, inventoryStart, hotbarEnd, false))
return ItemStack.EMPTY;
if (slotStack.isEmpty())
slot.putStack(ItemStack.EMPTY);
else
slot.onSlotChanged();
if (slotStack.getCount() == itemStack.getCount())
return ItemStack.EMPTY;
slot.onTake(player, slotStack);
}
return itemStack;
}
示例12: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
/**
* Take a stack from the specified inventory slot.
*/
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
ItemStack itemstack = ItemStack.EMPTY;
Slot slot = this.inventorySlots.get(index);
if (slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
if (itemstack1.getItem() == TF2weapons.itemTF2 && itemstack1.getMetadata() == 9)
itemstack1 = ItemFromData.getRandomWeapon(playerIn.getRNG(), ItemFromData.VISIBLE_WEAPON);
else if (itemstack1.getItem() == TF2weapons.itemTF2 && itemstack1.getMetadata() == 10)
itemstack1 = ItemFromData.getRandomWeaponOfClass("cosmetic", playerIn.getRNG(), false);
itemstack = itemstack1.copy();
if (index == 0) {
if (!this.mergeItemStack(itemstack1, 10, 46, true))
return ItemStack.EMPTY;
slot.onSlotChange(itemstack1, itemstack);
} else if (index >= 10 && index < 37) {
if (!this.mergeItemStack(itemstack1, 37, 46, false))
return ItemStack.EMPTY;
} else if (index >= 37 && index < 46) {
if (!this.mergeItemStack(itemstack1, 10, 37, false))
return ItemStack.EMPTY;
} else if (!this.mergeItemStack(itemstack1, 10, 46, false))
return ItemStack.EMPTY;
if (itemstack1.isEmpty())
slot.putStack(ItemStack.EMPTY);
else
slot.onSlotChanged();
if (itemstack1.getCount() ==itemstack.getCount())
return ItemStack.EMPTY;
slot.onTake(playerIn, itemstack1);
}
return itemstack;
}
示例13: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
{
ItemStack prev = null;
Slot slot = (Slot) this.inventorySlots.get(index);
if (slot != null && slot.getHasStack())
{
ItemStack cur = slot.getStack();
prev = cur.copy();
// From crystlaizer -> player
if (index < TileEntityAnimusMaterializer.SIZE)
{
// TODO: not hardcode the max inv size to support mods that altar the player inventory
if (!this.mergeItemStack(cur, TileEntityAnimusMaterializer.SIZE, 42, true))
{
return ItemStack.EMPTY;
}
}
// From player to crystallizer - we dont want this!
else
{
return ItemStack.EMPTY;
}
if (cur.getCount() == 0)
{
slot.putStack(ItemStack.EMPTY);
} else
{
slot.onSlotChanged();
}
if (cur.getCount() == prev.getCount())
{
return ItemStack.EMPTY;
}
}
return prev;
}
示例14: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotId)
{
ItemStack itemstackCopy = null;
Slot slot = (Slot)inventorySlots.get(slotId);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack = slot.getStack();
itemstackCopy = itemstack.copy();
if (slotId == SLOT_OUTPUT)
{
if (!mergeItemStack(itemstack, SLOT_PAN + 1, 39, true))
{
return null;
}
slot.onSlotChange(itemstack, itemstackCopy);
}
else if (slotId != SLOT_INPUT && slotId != SLOT_FUEL && slotId != SLOT_PAN)
{
if (itemstack.getItem() instanceof ItemPan)
{
if (!mergeItemStack(itemstack, SLOT_PAN, SLOT_PAN + 1, false))
{
return null;
}
}
else if (TileEntityCampfire.isItemFuel(itemstack))
{
if (!mergeItemStack(itemstack, SLOT_FUEL, SLOT_FUEL + 1, false))
{
return null;
}
}
else if (CampfireRecipeHandler.instance().getSmeltingResult(itemstack) != null)
{
if (!mergeItemStack(itemstack, SLOT_INPUT, SLOT_INPUT + 1, false))
{
return null;
}
}
else if (slotId > SLOT_OUTPUT && slotId < 30)
{
if (!mergeItemStack(itemstack, 30, 39, false))
{
return null;
}
}
else if (slotId >= 30 && slotId < 39 &&
!mergeItemStack(itemstack, SLOT_PAN + 1, 30, false))
{
return null;
}
}
else if (!mergeItemStack(itemstack, SLOT_PAN + 1, 39, false))
{
return null;
}
if (itemstack.getCount() == 0)
{
slot.putStack(null);
}
else
{
slot.onSlotChanged();
}
if (itemstack.getCount() == itemstackCopy.getCount())
{
return null;
}
slot.onTake(player, itemstack);
}
return itemstackCopy;
}
示例15: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
/**
* Take a stack from the specified inventory slot.
*/
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
{
ItemStack itemstack = ItemStack.EMPTY;
Slot slot = (Slot)this.inventorySlots.get(index);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (index == 1)
{
if (!this.mergeItemStack(itemstack1, 2, 38, true))
{
return ItemStack.EMPTY;
}
slot.onSlotChange(itemstack1, itemstack);
}
else if (index != 0)
{
boolean flag = false;
int[] ids = OreDictionary.getOreIDs(itemstack1);
for(int id: ids)
if(OreDictionary.getOreName(id).contains("food")){
flag = true;
break;
}
if ((itemstack1.getItem() instanceof ItemFood || flag) && !FurnaceRecipes.instance().getSmeltingResult(itemstack1).isEmpty())
{
if (!this.mergeItemStack(itemstack1, 0, 1, false))
{
return ItemStack.EMPTY;
}
}
else if (index >= 2 && index < 29)
{
if (!this.mergeItemStack(itemstack1, 29, 38, false))
{
return ItemStack.EMPTY;
}
}
else if (index >= 29 && index < 38 && !this.mergeItemStack(itemstack1, 2, 29, false))
{
return ItemStack.EMPTY;
}
}
else if (!this.mergeItemStack(itemstack1, 2, 38, false))
{
return ItemStack.EMPTY;
}
if (itemstack1.isEmpty())
{
slot.putStack(ItemStack.EMPTY);
}
else
{
slot.onSlotChanged();
}
if (itemstack1.getCount() == itemstack.getCount())
{
return ItemStack.EMPTY;
}
slot.onTake(playerIn, itemstack1);
}
return itemstack;
}