當前位置: 首頁>>代碼示例>>Java>>正文


Java MouseEvent.getDwheel方法代碼示例

本文整理匯總了Java中net.minecraftforge.client.event.MouseEvent.getDwheel方法的典型用法代碼示例。如果您正苦於以下問題:Java MouseEvent.getDwheel方法的具體用法?Java MouseEvent.getDwheel怎麽用?Java MouseEvent.getDwheel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.client.event.MouseEvent的用法示例。


在下文中一共展示了MouseEvent.getDwheel方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onMouseEvent

import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onMouseEvent(MouseEvent event) {
    EntityPlayerSP player = Minecraft.getMinecraft().player;
    if(event.getDwheel() != 0 && player != null && player.isSneaking()) {
        ItemStack stack = player.getHeldItemMainhand();
        Item item = stack.getItem();
        if(item instanceof ItemTransporter) {
            if(((ItemTransporter) item).getMode(stack) == 1) {

                ItemTransporter.cycleSelected(stack, event.getDwheel());
                PacketWhoosh.sendCycleSelectedPacketToServer(event.getDwheel());
                event.setCanceled(true);
            }
        }
    }
}
 
開發者ID:ImbaKnugel,項目名稱:Whoosh,代碼行數:17,代碼來源:EventHandlerClient.java

示例2: handleScroll

