net.minecraftforge.client.event.MouseEvent Java Examples

The following examples show how to use net.minecraftforge.client.event.MouseEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DragonsFuck.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    MovingObjectPosition mop = Wrapper.INSTANCE.mc().objectMouseOver;
    if (mop.sideHit == -1) {
        return;
    }
    if (Mouse.isButtonDown(1)) {
        TileEntity entity = Wrapper.INSTANCE.world().getTileEntity(mop.blockX, mop.blockY, mop.blockZ);
        try {
            if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && entity != null && Class.forName("eu.thesociety.DragonbornSR.DragonsRadioMod.Block.TileEntity.TileEntityRadio").isInstance(entity)) {
                Wrapper.INSTANCE.mc().displayGuiScreen((GuiScreen) Class.forName("eu.thesociety.DragonbornSR.DragonsRadioMod.Block.Gui.NGuiRadio").getConstructor(Class.forName("eu.thesociety.DragonbornSR.DragonsRadioMod.Block.TileEntity.TileEntityRadio")).newInstance(entity));
                InteropUtils.log("Gui opened", this);
                if (event.isCancelable()) {
                    event.setCanceled(true);
                }
            }
        } catch (Exception ex) {
            InteropUtils.log("&cError", this);
        }
    }
}
 
Example #2
Source File: ItemWrench.java    From Framez with GNU General Public License v3.0 6 votes vote down vote up
@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);
            }
        }
    }
}
 
Example #3
Source File: ItemFairyBell.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void onScroll(MouseEvent event) {
	EntityPlayer player = Minecraft.getMinecraft().player;
	if (player == null) return;

	if (Keyboard.isCreated() && event.getDwheel() != 0) {

		for (EnumHand hand : EnumHand.values()) {
			ItemStack stack = player.getHeldItem(hand);

			if (stack.getItem() != ModItems.FAIRY_BELL)
				continue;


			IMiscCapability cap = MiscCapabilityProvider.getCap(Minecraft.getMinecraft().player);
			if (cap == null) continue;

			cap.setSelectedFairy(null);

			PacketHandler.NETWORK.sendToServer(new PacketUpdateMiscCapToServer(cap.serializeNBT()));
		}
	}
}
 
Example #4
Source File: ManualDeleteMod.java    From ForgeHax with MIT License 6 votes vote down vote up
@SubscribeEvent
public void onInput(MouseEvent event) {
  if (getWorld() == null || getLocalPlayer() == null) {
    return;
  }
  
  if (event.getButton() == 2 && Mouse.getEventButtonState()) { // on middle click
    RayTraceResult aim = MC.objectMouseOver;
    if (aim == null) {
      return;
    }
    if (aim.typeOfHit == RayTraceResult.Type.ENTITY) {
      if (aim.entityHit != null) {
        MC.world.removeEntity(aim.entityHit);
      }
    }
  }
}
 
Example #5
Source File: ShowContainer.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    try {
        boolean nowState = Mouse.isButtonDown(1);
        MovingObjectPosition position = Wrapper.INSTANCE.mc().objectMouseOver;
        if (position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && !prevState && nowState) {
            TileEntity tileEntity = Wrapper.INSTANCE.world().getTileEntity(position.blockX, position.blockY, position.blockZ);
            if (tileEntity instanceof IInventory) {
                ItemStack[] stacks = new ItemStack[0];
                Wrapper.INSTANCE.mc().displayGuiScreen(new ShowContainerGui(new ShowContainerContainer(stacks, tileEntity.getClass().getSimpleName())));
                if (event.isCancelable()) {
                    event.setCanceled(true);
                }
            } else {
                InteropUtils.log("Not a container", this);
            }
        }
        prevState = nowState;
    } catch (Exception ignored) {

    }
}
 
