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


Java MouseEvent類代碼示例

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


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

示例1: onMouseEvent

import net.minecraftforge.client.event.MouseEvent; //導入依賴的package包/類
@Override
public void onMouseEvent(MouseEvent evt) {
	
	ScaledResolution scale = new ScaledResolution(this.mc);
	
	float scaleFactor = scale.getScaledWidth() / (float)this.mc.displayWidth; 
	int mx = (int)(evt.getX() * scaleFactor);
	int my = (int)((this.mc.displayHeight - evt.getY()) * scaleFactor);
	int btn = evt.getButton();

	boolean hitRemoteShell = 
		mx > remoteShellX && mx < remoteShellX + remoteShellWidth
		&& my > remoteShellY && my < remoteShellY + fontHeight
	;
	
	if (!this.mouseDown && Mouse.isButtonDown(0)) {
		this.mouseDown = true;
		if (hitRemoteShell) {
			System.out.println("You tried to return to the remote shell!");
			this.entity.returnToShell();
		}
	} else {
		this.mouseDown = false;
		this.remoteShellColor = hitRemoteShell ? this.remoteShellColorHover : this.remoteShellColorNormal;
	}
}
 
開發者ID:astronautlabs,項目名稱:rezolve,代碼行數:27,代碼來源:RemoteShellOverlay.java

示例2: click

import net.minecraftforge.client.event.MouseEvent; //導入依賴的package包/類
private void click(boolean state) {
    if (Wrapper.currentScreen() != null) {
        clickInventory(0, state);
        return;
    }

    if (inventoryOnly.getValue()) return;

    try {
        MouseEvent event = new MouseEvent();
        int key = Wrapper.getKeyCode(Wrapper.keybindAttack());
        ReflectionUtil.setField("button", event, Wrapper.convertKeyToLWJGL(key));
        ReflectionUtil.setField("buttonstate", event, state);
        //calling the event for CPSMod compatibility.
        boolean thingy = MinecraftForge.EVENT_BUS.post(event);
        Wrapper.keybinding_setKeybindState(key, state);
        if (state)
            Wrapper.keybinding_onTick(key);
        if (!thingy)
            FMLCommonHandler.instance().fireMouseInput();
    } catch (Exception ex) {
    }
}
 
開發者ID:Ygore,項目名稱:bit-client,代碼行數:24,代碼來源:ModuleAutoclicker.java

示例3: 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

示例4: 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

示例5: 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

示例6: onLeftClick

import net.minecraftforge.client.event.MouseEvent; //導入依賴的package包/類
@SubscribeEvent
@SuppressWarnings("unused")
public void onLeftClick(MouseEvent event) {
    EntityPlayerSP player = Minecraft.getMinecraft().player;
    ItemStack stack = player.getHeldItemOffhand();
    if(event.getButton() != LMB) {
        return;
    }
    leftButtonPressed = !leftButtonPressed;
    if(stack == null) {
        return;
    }
    if(stack.getItem() instanceof IDualWieldedWeapon) {
        if(leftButtonPressed) {
            boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT);
            boolean ctrl = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL);
            IDualWieldedWeapon weapon = (IDualWieldedWeapon) stack.getItem();
            attackEntity(weapon, player, stack, true, shift, ctrl, EnumHand.OFF_HAND);
            weapon.onItemUsed(stack, player, shift, ctrl, EnumHand.OFF_HAND);
            new MessageMouseButtonPressed(true, shift, ctrl).sendToServer();
            Minecraft.getMinecraft().player.swingArm(EnumHand.OFF_HAND);
        }
        event.setResult(Event.Result.DENY);
        event.setCanceled(true);
    }
}
 
開發者ID:InfinityRaider,項目名稱:InfinityLib,代碼行數:27,代碼來源:MouseClickHandler.java

示例7: onRightClick

import net.minecraftforge.client.event.MouseEvent; //導入依賴的package包/類
@SubscribeEvent
@SuppressWarnings("unused")
public void onRightClick(MouseEvent event) {
    EntityPlayerSP player = Minecraft.getMinecraft().player;
    ItemStack stack = player.getHeldItemMainhand();
    if(event.getButton() != RMB) {
        return;
    }
    rightButtonPressed = !rightButtonPressed;
    if(stack == null) {
        return;
    }
    if(stack.getItem() instanceof IDualWieldedWeapon) {
        if(rightButtonPressed) {
            boolean shift = Minecraft.getMinecraft().gameSettings.keyBindSneak.isKeyDown();
            boolean ctrl = Minecraft.getMinecraft().gameSettings.keyBindSprint.isKeyDown();
            IDualWieldedWeapon weapon = (IDualWieldedWeapon) stack.getItem();
            attackEntity(weapon, player, stack, false, shift, ctrl, EnumHand.MAIN_HAND);
            weapon.onItemUsed(stack, player, shift, ctrl, EnumHand.MAIN_HAND);
            new MessageMouseButtonPressed(false, shift, ctrl).sendToServer();
            Minecraft.getMinecraft().player.swingArm(EnumHand.MAIN_HAND);
        }
        event.setResult(Event.Result.DENY);
        event.setCanceled(true);
    }
}
 
開發者ID:InfinityRaider,項目名稱:InfinityLib,代碼行數:27,代碼來源:MouseClickHandler.java

示例8: onMouseInput