import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void handleScroll(MouseEvent event){
	int scroll = event.getDwheel();
	EntityPlayer player = CrystalMod.proxy.getClientPlayer();
	if(player !=null && player.isSneaking()){
		if(scroll >=30){
			//Up (Weapons)
			if(BackpackUtil.canSwapWeapons(player)){
 			CrystalModNetwork.sendToServer(new PacketToolSwap(0));
 			event.setCanceled(true);
			}
		} else if(scroll <=-30){
			//Down (Tools)
			if(BackpackUtil.canSwapTools(player)){
 			CrystalModNetwork.sendToServer(new PacketToolSwap(1));
 			event.setCanceled(true);
			}
		}
	}
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:21,代碼來源:ClientEventHandler.java

示例3: handleMouseInputEvent

import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void handleMouseInputEvent(MouseEvent event) {
	if (Minecraft.getMinecraft().player != null && Minecraft.getMinecraft().player.isSneaking()) {
		if (event.getDwheel() != 0) {
			int w = event.getDwheel();
			ItemStack stack = Minecraft.getMinecraft().player.getHeldItemMainhand();
			if (stack.getItem() instanceof IScroller) {
				if (((IScroller) stack.getItem()).canScroll(stack)) {
					event.setCanceled(true);
					NetworkHandler.sendToServer(new MessageScroll(w > 0 ? ScrollDirection.UP : ScrollDirection.DOWN));
				}
			}
		}
	}
}
 
開發者ID:tom5454,項目名稱:Toms-Mod,代碼行數:17,代碼來源:KeyInputHandler.java

示例4: onMouseEvent

import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@SideOnly(Side.CLIENT)
@SubscribeEvent
public static void onMouseEvent(MouseEvent event) {
    if (event.getButton() < 0) {
        EntityPlayer player = Minecraft.getMinecraft().player;
        if (player.isSneaking()) {
            ItemStack stack = player.getHeldItemMainhand();
            if (stack.getItem() == ModItems.DEBUG_ITEM) {
                if (event.getDwheel() != 0) {
                    NetworkHandler.WRAPPER.sendToServer(new PacketChangeMode(4, stack, player.inventory.currentItem, event.getDwheel() < 0));
                }
                event.setCanceled(true);
            }
        }
    }
}
 
開發者ID:GirafiStudios,項目名稱:Culinary-Cultivation,代碼行數:17,代碼來源:ItemDebugItem.java

示例5: onMouseInput

import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onMouseInput(MouseEvent event) {
  EntityPlayer player = Minecraft.getMinecraft().player;
  if (!player.isSneaking() || event.getDwheel() == 0) {
    return;
  }
  ItemStack wand = UtilSpellCaster.getPlayerWandIfHeld(player);
  if (wand.isEmpty()) {
    return;
  }
  //if theres only one spell, do nothing
  if (SpellRegistry.getSpellbook(wand) == null || SpellRegistry.getSpellbook(wand).size() <= 1) {
    return;
  }
  if (event.getDwheel() < 0) {
    ModCyclic.network.sendToServer(new PacketSpellShiftRight());
    event.setCanceled(true);
    UtilSound.playSound(player, player.getPosition(), SoundRegistry.bip);
  }
  else if (event.getDwheel() > 0) {
    ModCyclic.network.sendToServer(new PacketSpellShiftLeft());
    event.setCanceled(true);
    UtilSound.playSound(player, player.getPosition(), SoundRegistry.bip);
  }
}
 
開發者ID:PrinceOfAmber,項目名稱:Cyclic,代碼行數:27,代碼來源:EventKeyInput.java

示例6: onMouseInput

import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onMouseInput(MouseEvent event)
{
    if(Keybindings.toolbelt.isKeyDown())
    {
        int wheel = event.getDwheel();
        if(wheel > 0) //To the left.
        {
            if(process(true))
            {
                event.setCanceled(true);
            }
        }
        else if(wheel < 0) //To the right.
            if(process(false))
            {
                event.setCanceled(true);
            }
    }
}
 
開發者ID:Lumaceon,項目名稱:ClockworkPhase2,代碼行數:21,代碼來源:MouseInputHandler.java

示例7: onMouseEvent

import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onMouseEvent(MouseEvent event) {
	if (event.getDwheel() != 0 && Minecraft.getMinecraft().gameSettings.keyBindSneak.isKeyDown()) {
		for (Entry<Item, Function<MouseEvent, Boolean>> entry : scrollWheelBindings.entrySet()) {
			HeldEquipment equipment =
					PlayerUtil.getHeldEquipment(Minecraft.getMinecraft().player, entry.getKey());
			if (equipment != null) {
				if (entry.getValue().apply(event)) {
					event.setCanceled(true);
					return;
				}
			}
		}
	}
}
 
開發者ID:hea3ven,項目名稱:CommonUtils,代碼行數:16,代碼來源:KeyBindingManager.java

示例8: onMouseEvent

import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onMouseEvent(MouseEvent event) {
	if (event.getDwheel() != 0 && Minecraft.getMinecraft().player.isSneaking()) {
		ItemStack stack = Minecraft.getMinecraft().player.getHeldItemMainhand();
		if (stack.getItem() instanceof IAmmoConsumer) {

			List<ItemStack> ammoList = IAmmoConsumer.findAllAmmo(Minecraft.getMinecraft().player);
			if (ammoList.size() <= 0) {
				event.setCanceled(true);
				return;
			}
			Set<Color> colorSet = ammoList.stream().map(ammo -> new Color(((IAmmo) ammo.getItem()).getInternalColor(ammo), true)).collect(Collectors.toSet());
			List<Color> colors = new ArrayList<>(colorSet);

			Color gunColor = new Color(ItemNBTHelper.getInt(stack, "color", 0xFFFFFF), true);
			int slot = -1;
			for (Color color : colors)
				if (Utils.doColorsMatchNoAlpha(color, gunColor)) {
					slot = colors.indexOf(color);
					break;
				}
			if (slot == -1) slot = 0;

			if (event.getDwheel() > 0) {
				if (colors.size() - 1 >= slot + 1)
					PacketHandler.NETWORK.sendToServer(new PacketAmmoColorChange(Minecraft.getMinecraft().player.inventory.getSlotFor(stack), colors.get(slot + 1)));
				else
					PacketHandler.NETWORK.sendToServer(new PacketAmmoColorChange(Minecraft.getMinecraft().player.inventory.getSlotFor(stack), colors.get(0)));
			} else if (event.getDwheel() < 0) {
				if (slot - 1 >= 0)
					PacketHandler.NETWORK.sendToServer(new PacketAmmoColorChange(Minecraft.getMinecraft().player.inventory.getSlotFor(stack), colors.get(slot - 1)));
				else
					PacketHandler.NETWORK.sendToServer(new PacketAmmoColorChange(Minecraft.getMinecraft().player.inventory.getSlotFor(stack), colors.get(colors.size() - 1)));
			}
			event.setCanceled(true);
		}
	}
}
 
開發者ID:TeamWizardry,項目名稱:TMT-Refraction,代碼行數:39,代碼來源:EventHandlerClient.java

示例9: onMouseScroll

import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onMouseScroll(MouseEvent evt) {
    if (isUsingBinoculars() && evt.getDwheel() != 0 && mc.gameSettings.thirdPersonView == 0) {
        currentZoom = 1 / Math.min(Math.max(1 / currentZoom + evt.getDwheel() / 180F, 1 / MIN_ZOOM), 1 / MAX_ZOOM);
        evt.setCanceled(true);
    }
}
 
開發者ID:Tonius,項目名稱:Zoom,代碼行數:8,代碼來源:EventHandler.java

示例10: OnMouseWheelScroll

import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void OnMouseWheelScroll (MouseEvent event) {
    Minecraft mc = Minecraft.getMinecraft();
    EntityPlayer player = mc.player;
    World world = mc.world;
    if (!mc.inGameHasFocus && !KeyboardHelper.isScrollActivatorDown()) {
        event.setCanceled(false);
        return;
    }

    /*if (player.getCapability(ModCapabilities.DRIVE_STATE, null).getInDrive()) {
        if (player.getCapability(ModCapabilities.DRIVE_STATE, null).getActiveDriveName().equals(Strings.Form_Wisdom)) {
            event.setCanceled(true);
        } else {
            event.setCanceled(false);
        }
    }*/

    if (event.getButton() == Constants.LEFT_MOUSE && KeyboardHelper.isScrollActivatorDown() && event.isButtonstate()) {
        commandEnter();
        event.setCanceled(true);
    }

    if (event.getButton() == Constants.RIGHT_MOUSE && KeyboardHelper.isScrollActivatorDown() && event.isButtonstate()) {
        commandBack();
        event.setCanceled(true);
    }

    if (event.getDwheel() <= Constants.WHEEL_DOWN && KeyboardHelper.isScrollActivatorDown() && event.getDwheel() != 0) {
        commandDown();
        event.setCanceled(true);
        world.playSound(player, player.getPosition(), ModSounds.move, SoundCategory.MASTER, 1.0f, 1.0f);
    }
    if (event.getDwheel() >= Constants.WHEEL_UP && KeyboardHelper.isScrollActivatorDown() && event.getDwheel() != 0) {
        commandUp();
        event.setCanceled(true);
        world.playSound(player, player.getPosition(), ModSounds.move, SoundCategory.MASTER, 1.0f, 1.0f);
    }

}
 
開發者ID:Wehavecookies56,項目名稱:Kingdom-Keys-Re-Coded,代碼行數:41,代碼來源:InputHandler.java

示例11: onMouseEvent

import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onMouseEvent(MouseEvent event)
{
    int dWheel = event.getDwheel();
    if (dWheel != 0)
    {
        dWheel /= 120;

        // If the player pressed down a modifier key while holding an IKeyBound item
        // (note: this means it specifically WON'T work if the player started pressing a modifier
        // key while holding something else, for example when scrolling through the hotbar!!),
        // then we allow for easily scrolling through the changeable stuff using the mouse wheel.
        if (scrollingMask != 0)
        {
            EntityPlayer player = FMLClientHandler.instance().getClientPlayerEntity();

            if (isHoldingKeyboundItem(player))
            {
                int key = HotKeys.KEYCODE_SCROLL | scrollingMask;

                // Scrolling up, reverse the direction.
                if (dWheel > 0)
                {
                    key |= HotKeys.SCROLL_MODIFIER_REVERSE;
                }

                if (event.isCancelable())
                {
                    event.setCanceled(true);
                }

                PacketHandler.INSTANCE.sendToServer(new MessageKeyPressed(key));
            }
        }
    }
}
 
開發者ID:maruohon,項目名稱:enderutilities,代碼行數:37,代碼來源:InputEventHandler.java

示例12: onMouseEvent

import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onMouseEvent(MouseEvent event) {
  EntityPlayerSP player = Minecraft.getMinecraft().player;
  if (event.getDwheel() != 0 && player.isSneaking()) {
    ItemStack stack = player.getHeldItemMainhand();
    Item item = stack.getItem();
    if (item instanceof IConduitControl) {
      changeDisplayMode(stack, player, event.getDwheel());
      event.setCanceled(true);
    } else if (item instanceof ItemConduitProbe) {
      changeConduitProbeMode(stack);
      event.setCanceled(true);
    }
  }
}
 
開發者ID:SleepyTrousers,項目名稱:EnderIO,代碼行數:16,代碼來源:ToolTickHandler.java

示例13: onMouseEvent

import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@SubscribeEvent
public static void onMouseEvent(MouseEvent event) {
  EntityPlayerSP player = Minecraft.getMinecraft().player;
  if (event.getDwheel() != 0 && player.isSneaking()) {
    ItemStack stack = player.getHeldItemMainhand();
    Item item = stack.getItem();
    if (item instanceof IConduitControl) {
      changeDisplayMode(stack, player, event.getDwheel());
      event.setCanceled(true);
    } else if (item instanceof ItemConduitProbe) {
      changeConduitProbeMode(stack);
      event.setCanceled(true);
    }
  }
}
 
開發者ID:SleepyTrousers,項目名稱:EnderIO,代碼行數:16,代碼來源:ToolTickHandler.java

示例14: mouseEvent

import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
/**
 * Handles mouse scroll for hotbar
 * @param event mouse event
 */
public void mouseEvent(MouseEvent event) {
    if (!hasCoreMod || getShowDefaultToggle())
        return;
    // Scrolled
    if (event.getDwheel() != 0) {
        updateTooltips();
        // Handle hotbar selector scroll
        EntityPlayer player = Minecraft.getMinecraft().player;
        // Calculate next/previous hotbar
        int nextHotbar = getNextHotbarWithCustomOrder();
        int previousHotbar = getPreviousHotbarWithCustomOrder();
        // Scrolled right
        if (event.getDwheel() < 0) {
            // Modifier button is pressed. Move to next hotbar
            if (KeyBindings.scrollModifier.isKeyDown())
                moveSelectionToNextHotbar();
            // The end of the current hotbar has been reached. Move to the beginning of the next one.
            else if (player.inventory.currentItem % VANILLA_HOTBAR_SIZE == VANILLA_HOTBAR_SIZE - 1) {
                if (!shouldShowDefault())
                    player.inventory.currentItem = (Config.inverseScrollDirection ? previousHotbar : nextHotbar) *
                            VANILLA_HOTBAR_SIZE;
                else
                    player.inventory.currentItem = getCurrentHotbar() * VANILLA_HOTBAR_SIZE;
            }
            // Move to next item
            else
               player.inventory.currentItem++;
        }
        // Scrolled left
        else {
            // Modifier is pressed. Move to previous hotbar.
            if (KeyBindings.scrollModifier.isKeyDown())
                moveSelectionToPreviousHotbar();
            // The beginning of the current hotbar has been reached. Move to the end of the previous one.
            else if (player.inventory.currentItem % 9 == 0) {
                if (!shouldShowDefault())
                    player.inventory.currentItem = (Config.inverseScrollDirection ? nextHotbar : previousHotbar) *
                            VANILLA_HOTBAR_SIZE + VANILLA_HOTBAR_SIZE - 1;
                else
                    player.inventory.currentItem = getCurrentHotbar() * VANILLA_HOTBAR_SIZE +
                            VANILLA_HOTBAR_SIZE - 1;
            }
            // Move to previous item
            else
                player.inventory.currentItem--;
        }
        event.setCanceled(true);
        resetTooltipTicks();
    }
}
 
開發者ID:rolandoislas,項目名稱:multi-hotbar,代碼行數:55,代碼來源:HotbarLogic.java


注:本文中的net.minecraftforge.client.event.MouseEvent.getDwheel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。