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