本文整理匯總了Java中net.minecraftforge.client.event.MouseEvent.getButton方法的典型用法代碼示例。如果您正苦於以下問題:Java MouseEvent.getButton方法的具體用法?Java MouseEvent.getButton怎麽用?Java MouseEvent.getButton使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.client.event.MouseEvent
的用法示例。
在下文中一共展示了MouseEvent.getButton方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onMouseEvent
import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@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;
}
}
示例2: 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);
}
}
示例3: 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);
}
}
示例4: 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);
}
}
}
}
示例5: onMouseEvent
import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@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);
}
}
示例6: 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;
}
}
}
示例7: mousePress
import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@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());
}
}
}
示例8: OnMouseWheelScroll
import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@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);
}
}
示例9: onEvent
import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@SideOnly(Side.CLIENT)
@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
public void onEvent(MouseEvent event)
{
if (event.getButton() == 0 && event.isButtonstate())
{
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer thePlayer = mc.thePlayer;
if (thePlayer != null)
{
ItemStack itemstack = thePlayer.getHeldItemMainhand();
IExtendedReach ieri;
if (itemstack != null)
{
if (itemstack.getItem() instanceof IExtendedReach)
{
ieri = (IExtendedReach) itemstack.getItem();
} else
{
ieri = null;
}
if (ieri != null)
{
float reach = ieri.getReach();
RayTraceResult mov = getMouseOverExtended(reach);
if (mov != null)
{
if (mov.entityHit != null && mov.entityHit.hurtResistantTime == 0)
{
if (mov.entityHit != thePlayer )
{
Polearms.network.sendToServer(new MessageExtendedReachAttack(
mov.entityHit.getEntityId()));
}
}
}
}
}
}
}
}
示例10: onEvent
import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@SideOnly(Side.CLIENT)
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
public void onEvent(MouseEvent event) {
if (event.getButton() != 1) {
return;
}
if (!event.isButtonstate()) {
return;
}
EntityPlayer player = Minecraft.getMinecraft().player;
if (player == null) {
return;
}
ItemStack stack = player.getHeldItemMainhand();
if (stack == null || !(stack.getItem() instanceof IExtendedReach)) {
return;
}
IExtendedReach extendedReachItem = (IExtendedReach) stack.getItem();
RayTraceResult raytrace = getMouseOverExtended(extendedReachItem.getReach());
if (raytrace == null) {
return;
}
if (raytrace.entityHit != null) {
ToroChess.NETWORK.sendToServer(new MessageExtendedReachInteract(raytrace.entityHit.getEntityId()));
/*
* send to client
*/
((IExtendedReach) (stack.getItem())).itemInteractionForEntityExtended(stack, player, (EntityLivingBase) raytrace.entityHit,
EnumHand.MAIN_HAND);
} else if (RayTraceResult.Type.BLOCK.equals(raytrace.typeOfHit)) {
ToroChess.NETWORK.sendToServer(new MessageExtendedReachInteract(raytrace.getBlockPos()));
/*
* send to client
*/
Vec3d vec = player.getPositionVector();
((IExtendedReach) (stack.getItem())).onItemUseExtended(player, player.world, raytrace.getBlockPos(), EnumHand.MAIN_HAND, null,
(float) vec.x, (float) vec.y, (float) vec.z);
}
}
示例11: onMouseEvent
import net.minecraftforge.client.event.MouseEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onMouseEvent(MouseEvent evt)
{
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer thePlayer = mc.player;
ItemStack rightHandStack = thePlayer.getHeldItemMainhand();
ItemStack leftHandStack = thePlayer.getHeldItemMainhand();
InventoryAttachment att = InventoryAttachment.create(rightHandStack);
if(rightHandStack != null && rightHandStack.getItem() instanceof ItemRangedWeapon && leftHandStack != null && leftHandStack.getItem() instanceof ItemRangedWeapon)
{
ItemRangedWeapon rightHandGun = (ItemRangedWeapon) rightHandStack.getItem();
ItemRangedWeapon leftHandGun = (ItemRangedWeapon) leftHandStack.getItem();
if(!rightHandGun.IsTwoHanded() && !leftHandGun.IsTwoHanded())
{
System.out.println("duel Wielding");
}
else
{
//Fire the main hand gun
}
}
else if (rightHandStack != null && rightHandStack.getItem() instanceof ItemRangedWeapon)
{
if(leftHandStack != null && leftHandStack.getItem() instanceof ItemRangedWeapon)
System.out.println(leftHandStack.getItem());
if(evt.getButton() == 0)
{
evt.setCanceled(true);
}
if(evt.getButton() == 1)
{
// if()
evt.setCanceled(true);
if (att != null && att.isScopePresent()) {
showScopeOverlap = evt.isButtonstate();
selected = rightHandStack;
// if (showScopeOverlap)
}
}
}
}