Example #6
Source File: FakeDestroy.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    try {
        boolean nowState = Mouse.isButtonDown(0);
        MovingObjectPosition position = Wrapper.INSTANCE.mc().objectMouseOver;
        if (position.sideHit != -1 && !prevState && nowState) {
            removedBlocks.add(new BlockInfo(new int[]{position.blockX, position.blockY, position.blockZ}, Wrapper.INSTANCE.world().getBlock(position.blockX, position.blockY, position.blockZ), Wrapper.INSTANCE.world().getBlockMetadata(position.blockX, position.blockY, position.blockZ)));
            Wrapper.INSTANCE.world().setBlockToAir(position.blockX, position.blockY, position.blockZ);
            if (event.isCancelable()) {
                event.setCanceled(true);
            }
        }
        prevState = nowState;
    } catch (Exception ignored) {

    }
}
 
Example #7
Source File: NoLimitDamage.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    if (Wrapper.INSTANCE.mc().objectMouseOver.entityHit != null && event.button == 0 && !lastPressed) {
        int playerId = Wrapper.INSTANCE.player().getEntityId();
        int entityId = Wrapper.INSTANCE.mc().objectMouseOver.entityHit.getEntityId();
        int dimensionId = Wrapper.INSTANCE.player().dimension;
        ByteBuf buf = Unpooled.buffer(0);
        buf.writeByte(0);
        buf.writeInt(entityId);
        buf.writeInt(playerId);
        buf.writeInt(dimensionId);
        buf.writeFloat(Float.MAX_VALUE);
        buf.writeBoolean(false);
        C17PacketCustomPayload packet = new C17PacketCustomPayload("taintedmagic", buf);
        Wrapper.INSTANCE.player().sendQueue.addToSendQueue(packet);
        lastPressed = true;
    }
    if (lastPressed && event.button == 0 && !event.buttonstate) {
        lastPressed = false;
    }
}
 
Example #8
Source File: SpaceFire.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    try {
        MovingObjectPosition position = Wrapper.INSTANCE.mc().objectMouseOver;
        if (position.entityHit instanceof EntityLivingBase && Mouse.isButtonDown(0)) {
            Object packetPipeLine = Class.forName("micdoodle8.mods.galacticraft.core.GalacticraftCore").getField("packetPipeline").get(null);
            Method sendMethod = packetPipeLine.getClass().getMethod("sendToServer", Class.forName("micdoodle8.mods.galacticraft.core.network.IPacket"));
            Object packetObj = Class.forName("micdoodle8.mods.galacticraft.core.network.PacketSimple").getConstructor(new Class[]{Class.forName("micdoodle8.mods.galacticraft.core.network.PacketSimple$EnumSimplePacket"), Object[].class}).newInstance(Class.forName("micdoodle8.mods.galacticraft.core.network.PacketSimple$EnumSimplePacket").getMethod("valueOf", String.class).invoke(null, "S_SET_ENTITY_FIRE"), new Object[]{position.entityHit.getEntityId()});
            sendMethod.invoke(packetPipeLine, packetObj);
            if (event.isCancelable()) {
                event.setCanceled(true);
            }
        }
    } catch (Exception e) {

    }
}
 
Example #9
Source File: CarpenterOpener.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    try {
        MovingObjectPosition position = Wrapper.INSTANCE.mc().objectMouseOver;
        if (position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && Mouse.isButtonDown(1)) {
            if (event.isCancelable()) {
                event.setCanceled(true);
            }
            ByteBuf buf = Unpooled.buffer(0);
            buf.writeInt(0);
            buf.writeInt(position.blockX);
            buf.writeInt(position.blockY);
            buf.writeInt(position.blockZ);
            buf.writeInt(position.sideHit);
            C17PacketCustomPayload packet = new C17PacketCustomPayload("CarpentersBlocks", buf);
            Wrapper.INSTANCE.player().sendQueue.addToSendQueue(packet);
        }
    } catch (Exception e) {

    }
}
 
Example #10
Source File: ExtendedDestroyer.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    try {
        MovingObjectPosition position = Wrapper.INSTANCE.mc().objectMouseOver;
        boolean nowState = Mouse.isButtonDown(0);
        if (position.sideHit != -1 && nowState && !prevState) {
            ByteBuf buf = Unpooled.buffer(0);
            buf.writeByte(14);
            buf.writeInt(position.blockX);
            buf.writeInt(position.blockY);
            buf.writeInt(position.blockZ);
            C17PacketCustomPayload packet = new C17PacketCustomPayload("cfm", buf);
            Wrapper.INSTANCE.player().sendQueue.addToSendQueue(packet);
        }
        prevState = nowState;
    } catch (Exception ignored) {

    }
}
 
