Java 类net.minecraftforge.client.event.MouseEvent 实例源码

项目:rezolve    文件:RemoteShellOverlay.java   
@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;
    }
}
项目:bit-client    文件:ModuleAutoclicker.java   
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) {
    }
}
项目:Whoosh    文件:EventHandlerClient.java   
@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);
            }
        }
    }
}
项目:CrystalMod    文件:ClientEventHandler.java   
@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);
            }
        }
    }
}
项目:Toms-Mod    文件:KeyInputHandler.java   
@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));
                }
            }
        }
    }
}
项目:InfinityLib    文件:MouseClickHandler.java   
@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);
    }
}
项目:InfinityLib    文件:MouseClickHandler.java   
@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);
    }
}
项目:wig    文件:SingleBarInputHandler.java   
@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;
    }
}
项目:wig    文件:SingleToolInputHandler.java   
@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
    }
}
项目:CollectiveFramework    文件:GuiBook.java   
@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);
        }
}
项目:Culinary-Cultivation    文件:ItemDebugItem.java   
@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);
            }
        }
    }
}
项目:Cyclic    文件:EventKeyInput.java   
@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);
  }
}
项目:ClockworkPhase2    文件:MouseInputHandler.java   
@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);
            }
    }
}
项目:ARKCraft-Code    文件:ClientEventHandler.java   
@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);
        }
    }
}
项目:Framez    文件:ItemWrench.java   
@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);
            }
        }
    }
}
项目:ZeroQuest    文件:FireEventHandler.java   
@SubscribeEvent
public void onMouseEvent(MouseEvent event) {
    int button = event.button - 100;
    Minecraft mc = Minecraft.getMinecraft();
    EntityPlayer player = mc.thePlayer;
    World world = mc.theWorld;
    int key = mc.gameSettings.keyBindAttack.getKeyCode();

    BlockPos pos = mc.objectMouseOver.getBlockPos();
    EnumFacing face = mc.objectMouseOver.sideHit;

    if ((button == key) && (Mouse.isButtonDown(button + 100))) {
        if (pos != null) {
            if (world.getBlockState(pos).getBlock() != null) {
                this.extinguishFire(player, pos, face, world, event, button);
            }
        }
    }
}
项目:ZeroQuest    文件:FireEventHandler.java   
private void extinguishFire(EntityPlayer player, BlockPos posIn, EnumFacing face, World world, Event event, int key) {
    BlockPos pos = posIn.offset(face);

    if (world.getBlockState(pos).getBlock() == ModBlocks.nileFire) {
        if ((event instanceof MouseEvent) || (event instanceof PlayerInteractEvent)) {
            PacketHandler.sendToServer(new FireSound(player, face, pos));
            event.setCanceled(true);
        }
        else if (event instanceof KeyInputEvent) {
            player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Please contact the modder of Zero Quest if you are trying to put out a fire " + EnumChatFormatting.RED + "using a key on your keyboard as your attack key."));
        }
    }
    else if (world.getBlockState(pos).getBlock() == ModBlocks.darkFire) {
        if ((event instanceof MouseEvent) || (event instanceof PlayerInteractEvent)) {
            PacketHandler.sendToServer(new FireSound(player, face, pos));
            event.setCanceled(true);
        }
        else if (event instanceof KeyInputEvent) {
            player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Please contact the modder of Zero Quest if you are trying to put out a fire " + EnumChatFormatting.RED + "using a key on your keyboard as your attack key."));
        }
    }
}
项目:AbyssalCraft    文件:AbyssalCraftClientEventHooks.java   
@SubscribeEvent
public void onMouseEvent(MouseEvent event) {
    int button = event.getButton() - 100;
    Minecraft mc = Minecraft.getMinecraft();
    EntityPlayer player = mc.player;
    World world = mc.world;
    int key = mc.gameSettings.keyBindAttack.getKeyCode();

    if (button == key && Mouse.isButtonDown(button + 100))
        if(mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == Type.BLOCK){
            BlockPos pos = mc.objectMouseOver.getBlockPos();
            EnumFacing face = mc.objectMouseOver.sideHit;
            if(pos != null && face != null)
                if (world.getBlockState(pos).getBlock() != null)
                    extinguishFire(player, pos, face, world, event);
        }
}
项目:Dimensional-Pockets    文件:ClientEventHandler.java   
@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);
                }
            }
        }
    }
}
项目:carpentersblocks    文件:EventHandler.java   
@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);
            }
        }
    }
}
项目:TheMinersFriend    文件:ToolBeltMouseWheelHandler.java   
@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);
        }
    }
}
项目:pnc-repressurized    文件:BlockTrackUpgradeHandler.java   
public boolean scroll(MouseEvent event) {
    for (RenderBlockTarget target : blockTargets) {
        if (target.scroll(event)) {
            getAnimatedStat().handleMouseWheel(event.getDwheel());
            return true;
        }
    }
    return false;
}
项目:Infernum    文件:RenderKnowledgeTome.java   
@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;
        }
    }

}
项目:Mods    文件:TF2EventsClient.java   
@SubscribeEvent
public void mousePress(MouseEvent event) {
    if (event.getButton() != -1) {
        Minecraft minecraft = Minecraft.getMinecraft();
        if (minecraft.player != null && !minecraft.player.getHeldItemMainhand().isEmpty())
            if (minecraft.player.getHeldItemMainhand().getItem() instanceof ItemUsable) {
                KeyBinding.setKeyBindState(event.getButton() - 100, event.isButtonstate());
                keyPressUpdate(minecraft.gameSettings.keyBindAttack.isKeyDown(), minecraft.gameSettings.keyBindUseItem.isKeyDown());
            }
    }
}
项目:SignPicture    文件:SignHandler.java   
@CoreEvent
public void onClick(final @Nonnull MouseEvent event) {
    if (event.buttonstate&&Client.mc.gameSettings.keyBindUseItem.getKeyCode()==event.button-100) {
        final ItemStack handItem = Client.mc.thePlayer.getCurrentEquippedItem();
        EntryId handEntry = null;
        if (handItem!=null&&handItem.getItem()==Items.sign) {
            handEntry = ItemEntryId.fromItemStack(handItem);
            CurrentMode.instance.setHandSign(handEntry);
        } else
            CurrentMode.instance.setHandSign(EntryId.blank);
        if (CurrentMode.instance.isMode(CurrentMode.Mode.SETPREVIEW)) {
            Sign.preview.capturePlace();
            event.setCanceled(true);
            CurrentMode.instance.setMode();
            Client.openEditor();
        } else if (CurrentMode.instance.isMode(CurrentMode.Mode.OPTION)) {
            final TileEntitySign tilesign = Client.getTileSignLooking();
            Entry entry = null;
            if (tilesign!=null)
                entry = SignEntryId.fromTile(tilesign).entry();
            else if (handEntry!=null)
                entry = handEntry.entry();
            if (entry!=null) {
                event.setCanceled(true);
                Client.mc.displayGuiScreen(new GuiSignOption(entry));
                if (!CurrentMode.instance.isState(CurrentMode.State.CONTINUE))
                    CurrentMode.instance.setMode();
            }
        }
    }
}
项目:InspiringWorld    文件:Overlay.java   
@SubscribeEvent
public void mouse(MouseEvent event)
{
    if (!enable) return;
    int x = (int) (currentX + event.getDx() * factor);
    int y = (int) (currentY - event.getDy() * factor);
    if (range.contains(x, y))
    {
        currentX = x;
        currentY = y;
    }
}
项目:CommonUtils    文件:KeyBindingManager.java   
@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;
                }
            }
        }
    }
}
项目:TMT-Refraction    文件:EventHandlerClient.java   
@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);
        }
    }
}
项目:Zoom    文件:EventHandler.java   
@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);
    }
}
项目:Kingdom-Keys-Re-Coded    文件:InputHandler.java   
@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);
    }

}
项目:rpginventory    文件:MouseHandler.java   
@SubscribeEvent
public void mouse(MouseEvent ev){
    EntityPlayer p = Minecraft.getMinecraft().thePlayer;
    PlayerRpgInventory inv = PlayerRpgInventory.get(p);

    if(inv.getShield() == null)
        return;
    if(ev.button == 0 && PlayerRpgInventory.get(Minecraft.getMinecraft().thePlayer).isBlocking()){
        ev.setCanceled(true);
    }
}
项目:enderutilities    文件:InputEventHandler.java   
@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));
            }
        }
    }
}
项目:AbyssalCraft    文件:AbyssalCraftClientEventHooks.java   
private void extinguishFire(EntityPlayer player, BlockPos posIn, EnumFacing face, World world, Event event) {
    BlockPos pos = posIn.offset(face);

    if (world.getBlockState(pos).getBlock() == ACBlocks.mimic_fire ||
            world.getBlockState(pos).getBlock() == ACBlocks.coralium_fire ||
            world.getBlockState(pos).getBlock() == ACBlocks.dreaded_fire ||
            world.getBlockState(pos).getBlock() == ACBlocks.omothol_fire)
        if (event instanceof MouseEvent) {
            PacketDispatcher.sendToServer(new FireMessage(pos));
            PacketDispatcher.sendToAllAround(new FireMessage(pos), player, 30);
            event.setCanceled(true);
        }
}
项目:SecurityCraft    文件:SCEventHandler.java   
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onMouseClicked(MouseEvent event) {
    if(Minecraft.getMinecraft().theWorld != null)
        if(PlayerUtils.isPlayerMountedOnCamera(Minecraft.getMinecraft().thePlayer))
            event.setCanceled(true);
}
项目:SecurityCraft    文件:SCEventHandler.java   
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onMouseClicked(MouseEvent event) {
    if(Minecraft.getMinecraft().world != null)
        if(PlayerUtils.isPlayerMountedOnCamera(Minecraft.getMinecraft().player))
            event.setCanceled(true);
}
项目:SecurityCraft    文件:SCEventHandler.java   
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onMouseClicked(MouseEvent event) {
    if(Minecraft.getMinecraft().theWorld != null)
        if(PlayerUtils.isPlayerMountedOnCamera(Minecraft.getMinecraft().thePlayer))
            event.setCanceled(true);
}
项目:SecurityCraft    文件:SCEventHandler.java   
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onMouseClicked(MouseEvent event) {
    if(Minecraft.getMinecraft().theWorld != null)
        if(PlayerUtils.isPlayerMountedOnCamera(Minecraft.getMinecraft().thePlayer))
            event.setCanceled(true);
}
项目:SecurityCraft    文件:SCEventHandler.java   
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onMouseClicked(MouseEvent event) {
    if(Minecraft.getMinecraft().world != null)
        if(PlayerUtils.isPlayerMountedOnCamera(Minecraft.getMinecraft().player))
            event.setCanceled(true);
}
项目:SecurityCraft    文件:SCEventHandler.java   
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onMouseClicked(MouseEvent event) {
    if(Minecraft.getMinecraft().theWorld != null)
        if(PlayerUtils.isPlayerMountedOnCamera(Minecraft.getMinecraft().thePlayer))
            event.setCanceled(true);
}
项目:CubesEdge    文件:MovementWallJump.java   
@SubscribeEvent
public void onClick(MouseEvent event) {
    if (((EntityPlayerCustom) Minecraft.getMinecraft().thePlayer
            .getExtendedProperties("Cube's Edge Player")).animLeft
            || ((EntityPlayerCustom) Minecraft.getMinecraft().thePlayer
                    .getExtendedProperties("Cube's Edge Player")).animRight) {
        event.setCanceled(true);
    }
}