下面列出了net.minecraft.util.MovingObjectPosition#net.minecraft.client.gui.GuiScreen 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
protected void mouseClicked(int x, int y, int par3){
ItemStack programmedItem = te.getStackInSlot(TileEntityProgrammer.PROGRAM_SLOT);
if(nameField.isFocused() && programmedItem != null) {
programmedItem.setStackDisplayName(nameField.getText());
NetworkHandler.sendToServer(new PacketUpdateTextfield(te, 0));
}
super.mouseClicked(x, y, par3);
if(par3 == 1 && showingWidgetProgress == 0) {
IProgWidget widget = programmerUnit.getHoveredWidget(x, y);
if(widget != null) {
GuiScreen screen = widget.getOptionWindow(this);
if(screen != null) mc.displayGuiScreen(screen);
}
}
}
@Override
protected void actionPerformed(GuiButton button) {
if (button.id == 1) {
try {
if (hasteLink == null) {
hasteLink = HasteUpload.uploadToHaste(ModConfig.crashes.hasteURL, "mccrash", report.getCompleteReport());
}
ReflectionHelper.findField(GuiScreen.class, "clickedLinkURI", "field_175286_t").set(this, new URI(hasteLink));
mc.displayGuiScreen(new GuiConfirmOpenLink(this, hasteLink, 31102009, false));
} catch (Throwable e) {
log.error("Exception when crash menu button clicked:", e);
button.displayString = I18n.format("vanillafix.gui.failed");
button.enabled = false;
}
}
}
@Override
public boolean mouseClicked(GuiScreen gui, int mouseX, int mouseY, int button) {
if (isHidden()) {
return false;
}
if (!isEnabled()) {
return options.contains(mouseX, mouseY) && options.handleClick(mouseX, mouseY, button);
}
for (Widget widget : controlWidgets) {
widget.onGuiClick(mouseX, mouseY);
if (widget.contains(mouseX, mouseY) ? widget.handleClick(mouseX, mouseY, button) : widget.handleClickExt(mouseX, mouseY, button)) {
return true;
}
}
return false;
}
@Override
public boolean lastKeyTyped(GuiScreen gui, char keyChar, int keyID) {
if (KeyBindings.get("nei.options.keys.gui.hide").isActiveAndMatches(keyID)) {
toggleBooleanSetting("inventory.hidden");
//False, because we need to not consume the event.
return false;
}
if (isEnabled() && !isHidden()) {
for (Widget widget : controlWidgets) {
if (inputFocused == null) {
widget.lastKeyTyped(keyID, keyChar);
}
}
}
return false;
}
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData)
{
if (type.equals(EnumSet.of(TickType.CLIENT)))
{
GuiScreen curScreen = Minecraft.getMinecraft().currentScreen;
if (curScreen != null)
{
onTickInGui(curScreen);
}
else
{
onTickInGame();
}
}
}
@Override
public boolean handleKeyPress(int keyID, char keyChar) {
if (!focused())
return false;
if (keyID == Keyboard.KEY_BACK) {
if (text.length() > 0) {
setText(text.substring(0, text.length() - 1));
backdowntime = System.currentTimeMillis();
}
} else if (keyID == Keyboard.KEY_RETURN || keyID == Keyboard.KEY_ESCAPE) {
setFocus(false);
onExit();
} else if (keyChar == 22)//paste
{
String pastestring = GuiScreen.getClipboardString();
if (pastestring == null)
pastestring = "";
if (isValid(text + pastestring))
setText(text + pastestring);
} else if (isValid(text + keyChar))
setText(text + keyChar);
return true;
}
@SubscribeEvent
public void drawScreenPost(DrawScreenEvent.Post event) {
GuiScreen screen = event.getGui();
Point mousePos = GuiDraw.getMousePosition();
List<String> tooltip = new LinkedList<>();
ItemStack stack = ItemStack.EMPTY;
if (instanceTooltipHandlers != null) {
instanceTooltipHandlers.forEach(handler -> handler.handleTooltip(screen, mousePos.x, mousePos.y, tooltip));
}
if (screen instanceof GuiContainer) {
if (tooltip.isEmpty() && GuiHelper.shouldShowTooltip(screen)) {
GuiContainer container = (GuiContainer) screen;
stack = GuiHelper.getStackMouseOver(container, false);
if (!stack.isEmpty()) {
tooltip.clear();
tooltip.addAll(GuiHelper.itemDisplayNameMultiline(stack, container, false));
}
}
}
GuiDraw.drawMultiLineTip(stack, mousePos.x + 10, mousePos.y - 12, tooltip);
}
private void drawItem(ItemStack itemstack, int x, int y, String name) {
GL11.glColor3ub((byte) -1, (byte) -1, (byte) -1);
GL11.glDisable(2896);
this.zLevel = 200.0f;
GuiScreen.itemRender.zLevel = 200.0f;
FontRenderer font = null;
if (itemstack != null) {
font = itemstack.getItem().getFontRenderer(itemstack);
}
if (font == null) {
font = this.fontRendererObj;
}
GuiScreen.itemRender.renderItemAndEffectIntoGUI(font, this.mc.getTextureManager(), itemstack, x, y);
GuiScreen.itemRender.renderItemOverlayIntoGUI(font, this.mc.getTextureManager(), itemstack, x, y, name);
this.zLevel = 0.0f;
GuiScreen.itemRender.zLevel = 0.0f;
GL11.glEnable(2896);
}
private boolean isCorrectModeActive()
{
switch (mode.toLowerCase())
{
case MODE_SHIFT:
return GuiScreen.isShiftKeyDown();
case MODE_CTRL:
return GuiScreen.isCtrlKeyDown();
case MODE_ALT:
return GuiScreen.isAltKeyDown();
case MODE_NO_SHIFT:
return !GuiScreen.isShiftKeyDown();
case MODE_NO_CTRL:
return !GuiScreen.isCtrlKeyDown();
case MODE_NO_ALT:
return !GuiScreen.isAltKeyDown();
default:
return true;
}
}
@SubscribeEvent
public void onKeyRepeatSet(GlassesSetKeyRepeatEvent evt) {
GuiScreen gui = FMLClientHandler.instance().getClient().currentScreen;
if (gui instanceof GuiCapture) {
final GuiCapture capture = (GuiCapture)gui;
long guid = capture.getGuid();
if (guid == evt.guid) capture.setKeyRepeat(evt.repeat);
}
}
@Override
public void keyTyped(char c, int keycode) throws IOException {
if (keycode == 1) {//esc
GuiScreen p = parent;
while (p instanceof GuiOptionList) {
p = ((GuiOptionList) p).parent;
}
Minecraft.getMinecraft().displayGuiScreen(p);
} else {
super.keyTyped(c, keycode);
}
}
public void keyTyped(char keyChar, int keyID)
{
super.keyTyped(keyChar, keyID);
if (keyID == Keyboard.KEY_ESCAPE || keyID == mc.gameSettings.keyBindInventory.keyCode)
{
this.mc.displayGuiScreen((GuiScreen) null);
this.mc.setIngameFocus();
}
}
public GuiConfigToroQuest(GuiScreen parent) {
super (parent, new ConfigElement(ConfigurationHandler.config.getCategory(Configuration.CATEGORY_CLIENT)).getChildElements(),
ToroQuest.MODID,
false,
false,
"ToroQuest");
titleLine2 = ConfigurationHandler.config.getConfigFile().getAbsolutePath();
}
@SubscribeEvent
public void onDragParamsSet(GlassesSetDragParamsEvent evt) {
GuiScreen gui = FMLClientHandler.instance().getClient().currentScreen;
if (gui instanceof GuiCapture) {
final GuiCapture capture = (GuiCapture)gui;
long guid = capture.getGuid();
if (guid == evt.guid) capture.setDragParameters(evt.threshold, evt.period);
}
}
@Override
@SideOnly(Side.CLIENT)
public GuiScreen getOptionWindow(GuiProgrammer guiProgrammer){
return new GuiProgWidgetCondition(this, guiProgrammer){
@Override
public void initGui(){
super.initGui();
addWidget(new GuiCheckBox(500, guiLeft + 5, guiTop + 60, 0xFF000000, I18n.format("gui.progWidget.conditionBlock.checkForAir")).setChecked(checkingForAir).setTooltip(I18n.format("gui.progWidget.conditionBlock.checkForAir.tooltip")));
addWidget(new GuiCheckBox(501, guiLeft + 5, guiTop + 72, 0xFF000000, I18n.format("gui.progWidget.conditionBlock.checkForLiquids")).setChecked(checkingForLiquids).setTooltip(I18n.format("gui.progWidget.conditionBlock.checkForLiquids.tooltip")));
}
@Override
protected boolean requiresNumber(){
return false;
}
@Override
protected boolean isSidedWidget(){
return false;
}
@Override
public void actionPerformed(IGuiWidget widget){
if(widget.getID() == 500) checkingForAir = !checkingForAir;
if(widget.getID() == 501) checkingForLiquids = !checkingForLiquids;
else super.actionPerformed(widget);
}
};
}
@Override
public void keyTyped(char c, int keycode)
{
if(!isEnabled || !isFocused)
return;
/*if(c == '\t')//tab
{
parentGuiScreen.selectNextField();
}*/
if(c == '\026')//paste
{
String s = GuiScreen.getClipboardString();
if(s == null || s.equals(""))
return;
for(int i = 0; i < s.length(); i++)
{
if(text.length() == maxStringLength)
return;
char tc = s.charAt(i);
if(canAddChar(tc))
setText(text + tc);
}
}
if(keycode == Keyboard.KEY_RETURN)
{
setFocused(false);
sendAction(actionCommand, getText());
}
if(keycode == Keyboard.KEY_BACK && text.length() > 0)
setText(text.substring(0, text.length() - 1));
if((text.length() < maxStringLength || maxStringLength == 0) && canAddChar(c))
setText(text + c);
}
@Override
public boolean isPaused() {
if (FMLClientHandler.instance().getClient().isSingleplayer() && !FMLClientHandler.instance().getClient().getIntegratedServer().getPublic()) {
GuiScreen screen = FMLClientHandler.instance().getClient().currentScreen;
if (screen != null) {
if (screen.doesGuiPauseGame()) {
return true;
}
}
}
return false;
}
@Override
@SideOnly(Side.CLIENT)
public GuiScreen getOptionWindow(GuiProgrammer guiProgrammer){
return new GuiProgWidgetCondition(this, guiProgrammer){
@Override
protected boolean isSidedWidget(){
return false;
}
@Override
protected boolean isUsingAndOr(){
return false;
}
};
}
@Override
public void onMouseClickedPost(GuiScreen gui, int mouseX, int mouseY, int button) {
if (!(gui instanceof GuiContainer) || !NEIClientConfig.isEnabled()) {
return;
}
Slot slot = GuiHelper.getSlotMouseOver(((GuiContainer) gui));
if (slot != null) {
ItemStack nowHeld = NEIClientUtils.getHeldItem();
if (heldTracker != nowHeld) {
pickedUpFromSlot = slot.slotNumber;
}
}
}
@Override
@SideOnly(Side.CLIENT)
public GuiScreen getOptionWindow(GuiProgrammer guiProgrammer){
return new GuiProgWidgetImportExport(this, guiProgrammer){
@Override
protected boolean showSides(){
return false;
}
};
}
@SubscribeEvent
public void onKeyTypedPost(KeyboardInputEvent.Post event) {
GuiScreen gui = event.getGui();
if (gui instanceof GuiContainer) {
char c = Keyboard.getEventCharacter();
int eventKey = Keyboard.getEventKey();
if (eventKey == 0 && c >= 32 || Keyboard.getEventKeyState()) {
if (eventKey != 1) {
for (IInputHandler inputhander : inputHandlers) {
if (inputhander.lastKeyTyped(gui, c, eventKey)) {
event.setCanceled(true);
return;
}
}
}
if (KeyBindings.get("nei.options.keys.gui.enchant").isActiveAndMatches(eventKey) && canPerformAction("enchant")) {
NEIClientPacketHandler.sendOpenEnchantmentWindow();
event.setCanceled(true);
}
if (KeyBindings.get("nei.options.keys.gui.potion").isActiveAndMatches(eventKey) && canPerformAction("potion")) {
NEIClientPacketHandler.sendOpenPotionWindow();
event.setCanceled(true);
}
}
}
}
public GuiDrawScreenEvent(GuiScreen screen, int mouseX, int mouseY, float partialTicks) {
this.screen = screen;
this.mouseX = mouseX;
this.mouseY = mouseY;
this.partialTicks = partialTicks;
}
public MwGuiMarkerDialog(GuiScreen parentScreen, MarkerManager markerManager, Marker editingMarker) {
super(parentScreen, "Edit Marker Name:", editingMarker.name, "marker must have a name");
this.markerManager = markerManager;
this.editingMarker = editingMarker;
this.markerName = editingMarker.name;
this.markerGroup = editingMarker.groupName;
this.markerX = editingMarker.x;
this.markerY = editingMarker.y;
this.markerZ = editingMarker.z;
this.dimension = editingMarker.dimension;
}
@Override
protected void actionPerformedWithButton(GuiButton button, int mouseButton) throws IOException
{
int dim = this.player.getEntityWorld().provider.getDimension();
int amount = 0;
if (mouseButton == 0 || mouseButton == 11)
{
amount = 1;
}
else if (mouseButton == 1 || mouseButton == 9)
{
amount = -1;
}
// Pitch and Volume
if (button.id == 1 || button.id == 2)
{
if (GuiScreen.isShiftKeyDown()) { amount *= 10; }
if (GuiScreen.isCtrlKeyDown()) { amount *= 100; }
}
// Clear the search field
if (button.id == 20)
{
this.searchField.setText("");
this.applyFilterString();
}
else
{
PacketHandler.INSTANCE.sendToServer(new MessageGuiAction(dim, this.tesb.getPos(),
ReferenceGuiIds.GUI_ID_TILE_ENTITY_GENERIC, button.id, amount));
}
}
public MwGuiMarkerDialog(GuiScreen parentScreen, MarkerManager markerManager, String markerName, String markerGroup, int x, int y, int z, int dimension) {
super(parentScreen, "Marker Name:", markerName, "marker must have a name");
this.markerManager = markerManager;
this.markerName = markerName;
this.markerGroup = markerGroup;
this.markerX = x;
this.markerY = y;
this.markerZ = z;
this.editingMarker = null;
this.dimension = dimension;
}
private static void processSnifferFreqUpdate(PacketCustom packet) {
GuiScreen currentscreen = Minecraft.getMinecraft().currentScreen;
if (currentscreen == null || !(currentscreen instanceof GuiWirelessSniffer))
return;
GuiWirelessSniffer sniffergui = ((GuiWirelessSniffer) currentscreen);
sniffergui.setEtherFreq(packet.readUShort(), packet.readBoolean());
}
public GuiPastebin(GuiScreen parentScreen, String pastingString){
xSize = 183;
ySize = 202;
this.pastingString = pastingString;
this.parentScreen = parentScreen;
Keyboard.enableRepeatEvents(true);
}
public void openEditGui(@Nullable GuiScreen parent)
{
GuiBase gui = this.getEditGui();
if (gui != null)
{
gui.setParent(parent);
GuiBase.openGui(gui);
}
}
/** Creates a config GUI screen for Wearable Backpacks (and its GENERAL category). */
public BackpacksConfigScreen(GuiScreen parentScreen) {
this(parentScreen, (String)null);
// Add all settings from the GENERAL category to the entry list.
for (Setting<?> setting : WearableBackpacks.CONFIG.getSettingsGeneral())
addEntry(CreateEntryFromSetting(setting));
// After adding all settings from the GENERAL category, add its sub-categories.
for (String cat : WearableBackpacks.CONFIG.getCategories())
addEntry(new EntryCategory(this, cat));
}
public ModGuiConfig (GuiScreen parentScreen)
{
super(parentScreen,
new ConfigElement(ConfigurationHandler.instance().getConfigurationCategory()).getChildElements(),
Reference.MOD_ID,
false,
false,
GuiConfig.getAbridgedConfigPath(ConfigurationHandler.instance().toString()));
}