Example #11
Source File: BlockTrackUpgradeHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public boolean scroll(MouseEvent event){
    for(RenderBlockTarget target : blockTargets) {
        if(target.scroll(event)) {
            getAnimatedStat().handleMouseWheel(event.dwheel);
            return true;
        }
    }
    return false;
}
 
Example #12
Source File: Events.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onMouse(MouseEvent event) {
    if (!cheatEnabled) {
        return;
    }
    ModuleController.INSTANCE.modules.stream().filter((mod) -> !(!mod.isActive() || Wrapper.INSTANCE.world() == null)).forEachOrdered((mod) -> {
        mod.onMouse(event);
    });
}
 
Example #13
Source File: HUDHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onMouseEvent(MouseEvent event){
    boolean isCaptured = false;
    isCaptured = getSpecificRenderer(BlockTrackUpgradeHandler.class).scroll(event);
    if(!isCaptured) isCaptured = getSpecificRenderer(EntityTrackUpgradeHandler.class).scroll(event);
    if(isCaptured) event.setCanceled(true);
}
 
Example #14
Source File: SignTextMod.java    From ForgeHax with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onInput(MouseEvent event) {
  if (event.getButton() == 2 && Mouse.getEventButtonState()) { // on middle click
    RayTraceResult result = MC.player.rayTrace(999, 0);
    if (result == null) {
      return;
    }
    if (result.typeOfHit == RayTraceResult.Type.BLOCK) {
      TileEntity tileEntity = MC.world.getTileEntity(result.getBlockPos());
      
      if (tileEntity instanceof TileEntitySign) {
        TileEntitySign sign = (TileEntitySign) tileEntity;
        
        int signTextLength = 0;
        // find the first line from the bottom that isn't empty
        for (int i = 3; i >= 0; i--) {
          if (!sign.signText[i].getUnformattedText().isEmpty()) {
            signTextLength = i + 1;
            break;
          }
        }
        if (signTextLength == 0) {
          return; // if the sign is empty don't do anything
        }
        
        String[] lines = new String[signTextLength];
        
        for (int i = 0; i < signTextLength; i++) {
          lines[i] =
              sign.signText[i].getFormattedText().replace(TextFormatting.RESET.toString(), "");
        }
        
        String fullText = String.join("\n", lines);
        
        Helper.printMessage("Copied sign");
        setClipboardString(fullText);
      }
    }
  }
}
 
Example #15
Source File: MusicalCrash.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    MovingObjectPosition mop = Wrapper.INSTANCE.mc().objectMouseOver;
    if (mop.sideHit == -1) {
        return;
    }
    boolean nowState = Mouse.isButtonDown(1);
    if (!prevState && nowState) {
        prevState = nowState;
        TileEntity entity = Wrapper.INSTANCE.world().getTileEntity(mop.blockX, mop.blockY, mop.blockZ);
        try {
            if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && entity != null && !Class.forName("eu.thesociety.DragonbornSR.DragonsRadioMod.Block.TileEntity.TileEntityRadio").isInstance(entity)) {
                ByteBuf buf = Unpooled.buffer(0);
                buf.writeByte(0);
                buf.writeInt(0);
                buf.writeDouble(mop.blockX);
                buf.writeDouble(mop.blockY);
                buf.writeDouble(mop.blockZ);
                buf.writeInt(Wrapper.INSTANCE.player().dimension);
                buf.writeInt(0);
                buf.writeBytes(new byte[0]);
                buf.writeBoolean(false);
                buf.writeFloat(0);
                buf.writeDouble(0);
                buf.writeDouble(0);
                buf.writeDouble(0);
                C17PacketCustomPayload packet = new C17PacketCustomPayload("DragonsRadioMod", buf);
                Wrapper.INSTANCE.player().sendQueue.addToSendQueue(packet);
                InteropUtils.log("Crash sent", this);
                if (event.isCancelable()) {
                    event.setCanceled(true);
                }
            }
        } catch (Exception ex) {
            InteropUtils.log("Error happened", this);
        }
    }
    prevState = nowState;
}
 
