本文整理汇总了Java中net.minecraft.client.gui.GuiYesNoCallback类的典型用法代码示例。如果您正苦于以下问题:Java GuiYesNoCallback类的具体用法?Java GuiYesNoCallback怎么用?Java GuiYesNoCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GuiYesNoCallback类属于net.minecraft.client.gui包,在下文中一共展示了GuiYesNoCallback类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: displayScreenJoinTeam
import net.minecraft.client.gui.GuiYesNoCallback; //导入依赖的package包/类
public static void displayScreenJoinTeam() {
final GuiScreen prevScreen = Minecraft.getMinecraft().currentScreen;
Minecraft.getMinecraft().displayGuiScreen(new GuiYesNo(new GuiYesNoCallback() {
@Override
public void confirmClicked(boolean result, int id) {
if (result)
TF2weapons.network.sendToServer(new TF2Message.ActionMessage(16));
else
TF2weapons.network.sendToServer(new TF2Message.ActionMessage(17));
Minecraft.getMinecraft().displayGuiScreen(prevScreen);
}
}, "Choose your team", "Before using the store, you need to join a team", "RED", "BLU", 0));
}
示例2: mousePressed
import net.minecraft.client.gui.GuiYesNoCallback; //导入依赖的package包/类
/**
* Returns true if the mouse has been pressed on this control.
*/
public boolean mousePressed(int slotIndex, int p_148278_2_, int p_148278_3_, int p_148278_4_, int p_148278_5_, int p_148278_6_)
{
if (this.func_148310_d() && p_148278_5_ <= 32)
{
if (this.func_148309_e())
{
this.resourcePacksGUI.markChanged();
int j = this.func_183019_a();
if (j != 1)
{
String s1 = I18n.format("resourcePack.incompatible.confirm.title", new Object[0]);
String s = I18n.format("resourcePack.incompatible.confirm." + (j > 1 ? "new" : "old"), new Object[0]);
this.mc.displayGuiScreen(new GuiYesNo(new GuiYesNoCallback()
{
public void confirmClicked(boolean result, int id)
{
List<ResourcePackListEntry> list2 = ResourcePackListEntry.this.resourcePacksGUI.getListContaining(ResourcePackListEntry.this);
ResourcePackListEntry.this.mc.displayGuiScreen(ResourcePackListEntry.this.resourcePacksGUI);
if (result)
{
list2.remove(ResourcePackListEntry.this);
ResourcePackListEntry.this.resourcePacksGUI.getSelectedResourcePacks().add(0, ResourcePackListEntry.this);
}
}
}, s1, s, 0));
}
else
{
this.resourcePacksGUI.getListContaining(this).remove(this);
this.resourcePacksGUI.getSelectedResourcePacks().add(0, this);
}
return true;
}
if (p_148278_5_ < 16 && this.func_148308_f())
{
this.resourcePacksGUI.getListContaining(this).remove(this);
this.resourcePacksGUI.getAvailableResourcePacks().add(0, this);
this.resourcePacksGUI.markChanged();
return true;
}
if (p_148278_5_ > 16 && p_148278_6_ < 16 && this.func_148314_g())
{
List<ResourcePackListEntry> list1 = this.resourcePacksGUI.getListContaining(this);
int k = list1.indexOf(this);
list1.remove(this);
list1.add(k - 1, this);
this.resourcePacksGUI.markChanged();
return true;
}
if (p_148278_5_ > 16 && p_148278_6_ > 16 && this.func_148307_h())
{
List<ResourcePackListEntry> list = this.resourcePacksGUI.getListContaining(this);
int i = list.indexOf(this);
list.remove(this);
list.add(i + 1, this);
this.resourcePacksGUI.markChanged();
return true;
}
}
return false;
}
示例3: dispatchKeypresses
import net.minecraft.client.gui.GuiYesNoCallback; //导入依赖的package包/类
public void dispatchKeypresses() {
int i = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() : Keyboard.getEventKey();
if (i != 0 && !Keyboard.isRepeatEvent()) {
if (!(this.currentScreen instanceof GuiControls)
|| ((GuiControls) this.currentScreen).time <= getSystemTime() - 20L) {
if (Keyboard.getEventKeyState()) {
if (i == this.gameSettings.keyBindStreamStartStop.getKeyCode()) {
if (this.getTwitchStream().isBroadcasting()) {
this.getTwitchStream().stopBroadcasting();
} else if (this.getTwitchStream().isReadyToBroadcast()) {
this.displayGuiScreen(new GuiYesNo(new GuiYesNoCallback() {
public void confirmClicked(boolean result, int id) {
if (result) {
Minecraft.this.getTwitchStream().func_152930_t();
}
Minecraft.this.displayGuiScreen((GuiScreen) null);
}
}, I18n.format("stream.confirm_start", new Object[0]), "", 0));
} else if (this.getTwitchStream().func_152928_D() && this.getTwitchStream().func_152936_l()) {
if (this.theWorld != null) {
this.ingameGUI.getChatGUI()
.printChatMessage(new ChatComponentText("Not ready to start streaming yet!"));
}
} else {
GuiStreamUnavailable.func_152321_a(this.currentScreen);
}
} else if (i == this.gameSettings.keyBindStreamPauseUnpause.getKeyCode()) {
if (this.getTwitchStream().isBroadcasting()) {
if (this.getTwitchStream().isPaused()) {
this.getTwitchStream().unpause();
} else {
this.getTwitchStream().pause();
}
}
} else if (i == this.gameSettings.keyBindStreamCommercials.getKeyCode()) {
if (this.getTwitchStream().isBroadcasting()) {
this.getTwitchStream().requestCommercial();
}
} else if (i == this.gameSettings.keyBindStreamToggleMic.getKeyCode()) {
this.stream.muteMicrophone(true);
} else if (i == this.gameSettings.keyBindFullscreen.getKeyCode()) {
this.toggleFullscreen();
} else if (i == this.gameSettings.keyBindScreenshot.getKeyCode()) {
this.ingameGUI.getChatGUI().printChatMessage(ScreenShotHelper.saveScreenshot(this.mcDataDir,
this.displayWidth, this.displayHeight, this.framebufferMc));
}
} else if (i == this.gameSettings.keyBindStreamToggleMic.getKeyCode()) {
this.stream.muteMicrophone(false);
}
}
}
}
示例4: mousePressed
import net.minecraft.client.gui.GuiYesNoCallback; //导入依赖的package包/类
/**
* Called when the mouse is clicked within this entry. Returning true means that something within this entry was
* clicked and the list should not be dragged.
*/
public boolean mousePressed(int slotIndex, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY)
{
if (this.showHoverOverlay() && relativeX <= 32)
{
if (this.canMoveRight())
{
this.resourcePacksGUI.markChanged();
final int j = ((ResourcePackListEntry)this.resourcePacksGUI.getSelectedResourcePacks().get(0)).isServerPack() ? 1 : 0;
int l = this.getResourcePackFormat();
if (l == 3)
{
this.resourcePacksGUI.getListContaining(this).remove(this);
this.resourcePacksGUI.getSelectedResourcePacks().add(j, this);
}
else
{
String s = I18n.format("resourcePack.incompatible.confirm.title", new Object[0]);
String s1 = I18n.format("resourcePack.incompatible.confirm." + (l > 3 ? "new" : "old"), new Object[0]);
this.mc.displayGuiScreen(new GuiYesNo(new GuiYesNoCallback()
{
public void confirmClicked(boolean result, int id)
{
List<ResourcePackListEntry> list2 = ResourcePackListEntry.this.resourcePacksGUI.getListContaining(ResourcePackListEntry.this);
ResourcePackListEntry.this.mc.displayGuiScreen(ResourcePackListEntry.this.resourcePacksGUI);
if (result)
{
list2.remove(ResourcePackListEntry.this);
ResourcePackListEntry.this.resourcePacksGUI.getSelectedResourcePacks().add(j, ResourcePackListEntry.this);
}
}
}, s, s1, 0));
}
return true;
}
if (relativeX < 16 && this.canMoveLeft())
{
this.resourcePacksGUI.getListContaining(this).remove(this);
this.resourcePacksGUI.getAvailableResourcePacks().add(0, this);
this.resourcePacksGUI.markChanged();
return true;
}
if (relativeX > 16 && relativeY < 16 && this.canMoveUp())
{
List<ResourcePackListEntry> list1 = this.resourcePacksGUI.getListContaining(this);
int k = list1.indexOf(this);
list1.remove(this);
list1.add(k - 1, this);
this.resourcePacksGUI.markChanged();
return true;
}
if (relativeX > 16 && relativeY > 16 && this.canMoveDown())
{
List<ResourcePackListEntry> list = this.resourcePacksGUI.getListContaining(this);
int i = list.indexOf(this);
list.remove(this);
list.add(i + 1, this);
this.resourcePacksGUI.markChanged();
return true;
}
}
return false;
}
示例5: handleResourcePack
import net.minecraft.client.gui.GuiYesNoCallback; //导入依赖的package包/类
public void handleResourcePack(SPacketResourcePackSend packetIn)
{
final String s = packetIn.getURL();
final String s1 = packetIn.getHash();
if (this.validateResourcePackUrl(s))
{
if (s.startsWith("level://"))
{
String s2 = s.substring("level://".length());
File file1 = new File(this.gameController.mcDataDir, "saves");
File file2 = new File(file1, s2);
if (file2.isFile())
{
this.netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.ACCEPTED));
Futures.addCallback(this.gameController.getResourcePackRepository().setResourcePackInstance(file2), this.createDownloadCallback());
}
else
{
this.netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.FAILED_DOWNLOAD));
}
}
else
{
ServerData serverdata = this.gameController.getCurrentServerData();
if (serverdata != null && serverdata.getResourceMode() == ServerData.ServerResourceMode.ENABLED)
{
this.netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.ACCEPTED));
Futures.addCallback(this.gameController.getResourcePackRepository().downloadResourcePack(s, s1), this.createDownloadCallback());
}
else if (serverdata != null && serverdata.getResourceMode() != ServerData.ServerResourceMode.PROMPT)
{
this.netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.DECLINED));
}
else
{
this.gameController.addScheduledTask(new Runnable()
{
public void run()
{
NetHandlerPlayClient.this.gameController.displayGuiScreen(new GuiYesNo(new GuiYesNoCallback()
{
public void confirmClicked(boolean result, int id)
{
NetHandlerPlayClient.this.gameController = Minecraft.getMinecraft();
ServerData serverdata1 = NetHandlerPlayClient.this.gameController.getCurrentServerData();
if (result)
{
if (serverdata1 != null)
{
serverdata1.setResourceMode(ServerData.ServerResourceMode.ENABLED);
}
NetHandlerPlayClient.this.netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.ACCEPTED));
Futures.addCallback(NetHandlerPlayClient.this.gameController.getResourcePackRepository().downloadResourcePack(s, s1), NetHandlerPlayClient.this.createDownloadCallback());
}
else
{
if (serverdata1 != null)
{
serverdata1.setResourceMode(ServerData.ServerResourceMode.DISABLED);
}
NetHandlerPlayClient.this.netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.DECLINED));
}
ServerList.saveSingleServer(serverdata1);
NetHandlerPlayClient.this.gameController.displayGuiScreen((GuiScreen)null);
}
}, I18n.format("multiplayer.texturePrompt.line1", new Object[0]), I18n.format("multiplayer.texturePrompt.line2", new Object[0]), 0));
}
});
}
}
}
}
示例6: mousePressed
import net.minecraft.client.gui.GuiYesNoCallback; //导入依赖的package包/类
/**
* Called when the mouse is clicked within this entry. Returning true means that something within this entry was
* clicked and the list should not be dragged.
*/
public boolean mousePressed(int slotIndex, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY)
{
if (this.showHoverOverlay() && relativeX <= 32)
{
if (this.canMoveRight())
{
this.resourcePacksGUI.markChanged();
final int j = ((ResourcePackListEntry)this.resourcePacksGUI.getSelectedResourcePacks().get(0)).isServerPack() ? 1 : 0;
int l = this.getResourcePackFormat();
if (l == 2)
{
this.resourcePacksGUI.getListContaining(this).remove(this);
this.resourcePacksGUI.getSelectedResourcePacks().add(j, this);
}
else
{
String s = I18n.format("resourcePack.incompatible.confirm.title", new Object[0]);
String s1 = I18n.format("resourcePack.incompatible.confirm." + (l > 2 ? "new" : "old"), new Object[0]);
this.mc.displayGuiScreen(new GuiYesNo(new GuiYesNoCallback()
{
public void confirmClicked(boolean result, int id)
{
List<ResourcePackListEntry> list2 = ResourcePackListEntry.this.resourcePacksGUI.getListContaining(ResourcePackListEntry.this);
ResourcePackListEntry.this.mc.displayGuiScreen(ResourcePackListEntry.this.resourcePacksGUI);
if (result)
{
list2.remove(ResourcePackListEntry.this);
ResourcePackListEntry.this.resourcePacksGUI.getSelectedResourcePacks().add(j, ResourcePackListEntry.this);
}
}
}, s, s1, 0));
}
return true;
}
if (relativeX < 16 && this.canMoveLeft())
{
this.resourcePacksGUI.getListContaining(this).remove(this);
this.resourcePacksGUI.getAvailableResourcePacks().add(0, this);
this.resourcePacksGUI.markChanged();
return true;
}
if (relativeX > 16 && relativeY < 16 && this.canMoveUp())
{
List<ResourcePackListEntry> list1 = this.resourcePacksGUI.getListContaining(this);
int k = list1.indexOf(this);
list1.remove(this);
list1.add(k - 1, this);
this.resourcePacksGUI.markChanged();
return true;
}
if (relativeX > 16 && relativeY > 16 && this.canMoveDown())
{
List<ResourcePackListEntry> list = this.resourcePacksGUI.getListContaining(this);
int i = list.indexOf(this);
list.remove(this);
list.add(i + 1, this);
this.resourcePacksGUI.markChanged();
return true;
}
}
return false;
}
示例7: handleClickEvent
import net.minecraft.client.gui.GuiYesNoCallback; //导入依赖的package包/类
/**
* A static alternative to
* {@link GuiScreen#handleComponentClick(IChatComponent)}, with the
* additional functionality that click events from elsewhere can be handled
*
* @param event
* @return
*/
public static boolean handleClickEvent(ClickEvent event) {
if (event != null) {
if (event.getAction() == ClickEvent.Action.OPEN_URL) {
if (!Minecraft.getMinecraft().gameSettings.chatLinks) {
return false;
}
try {
final URI webUri = new URI(event.getValue());
String protocol = webUri.getScheme();
if (protocol == null) {
throw new URISyntaxException(event.getValue(), "Missing protocol");
}
if (!PROTOCOLS.contains(protocol.toLowerCase())) {
throw new URISyntaxException(event.getValue(),
"Unsupported protocol: " + protocol.toLowerCase());
}
if (Minecraft.getMinecraft().gameSettings.chatLinksPrompt) {
final GuiScreen prevScreen = Minecraft.getMinecraft().currentScreen;
GuiYesNoCallback callback = new GuiYesNoCallback() {
@Override
public void confirmClicked(boolean result, int id) {
if (id == 31102009) {
if (result) {
openWebLink(webUri);
}
Minecraft.getMinecraft().displayGuiScreen(prevScreen);
}
}
};
Minecraft.getMinecraft()
.displayGuiScreen(new GuiConfirmOpenLink(callback, event.getValue(), 31102009, false));
} else {
openWebLink(webUri);
}
} catch (URISyntaxException e) {
MC_LOGGER.error("Can't open url for " + event, e);
}
} else if (event.getAction() == ClickEvent.Action.OPEN_FILE) {
URI fileUri = new File(event.getValue()).toURI();
openWebLink(fileUri);
} else if (event.getAction() == ClickEvent.Action.SUGGEST_COMMAND) {
// Can't do insertion
} else if (event.getAction() == ClickEvent.Action.RUN_COMMAND) {
if (Minecraft.getMinecraft().player != null)
Minecraft.getMinecraft().player.sendChatMessage(event.getValue());
} else {
MC_LOGGER.error("Don't know how to handle " + event);
}
return true;
}
return false;
}
示例8: handleResourcePack
import net.minecraft.client.gui.GuiYesNoCallback; //导入依赖的package包/类
public void handleResourcePack(SPacketResourcePackSend packetIn)
{
final String s = packetIn.getURL();
final String s1 = packetIn.getHash();
if (this.func_189688_b(s))
{
if (s.startsWith("level://"))
{
String s2 = s.substring("level://".length());
File file1 = new File(this.gameController.mcDataDir, "saves");
File file2 = new File(file1, s2);
if (file2.isFile())
{
this.netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.ACCEPTED));
Futures.addCallback(this.gameController.getResourcePackRepository().setResourcePackInstance(file2), this.func_189686_f());
}
else
{
this.netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.FAILED_DOWNLOAD));
}
}
else
{
ServerData serverdata = this.gameController.getCurrentServerData();
if (serverdata != null && serverdata.getResourceMode() == ServerData.ServerResourceMode.ENABLED)
{
this.netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.ACCEPTED));
Futures.addCallback(this.gameController.getResourcePackRepository().downloadResourcePack(s, s1), this.func_189686_f());
}
else if (serverdata != null && serverdata.getResourceMode() != ServerData.ServerResourceMode.PROMPT)
{
this.netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.DECLINED));
}
else
{
this.gameController.addScheduledTask(new Runnable()
{
public void run()
{
NetHandlerPlayClient.this.gameController.displayGuiScreen(new GuiYesNo(new GuiYesNoCallback()
{
public void confirmClicked(boolean result, int id)
{
NetHandlerPlayClient.this.gameController = Minecraft.getMinecraft();
ServerData serverdata1 = NetHandlerPlayClient.this.gameController.getCurrentServerData();
if (result)
{
if (serverdata1 != null)
{
serverdata1.setResourceMode(ServerData.ServerResourceMode.ENABLED);
}
NetHandlerPlayClient.this.netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.ACCEPTED));
Futures.addCallback(NetHandlerPlayClient.this.gameController.getResourcePackRepository().downloadResourcePack(s, s1), NetHandlerPlayClient.this.func_189686_f());
}
else
{
if (serverdata1 != null)
{
serverdata1.setResourceMode(ServerData.ServerResourceMode.DISABLED);
}
NetHandlerPlayClient.this.netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.DECLINED));
}
ServerList.saveSingleServer(serverdata1);
NetHandlerPlayClient.this.gameController.displayGuiScreen((GuiScreen)null);
}
}, I18n.format("multiplayer.texturePrompt.line1", new Object[0]), I18n.format("multiplayer.texturePrompt.line2", new Object[0]), 0));
}
});
}
}
}
}
示例9: handleCustomPayload
import net.minecraft.client.gui.GuiYesNoCallback; //导入依赖的package包/类
public void handleCustomPayload(S3FPacketCustomPayload p_147240_1_)
{
if ("MC|TrList".equals(p_147240_1_.func_149169_c()))
{
ByteBuf bytebuf = Unpooled.wrappedBuffer(p_147240_1_.func_149168_d());
try
{
int i = bytebuf.readInt();
GuiScreen guiscreen = this.gameController.currentScreen;
if (guiscreen != null && guiscreen instanceof GuiMerchant && i == this.gameController.thePlayer.openContainer.windowId)
{
IMerchant imerchant = ((GuiMerchant)guiscreen).func_147035_g();
MerchantRecipeList merchantrecipelist = MerchantRecipeList.func_151390_b(new PacketBuffer(bytebuf));
imerchant.setRecipes(merchantrecipelist);
}
}
catch (IOException ioexception)
{
logger.error("Couldn\'t load trade info", ioexception);
}
finally
{
bytebuf.release();
}
}
else if ("MC|Brand".equals(p_147240_1_.func_149169_c()))
{
this.gameController.thePlayer.func_142020_c(new String(p_147240_1_.func_149168_d(), Charsets.UTF_8));
}
else if ("MC|RPack".equals(p_147240_1_.func_149169_c()))
{
final String s = new String(p_147240_1_.func_149168_d(), Charsets.UTF_8);
if (this.gameController.func_147104_D() != null && this.gameController.func_147104_D().func_152586_b() == ServerData.ServerResourceMode.ENABLED)
{
this.gameController.getResourcePackRepository().func_148526_a(s);
}
else if (this.gameController.func_147104_D() == null || this.gameController.func_147104_D().func_152586_b() == ServerData.ServerResourceMode.PROMPT)
{
this.gameController.displayGuiScreen(new GuiYesNo(new GuiYesNoCallback()
{
private static final String __OBFID = "CL_00000879";
public void confirmClicked(boolean p_73878_1_, int p_73878_2_)
{
NetHandlerPlayClient.this.gameController = Minecraft.getMinecraft();
if (NetHandlerPlayClient.this.gameController.func_147104_D() != null)
{
NetHandlerPlayClient.this.gameController.func_147104_D().func_152584_a(ServerData.ServerResourceMode.ENABLED);
ServerList.func_147414_b(NetHandlerPlayClient.this.gameController.func_147104_D());
}
if (p_73878_1_)
{
NetHandlerPlayClient.this.gameController.getResourcePackRepository().func_148526_a(s);
}
NetHandlerPlayClient.this.gameController.displayGuiScreen((GuiScreen)null);
}
}, I18n.format("multiplayer.texturePrompt.line1", new Object[0]), I18n.format("multiplayer.texturePrompt.line2", new Object[0]), 0));
}
}
}