import net.minecraftforge.client.event.MouseEvent; //導入依賴的package包/類
@SubscribeEvent
public void onMouseInput(MouseEvent event) {
    if (WigMod.ActivePage == null || WigMod.ActiveTool != null) {
        return;
    }

    event.setCanceled(true);

    Minecraft mc = Minecraft.getMinecraft();

    if (event.dwheel != 0) {
        int diff = (event.dwheel > 0)?-1:1;
        WigMod.ActivePage.setToolIndex(Math.floorMod(WigMod.ActivePage.getToolIndex() + diff, 9));
    } else if (event.button == 0 && WigMod.ActivePage.getSelectedTool() != null && event.buttonstate) {
        WigMod.ActiveTool = WigMod.ActivePage.getSelectedTool();
    } else if (event.button == 1 && event.buttonstate) {
        WigMod.ActivePage = null;
        GuiIngameForge.renderHotbar = true;
        mc.ingameGUI.remainingHighlightTicks = 40;
    }
}
 
開發者ID:CannibalVox,項目名稱:wig,代碼行數:22,代碼來源:SingleBarInputHandler.java

示例9: onMouseInput

import net.minecraftforge.client.event.MouseEvent; //導入依賴的package包/類
@SubscribeEvent
public void onMouseInput(MouseEvent event) {
    if (WigMod.ActiveTool == null) {
        return;
    }

    event.setCanceled(true);

    if (event.dwheel != 0) {
        boolean direction = event.dwheel > 0;
        WigMod.ActiveTool.getState().cycleOptionState(WigMod.ActiveTool.getState().getCurrentOption(), )
    } else if (event.button == 1 && event.buttonstate) {
        WigMod.ActiveTool = null;
    } else if (event.button == 0 && event.buttonstate) {
        //Run behavior
    }
}
 
開發者ID:CannibalVox,項目名稱:wig,代碼行數:18,代碼來源:SingleToolInputHandler.java

示例10: onMouseInput

import net.minecraftforge.client.event.MouseEvent; //導入依賴的package包/類
@SubscribeEvent
public void onMouseInput(MouseEvent event) {
	Page page = book.getPages()[book.getCurrentPage()];
	for (Entry entry : page.getEntries())
		if (entry instanceof InteractiveEntry) {
			int offsetX = 0, offsetY = 0;
			TwoDimensionalVector startCoords = entry.getCoords();
			if (!entry.useAbsoluteCoords)
				try {
					ScaledResolution resolution = GuiUtils.getCurrentResolution();
					BufferedImage backgroundImage = ImageIO.read(GuiUtils.getResourceAsStream(book.getBackground()));
					int backgroundWidth = backgroundImage.getWidth();
					int backgroundHeight = backgroundImage.getHeight();
					offsetX = (resolution.getScaledWidth() - backgroundWidth) / 2;
					offsetY = (resolution.getScaledHeight() - backgroundHeight) / 2;
					startCoords = startCoords.add(new TwoDimensionalVector(offsetX, offsetY));
				} catch (Exception e) {
					e.printStackTrace();
				}
			if (event.x >= startCoords.getRoundedX() && event.x <= startCoords.getRoundedX()+entry.width 
					&& event.y >= startCoords.getRoundedY() && event.y <= entry.height)
				((InteractiveEntry) entry).onMouseEvent(event.x-offsetX, event.y-offsetY, event.dx, event.dy, event.button, event.dwheel, event.buttonstate);
		}
}
 
開發者ID:austinv11,項目名稱:CollectiveFramework,代碼行數:25,代碼來源:GuiBook.java

示例11: 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

示例12: 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

示例13: 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

示例14: onMouseEvent

import net.minecraftforge.client.event.MouseEvent; //導入依賴的package包/類
@SubscribeEvent
public void onMouseEvent(MouseEvent evt)
{
	Minecraft mc = Minecraft.getMinecraft();
	EntityPlayer thePlayer = mc.thePlayer;

	if (evt.button == 0)
	{
		ItemStack stack = thePlayer.getCurrentEquippedItem();
		InventoryAttachment att = InventoryAttachment.create(stack);
		if (att != null)
		{
			showScopeOverlap = stack != null && (att.isScopePresent() || stack.getItem()
					.equals(ARKCraftItems.spy_glass)) && evt.buttonstate;
			selected = stack;
			if (stack != null && att.isScopePresent()) evt.setCanceled(true);
		}
	}
}
 
開發者ID:Archiving,項目名稱:ARKCraft-Code,代碼行數:20,代碼來源:ClientEventHandler.java

示例15: onMouseEvent

import net.minecraftforge.client.event.MouseEvent; //導入依賴的package包/類
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onMouseEvent(MouseEvent event) {

    // We only want to process wheel events
    if (event.button < 0) {
        EntityPlayer entityPlayer = Minecraft.getMinecraft().thePlayer;
        if (entityPlayer.isSneaking()) {
            ItemStack itemStack = entityPlayer.getHeldItem();
            if (itemStack != null && itemStack.getItem() == this) {
                if (event.dwheel != 0)
                    NetworkHandler.instance().sendToServer(new PacketWrenchMode(entityPlayer.inventory.currentItem, event.dwheel < 0));
                event.setCanceled(true);
            }
        }
    }
}
 
開發者ID:amadornes,項目名稱:Framez,代碼行數:18,代碼來源:ItemWrench.java


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