本文整理匯總了Java中net.minecraft.inventory.Slot.isItemValid方法的典型用法代碼示例。如果您正苦於以下問題:Java Slot.isItemValid方法的具體用法?Java Slot.isItemValid怎麽用?Java Slot.isItemValid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.inventory.Slot
的用法示例。
在下文中一共展示了Slot.isItemValid方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: slotClickPhantom
import net.minecraft.inventory.Slot; //導入方法依賴的package包/類
@Nonnull
private ItemStack slotClickPhantom(Slot slot, int dragType, ClickType clickType, EntityPlayer player) {
ItemStack stack = ItemStack.EMPTY;
if (clickType == ClickType.CLONE && dragType == 2) {
// middle-click: clear slot
if (((IPhantomSlot) slot).canAdjust()) {
slot.putStack(ItemStack.EMPTY);
}
} else if ((clickType == ClickType.PICKUP || clickType == ClickType.QUICK_MOVE) && (dragType == 0 || dragType == 1)) {
// left or right-click...
InventoryPlayer playerInv = player.inventory;
slot.onSlotChanged();
ItemStack stackSlot = slot.getStack();
ItemStack stackHeld = playerInv.getItemStack();
stack = stackSlot.copy();
if (stackSlot.isEmpty()) {
if (!stackHeld.isEmpty() && slot.isItemValid(stackHeld)) {
fillPhantomSlot(slot, stackHeld, clickType, dragType);
}
} else if (stackHeld.isEmpty()) {
adjustPhantomSlot(slot, clickType, dragType);
slot.onTake(player, playerInv.getItemStack());
} else if (slot.isItemValid(stackHeld)) {
if (canStacksMerge(stackSlot, stackHeld)) {
adjustPhantomSlot(slot, clickType, dragType);
} else {
fillPhantomSlot(slot, stackHeld, clickType, dragType);
}
}
}
return stack;
}
示例2: mouseClickMove
import net.minecraft.inventory.Slot; //導入方法依賴的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: mouseClickMove
import net.minecraft.inventory.Slot; //導入方法依賴的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();
}
}
示例4: mouseClickMove
import net.minecraft.inventory.Slot; //導入方法依賴的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();
}
}