本文整理汇总了Java中net.minecraft.inventory.Container.canAddItemToSlot方法的典型用法代码示例。如果您正苦于以下问题:Java Container.canAddItemToSlot方法的具体用法?Java Container.canAddItemToSlot怎么用?Java Container.canAddItemToSlot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.inventory.Container
的用法示例。
在下文中一共展示了Container.canAddItemToSlot方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawSlot
import net.minecraft.inventory.Container; //导入方法依赖的package包/类
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 != null && !this.isRightMouseClick;
ItemStack itemstack1 = this.mc.thePlayer.inventory.getItemStack();
String s = null;
if (slotIn == this.clickedSlot && this.draggedStack != null && this.isRightMouseClick && itemstack != null)
{
itemstack = itemstack.copy();
itemstack.stackSize /= 2;
}
else if (this.dragSplitting && this.dragSplittingSlots.contains(slotIn) && itemstack1 != null)
{
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() == null ? 0 : slotIn.getStack().stackSize);
if (itemstack.stackSize > itemstack.getMaxStackSize())
{
s = EnumChatFormatting.YELLOW + "" + itemstack.getMaxStackSize();
itemstack.stackSize = itemstack.getMaxStackSize();
}
if (itemstack.stackSize > slotIn.getItemStackLimit(itemstack))
{
s = EnumChatFormatting.YELLOW + "" + slotIn.getItemStackLimit(itemstack);
itemstack.stackSize = slotIn.getItemStackLimit(itemstack);
}
}
else
{
this.dragSplittingSlots.remove(slotIn);
this.updateDragSplitting();
}
}
this.zLevel = 100.0F;
this.itemRender.zLevel = 100.0F;
if (itemstack == null)
{
String s1 = slotIn.getSlotTexture();
if (s1 != null)
{
TextureAtlasSprite textureatlassprite = this.mc.getTextureMapBlocks().getAtlasSprite(s1);
GlStateManager.disableLighting();
this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
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(itemstack, i, j);
this.itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, itemstack, i, j, s);
}
this.itemRender.zLevel = 0.0F;
this.zLevel = 0.0F;
}
示例2: mouseClickMove
import net.minecraft.inventory.Container; //导入方法依赖的package包/类
/**
* Called when a mouse button is pressed and the mouse is moved around. Parameters are : mouseX, mouseY,
* lastButtonClicked & timeSinceMouseClick.
*/
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick)
{
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();
if (this.clickedSlot != null && this.mc.gameSettings.touchscreen)
{
if (clickedMouseButton == 0 || clickedMouseButton == 1)
{
if (this.draggedStack == null)
{
if (slot != this.clickedSlot && this.clickedSlot.getStack() != null)
{
this.draggedStack = this.clickedSlot.getStack().copy();
}
}
else if (this.draggedStack.stackSize > 1 && slot != null && Container.canAddItemToSlot(slot, this.draggedStack, false))
{
long i = Minecraft.getSystemTime();
if (this.currentDragTargetSlot == slot)
{
if (i - this.dragItemDropDelay > 500L)
{
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, 0);
this.handleMouseClick(slot, slot.slotNumber, 1, 0);
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, 0);
this.dragItemDropDelay = i + 750L;
--this.draggedStack.stackSize;
}
}
else
{
this.currentDragTargetSlot = slot;
this.dragItemDropDelay = i;
}
}
}
}
else if (this.dragSplitting && slot != null && itemstack != null && itemstack.stackSize > this.dragSplittingSlots.size() && Container.canAddItemToSlot(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot))
{
this.dragSplittingSlots.add(slot);
this.updateDragSplitting();
}
}
示例3: drawSlot
import net.minecraft.inventory.Container; //导入方法依赖的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;
}
示例4: mouseClickMove
import net.minecraft.inventory.Container; //导入方法依赖的package包/类
/**
* Called when a mouse button is pressed and the mouse is moved around. Parameters are : mouseX, mouseY,
* lastButtonClicked & timeSinceMouseClick.
*/
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick)
{
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
ItemStack itemstack = this.mc.player.inventory.getItemStack();
if (this.clickedSlot != null && this.mc.gameSettings.touchscreen)
{
if (clickedMouseButton == 0 || clickedMouseButton == 1)
{
if (this.draggedStack.func_190926_b())
{
if (slot != this.clickedSlot && !this.clickedSlot.getStack().func_190926_b())
{
this.draggedStack = this.clickedSlot.getStack().copy();
}
}
else if (this.draggedStack.func_190916_E() > 1 && slot != null && Container.canAddItemToSlot(slot, this.draggedStack, false))
{
long i = Minecraft.getSystemTime();
if (this.currentDragTargetSlot == slot)
{
if (i - this.dragItemDropDelay > 500L)
{
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, ClickType.PICKUP);
this.handleMouseClick(slot, slot.slotNumber, 1, ClickType.PICKUP);
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, ClickType.PICKUP);
this.dragItemDropDelay = i + 750L;
this.draggedStack.func_190918_g(1);
}
}
else
{
this.currentDragTargetSlot = slot;
this.dragItemDropDelay = i;
}
}
}
}
else if (this.dragSplitting && slot != null && !itemstack.func_190926_b() && (itemstack.func_190916_E() > this.dragSplittingSlots.size() || this.dragSplittingLimit == 2) && Container.canAddItemToSlot(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot))
{
this.dragSplittingSlots.add(slot);
this.updateDragSplitting();
}
}
示例5: mouseClickMove
import net.minecraft.inventory.Container; //导入方法依赖的package包/类
/**
* Called when a mouse button is pressed and the mouse is moved around. Parameters are : mouseX, mouseY,
* lastButtonClicked & timeSinceMouseClick.
*/
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick)
{
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();
if (this.clickedSlot != null && this.mc.gameSettings.touchscreen)
{
if (clickedMouseButton == 0 || clickedMouseButton == 1)
{
if (this.draggedStack == null)
{
if (slot != this.clickedSlot && this.clickedSlot.getStack() != null)
{
this.draggedStack = this.clickedSlot.getStack().copy();
}
}
else if (this.draggedStack.stackSize > 1 && slot != null && Container.canAddItemToSlot(slot, this.draggedStack, false))
{
long i = Minecraft.getSystemTime();
if (this.currentDragTargetSlot == slot)
{
if (i - this.dragItemDropDelay > 500L)
{
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, ClickType.PICKUP);
this.handleMouseClick(slot, slot.slotNumber, 1, ClickType.PICKUP);
this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, ClickType.PICKUP);
this.dragItemDropDelay = i + 750L;
--this.draggedStack.stackSize;
}
}
else
{
this.currentDragTargetSlot = slot;
this.dragItemDropDelay = i;
}
}
}
}
else if (this.dragSplitting && slot != null && itemstack != null && itemstack.stackSize > this.dragSplittingSlots.size() && Container.canAddItemToSlot(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot))
{
this.dragSplittingSlots.add(slot);
this.updateDragSplitting();
}
}