Example #16
Source File: RenderBlockTarget.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public boolean scroll(MouseEvent event){
    if(isInitialized() && isPlayerLookingAtTarget()) {
        return stat.handleMouseWheel(event.dwheel);
    }
    return false;
}
 
Example #17
Source File: RenderTarget.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public boolean scroll(MouseEvent event){
    if(isInitialized() && isPlayerLookingAtTarget()) {
        return stat.handleMouseWheel(event.dwheel);
    }
    return false;
}
 
Example #18
Source File: EntityTrackUpgradeHandler.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public boolean scroll(MouseEvent event){
    for(RenderTarget target : targets) {
        if(target.scroll(event)) return true;
    }
    return false;
}
 
Example #19
Source File: InputEventHandler.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@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));
            }
        }
    }
    else if (this.onInputEvent(Mouse.getEventButton() - 100, Mouse.getEventButtonState()))
    {
        event.setCanceled(true);
    }
}
 
Example #20
Source File: Module.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
public void onMouse(MouseEvent event) {
}
 
Example #21
Source File: EndPort.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    if (event.button == 1 && event.buttonstate) {

        if (selectedEnt != null) {
            Wrapper.INSTANCE.world().removeEntityFromWorld(-2);
            selectedEnt = null;
            distVec = null;
            if (event.isCancelable()) {
                event.setCanceled(true);
            }
            return;
        }
        selectedEnt = getMouseOver(1f, 500, false);
        if (!(selectedEnt instanceof EntityFakePlayer)) {
            if (selectedEnt != null) {
                distVec = Wrapper.INSTANCE.mc().renderViewEntity.getLookVec().normalize();
                size = Wrapper.INSTANCE.mc().renderViewEntity.getPosition(1f).distanceTo(Vec3.createVectorHelper(selectedEnt.posX, selectedEnt.posY, selectedEnt.posZ));
                distVec.xCoord *= size;
                distVec.yCoord *= size;
                distVec.zCoord *= size;
                if (event.isCancelable()) {
                    event.setCanceled(true);
                }
            } else {
                distVec = null;
            }
        }
    }
    if (selectedEnt != null) {
        if (event.dwheel > 0) {
            size = Math.min(size + event.dwheel / 120f, 200f);
            if (event.isCancelable()) {
                event.setCanceled(true);
            }
        } else if (event.dwheel < 0) {
            size = Math.max(size + event.dwheel / 120f, 1f);
            if (event.isCancelable()) {
                event.setCanceled(true);
            }
        }
    }
    if (event.button == 0) {
        if (selectedEnt != null) {
            tpEntity(selectedEnt, (int) Math.round(Wrapper.INSTANCE.mc().renderViewEntity.posX + distVec.xCoord), (int) Math.round(Wrapper.INSTANCE.mc().renderViewEntity.posY + distVec.yCoord - ((selectedEnt instanceof EntityPlayer) ? 2 : 0)), (int) Math.round(Wrapper.INSTANCE.mc().renderViewEntity.posZ + distVec.zCoord));
            selectedEnt = null;
            distVec = null;
            if (event.isCancelable()) {
                event.setCanceled(true);
            }
        }
    }
}
 
