本文整理匯總了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);
}
}
}
}
示例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);
}
}
}
}
示例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));
}
}
}
}
}
示例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);
}
}
}
}
示例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);
}
}
示例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);
}
}
}
示例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;
}
}
}
}
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
示例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));
}
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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();
}
}