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


Java MouseEvent.setCanceled方法代碼示例

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


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

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

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

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

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

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

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

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

示例12: onMouseEvent

import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onMouseEvent(MouseEvent event) {
	if (event.buttonstate && (event.button == 0 || event.button == 1)) {
		EntityPlayer player = Minecraft.getMinecraft().thePlayer;
		if (player != null && player.isSneaking() && player.worldObj.provider.dimensionId == Reference.DIMENSION_ID) {
			ItemStack stack = player.getCurrentEquippedItem();
			// stop EnderIO Travelers Staff from working in a DP
			if (stack != null && "item.itemTravelStaff".equals(stack.getUnlocalizedName())) {
				event.setCanceled(true);
				if (System.currentTimeMillis() > (lastTravelStaffWarningTime + 3000)) { // 3 second nag delay
					lastTravelStaffWarningTime = System.currentTimeMillis();
					ChatComponentText text = new ChatComponentText(Localise.translate("functionality.disabled.in.pocket"));
					text.getChatStyle().setItalic(Boolean.TRUE).setColor(EnumChatFormatting.GRAY);
					player.addChatMessage(text);
				}
			}
		}
	}
}
 
開發者ID:NPException,項目名稱:Dimensional-Pockets,代碼行數:20,代碼來源:ClientEventHandler.java

示例13: onMouseEvent

import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@SideOnly(Side.CLIENT)
@SubscribeEvent
/**
 * Grabs mouse scroll events for slope selection.
 */
public void onMouseEvent(MouseEvent event)
{
    // We only want to process wheel events
    if (event.button < 0)
    {
        EntityPlayer entityPlayer = Minecraft.getMinecraft().thePlayer;

        if (entityPlayer != null && entityPlayer.isSneaking()) {
            ItemStack itemStack = entityPlayer.getHeldItem();
            if (itemStack != null && itemStack.getItem() instanceof ItemBlock && BlockProperties.toBlock(itemStack).equals(BlockRegistry.blockCarpentersSlope)) {
                if (event.dwheel != 0) {
                    PacketHandler.sendPacketToServer(new PacketSlopeSelect(entityPlayer.inventory.currentItem, event.dwheel > 0));
                }
                event.setCanceled(true);
            }
        }
    }
}
 
開發者ID:Mineshopper,項目名稱:carpentersblocks,代碼行數:24,代碼來源:EventHandler.java

示例14: onMouseEvent

import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onMouseEvent(MouseEvent event) {
    int wheel = event.dwheel;
    EntityPlayer entityplayer = FMLClientHandler.instance().getClient().thePlayer;
    World world = entityplayer.getEntityWorld();
    ItemStack heldItem = entityplayer.getHeldItem();
    if (ItemHelper.isToolBelt(heldItem)) {
        if (isScrolling(wheel)) {
            if (wheel > 0) {
                KeyBindings.doToolBeltCycle(CommandLib.CYCLE_TOOLBELT_UP);
                event.setCanceled(true);
            }
            if (wheel < 0) {
                KeyBindings.doToolBeltCycle(CommandLib.CYCLE_TOOLBELT_DOWN);
                event.setCanceled(true);
            }
        }
        if (isRightClicking(event.button)) {
            PacketLib.sendToolBeltGuiRequest(world,
                                             entityplayer);
            event.setCanceled(true);
        }
    }
}
 
開發者ID:SlimeVoid,項目名稱:TheMinersFriend,代碼行數:25,代碼來源:ToolBeltMouseWheelHandler.java

示例15: onMouseClick

import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onMouseClick(MouseEvent event) {
	Minecraft minecraft = Minecraft.getMinecraft();
	EntityPlayer player = minecraft.player;
	if (minecraft.gameSettings.thirdPersonView != 0
			|| player.getHeldItem(EnumHand.MAIN_HAND).func_190916_E() <= 0
			|| player.getHeldItem(EnumHand.MAIN_HAND).getItem() != InfernumItems.KNOWLEDGE_BOOK) {
		return;
	}
	if (!player.getHeldItem(EnumHand.OFF_HAND).equals(ItemStack.field_190927_a)) {
		return;
	}
	if (ticksOpen < 10 || pageFlipTicks > 0) {
		return;
	}
	
	if (event.getButton() == 0 && event.isButtonstate()) {
		event.setCanceled(true);
		if (page > 0 && pageFlipTicks <= 0 && ticksOpen >= 10) {
			page--;
			pageFlipTicks = 10;
			flipPageAngle = -coverAngles;
		}
	}
	if (event.getButton() == 1 && event.isButtonstate()) {
		event.setCanceled(true);
		if (page < totalPages - 1 && pageFlipTicks <= 0 && ticksOpen >= 10) {
			page++;
			pageFlipTicks = 10;
			flipPageAngle = coverAngles;
		}
	}
	
}
 
開發者ID:the-realest-stu,項目名稱:Infernum,代碼行數:36,代碼來源:RenderKnowledgeTome.java


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