Example #22
Source File: SelfEnd.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    if (event.button == 2 && event.buttonstate) {

        if (selectedEnt != null) {
            Wrapper.INSTANCE.world().removeEntityFromWorld(-2);
            selectedEnt = null;
            distVec = null;
            if (event.isCancelable()) {
                event.setCanceled(true);
            }
            return;
        }
        selectedEnt = Wrapper.INSTANCE.player();
        if (!(selectedEnt instanceof EntityFakePlayer)) {
            if (selectedEnt != null) {
                distVec = Wrapper.INSTANCE.mc().renderViewEntity.getLookVec().normalize();
                size = 3f;
                distVec.xCoord *= size;
                distVec.yCoord *= size;
                distVec.zCoord *= size;
                if (event.isCancelable()) {
                    event.setCanceled(true);
                }
            } else {
                distVec = null;
            }
        }
    }
    if (selectedEnt != null) {
        if (event.dwheel > 0) {
            size = Math.min(size + event.dwheel / 120f, 200f);
            if (event.isCancelable()) {
                event.setCanceled(true);
            }
        } else if (event.dwheel < 0) {
            size = Math.max(size + event.dwheel / 120f, 1f);
            if (event.isCancelable()) {
                event.setCanceled(true);
            }
        }
    }
    if (distVec != null) {
        distVec = Wrapper.INSTANCE.mc().renderViewEntity.getLookVec().normalize();
        distVec.xCoord *= size;
        distVec.yCoord *= size;
        distVec.zCoord *= size;
    }
    if (event.button == 0) {
        if (selectedEnt != null) {
            tpEntity(selectedEnt, (int) Math.round(Wrapper.INSTANCE.mc().renderViewEntity.lastTickPosX + distVec.xCoord), (int) Math.round(Wrapper.INSTANCE.mc().renderViewEntity.lastTickPosY + distVec.yCoord - 2), (int) Math.round(Wrapper.INSTANCE.mc().renderViewEntity.lastTickPosZ + distVec.zCoord));
            selectedEnt = null;
            distVec = null;
            if (event.isCancelable()) {
                event.setCanceled(true);
            }
        }
    }
}
 
Example #23
Source File: SelfRf.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    if (event.button == 2 && event.buttonstate) {

        if (selectedEnt != null) {
            Wrapper.INSTANCE.world().removeEntityFromWorld(-2);
            selectedEnt = null;
            distVec = null;
            if (event.isCancelable()) {
                event.setCanceled(true);
            }
            return;
        }
        selectedEnt = Wrapper.INSTANCE.player();
        if (!(selectedEnt instanceof EntityFakePlayer)) {
            if (selectedEnt != null) {
                distVec = Wrapper.INSTANCE.mc().renderViewEntity.getLookVec().normalize();
                size = 3f;
                distVec.xCoord *= size;
                distVec.yCoord *= size;
                distVec.zCoord *= size;
                if (event.isCancelable()) {
                    event.setCanceled(true);
                }
            } else {
                distVec = null;
            }
        }
    }
    if (selectedEnt != null) {
        if (event.dwheel > 0) {
            size = Math.min(size + event.dwheel / 120f, 200f);
            if (event.isCancelable()) {
                event.setCanceled(true);
            }
        } else if (event.dwheel < 0) {
            size = Math.max(size + event.dwheel / 120f, 1f);
            if (event.isCancelable()) {
                event.setCanceled(true);
            }
        }
    }
    if (distVec != null) {
        distVec = Wrapper.INSTANCE.mc().renderViewEntity.getLookVec().normalize();
        distVec.xCoord *= size;
        distVec.yCoord *= size;
        distVec.zCoord *= size;
    }
    if (event.button == 0) {
        if (selectedEnt != null) {
            tpEntity(selectedEnt, (int) Math.round(Wrapper.INSTANCE.mc().renderViewEntity.lastTickPosX + distVec.xCoord), (int) Math.round(Wrapper.INSTANCE.mc().renderViewEntity.lastTickPosY + distVec.yCoord - 2), (int) Math.round(Wrapper.INSTANCE.mc().renderViewEntity.lastTickPosZ + distVec.zCoord), Wrapper.INSTANCE.player().dimension);
            selectedEnt = null;
            distVec = null;
            if (event.isCancelable()) {
                event.setCanceled(true);
            }
        }
    }
}
 
Example #24
Source File: RocketChaos.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {
    if (Mouse.isButtonDown(0)) {
        sendRocket(0);
    }
}
 
Example #25
Source File: ContainerClear.java    From ehacks-pro with GNU General Public License v3.0 2 votes vote down vote up
@Override
public void onMouse(MouseEvent event) {

}