本文整理汇总了Java中net.minecraft.inventory.Slot.getHasStack方法的典型用法代码示例。如果您正苦于以下问题:Java Slot.getHasStack方法的具体用法?Java Slot.getHasStack怎么用?Java Slot.getHasStack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.inventory.Slot
的用法示例。
在下文中一共展示了Slot.getHasStack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
public ItemStack transferStackInSlot(EntityPlayer ply, int prevSlot) {
ItemStack itemstack = ItemStack.EMPTY;
Slot slot = inventorySlots.get(prevSlot);
if (slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (prevSlot < size) {
if (!mergeItemStack(itemstack1, size, inventorySlots.size(), true)) {
return ItemStack.EMPTY;
}
} else if (!mergeItemStack(itemstack1, 0, size, false)) {
return ItemStack.EMPTY;
}
if (itemstack1.isEmpty()) {
slot.putStack(ItemStack.EMPTY);
} else {
slot.onSlotChanged();
}
}
return itemstack;
}
示例2: 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(!mergeItemStack(itemstack1, 0, 1, false)){
return ItemStack.EMPTY;
}
if (itemstack1.isEmpty()) {
slot.putStack(ItemStack.EMPTY);
} else {
slot.onSlotChanged();
}
}
return itemstack;
}
示例3: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
/**
* Take a stack from the specified inventory slot.
*/
@Nullable
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
{
if (index >= this.inventorySlots.size() - 9 && index < this.inventorySlots.size())
{
Slot slot = (Slot)this.inventorySlots.get(index);
if (slot != null && slot.getHasStack())
{
slot.putStack((ItemStack)null);
}
}
return null;
}
示例4: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
{
if (index >= this.inventorySlots.size() - 9 && index < this.inventorySlots.size())
{
Slot slot = (Slot)this.inventorySlots.get(index);
if (slot != null && slot.getHasStack())
{
slot.putStack((ItemStack)null);
}
}
return null;
}
示例5: 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 < beltSlots)
{
if (!this.mergeItemStack(itemstack1, beltSlots, this.inventorySlots.size(), true))
{
return ItemStack.EMPTY;
}
}
else if (!this.mergeItemStack(itemstack1, 0, beltSlots, false))
{
return ItemStack.EMPTY;
}
if (itemstack1.getCount() == 0)
{
slot.putStack(ItemStack.EMPTY);
}
else
{
slot.onSlotChanged();
}
}
return itemstack;
}
示例6: moveStackToInventory
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
protected boolean moveStackToInventory(ItemStack itemStackIn) {
for (int i = 0; i <= 36; i++) {
Slot possiblyOpenSlot = inventorySlots.get(i);
if (!possiblyOpenSlot.getHasStack()) {
possiblyOpenSlot.putStack(itemStackIn);
return true;
}
}
return false;
}
示例7: renameItem
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
private void renameItem()
{
String s = this.nameField.getText();
Slot slot = this.anvil.getSlot(0);
if (slot != null && slot.getHasStack() && !slot.getStack().hasDisplayName() && s.equals(slot.getStack().getDisplayName()))
{
s = "";
}
this.anvil.updateItemName(s);
this.mc.thePlayer.sendQueue.addToSendQueue(new C17PacketCustomPayload("MC|ItemName", (new PacketBuffer(Unpooled.buffer())).writeString(s)));
}
示例8: 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;
}
示例9: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Nonnull
@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int slotIndex) {
ItemStack stack = ItemStack.EMPTY;
Slot srcSlot = inventorySlots.get(slotIndex);
if (srcSlot != null && srcSlot.getHasStack()) {
ItemStack stackInSlot = srcSlot.getStack();
stack = stackInSlot.copy();
if (slotIndex < 27) {
if (!mergeItemStack(stackInSlot, 27, 36, false)) return ItemStack.EMPTY;
srcSlot.onSlotChange(stackInSlot, stack);
} else {
if (!mergeItemStack(stackInSlot, 0, 27, false)) return ItemStack.EMPTY;
srcSlot.onSlotChange(stackInSlot, stack);
}
if (stackInSlot.isEmpty()) {
srcSlot.putStack(ItemStack.EMPTY);
} else {
srcSlot.onSlotChanged();
}
if (stackInSlot.getCount() == stack.getCount()) return ItemStack.EMPTY;
srcSlot.onTake(par1EntityPlayer, stackInSlot);
}
return stack;
}
示例10: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, 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 == 0){
// ent -> player
if(!this.mergeItemStack(current, 13, 49, true))
return null;
}
else if(fromSlot >= 13) {
// player -> ent
if(!this.mergeItemStack(current, 0, 1, false))
return null;
}
// end custom behaviour
if (current.stackSize == 0)
slot.putStack((ItemStack) null);
else
slot.onSlotChanged();
if (current.stackSize == previous.stackSize)
return null;
slot.onPickupFromSlot(playerIn, current);
}
return previous;
}
示例11: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
{
ItemStack stack = ItemStack.EMPTY;
Slot slot = inventorySlots.get(index);
if (slot != null && slot.getHasStack())
{
ItemStack slotStack = slot.getStack();
if (index < TileEntityChunkLoader.INV_SLOTS)
{
if (!this.mergeItemStack(slotStack, TileEntityChunkLoader.INV_SLOTS, inventorySlots.size(), true))
{
return new ItemStack(Items.ENDER_PEARL, 0);
}
}
else if (!this.mergeItemStack(slotStack, 0, TileEntityChunkLoader.INV_SLOTS, false))
{
return ItemStack.EMPTY;
}
if (slotStack.isEmpty())
{
slot.putStack(ItemStack.EMPTY);
}
else
{
slot.onSlotChanged();
}
}
return stack;
}
示例12: 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 < 3) {
if (!this.mergeItemStack(itemstack1, 3, this.inventorySlots.size(), true)) {
te.updateResult();
return ItemStack.EMPTY;
}
} else if (!this.mergeItemStack(itemstack1, 0, 3, false)) {
te.updateResult();
return ItemStack.EMPTY;
}
if (itemstack1.isEmpty()) {
slot.putStack(ItemStack.EMPTY);
} else {
slot.onSlotChanged();
}
}
te.updateResult();
return itemstack;
}
示例13: 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;
}
示例14: transferStackInSlot
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
public ItemStack transferStackInSlot(EntityPlayer player, int slotNumber) {
ItemStack itemstack = null;
Slot slot = (Slot) this.inventorySlots.get(slotNumber);
if(slot != null && slot.getHasStack()) {
ItemStack slotStack = slot.getStack();
itemstack = slotStack.copy();
if(slotNumber == 0) {
if(!this.mergeItemStack(slotStack, 5, 41, true)) {
return null;
}
slot.onSlotChange(slotStack, itemstack);
} else if(!this.mergeItemStack(slotStack, 5, 41, false)) {
return null;
}
if(slotStack.stackSize == 0) {
slot.putStack((ItemStack) null);
} else {
slot.onSlotChanged();
}
if(slotStack.stackSize == itemstack.stackSize) {
return null;
}
slot.onPickupFromSlot(player, slotStack);
}
return itemstack;
}
示例15: 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();
EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(itemstack);
if (index >= 0 && index < 4) {
if (!this.mergeItemStack(itemstack1, 8, 44, false))
return ItemStack.EMPTY;
} else if (index >= 4 && index < 7) {
if (!this.mergeItemStack(itemstack1, 8, 44, false))
return ItemStack.EMPTY;
} else if (entityequipmentslot.getSlotType() == EntityEquipmentSlot.Type.ARMOR
&& !this.inventorySlots.get(4 - entityequipmentslot.getIndex()).getHasStack()) {
int i = 4 - entityequipmentslot.getIndex();
if (!this.mergeItemStack(itemstack1, i, i + 1, false))
return ItemStack.EMPTY;
} else if (entityequipmentslot == EntityEquipmentSlot.OFFHAND
&& !this.inventorySlots.get(44).getHasStack()) {
if (!this.mergeItemStack(itemstack1, 44, 45, false))
return ItemStack.EMPTY;
} else if (itemstack1.getItem() instanceof ItemAmmoBelt
&& !this.inventorySlots.get(7).getHasStack()) {
if (!this.mergeItemStack(itemstack1, 7, 8, false))
return ItemStack.EMPTY;
} else if (itemstack1.getItem() instanceof ItemWearable && index >= 8) {
if (!this.mergeItemStack(itemstack1, 4, 7, false))
return ItemStack.EMPTY;
} else if (itemstack1.getItem() instanceof ItemAmmo && ammoBelt && index < 44) {
if (!this.mergeItemStack(itemstack1, 45, 54, false))
return ItemStack.EMPTY;
} else if (index >= 8 && index < 35) {
if (!this.mergeItemStack(itemstack1, 35, 44, false))
return ItemStack.EMPTY;
} else if (index >= 35 && index < 44) {
if (!this.mergeItemStack(itemstack1, 8, 35, false))
return ItemStack.EMPTY;
} else if (!this.mergeItemStack(itemstack1, 8, 44, 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;
}