Java Code Examples for net.minecraftforge.client.event.MouseEvent#isCancelable()
The following examples show how to use
net.minecraftforge.client.event.MouseEvent#isCancelable() .
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 |
@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: CarpenterOpener.java From ehacks-pro with GNU General Public License v3.0 | 6 votes |
@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 3
Source File: SpaceFire.java From ehacks-pro with GNU General Public License v3.0 | 6 votes |
@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 4
Source File: FakeDestroy.java From ehacks-pro with GNU General Public License v3.0 | 6 votes |
@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 5
Source File: ShowContainer.java From ehacks-pro with GNU General Public License v3.0 | 6 votes |
@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: MusicalCrash.java From ehacks-pro with GNU General Public License v3.0 | 5 votes |
@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 7
Source File: EndPort.java From ehacks-pro with GNU General Public License v3.0 | 4 votes |
@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 8
Source File: SelfEnd.java From ehacks-pro with GNU General Public License v3.0 | 4 votes |
@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 9
Source File: SelfRf.java From ehacks-pro with GNU General Public License v3.0 | 4 votes |
@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 10
Source File: InputEventHandler.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
@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); } }