本文整理匯總了Java中net.minecraft.inventory.ClickType.CLONE屬性的典型用法代碼示例。如果您正苦於以下問題:Java ClickType.CLONE屬性的具體用法?Java ClickType.CLONE怎麽用?Java ClickType.CLONE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類net.minecraft.inventory.ClickType
的用法示例。
在下文中一共展示了ClickType.CLONE屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: slotClick
@Override
public ItemStack slotClick(int slotNum, int dragType, ClickType clickType, EntityPlayer player)
{
ItemStack stack = ItemQuickStacker.getEnabledItem(player);
// Middle click
if (clickType == ClickType.CLONE && dragType == 2 && stack.isEmpty() == false)
{
int invSlotNum = this.getSlot(slotNum) != null ? this.getSlot(slotNum).getSlotIndex() : -1;
if (invSlotNum != -1)
{
byte selected = NBTUtils.getByte(stack, ItemQuickStacker.TAG_NAME_CONTAINER, ItemQuickStacker.TAG_NAME_PRESET_SELECTION);
long mask = NBTUtils.getLong(stack, ItemQuickStacker.TAG_NAME_CONTAINER, ItemQuickStacker.TAG_NAME_PRESET + selected);
mask ^= (0x1L << invSlotNum);
NBTUtils.setLong(stack, ItemQuickStacker.TAG_NAME_CONTAINER, ItemQuickStacker.TAG_NAME_PRESET + selected, mask);
}
return ItemStack.EMPTY;
}
return super.slotClick(slotNum, dragType, clickType, player);
}
示例2: onClick
@Override
public ItemStack onClick(EntityPlayer player, int dragType, ClickType clickType) {
if (clickType == ClickType.CLONE && player.capabilities.isCreativeMode) {
ItemStack contents = getStack();
if (!contents.isEmpty()) {
ItemStack tmp = contents.copy();
tmp.setCount(tmp.getMaxStackSize());
player.inventory.setItemStack(tmp);
return tmp;
}
}
ItemStack held = player.inventory.getItemStack();
ItemStack place = ItemStack.EMPTY;
if (!held.isEmpty()) {
place = held.copy();
if (!keepSize) place.setCount(1);
}
inventory.setInventorySlotContents(slotNumber, place);
onSlotChanged();
return place;
}
示例3: slotClickPhantom
@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;
}
示例4: slotClick
@Override
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer playerIn) {
Slot slot = slotId > -1 && slotId < inventorySlots.size() ? inventorySlots.get(slotId) : null;
if (slot instanceof SlotPhantom) {
ItemStack s = TomsModUtils.copyItemStack(playerIn.inventory.getItemStack());
if (!s.isEmpty()) {
if (!ItemIgnoreList.accepts(s))
s.setTagCompound(null);
slot.putStack(dragType == 1 ? s.splitStack(1) : s);
} else if (dragType != 1)
slot.putStack(ItemStack.EMPTY);
else if (dragType == 1) {
if (!slot.getStack().isEmpty()) {
int c = 1;
if (clickTypeIn == ClickType.PICKUP_ALL)
c = -1;
else if (clickTypeIn == ClickType.QUICK_CRAFT)
c = -phantomSlotChange;
else if (clickTypeIn == ClickType.CLONE)
c = phantomSlotChange;
if (slot.getStack().getMaxStackSize() >= slot.getStack().getCount() + c && slot.getStack().getCount() + c > 0) {
slot.getStack().grow(c);
}
}
}
return playerIn.inventory.getItemStack();
} else if (slot instanceof ISlotClickListener) {
((ISlotClickListener) slot).slotClick(slotId, dragType, clickTypeIn, playerIn);
return super.slotClick(slotId, dragType, clickTypeIn, playerIn);
} else
return super.slotClick(slotId, dragType, clickTypeIn, playerIn);
}
示例5: slotClick
@Override
public ItemStack slotClick(int slotNum, int dragType, ClickType clickType, EntityPlayer player)
{
ItemStack stack = this.getContainerItem();
// Middle click
if (clickType == ClickType.CLONE && dragType == 2 && stack.isEmpty() == false &&
(this.playerMainSlotsIncHotbar.contains(slotNum) ||
this.playerArmorSlots.contains(slotNum) ||
this.playerOffhandSlots.contains(slotNum) ||
this.playerBaublesSlots.contains(slotNum)))
{
int invSlotNum = this.getSlot(slotNum) != null ? this.getSlot(slotNum).getSlotIndex() : -1;
if (this.playerBaublesSlots.contains(slotNum))
{
invSlotNum += 41;
}
if (invSlotNum == -1)
{
return ItemStack.EMPTY;
}
byte selected = NBTUtils.getByte(stack, ItemInventorySwapper.TAG_NAME_CONTAINER, ItemInventorySwapper.TAG_NAME_PRESET_SELECTION);
long mask = NBTUtils.getLong(stack, ItemInventorySwapper.TAG_NAME_CONTAINER, ItemInventorySwapper.TAG_NAME_PRESET + selected);
mask ^= (0x1L << invSlotNum);
NBTUtils.setLong(stack, ItemInventorySwapper.TAG_NAME_CONTAINER, ItemInventorySwapper.TAG_NAME_PRESET + selected, mask);
return ItemStack.EMPTY;
}
stack = super.slotClick(slotNum, dragType, clickType, player);
this.detectAndSendChanges();
return stack;
}
示例6: handleMouseClick
@Override
protected void handleMouseClick(Slot slotIn, int slotId, int mouseButton, ClickType type)
{
// Custom: middle click on a slot, with a modifier key active
if (type == ClickType.CLONE && (isShiftKeyDown() || isCtrlKeyDown() || isAltKeyDown()))
{
if (slotIn != null)
{
slotId = slotIn.slotNumber;
}
int modifier = 0;
if (isShiftKeyDown()) { modifier |= HotKeys.MOD_SHIFT; }
if (isCtrlKeyDown()) { modifier |= HotKeys.MOD_CTRL; }
if (isAltKeyDown()) { modifier |= HotKeys.MOD_ALT; }
int action = HotKeys.KEYCODE_MIDDLE_CLICK | modifier;
// Send a packet to the server
PacketHandler.INSTANCE.sendToServer(new MessageGuiAction(0, BlockPos.ORIGIN,
ReferenceGuiIds.GUI_ID_CONTAINER_GENERIC, action, slotId));
}
else
{
super.handleMouseClick(slotIn, slotId, mouseButton, type);
}
}
示例7: slotClick
@Override
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
if (clickTypeIn == ClickType.CLONE) {
Slot slot = getSlot(slotId);
if (slot.inventory == inventory) {
ItemStack stack = slot.getStack();
if (stack.getItem() instanceof IUpgrade && ((IUpgrade) stack.getItem()).canBeDisabled(stack)) {
inventory.getUpgradePart().setUpgradeDisabled(slot.getStack(), !inventory.getUpgradePart().isUpgradeDisabled(slot.getStack()));
}
return ItemStack.EMPTY;
}
}
return super.slotClick(slotId, dragType, clickTypeIn, player);
}
示例8: slotClick
@Override
public ItemStack slotClick(int slotNum, int dragType, ClickType clickType, EntityPlayer player)
{
if (this.filterSlots.contains(slotNum))
{
this.fakeSlotClick(slotNum, dragType, clickType, player);
return ItemStack.EMPTY;
}
// (Starting) or ending a drag and the dragged slots include at least one of our fake slots
if (clickType == ClickType.QUICK_CRAFT && slotNum == -999)
{
for (int i : this.draggedSlots)
{
if (this.filterSlots.contains(i))
{
this.fakeSlotClick(i, dragType, clickType, player);
return ItemStack.EMPTY;
}
}
}
// Middle click
else if (clickType == ClickType.CLONE && dragType == 2)
{
int invSlotNum = this.getSlot(slotNum) != null ? this.getSlot(slotNum).getSlotIndex() : -1;
if (invSlotNum == -1 || (invSlotNum >= 36 && invSlotNum != 40))
{
return ItemStack.EMPTY;
}
long mask = this.teqsa.getEnabledSlotsMask();
mask ^= (0x1L << invSlotNum);
this.teqsa.setEnabledSlotsMask(mask);
return ItemStack.EMPTY;
}
ItemStack stack = super.slotClick(slotNum, dragType, clickType, player);
if (player instanceof EntityPlayerMP)
{
this.detectAndSendChanges();
}
return stack;
}