Java源码示例:net.minecraftforge.client.event.MouseEvent

示例1
@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);
        }
    }
}
 
示例2
@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) {

    }
}
 
示例3
@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) {

    }
}
 
示例4
@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) {

    }
}
 
示例5
@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;
    }
}
 
示例6
@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) {

    }
}
 
示例7
@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) {

    }
}
 
示例8
@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);
      }
    }
  }
}
 
示例9
@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()));
		}
	}
}
 
示例10
@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);
            }
        }
    }
}
 
示例11
@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;
}
 
示例12
@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);
    });
}
 
示例13
@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);
      }
    }
  }
}
 
示例14
@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);
}
 
示例15
public boolean scroll(MouseEvent event){
    for(RenderBlockTarget target : blockTargets) {
        if(target.scroll(event)) {
            getAnimatedStat().handleMouseWheel(event.dwheel);
            return true;
        }
    }
    return false;
}
 
示例16
public void onMouse(MouseEvent event) {
}
 
示例17
@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);
            }
        }
    }
}
 
示例18
@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);
            }
        }
    }
}
 
示例19
@Override
public void onMouse(MouseEvent event) {
    if (Mouse.isButtonDown(0)) {
        sendRocket(0);
    }
}
 
示例20
@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);
            }
        }
    }
}
 
示例21
@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);
    }
}
 
示例22
public boolean scroll(MouseEvent event){
    for(RenderTarget target : targets) {
        if(target.scroll(event)) return true;
    }
    return false;
}
 
示例23
public boolean scroll(MouseEvent event){
    if(isInitialized() && isPlayerLookingAtTarget()) {
        return stat.handleMouseWheel(event.dwheel);
    }
    return false;
}
 
示例24
public boolean scroll(MouseEvent event){
    if(isInitialized() && isPlayerLookingAtTarget()) {
        return stat.handleMouseWheel(event.dwheel);
    }
    return false;
}
 
示例25
@Override
public void onMouse(MouseEvent event) {

}