本文整理匯總了Java中net.minecraft.inventory.ClickType類的典型用法代碼示例。如果您正苦於以下問題:Java ClickType類的具體用法?Java ClickType怎麽用?Java ClickType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ClickType類屬於net.minecraft.inventory包,在下文中一共展示了ClickType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: slotClick
import net.minecraft.inventory.ClickType; //導入依賴的package包/類
@Nullable
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
if (!player.getEntityWorld().isRemote) {
if (slotId == 1 && getSlot(1) != null && getSlot(1).getHasStack()) {
listPid.remove(index);
if (index +1>=totalPictureNum) {
index--;
}
totalPictureNum--;
if(totalPictureNum==0){
index=-1;
}
}
}
ItemStack i = super.slotClick(slotId, dragType, clickTypeIn, player);
saveToNBT(player);
return i;
}
示例2: adjustPhantomSlot
import net.minecraft.inventory.ClickType; //導入依賴的package包/類
private void adjustPhantomSlot(Slot slot, ClickType clickType, int dragType) {
if (!((IPhantomSlot) slot).canAdjust()) {
return;
}
ItemStack stackSlot = slot.getStack().copy();
if (dragType == 1) {
if (clickType == ClickType.QUICK_MOVE) {
stackSlot.setCount(Math.min(stackSlot.getCount() * 2, slot.getSlotStackLimit())); // shift-r-click: double stack size
} else {
stackSlot.setCount(Math.min(stackSlot.getCount() + 1, slot.getSlotStackLimit())); // r-click: increase stack size
}
} else if (dragType == 0) {
if (clickType == ClickType.QUICK_MOVE) {
stackSlot.setCount(stackSlot.getCount() / 2); // shift-l-click: half stack size
} else {
stackSlot.shrink(1); // l-click: decrease stack size
}
}
slot.putStack(stackSlot);
}
示例3: keyTyped
import net.minecraft.inventory.ClickType; //導入依賴的package包/類
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
if (keyCode == 1 || mc.gameSettings.keyBindInventory.isActiveAndMatches(keyCode)) {
mc.player.closeScreen();
}
//this.checkHotbarKeys(keyCode);
if (theSlot != null && theSlot.getHasStack()) {
if (mc.gameSettings.keyBindPickBlock.isActiveAndMatches(keyCode)) {
handleMouseClick(theSlot, theSlot.slotNumber, 0, ClickType.CLONE);
}
else if (mc.gameSettings.keyBindDrop.isActiveAndMatches(keyCode)) {
handleMouseClick(theSlot, theSlot.slotNumber, isCtrlKeyDown() && !(theSlot instanceof SlotDankNull) ? 1 : 0, ClickType.THROW);
}
}
}
示例4: slotClick
import net.minecraft.inventory.ClickType; //導入依賴的package包/類
@Nullable
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player)
{
if(inventorySlots.get(slotId) != null)
{
if(!inventorySlots.get(slotId).getStack().isEmpty())
{
if(!player.world.isRemote)
{
InventoryHelper.spawnItemStack(player.world, inventory.getPos().getX() + 0.5D, inventory.getPos().getY() + 1D, inventory.getPos().getZ() + 0.5D, inventorySlots.get(slotId).getStack());
}
player.world.playSound(null, inventory.getPos().getX() + 0.5D, inventory.getPos().getY() + 1D, inventory.getPos().getZ() + 0.5D, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((player.world.rand.nextFloat() - player.world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
inventorySlots.get(slotId).putStack(ItemStack.EMPTY);
inventory.setInventorySlotContents(slotId, ItemStack.EMPTY);
inventory.markDirty();
}
}
return super.slotClick(slotId, dragType, clickTypeIn, player);
}
示例5: eatFood
import net.minecraft.inventory.ClickType; //導入依賴的package包/類
private void eatFood() {
for(int slot = 44; slot >= 9; slot--) {
ItemStack stack = Wrapper.getPlayer().inventoryContainer.getSlot(slot).getStack();
if(stack != null) {
if(slot >= 36 && slot <= 44) {
if(stack.getItem() instanceof ItemFood
&& !(stack.getItem() instanceof ItemAppleGold)) {
Wrapper.getPlayer().inventory.currentItem = slot - 36;
Wrapper.getMinecraft().gameSettings.keyBindUseItem.pressed = true;
return;
}
} else if(stack.getItem() instanceof ItemFood
&& !(stack.getItem() instanceof ItemAppleGold)) {
int itemSlot = slot;
int currentSlot = Wrapper.getPlayer().inventory.currentItem + 36;
Wrapper.getMinecraft().playerController.windowClick(0, slot, 0, ClickType.PICKUP, Wrapper.getPlayer());
Wrapper.getMinecraft().playerController.windowClick(0, currentSlot, 0, ClickType.PICKUP, Wrapper.getPlayer());
Wrapper.getMinecraft().playerController.windowClick(0, slot, 0, ClickType.PICKUP, Wrapper.getPlayer());
return;
}
}
}
}
示例6: keyTyped
import net.minecraft.inventory.ClickType; //導入依賴的package包/類
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
if (keyCode == 1 || keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode())
{
this.mc.player.closeScreen();
}
this.checkHotbarKeys(keyCode);
if (this.theSlot != null && this.theSlot.getHasStack())
{
if (keyCode == this.mc.gameSettings.keyBindPickBlock.getKeyCode())
{
this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, 0, ClickType.CLONE);
}
else if (keyCode == this.mc.gameSettings.keyBindDrop.getKeyCode())
{
this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, isCtrlKeyDown() ? 1 : 0, ClickType.THROW);
}
}
}
示例7: checkHotbarKeys
import net.minecraft.inventory.ClickType; //導入依賴的package包/類
/**
* Checks whether a hotbar key (to swap the hovered item with an item in the hotbar) has been pressed. If so, it
* swaps the given items.
* Returns true if a hotbar key was pressed.
*/
protected boolean checkHotbarKeys(int keyCode)
{
if (this.mc.player.inventory.getItemStack().func_190926_b() && this.theSlot != null)
{
for (int i = 0; i < 9; ++i)
{
if (keyCode == this.mc.gameSettings.keyBindsHotbar[i].getKeyCode())
{
this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, i, ClickType.SWAP);
return true;
}
}
}
return false;
}
示例8: keyTyped
import net.minecraft.inventory.ClickType; //導入依賴的package包/類
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
if (keyCode == 1 || this.mc.gameSettings.keyBindInventory.isActiveAndMatches(keyCode))
{
this.mc.thePlayer.closeScreen();
}
this.checkHotbarKeys(keyCode);
if (this.theSlot != null && this.theSlot.getHasStack())
{
if (this.mc.gameSettings.keyBindPickBlock.isActiveAndMatches(keyCode))
{
this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, 0, ClickType.CLONE);
}
else if (this.mc.gameSettings.keyBindDrop.isActiveAndMatches(keyCode))
{
this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, isCtrlKeyDown() ? 1 : 0, ClickType.THROW);
}
}
}
示例9: checkHotbarKeys
import net.minecraft.inventory.ClickType; //導入依賴的package包/類
/**
* Checks whether a hotbar key (to swap the hovered item with an item in the hotbar) has been pressed. If so, it
* swaps the given items.
* Returns true if a hotbar key was pressed.
*/
protected boolean checkHotbarKeys(int keyCode)
{
if (this.mc.thePlayer.inventory.getItemStack() == null && this.theSlot != null)
{
for (int i = 0; i < 9; ++i)
{
if (this.mc.gameSettings.keyBindsHotbar[i].isActiveAndMatches(keyCode))
{
this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, i, ClickType.SWAP);
return true;
}
}
}
return false;
}
示例10: slotClick
import net.minecraft.inventory.ClickType; //導入依賴的package包/類
@Override
public ItemStack slotClick(int id, int clickedButton, ClickType clickType, EntityPlayer player) {
Slot slot = id >= 0 ? getSlot(id) : null;
if(slot !=null){
if(slot instanceof SlotGhost){
if(ItemStackTools.isValid(slot.getStack())){
slot.putStack(ItemStackTools.getEmptyStack());
} else {
if(ItemStackTools.isValid(player.inventory.getItemStack())){
slot.putStack(ItemUtil.copy(player.inventory.getItemStack(), 1));
}
}
return player.inventory.getItemStack();
}
}
return super.slotClick(id, clickedButton, clickType, player);
}
示例11: slotClick
import net.minecraft.inventory.ClickType; //導入依賴的package包/類
@Override
public ItemStack slotClick(int slot, int dragType, ClickType clickType, EntityPlayer player) {
if (slot == 0) {
ItemStack stack = inventorySlots.get(0).getStack();
if (stack != null) {
Item item = stack.getItem();
if (item instanceof ICraftAchievement) {
player.addStat(((ICraftAchievement) item).getAchievementOnCraft(stack, player, tile));
} else if (item instanceof ItemBlock && Block.getBlockFromItem(item) instanceof ICraftAchievement) {
player.addStat(((ICraftAchievement) Block.getBlockFromItem(item)).getAchievementOnCraft(stack, player, tile));
}
}
if (dragType > 0) dragType = 0;
}
return super.slotClick(slot, dragType, clickType, player);
}
示例12: onUpdate
import net.minecraft.inventory.ClickType; //導入依賴的package包/類
@Override
public void onUpdate() {
if(mc.thePlayer.openContainer != null){
if(mc.thePlayer.openContainer instanceof ContainerChest){
ContainerChest chest = (ContainerChest) mc.thePlayer.openContainer;
int i;
for(i = 0; i<chest.numRows*9;i++){
if(mc.thePlayer.openContainer == null){
break;
}
Slot slot =(Slot)chest.inventorySlots.get(i);
if(slot.getStack() == null)
continue;
if(!timer.check((float)(delay == 0 ? 1 : delay))){
return;
}
mc.playerController.func_187098_a(chest.windowId, i, 0, ClickType.QUICK_MOVE, mc.thePlayer);
}
}
}
}
示例13: slotClick
import net.minecraft.inventory.ClickType; //導入依賴的package包/類
@Override
public ItemStack slotClick(int slotId, int clickedButton, ClickType mode, EntityPlayer playerIn)
{
if (slotId >= 0)
{
Slot s = getSlot(slotId);
if (s instanceof EngramSlot && clickedButton == 0)
{
s.onPickupFromSlot(playerIn, playerIn.inventory.getCurrentItem());
//TODO: check
if (mode == ClickType.PICKUP_ALL && selected != null && ARKPlayer.get(playerIn).canLearnEngram(selected.getId())
&& !playerIn.world.isRemote)
{
enchantItem(playerIn, 1);
}
return playerIn.inventory.getCurrentItem();
}
}
return super.slotClick(slotId, clickedButton, mode, playerIn);
}
示例14: keyTyped
import net.minecraft.inventory.ClickType; //導入依賴的package包/類
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException {
if (manager.lastKeyTyped(keyCode, typedChar)) {
return;
}
if (keyCode == 1 || this.mc.gameSettings.keyBindInventory.isActiveAndMatches(keyCode)) {
this.mc.thePlayer.closeScreen();
}
this.checkHotbarKeys(keyCode);
if (this.theSlot != null && this.theSlot.getHasStack()) {
if (this.mc.gameSettings.keyBindPickBlock.isActiveAndMatches(keyCode)) {
managerHandleMouseClick(this.theSlot, this.theSlot.slotNumber, 0, ClickType.CLONE);
} else if (this.mc.gameSettings.keyBindDrop.isActiveAndMatches(keyCode)) {
managerHandleMouseClick(this.theSlot, this.theSlot.slotNumber, isCtrlKeyDown() ? 1 : 0, ClickType.THROW);
}
}
}
示例15: clearIngredients
import net.minecraft.inventory.ClickType; //導入依賴的package包/類
@SuppressWarnings ("unchecked")
private boolean clearIngredients(GuiContainer gui, List<PositionedStack> ingreds) {
for (PositionedStack pstack : ingreds) {
for (Slot slot : gui.inventorySlots.inventorySlots) {
if (slot.xPos == pstack.relx + offsetx && slot.yPos == pstack.rely + offsety) {
if (!slot.getHasStack()) {
continue;
}
FastTransferManager.clickSlot(gui, slot.slotNumber, 0, ClickType.QUICK_MOVE);
if (slot.getHasStack()) {
return false;
}
}
}
}
return true;
}