本文整理汇总了Java中net.minecraft.event.ClickEvent.getAction方法的典型用法代码示例。如果您正苦于以下问题:Java ClickEvent.getAction方法的具体用法?Java ClickEvent.getAction怎么用?Java ClickEvent.getAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.event.ClickEvent
的用法示例。
在下文中一共展示了ClickEvent.getAction方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mouseClicked
import net.minecraft.event.ClickEvent; //导入方法依赖的package包/类
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton)
{
super.mouseClicked(mouseX, mouseY, mouseButton);
int info2Start = (this.height / 2) - 50;
if (orderPressed && !isSure && mouseY >= info2Start && mouseY <= info2Start + fontRendererObj.FONT_HEIGHT)
{
IChatComponent comp = getComponent(mouseX, mouseY);
ClickEvent clickevent = comp.getChatStyle().getChatClickEvent();
if (clickevent != null && clickevent.getAction() == ClickEvent.Action.OPEN_URL)
{
try
{
URI uri = new URI(clickevent.getValue());
Class<?> oclass = Class.forName("java.awt.Desktop");
Object object = oclass.getMethod("getDesktop").invoke(null);
oclass.getMethod("browse", URI.class).invoke(object, uri);
}
catch (Throwable t)
{
CreeperHost.logger.error("Can\'t open url for " + clickevent, t);
}
return;
}
}
for (TextFieldDetails field : this.fields)
{
field.mouseClicked(mouseX, mouseY, mouseButton);
}
}
示例2: getLinksFromChat0
import net.minecraft.event.ClickEvent; //导入方法依赖的package包/类
private static void getLinksFromChat0(final @Nonnull List<ClickEvent> list, final @Nonnull IChatComponent pchat) {
final List<?> chats = pchat.getSiblings();
for (final Object o : chats) {
final IChatComponent chat = (IChatComponent) o;
final ClickEvent ev = chat.getChatStyle().getChatClickEvent();
if (ev!=null&&ev.getAction()==ClickEvent.Action.OPEN_URL)
list.add(ev);
getLinksFromChat0(list, chat);
}
}
示例3: executeCommand
import net.minecraft.event.ClickEvent; //导入方法依赖的package包/类
public boolean executeCommand(final EntityPlayer playerIn)
{
ICommandSender icommandsender = new ICommandSender()
{
public String getName()
{
return playerIn.getName();
}
public IChatComponent getDisplayName()
{
return playerIn.getDisplayName();
}
public void addChatMessage(IChatComponent component)
{
}
public boolean canCommandSenderUseCommand(int permLevel, String commandName)
{
return permLevel <= 2;
}
public BlockPos getPosition()
{
return TileEntitySign.this.pos;
}
public Vec3 getPositionVector()
{
return new Vec3((double)TileEntitySign.this.pos.getX() + 0.5D, (double)TileEntitySign.this.pos.getY() + 0.5D, (double)TileEntitySign.this.pos.getZ() + 0.5D);
}
public World getEntityWorld()
{
return playerIn.getEntityWorld();
}
public Entity getCommandSenderEntity()
{
return playerIn;
}
public boolean sendCommandFeedback()
{
return false;
}
public void setCommandStat(CommandResultStats.Type type, int amount)
{
TileEntitySign.this.stats.func_179672_a(this, type, amount);
}
};
for (int i = 0; i < this.signText.length; ++i)
{
ChatStyle chatstyle = this.signText[i] == null ? null : this.signText[i].getChatStyle();
if (chatstyle != null && chatstyle.getChatClickEvent() != null)
{
ClickEvent clickevent = chatstyle.getChatClickEvent();
if (clickevent.getAction() == ClickEvent.Action.RUN_COMMAND)
{
MinecraftServer.getServer().getCommandManager().executeCommand(icommandsender, clickevent.getValue());
}
}
}
return true;
}
示例4: handleComponentClick
import net.minecraft.event.ClickEvent; //导入方法依赖的package包/类
/**
* Executes the click event specified by the given chat component
*/
protected boolean handleComponentClick(IChatComponent p_175276_1_)
{
ClickEvent clickevent = p_175276_1_ == null ? null : p_175276_1_.getChatStyle().getChatClickEvent();
if (clickevent == null)
{
return false;
}
else if (clickevent.getAction() == ClickEvent.Action.CHANGE_PAGE)
{
String s = clickevent.getValue();
try
{
int i = Integer.parseInt(s) - 1;
if (i >= 0 && i < this.bookTotalPages && i != this.currPage)
{
this.currPage = i;
this.updateButtons();
return true;
}
}
catch (Throwable var5)
{
;
}
return false;
}
else
{
boolean flag = super.handleComponentClick(p_175276_1_);
if (flag && clickevent.getAction() == ClickEvent.Action.RUN_COMMAND)
{
this.mc.displayGuiScreen((GuiScreen)null);
}
return flag;
}
}
示例5: mouseClicked
import net.minecraft.event.ClickEvent; //导入方法依赖的package包/类
/**
* Called when the mouse is clicked.
*/
protected void mouseClicked(int par1, int par2, int par3)
{
if (par3 == 0 && this.mc.gameSettings.chatLinks)
{
IChatComponent var4 = this.mc.ingameGUI.getChatGUI().func_146236_a(Mouse.getX(), Mouse.getY());
if (var4 != null)
{
ClickEvent var5 = var4.getChatStyle().getChatClickEvent();
if (var5 != null)
{
if (isShiftKeyDown())
{
this.field_146415_a.func_146191_b(var4.getUnformattedTextForChat());
}
else
{
URI var6;
if (var5.getAction() == ClickEvent.Action.OPEN_URL)
{
try
{
var6 = new URI(var5.getValue());
if (this.mc.gameSettings.chatLinksPrompt)
{
this.field_146411_u = var6;
this.mc.displayGuiScreen(new GuiConfirmOpenLink(this, var5.getValue(), 0, false));
}
else
{
this.func_146407_a(var6);
}
}
catch (URISyntaxException var7)
{
logger.error("Can\'t open url for " + var5, var7);
}
}
else if (var5.getAction() == ClickEvent.Action.OPEN_FILE)
{
var6 = (new File(var5.getValue())).toURI();
this.func_146407_a(var6);
}
else if (var5.getAction() == ClickEvent.Action.SUGGEST_COMMAND)
{
this.field_146415_a.setText(var5.getValue());
}
else if (var5.getAction() == ClickEvent.Action.RUN_COMMAND)
{
this.func_146403_a(var5.getValue());
}
else
{
logger.error("Don\'t know how to handle " + var5);
}
}
return;
}
}
}
this.field_146415_a.mouseClicked(par1, par2, par3);
super.mouseClicked(par1, par2, par3);
}
示例6: mouseClicked
import net.minecraft.event.ClickEvent; //导入方法依赖的package包/类
/**
* Called when the mouse is clicked.
*/
protected void mouseClicked(int par1, int par2, int par3)
{
if (par3 == 0 && this.mc.gameSettings.chatLinks)
{
IChatComponent ichatcomponent = this.mc.ingameGUI.getChatGUI().func_146236_a(Mouse.getX(), Mouse.getY());
if (ichatcomponent != null)
{
ClickEvent clickevent = ichatcomponent.getChatStyle().getChatClickEvent();
if (clickevent != null)
{
if (isShiftKeyDown())
{
inputField.writeText(ichatcomponent.getUnformattedTextForChat());
}
else
{
URI uri;
if (clickevent.getAction() == ClickEvent.Action.OPEN_URL)
{
try
{
uri = new URI(clickevent.getValue());
if (this.mc.gameSettings.chatLinksPrompt)
{
this.clickedURI = uri;
this.mc.displayGuiScreen(new GuiConfirmOpenLink(this, clickevent.getValue(), 0, false));
}
else
{
this.func_146407_a(uri);
}
}
catch (URISyntaxException urisyntaxexception)
{
logger.error("Can\'t open url for " + clickevent, urisyntaxexception);
}
}
else if (clickevent.getAction() == ClickEvent.Action.OPEN_FILE)
{
uri = (new File(clickevent.getValue())).toURI();
this.func_146407_a(uri);
}
else if (clickevent.getAction() == ClickEvent.Action.SUGGEST_COMMAND)
{
inputField.setText(clickevent.getValue());
}
else if (clickevent.getAction() == ClickEvent.Action.RUN_COMMAND)
{
this.func_146403_a(clickevent.getValue());
}
else
{
logger.error("Don\'t know how to handle " + clickevent);
}
}
return;
}
}
}
inputField.mouseClicked(par1, par2, par3);
super.mouseClicked(par1, par2, par3);
}