base mod created

This commit is contained in:
Mohammad-Ali Minaie
2018-10-08 09:07:47 -04:00
parent 0a7700c356
commit b86dedad2f
7848 changed files with 584664 additions and 1 deletions

View File

@@ -0,0 +1,60 @@
package net.minecraft.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.network.play.server.SPacketUpdateBossInfo;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.BossInfo;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class BossInfoClient extends BossInfo
{
protected float rawPercent;
protected long percentSetTime;
public BossInfoClient(SPacketUpdateBossInfo packetIn)
{
super(packetIn.getUniqueId(), packetIn.getName(), packetIn.getColor(), packetIn.getOverlay());
this.rawPercent = packetIn.getPercent();
this.percent = packetIn.getPercent();
this.percentSetTime = Minecraft.getSystemTime();
this.setDarkenSky(packetIn.shouldDarkenSky());
this.setPlayEndBossMusic(packetIn.shouldPlayEndBossMusic());
this.setCreateFog(packetIn.shouldCreateFog());
}
public void setPercent(float percentIn)
{
this.percent = this.getPercent();
this.rawPercent = percentIn;
this.percentSetTime = Minecraft.getSystemTime();
}
public float getPercent()
{
long i = Minecraft.getSystemTime() - this.percentSetTime;
float f = MathHelper.clamp((float)i / 100.0F, 0.0F, 1.0F);
return this.percent + (this.rawPercent - this.percent) * f;
}
public void updateFromPacket(SPacketUpdateBossInfo packetIn)
{
switch (packetIn.getOperation())
{
case UPDATE_NAME:
this.setName(packetIn.getName());
break;
case UPDATE_PCT:
this.setPercent(packetIn.getPercent());
break;
case UPDATE_STYLE:
this.setColor(packetIn.getColor());
this.setOverlay(packetIn.getOverlay());
break;
case UPDATE_PROPERTIES:
this.setDarkenSky(packetIn.shouldDarkenSky());
this.setPlayEndBossMusic(packetIn.shouldPlayEndBossMusic());
}
}
}

View File

@@ -0,0 +1,37 @@
package net.minecraft.client.gui;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ChatLine
{
/** GUI Update Counter value this Line was created at */
private final int updateCounterCreated;
private final ITextComponent lineString;
/** int value to refer to existing Chat Lines, can be 0 which means unreferrable */
private final int chatLineID;
public ChatLine(int updateCounterCreatedIn, ITextComponent lineStringIn, int chatLineIDIn)
{
this.lineString = lineStringIn;
this.updateCounterCreated = updateCounterCreatedIn;
this.chatLineID = chatLineIDIn;
}
public ITextComponent getChatComponent()
{
return this.lineString;
}
public int getUpdatedCounter()
{
return this.updateCounterCreated;
}
public int getChatLineID()
{
return this.chatLineID;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,220 @@
package net.minecraft.client.gui;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class Gui
{
public static final ResourceLocation OPTIONS_BACKGROUND = new ResourceLocation("textures/gui/options_background.png");
public static final ResourceLocation STAT_ICONS = new ResourceLocation("textures/gui/container/stats_icons.png");
public static final ResourceLocation ICONS = new ResourceLocation("textures/gui/icons.png");
protected float zLevel;
/**
* Draws a thin horizontal line between two points.
*/
protected void drawHorizontalLine(int startX, int endX, int y, int color)
{
if (endX < startX)
{
int i = startX;
startX = endX;
endX = i;
}
drawRect(startX, y, endX + 1, y + 1, color);
}
/**
* Draw a 1 pixel wide vertical line. Args : x, y1, y2, color
*/
protected void drawVerticalLine(int x, int startY, int endY, int color)
{
if (endY < startY)
{
int i = startY;
startY = endY;
endY = i;
}
drawRect(x, startY + 1, x + 1, endY, color);
}
/**
* Draws a solid color rectangle with the specified coordinates and color.
*/
public static void drawRect(int left, int top, int right, int bottom, int color)
{
if (left < right)
{
int i = left;
left = right;
right = i;
}
if (top < bottom)
{
int j = top;
top = bottom;
bottom = j;
}
float f3 = (float)(color >> 24 & 255) / 255.0F;
float f = (float)(color >> 16 & 255) / 255.0F;
float f1 = (float)(color >> 8 & 255) / 255.0F;
float f2 = (float)(color & 255) / 255.0F;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
GlStateManager.enableBlend();
GlStateManager.disableTexture2D();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.color(f, f1, f2, f3);
bufferbuilder.begin(7, DefaultVertexFormats.POSITION);
bufferbuilder.pos((double)left, (double)bottom, 0.0D).endVertex();
bufferbuilder.pos((double)right, (double)bottom, 0.0D).endVertex();
bufferbuilder.pos((double)right, (double)top, 0.0D).endVertex();
bufferbuilder.pos((double)left, (double)top, 0.0D).endVertex();
tessellator.draw();
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
}
/**
* Draws a rectangle with a vertical gradient between the specified colors (ARGB format). Args : x1, y1, x2, y2,
* topColor, bottomColor
*/
protected void drawGradientRect(int left, int top, int right, int bottom, int startColor, int endColor)
{
float f = (float)(startColor >> 24 & 255) / 255.0F;
float f1 = (float)(startColor >> 16 & 255) / 255.0F;
float f2 = (float)(startColor >> 8 & 255) / 255.0F;
float f3 = (float)(startColor & 255) / 255.0F;
float f4 = (float)(endColor >> 24 & 255) / 255.0F;
float f5 = (float)(endColor >> 16 & 255) / 255.0F;
float f6 = (float)(endColor >> 8 & 255) / 255.0F;
float f7 = (float)(endColor & 255) / 255.0F;
GlStateManager.disableTexture2D();
GlStateManager.enableBlend();
GlStateManager.disableAlpha();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.shadeModel(7425);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_COLOR);
bufferbuilder.pos((double)right, (double)top, (double)this.zLevel).color(f1, f2, f3, f).endVertex();
bufferbuilder.pos((double)left, (double)top, (double)this.zLevel).color(f1, f2, f3, f).endVertex();
bufferbuilder.pos((double)left, (double)bottom, (double)this.zLevel).color(f5, f6, f7, f4).endVertex();
bufferbuilder.pos((double)right, (double)bottom, (double)this.zLevel).color(f5, f6, f7, f4).endVertex();
tessellator.draw();
GlStateManager.shadeModel(7424);
GlStateManager.disableBlend();
GlStateManager.enableAlpha();
GlStateManager.enableTexture2D();
}
/**
* Renders the specified text to the screen, center-aligned. Args : renderer, string, x, y, color
*/
public void drawCenteredString(FontRenderer fontRendererIn, String text, int x, int y, int color)
{
fontRendererIn.drawStringWithShadow(text, (float)(x - fontRendererIn.getStringWidth(text) / 2), (float)y, color);
}
/**
* Renders the specified text to the screen. Args : renderer, string, x, y, color
*/
public void drawString(FontRenderer fontRendererIn, String text, int x, int y, int color)
{
fontRendererIn.drawStringWithShadow(text, (float)x, (float)y, color);
}
/**
* Draws a textured rectangle at the current z-value.
*/
public void drawTexturedModalRect(int x, int y, int textureX, int textureY, int width, int height)
{
float f = 0.00390625F;
float f1 = 0.00390625F;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
bufferbuilder.pos((double)(x + 0), (double)(y + height), (double)this.zLevel).tex((double)((float)(textureX + 0) * 0.00390625F), (double)((float)(textureY + height) * 0.00390625F)).endVertex();
bufferbuilder.pos((double)(x + width), (double)(y + height), (double)this.zLevel).tex((double)((float)(textureX + width) * 0.00390625F), (double)((float)(textureY + height) * 0.00390625F)).endVertex();
bufferbuilder.pos((double)(x + width), (double)(y + 0), (double)this.zLevel).tex((double)((float)(textureX + width) * 0.00390625F), (double)((float)(textureY + 0) * 0.00390625F)).endVertex();
bufferbuilder.pos((double)(x + 0), (double)(y + 0), (double)this.zLevel).tex((double)((float)(textureX + 0) * 0.00390625F), (double)((float)(textureY + 0) * 0.00390625F)).endVertex();
tessellator.draw();
}
/**
* Draws a textured rectangle using the texture currently bound to the TextureManager
*/
public void drawTexturedModalRect(float xCoord, float yCoord, int minU, int minV, int maxU, int maxV)
{
float f = 0.00390625F;
float f1 = 0.00390625F;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
bufferbuilder.pos((double)(xCoord + 0.0F), (double)(yCoord + (float)maxV), (double)this.zLevel).tex((double)((float)(minU + 0) * 0.00390625F), (double)((float)(minV + maxV) * 0.00390625F)).endVertex();
bufferbuilder.pos((double)(xCoord + (float)maxU), (double)(yCoord + (float)maxV), (double)this.zLevel).tex((double)((float)(minU + maxU) * 0.00390625F), (double)((float)(minV + maxV) * 0.00390625F)).endVertex();
bufferbuilder.pos((double)(xCoord + (float)maxU), (double)(yCoord + 0.0F), (double)this.zLevel).tex((double)((float)(minU + maxU) * 0.00390625F), (double)((float)(minV + 0) * 0.00390625F)).endVertex();
bufferbuilder.pos((double)(xCoord + 0.0F), (double)(yCoord + 0.0F), (double)this.zLevel).tex((double)((float)(minU + 0) * 0.00390625F), (double)((float)(minV + 0) * 0.00390625F)).endVertex();
tessellator.draw();
}
/**
* Draws a texture rectangle using the texture currently bound to the TextureManager
*/
public void drawTexturedModalRect(int xCoord, int yCoord, TextureAtlasSprite textureSprite, int widthIn, int heightIn)
{
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
bufferbuilder.pos((double)(xCoord + 0), (double)(yCoord + heightIn), (double)this.zLevel).tex((double)textureSprite.getMinU(), (double)textureSprite.getMaxV()).endVertex();
bufferbuilder.pos((double)(xCoord + widthIn), (double)(yCoord + heightIn), (double)this.zLevel).tex((double)textureSprite.getMaxU(), (double)textureSprite.getMaxV()).endVertex();
bufferbuilder.pos((double)(xCoord + widthIn), (double)(yCoord + 0), (double)this.zLevel).tex((double)textureSprite.getMaxU(), (double)textureSprite.getMinV()).endVertex();
bufferbuilder.pos((double)(xCoord + 0), (double)(yCoord + 0), (double)this.zLevel).tex((double)textureSprite.getMinU(), (double)textureSprite.getMinV()).endVertex();
tessellator.draw();
}
/**
* Draws a textured rectangle at z = 0. Args: x, y, u, v, width, height, textureWidth, textureHeight
*/
public static void drawModalRectWithCustomSizedTexture(int x, int y, float u, float v, int width, int height, float textureWidth, float textureHeight)
{
float f = 1.0F / textureWidth;
float f1 = 1.0F / textureHeight;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
bufferbuilder.pos((double)x, (double)(y + height), 0.0D).tex((double)(u * f), (double)((v + (float)height) * f1)).endVertex();
bufferbuilder.pos((double)(x + width), (double)(y + height), 0.0D).tex((double)((u + (float)width) * f), (double)((v + (float)height) * f1)).endVertex();
bufferbuilder.pos((double)(x + width), (double)y, 0.0D).tex((double)((u + (float)width) * f), (double)(v * f1)).endVertex();
bufferbuilder.pos((double)x, (double)y, 0.0D).tex((double)(u * f), (double)(v * f1)).endVertex();
tessellator.draw();
}
/**
* Draws a scaled, textured, tiled modal rect at z = 0. This method isn't used anywhere in vanilla code.
*/
public static void drawScaledCustomSizeModalRect(int x, int y, float u, float v, int uWidth, int vHeight, int width, int height, float tileWidth, float tileHeight)
{
float f = 1.0F / tileWidth;
float f1 = 1.0F / tileHeight;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
bufferbuilder.pos((double)x, (double)(y + height), 0.0D).tex((double)(u * f), (double)((v + (float)vHeight) * f1)).endVertex();
bufferbuilder.pos((double)(x + width), (double)(y + height), 0.0D).tex((double)((u + (float)uWidth) * f), (double)((v + (float)vHeight) * f1)).endVertex();
bufferbuilder.pos((double)(x + width), (double)y, 0.0D).tex((double)((u + (float)uWidth) * f), (double)(v * f1)).endVertex();
bufferbuilder.pos((double)x, (double)y, 0.0D).tex((double)(u * f), (double)(v * f1)).endVertex();
tessellator.draw();
}
}

View File

@@ -0,0 +1,147 @@
package net.minecraft.client.gui;
import com.google.common.collect.Maps;
import java.util.Map;
import java.util.UUID;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.network.play.server.SPacketUpdateBossInfo;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.BossInfo;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiBossOverlay extends Gui
{
private static final ResourceLocation GUI_BARS_TEXTURES = new ResourceLocation("textures/gui/bars.png");
private final Minecraft client;
private final Map<UUID, BossInfoClient> mapBossInfos = Maps.<UUID, BossInfoClient>newLinkedHashMap();
public GuiBossOverlay(Minecraft clientIn)
{
this.client = clientIn;
}
public void renderBossHealth()
{
if (!this.mapBossInfos.isEmpty())
{
ScaledResolution scaledresolution = new ScaledResolution(this.client);
int i = scaledresolution.getScaledWidth();
int j = 12;
for (BossInfoClient bossinfoclient : this.mapBossInfos.values())
{
int k = i / 2 - 91;
net.minecraftforge.client.event.RenderGameOverlayEvent.BossInfo event =
net.minecraftforge.client.ForgeHooksClient.bossBarRenderPre(scaledresolution, bossinfoclient, k, j, 10 + this.client.fontRenderer.FONT_HEIGHT);
if (!event.isCanceled()) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.client.getTextureManager().bindTexture(GUI_BARS_TEXTURES);
this.render(k, j, bossinfoclient);
String s = bossinfoclient.getName().getFormattedText();
this.client.fontRenderer.drawStringWithShadow(s, (float)(i / 2 - this.client.fontRenderer.getStringWidth(s) / 2), (float)(j - 9), 16777215);
}
j += event.getIncrement();
net.minecraftforge.client.ForgeHooksClient.bossBarRenderPost(scaledresolution);
if (j >= scaledresolution.getScaledHeight() / 3)
{
break;
}
}
}
}
private void render(int x, int y, BossInfo info)
{
this.drawTexturedModalRect(x, y, 0, info.getColor().ordinal() * 5 * 2, 182, 5);
if (info.getOverlay() != BossInfo.Overlay.PROGRESS)
{
this.drawTexturedModalRect(x, y, 0, 80 + (info.getOverlay().ordinal() - 1) * 5 * 2, 182, 5);
}
int i = (int)(info.getPercent() * 183.0F);
if (i > 0)
{
this.drawTexturedModalRect(x, y, 0, info.getColor().ordinal() * 5 * 2 + 5, i, 5);
if (info.getOverlay() != BossInfo.Overlay.PROGRESS)
{
this.drawTexturedModalRect(x, y, 0, 80 + (info.getOverlay().ordinal() - 1) * 5 * 2 + 5, i, 5);
}
}
}
public void read(SPacketUpdateBossInfo packetIn)
{
if (packetIn.getOperation() == SPacketUpdateBossInfo.Operation.ADD)
{
this.mapBossInfos.put(packetIn.getUniqueId(), new BossInfoClient(packetIn));
}
else if (packetIn.getOperation() == SPacketUpdateBossInfo.Operation.REMOVE)
{
this.mapBossInfos.remove(packetIn.getUniqueId());
}
else
{
((BossInfoClient)this.mapBossInfos.get(packetIn.getUniqueId())).updateFromPacket(packetIn);
}
}
public void clearBossInfos()
{
this.mapBossInfos.clear();
}
public boolean shouldPlayEndBossMusic()
{
if (!this.mapBossInfos.isEmpty())
{
for (BossInfo bossinfo : this.mapBossInfos.values())
{
if (bossinfo.shouldPlayEndBossMusic())
{
return true;
}
}
}
return false;
}
public boolean shouldDarkenSky()
{
if (!this.mapBossInfos.isEmpty())
{
for (BossInfo bossinfo : this.mapBossInfos.values())
{
if (bossinfo.shouldDarkenSky())
{
return true;
}
}
}
return false;
}
public boolean shouldCreateFog()
{
if (!this.mapBossInfos.isEmpty())
{
for (BossInfo bossinfo : this.mapBossInfos.values())
{
if (bossinfo.shouldCreateFog())
{
return true;
}
}
}
return false;
}
}

View File

@@ -0,0 +1,160 @@
package net.minecraft.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.audio.SoundHandler;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.init.SoundEvents;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiButton extends Gui
{
protected static final ResourceLocation BUTTON_TEXTURES = new ResourceLocation("textures/gui/widgets.png");
/** Button width in pixels */
public int width;
/** Button height in pixels */
public int height;
/** The x position of this control. */
public int x;
/** The y position of this control. */
public int y;
/** The string displayed on this control. */
public String displayString;
public int id;
/** True if this control is enabled, false to disable. */
public boolean enabled;
/** Hides the button completely if false. */
public boolean visible;
protected boolean hovered;
public int packedFGColour; //FML
public GuiButton(int buttonId, int x, int y, String buttonText)
{
this(buttonId, x, y, 200, 20, buttonText);
}
public GuiButton(int buttonId, int x, int y, int widthIn, int heightIn, String buttonText)
{
this.width = 200;
this.height = 20;
this.enabled = true;
this.visible = true;
this.id = buttonId;
this.x = x;
this.y = y;
this.width = widthIn;
this.height = heightIn;
this.displayString = buttonText;
}
/**
* Returns 0 if the button is disabled, 1 if the mouse is NOT hovering over this button and 2 if it IS hovering over
* this button.
*/
protected int getHoverState(boolean mouseOver)
{
int i = 1;
if (!this.enabled)
{
i = 0;
}
else if (mouseOver)
{
i = 2;
}
return i;
}
/**
* Draws this button to the screen.
*/
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks)
{
if (this.visible)
{
FontRenderer fontrenderer = mc.fontRenderer;
mc.getTextureManager().bindTexture(BUTTON_TEXTURES);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
int i = this.getHoverState(this.hovered);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.x, this.y, 0, 46 + i * 20, this.width / 2, this.height);
this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height);
this.mouseDragged(mc, mouseX, mouseY);
int j = 14737632;
if (packedFGColour != 0)
{
j = packedFGColour;
}
else
if (!this.enabled)
{
j = 10526880;
}
else if (this.hovered)
{
j = 16777120;
}
this.drawCenteredString(fontrenderer, this.displayString, this.x + this.width / 2, this.y + (this.height - 8) / 2, j);
}
}
/**
* Fired when the mouse button is dragged. Equivalent of MouseListener.mouseDragged(MouseEvent e).
*/
protected void mouseDragged(Minecraft mc, int mouseX, int mouseY)
{
}
/**
* Fired when the mouse button is released. Equivalent of MouseListener.mouseReleased(MouseEvent e).
*/
public void mouseReleased(int mouseX, int mouseY)
{
}
/**
* Returns true if the mouse has been pressed on this control. Equivalent of MouseListener.mousePressed(MouseEvent
* e).
*/
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY)
{
return this.enabled && this.visible && mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
}
/**
* Whether the mouse cursor is currently over the button.
*/
public boolean isMouseOver()
{
return this.hovered;
}
public void drawButtonForegroundLayer(int mouseX, int mouseY)
{
}
public void playPressSound(SoundHandler soundHandlerIn)
{
soundHandlerIn.playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
}
public int getButtonWidth()
{
return this.width;
}
public void setWidth(int width)
{
this.width = width;
}
}

View File

@@ -0,0 +1,54 @@
package net.minecraft.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiButtonImage extends GuiButton
{
private final ResourceLocation resourceLocation;
private final int xTexStart;
private final int yTexStart;
private final int yDiffText;
public GuiButtonImage(int p_i47392_1_, int p_i47392_2_, int p_i47392_3_, int p_i47392_4_, int p_i47392_5_, int p_i47392_6_, int p_i47392_7_, int p_i47392_8_, ResourceLocation p_i47392_9_)
{
super(p_i47392_1_, p_i47392_2_, p_i47392_3_, p_i47392_4_, p_i47392_5_, "");
this.xTexStart = p_i47392_6_;
this.yTexStart = p_i47392_7_;
this.yDiffText = p_i47392_8_;
this.resourceLocation = p_i47392_9_;
}
public void setPosition(int p_191746_1_, int p_191746_2_)
{
this.x = p_191746_1_;
this.y = p_191746_2_;
}
/**
* Draws this button to the screen.
*/
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks)
{
if (this.visible)
{
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
mc.getTextureManager().bindTexture(this.resourceLocation);
GlStateManager.disableDepth();
int i = this.xTexStart;
int j = this.yTexStart;
if (this.hovered)
{
j += this.yDiffText;
}
this.drawTexturedModalRect(this.x, this.y, i, j, this.width, this.height);
GlStateManager.enableDepth();
}
}
}

View File

@@ -0,0 +1,36 @@
package net.minecraft.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiButtonLanguage extends GuiButton
{
public GuiButtonLanguage(int buttonID, int xPos, int yPos)
{
super(buttonID, xPos, yPos, 20, 20, "");
}
/**
* Draws this button to the screen.
*/
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks)
{
if (this.visible)
{
mc.getTextureManager().bindTexture(GuiButton.BUTTON_TEXTURES);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
boolean flag = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
int i = 106;
if (flag)
{
i += this.height;
}
this.drawTexturedModalRect(this.x, this.y, 0, i, this.width, this.height);
}
}
}

View File

@@ -0,0 +1,108 @@
package net.minecraft.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.realms.RealmsButton;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiButtonRealmsProxy extends GuiButton
{
private final RealmsButton realmsButton;
public GuiButtonRealmsProxy(RealmsButton realmsButtonIn, int buttonId, int x, int y, String text)
{
super(buttonId, x, y, text);
this.realmsButton = realmsButtonIn;
}
public GuiButtonRealmsProxy(RealmsButton realmsButtonIn, int buttonId, int x, int y, String text, int widthIn, int heightIn)
{
super(buttonId, x, y, widthIn, heightIn, text);
this.realmsButton = realmsButtonIn;
}
public int getId()
{
return this.id;
}
public boolean getEnabled()
{
return this.enabled;
}
public void setEnabled(boolean isEnabled)
{
this.enabled = isEnabled;
}
public void setText(String text)
{
super.displayString = text;
}
public int getButtonWidth()
{
return super.getButtonWidth();
}
public int getPositionY()
{
return this.y;
}
/**
* Returns true if the mouse has been pressed on this control. Equivalent of MouseListener.mousePressed(MouseEvent
* e).
*/
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY)
{
if (super.mousePressed(mc, mouseX, mouseY))
{
this.realmsButton.clicked(mouseX, mouseY);
}
return super.mousePressed(mc, mouseX, mouseY);
}
/**
* Fired when the mouse button is released. Equivalent of MouseListener.mouseReleased(MouseEvent e).
*/
public void mouseReleased(int mouseX, int mouseY)
{
this.realmsButton.released(mouseX, mouseY);
}
/**
* Fired when the mouse button is dragged. Equivalent of MouseListener.mouseDragged(MouseEvent e).
*/
public void mouseDragged(Minecraft mc, int mouseX, int mouseY)
{
this.realmsButton.renderBg(mouseX, mouseY);
}
public RealmsButton getRealmsButton()
{
return this.realmsButton;
}
/**
* Returns 0 if the button is disabled, 1 if the mouse is NOT hovering over this button and 2 if it IS hovering over
* this button.
*/
public int getHoverState(boolean mouseOver)
{
return this.realmsButton.getYImage(mouseOver);
}
public int getYImage(boolean p_154312_1_)
{
return super.getHoverState(p_154312_1_);
}
public int getHeight()
{
return this.height;
}
}

View File

@@ -0,0 +1,77 @@
package net.minecraft.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiButtonToggle extends GuiButton
{
protected ResourceLocation resourceLocation;
protected boolean stateTriggered;
protected int xTexStart;
protected int yTexStart;
protected int xDiffTex;
protected int yDiffTex;
public GuiButtonToggle(int buttonId, int xIn, int yIn, int widthIn, int heightIn, boolean buttonText)
{
super(buttonId, xIn, yIn, widthIn, heightIn, "");
this.stateTriggered = buttonText;
}
public void initTextureValues(int xTexStartIn, int yTexStartIn, int xDiffTexIn, int yDiffTexIn, ResourceLocation resourceLocationIn)
{
this.xTexStart = xTexStartIn;
this.yTexStart = yTexStartIn;
this.xDiffTex = xDiffTexIn;
this.yDiffTex = yDiffTexIn;
this.resourceLocation = resourceLocationIn;
}
public void setStateTriggered(boolean p_191753_1_)
{
this.stateTriggered = p_191753_1_;
}
public boolean isStateTriggered()
{
return this.stateTriggered;
}
public void setPosition(int p_191752_1_, int p_191752_2_)
{
this.x = p_191752_1_;
this.y = p_191752_2_;
}
/**
* Draws this button to the screen.
*/
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks)
{
if (this.visible)
{
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
mc.getTextureManager().bindTexture(this.resourceLocation);
GlStateManager.disableDepth();
int i = this.xTexStart;
int j = this.yTexStart;
if (this.stateTriggered)
{
i += this.xDiffTex;
}
if (this.hovered)
{
j += this.yDiffTex;
}
this.drawTexturedModalRect(this.x, this.y, i, j, this.width, this.height);
GlStateManager.enableDepth();
}
}
}

View File

@@ -0,0 +1,312 @@
package net.minecraft.client.gui;
import java.io.IOException;
import javax.annotation.Nullable;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ITabCompleter;
import net.minecraft.util.TabCompleter;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
@SideOnly(Side.CLIENT)
public class GuiChat extends GuiScreen implements ITabCompleter
{
private static final Logger LOGGER = LogManager.getLogger();
private String historyBuffer = "";
/**
* keeps position of which chat message you will select when you press up, (does not increase for duplicated
* messages sent immediately after each other)
*/
private int sentHistoryCursor = -1;
private TabCompleter tabCompleter;
/** Chat entry field */
protected GuiTextField inputField;
/** is the text that appears when you press the chat key and the input box appears pre-filled */
private String defaultInputFieldText = "";
public GuiChat()
{
}
public GuiChat(String defaultText)
{
this.defaultInputFieldText = defaultText;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
Keyboard.enableRepeatEvents(true);
this.sentHistoryCursor = this.mc.ingameGUI.getChatGUI().getSentMessages().size();
this.inputField = new GuiTextField(0, this.fontRenderer, 4, this.height - 12, this.width - 4, 12);
this.inputField.setMaxStringLength(256);
this.inputField.setEnableBackgroundDrawing(false);
this.inputField.setFocused(true);
this.inputField.setText(this.defaultInputFieldText);
this.inputField.setCanLoseFocus(false);
this.tabCompleter = new GuiChat.ChatTabCompleter(this.inputField);
}
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
Keyboard.enableRepeatEvents(false);
this.mc.ingameGUI.getChatGUI().resetScroll();
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
this.inputField.updateCursorCounter();
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
this.tabCompleter.resetRequested();
if (keyCode == 15)
{
this.tabCompleter.complete();
}
else
{
this.tabCompleter.resetDidComplete();
}
if (keyCode == 1)
{
this.mc.displayGuiScreen((GuiScreen)null);
}
else if (keyCode != 28 && keyCode != 156)
{
if (keyCode == 200)
{
this.getSentHistory(-1);
}
else if (keyCode == 208)
{
this.getSentHistory(1);
}
else if (keyCode == 201)
{
this.mc.ingameGUI.getChatGUI().scroll(this.mc.ingameGUI.getChatGUI().getLineCount() - 1);
}
else if (keyCode == 209)
{
this.mc.ingameGUI.getChatGUI().scroll(-this.mc.ingameGUI.getChatGUI().getLineCount() + 1);
}
else
{
this.inputField.textboxKeyTyped(typedChar, keyCode);
}
}
else
{
String s = this.inputField.getText().trim();
if (!s.isEmpty())
{
this.sendChatMessage(s);
}
this.mc.displayGuiScreen((GuiScreen)null);
}
}
/**
* Handles mouse input.
*/
public void handleMouseInput() throws IOException
{
super.handleMouseInput();
int i = Mouse.getEventDWheel();
if (i != 0)
{
if (i > 1)
{
i = 1;
}
if (i < -1)
{
i = -1;
}
if (!isShiftKeyDown())
{
i *= 7;
}
this.mc.ingameGUI.getChatGUI().scroll(i);
}
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
if (mouseButton == 0)
{
ITextComponent itextcomponent = this.mc.ingameGUI.getChatGUI().getChatComponent(Mouse.getX(), Mouse.getY());
if (itextcomponent != null && this.handleComponentClick(itextcomponent))
{
return;
}
}
this.inputField.mouseClicked(mouseX, mouseY, mouseButton);
super.mouseClicked(mouseX, mouseY, mouseButton);
}
/**
* Sets the text of the chat
*/
protected void setText(String newChatText, boolean shouldOverwrite)
{
if (shouldOverwrite)
{
this.inputField.setText(newChatText);
}
else
{
this.inputField.writeText(newChatText);
}
}
/**
* input is relative and is applied directly to the sentHistoryCursor so -1 is the previous message, 1 is the next
* message from the current cursor position
*/
public void getSentHistory(int msgPos)
{
int i = this.sentHistoryCursor + msgPos;
int j = this.mc.ingameGUI.getChatGUI().getSentMessages().size();
i = MathHelper.clamp(i, 0, j);
if (i != this.sentHistoryCursor)
{
if (i == j)
{
this.sentHistoryCursor = j;
this.inputField.setText(this.historyBuffer);
}
else
{
if (this.sentHistoryCursor == j)
{
this.historyBuffer = this.inputField.getText();
}
this.inputField.setText((String)this.mc.ingameGUI.getChatGUI().getSentMessages().get(i));
this.sentHistoryCursor = i;
}
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
drawRect(2, this.height - 14, this.width - 2, this.height - 2, Integer.MIN_VALUE);
this.inputField.drawTextBox();
ITextComponent itextcomponent = this.mc.ingameGUI.getChatGUI().getChatComponent(Mouse.getX(), Mouse.getY());
if (itextcomponent != null && itextcomponent.getStyle().getHoverEvent() != null)
{
this.handleComponentHover(itextcomponent, mouseX, mouseY);
}
super.drawScreen(mouseX, mouseY, partialTicks);
}
/**
* Returns true if this GUI should pause the game when it is displayed in single-player
*/
public boolean doesGuiPauseGame()
{
return false;
}
/**
* Sets the list of tab completions, as long as they were previously requested.
*/
public void setCompletions(String... newCompletions)
{
this.tabCompleter.setCompletions(newCompletions);
}
@SideOnly(Side.CLIENT)
public static class ChatTabCompleter extends TabCompleter
{
/** The instance of the Minecraft client */
private final Minecraft client = Minecraft.getMinecraft();
public ChatTabCompleter(GuiTextField p_i46749_1_)
{
super(p_i46749_1_, false);
}
/**
* Called when tab key pressed. If it's the first time we tried to complete this string, we ask the server
* for completions. When the server responds, this method gets called again (via setCompletions).
*/
public void complete()
{
super.complete();
if (this.completions.size() > 1)
{
StringBuilder stringbuilder = new StringBuilder();
for (String s : this.completions)
{
if (stringbuilder.length() > 0)
{
stringbuilder.append(", ");
}
stringbuilder.append(s);
}
this.client.ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new TextComponentString(stringbuilder.toString()), 1);
}
}
@Nullable
public BlockPos getTargetBlockPos()
{
BlockPos blockpos = null;
if (this.client.objectMouseOver != null && this.client.objectMouseOver.typeOfHit == RayTraceResult.Type.BLOCK)
{
blockpos = this.client.objectMouseOver.getBlockPos();
}
return blockpos;
}
}
}

View File

@@ -0,0 +1,120 @@
package net.minecraft.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.realms.RealmsClickableScrolledSelectionList;
import net.minecraft.realms.Tezzelator;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.input.Mouse;
@SideOnly(Side.CLIENT)
public class GuiClickableScrolledSelectionListProxy extends GuiSlot
{
private final RealmsClickableScrolledSelectionList proxy;
public GuiClickableScrolledSelectionListProxy(RealmsClickableScrolledSelectionList selectionList, int widthIn, int heightIn, int topIn, int bottomIn, int slotHeightIn)
{
super(Minecraft.getMinecraft(), widthIn, heightIn, topIn, bottomIn, slotHeightIn);
this.proxy = selectionList;
}
protected int getSize()
{
return this.proxy.getItemCount();
}
/**
* The element in the slot that was clicked, boolean for whether it was double clicked or not
*/
protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY)
{
this.proxy.selectItem(slotIndex, isDoubleClick, mouseX, mouseY);
}
/**
* Returns true if the element passed in is currently selected
*/
protected boolean isSelected(int slotIndex)
{
return this.proxy.isSelectedItem(slotIndex);
}
protected void drawBackground()
{
this.proxy.renderBackground();
}
protected void drawSlot(int slotIndex, int xPos, int yPos, int heightIn, int mouseXIn, int mouseYIn, float partialTicks)
{
this.proxy.renderItem(slotIndex, xPos, yPos, heightIn, mouseXIn, mouseYIn);
}
public int width()
{
return this.width;
}
public int mouseY()
{
return this.mouseY;
}
public int mouseX()
{
return this.mouseX;
}
/**
* Return the height of the content being scrolled
*/
protected int getContentHeight()
{
return this.proxy.getMaxPosition();
}
protected int getScrollBarX()
{
return this.proxy.getScrollbarPosition();
}
public void handleMouseInput()
{
super.handleMouseInput();
if (this.scrollMultiplier > 0.0F && Mouse.getEventButtonState())
{
this.proxy.customMouseEvent(this.top, this.bottom, this.headerPadding, this.amountScrolled, this.slotHeight);
}
}
public void renderSelected(int p_178043_1_, int p_178043_2_, int p_178043_3_, Tezzelator p_178043_4_)
{
this.proxy.renderSelected(p_178043_1_, p_178043_2_, p_178043_3_, p_178043_4_);
}
/**
* Draws the selection box around the selected slot element.
*/
protected void drawSelectionBox(int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks)
{
int i = this.getSize();
for (int j = 0; j < i; ++j)
{
int k = insideTop + j * this.slotHeight + this.headerPadding;
int l = this.slotHeight - 4;
if (k > this.bottom || k + l < this.top)
{
this.updateItemPos(j, insideLeft, k, partialTicks);
}
if (this.showSelectionBox && this.isSelected(j))
{
this.renderSelected(this.width, k, l, Tezzelator.instance);
}
this.drawSlot(j, insideLeft, k, l, mouseXIn, mouseYIn, partialTicks);
}
}
}

View File

@@ -0,0 +1,322 @@
package net.minecraft.client.gui;
import io.netty.buffer.Unpooled;
import java.io.IOException;
import javax.annotation.Nullable;
import net.minecraft.client.resources.I18n;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.client.CPacketCustomPayload;
import net.minecraft.tileentity.CommandBlockBaseLogic;
import net.minecraft.tileentity.TileEntityCommandBlock;
import net.minecraft.util.ITabCompleter;
import net.minecraft.util.TabCompleter;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.input.Keyboard;
@SideOnly(Side.CLIENT)
public class GuiCommandBlock extends GuiScreen implements ITabCompleter
{
/** Text field containing the command block's command. */
private GuiTextField commandTextField;
private GuiTextField previousOutputTextField;
private final TileEntityCommandBlock commandBlock;
/** "Done" button for the GUI. */
private GuiButton doneBtn;
private GuiButton cancelBtn;
private GuiButton outputBtn;
private GuiButton modeBtn;
private GuiButton conditionalBtn;
private GuiButton autoExecBtn;
private boolean trackOutput;
private TileEntityCommandBlock.Mode commandBlockMode = TileEntityCommandBlock.Mode.REDSTONE;
private TabCompleter tabCompleter;
private boolean conditional;
private boolean automatic;
public GuiCommandBlock(TileEntityCommandBlock commandBlockIn)
{
this.commandBlock = commandBlockIn;
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
this.commandTextField.updateCursorCounter();
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
final CommandBlockBaseLogic commandblockbaselogic = this.commandBlock.getCommandBlockLogic();
Keyboard.enableRepeatEvents(true);
this.buttonList.clear();
this.doneBtn = this.addButton(new GuiButton(0, this.width / 2 - 4 - 150, this.height / 4 + 120 + 12, 150, 20, I18n.format("gui.done")));
this.cancelBtn = this.addButton(new GuiButton(1, this.width / 2 + 4, this.height / 4 + 120 + 12, 150, 20, I18n.format("gui.cancel")));
this.outputBtn = this.addButton(new GuiButton(4, this.width / 2 + 150 - 20, 135, 20, 20, "O"));
this.modeBtn = this.addButton(new GuiButton(5, this.width / 2 - 50 - 100 - 4, 165, 100, 20, I18n.format("advMode.mode.sequence")));
this.conditionalBtn = this.addButton(new GuiButton(6, this.width / 2 - 50, 165, 100, 20, I18n.format("advMode.mode.unconditional")));
this.autoExecBtn = this.addButton(new GuiButton(7, this.width / 2 + 50 + 4, 165, 100, 20, I18n.format("advMode.mode.redstoneTriggered")));
this.commandTextField = new GuiTextField(2, this.fontRenderer, this.width / 2 - 150, 50, 300, 20);
this.commandTextField.setMaxStringLength(32500);
this.commandTextField.setFocused(true);
this.previousOutputTextField = new GuiTextField(3, this.fontRenderer, this.width / 2 - 150, 135, 276, 20);
this.previousOutputTextField.setMaxStringLength(32500);
this.previousOutputTextField.setEnabled(false);
this.previousOutputTextField.setText("-");
this.doneBtn.enabled = false;
this.outputBtn.enabled = false;
this.modeBtn.enabled = false;
this.conditionalBtn.enabled = false;
this.autoExecBtn.enabled = false;
this.tabCompleter = new TabCompleter(this.commandTextField, true)
{
@Nullable
public BlockPos getTargetBlockPos()
{
return commandblockbaselogic.getPosition();
}
};
}
public void updateGui()
{
CommandBlockBaseLogic commandblockbaselogic = this.commandBlock.getCommandBlockLogic();
this.commandTextField.setText(commandblockbaselogic.getCommand());
this.trackOutput = commandblockbaselogic.shouldTrackOutput();
this.commandBlockMode = this.commandBlock.getMode();
this.conditional = this.commandBlock.isConditional();
this.automatic = this.commandBlock.isAuto();
this.updateCmdOutput();
this.updateMode();
this.updateConditional();
this.updateAutoExec();
this.doneBtn.enabled = true;
this.outputBtn.enabled = true;
this.modeBtn.enabled = true;
this.conditionalBtn.enabled = true;
this.autoExecBtn.enabled = true;
}
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
Keyboard.enableRepeatEvents(false);
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.enabled)
{
CommandBlockBaseLogic commandblockbaselogic = this.commandBlock.getCommandBlockLogic();
if (button.id == 1)
{
commandblockbaselogic.setTrackOutput(this.trackOutput);
this.mc.displayGuiScreen((GuiScreen)null);
}
else if (button.id == 0)
{
PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
commandblockbaselogic.fillInInfo(packetbuffer);
packetbuffer.writeString(this.commandTextField.getText());
packetbuffer.writeBoolean(commandblockbaselogic.shouldTrackOutput());
packetbuffer.writeString(this.commandBlockMode.name());
packetbuffer.writeBoolean(this.conditional);
packetbuffer.writeBoolean(this.automatic);
this.mc.getConnection().sendPacket(new CPacketCustomPayload("MC|AutoCmd", packetbuffer));
if (!commandblockbaselogic.shouldTrackOutput())
{
commandblockbaselogic.setLastOutput((ITextComponent)null);
}
this.mc.displayGuiScreen((GuiScreen)null);
}
else if (button.id == 4)
{
commandblockbaselogic.setTrackOutput(!commandblockbaselogic.shouldTrackOutput());
this.updateCmdOutput();
}
else if (button.id == 5)
{
this.nextMode();
this.updateMode();
}
else if (button.id == 6)
{
this.conditional = !this.conditional;
this.updateConditional();
}
else if (button.id == 7)
{
this.automatic = !this.automatic;
this.updateAutoExec();
}
}
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
this.tabCompleter.resetRequested();
if (keyCode == 15)
{
this.tabCompleter.complete();
}
else
{
this.tabCompleter.resetDidComplete();
}
this.commandTextField.textboxKeyTyped(typedChar, keyCode);
this.previousOutputTextField.textboxKeyTyped(typedChar, keyCode);
if (keyCode != 28 && keyCode != 156)
{
if (keyCode == 1)
{
this.actionPerformed(this.cancelBtn);
}
}
else
{
this.actionPerformed(this.doneBtn);
}
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
super.mouseClicked(mouseX, mouseY, mouseButton);
this.commandTextField.mouseClicked(mouseX, mouseY, mouseButton);
this.previousOutputTextField.mouseClicked(mouseX, mouseY, mouseButton);
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, I18n.format("advMode.setCommand"), this.width / 2, 20, 16777215);
this.drawString(this.fontRenderer, I18n.format("advMode.command"), this.width / 2 - 150, 40, 10526880);
this.commandTextField.drawTextBox();
int i = 75;
int j = 0;
this.drawString(this.fontRenderer, I18n.format("advMode.nearestPlayer"), this.width / 2 - 140, i + j++ * this.fontRenderer.FONT_HEIGHT, 10526880);
this.drawString(this.fontRenderer, I18n.format("advMode.randomPlayer"), this.width / 2 - 140, i + j++ * this.fontRenderer.FONT_HEIGHT, 10526880);
this.drawString(this.fontRenderer, I18n.format("advMode.allPlayers"), this.width / 2 - 140, i + j++ * this.fontRenderer.FONT_HEIGHT, 10526880);
this.drawString(this.fontRenderer, I18n.format("advMode.allEntities"), this.width / 2 - 140, i + j++ * this.fontRenderer.FONT_HEIGHT, 10526880);
this.drawString(this.fontRenderer, I18n.format("advMode.self"), this.width / 2 - 140, i + j++ * this.fontRenderer.FONT_HEIGHT, 10526880);
if (!this.previousOutputTextField.getText().isEmpty())
{
i = i + j * this.fontRenderer.FONT_HEIGHT + 1;
this.drawString(this.fontRenderer, I18n.format("advMode.previousOutput"), this.width / 2 - 150, i + 4, 10526880);
this.previousOutputTextField.drawTextBox();
}
super.drawScreen(mouseX, mouseY, partialTicks);
}
private void updateCmdOutput()
{
CommandBlockBaseLogic commandblockbaselogic = this.commandBlock.getCommandBlockLogic();
if (commandblockbaselogic.shouldTrackOutput())
{
this.outputBtn.displayString = "O";
if (commandblockbaselogic.getLastOutput() != null)
{
this.previousOutputTextField.setText(commandblockbaselogic.getLastOutput().getUnformattedText());
}
}
else
{
this.outputBtn.displayString = "X";
this.previousOutputTextField.setText("-");
}
}
private void updateMode()
{
switch (this.commandBlockMode)
{
case SEQUENCE:
this.modeBtn.displayString = I18n.format("advMode.mode.sequence");
break;
case AUTO:
this.modeBtn.displayString = I18n.format("advMode.mode.auto");
break;
case REDSTONE:
this.modeBtn.displayString = I18n.format("advMode.mode.redstone");
}
}
private void nextMode()
{
switch (this.commandBlockMode)
{
case SEQUENCE:
this.commandBlockMode = TileEntityCommandBlock.Mode.AUTO;
break;
case AUTO:
this.commandBlockMode = TileEntityCommandBlock.Mode.REDSTONE;
break;
case REDSTONE:
this.commandBlockMode = TileEntityCommandBlock.Mode.SEQUENCE;
}
}
private void updateConditional()
{
if (this.conditional)
{
this.conditionalBtn.displayString = I18n.format("advMode.mode.conditional");
}
else
{
this.conditionalBtn.displayString = I18n.format("advMode.mode.unconditional");
}
}
private void updateAutoExec()
{
if (this.automatic)
{
this.autoExecBtn.displayString = I18n.format("advMode.mode.autoexec.bat");
}
else
{
this.autoExecBtn.displayString = I18n.format("advMode.mode.redstoneTriggered");
}
}
/**
* Sets the list of tab completions, as long as they were previously requested.
*/
public void setCompletions(String... newCompletions)
{
this.tabCompleter.setCompletions(newCompletions);
}
}

View File

@@ -0,0 +1,79 @@
package net.minecraft.client.gui;
import java.io.IOException;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiConfirmOpenLink extends GuiYesNo
{
/** Text to warn players from opening unsafe links. */
private final String openLinkWarning;
/** Label for the Copy to Clipboard button. */
private final String copyLinkButtonText;
private final String linkText;
private boolean showSecurityWarning = true;
public GuiConfirmOpenLink(GuiYesNoCallback parentScreenIn, String linkTextIn, int parentButtonClickedIdIn, boolean trusted)
{
super(parentScreenIn, I18n.format(trusted ? "chat.link.confirmTrusted" : "chat.link.confirm"), linkTextIn, parentButtonClickedIdIn);
this.confirmButtonText = I18n.format(trusted ? "chat.link.open" : "gui.yes");
this.cancelButtonText = I18n.format(trusted ? "gui.cancel" : "gui.no");
this.copyLinkButtonText = I18n.format("chat.copy");
this.openLinkWarning = I18n.format("chat.link.warning");
this.linkText = linkTextIn;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
super.initGui();
this.buttonList.clear();
this.buttonList.add(new GuiButton(0, this.width / 2 - 50 - 105, this.height / 6 + 96, 100, 20, this.confirmButtonText));
this.buttonList.add(new GuiButton(2, this.width / 2 - 50, this.height / 6 + 96, 100, 20, this.copyLinkButtonText));
this.buttonList.add(new GuiButton(1, this.width / 2 - 50 + 105, this.height / 6 + 96, 100, 20, this.cancelButtonText));
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.id == 2)
{
this.copyLinkToClipboard();
}
this.parentScreen.confirmClicked(button.id == 0, this.parentButtonClickedId);
}
/**
* Copies the link to the system clipboard.
*/
public void copyLinkToClipboard()
{
setClipboardString(this.linkText);
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
super.drawScreen(mouseX, mouseY, partialTicks);
if (this.showSecurityWarning)
{
this.drawCenteredString(this.fontRenderer, this.openLinkWarning, this.width / 2, 110, 16764108);
}
}
public void disableSecurityWarning()
{
this.showSecurityWarning = false;
}
}

View File

@@ -0,0 +1,179 @@
package net.minecraft.client.gui;
import java.io.IOException;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.client.settings.KeyBinding;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiControls extends GuiScreen
{
private static final GameSettings.Options[] OPTIONS_ARR = new GameSettings.Options[] {GameSettings.Options.INVERT_MOUSE, GameSettings.Options.SENSITIVITY, GameSettings.Options.TOUCHSCREEN, GameSettings.Options.AUTO_JUMP};
/** A reference to the screen object that created this. Used for navigating between screens. */
private final GuiScreen parentScreen;
protected String screenTitle = "Controls";
/** Reference to the GameSettings object. */
private final GameSettings options;
/** The ID of the button that has been pressed. */
public KeyBinding buttonId;
public long time;
private GuiKeyBindingList keyBindingList;
private GuiButton buttonReset;
public GuiControls(GuiScreen screen, GameSettings settings)
{
this.parentScreen = screen;
this.options = settings;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.keyBindingList = new GuiKeyBindingList(this, this.mc);
this.buttonList.add(new GuiButton(200, this.width / 2 - 155 + 160, this.height - 29, 150, 20, I18n.format("gui.done")));
this.buttonReset = this.addButton(new GuiButton(201, this.width / 2 - 155, this.height - 29, 150, 20, I18n.format("controls.resetAll")));
this.screenTitle = I18n.format("controls.title");
int i = 0;
for (GameSettings.Options gamesettings$options : OPTIONS_ARR)
{
if (gamesettings$options.isFloat())
{
this.buttonList.add(new GuiOptionSlider(gamesettings$options.getOrdinal(), this.width / 2 - 155 + i % 2 * 160, 18 + 24 * (i >> 1), gamesettings$options));
}
else
{
this.buttonList.add(new GuiOptionButton(gamesettings$options.getOrdinal(), this.width / 2 - 155 + i % 2 * 160, 18 + 24 * (i >> 1), gamesettings$options, this.options.getKeyBinding(gamesettings$options)));
}
++i;
}
}
/**
* Handles mouse input.
*/
public void handleMouseInput() throws IOException
{
super.handleMouseInput();
this.keyBindingList.handleMouseInput();
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.id == 200)
{
this.mc.displayGuiScreen(this.parentScreen);
}
else if (button.id == 201)
{
for (KeyBinding keybinding : this.mc.gameSettings.keyBindings)
{
keybinding.setToDefault();
}
KeyBinding.resetKeyBindingArrayAndHash();
}
else if (button.id < 100 && button instanceof GuiOptionButton)
{
this.options.setOptionValue(((GuiOptionButton)button).getOption(), 1);
button.displayString = this.options.getKeyBinding(GameSettings.Options.byOrdinal(button.id));
}
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
if (this.buttonId != null)
{
this.buttonId.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), -100 + mouseButton);
this.options.setOptionKeyBinding(this.buttonId, -100 + mouseButton);
this.buttonId = null;
KeyBinding.resetKeyBindingArrayAndHash();
}
else if (mouseButton != 0 || !this.keyBindingList.mouseClicked(mouseX, mouseY, mouseButton))
{
super.mouseClicked(mouseX, mouseY, mouseButton);
}
}
/**
* Called when a mouse button is released.
*/
protected void mouseReleased(int mouseX, int mouseY, int state)
{
if (state != 0 || !this.keyBindingList.mouseReleased(mouseX, mouseY, state))
{
super.mouseReleased(mouseX, mouseY, state);
}
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
if (this.buttonId != null)
{
if (keyCode == 1)
{
this.buttonId.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.NONE, 0);
this.options.setOptionKeyBinding(this.buttonId, 0);
}
else if (keyCode != 0)
{
this.buttonId.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), keyCode);
this.options.setOptionKeyBinding(this.buttonId, keyCode);
}
else if (typedChar > 0)
{
this.buttonId.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), typedChar + 256);
this.options.setOptionKeyBinding(this.buttonId, typedChar + 256);
}
if (!net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(keyCode))
this.buttonId = null;
this.time = Minecraft.getSystemTime();
KeyBinding.resetKeyBindingArrayAndHash();
}
else
{
super.keyTyped(typedChar, keyCode);
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.keyBindingList.drawScreen(mouseX, mouseY, partialTicks);
this.drawCenteredString(this.fontRenderer, this.screenTitle, this.width / 2, 8, 16777215);
boolean flag = false;
for (KeyBinding keybinding : this.options.keyBindings)
{
if (!keybinding.isSetToDefaultValue())
{
flag = true;
break;
}
}
this.buttonReset.enabled = flag;
super.drawScreen(mouseX, mouseY, partialTicks);
}
}

View File

@@ -0,0 +1,296 @@
package net.minecraft.client.gui;
import java.io.IOException;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.resources.I18n;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.gen.FlatGeneratorInfo;
import net.minecraft.world.gen.FlatLayerInfo;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiCreateFlatWorld extends GuiScreen
{
private final GuiCreateWorld createWorldGui;
private FlatGeneratorInfo generatorInfo = FlatGeneratorInfo.getDefaultFlatGenerator();
/** The title given to the flat world currently in creation */
private String flatWorldTitle;
/** The text used to identify the material for a layer */
private String materialText;
/** The text used to identify the height of a layer */
private String heightText;
private GuiCreateFlatWorld.Details createFlatWorldListSlotGui;
/** The (unused and permenantly hidden) add layer button */
private GuiButton addLayerButton;
/** The (unused and permenantly hidden) edit layer button */
private GuiButton editLayerButton;
/** The remove layer button */
private GuiButton removeLayerButton;
public GuiCreateFlatWorld(GuiCreateWorld createWorldGuiIn, String preset)
{
this.createWorldGui = createWorldGuiIn;
this.setPreset(preset);
}
/**
* Gets the superflat preset in the text format described on the Superflat article on the Minecraft Wiki
*/
public String getPreset()
{
return this.generatorInfo.toString();
}
/**
* Sets the superflat preset. Invalid or null values will result in the default superflat preset being used.
*/
public void setPreset(String preset)
{
this.generatorInfo = FlatGeneratorInfo.createFlatGeneratorFromString(preset);
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.buttonList.clear();
this.flatWorldTitle = I18n.format("createWorld.customize.flat.title");
this.materialText = I18n.format("createWorld.customize.flat.tile");
this.heightText = I18n.format("createWorld.customize.flat.height");
this.createFlatWorldListSlotGui = new GuiCreateFlatWorld.Details();
this.addLayerButton = this.addButton(new GuiButton(2, this.width / 2 - 154, this.height - 52, 100, 20, I18n.format("createWorld.customize.flat.addLayer") + " (NYI)"));
this.editLayerButton = this.addButton(new GuiButton(3, this.width / 2 - 50, this.height - 52, 100, 20, I18n.format("createWorld.customize.flat.editLayer") + " (NYI)"));
this.removeLayerButton = this.addButton(new GuiButton(4, this.width / 2 - 155, this.height - 52, 150, 20, I18n.format("createWorld.customize.flat.removeLayer")));
this.buttonList.add(new GuiButton(0, this.width / 2 - 155, this.height - 28, 150, 20, I18n.format("gui.done")));
this.buttonList.add(new GuiButton(5, this.width / 2 + 5, this.height - 52, 150, 20, I18n.format("createWorld.customize.presets")));
this.buttonList.add(new GuiButton(1, this.width / 2 + 5, this.height - 28, 150, 20, I18n.format("gui.cancel")));
this.addLayerButton.visible = false;
this.editLayerButton.visible = false;
this.generatorInfo.updateLayers();
this.onLayersChanged();
}
/**
* Handles mouse input.
*/
public void handleMouseInput() throws IOException
{
super.handleMouseInput();
this.createFlatWorldListSlotGui.handleMouseInput();
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
int i = this.generatorInfo.getFlatLayers().size() - this.createFlatWorldListSlotGui.selectedLayer - 1;
if (button.id == 1)
{
this.mc.displayGuiScreen(this.createWorldGui);
}
else if (button.id == 0)
{
this.createWorldGui.chunkProviderSettingsJson = this.getPreset();
this.mc.displayGuiScreen(this.createWorldGui);
}
else if (button.id == 5)
{
this.mc.displayGuiScreen(new GuiFlatPresets(this));
}
else if (button.id == 4 && this.hasSelectedLayer())
{
this.generatorInfo.getFlatLayers().remove(i);
this.createFlatWorldListSlotGui.selectedLayer = Math.min(this.createFlatWorldListSlotGui.selectedLayer, this.generatorInfo.getFlatLayers().size() - 1);
}
this.generatorInfo.updateLayers();
this.onLayersChanged();
}
/**
* Would update whether or not the edit and remove buttons are enabled, but is currently disabled and always
* disables the buttons (which are invisible anyways)
*/
public void onLayersChanged()
{
boolean flag = this.hasSelectedLayer();
this.removeLayerButton.enabled = flag;
this.editLayerButton.enabled = flag;
this.editLayerButton.enabled = false;
this.addLayerButton.enabled = false;
}
/**
* Returns whether there is a valid layer selection
*/
private boolean hasSelectedLayer()
{
return this.createFlatWorldListSlotGui.selectedLayer > -1 && this.createFlatWorldListSlotGui.selectedLayer < this.generatorInfo.getFlatLayers().size();
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.createFlatWorldListSlotGui.drawScreen(mouseX, mouseY, partialTicks);
this.drawCenteredString(this.fontRenderer, this.flatWorldTitle, this.width / 2, 8, 16777215);
int i = this.width / 2 - 92 - 16;
this.drawString(this.fontRenderer, this.materialText, i, 32, 16777215);
this.drawString(this.fontRenderer, this.heightText, i + 2 + 213 - this.fontRenderer.getStringWidth(this.heightText), 32, 16777215);
super.drawScreen(mouseX, mouseY, partialTicks);
}
@SideOnly(Side.CLIENT)
class Details extends GuiSlot
{
/**
* The currently selected layer; -1 if there is no selection. This is in the order that it is displayed on-
* screen, with the topmost layer having index 0.
*/
public int selectedLayer = -1;
public Details()
{
super(GuiCreateFlatWorld.this.mc, GuiCreateFlatWorld.this.width, GuiCreateFlatWorld.this.height, 43, GuiCreateFlatWorld.this.height - 60, 24);
}
/**
* Draws an item with a background at the given coordinates. The item and its background are 20 pixels tall/wide
* (though only the inner 18x18 is actually drawn on)
*/
private void drawItem(int x, int z, ItemStack itemToDraw)
{
this.drawItemBackground(x + 1, z + 1);
GlStateManager.enableRescaleNormal();
if (!itemToDraw.isEmpty())
{
RenderHelper.enableGUIStandardItemLighting();
GuiCreateFlatWorld.this.itemRender.renderItemIntoGUI(itemToDraw, x + 2, z + 2);
RenderHelper.disableStandardItemLighting();
}
GlStateManager.disableRescaleNormal();
}
/**
* Draws the background icon for an item, with the indented texture from stats.png
*/
private void drawItemBackground(int x, int y)
{
this.drawItemBackground(x, y, 0, 0);
}
/**
* Draws the background icon for an item, using a texture from stats.png with the given coords
*/
private void drawItemBackground(int x, int z, int textureX, int textureY)
{
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(Gui.STAT_ICONS);
float f = 0.0078125F;
float f1 = 0.0078125F;
int i = 18;
int j = 18;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
bufferbuilder.pos((double)(x + 0), (double)(z + 18), (double)GuiCreateFlatWorld.this.zLevel).tex((double)((float)(textureX + 0) * 0.0078125F), (double)((float)(textureY + 18) * 0.0078125F)).endVertex();
bufferbuilder.pos((double)(x + 18), (double)(z + 18), (double)GuiCreateFlatWorld.this.zLevel).tex((double)((float)(textureX + 18) * 0.0078125F), (double)((float)(textureY + 18) * 0.0078125F)).endVertex();
bufferbuilder.pos((double)(x + 18), (double)(z + 0), (double)GuiCreateFlatWorld.this.zLevel).tex((double)((float)(textureX + 18) * 0.0078125F), (double)((float)(textureY + 0) * 0.0078125F)).endVertex();
bufferbuilder.pos((double)(x + 0), (double)(z + 0), (double)GuiCreateFlatWorld.this.zLevel).tex((double)((float)(textureX + 0) * 0.0078125F), (double)((float)(textureY + 0) * 0.0078125F)).endVertex();
tessellator.draw();
}
protected int getSize()
{
return GuiCreateFlatWorld.this.generatorInfo.getFlatLayers().size();
}
/**
* The element in the slot that was clicked, boolean for whether it was double clicked or not
*/
protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY)
{
this.selectedLayer = slotIndex;
GuiCreateFlatWorld.this.onLayersChanged();
}
/**
* Returns true if the element passed in is currently selected
*/
protected boolean isSelected(int slotIndex)
{
return slotIndex == this.selectedLayer;
}
protected void drawBackground()
{
}
protected void drawSlot(int slotIndex, int xPos, int yPos, int heightIn, int mouseXIn, int mouseYIn, float partialTicks)
{
FlatLayerInfo flatlayerinfo = (FlatLayerInfo)GuiCreateFlatWorld.this.generatorInfo.getFlatLayers().get(GuiCreateFlatWorld.this.generatorInfo.getFlatLayers().size() - slotIndex - 1);
IBlockState iblockstate = flatlayerinfo.getLayerMaterial();
Block block = iblockstate.getBlock();
Item item = Item.getItemFromBlock(block);
if (item == Items.AIR)
{
if (block != Blocks.WATER && block != Blocks.FLOWING_WATER)
{
if (block == Blocks.LAVA || block == Blocks.FLOWING_LAVA)
{
item = Items.LAVA_BUCKET;
}
}
else
{
item = Items.WATER_BUCKET;
}
}
ItemStack itemstack = new ItemStack(item, 1, item.getHasSubtypes() ? block.getMetaFromState(iblockstate) : 0);
String s = item.getItemStackDisplayName(itemstack);
this.drawItem(xPos, yPos, itemstack);
GuiCreateFlatWorld.this.fontRenderer.drawString(s, xPos + 18 + 5, yPos + 3, 16777215);
String s1;
if (slotIndex == 0)
{
s1 = I18n.format("createWorld.customize.flat.layer.top", flatlayerinfo.getLayerCount());
}
else if (slotIndex == GuiCreateFlatWorld.this.generatorInfo.getFlatLayers().size() - 1)
{
s1 = I18n.format("createWorld.customize.flat.layer.bottom", flatlayerinfo.getLayerCount());
}
else
{
s1 = I18n.format("createWorld.customize.flat.layer", flatlayerinfo.getLayerCount());
}
GuiCreateFlatWorld.this.fontRenderer.drawString(s1, xPos + 2 + 213 - GuiCreateFlatWorld.this.fontRenderer.getStringWidth(s1), yPos + 3, 16777215);
}
protected int getScrollBarX()
{
return this.width - 70;
}
}
}

View File

@@ -0,0 +1,547 @@
package net.minecraft.client.gui;
import java.io.IOException;
import java.util.Random;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ChatAllowedCharacters;
import net.minecraft.world.GameType;
import net.minecraft.world.WorldSettings;
import net.minecraft.world.WorldType;
import net.minecraft.world.storage.ISaveFormat;
import net.minecraft.world.storage.WorldInfo;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.StringUtils;
import org.lwjgl.input.Keyboard;
@SideOnly(Side.CLIENT)
public class GuiCreateWorld extends GuiScreen
{
private final GuiScreen parentScreen;
private GuiTextField worldNameField;
private GuiTextField worldSeedField;
private String saveDirName;
private String gameMode = "survival";
/** Used to save away the game mode when the current "debug" world type is chosen (forcing it to spectator mode) */
private String savedGameMode;
private boolean generateStructuresEnabled = true;
/** If cheats are allowed */
private boolean allowCheats;
/**
* User explicitly clicked "Allow Cheats" at some point
* Prevents value changes due to changing game mode
*/
private boolean allowCheatsWasSetByUser;
private boolean bonusChestEnabled;
/** Set to true when "hardcore" is the currently-selected gamemode */
private boolean hardCoreMode;
private boolean alreadyGenerated;
private boolean inMoreWorldOptionsDisplay;
private GuiButton btnGameMode;
private GuiButton btnMoreOptions;
private GuiButton btnMapFeatures;
private GuiButton btnBonusItems;
private GuiButton btnMapType;
private GuiButton btnAllowCommands;
private GuiButton btnCustomizeType;
private String gameModeDesc1;
private String gameModeDesc2;
private String worldSeed;
private String worldName;
private int selectedIndex;
public String chunkProviderSettingsJson = "";
/** These filenames are known to be restricted on one or more OS's. */
private static final String[] DISALLOWED_FILENAMES = new String[] {"CON", "COM", "PRN", "AUX", "CLOCK$", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"};
public GuiCreateWorld(GuiScreen p_i46320_1_)
{
this.parentScreen = p_i46320_1_;
this.worldSeed = "";
this.worldName = I18n.format("selectWorld.newWorld");
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
this.worldNameField.updateCursorCounter();
this.worldSeedField.updateCursorCounter();
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
Keyboard.enableRepeatEvents(true);
this.buttonList.clear();
this.buttonList.add(new GuiButton(0, this.width / 2 - 155, this.height - 28, 150, 20, I18n.format("selectWorld.create")));
this.buttonList.add(new GuiButton(1, this.width / 2 + 5, this.height - 28, 150, 20, I18n.format("gui.cancel")));
this.btnGameMode = this.addButton(new GuiButton(2, this.width / 2 - 75, 115, 150, 20, I18n.format("selectWorld.gameMode")));
this.btnMoreOptions = this.addButton(new GuiButton(3, this.width / 2 - 75, 187, 150, 20, I18n.format("selectWorld.moreWorldOptions")));
this.btnMapFeatures = this.addButton(new GuiButton(4, this.width / 2 - 155, 100, 150, 20, I18n.format("selectWorld.mapFeatures")));
this.btnMapFeatures.visible = false;
this.btnBonusItems = this.addButton(new GuiButton(7, this.width / 2 + 5, 151, 150, 20, I18n.format("selectWorld.bonusItems")));
this.btnBonusItems.visible = false;
this.btnMapType = this.addButton(new GuiButton(5, this.width / 2 + 5, 100, 150, 20, I18n.format("selectWorld.mapType")));
this.btnMapType.visible = false;
this.btnAllowCommands = this.addButton(new GuiButton(6, this.width / 2 - 155, 151, 150, 20, I18n.format("selectWorld.allowCommands")));
this.btnAllowCommands.visible = false;
this.btnCustomizeType = this.addButton(new GuiButton(8, this.width / 2 + 5, 120, 150, 20, I18n.format("selectWorld.customizeType")));
this.btnCustomizeType.visible = false;
this.worldNameField = new GuiTextField(9, this.fontRenderer, this.width / 2 - 100, 60, 200, 20);
this.worldNameField.setFocused(true);
this.worldNameField.setText(this.worldName);
this.worldSeedField = new GuiTextField(10, this.fontRenderer, this.width / 2 - 100, 60, 200, 20);
this.worldSeedField.setText(this.worldSeed);
this.showMoreWorldOptions(this.inMoreWorldOptionsDisplay);
this.calcSaveDirName();
this.updateDisplayState();
}
/**
* Determine a save-directory name from the world name
*/
private void calcSaveDirName()
{
this.saveDirName = this.worldNameField.getText().trim();
for (char c0 : ChatAllowedCharacters.ILLEGAL_FILE_CHARACTERS)
{
this.saveDirName = this.saveDirName.replace(c0, '_');
}
if (StringUtils.isEmpty(this.saveDirName))
{
this.saveDirName = "World";
}
this.saveDirName = getUncollidingSaveDirName(this.mc.getSaveLoader(), this.saveDirName);
}
/**
* Sets displayed GUI elements according to the current settings state
*/
private void updateDisplayState()
{
this.btnGameMode.displayString = I18n.format("selectWorld.gameMode") + ": " + I18n.format("selectWorld.gameMode." + this.gameMode);
this.gameModeDesc1 = I18n.format("selectWorld.gameMode." + this.gameMode + ".line1");
this.gameModeDesc2 = I18n.format("selectWorld.gameMode." + this.gameMode + ".line2");
this.btnMapFeatures.displayString = I18n.format("selectWorld.mapFeatures") + " ";
if (this.generateStructuresEnabled)
{
this.btnMapFeatures.displayString = this.btnMapFeatures.displayString + I18n.format("options.on");
}
else
{
this.btnMapFeatures.displayString = this.btnMapFeatures.displayString + I18n.format("options.off");
}
this.btnBonusItems.displayString = I18n.format("selectWorld.bonusItems") + " ";
if (this.bonusChestEnabled && !this.hardCoreMode)
{
this.btnBonusItems.displayString = this.btnBonusItems.displayString + I18n.format("options.on");
}
else
{
this.btnBonusItems.displayString = this.btnBonusItems.displayString + I18n.format("options.off");
}
this.btnMapType.displayString = I18n.format("selectWorld.mapType") + " " + I18n.format(WorldType.WORLD_TYPES[this.selectedIndex].getTranslationKey());
this.btnAllowCommands.displayString = I18n.format("selectWorld.allowCommands") + " ";
if (this.allowCheats && !this.hardCoreMode)
{
this.btnAllowCommands.displayString = this.btnAllowCommands.displayString + I18n.format("options.on");
}
else
{
this.btnAllowCommands.displayString = this.btnAllowCommands.displayString + I18n.format("options.off");
}
}
/**
* Ensures that a proposed directory name doesn't collide with existing names.
* Returns the name, possibly modified to avoid collisions.
*/
public static String getUncollidingSaveDirName(ISaveFormat saveLoader, String name)
{
name = name.replaceAll("[\\./\"]", "_");
for (String s : DISALLOWED_FILENAMES)
{
if (name.equalsIgnoreCase(s))
{
name = "_" + name + "_";
}
}
while (saveLoader.getWorldInfo(name) != null)
{
name = name + "-";
}
return name;
}
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
Keyboard.enableRepeatEvents(false);
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.enabled)
{
if (button.id == 1)
{
this.mc.displayGuiScreen(this.parentScreen);
}
else if (button.id == 0)
{
this.mc.displayGuiScreen((GuiScreen)null);
if (this.alreadyGenerated)
{
return;
}
this.alreadyGenerated = true;
long i = (new Random()).nextLong();
String s = this.worldSeedField.getText();
if (!StringUtils.isEmpty(s))
{
try
{
long j = Long.parseLong(s);
if (j != 0L)
{
i = j;
}
}
catch (NumberFormatException var7)
{
i = (long)s.hashCode();
}
}
WorldType.WORLD_TYPES[this.selectedIndex].onGUICreateWorldPress();
WorldSettings worldsettings = new WorldSettings(i, GameType.getByName(this.gameMode), this.generateStructuresEnabled, this.hardCoreMode, WorldType.WORLD_TYPES[this.selectedIndex]);
worldsettings.setGeneratorOptions(this.chunkProviderSettingsJson);
if (this.bonusChestEnabled && !this.hardCoreMode)
{
worldsettings.enableBonusChest();
}
if (this.allowCheats && !this.hardCoreMode)
{
worldsettings.enableCommands();
}
this.mc.launchIntegratedServer(this.saveDirName, this.worldNameField.getText().trim(), worldsettings);
}
else if (button.id == 3)
{
this.toggleMoreWorldOptions();
}
else if (button.id == 2)
{
if ("survival".equals(this.gameMode))
{
if (!this.allowCheatsWasSetByUser)
{
this.allowCheats = false;
}
this.hardCoreMode = false;
this.gameMode = "hardcore";
this.hardCoreMode = true;
this.btnAllowCommands.enabled = false;
this.btnBonusItems.enabled = false;
this.updateDisplayState();
}
else if ("hardcore".equals(this.gameMode))
{
if (!this.allowCheatsWasSetByUser)
{
this.allowCheats = true;
}
this.hardCoreMode = false;
this.gameMode = "creative";
this.updateDisplayState();
this.hardCoreMode = false;
this.btnAllowCommands.enabled = true;
this.btnBonusItems.enabled = true;
}
else
{
if (!this.allowCheatsWasSetByUser)
{
this.allowCheats = false;
}
this.gameMode = "survival";
this.updateDisplayState();
this.btnAllowCommands.enabled = true;
this.btnBonusItems.enabled = true;
this.hardCoreMode = false;
}
this.updateDisplayState();
}
else if (button.id == 4)
{
this.generateStructuresEnabled = !this.generateStructuresEnabled;
this.updateDisplayState();
}
else if (button.id == 7)
{
this.bonusChestEnabled = !this.bonusChestEnabled;
this.updateDisplayState();
}
else if (button.id == 5)
{
++this.selectedIndex;
if (this.selectedIndex >= WorldType.WORLD_TYPES.length)
{
this.selectedIndex = 0;
}
while (!this.canSelectCurWorldType())
{
++this.selectedIndex;
if (this.selectedIndex >= WorldType.WORLD_TYPES.length)
{
this.selectedIndex = 0;
}
}
this.chunkProviderSettingsJson = "";
this.updateDisplayState();
this.showMoreWorldOptions(this.inMoreWorldOptionsDisplay);
}
else if (button.id == 6)
{
this.allowCheatsWasSetByUser = true;
this.allowCheats = !this.allowCheats;
this.updateDisplayState();
}
else if (button.id == 8)
{
WorldType.WORLD_TYPES[this.selectedIndex].onCustomizeButton(mc, this);
}
}
}
/**
* Returns whether the currently-selected world type is actually acceptable for selection
* Used to hide the "debug" world type unless the shift key is depressed.
*/
private boolean canSelectCurWorldType()
{
WorldType worldtype = WorldType.WORLD_TYPES[this.selectedIndex];
if (worldtype != null && worldtype.canBeCreated())
{
return worldtype == WorldType.DEBUG_ALL_BLOCK_STATES ? isShiftKeyDown() : true;
}
else
{
return false;
}
}
/**
* Toggles between initial world-creation display, and "more options" display.
* Called when user clicks "More World Options..." or "Done" (same button, different labels depending on current
* display).
*/
private void toggleMoreWorldOptions()
{
this.showMoreWorldOptions(!this.inMoreWorldOptionsDisplay);
}
/**
* Shows additional world-creation options if toggle is true, otherwise shows main world-creation elements
*/
private void showMoreWorldOptions(boolean toggle)
{
this.inMoreWorldOptionsDisplay = toggle;
if (WorldType.WORLD_TYPES[this.selectedIndex] == WorldType.DEBUG_ALL_BLOCK_STATES)
{
this.btnGameMode.visible = !this.inMoreWorldOptionsDisplay;
this.btnGameMode.enabled = false;
if (this.savedGameMode == null)
{
this.savedGameMode = this.gameMode;
}
this.gameMode = "spectator";
this.btnMapFeatures.visible = false;
this.btnBonusItems.visible = false;
this.btnMapType.visible = this.inMoreWorldOptionsDisplay;
this.btnAllowCommands.visible = false;
this.btnCustomizeType.visible = false;
}
else
{
this.btnGameMode.visible = !this.inMoreWorldOptionsDisplay;
this.btnGameMode.enabled = true;
if (this.savedGameMode != null)
{
this.gameMode = this.savedGameMode;
this.savedGameMode = null;
}
this.btnMapFeatures.visible = this.inMoreWorldOptionsDisplay && WorldType.WORLD_TYPES[this.selectedIndex] != WorldType.CUSTOMIZED;
this.btnBonusItems.visible = this.inMoreWorldOptionsDisplay;
this.btnMapType.visible = this.inMoreWorldOptionsDisplay;
this.btnAllowCommands.visible = this.inMoreWorldOptionsDisplay;
this.btnCustomizeType.visible = this.inMoreWorldOptionsDisplay && WorldType.WORLD_TYPES[this.selectedIndex].isCustomizable();
}
this.updateDisplayState();
if (this.inMoreWorldOptionsDisplay)
{
this.btnMoreOptions.displayString = I18n.format("gui.done");
}
else
{
this.btnMoreOptions.displayString = I18n.format("selectWorld.moreWorldOptions");
}
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
if (this.worldNameField.isFocused() && !this.inMoreWorldOptionsDisplay)
{
this.worldNameField.textboxKeyTyped(typedChar, keyCode);
this.worldName = this.worldNameField.getText();
}
else if (this.worldSeedField.isFocused() && this.inMoreWorldOptionsDisplay)
{
this.worldSeedField.textboxKeyTyped(typedChar, keyCode);
this.worldSeed = this.worldSeedField.getText();
}
if (keyCode == 28 || keyCode == 156)
{
this.actionPerformed(this.buttonList.get(0));
}
(this.buttonList.get(0)).enabled = !this.worldNameField.getText().isEmpty();
this.calcSaveDirName();
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
super.mouseClicked(mouseX, mouseY, mouseButton);
if (this.inMoreWorldOptionsDisplay)
{
this.worldSeedField.mouseClicked(mouseX, mouseY, mouseButton);
}
else
{
this.worldNameField.mouseClicked(mouseX, mouseY, mouseButton);
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, I18n.format("selectWorld.create"), this.width / 2, 20, -1);
if (this.inMoreWorldOptionsDisplay)
{
this.drawString(this.fontRenderer, I18n.format("selectWorld.enterSeed"), this.width / 2 - 100, 47, -6250336);
this.drawString(this.fontRenderer, I18n.format("selectWorld.seedInfo"), this.width / 2 - 100, 85, -6250336);
if (this.btnMapFeatures.visible)
{
this.drawString(this.fontRenderer, I18n.format("selectWorld.mapFeatures.info"), this.width / 2 - 150, 122, -6250336);
}
if (this.btnAllowCommands.visible)
{
this.drawString(this.fontRenderer, I18n.format("selectWorld.allowCommands.info"), this.width / 2 - 150, 172, -6250336);
}
this.worldSeedField.drawTextBox();
if (WorldType.WORLD_TYPES[this.selectedIndex].hasInfoNotice())
{
this.fontRenderer.drawSplitString(I18n.format(WorldType.WORLD_TYPES[this.selectedIndex].getInfoTranslationKey()), this.btnMapType.x + 2, this.btnMapType.y + 22, this.btnMapType.getButtonWidth(), 10526880);
}
}
else
{
this.drawString(this.fontRenderer, I18n.format("selectWorld.enterName"), this.width / 2 - 100, 47, -6250336);
this.drawString(this.fontRenderer, I18n.format("selectWorld.resultFolder") + " " + this.saveDirName, this.width / 2 - 100, 85, -6250336);
this.worldNameField.drawTextBox();
this.drawString(this.fontRenderer, this.gameModeDesc1, this.width / 2 - 100, 137, -6250336);
this.drawString(this.fontRenderer, this.gameModeDesc2, this.width / 2 - 100, 149, -6250336);
}
super.drawScreen(mouseX, mouseY, partialTicks);
}
/**
* Set the initial values of a new world to create, from the values from an existing world.
*
* Called after construction when a user selects the "Recreate" button.
*/
public void recreateFromExistingWorld(WorldInfo original)
{
this.worldName = I18n.format("selectWorld.newWorld.copyOf", original.getWorldName());
this.worldSeed = original.getSeed() + "";
this.selectedIndex = original.getTerrainType().getId();
this.chunkProviderSettingsJson = original.getGeneratorOptions();
this.generateStructuresEnabled = original.isMapFeaturesEnabled();
this.allowCheats = original.areCommandsAllowed();
if (original.isHardcoreModeEnabled())
{
this.gameMode = "hardcore";
}
else if (original.getGameType().isSurvivalOrAdventure())
{
this.gameMode = "survival";
}
else if (original.getGameType().isCreative())
{
this.gameMode = "creative";
}
}
}

View File

@@ -0,0 +1,127 @@
package net.minecraft.client.gui;
import java.io.IOException;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.entity.player.EnumPlayerModelParts;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiCustomizeSkin extends GuiScreen
{
/** The parent GUI for this GUI */
private final GuiScreen parentScreen;
/** The title of the GUI. */
private String title;
public GuiCustomizeSkin(GuiScreen parentScreenIn)
{
this.parentScreen = parentScreenIn;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
int i = 0;
this.title = I18n.format("options.skinCustomisation.title");
for (EnumPlayerModelParts enumplayermodelparts : EnumPlayerModelParts.values())
{
this.buttonList.add(new GuiCustomizeSkin.ButtonPart(enumplayermodelparts.getPartId(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), 150, 20, enumplayermodelparts));
++i;
}
this.buttonList.add(new GuiOptionButton(199, this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), GameSettings.Options.MAIN_HAND, this.mc.gameSettings.getKeyBinding(GameSettings.Options.MAIN_HAND)));
++i;
if (i % 2 == 1)
{
++i;
}
this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 24 * (i >> 1), I18n.format("gui.done")));
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
if (keyCode == 1)
{
this.mc.gameSettings.saveOptions();
}
super.keyTyped(typedChar, keyCode);
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.enabled)
{
if (button.id == 200)
{
this.mc.gameSettings.saveOptions();
this.mc.displayGuiScreen(this.parentScreen);
}
else if (button.id == 199)
{
this.mc.gameSettings.setOptionValue(GameSettings.Options.MAIN_HAND, 1);
button.displayString = this.mc.gameSettings.getKeyBinding(GameSettings.Options.MAIN_HAND);
this.mc.gameSettings.sendSettingsToServer();
}
else if (button instanceof GuiCustomizeSkin.ButtonPart)
{
EnumPlayerModelParts enumplayermodelparts = ((GuiCustomizeSkin.ButtonPart)button).playerModelParts;
this.mc.gameSettings.switchModelPartEnabled(enumplayermodelparts);
button.displayString = this.getMessage(enumplayermodelparts);
}
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, this.title, this.width / 2, 20, 16777215);
super.drawScreen(mouseX, mouseY, partialTicks);
}
private String getMessage(EnumPlayerModelParts playerModelParts)
{
String s;
if (this.mc.gameSettings.getModelParts().contains(playerModelParts))
{
s = I18n.format("options.on");
}
else
{
s = I18n.format("options.off");
}
return playerModelParts.getName().getFormattedText() + ": " + s;
}
@SideOnly(Side.CLIENT)
class ButtonPart extends GuiButton
{
private final EnumPlayerModelParts playerModelParts;
private ButtonPart(int p_i45514_2_, int p_i45514_3_, int p_i45514_4_, int p_i45514_5_, int p_i45514_6_, EnumPlayerModelParts playerModelParts)
{
super(p_i45514_2_, p_i45514_3_, p_i45514_4_, p_i45514_5_, p_i45514_6_, GuiCustomizeSkin.this.getMessage(playerModelParts));
this.playerModelParts = playerModelParts;
}
}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,77 @@
package net.minecraft.client.gui;
import java.io.IOException;
import java.util.List;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiDisconnected extends GuiScreen
{
private final String reason;
private final ITextComponent message;
private List<String> multilineMessage;
private final GuiScreen parentScreen;
private int textHeight;
public GuiDisconnected(GuiScreen screen, String reasonLocalizationKey, ITextComponent chatComp)
{
this.parentScreen = screen;
this.reason = I18n.format(reasonLocalizationKey);
this.message = chatComp;
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.buttonList.clear();
this.multilineMessage = this.fontRenderer.listFormattedStringToWidth(this.message.getFormattedText(), this.width - 50);
this.textHeight = this.multilineMessage.size() * this.fontRenderer.FONT_HEIGHT;
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, Math.min(this.height / 2 + this.textHeight / 2 + this.fontRenderer.FONT_HEIGHT, this.height - 30), I18n.format("gui.toMenu")));
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.id == 0)
{
this.mc.displayGuiScreen(this.parentScreen);
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, this.reason, this.width / 2, this.height / 2 - this.textHeight / 2 - this.fontRenderer.FONT_HEIGHT * 2, 11184810);
int i = this.height / 2 - this.textHeight / 2;
if (this.multilineMessage != null)
{
for (String s : this.multilineMessage)
{
this.drawCenteredString(this.fontRenderer, s, this.width / 2, i, 16777215);
i += this.fontRenderer.FONT_HEIGHT;
}
}
super.drawScreen(mouseX, mouseY, partialTicks);
}
}

View File

@@ -0,0 +1,36 @@
package net.minecraft.client.gui;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiDownloadTerrain extends GuiScreen
{
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.buttonList.clear();
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawBackground(0);
this.drawCenteredString(this.fontRenderer, I18n.format("multiplayer.downloadingTerrain"), this.width / 2, this.height / 2 - 50, 16777215);
super.drawScreen(mouseX, mouseY, partialTicks);
}
/**
* Returns true if this GUI should pause the game when it is displayed in single-player
*/
public boolean doesGuiPauseGame()
{
return false;
}
}

View File

@@ -0,0 +1,340 @@
package net.minecraft.client.gui;
import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.List;
import java.util.Random;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.model.ModelBook;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.resources.I18n;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ContainerEnchantment;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnchantmentNameParts;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.IWorldNameable;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.util.glu.Project;
@SideOnly(Side.CLIENT)
public class GuiEnchantment extends GuiContainer
{
/** The ResourceLocation containing the Enchantment GUI texture location */
private static final ResourceLocation ENCHANTMENT_TABLE_GUI_TEXTURE = new ResourceLocation("textures/gui/container/enchanting_table.png");
/** The ResourceLocation containing the texture for the Book rendered above the enchantment table */
private static final ResourceLocation ENCHANTMENT_TABLE_BOOK_TEXTURE = new ResourceLocation("textures/entity/enchanting_table_book.png");
/** The ModelBook instance used for rendering the book on the Enchantment table */
private static final ModelBook MODEL_BOOK = new ModelBook();
/** The player inventory currently bound to this GuiEnchantment instance. */
private final InventoryPlayer playerInventory;
/** A Random instance for use with the enchantment gui */
private final Random random = new Random();
private final ContainerEnchantment container;
public int ticks;
public float flip;
public float oFlip;
public float flipT;
public float flipA;
public float open;
public float oOpen;
private ItemStack last = ItemStack.EMPTY;
private final IWorldNameable nameable;
public GuiEnchantment(InventoryPlayer inventory, World worldIn, IWorldNameable nameable)
{
super(new ContainerEnchantment(inventory, worldIn));
this.playerInventory = inventory;
this.container = (ContainerEnchantment)this.inventorySlots;
this.nameable = nameable;
}
/**
* Draw the foreground layer for the GuiContainer (everything in front of the items)
*/
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
this.fontRenderer.drawString(this.nameable.getDisplayName().getUnformattedText(), 12, 5, 4210752);
this.fontRenderer.drawString(this.playerInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 96 + 2, 4210752);
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
super.updateScreen();
this.tickBook();
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
super.mouseClicked(mouseX, mouseY, mouseButton);
int i = (this.width - this.xSize) / 2;
int j = (this.height - this.ySize) / 2;
for (int k = 0; k < 3; ++k)
{
int l = mouseX - (i + 60);
int i1 = mouseY - (j + 14 + 19 * k);
if (l >= 0 && i1 >= 0 && l < 108 && i1 < 19 && this.container.enchantItem(this.mc.player, k))
{
this.mc.playerController.sendEnchantPacket(this.container.windowId, k);
}
}
}
/**
* Draws the background layer of this container (behind the items).
*/
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
{
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(ENCHANTMENT_TABLE_GUI_TEXTURE);
int i = (this.width - this.xSize) / 2;
int j = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
GlStateManager.pushMatrix();
GlStateManager.matrixMode(5889);
GlStateManager.pushMatrix();
GlStateManager.loadIdentity();
ScaledResolution scaledresolution = new ScaledResolution(this.mc);
GlStateManager.viewport((scaledresolution.getScaledWidth() - 320) / 2 * scaledresolution.getScaleFactor(), (scaledresolution.getScaledHeight() - 240) / 2 * scaledresolution.getScaleFactor(), 320 * scaledresolution.getScaleFactor(), 240 * scaledresolution.getScaleFactor());
GlStateManager.translate(-0.34F, 0.23F, 0.0F);
Project.gluPerspective(90.0F, 1.3333334F, 9.0F, 80.0F);
float f = 1.0F;
GlStateManager.matrixMode(5888);
GlStateManager.loadIdentity();
RenderHelper.enableStandardItemLighting();
GlStateManager.translate(0.0F, 3.3F, -16.0F);
GlStateManager.scale(1.0F, 1.0F, 1.0F);
float f1 = 5.0F;
GlStateManager.scale(5.0F, 5.0F, 5.0F);
GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
this.mc.getTextureManager().bindTexture(ENCHANTMENT_TABLE_BOOK_TEXTURE);
GlStateManager.rotate(20.0F, 1.0F, 0.0F, 0.0F);
float f2 = this.oOpen + (this.open - this.oOpen) * partialTicks;
GlStateManager.translate((1.0F - f2) * 0.2F, (1.0F - f2) * 0.1F, (1.0F - f2) * 0.25F);
GlStateManager.rotate(-(1.0F - f2) * 90.0F - 90.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
float f3 = this.oFlip + (this.flip - this.oFlip) * partialTicks + 0.25F;
float f4 = this.oFlip + (this.flip - this.oFlip) * partialTicks + 0.75F;
f3 = (f3 - (float)MathHelper.fastFloor((double)f3)) * 1.6F - 0.3F;
f4 = (f4 - (float)MathHelper.fastFloor((double)f4)) * 1.6F - 0.3F;
if (f3 < 0.0F)
{
f3 = 0.0F;
}
if (f4 < 0.0F)
{
f4 = 0.0F;
}
if (f3 > 1.0F)
{
f3 = 1.0F;
}
if (f4 > 1.0F)
{
f4 = 1.0F;
}
GlStateManager.enableRescaleNormal();
MODEL_BOOK.render((Entity)null, 0.0F, f3, f4, f2, 0.0F, 0.0625F);
GlStateManager.disableRescaleNormal();
RenderHelper.disableStandardItemLighting();
GlStateManager.matrixMode(5889);
GlStateManager.viewport(0, 0, this.mc.displayWidth, this.mc.displayHeight);
GlStateManager.popMatrix();
GlStateManager.matrixMode(5888);
GlStateManager.popMatrix();
RenderHelper.disableStandardItemLighting();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
EnchantmentNameParts.getInstance().reseedRandomGenerator((long)this.container.xpSeed);
int k = this.container.getLapisAmount();
for (int l = 0; l < 3; ++l)
{
int i1 = i + 60;
int j1 = i1 + 20;
this.zLevel = 0.0F;
this.mc.getTextureManager().bindTexture(ENCHANTMENT_TABLE_GUI_TEXTURE);
int k1 = this.container.enchantLevels[l];
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
if (k1 == 0)
{
this.drawTexturedModalRect(i1, j + 14 + 19 * l, 0, 185, 108, 19);
}
else
{
String s = "" + k1;
int l1 = 86 - this.fontRenderer.getStringWidth(s);
String s1 = EnchantmentNameParts.getInstance().generateNewRandomName(this.fontRenderer, l1);
FontRenderer fontrenderer = this.mc.standardGalacticFontRenderer;
int i2 = 6839882;
if (((k < l + 1 || this.mc.player.experienceLevel < k1) && !this.mc.player.capabilities.isCreativeMode) || this.container.enchantClue[l] == -1) // Forge: render buttons as disabled when enchantable but enchantability not met on lower levels
{
this.drawTexturedModalRect(i1, j + 14 + 19 * l, 0, 185, 108, 19);
this.drawTexturedModalRect(i1 + 1, j + 15 + 19 * l, 16 * l, 239, 16, 16);
fontrenderer.drawSplitString(s1, j1, j + 16 + 19 * l, l1, (i2 & 16711422) >> 1);
i2 = 4226832;
}
else
{
int j2 = mouseX - (i + 60);
int k2 = mouseY - (j + 14 + 19 * l);
if (j2 >= 0 && k2 >= 0 && j2 < 108 && k2 < 19)
{
this.drawTexturedModalRect(i1, j + 14 + 19 * l, 0, 204, 108, 19);
i2 = 16777088;
}
else
{
this.drawTexturedModalRect(i1, j + 14 + 19 * l, 0, 166, 108, 19);
}
this.drawTexturedModalRect(i1 + 1, j + 15 + 19 * l, 16 * l, 223, 16, 16);
fontrenderer.drawSplitString(s1, j1, j + 16 + 19 * l, l1, i2);
i2 = 8453920;
}
fontrenderer = this.mc.fontRenderer;
fontrenderer.drawStringWithShadow(s, (float)(j1 + 86 - fontrenderer.getStringWidth(s)), (float)(j + 16 + 19 * l + 7), i2);
}
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
partialTicks = this.mc.getTickLength();
this.drawDefaultBackground();
super.drawScreen(mouseX, mouseY, partialTicks);
this.renderHoveredToolTip(mouseX, mouseY);
boolean flag = this.mc.player.capabilities.isCreativeMode;
int i = this.container.getLapisAmount();
for (int j = 0; j < 3; ++j)
{
int k = this.container.enchantLevels[j];
Enchantment enchantment = Enchantment.getEnchantmentByID(this.container.enchantClue[j]);
int l = this.container.worldClue[j];
int i1 = j + 1;
if (this.isPointInRegion(60, 14 + 19 * j, 108, 17, mouseX, mouseY) && k > 0)
{
List<String> list = Lists.<String>newArrayList();
list.add("" + TextFormatting.WHITE + TextFormatting.ITALIC + I18n.format("container.enchant.clue", enchantment == null ? "" : enchantment.getTranslatedName(l)));
if(enchantment == null) java.util.Collections.addAll(list, "", TextFormatting.RED + I18n.format("forge.container.enchant.limitedEnchantability")); else
if (!flag)
{
list.add("");
if (this.mc.player.experienceLevel < k)
{
list.add(TextFormatting.RED + I18n.format("container.enchant.level.requirement", this.container.enchantLevels[j]));
}
else
{
String s;
if (i1 == 1)
{
s = I18n.format("container.enchant.lapis.one");
}
else
{
s = I18n.format("container.enchant.lapis.many", i1);
}
TextFormatting textformatting = i >= i1 ? TextFormatting.GRAY : TextFormatting.RED;
list.add(textformatting + "" + s);
if (i1 == 1)
{
s = I18n.format("container.enchant.level.one");
}
else
{
s = I18n.format("container.enchant.level.many", i1);
}
list.add(TextFormatting.GRAY + "" + s);
}
}
this.drawHoveringText(list, mouseX, mouseY);
break;
}
}
}
public void tickBook()
{
ItemStack itemstack = this.inventorySlots.getSlot(0).getStack();
if (!ItemStack.areItemStacksEqual(itemstack, this.last))
{
this.last = itemstack;
while (true)
{
this.flipT += (float)(this.random.nextInt(4) - this.random.nextInt(4));
if (this.flip > this.flipT + 1.0F || this.flip < this.flipT - 1.0F)
{
break;
}
}
}
++this.ticks;
this.oFlip = this.flip;
this.oOpen = this.open;
boolean flag = false;
for (int i = 0; i < 3; ++i)
{
if (this.container.enchantLevels[i] != 0)
{
flag = true;
}
}
if (flag)
{
this.open += 0.2F;
}
else
{
this.open -= 0.2F;
}
this.open = MathHelper.clamp(this.open, 0.0F, 1.0F);
float f1 = (this.flipT - this.flip) * 0.4F;
float f = 0.2F;
f1 = MathHelper.clamp(f1, -0.2F, 0.2F);
this.flipA += (f1 - this.flipA) * 0.9F;
this.flip += this.flipA;
}
}

View File

@@ -0,0 +1,56 @@
package net.minecraft.client.gui;
import java.io.IOException;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiErrorScreen extends GuiScreen
{
private final String title;
private final String message;
public GuiErrorScreen(String titleIn, String messageIn)
{
this.title = titleIn;
this.message = messageIn;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
super.initGui();
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, 140, I18n.format("gui.cancel")));
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawGradientRect(0, 0, this.width, this.height, -12574688, -11530224);
this.drawCenteredString(this.fontRenderer, this.title, this.width / 2, 90, 16777215);
this.drawCenteredString(this.fontRenderer, this.message, this.width / 2, 110, 16777215);
super.drawScreen(mouseX, mouseY, partialTicks);
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
this.mc.displayGuiScreen((GuiScreen)null);
}
}

View File

@@ -0,0 +1,285 @@
package net.minecraft.client.gui;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import net.minecraft.block.BlockTallGrass;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.resources.I18n;
import net.minecraft.init.Biomes;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.FlatGeneratorInfo;
import net.minecraft.world.gen.FlatLayerInfo;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.input.Keyboard;
@SideOnly(Side.CLIENT)
public class GuiFlatPresets extends GuiScreen
{
private static final List<GuiFlatPresets.LayerItem> FLAT_WORLD_PRESETS = Lists.<GuiFlatPresets.LayerItem>newArrayList();
/** The parent GUI */
private final GuiCreateFlatWorld parentScreen;
private String presetsTitle;
private String presetsShare;
private String listText;
private GuiFlatPresets.ListSlot list;
private GuiButton btnSelect;
private GuiTextField export;
public GuiFlatPresets(GuiCreateFlatWorld p_i46318_1_)
{
this.parentScreen = p_i46318_1_;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.buttonList.clear();
Keyboard.enableRepeatEvents(true);
this.presetsTitle = I18n.format("createWorld.customize.presets.title");
this.presetsShare = I18n.format("createWorld.customize.presets.share");
this.listText = I18n.format("createWorld.customize.presets.list");
this.export = new GuiTextField(2, this.fontRenderer, 50, 40, this.width - 100, 20);
this.list = new GuiFlatPresets.ListSlot();
this.export.setMaxStringLength(1230);
this.export.setText(this.parentScreen.getPreset());
this.btnSelect = this.addButton(new GuiButton(0, this.width / 2 - 155, this.height - 28, 150, 20, I18n.format("createWorld.customize.presets.select")));
this.buttonList.add(new GuiButton(1, this.width / 2 + 5, this.height - 28, 150, 20, I18n.format("gui.cancel")));
this.updateButtonValidity();
}
/**
* Handles mouse input.
*/
public void handleMouseInput() throws IOException
{
super.handleMouseInput();
this.list.handleMouseInput();
}
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
Keyboard.enableRepeatEvents(false);
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
this.export.mouseClicked(mouseX, mouseY, mouseButton);
super.mouseClicked(mouseX, mouseY, mouseButton);
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
if (!this.export.textboxKeyTyped(typedChar, keyCode))
{
super.keyTyped(typedChar, keyCode);
}
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.id == 0 && this.hasValidSelection())
{
this.parentScreen.setPreset(this.export.getText());
this.mc.displayGuiScreen(this.parentScreen);
}
else if (button.id == 1)
{
this.mc.displayGuiScreen(this.parentScreen);
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.list.drawScreen(mouseX, mouseY, partialTicks);
this.drawCenteredString(this.fontRenderer, this.presetsTitle, this.width / 2, 8, 16777215);
this.drawString(this.fontRenderer, this.presetsShare, 50, 30, 10526880);
this.drawString(this.fontRenderer, this.listText, 50, 70, 10526880);
this.export.drawTextBox();
super.drawScreen(mouseX, mouseY, partialTicks);
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
this.export.updateCursorCounter();
super.updateScreen();
}
public void updateButtonValidity()
{
this.btnSelect.enabled = this.hasValidSelection();
}
private boolean hasValidSelection()
{
return this.list.selected > -1 && this.list.selected < FLAT_WORLD_PRESETS.size() || this.export.getText().length() > 1;
}
private static void registerPreset(String name, Item icon, Biome biome, List<String> features, FlatLayerInfo... layers)
{
registerPreset(name, icon, 0, biome, features, layers);
}
private static void registerPreset(String name, Item icon, int iconMetadata, Biome biome, List<String> features, FlatLayerInfo... layers)
{
FlatGeneratorInfo flatgeneratorinfo = new FlatGeneratorInfo();
for (int i = layers.length - 1; i >= 0; --i)
{
flatgeneratorinfo.getFlatLayers().add(layers[i]);
}
flatgeneratorinfo.setBiome(Biome.getIdForBiome(biome));
flatgeneratorinfo.updateLayers();
for (String s : features)
{
flatgeneratorinfo.getWorldFeatures().put(s, Maps.newHashMap());
}
FLAT_WORLD_PRESETS.add(new GuiFlatPresets.LayerItem(icon, iconMetadata, name, flatgeneratorinfo.toString()));
}
static
{
registerPreset(I18n.format("createWorld.customize.preset.classic_flat"), Item.getItemFromBlock(Blocks.GRASS), Biomes.PLAINS, Arrays.asList("village"), new FlatLayerInfo(1, Blocks.GRASS), new FlatLayerInfo(2, Blocks.DIRT), new FlatLayerInfo(1, Blocks.BEDROCK));
registerPreset(I18n.format("createWorld.customize.preset.tunnelers_dream"), Item.getItemFromBlock(Blocks.STONE), Biomes.EXTREME_HILLS, Arrays.asList("biome_1", "dungeon", "decoration", "stronghold", "mineshaft"), new FlatLayerInfo(1, Blocks.GRASS), new FlatLayerInfo(5, Blocks.DIRT), new FlatLayerInfo(230, Blocks.STONE), new FlatLayerInfo(1, Blocks.BEDROCK));
registerPreset(I18n.format("createWorld.customize.preset.water_world"), Items.WATER_BUCKET, Biomes.DEEP_OCEAN, Arrays.asList("biome_1", "oceanmonument"), new FlatLayerInfo(90, Blocks.WATER), new FlatLayerInfo(5, Blocks.SAND), new FlatLayerInfo(5, Blocks.DIRT), new FlatLayerInfo(5, Blocks.STONE), new FlatLayerInfo(1, Blocks.BEDROCK));
registerPreset(I18n.format("createWorld.customize.preset.overworld"), Item.getItemFromBlock(Blocks.TALLGRASS), BlockTallGrass.EnumType.GRASS.getMeta(), Biomes.PLAINS, Arrays.asList("village", "biome_1", "decoration", "stronghold", "mineshaft", "dungeon", "lake", "lava_lake"), new FlatLayerInfo(1, Blocks.GRASS), new FlatLayerInfo(3, Blocks.DIRT), new FlatLayerInfo(59, Blocks.STONE), new FlatLayerInfo(1, Blocks.BEDROCK));
registerPreset(I18n.format("createWorld.customize.preset.snowy_kingdom"), Item.getItemFromBlock(Blocks.SNOW_LAYER), Biomes.ICE_PLAINS, Arrays.asList("village", "biome_1"), new FlatLayerInfo(1, Blocks.SNOW_LAYER), new FlatLayerInfo(1, Blocks.GRASS), new FlatLayerInfo(3, Blocks.DIRT), new FlatLayerInfo(59, Blocks.STONE), new FlatLayerInfo(1, Blocks.BEDROCK));
registerPreset(I18n.format("createWorld.customize.preset.bottomless_pit"), Items.FEATHER, Biomes.PLAINS, Arrays.asList("village", "biome_1"), new FlatLayerInfo(1, Blocks.GRASS), new FlatLayerInfo(3, Blocks.DIRT), new FlatLayerInfo(2, Blocks.COBBLESTONE));
registerPreset(I18n.format("createWorld.customize.preset.desert"), Item.getItemFromBlock(Blocks.SAND), Biomes.DESERT, Arrays.asList("village", "biome_1", "decoration", "stronghold", "mineshaft", "dungeon"), new FlatLayerInfo(8, Blocks.SAND), new FlatLayerInfo(52, Blocks.SANDSTONE), new FlatLayerInfo(3, Blocks.STONE), new FlatLayerInfo(1, Blocks.BEDROCK));
registerPreset(I18n.format("createWorld.customize.preset.redstone_ready"), Items.REDSTONE, Biomes.DESERT, Collections.emptyList(), new FlatLayerInfo(52, Blocks.SANDSTONE), new FlatLayerInfo(3, Blocks.STONE), new FlatLayerInfo(1, Blocks.BEDROCK));
registerPreset(I18n.format("createWorld.customize.preset.the_void"), Item.getItemFromBlock(Blocks.BARRIER), Biomes.VOID, Arrays.asList("decoration"), new FlatLayerInfo(1, Blocks.AIR));
}
@SideOnly(Side.CLIENT)
static class LayerItem
{
public Item icon;
public int iconMetadata;
public String name;
public String generatorInfo;
public LayerItem(Item iconIn, int iconMetadataIn, String nameIn, String generatorInfoIn)
{
this.icon = iconIn;
this.iconMetadata = iconMetadataIn;
this.name = nameIn;
this.generatorInfo = generatorInfoIn;
}
}
@SideOnly(Side.CLIENT)
class ListSlot extends GuiSlot
{
public int selected = -1;
public ListSlot()
{
super(GuiFlatPresets.this.mc, GuiFlatPresets.this.width, GuiFlatPresets.this.height, 80, GuiFlatPresets.this.height - 37, 24);
}
private void renderIcon(int p_178054_1_, int p_178054_2_, Item icon, int iconMetadata)
{
this.blitSlotBg(p_178054_1_ + 1, p_178054_2_ + 1);
GlStateManager.enableRescaleNormal();
RenderHelper.enableGUIStandardItemLighting();
GuiFlatPresets.this.itemRender.renderItemIntoGUI(new ItemStack(icon, 1, icon.getHasSubtypes() ? iconMetadata : 0), p_178054_1_ + 2, p_178054_2_ + 2);
RenderHelper.disableStandardItemLighting();
GlStateManager.disableRescaleNormal();
}
private void blitSlotBg(int p_148173_1_, int p_148173_2_)
{
this.blitSlotIcon(p_148173_1_, p_148173_2_, 0, 0);
}
private void blitSlotIcon(int p_148171_1_, int p_148171_2_, int p_148171_3_, int p_148171_4_)
{
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(Gui.STAT_ICONS);
float f = 0.0078125F;
float f1 = 0.0078125F;
int i = 18;
int j = 18;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
bufferbuilder.pos((double)(p_148171_1_ + 0), (double)(p_148171_2_ + 18), (double)GuiFlatPresets.this.zLevel).tex((double)((float)(p_148171_3_ + 0) * 0.0078125F), (double)((float)(p_148171_4_ + 18) * 0.0078125F)).endVertex();
bufferbuilder.pos((double)(p_148171_1_ + 18), (double)(p_148171_2_ + 18), (double)GuiFlatPresets.this.zLevel).tex((double)((float)(p_148171_3_ + 18) * 0.0078125F), (double)((float)(p_148171_4_ + 18) * 0.0078125F)).endVertex();
bufferbuilder.pos((double)(p_148171_1_ + 18), (double)(p_148171_2_ + 0), (double)GuiFlatPresets.this.zLevel).tex((double)((float)(p_148171_3_ + 18) * 0.0078125F), (double)((float)(p_148171_4_ + 0) * 0.0078125F)).endVertex();
bufferbuilder.pos((double)(p_148171_1_ + 0), (double)(p_148171_2_ + 0), (double)GuiFlatPresets.this.zLevel).tex((double)((float)(p_148171_3_ + 0) * 0.0078125F), (double)((float)(p_148171_4_ + 0) * 0.0078125F)).endVertex();
tessellator.draw();
}
protected int getSize()
{
return GuiFlatPresets.FLAT_WORLD_PRESETS.size();
}
/**
* The element in the slot that was clicked, boolean for whether it was double clicked or not
*/
protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY)
{
this.selected = slotIndex;
GuiFlatPresets.this.updateButtonValidity();
GuiFlatPresets.this.export.setText((GuiFlatPresets.FLAT_WORLD_PRESETS.get(GuiFlatPresets.this.list.selected)).generatorInfo);
}
/**
* Returns true if the element passed in is currently selected
*/
protected boolean isSelected(int slotIndex)
{
return slotIndex == this.selected;
}
protected void drawBackground()
{
}
protected void drawSlot(int slotIndex, int xPos, int yPos, int heightIn, int mouseXIn, int mouseYIn, float partialTicks)
{
GuiFlatPresets.LayerItem guiflatpresets$layeritem = GuiFlatPresets.FLAT_WORLD_PRESETS.get(slotIndex);
this.renderIcon(xPos, yPos, guiflatpresets$layeritem.icon, guiflatpresets$layeritem.iconMetadata);
GuiFlatPresets.this.fontRenderer.drawString(guiflatpresets$layeritem.name, xPos + 18 + 5, yPos + 6, 16777215);
}
}
}

View File

@@ -0,0 +1,200 @@
package net.minecraft.client.gui;
import java.io.IOException;
import javax.annotation.Nullable;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiGameOver extends GuiScreen
{
/** The integer value containing the number of ticks that have passed since the player's death */
private int enableButtonsTimer;
private final ITextComponent causeOfDeath;
public GuiGameOver(@Nullable ITextComponent causeOfDeathIn)
{
this.causeOfDeath = causeOfDeathIn;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.buttonList.clear();
this.enableButtonsTimer = 0;
if (this.mc.world.getWorldInfo().isHardcoreModeEnabled())
{
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 72, I18n.format("deathScreen.spectate")));
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 96, I18n.format("deathScreen." + (this.mc.isIntegratedServerRunning() ? "deleteWorld" : "leaveServer"))));
}
else
{
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 72, I18n.format("deathScreen.respawn")));
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 96, I18n.format("deathScreen.titleScreen")));
if (this.mc.getSession() == null)
{
(this.buttonList.get(1)).enabled = false;
}
}
for (GuiButton guibutton : this.buttonList)
{
guibutton.enabled = false;
}
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
switch (button.id)
{
case 0:
this.mc.player.respawnPlayer();
this.mc.displayGuiScreen((GuiScreen)null);
break;
case 1:
if (this.mc.world.getWorldInfo().isHardcoreModeEnabled())
{
this.mc.displayGuiScreen(new GuiMainMenu());
}
else
{
GuiYesNo guiyesno = new GuiYesNo(this, I18n.format("deathScreen.quit.confirm"), "", I18n.format("deathScreen.titleScreen"), I18n.format("deathScreen.respawn"), 0);
this.mc.displayGuiScreen(guiyesno);
guiyesno.setButtonDelay(20);
}
}
}
public void confirmClicked(boolean result, int id)
{
if (result)
{
if (this.mc.world != null)
{
this.mc.world.sendQuittingDisconnectingPacket();
}
this.mc.loadWorld((WorldClient)null);
this.mc.displayGuiScreen(new GuiMainMenu());
}
else
{
this.mc.player.respawnPlayer();
this.mc.displayGuiScreen((GuiScreen)null);
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
boolean flag = this.mc.world.getWorldInfo().isHardcoreModeEnabled();
this.drawGradientRect(0, 0, this.width, this.height, 1615855616, -1602211792);
GlStateManager.pushMatrix();
GlStateManager.scale(2.0F, 2.0F, 2.0F);
this.drawCenteredString(this.fontRenderer, I18n.format(flag ? "deathScreen.title.hardcore" : "deathScreen.title"), this.width / 2 / 2, 30, 16777215);
GlStateManager.popMatrix();
if (this.causeOfDeath != null)
{
this.drawCenteredString(this.fontRenderer, this.causeOfDeath.getFormattedText(), this.width / 2, 85, 16777215);
}
this.drawCenteredString(this.fontRenderer, I18n.format("deathScreen.score") + ": " + TextFormatting.YELLOW + this.mc.player.getScore(), this.width / 2, 100, 16777215);
if (this.causeOfDeath != null && mouseY > 85 && mouseY < 85 + this.fontRenderer.FONT_HEIGHT)
{
ITextComponent itextcomponent = this.getClickedComponentAt(mouseX);
if (itextcomponent != null && itextcomponent.getStyle().getHoverEvent() != null)
{
this.handleComponentHover(itextcomponent, mouseX, mouseY);
}
}
super.drawScreen(mouseX, mouseY, partialTicks);
}
@Nullable
public ITextComponent getClickedComponentAt(int p_184870_1_)
{
if (this.causeOfDeath == null)
{
return null;
}
else
{
int i = this.mc.fontRenderer.getStringWidth(this.causeOfDeath.getFormattedText());
int j = this.width / 2 - i / 2;
int k = this.width / 2 + i / 2;
int l = j;
if (p_184870_1_ >= j && p_184870_1_ <= k)
{
for (ITextComponent itextcomponent : this.causeOfDeath)
{
l += this.mc.fontRenderer.getStringWidth(GuiUtilRenderComponents.removeTextColorsIfConfigured(itextcomponent.getUnformattedComponentText(), false));
if (l > p_184870_1_)
{
return itextcomponent;
}
}
return null;
}
else
{
return null;
}
}
}
/**
* Returns true if this GUI should pause the game when it is displayed in single-player
*/
public boolean doesGuiPauseGame()
{
return false;
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
super.updateScreen();
++this.enableButtonsTimer;
if (this.enableButtonsTimer == 20)
{
for (GuiButton guibutton : this.buttonList)
{
guibutton.enabled = true;
}
}
}
}

View File

@@ -0,0 +1,62 @@
package net.minecraft.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ContainerHopper;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiHopper extends GuiContainer
{
/** The ResourceLocation containing the gui texture for the hopper */
private static final ResourceLocation HOPPER_GUI_TEXTURE = new ResourceLocation("textures/gui/container/hopper.png");
/** The player inventory currently bound to this GUI instance */
private final IInventory playerInventory;
/** The hopper inventory bound to this GUI instance */
private final IInventory hopperInventory;
public GuiHopper(InventoryPlayer playerInv, IInventory hopperInv)
{
super(new ContainerHopper(playerInv, hopperInv, Minecraft.getMinecraft().player));
this.playerInventory = playerInv;
this.hopperInventory = hopperInv;
this.allowUserInput = false;
this.ySize = 133;
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
super.drawScreen(mouseX, mouseY, partialTicks);
this.renderHoveredToolTip(mouseX, mouseY);
}
/**
* Draw the foreground layer for the GuiContainer (everything in front of the items)
*/
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
this.fontRenderer.drawString(this.hopperInventory.getDisplayName().getUnformattedText(), 8, 6, 4210752);
this.fontRenderer.drawString(this.playerInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 96 + 2, 4210752);
}
/**
* Draws the background layer of this container (behind the items).
*/
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
{
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(HOPPER_GUI_TEXTURE);
int i = (this.width - this.xSize) / 2;
int j = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,118 @@
package net.minecraft.client.gui;
import java.io.IOException;
import net.minecraft.client.gui.achievement.GuiStats;
import net.minecraft.client.gui.advancements.GuiScreenAdvancements;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.resources.I18n;
import net.minecraft.realms.RealmsBridge;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiIngameMenu extends GuiScreen
{
private int saveStep;
private int visibleTime;
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.saveStep = 0;
this.buttonList.clear();
int i = -16;
int j = 98;
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + -16, I18n.format("menu.returnToMenu")));
if (!this.mc.isIntegratedServerRunning())
{
(this.buttonList.get(0)).displayString = I18n.format("menu.disconnect");
}
this.buttonList.add(new GuiButton(4, this.width / 2 - 100, this.height / 4 + 24 + -16, I18n.format("menu.returnToGame")));
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + -16, 98, 20, I18n.format("menu.options")));
this.buttonList.add(new GuiButton(12, this.width / 2 + 2, this.height / 4 + 96 + i, 98, 20, I18n.format("fml.menu.modoptions")));
GuiButton guibutton = this.addButton(new GuiButton(7, this.width / 2 - 100, this.height / 4 + 72 + -16, 200, 20, I18n.format("menu.shareToLan", new Object[0])));
guibutton.enabled = this.mc.isSingleplayer() && !this.mc.getIntegratedServer().getPublic();
this.buttonList.add(new GuiButton(5, this.width / 2 - 100, this.height / 4 + 48 + -16, 98, 20, I18n.format("gui.advancements")));
this.buttonList.add(new GuiButton(6, this.width / 2 + 2, this.height / 4 + 48 + -16, 98, 20, I18n.format("gui.stats")));
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
switch (button.id)
{
case 0:
this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings));
break;
case 1:
boolean flag = this.mc.isIntegratedServerRunning();
boolean flag1 = this.mc.isConnectedToRealms();
button.enabled = false;
this.mc.world.sendQuittingDisconnectingPacket();
this.mc.loadWorld((WorldClient)null);
if (flag)
{
this.mc.displayGuiScreen(new GuiMainMenu());
}
else if (flag1)
{
RealmsBridge realmsbridge = new RealmsBridge();
realmsbridge.switchToRealms(new GuiMainMenu());
}
else
{
this.mc.displayGuiScreen(new GuiMultiplayer(new GuiMainMenu()));
}
case 2:
case 3:
default:
break;
case 4:
this.mc.displayGuiScreen((GuiScreen)null);
this.mc.setIngameFocus();
break;
case 5:
if (this.mc.player != null)
this.mc.displayGuiScreen(new GuiScreenAdvancements(this.mc.player.connection.getAdvancementManager()));
break;
case 6:
if (this.mc.player != null)
this.mc.displayGuiScreen(new GuiStats(this, this.mc.player.getStatFileWriter()));
break;
case 7:
this.mc.displayGuiScreen(new GuiShareToLan(this));
break;
case 12:
net.minecraftforge.fml.client.FMLClientHandler.instance().showInGameModOptions(this);
break;
}
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
super.updateScreen();
++this.visibleTime;
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, I18n.format("menu.game"), this.width / 2, 40, 16777215);
super.drawScreen(mouseX, mouseY, partialTicks);
}
}

View File

@@ -0,0 +1,210 @@
package net.minecraft.client.gui;
import java.util.Arrays;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.ArrayUtils;
@SideOnly(Side.CLIENT)
public class GuiKeyBindingList extends GuiListExtended
{
private final GuiControls controlsScreen;
private final Minecraft mc;
private final GuiListExtended.IGuiListEntry[] listEntries;
private int maxListLabelWidth;
public GuiKeyBindingList(GuiControls controls, Minecraft mcIn)
{
super(mcIn, controls.width + 45, controls.height, 63, controls.height - 32, 20);
this.controlsScreen = controls;
this.mc = mcIn;
KeyBinding[] akeybinding = (KeyBinding[])ArrayUtils.clone(mcIn.gameSettings.keyBindings);
this.listEntries = new GuiListExtended.IGuiListEntry[akeybinding.length + KeyBinding.getKeybinds().size()];
Arrays.sort((Object[])akeybinding);
int i = 0;
String s = null;
for (KeyBinding keybinding : akeybinding)
{
String s1 = keybinding.getKeyCategory();
if (!s1.equals(s))
{
s = s1;
this.listEntries[i++] = new GuiKeyBindingList.CategoryEntry(s1);
}
int j = mcIn.fontRenderer.getStringWidth(I18n.format(keybinding.getKeyDescription()));
if (j > this.maxListLabelWidth)
{
this.maxListLabelWidth = j;
}
this.listEntries[i++] = new GuiKeyBindingList.KeyEntry(keybinding);
}
}
protected int getSize()
{
return this.listEntries.length;
}
/**
* Gets the IGuiListEntry object for the given index
*/
public GuiListExtended.IGuiListEntry getListEntry(int index)
{
return this.listEntries[index];
}
protected int getScrollBarX()
{
return super.getScrollBarX() + 35;
}
/**
* Gets the width of the list
*/
public int getListWidth()
{
return super.getListWidth() + 32;
}
@SideOnly(Side.CLIENT)
public class CategoryEntry implements GuiListExtended.IGuiListEntry
{
private final String labelText;
private final int labelWidth;
public CategoryEntry(String name)
{
this.labelText = I18n.format(name);
this.labelWidth = GuiKeyBindingList.this.mc.fontRenderer.getStringWidth(this.labelText);
}
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float partialTicks)
{
GuiKeyBindingList.this.mc.fontRenderer.drawString(this.labelText, GuiKeyBindingList.this.mc.currentScreen.width / 2 - this.labelWidth / 2, y + slotHeight - GuiKeyBindingList.this.mc.fontRenderer.FONT_HEIGHT - 1, 16777215);
}
/**
* 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)
{
return false;
}
/**
* Fired when the mouse button is released. Arguments: index, x, y, mouseEvent, relativeX, relativeY
*/
public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY)
{
}
public void updatePosition(int slotIndex, int x, int y, float partialTicks)
{
}
}
@SideOnly(Side.CLIENT)
public class KeyEntry implements GuiListExtended.IGuiListEntry
{
/** The keybinding specified for this KeyEntry */
private final KeyBinding keybinding;
/** The localized key description for this KeyEntry */
private final String keyDesc;
private final GuiButton btnChangeKeyBinding;
private final GuiButton btnReset;
private KeyEntry(KeyBinding name)
{
this.keybinding = name;
this.keyDesc = I18n.format(name.getKeyDescription());
this.btnChangeKeyBinding = new GuiButton(0, 0, 0, 95, 20, I18n.format(name.getKeyDescription()));
this.btnReset = new GuiButton(0, 0, 0, 50, 20, I18n.format("controls.reset"));
}
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float partialTicks)
{
boolean flag = GuiKeyBindingList.this.controlsScreen.buttonId == this.keybinding;
GuiKeyBindingList.this.mc.fontRenderer.drawString(this.keyDesc, x + 90 - GuiKeyBindingList.this.maxListLabelWidth, y + slotHeight / 2 - GuiKeyBindingList.this.mc.fontRenderer.FONT_HEIGHT / 2, 16777215);
this.btnReset.x = x + 210;
this.btnReset.y = y;
this.btnReset.enabled = !this.keybinding.isSetToDefaultValue();
this.btnReset.drawButton(GuiKeyBindingList.this.mc, mouseX, mouseY, partialTicks);
this.btnChangeKeyBinding.x = x + 105;
this.btnChangeKeyBinding.y = y;
this.btnChangeKeyBinding.displayString = this.keybinding.getDisplayName();
boolean flag1 = false;
boolean keyCodeModifierConflict = true; // less severe form of conflict, like SHIFT conflicting with SHIFT+G
if (this.keybinding.getKeyCode() != 0)
{
for (KeyBinding keybinding : GuiKeyBindingList.this.mc.gameSettings.keyBindings)
{
if (keybinding != this.keybinding && keybinding.conflicts(this.keybinding))
{
flag1 = true;
keyCodeModifierConflict &= keybinding.hasKeyCodeModifierConflict(this.keybinding);
}
}
}
if (flag)
{
this.btnChangeKeyBinding.displayString = TextFormatting.WHITE + "> " + TextFormatting.YELLOW + this.btnChangeKeyBinding.displayString + TextFormatting.WHITE + " <";
}
else if (flag1)
{
this.btnChangeKeyBinding.displayString = (keyCodeModifierConflict ? TextFormatting.GOLD : TextFormatting.RED) + this.btnChangeKeyBinding.displayString;
}
this.btnChangeKeyBinding.drawButton(GuiKeyBindingList.this.mc, mouseX, mouseY, partialTicks);
}
/**
* 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.btnChangeKeyBinding.mousePressed(GuiKeyBindingList.this.mc, mouseX, mouseY))
{
GuiKeyBindingList.this.controlsScreen.buttonId = this.keybinding;
return true;
}
else if (this.btnReset.mousePressed(GuiKeyBindingList.this.mc, mouseX, mouseY))
{
this.keybinding.setToDefault();
GuiKeyBindingList.this.mc.gameSettings.setOptionKeyBinding(this.keybinding, this.keybinding.getKeyCodeDefault());
KeyBinding.resetKeyBindingArrayAndHash();
return true;
}
else
{
return false;
}
}
/**
* Fired when the mouse button is released. Arguments: index, x, y, mouseEvent, relativeX, relativeY
*/
public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY)
{
this.btnChangeKeyBinding.mouseReleased(x, y);
this.btnReset.mouseReleased(x, y);
}
public void updatePosition(int slotIndex, int x, int y, float partialTicks)
{
}
}
}

View File

@@ -0,0 +1,101 @@
package net.minecraft.client.gui;
import com.google.common.collect.Lists;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiLabel extends Gui
{
protected int width = 200;
protected int height = 20;
public int x;
public int y;
private final List<String> labels;
public int id;
private boolean centered;
public boolean visible = true;
private boolean labelBgEnabled;
private final int textColor;
private int backColor;
private int ulColor;
private int brColor;
private final FontRenderer fontRenderer;
private int border;
public GuiLabel(FontRenderer fontRendererObj, int p_i45540_2_, int p_i45540_3_, int p_i45540_4_, int p_i45540_5_, int p_i45540_6_, int p_i45540_7_)
{
this.fontRenderer = fontRendererObj;
this.id = p_i45540_2_;
this.x = p_i45540_3_;
this.y = p_i45540_4_;
this.width = p_i45540_5_;
this.height = p_i45540_6_;
this.labels = Lists.<String>newArrayList();
this.centered = false;
this.labelBgEnabled = false;
this.textColor = p_i45540_7_;
this.backColor = -1;
this.ulColor = -1;
this.brColor = -1;
this.border = 0;
}
public void addLine(String p_175202_1_)
{
this.labels.add(I18n.format(p_175202_1_));
}
/**
* Sets the Label to be centered
*/
public GuiLabel setCentered()
{
this.centered = true;
return this;
}
public void drawLabel(Minecraft mc, int mouseX, int mouseY)
{
if (this.visible)
{
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
this.drawLabelBackground(mc, mouseX, mouseY);
int i = this.y + this.height / 2 + this.border / 2;
int j = i - this.labels.size() * 10 / 2;
for (int k = 0; k < this.labels.size(); ++k)
{
if (this.centered)
{
this.drawCenteredString(this.fontRenderer, this.labels.get(k), this.x + this.width / 2, j + k * 10, this.textColor);
}
else
{
this.drawString(this.fontRenderer, this.labels.get(k), this.x, j + k * 10, this.textColor);
}
}
}
}
protected void drawLabelBackground(Minecraft mcIn, int p_146160_2_, int p_146160_3_)
{
if (this.labelBgEnabled)
{
int i = this.width + this.border * 2;
int j = this.height + this.border * 2;
int k = this.x - this.border;
int l = this.y - this.border;
drawRect(k, l, k + i, l + j, this.backColor);
this.drawHorizontalLine(k, k + i, l, this.ulColor);
this.drawHorizontalLine(k, k + i, l + j, this.brColor);
this.drawVerticalLine(k, l, l + j, this.ulColor);
this.drawVerticalLine(k + i, l, l + j, this.brColor);
}
}
}

View File

@@ -0,0 +1,171 @@
package net.minecraft.client.gui;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.io.IOException;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.resources.Language;
import net.minecraft.client.resources.LanguageManager;
import net.minecraft.client.settings.GameSettings;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiLanguage extends GuiScreen
{
/** The parent Gui screen */
protected GuiScreen parentScreen;
/** The List GuiSlot object reference. */
private GuiLanguage.List list;
/** Reference to the GameSettings object. */
private final GameSettings game_settings_3;
/** Reference to the LanguageManager object. */
private final LanguageManager languageManager;
/** A button which allows the user to determine if the Unicode font should be forced. */
private GuiOptionButton forceUnicodeFontBtn;
/** The button to confirm the current settings. */
private GuiOptionButton confirmSettingsBtn;
public GuiLanguage(GuiScreen screen, GameSettings gameSettingsObj, LanguageManager manager)
{
this.parentScreen = screen;
this.game_settings_3 = gameSettingsObj;
this.languageManager = manager;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.forceUnicodeFontBtn = (GuiOptionButton)this.addButton(new GuiOptionButton(100, this.width / 2 - 155, this.height - 38, GameSettings.Options.FORCE_UNICODE_FONT, this.game_settings_3.getKeyBinding(GameSettings.Options.FORCE_UNICODE_FONT)));
this.confirmSettingsBtn = (GuiOptionButton)this.addButton(new GuiOptionButton(6, this.width / 2 - 155 + 160, this.height - 38, I18n.format("gui.done")));
this.list = new GuiLanguage.List(this.mc);
this.list.registerScrollButtons(7, 8);
}
/**
* Handles mouse input.
*/
public void handleMouseInput() throws IOException
{
super.handleMouseInput();
this.list.handleMouseInput();
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.enabled)
{
switch (button.id)
{
case 5:
break;
case 6:
this.mc.displayGuiScreen(this.parentScreen);
break;
case 100:
if (button instanceof GuiOptionButton)
{
this.game_settings_3.setOptionValue(((GuiOptionButton)button).getOption(), 1);
button.displayString = this.game_settings_3.getKeyBinding(GameSettings.Options.FORCE_UNICODE_FONT);
ScaledResolution scaledresolution = new ScaledResolution(this.mc);
int i = scaledresolution.getScaledWidth();
int j = scaledresolution.getScaledHeight();
this.setWorldAndResolution(this.mc, i, j);
}
break;
default:
this.list.actionPerformed(button);
}
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.list.drawScreen(mouseX, mouseY, partialTicks);
this.drawCenteredString(this.fontRenderer, I18n.format("options.language"), this.width / 2, 16, 16777215);
this.drawCenteredString(this.fontRenderer, "(" + I18n.format("options.languageWarning") + ")", this.width / 2, this.height - 56, 8421504);
super.drawScreen(mouseX, mouseY, partialTicks);
}
@SideOnly(Side.CLIENT)
class List extends GuiSlot
{
/** A list containing the many different locale language codes. */
private final java.util.List<String> langCodeList = Lists.<String>newArrayList();
/** The map containing the Locale-Language pairs. */
private final Map<String, Language> languageMap = Maps.<String, Language>newHashMap();
public List(Minecraft mcIn)
{
super(mcIn, GuiLanguage.this.width, GuiLanguage.this.height, 32, GuiLanguage.this.height - 65 + 4, 18);
for (Language language : GuiLanguage.this.languageManager.getLanguages())
{
this.languageMap.put(language.getLanguageCode(), language);
this.langCodeList.add(language.getLanguageCode());
}
}
protected int getSize()
{
return this.langCodeList.size();
}
/**
* The element in the slot that was clicked, boolean for whether it was double clicked or not
*/
protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY)
{
Language language = this.languageMap.get(this.langCodeList.get(slotIndex));
GuiLanguage.this.languageManager.setCurrentLanguage(language);
GuiLanguage.this.game_settings_3.language = language.getLanguageCode();
net.minecraftforge.fml.client.FMLClientHandler.instance().refreshResources(net.minecraftforge.client.resource.VanillaResourceType.LANGUAGES);
GuiLanguage.this.fontRenderer.setUnicodeFlag(GuiLanguage.this.languageManager.isCurrentLocaleUnicode() || GuiLanguage.this.game_settings_3.forceUnicodeFont);
GuiLanguage.this.fontRenderer.setBidiFlag(GuiLanguage.this.languageManager.isCurrentLanguageBidirectional());
GuiLanguage.this.confirmSettingsBtn.displayString = I18n.format("gui.done");
GuiLanguage.this.forceUnicodeFontBtn.displayString = GuiLanguage.this.game_settings_3.getKeyBinding(GameSettings.Options.FORCE_UNICODE_FONT);
GuiLanguage.this.game_settings_3.saveOptions();
}
/**
* Returns true if the element passed in is currently selected
*/
protected boolean isSelected(int slotIndex)
{
return ((String)this.langCodeList.get(slotIndex)).equals(GuiLanguage.this.languageManager.getCurrentLanguage().getLanguageCode());
}
/**
* Return the height of the content being scrolled
*/
protected int getContentHeight()
{
return this.getSize() * 18;
}
protected void drawBackground()
{
GuiLanguage.this.drawDefaultBackground();
}
protected void drawSlot(int slotIndex, int xPos, int yPos, int heightIn, int mouseXIn, int mouseYIn, float partialTicks)
{
GuiLanguage.this.fontRenderer.setBidiFlag(true);
GuiLanguage.this.drawCenteredString(GuiLanguage.this.fontRenderer, ((Language)this.languageMap.get(this.langCodeList.get(slotIndex))).toString(), this.width / 2, yPos + 1, 16777215);
GuiLanguage.this.fontRenderer.setBidiFlag(GuiLanguage.this.languageManager.getCurrentLanguage().isBidirectional());
}
}
}

View File

@@ -0,0 +1,59 @@
package net.minecraft.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiListButton extends GuiButton
{
private boolean value;
/** The localization string used by this control. */
private final String localizationStr;
/** The GuiResponder Object reference. */
private final GuiPageButtonList.GuiResponder guiResponder;
public GuiListButton(GuiPageButtonList.GuiResponder responder, int buttonId, int x, int y, String localizationStrIn, boolean valueIn)
{
super(buttonId, x, y, 150, 20, "");
this.localizationStr = localizationStrIn;
this.value = valueIn;
this.displayString = this.buildDisplayString();
this.guiResponder = responder;
}
/**
* Builds the localized display string for this GuiListButton
*/
private String buildDisplayString()
{
return I18n.format(this.localizationStr) + ": " + I18n.format(this.value ? "gui.yes" : "gui.no");
}
public void setValue(boolean valueIn)
{
this.value = valueIn;
this.displayString = this.buildDisplayString();
this.guiResponder.setEntryValue(this.id, valueIn);
}
/**
* Returns true if the mouse has been pressed on this control. Equivalent of MouseListener.mousePressed(MouseEvent
* e).
*/
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY)
{
if (super.mousePressed(mc, mouseX, mouseY))
{
this.value = !this.value;
this.displayString = this.buildDisplayString();
this.guiResponder.setEntryValue(this.id, this.value);
return true;
}
else
{
return false;
}
}
}

View File

@@ -0,0 +1,106 @@
package net.minecraft.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public abstract class GuiListExtended extends GuiSlot
{
public GuiListExtended(Minecraft mcIn, int widthIn, int heightIn, int topIn, int bottomIn, int slotHeightIn)
{
super(mcIn, widthIn, heightIn, topIn, bottomIn, slotHeightIn);
}
/**
* The element in the slot that was clicked, boolean for whether it was double clicked or not
*/
protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY)
{
}
/**
* Returns true if the element passed in is currently selected
*/
protected boolean isSelected(int slotIndex)
{
return false;
}
protected void drawBackground()
{
}
protected void drawSlot(int slotIndex, int xPos, int yPos, int heightIn, int mouseXIn, int mouseYIn, float partialTicks)
{
this.getListEntry(slotIndex).drawEntry(slotIndex, xPos, yPos, this.getListWidth(), heightIn, mouseXIn, mouseYIn, this.isMouseYWithinSlotBounds(mouseYIn) && this.getSlotIndexFromScreenCoords(mouseXIn, mouseYIn) == slotIndex, partialTicks);
}
protected void updateItemPos(int entryID, int insideLeft, int yPos, float partialTicks)
{
this.getListEntry(entryID).updatePosition(entryID, insideLeft, yPos, partialTicks);
}
public boolean mouseClicked(int mouseX, int mouseY, int mouseEvent)
{
if (this.isMouseYWithinSlotBounds(mouseY))
{
int i = this.getSlotIndexFromScreenCoords(mouseX, mouseY);
if (i >= 0)
{
int j = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
int k = this.top + 4 - this.getAmountScrolled() + i * this.slotHeight + this.headerPadding;
int l = mouseX - j;
int i1 = mouseY - k;
if (this.getListEntry(i).mousePressed(i, mouseX, mouseY, mouseEvent, l, i1))
{
this.setEnabled(false);
return true;
}
}
}
return false;
}
public boolean mouseReleased(int x, int y, int mouseEvent)
{
for (int i = 0; i < this.getSize(); ++i)
{
int j = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
int k = this.top + 4 - this.getAmountScrolled() + i * this.slotHeight + this.headerPadding;
int l = x - j;
int i1 = y - k;
this.getListEntry(i).mouseReleased(i, x, y, mouseEvent, l, i1);
}
this.setEnabled(true);
return false;
}
/**
* Gets the IGuiListEntry object for the given index
*/
public abstract GuiListExtended.IGuiListEntry getListEntry(int index);
@SideOnly(Side.CLIENT)
public interface IGuiListEntry
{
void updatePosition(int slotIndex, int x, int y, float partialTicks);
void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float partialTicks);
/**
* 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.
*/
boolean mousePressed(int slotIndex, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY);
/**
* Fired when the mouse button is released. Arguments: index, x, y, mouseEvent, relativeX, relativeY
*/
void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY);
}
}

View File

@@ -0,0 +1,107 @@
package net.minecraft.client.gui;
import com.google.common.collect.Lists;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.client.AnvilConverterException;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.world.storage.ISaveFormat;
import net.minecraft.world.storage.WorldSummary;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@SideOnly(Side.CLIENT)
public class GuiListWorldSelection extends GuiListExtended
{
private static final Logger LOGGER = LogManager.getLogger();
private final GuiWorldSelection worldSelection;
private final List<GuiListWorldSelectionEntry> entries = Lists.<GuiListWorldSelectionEntry>newArrayList();
/** Index to the currently selected world */
private int selectedIdx = -1;
public GuiListWorldSelection(GuiWorldSelection p_i46590_1_, Minecraft clientIn, int widthIn, int heightIn, int topIn, int bottomIn, int slotHeightIn)
{
super(clientIn, widthIn, heightIn, topIn, bottomIn, slotHeightIn);
this.worldSelection = p_i46590_1_;
this.refreshList();
}
public void refreshList()
{
ISaveFormat isaveformat = this.mc.getSaveLoader();
List<WorldSummary> list;
try
{
list = isaveformat.getSaveList();
}
catch (AnvilConverterException anvilconverterexception)
{
LOGGER.error("Couldn't load level list", (Throwable)anvilconverterexception);
this.mc.displayGuiScreen(new GuiErrorScreen(I18n.format("selectWorld.unable_to_load"), anvilconverterexception.getMessage()));
return;
}
Collections.sort(list);
for (WorldSummary worldsummary : list)
{
this.entries.add(new GuiListWorldSelectionEntry(this, worldsummary, this.mc.getSaveLoader()));
}
}
/**
* Gets the IGuiListEntry object for the given index
*/
public GuiListWorldSelectionEntry getListEntry(int index)
{
return this.entries.get(index);
}
protected int getSize()
{
return this.entries.size();
}
protected int getScrollBarX()
{
return super.getScrollBarX() + 20;
}
/**
* Gets the width of the list
*/
public int getListWidth()
{
return super.getListWidth() + 50;
}
public void selectWorld(int idx)
{
this.selectedIdx = idx;
this.worldSelection.selectWorld(this.getSelectedWorld());
}
/**
* Returns true if the element passed in is currently selected
*/
protected boolean isSelected(int slotIndex)
{
return slotIndex == this.selectedIdx;
}
@Nullable
public GuiListWorldSelectionEntry getSelectedWorld()
{
return this.selectedIdx >= 0 && this.selectedIdx < this.getSize() ? this.getListEntry(this.selectedIdx) : null;
}
public GuiWorldSelection getGuiWorldSelection()
{
return this.worldSelection;
}
}

View File

@@ -0,0 +1,304 @@
package net.minecraft.client.gui;
import java.awt.image.BufferedImage;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.imageio.ImageIO;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.resources.I18n;
import net.minecraft.init.SoundEvents;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.WorldSettings;
import net.minecraft.world.storage.ISaveFormat;
import net.minecraft.world.storage.ISaveHandler;
import net.minecraft.world.storage.WorldInfo;
import net.minecraft.world.storage.WorldSummary;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@SideOnly(Side.CLIENT)
public class GuiListWorldSelectionEntry implements GuiListExtended.IGuiListEntry
{
private static final Logger LOGGER = LogManager.getLogger();
private static final DateFormat DATE_FORMAT = new SimpleDateFormat();
private static final ResourceLocation ICON_MISSING = new ResourceLocation("textures/misc/unknown_server.png");
private static final ResourceLocation ICON_OVERLAY_LOCATION = new ResourceLocation("textures/gui/world_selection.png");
private final Minecraft client;
private final GuiWorldSelection worldSelScreen;
private final WorldSummary worldSummary;
private final ResourceLocation iconLocation;
private final GuiListWorldSelection containingListSel;
private File iconFile;
private DynamicTexture icon;
private long lastClickTime;
public GuiListWorldSelectionEntry(GuiListWorldSelection listWorldSelIn, WorldSummary worldSummaryIn, ISaveFormat saveFormat)
{
this.containingListSel = listWorldSelIn;
this.worldSelScreen = listWorldSelIn.getGuiWorldSelection();
this.worldSummary = worldSummaryIn;
this.client = Minecraft.getMinecraft();
this.iconLocation = new ResourceLocation("worlds/" + worldSummaryIn.getFileName() + "/icon");
this.iconFile = saveFormat.getFile(worldSummaryIn.getFileName(), "icon.png");
if (!this.iconFile.isFile())
{
this.iconFile = null;
}
this.loadServerIcon();
}
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float partialTicks)
{
String s = this.worldSummary.getDisplayName();
String s1 = this.worldSummary.getFileName() + " (" + DATE_FORMAT.format(new Date(this.worldSummary.getLastTimePlayed())) + ")";
String s2 = "";
if (StringUtils.isEmpty(s))
{
s = I18n.format("selectWorld.world") + " " + (slotIndex + 1);
}
if (this.worldSummary.requiresConversion())
{
s2 = I18n.format("selectWorld.conversion") + " " + s2;
}
else
{
s2 = I18n.format("gameMode." + this.worldSummary.getEnumGameType().getName());
if (this.worldSummary.isHardcoreModeEnabled())
{
s2 = TextFormatting.DARK_RED + I18n.format("gameMode.hardcore") + TextFormatting.RESET;
}
if (this.worldSummary.getCheatsEnabled())
{
s2 = s2 + ", " + I18n.format("selectWorld.cheats");
}
String s3 = this.worldSummary.getVersionName();
if (this.worldSummary.markVersionInList())
{
if (this.worldSummary.askToOpenWorld())
{
s2 = s2 + ", " + I18n.format("selectWorld.version") + " " + TextFormatting.RED + s3 + TextFormatting.RESET;
}
else
{
s2 = s2 + ", " + I18n.format("selectWorld.version") + " " + TextFormatting.ITALIC + s3 + TextFormatting.RESET;
}
}
else
{
s2 = s2 + ", " + I18n.format("selectWorld.version") + " " + s3;
}
}
this.client.fontRenderer.drawString(s, x + 32 + 3, y + 1, 16777215);
this.client.fontRenderer.drawString(s1, x + 32 + 3, y + this.client.fontRenderer.FONT_HEIGHT + 3, 8421504);
this.client.fontRenderer.drawString(s2, x + 32 + 3, y + this.client.fontRenderer.FONT_HEIGHT + this.client.fontRenderer.FONT_HEIGHT + 3, 8421504);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.client.getTextureManager().bindTexture(this.icon != null ? this.iconLocation : ICON_MISSING);
GlStateManager.enableBlend();
Gui.drawModalRectWithCustomSizedTexture(x, y, 0.0F, 0.0F, 32, 32, 32.0F, 32.0F);
GlStateManager.disableBlend();
if (this.client.gameSettings.touchscreen || isSelected)
{
this.client.getTextureManager().bindTexture(ICON_OVERLAY_LOCATION);
Gui.drawRect(x, y, x + 32, y + 32, -1601138544);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
int j = mouseX - x;
int i = j < 32 ? 32 : 0;
if (this.worldSummary.markVersionInList())
{
Gui.drawModalRectWithCustomSizedTexture(x, y, 32.0F, (float)i, 32, 32, 256.0F, 256.0F);
if (this.worldSummary.askToOpenWorld())
{
Gui.drawModalRectWithCustomSizedTexture(x, y, 96.0F, (float)i, 32, 32, 256.0F, 256.0F);
if (j < 32)
{
this.worldSelScreen.setVersionTooltip(TextFormatting.RED + I18n.format("selectWorld.tooltip.fromNewerVersion1") + "\n" + TextFormatting.RED + I18n.format("selectWorld.tooltip.fromNewerVersion2"));
}
}
else
{
Gui.drawModalRectWithCustomSizedTexture(x, y, 64.0F, (float)i, 32, 32, 256.0F, 256.0F);
if (j < 32)
{
this.worldSelScreen.setVersionTooltip(TextFormatting.GOLD + I18n.format("selectWorld.tooltip.snapshot1") + "\n" + TextFormatting.GOLD + I18n.format("selectWorld.tooltip.snapshot2"));
}
}
}
else
{
Gui.drawModalRectWithCustomSizedTexture(x, y, 0.0F, (float)i, 32, 32, 256.0F, 256.0F);
}
}
}
/**
* 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)
{
this.containingListSel.selectWorld(slotIndex);
if (relativeX <= 32 && relativeX < 32)
{
this.joinWorld();
return true;
}
else if (Minecraft.getSystemTime() - this.lastClickTime < 250L)
{
this.joinWorld();
return true;
}
else
{
this.lastClickTime = Minecraft.getSystemTime();
return false;
}
}
public void joinWorld()
{
if (this.worldSummary.askToOpenWorld())
{
this.client.displayGuiScreen(new GuiYesNo(new GuiYesNoCallback()
{
public void confirmClicked(boolean result, int id)
{
if (result)
{
GuiListWorldSelectionEntry.this.loadWorld();
}
else
{
GuiListWorldSelectionEntry.this.client.displayGuiScreen(GuiListWorldSelectionEntry.this.worldSelScreen);
}
}
}, I18n.format("selectWorld.versionQuestion"), I18n.format("selectWorld.versionWarning", this.worldSummary.getVersionName()), I18n.format("selectWorld.versionJoinButton"), I18n.format("gui.cancel"), 0));
}
else
{
this.loadWorld();
}
}
public void deleteWorld()
{
this.client.displayGuiScreen(new GuiYesNo(new GuiYesNoCallback()
{
public void confirmClicked(boolean result, int id)
{
if (result)
{
GuiListWorldSelectionEntry.this.client.displayGuiScreen(new GuiScreenWorking());
ISaveFormat isaveformat = GuiListWorldSelectionEntry.this.client.getSaveLoader();
isaveformat.flushCache();
isaveformat.deleteWorldDirectory(GuiListWorldSelectionEntry.this.worldSummary.getFileName());
GuiListWorldSelectionEntry.this.containingListSel.refreshList();
}
GuiListWorldSelectionEntry.this.client.displayGuiScreen(GuiListWorldSelectionEntry.this.worldSelScreen);
}
}, I18n.format("selectWorld.deleteQuestion"), "'" + this.worldSummary.getDisplayName() + "' " + I18n.format("selectWorld.deleteWarning"), I18n.format("selectWorld.deleteButton"), I18n.format("gui.cancel"), 0));
}
public void editWorld()
{
this.client.displayGuiScreen(new GuiWorldEdit(this.worldSelScreen, this.worldSummary.getFileName()));
}
public void recreateWorld()
{
this.client.displayGuiScreen(new GuiScreenWorking());
GuiCreateWorld guicreateworld = new GuiCreateWorld(this.worldSelScreen);
ISaveHandler isavehandler = this.client.getSaveLoader().getSaveLoader(this.worldSummary.getFileName(), false);
WorldInfo worldinfo = isavehandler.loadWorldInfo();
isavehandler.flush();
if (worldinfo != null)
{
guicreateworld.recreateFromExistingWorld(worldinfo);
this.client.displayGuiScreen(guicreateworld);
}
}
private void loadWorld()
{
this.client.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
if (this.client.getSaveLoader().canLoadWorld(this.worldSummary.getFileName()))
{
net.minecraftforge.fml.client.FMLClientHandler.instance().tryLoadExistingWorld(worldSelScreen, this.worldSummary);
}
}
private void loadServerIcon()
{
boolean flag = this.iconFile != null && this.iconFile.isFile();
if (flag)
{
BufferedImage bufferedimage;
try
{
bufferedimage = ImageIO.read(this.iconFile);
Validate.validState(bufferedimage.getWidth() == 64, "Must be 64 pixels wide");
Validate.validState(bufferedimage.getHeight() == 64, "Must be 64 pixels high");
}
catch (Throwable throwable)
{
LOGGER.error("Invalid icon for world {}", this.worldSummary.getFileName(), throwable);
this.iconFile = null;
return;
}
if (this.icon == null)
{
this.icon = new DynamicTexture(bufferedimage.getWidth(), bufferedimage.getHeight());
this.client.getTextureManager().loadTexture(this.iconLocation, this.icon);
}
bufferedimage.getRGB(0, 0, bufferedimage.getWidth(), bufferedimage.getHeight(), this.icon.getTextureData(), 0, bufferedimage.getWidth());
this.icon.updateDynamicTexture();
}
else if (!flag)
{
this.client.getTextureManager().deleteTexture(this.iconLocation);
this.icon = null;
}
}
/**
* Fired when the mouse button is released. Arguments: index, x, y, mouseEvent, relativeX, relativeY
*/
public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY)
{
}
public void updatePosition(int slotIndex, int x, int y, float partialTicks)
{
}
}

View File

@@ -0,0 +1,101 @@
package net.minecraft.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiLockIconButton extends GuiButton
{
private boolean locked;
public GuiLockIconButton(int buttonId, int x, int y)
{
super(buttonId, x, y, 20, 20, "");
}
public boolean isLocked()
{
return this.locked;
}
public void setLocked(boolean lockedIn)
{
this.locked = lockedIn;
}
/**
* Draws this button to the screen.
*/
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks)
{
if (this.visible)
{
mc.getTextureManager().bindTexture(GuiButton.BUTTON_TEXTURES);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
boolean flag = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
GuiLockIconButton.Icon guilockiconbutton$icon;
if (this.locked)
{
if (!this.enabled)
{
guilockiconbutton$icon = GuiLockIconButton.Icon.LOCKED_DISABLED;
}
else if (flag)
{
guilockiconbutton$icon = GuiLockIconButton.Icon.LOCKED_HOVER;
}
else
{
guilockiconbutton$icon = GuiLockIconButton.Icon.LOCKED;
}
}
else if (!this.enabled)
{
guilockiconbutton$icon = GuiLockIconButton.Icon.UNLOCKED_DISABLED;
}
else if (flag)
{
guilockiconbutton$icon = GuiLockIconButton.Icon.UNLOCKED_HOVER;
}
else
{
guilockiconbutton$icon = GuiLockIconButton.Icon.UNLOCKED;
}
this.drawTexturedModalRect(this.x, this.y, guilockiconbutton$icon.getX(), guilockiconbutton$icon.getY(), this.width, this.height);
}
}
@SideOnly(Side.CLIENT)
static enum Icon
{
LOCKED(0, 146),
LOCKED_HOVER(0, 166),
LOCKED_DISABLED(0, 186),
UNLOCKED(20, 146),
UNLOCKED_HOVER(20, 166),
UNLOCKED_DISABLED(20, 186);
private final int x;
private final int y;
private Icon(int xIn, int yIn)
{
this.x = xIn;
this.y = yIn;
}
public int getX()
{
return this.x;
}
public int getY()
{
return this.y;
}
}
}

View File

@@ -0,0 +1,668 @@
package net.minecraft.client.gui;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.Runnables;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Random;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.resources.IResource;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.realms.RealmsBridge;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StringUtils;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.WorldServerDemo;
import net.minecraft.world.storage.ISaveFormat;
import net.minecraft.world.storage.WorldInfo;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.io.IOUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GLContext;
import org.lwjgl.util.glu.Project;
@SideOnly(Side.CLIENT)
public class GuiMainMenu extends GuiScreen
{
private static final Logger LOGGER = LogManager.getLogger();
private static final Random RANDOM = new Random();
/**
* A random number between 0.0 and 1.0, used to determine if the title screen says <a
* href="https://minecraft.gamepedia.com/Menu_screen#Minceraft">Minceraft</a> instead of Minecraft. Set during
* construction; if the value is less than .0001, then Minceraft is displayed.
*/
private final float minceraftRoll;
/** The splash message. */
private String splashText;
private GuiButton buttonResetDemo;
/** Timer used to rotate the panorama, increases every tick. */
private float panoramaTimer;
/** Texture allocated for the current viewport of the main menu's panorama background. */
private DynamicTexture viewportTexture;
/** The Object object utilized as a thread lock when performing non thread-safe operations */
private final Object threadLock = new Object();
public static final String MORE_INFO_TEXT = "Please click " + TextFormatting.UNDERLINE + "here" + TextFormatting.RESET + " for more information.";
/** Width of openGLWarning2 */
private int openGLWarning2Width;
/** Width of openGLWarning1 */
private int openGLWarning1Width;
/** Left x coordinate of the OpenGL warning */
private int openGLWarningX1;
/** Top y coordinate of the OpenGL warning */
private int openGLWarningY1;
/** Right x coordinate of the OpenGL warning */
private int openGLWarningX2;
/** Bottom y coordinate of the OpenGL warning */
private int openGLWarningY2;
/** OpenGL graphics card warning. */
private String openGLWarning1;
/** OpenGL graphics card warning. */
private String openGLWarning2;
/** Link to the Mojang Support about minimum requirements */
private String openGLWarningLink;
private static final ResourceLocation SPLASH_TEXTS = new ResourceLocation("texts/splashes.txt");
private static final ResourceLocation MINECRAFT_TITLE_TEXTURES = new ResourceLocation("textures/gui/title/minecraft.png");
private static final ResourceLocation field_194400_H = new ResourceLocation("textures/gui/title/edition.png");
/** An array of all the paths to the panorama pictures. */
private static final ResourceLocation[] TITLE_PANORAMA_PATHS = new ResourceLocation[] {new ResourceLocation("textures/gui/title/background/panorama_0.png"), new ResourceLocation("textures/gui/title/background/panorama_1.png"), new ResourceLocation("textures/gui/title/background/panorama_2.png"), new ResourceLocation("textures/gui/title/background/panorama_3.png"), new ResourceLocation("textures/gui/title/background/panorama_4.png"), new ResourceLocation("textures/gui/title/background/panorama_5.png")};
private ResourceLocation backgroundTexture;
/** Minecraft Realms button. */
private GuiButton realmsButton;
/** Has the check for a realms notification screen been performed? */
private boolean hasCheckedForRealmsNotification;
/**
* A screen generated by realms for notifications; drawn in adition to the main menu (buttons and such from both are
* drawn at the same time). May be null.
*/
private GuiScreen realmsNotification;
private int widthCopyright;
private int widthCopyrightRest;
private GuiButton modButton;
private net.minecraftforge.client.gui.NotificationModUpdateScreen modUpdateNotification;
public GuiMainMenu()
{
this.openGLWarning2 = MORE_INFO_TEXT;
this.splashText = "missingno";
IResource iresource = null;
try
{
List<String> list = Lists.<String>newArrayList();
iresource = Minecraft.getMinecraft().getResourceManager().getResource(SPLASH_TEXTS);
BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(iresource.getInputStream(), StandardCharsets.UTF_8));
String s;
while ((s = bufferedreader.readLine()) != null)
{
s = s.trim();
if (!s.isEmpty())
{
list.add(s);
}
}
if (!list.isEmpty())
{
while (true)
{
this.splashText = list.get(RANDOM.nextInt(list.size()));
if (this.splashText.hashCode() != 125780783)
{
break;
}
}
}
}
catch (IOException var8)
{
;
}
finally
{
IOUtils.closeQuietly((Closeable)iresource);
}
this.minceraftRoll = RANDOM.nextFloat();
this.openGLWarning1 = "";
if (!GLContext.getCapabilities().OpenGL20 && !OpenGlHelper.areShadersSupported())
{
this.openGLWarning1 = I18n.format("title.oldgl1");
this.openGLWarning2 = I18n.format("title.oldgl2");
this.openGLWarningLink = "https://help.mojang.com/customer/portal/articles/325948?ref=game";
}
}
/**
* Is there currently a realms notification screen, and are realms notifications enabled?
*/
private boolean areRealmsNotificationsEnabled()
{
return Minecraft.getMinecraft().gameSettings.getOptionOrdinalValue(GameSettings.Options.REALMS_NOTIFICATIONS) && this.realmsNotification != null;
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
if (this.areRealmsNotificationsEnabled())
{
this.realmsNotification.updateScreen();
}
}
/**
* Returns true if this GUI should pause the game when it is displayed in single-player
*/
public boolean doesGuiPauseGame()
{
return false;
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.viewportTexture = new DynamicTexture(256, 256);
this.backgroundTexture = this.mc.getTextureManager().getDynamicTextureLocation("background", this.viewportTexture);
this.widthCopyright = this.fontRenderer.getStringWidth("Copyright Mojang AB. Do not distribute!");
this.widthCopyrightRest = this.width - this.widthCopyright - 2;
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
if (calendar.get(2) + 1 == 12 && calendar.get(5) == 24)
{
this.splashText = "Merry X-mas!";
}
else if (calendar.get(2) + 1 == 1 && calendar.get(5) == 1)
{
this.splashText = "Happy new year!";
}
else if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31)
{
this.splashText = "OOoooOOOoooo! Spooky!";
}
int i = 24;
int j = this.height / 4 + 48;
if (this.mc.isDemo())
{
this.addDemoButtons(j, 24);
}
else
{
this.addSingleplayerMultiplayerButtons(j, 24);
}
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, j + 72 + 12, 98, 20, I18n.format("menu.options")));
this.buttonList.add(new GuiButton(4, this.width / 2 + 2, j + 72 + 12, 98, 20, I18n.format("menu.quit")));
this.buttonList.add(new GuiButtonLanguage(5, this.width / 2 - 124, j + 72 + 12));
synchronized (this.threadLock)
{
this.openGLWarning1Width = this.fontRenderer.getStringWidth(this.openGLWarning1);
this.openGLWarning2Width = this.fontRenderer.getStringWidth(this.openGLWarning2);
int k = Math.max(this.openGLWarning1Width, this.openGLWarning2Width);
this.openGLWarningX1 = (this.width - k) / 2;
this.openGLWarningY1 = (this.buttonList.get(0)).y - 24;
this.openGLWarningX2 = this.openGLWarningX1 + k;
this.openGLWarningY2 = this.openGLWarningY1 + 24;
}
this.mc.setConnectedToRealms(false);
if (Minecraft.getMinecraft().gameSettings.getOptionOrdinalValue(GameSettings.Options.REALMS_NOTIFICATIONS) && !this.hasCheckedForRealmsNotification)
{
RealmsBridge realmsbridge = new RealmsBridge();
this.realmsNotification = realmsbridge.getNotificationScreen(this);
this.hasCheckedForRealmsNotification = true;
}
if (this.areRealmsNotificationsEnabled())
{
this.realmsNotification.setGuiSize(this.width, this.height);
this.realmsNotification.initGui();
}
modUpdateNotification = net.minecraftforge.client.gui.NotificationModUpdateScreen.init(this, modButton);
}
/**
* Adds Singleplayer and Multiplayer buttons on Main Menu for players who have bought the game.
*/
private void addSingleplayerMultiplayerButtons(int p_73969_1_, int p_73969_2_)
{
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, p_73969_1_, I18n.format("menu.singleplayer")));
this.buttonList.add(new GuiButton(2, this.width / 2 - 100, p_73969_1_ + p_73969_2_ * 1, I18n.format("menu.multiplayer")));
this.realmsButton = this.addButton(new GuiButton(14, this.width / 2 + 2, p_73969_1_ + p_73969_2_ * 2, 98, 20, I18n.format("menu.online").replace("Minecraft", "").trim()));
this.buttonList.add(modButton = new GuiButton(6, this.width / 2 - 100, p_73969_1_ + p_73969_2_ * 2, 98, 20, I18n.format("fml.menu.mods")));
}
/**
* Adds Demo buttons on Main Menu for players who are playing Demo.
*/
private void addDemoButtons(int p_73972_1_, int p_73972_2_)
{
this.buttonList.add(new GuiButton(11, this.width / 2 - 100, p_73972_1_, I18n.format("menu.playdemo")));
this.buttonResetDemo = this.addButton(new GuiButton(12, this.width / 2 - 100, p_73972_1_ + p_73972_2_ * 1, I18n.format("menu.resetdemo")));
ISaveFormat isaveformat = this.mc.getSaveLoader();
WorldInfo worldinfo = isaveformat.getWorldInfo("Demo_World");
if (worldinfo == null)
{
this.buttonResetDemo.enabled = false;
}
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.id == 0)
{
this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings));
}
if (button.id == 5)
{
this.mc.displayGuiScreen(new GuiLanguage(this, this.mc.gameSettings, this.mc.getLanguageManager()));
}
if (button.id == 1)
{
this.mc.displayGuiScreen(new GuiWorldSelection(this));
}
if (button.id == 2)
{
this.mc.displayGuiScreen(new GuiMultiplayer(this));
}
if (button.id == 14 && this.realmsButton.visible)
{
this.switchToRealms();
}
if (button.id == 4)
{
this.mc.shutdown();
}
if (button.id == 6)
{
this.mc.displayGuiScreen(new net.minecraftforge.fml.client.GuiModList(this));
}
if (button.id == 11)
{
this.mc.launchIntegratedServer("Demo_World", "Demo_World", WorldServerDemo.DEMO_WORLD_SETTINGS);
}
if (button.id == 12)
{
ISaveFormat isaveformat = this.mc.getSaveLoader();
WorldInfo worldinfo = isaveformat.getWorldInfo("Demo_World");
if (worldinfo != null)
{
this.mc.displayGuiScreen(new GuiYesNo(this, I18n.format("selectWorld.deleteQuestion"), "'" + worldinfo.getWorldName() + "' " + I18n.format("selectWorld.deleteWarning"), I18n.format("selectWorld.deleteButton"), I18n.format("gui.cancel"), 12));
}
}
}
private void switchToRealms()
{
RealmsBridge realmsbridge = new RealmsBridge();
realmsbridge.switchToRealms(this);
}
public void confirmClicked(boolean result, int id)
{
if (result && id == 12)
{
ISaveFormat isaveformat = this.mc.getSaveLoader();
isaveformat.flushCache();
isaveformat.deleteWorldDirectory("Demo_World");
this.mc.displayGuiScreen(this);
}
else if (id == 12)
{
this.mc.displayGuiScreen(this);
}
else if (id == 13)
{
if (result)
{
try
{
Class<?> oclass = Class.forName("java.awt.Desktop");
Object object = oclass.getMethod("getDesktop").invoke((Object)null);
oclass.getMethod("browse", URI.class).invoke(object, new URI(this.openGLWarningLink));
}
catch (Throwable throwable)
{
LOGGER.error("Couldn't open link", throwable);
}
}
this.mc.displayGuiScreen(this);
}
}
/**
* Draws the main menu panorama
*/
private void drawPanorama(int mouseX, int mouseY, float partialTicks)
{
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
GlStateManager.matrixMode(5889);
GlStateManager.pushMatrix();
GlStateManager.loadIdentity();
Project.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F);
GlStateManager.matrixMode(5888);
GlStateManager.pushMatrix();
GlStateManager.loadIdentity();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.enableBlend();
GlStateManager.disableAlpha();
GlStateManager.disableCull();
GlStateManager.depthMask(false);
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
int i = 8;
for (int j = 0; j < 64; ++j)
{
GlStateManager.pushMatrix();
float f = ((float)(j % 8) / 8.0F - 0.5F) / 64.0F;
float f1 = ((float)(j / 8) / 8.0F - 0.5F) / 64.0F;
float f2 = 0.0F;
GlStateManager.translate(f, f1, 0.0F);
GlStateManager.rotate(MathHelper.sin(this.panoramaTimer / 400.0F) * 25.0F + 20.0F, 1.0F, 0.0F, 0.0F);
GlStateManager.rotate(-this.panoramaTimer * 0.1F, 0.0F, 1.0F, 0.0F);
for (int k = 0; k < 6; ++k)
{
GlStateManager.pushMatrix();
if (k == 1)
{
GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
}
if (k == 2)
{
GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
}
if (k == 3)
{
GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
}
if (k == 4)
{
GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
}
if (k == 5)
{
GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F);
}
this.mc.getTextureManager().bindTexture(TITLE_PANORAMA_PATHS[k]);
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
int l = 255 / (j + 1);
float f3 = 0.0F;
bufferbuilder.pos(-1.0D, -1.0D, 1.0D).tex(0.0D, 0.0D).color(255, 255, 255, l).endVertex();
bufferbuilder.pos(1.0D, -1.0D, 1.0D).tex(1.0D, 0.0D).color(255, 255, 255, l).endVertex();
bufferbuilder.pos(1.0D, 1.0D, 1.0D).tex(1.0D, 1.0D).color(255, 255, 255, l).endVertex();
bufferbuilder.pos(-1.0D, 1.0D, 1.0D).tex(0.0D, 1.0D).color(255, 255, 255, l).endVertex();
tessellator.draw();
GlStateManager.popMatrix();
}
GlStateManager.popMatrix();
GlStateManager.colorMask(true, true, true, false);
}
bufferbuilder.setTranslation(0.0D, 0.0D, 0.0D);
GlStateManager.colorMask(true, true, true, true);
GlStateManager.matrixMode(5889);
GlStateManager.popMatrix();
GlStateManager.matrixMode(5888);
GlStateManager.popMatrix();
GlStateManager.depthMask(true);
GlStateManager.enableCull();
GlStateManager.enableDepth();
}
/**
* Rotate and blurs the skybox view in the main menu
*/
private void rotateAndBlurSkybox()
{
this.mc.getTextureManager().bindTexture(this.backgroundTexture);
GlStateManager.glTexParameteri(3553, 10241, 9729);
GlStateManager.glTexParameteri(3553, 10240, 9729);
GlStateManager.glCopyTexSubImage2D(3553, 0, 0, 0, 0, 0, 256, 256);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.colorMask(true, true, true, false);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
GlStateManager.disableAlpha();
int i = 3;
for (int j = 0; j < 3; ++j)
{
float f = 1.0F / (float)(j + 1);
int k = this.width;
int l = this.height;
float f1 = (float)(j - 1) / 256.0F;
bufferbuilder.pos((double)k, (double)l, (double)this.zLevel).tex((double)(0.0F + f1), 1.0D).color(1.0F, 1.0F, 1.0F, f).endVertex();
bufferbuilder.pos((double)k, 0.0D, (double)this.zLevel).tex((double)(1.0F + f1), 1.0D).color(1.0F, 1.0F, 1.0F, f).endVertex();
bufferbuilder.pos(0.0D, 0.0D, (double)this.zLevel).tex((double)(1.0F + f1), 0.0D).color(1.0F, 1.0F, 1.0F, f).endVertex();
bufferbuilder.pos(0.0D, (double)l, (double)this.zLevel).tex((double)(0.0F + f1), 0.0D).color(1.0F, 1.0F, 1.0F, f).endVertex();
}
tessellator.draw();
GlStateManager.enableAlpha();
GlStateManager.colorMask(true, true, true, true);
}
/**
* Renders the skybox in the main menu
*/
private void renderSkybox(int mouseX, int mouseY, float partialTicks)
{
this.mc.getFramebuffer().unbindFramebuffer();
GlStateManager.viewport(0, 0, 256, 256);
this.drawPanorama(mouseX, mouseY, partialTicks);
this.rotateAndBlurSkybox();
this.rotateAndBlurSkybox();
this.rotateAndBlurSkybox();
this.rotateAndBlurSkybox();
this.rotateAndBlurSkybox();
this.rotateAndBlurSkybox();
this.rotateAndBlurSkybox();
this.mc.getFramebuffer().bindFramebuffer(true);
GlStateManager.viewport(0, 0, this.mc.displayWidth, this.mc.displayHeight);
float f = 120.0F / (float)(this.width > this.height ? this.width : this.height);
float f1 = (float)this.height * f / 256.0F;
float f2 = (float)this.width * f / 256.0F;
int i = this.width;
int j = this.height;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
bufferbuilder.pos(0.0D, (double)j, (double)this.zLevel).tex((double)(0.5F - f1), (double)(0.5F + f2)).color(1.0F, 1.0F, 1.0F, 1.0F).endVertex();
bufferbuilder.pos((double)i, (double)j, (double)this.zLevel).tex((double)(0.5F - f1), (double)(0.5F - f2)).color(1.0F, 1.0F, 1.0F, 1.0F).endVertex();
bufferbuilder.pos((double)i, 0.0D, (double)this.zLevel).tex((double)(0.5F + f1), (double)(0.5F - f2)).color(1.0F, 1.0F, 1.0F, 1.0F).endVertex();
bufferbuilder.pos(0.0D, 0.0D, (double)this.zLevel).tex((double)(0.5F + f1), (double)(0.5F + f2)).color(1.0F, 1.0F, 1.0F, 1.0F).endVertex();
tessellator.draw();
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.panoramaTimer += partialTicks;
GlStateManager.disableAlpha();
this.renderSkybox(mouseX, mouseY, partialTicks);
GlStateManager.enableAlpha();
int i = 274;
int j = this.width / 2 - 137;
int k = 30;
this.drawGradientRect(0, 0, this.width, this.height, -2130706433, 16777215);
this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE);
this.mc.getTextureManager().bindTexture(MINECRAFT_TITLE_TEXTURES);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
if ((double)this.minceraftRoll < 1.0E-4D)
{
this.drawTexturedModalRect(j + 0, 30, 0, 0, 99, 44);
this.drawTexturedModalRect(j + 99, 30, 129, 0, 27, 44);
this.drawTexturedModalRect(j + 99 + 26, 30, 126, 0, 3, 44);
this.drawTexturedModalRect(j + 99 + 26 + 3, 30, 99, 0, 26, 44);
this.drawTexturedModalRect(j + 155, 30, 0, 45, 155, 44);
}
else
{
this.drawTexturedModalRect(j + 0, 30, 0, 0, 155, 44);
this.drawTexturedModalRect(j + 155, 30, 0, 45, 155, 44);
}
this.mc.getTextureManager().bindTexture(field_194400_H);
drawModalRectWithCustomSizedTexture(j + 88, 67, 0.0F, 0.0F, 98, 14, 128.0F, 16.0F);
this.splashText = net.minecraftforge.client.ForgeHooksClient.renderMainMenu(this, this.fontRenderer, this.width, this.height, this.splashText);
GlStateManager.pushMatrix();
GlStateManager.translate((float)(this.width / 2 + 90), 70.0F, 0.0F);
GlStateManager.rotate(-20.0F, 0.0F, 0.0F, 1.0F);
float f = 1.8F - MathHelper.abs(MathHelper.sin((float)(Minecraft.getSystemTime() % 1000L) / 1000.0F * ((float)Math.PI * 2F)) * 0.1F);
f = f * 100.0F / (float)(this.fontRenderer.getStringWidth(this.splashText) + 32);
GlStateManager.scale(f, f, f);
this.drawCenteredString(this.fontRenderer, this.splashText, 0, -8, -256);
GlStateManager.popMatrix();
String s = "Minecraft 1.12.2";
if (this.mc.isDemo())
{
s = s + " Demo";
}
else
{
s = s + ("release".equalsIgnoreCase(this.mc.getVersionType()) ? "" : "/" + this.mc.getVersionType());
}
java.util.List<String> brandings = com.google.common.collect.Lists.reverse(net.minecraftforge.fml.common.FMLCommonHandler.instance().getBrandings(true));
for (int brdline = 0; brdline < brandings.size(); brdline++)
{
String brd = brandings.get(brdline);
if (!com.google.common.base.Strings.isNullOrEmpty(brd))
{
this.drawString(this.fontRenderer, brd, 2, this.height - ( 10 + brdline * (this.fontRenderer.FONT_HEIGHT + 1)), 16777215);
}
}
this.drawString(this.fontRenderer, "Copyright Mojang AB. Do not distribute!", this.widthCopyrightRest, this.height - 10, -1);
if (mouseX > this.widthCopyrightRest && mouseX < this.widthCopyrightRest + this.widthCopyright && mouseY > this.height - 10 && mouseY < this.height && Mouse.isInsideWindow())
{
drawRect(this.widthCopyrightRest, this.height - 1, this.widthCopyrightRest + this.widthCopyright, this.height, -1);
}
if (this.openGLWarning1 != null && !this.openGLWarning1.isEmpty())
{
drawRect(this.openGLWarningX1 - 2, this.openGLWarningY1 - 2, this.openGLWarningX2 + 2, this.openGLWarningY2 - 1, 1428160512);
this.drawString(this.fontRenderer, this.openGLWarning1, this.openGLWarningX1, this.openGLWarningY1, -1);
this.drawString(this.fontRenderer, this.openGLWarning2, (this.width - this.openGLWarning2Width) / 2, (this.buttonList.get(0)).y - 12, -1);
}
super.drawScreen(mouseX, mouseY, partialTicks);
if (this.areRealmsNotificationsEnabled())
{
this.realmsNotification.drawScreen(mouseX, mouseY, partialTicks);
}
modUpdateNotification.drawScreen(mouseX, mouseY, partialTicks);
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
super.mouseClicked(mouseX, mouseY, mouseButton);
synchronized (this.threadLock)
{
if (!this.openGLWarning1.isEmpty() && !StringUtils.isNullOrEmpty(this.openGLWarningLink) && mouseX >= this.openGLWarningX1 && mouseX <= this.openGLWarningX2 && mouseY >= this.openGLWarningY1 && mouseY <= this.openGLWarningY2)
{
GuiConfirmOpenLink guiconfirmopenlink = new GuiConfirmOpenLink(this, this.openGLWarningLink, 13, true);
guiconfirmopenlink.disableSecurityWarning();
this.mc.displayGuiScreen(guiconfirmopenlink);
}
}
if (this.areRealmsNotificationsEnabled())
{
this.realmsNotification.mouseClicked(mouseX, mouseY, mouseButton);
}
if (mouseX > this.widthCopyrightRest && mouseX < this.widthCopyrightRest + this.widthCopyright && mouseY > this.height - 10 && mouseY < this.height)
{
this.mc.displayGuiScreen(new GuiWinGame(false, Runnables.doNothing()));
}
}
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
if (this.realmsNotification != null)
{
this.realmsNotification.onGuiClosed();
}
}
}

View File

@@ -0,0 +1,62 @@
package net.minecraft.client.gui;
import java.io.IOException;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiMemoryErrorScreen extends GuiScreen
{
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.buttonList.clear();
this.buttonList.add(new GuiOptionButton(0, this.width / 2 - 155, this.height / 4 + 120 + 12, I18n.format("gui.toTitle")));
this.buttonList.add(new GuiOptionButton(1, this.width / 2 - 155 + 160, this.height / 4 + 120 + 12, I18n.format("menu.quit")));
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.id == 0)
{
this.mc.displayGuiScreen(new GuiMainMenu());
}
else if (button.id == 1)
{
this.mc.shutdown();
}
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, "Out of memory!", this.width / 2, this.height / 4 - 60 + 20, 16777215);
this.drawString(this.fontRenderer, "Minecraft has run out of memory.", this.width / 2 - 140, this.height / 4 - 60 + 60 + 0, 10526880);
this.drawString(this.fontRenderer, "This could be caused by a bug in the game or by the", this.width / 2 - 140, this.height / 4 - 60 + 60 + 18, 10526880);
this.drawString(this.fontRenderer, "Java Virtual Machine not being allocated enough", this.width / 2 - 140, this.height / 4 - 60 + 60 + 27, 10526880);
this.drawString(this.fontRenderer, "memory.", this.width / 2 - 140, this.height / 4 - 60 + 60 + 36, 10526880);
this.drawString(this.fontRenderer, "To prevent level corruption, the current game has quit.", this.width / 2 - 140, this.height / 4 - 60 + 60 + 54, 10526880);
this.drawString(this.fontRenderer, "We've tried to free up enough memory to let you go back to", this.width / 2 - 140, this.height / 4 - 60 + 60 + 63, 10526880);
this.drawString(this.fontRenderer, "the main menu and back to playing, but this may not have worked.", this.width / 2 - 140, this.height / 4 - 60 + 60 + 72, 10526880);
this.drawString(this.fontRenderer, "Please restart the game if you see this message again.", this.width / 2 - 140, this.height / 4 - 60 + 60 + 81, 10526880);
super.drawScreen(mouseX, mouseY, partialTicks);
}
}

View File

@@ -0,0 +1,276 @@
package net.minecraft.client.gui;
import io.netty.buffer.Unpooled;
import java.io.IOException;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.IMerchant;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ContainerMerchant;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.client.CPacketCustomPayload;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.village.MerchantRecipe;
import net.minecraft.village.MerchantRecipeList;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@SideOnly(Side.CLIENT)
public class GuiMerchant extends GuiContainer
{
private static final Logger LOGGER = LogManager.getLogger();
/** The GUI texture for the villager merchant GUI. */
private static final ResourceLocation MERCHANT_GUI_TEXTURE = new ResourceLocation("textures/gui/container/villager.png");
/** The current IMerchant instance in use for this specific merchant. */
private final IMerchant merchant;
/** The button which proceeds to the next available merchant recipe. */
private GuiMerchant.MerchantButton nextButton;
/** Returns to the previous Merchant recipe if one is applicable. */
private GuiMerchant.MerchantButton previousButton;
/** The integer value corresponding to the currently selected merchant recipe. */
private int selectedMerchantRecipe;
/** The chat component utilized by this GuiMerchant instance. */
private final ITextComponent chatComponent;
public GuiMerchant(InventoryPlayer p_i45500_1_, IMerchant p_i45500_2_, World worldIn)
{
super(new ContainerMerchant(p_i45500_1_, p_i45500_2_, worldIn));
this.merchant = p_i45500_2_;
this.chatComponent = p_i45500_2_.getDisplayName();
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
super.initGui();
int i = (this.width - this.xSize) / 2;
int j = (this.height - this.ySize) / 2;
this.nextButton = (GuiMerchant.MerchantButton)this.addButton(new GuiMerchant.MerchantButton(1, i + 120 + 27, j + 24 - 1, true));
this.previousButton = (GuiMerchant.MerchantButton)this.addButton(new GuiMerchant.MerchantButton(2, i + 36 - 19, j + 24 - 1, false));
this.nextButton.enabled = false;
this.previousButton.enabled = false;
}
/**
* Draw the foreground layer for the GuiContainer (everything in front of the items)
*/
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
String s = this.chatComponent.getUnformattedText();
this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 6, 4210752);
this.fontRenderer.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
super.updateScreen();
MerchantRecipeList merchantrecipelist = this.merchant.getRecipes(this.mc.player);
if (merchantrecipelist != null)
{
this.nextButton.enabled = this.selectedMerchantRecipe < merchantrecipelist.size() - 1;
this.previousButton.enabled = this.selectedMerchantRecipe > 0;
}
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
boolean flag = false;
if (button == this.nextButton)
{
++this.selectedMerchantRecipe;
MerchantRecipeList merchantrecipelist = this.merchant.getRecipes(this.mc.player);
if (merchantrecipelist != null && this.selectedMerchantRecipe >= merchantrecipelist.size())
{
this.selectedMerchantRecipe = merchantrecipelist.size() - 1;
}
flag = true;
}
else if (button == this.previousButton)
{
--this.selectedMerchantRecipe;
if (this.selectedMerchantRecipe < 0)
{
this.selectedMerchantRecipe = 0;
}
flag = true;
}
if (flag)
{
((ContainerMerchant)this.inventorySlots).setCurrentRecipeIndex(this.selectedMerchantRecipe);
PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
packetbuffer.writeInt(this.selectedMerchantRecipe);
this.mc.getConnection().sendPacket(new CPacketCustomPayload("MC|TrSel", packetbuffer));
}
}
/**
* Draws the background layer of this container (behind the items).
*/
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
{
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(MERCHANT_GUI_TEXTURE);
int i = (this.width - this.xSize) / 2;
int j = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
MerchantRecipeList merchantrecipelist = this.merchant.getRecipes(this.mc.player);
if (merchantrecipelist != null && !merchantrecipelist.isEmpty())
{
int k = this.selectedMerchantRecipe;
if (k < 0 || k >= merchantrecipelist.size())
{
return;
}
MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(k);
if (merchantrecipe.isRecipeDisabled())
{
this.mc.getTextureManager().bindTexture(MERCHANT_GUI_TEXTURE);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.disableLighting();
this.drawTexturedModalRect(this.guiLeft + 83, this.guiTop + 21, 212, 0, 28, 21);
this.drawTexturedModalRect(this.guiLeft + 83, this.guiTop + 51, 212, 0, 28, 21);
}
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
super.drawScreen(mouseX, mouseY, partialTicks);
MerchantRecipeList merchantrecipelist = this.merchant.getRecipes(this.mc.player);
if (merchantrecipelist != null && !merchantrecipelist.isEmpty())
{
int i = (this.width - this.xSize) / 2;
int j = (this.height - this.ySize) / 2;
int k = this.selectedMerchantRecipe;
MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(k);
ItemStack itemstack = merchantrecipe.getItemToBuy();
ItemStack itemstack1 = merchantrecipe.getSecondItemToBuy();
ItemStack itemstack2 = merchantrecipe.getItemToSell();
GlStateManager.pushMatrix();
RenderHelper.enableGUIStandardItemLighting();
GlStateManager.disableLighting();
GlStateManager.enableRescaleNormal();
GlStateManager.enableColorMaterial();
GlStateManager.enableLighting();
this.itemRender.zLevel = 100.0F;
this.itemRender.renderItemAndEffectIntoGUI(itemstack, i + 36, j + 24);
this.itemRender.renderItemOverlays(this.fontRenderer, itemstack, i + 36, j + 24);
if (!itemstack1.isEmpty())
{
this.itemRender.renderItemAndEffectIntoGUI(itemstack1, i + 62, j + 24);
this.itemRender.renderItemOverlays(this.fontRenderer, itemstack1, i + 62, j + 24);
}
this.itemRender.renderItemAndEffectIntoGUI(itemstack2, i + 120, j + 24);
this.itemRender.renderItemOverlays(this.fontRenderer, itemstack2, i + 120, j + 24);
this.itemRender.zLevel = 0.0F;
GlStateManager.disableLighting();
if (this.isPointInRegion(36, 24, 16, 16, mouseX, mouseY) && !itemstack.isEmpty())
{
this.renderToolTip(itemstack, mouseX, mouseY);
}
else if (!itemstack1.isEmpty() && this.isPointInRegion(62, 24, 16, 16, mouseX, mouseY) && !itemstack1.isEmpty())
{
this.renderToolTip(itemstack1, mouseX, mouseY);
}
else if (!itemstack2.isEmpty() && this.isPointInRegion(120, 24, 16, 16, mouseX, mouseY) && !itemstack2.isEmpty())
{
this.renderToolTip(itemstack2, mouseX, mouseY);
}
else if (merchantrecipe.isRecipeDisabled() && (this.isPointInRegion(83, 21, 28, 21, mouseX, mouseY) || this.isPointInRegion(83, 51, 28, 21, mouseX, mouseY)))
{
this.drawHoveringText(I18n.format("merchant.deprecated"), mouseX, mouseY);
}
GlStateManager.popMatrix();
GlStateManager.enableLighting();
GlStateManager.enableDepth();
RenderHelper.enableStandardItemLighting();
}
this.renderHoveredToolTip(mouseX, mouseY);
}
public IMerchant getMerchant()
{
return this.merchant;
}
@SideOnly(Side.CLIENT)
static class MerchantButton extends GuiButton
{
private final boolean forward;
public MerchantButton(int buttonID, int x, int y, boolean p_i1095_4_)
{
super(buttonID, x, y, 12, 19, "");
this.forward = p_i1095_4_;
}
/**
* Draws this button to the screen.
*/
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks)
{
if (this.visible)
{
mc.getTextureManager().bindTexture(GuiMerchant.MERCHANT_GUI_TEXTURE);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
boolean flag = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
int i = 0;
int j = 176;
if (!this.enabled)
{
j += this.width * 2;
}
else if (flag)
{
j += this.width;
}
if (!this.forward)
{
i += this.height;
}
this.drawTexturedModalRect(this.x, this.y, j, i, this.width, this.height);
}
}
}
}

View File

@@ -0,0 +1,494 @@
package net.minecraft.client.gui;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.List;
import net.minecraft.client.multiplayer.GuiConnecting;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.multiplayer.ServerList;
import net.minecraft.client.network.LanServerDetector;
import net.minecraft.client.network.LanServerInfo;
import net.minecraft.client.network.ServerPinger;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.input.Keyboard;
@SideOnly(Side.CLIENT)
public class GuiMultiplayer extends GuiScreen
{
private static final Logger LOGGER = LogManager.getLogger();
private final ServerPinger oldServerPinger = new ServerPinger();
private final GuiScreen parentScreen;
private ServerSelectionList serverListSelector;
private ServerList savedServerList;
private GuiButton btnEditServer;
private GuiButton btnSelectServer;
private GuiButton btnDeleteServer;
private boolean deletingServer;
private boolean addingServer;
private boolean editingServer;
private boolean directConnect;
/** The text to be displayed when the player's cursor hovers over a server listing. */
private String hoveringText;
private ServerData selectedServer;
private LanServerDetector.LanServerList lanServerList;
private LanServerDetector.ThreadLanServerFind lanServerDetector;
private boolean initialized;
public GuiMultiplayer(GuiScreen parentScreen)
{
this.parentScreen = parentScreen;
net.minecraftforge.fml.client.FMLClientHandler.instance().setupServerList();
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
Keyboard.enableRepeatEvents(true);
this.buttonList.clear();
if (this.initialized)
{
this.serverListSelector.setDimensions(this.width, this.height, 32, this.height - 64);
}
else
{
this.initialized = true;
this.savedServerList = new ServerList(this.mc);
this.savedServerList.loadServerList();
this.lanServerList = new LanServerDetector.LanServerList();
try
{
this.lanServerDetector = new LanServerDetector.ThreadLanServerFind(this.lanServerList);
this.lanServerDetector.start();
}
catch (Exception exception)
{
LOGGER.warn("Unable to start LAN server detection: {}", (Object)exception.getMessage());
}
this.serverListSelector = new ServerSelectionList(this, this.mc, this.width, this.height, 32, this.height - 64, 36);
this.serverListSelector.updateOnlineServers(this.savedServerList);
}
this.createButtons();
}
/**
* Handles mouse input.
*/
public void handleMouseInput() throws IOException
{
super.handleMouseInput();
this.serverListSelector.handleMouseInput();
}
public void createButtons()
{
this.btnEditServer = this.addButton(new GuiButton(7, this.width / 2 - 154, this.height - 28, 70, 20, I18n.format("selectServer.edit")));
this.btnDeleteServer = this.addButton(new GuiButton(2, this.width / 2 - 74, this.height - 28, 70, 20, I18n.format("selectServer.delete")));
this.btnSelectServer = this.addButton(new GuiButton(1, this.width / 2 - 154, this.height - 52, 100, 20, I18n.format("selectServer.select")));
this.buttonList.add(new GuiButton(4, this.width / 2 - 50, this.height - 52, 100, 20, I18n.format("selectServer.direct")));
this.buttonList.add(new GuiButton(3, this.width / 2 + 4 + 50, this.height - 52, 100, 20, I18n.format("selectServer.add")));
this.buttonList.add(new GuiButton(8, this.width / 2 + 4, this.height - 28, 70, 20, I18n.format("selectServer.refresh")));
this.buttonList.add(new GuiButton(0, this.width / 2 + 4 + 76, this.height - 28, 75, 20, I18n.format("gui.cancel")));
this.selectServer(this.serverListSelector.getSelected());
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
super.updateScreen();
if (this.lanServerList.getWasUpdated())
{
List<LanServerInfo> list = this.lanServerList.getLanServers();
this.lanServerList.setWasNotUpdated();
this.serverListSelector.updateNetworkServers(list);
}
this.oldServerPinger.pingPendingNetworks();
}
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
Keyboard.enableRepeatEvents(false);
if (this.lanServerDetector != null)
{
this.lanServerDetector.interrupt();
this.lanServerDetector = null;
}
this.oldServerPinger.clearPendingNetworks();
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.enabled)
{
GuiListExtended.IGuiListEntry guilistextended$iguilistentry = this.serverListSelector.getSelected() < 0 ? null : this.serverListSelector.getListEntry(this.serverListSelector.getSelected());
if (button.id == 2 && guilistextended$iguilistentry instanceof ServerListEntryNormal)
{
String s4 = ((ServerListEntryNormal)guilistextended$iguilistentry).getServerData().serverName;
if (s4 != null)
{
this.deletingServer = true;
String s = I18n.format("selectServer.deleteQuestion");
String s1 = "'" + s4 + "' " + I18n.format("selectServer.deleteWarning");
String s2 = I18n.format("selectServer.deleteButton");
String s3 = I18n.format("gui.cancel");
GuiYesNo guiyesno = new GuiYesNo(this, s, s1, s2, s3, this.serverListSelector.getSelected());
this.mc.displayGuiScreen(guiyesno);
}
}
else if (button.id == 1)
{
this.connectToSelected();
}
else if (button.id == 4)
{
this.directConnect = true;
this.selectedServer = new ServerData(I18n.format("selectServer.defaultName"), "", false);
this.mc.displayGuiScreen(new GuiScreenServerList(this, this.selectedServer));
}
else if (button.id == 3)
{
this.addingServer = true;
this.selectedServer = new ServerData(I18n.format("selectServer.defaultName"), "", false);
this.mc.displayGuiScreen(new GuiScreenAddServer(this, this.selectedServer));
}
else if (button.id == 7 && guilistextended$iguilistentry instanceof ServerListEntryNormal)
{
this.editingServer = true;
ServerData serverdata = ((ServerListEntryNormal)guilistextended$iguilistentry).getServerData();
this.selectedServer = new ServerData(serverdata.serverName, serverdata.serverIP, false);
this.selectedServer.copyFrom(serverdata);
this.mc.displayGuiScreen(new GuiScreenAddServer(this, this.selectedServer));
}
else if (button.id == 0)
{
this.mc.displayGuiScreen(this.parentScreen);
}
else if (button.id == 8)
{
this.refreshServerList();
}
}
}
private void refreshServerList()
{
this.mc.displayGuiScreen(new GuiMultiplayer(this.parentScreen));
}
public void confirmClicked(boolean result, int id)
{
GuiListExtended.IGuiListEntry guilistextended$iguilistentry = this.serverListSelector.getSelected() < 0 ? null : this.serverListSelector.getListEntry(this.serverListSelector.getSelected());
if (this.deletingServer)
{
this.deletingServer = false;
if (result && guilistextended$iguilistentry instanceof ServerListEntryNormal)
{
this.savedServerList.removeServerData(this.serverListSelector.getSelected());
this.savedServerList.saveServerList();
this.serverListSelector.setSelectedSlotIndex(-1);
this.serverListSelector.updateOnlineServers(this.savedServerList);
}
this.mc.displayGuiScreen(this);
}
else if (this.directConnect)
{
this.directConnect = false;
if (result)
{
this.connectToServer(this.selectedServer);
}
else
{
this.mc.displayGuiScreen(this);
}
}
else if (this.addingServer)
{
this.addingServer = false;
if (result)
{
this.savedServerList.addServerData(this.selectedServer);
this.savedServerList.saveServerList();
this.serverListSelector.setSelectedSlotIndex(-1);
this.serverListSelector.updateOnlineServers(this.savedServerList);
}
this.mc.displayGuiScreen(this);
}
else if (this.editingServer)
{
this.editingServer = false;
if (result && guilistextended$iguilistentry instanceof ServerListEntryNormal)
{
ServerData serverdata = ((ServerListEntryNormal)guilistextended$iguilistentry).getServerData();
serverdata.serverName = this.selectedServer.serverName;
serverdata.serverIP = this.selectedServer.serverIP;
serverdata.copyFrom(this.selectedServer);
this.savedServerList.saveServerList();
this.serverListSelector.updateOnlineServers(this.savedServerList);
}
this.mc.displayGuiScreen(this);
}
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
int i = this.serverListSelector.getSelected();
GuiListExtended.IGuiListEntry guilistextended$iguilistentry = i < 0 ? null : this.serverListSelector.getListEntry(i);
if (keyCode == 63)
{
this.refreshServerList();
}
else
{
if (i >= 0)
{
if (keyCode == 200)
{
if (isShiftKeyDown())
{
if (i > 0 && guilistextended$iguilistentry instanceof ServerListEntryNormal)
{
this.savedServerList.swapServers(i, i - 1);
this.selectServer(this.serverListSelector.getSelected() - 1);
this.serverListSelector.scrollBy(-this.serverListSelector.getSlotHeight());
this.serverListSelector.updateOnlineServers(this.savedServerList);
}
}
else if (i > 0)
{
this.selectServer(this.serverListSelector.getSelected() - 1);
this.serverListSelector.scrollBy(-this.serverListSelector.getSlotHeight());
if (this.serverListSelector.getListEntry(this.serverListSelector.getSelected()) instanceof ServerListEntryLanScan)
{
if (this.serverListSelector.getSelected() > 0)
{
this.selectServer(this.serverListSelector.getSize() - 1);
this.serverListSelector.scrollBy(-this.serverListSelector.getSlotHeight());
}
else
{
this.selectServer(-1);
}
}
}
else
{
this.selectServer(-1);
}
}
else if (keyCode == 208)
{
if (isShiftKeyDown())
{
if (i < this.savedServerList.countServers() - 1)
{
this.savedServerList.swapServers(i, i + 1);
this.selectServer(i + 1);
this.serverListSelector.scrollBy(this.serverListSelector.getSlotHeight());
this.serverListSelector.updateOnlineServers(this.savedServerList);
}
}
else if (i < this.serverListSelector.getSize())
{
this.selectServer(this.serverListSelector.getSelected() + 1);
this.serverListSelector.scrollBy(this.serverListSelector.getSlotHeight());
if (this.serverListSelector.getListEntry(this.serverListSelector.getSelected()) instanceof ServerListEntryLanScan)
{
if (this.serverListSelector.getSelected() < this.serverListSelector.getSize() - 1)
{
this.selectServer(this.serverListSelector.getSize() + 1);
this.serverListSelector.scrollBy(this.serverListSelector.getSlotHeight());
}
else
{
this.selectServer(-1);
}
}
}
else
{
this.selectServer(-1);
}
}
else if (keyCode != 28 && keyCode != 156)
{
super.keyTyped(typedChar, keyCode);
}
else
{
this.actionPerformed(this.buttonList.get(2));
}
}
else
{
super.keyTyped(typedChar, keyCode);
}
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.hoveringText = null;
this.drawDefaultBackground();
this.serverListSelector.drawScreen(mouseX, mouseY, partialTicks);
this.drawCenteredString(this.fontRenderer, I18n.format("multiplayer.title"), this.width / 2, 20, 16777215);
super.drawScreen(mouseX, mouseY, partialTicks);
if (this.hoveringText != null)
{
this.drawHoveringText(Lists.newArrayList(Splitter.on("\n").split(this.hoveringText)), mouseX, mouseY);
}
}
public void connectToSelected()
{
GuiListExtended.IGuiListEntry guilistextended$iguilistentry = this.serverListSelector.getSelected() < 0 ? null : this.serverListSelector.getListEntry(this.serverListSelector.getSelected());
if (guilistextended$iguilistentry instanceof ServerListEntryNormal)
{
this.connectToServer(((ServerListEntryNormal)guilistextended$iguilistentry).getServerData());
}
else if (guilistextended$iguilistentry instanceof ServerListEntryLanDetected)
{
LanServerInfo lanserverinfo = ((ServerListEntryLanDetected)guilistextended$iguilistentry).getServerData();
this.connectToServer(new ServerData(lanserverinfo.getServerMotd(), lanserverinfo.getServerIpPort(), true));
}
}
private void connectToServer(ServerData server)
{
net.minecraftforge.fml.client.FMLClientHandler.instance().connectToServer(this, server);
}
public void selectServer(int index)
{
this.serverListSelector.setSelectedSlotIndex(index);
GuiListExtended.IGuiListEntry guilistextended$iguilistentry = index < 0 ? null : this.serverListSelector.getListEntry(index);
this.btnSelectServer.enabled = false;
this.btnEditServer.enabled = false;
this.btnDeleteServer.enabled = false;
if (guilistextended$iguilistentry != null && !(guilistextended$iguilistentry instanceof ServerListEntryLanScan))
{
this.btnSelectServer.enabled = true;
if (guilistextended$iguilistentry instanceof ServerListEntryNormal)
{
this.btnEditServer.enabled = true;
this.btnDeleteServer.enabled = true;
}
}
}
public ServerPinger getOldServerPinger()
{
return this.oldServerPinger;
}
public void setHoveringText(String p_146793_1_)
{
this.hoveringText = p_146793_1_;
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
super.mouseClicked(mouseX, mouseY, mouseButton);
this.serverListSelector.mouseClicked(mouseX, mouseY, mouseButton);
}
/**
* Called when a mouse button is released.
*/
protected void mouseReleased(int mouseX, int mouseY, int state)
{
super.mouseReleased(mouseX, mouseY, state);
this.serverListSelector.mouseReleased(mouseX, mouseY, state);
}
public ServerList getServerList()
{
return this.savedServerList;
}
public boolean canMoveUp(ServerListEntryNormal p_175392_1_, int p_175392_2_)
{
return p_175392_2_ > 0;
}
public boolean canMoveDown(ServerListEntryNormal p_175394_1_, int p_175394_2_)
{
return p_175394_2_ < this.savedServerList.countServers() - 1;
}
public void moveServerUp(ServerListEntryNormal p_175391_1_, int p_175391_2_, boolean p_175391_3_)
{
int i = p_175391_3_ ? 0 : p_175391_2_ - 1;
this.savedServerList.swapServers(p_175391_2_, i);
if (this.serverListSelector.getSelected() == p_175391_2_)
{
this.selectServer(i);
}
this.serverListSelector.updateOnlineServers(this.savedServerList);
}
public void moveServerDown(ServerListEntryNormal p_175393_1_, int p_175393_2_, boolean p_175393_3_)
{
int i = p_175393_3_ ? this.savedServerList.countServers() - 1 : p_175393_2_ + 1;
this.savedServerList.swapServers(p_175393_2_, i);
if (this.serverListSelector.getSelected() == p_175393_2_)
{
this.selectServer(i);
}
this.serverListSelector.updateOnlineServers(this.savedServerList);
}
}

View File

@@ -0,0 +1,386 @@
package net.minecraft.client.gui;
import com.google.common.collect.Lists;
import java.util.Iterator;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@SideOnly(Side.CLIENT)
public class GuiNewChat extends Gui
{
private static final Logger LOGGER = LogManager.getLogger();
private final Minecraft mc;
/** A list of messages previously sent through the chat GUI */
private final List<String> sentMessages = Lists.<String>newArrayList();
/** Chat lines to be displayed in the chat box */
private final List<ChatLine> chatLines = Lists.<ChatLine>newArrayList();
/** List of the ChatLines currently drawn */
private final List<ChatLine> drawnChatLines = Lists.<ChatLine>newArrayList();
private int scrollPos;
private boolean isScrolled;
public GuiNewChat(Minecraft mcIn)
{
this.mc = mcIn;
}
public void drawChat(int updateCounter)
{
if (this.mc.gameSettings.chatVisibility != EntityPlayer.EnumChatVisibility.HIDDEN)
{
int i = this.getLineCount();
int j = this.drawnChatLines.size();
float f = this.mc.gameSettings.chatOpacity * 0.9F + 0.1F;
if (j > 0)
{
boolean flag = false;
if (this.getChatOpen())
{
flag = true;
}
float f1 = this.getChatScale();
int k = MathHelper.ceil((float)this.getChatWidth() / f1);
GlStateManager.pushMatrix();
GlStateManager.translate(2.0F, 8.0F, 0.0F);
GlStateManager.scale(f1, f1, 1.0F);
int l = 0;
for (int i1 = 0; i1 + this.scrollPos < this.drawnChatLines.size() && i1 < i; ++i1)
{
ChatLine chatline = this.drawnChatLines.get(i1 + this.scrollPos);
if (chatline != null)
{
int j1 = updateCounter - chatline.getUpdatedCounter();
if (j1 < 200 || flag)
{
double d0 = (double)j1 / 200.0D;
d0 = 1.0D - d0;
d0 = d0 * 10.0D;
d0 = MathHelper.clamp(d0, 0.0D, 1.0D);
d0 = d0 * d0;
int l1 = (int)(255.0D * d0);
if (flag)
{
l1 = 255;
}
l1 = (int)((float)l1 * f);
++l;
if (l1 > 3)
{
int i2 = 0;
int j2 = -i1 * 9;
drawRect(-2, j2 - 9, 0 + k + 4, j2, l1 / 2 << 24);
String s = chatline.getChatComponent().getFormattedText();
GlStateManager.enableBlend();
this.mc.fontRenderer.drawStringWithShadow(s, 0.0F, (float)(j2 - 8), 16777215 + (l1 << 24));
GlStateManager.disableAlpha();
GlStateManager.disableBlend();
}
}
}
}
if (flag)
{
int k2 = this.mc.fontRenderer.FONT_HEIGHT;
GlStateManager.translate(-3.0F, 0.0F, 0.0F);
int l2 = j * k2 + j;
int i3 = l * k2 + l;
int j3 = this.scrollPos * i3 / j;
int k1 = i3 * i3 / l2;
if (l2 != i3)
{
int k3 = j3 > 0 ? 170 : 96;
int l3 = this.isScrolled ? 13382451 : 3355562;
drawRect(0, -j3, 2, -j3 - k1, l3 + (k3 << 24));
drawRect(2, -j3, 1, -j3 - k1, 13421772 + (k3 << 24));
}
}
GlStateManager.popMatrix();
}
}
}
/**
* Clears the chat.
*/
public void clearChatMessages(boolean p_146231_1_)
{
this.drawnChatLines.clear();
this.chatLines.clear();
if (p_146231_1_)
{
this.sentMessages.clear();
}
}
public void printChatMessage(ITextComponent chatComponent)
{
this.printChatMessageWithOptionalDeletion(chatComponent, 0);
}
/**
* prints the ChatComponent to Chat. If the ID is not 0, deletes an existing Chat Line of that ID from the GUI
*/
public void printChatMessageWithOptionalDeletion(ITextComponent chatComponent, int chatLineId)
{
this.setChatLine(chatComponent, chatLineId, this.mc.ingameGUI.getUpdateCounter(), false);
LOGGER.info("[CHAT] {}", (Object)chatComponent.getUnformattedText().replaceAll("\r", "\\\\r").replaceAll("\n", "\\\\n"));
}
private void setChatLine(ITextComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly)
{
if (chatLineId != 0)
{
this.deleteChatLine(chatLineId);
}
int i = MathHelper.floor((float)this.getChatWidth() / this.getChatScale());
List<ITextComponent> list = GuiUtilRenderComponents.splitText(chatComponent, i, this.mc.fontRenderer, false, false);
boolean flag = this.getChatOpen();
for (ITextComponent itextcomponent : list)
{
if (flag && this.scrollPos > 0)
{
this.isScrolled = true;
this.scroll(1);
}
this.drawnChatLines.add(0, new ChatLine(updateCounter, itextcomponent, chatLineId));
}
while (this.drawnChatLines.size() > 100)
{
this.drawnChatLines.remove(this.drawnChatLines.size() - 1);
}
if (!displayOnly)
{
this.chatLines.add(0, new ChatLine(updateCounter, chatComponent, chatLineId));
while (this.chatLines.size() > 100)
{
this.chatLines.remove(this.chatLines.size() - 1);
}
}
}
public void refreshChat()
{
this.drawnChatLines.clear();
this.resetScroll();
for (int i = this.chatLines.size() - 1; i >= 0; --i)
{
ChatLine chatline = this.chatLines.get(i);
this.setChatLine(chatline.getChatComponent(), chatline.getChatLineID(), chatline.getUpdatedCounter(), true);
}
}
/**
* Gets the list of messages previously sent through the chat GUI
*/
public List<String> getSentMessages()
{
return this.sentMessages;
}
/**
* Adds this string to the list of sent messages, for recall using the up/down arrow keys
*/
public void addToSentMessages(String message)
{
if (this.sentMessages.isEmpty() || !((String)this.sentMessages.get(this.sentMessages.size() - 1)).equals(message))
{
this.sentMessages.add(message);
}
}
/**
* Resets the chat scroll (executed when the GUI is closed, among others)
*/
public void resetScroll()
{
this.scrollPos = 0;
this.isScrolled = false;
}
/**
* Scrolls the chat by the given number of lines.
*/
public void scroll(int amount)
{
this.scrollPos += amount;
int i = this.drawnChatLines.size();
if (this.scrollPos > i - this.getLineCount())
{
this.scrollPos = i - this.getLineCount();
}
if (this.scrollPos <= 0)
{
this.scrollPos = 0;
this.isScrolled = false;
}
}
/**
* Gets the chat component under the mouse
*/
@Nullable
public ITextComponent getChatComponent(int mouseX, int mouseY)
{
if (!this.getChatOpen())
{
return null;
}
else
{
ScaledResolution scaledresolution = new ScaledResolution(this.mc);
int i = scaledresolution.getScaleFactor();
float f = this.getChatScale();
int j = mouseX / i - 2;
int k = mouseY / i - 40;
j = MathHelper.floor((float)j / f);
k = MathHelper.floor((float)k / f);
if (j >= 0 && k >= 0)
{
int l = Math.min(this.getLineCount(), this.drawnChatLines.size());
if (j <= MathHelper.floor((float)this.getChatWidth() / this.getChatScale()) && k < this.mc.fontRenderer.FONT_HEIGHT * l + l)
{
int i1 = k / this.mc.fontRenderer.FONT_HEIGHT + this.scrollPos;
if (i1 >= 0 && i1 < this.drawnChatLines.size())
{
ChatLine chatline = this.drawnChatLines.get(i1);
int j1 = 0;
for (ITextComponent itextcomponent : chatline.getChatComponent())
{
if (itextcomponent instanceof TextComponentString)
{
j1 += this.mc.fontRenderer.getStringWidth(GuiUtilRenderComponents.removeTextColorsIfConfigured(((TextComponentString)itextcomponent).getText(), false));
if (j1 > j)
{
return itextcomponent;
}
}
}
}
return null;
}
else
{
return null;
}
}
else
{
return null;
}
}
}
/**
* Returns true if the chat GUI is open
*/
public boolean getChatOpen()
{
return this.mc.currentScreen instanceof GuiChat;
}
/**
* finds and deletes a Chat line by ID
*/
public void deleteChatLine(int id)
{
Iterator<ChatLine> iterator = this.drawnChatLines.iterator();
while (iterator.hasNext())
{
ChatLine chatline = iterator.next();
if (chatline.getChatLineID() == id)
{
iterator.remove();
}
}
iterator = this.chatLines.iterator();
while (iterator.hasNext())
{
ChatLine chatline1 = iterator.next();
if (chatline1.getChatLineID() == id)
{
iterator.remove();
break;
}
}
}
public int getChatWidth()
{
return calculateChatboxWidth(this.mc.gameSettings.chatWidth);
}
public int getChatHeight()
{
return calculateChatboxHeight(this.getChatOpen() ? this.mc.gameSettings.chatHeightFocused : this.mc.gameSettings.chatHeightUnfocused);
}
/**
* Returns the chatscale from mc.gameSettings.chatScale
*/
public float getChatScale()
{
return this.mc.gameSettings.chatScale;
}
public static int calculateChatboxWidth(float scale)
{
int i = 320;
int j = 40;
return MathHelper.floor(scale * 280.0F + 40.0F);
}
public static int calculateChatboxHeight(float scale)
{
int i = 180;
int j = 20;
return MathHelper.floor(scale * 160.0F + 20.0F);
}
public int getLineCount()
{
return this.getChatHeight() / 9;
}
}

View File

@@ -0,0 +1,27 @@
package net.minecraft.client.gui;
import net.minecraft.client.settings.GameSettings;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiOptionButton extends GuiButton
{
private final GameSettings.Options enumOptions;
public GuiOptionButton(int p_i45011_1_, int p_i45011_2_, int p_i45011_3_, String p_i45011_4_)
{
this(p_i45011_1_, p_i45011_2_, p_i45011_3_, (GameSettings.Options)null, p_i45011_4_);
}
public GuiOptionButton(int p_i45013_1_, int p_i45013_2_, int p_i45013_3_, GameSettings.Options p_i45013_4_, String p_i45013_5_)
{
super(p_i45013_1_, p_i45013_2_, p_i45013_3_, 150, 20, p_i45013_5_);
this.enumOptions = p_i45013_4_;
}
public GameSettings.Options getOption()
{
return this.enumOptions;
}
}

View File

@@ -0,0 +1,97 @@
package net.minecraft.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiOptionSlider extends GuiButton
{
private float sliderValue;
public boolean dragging;
private final GameSettings.Options options;
private final float minValue;
private final float maxValue;
public GuiOptionSlider(int buttonId, int x, int y, GameSettings.Options optionIn)
{
this(buttonId, x, y, optionIn, 0.0F, 1.0F);
}
public GuiOptionSlider(int buttonId, int x, int y, GameSettings.Options optionIn, float minValueIn, float maxValue)
{
super(buttonId, x, y, 150, 20, "");
this.sliderValue = 1.0F;
this.options = optionIn;
this.minValue = minValueIn;
this.maxValue = maxValue;
Minecraft minecraft = Minecraft.getMinecraft();
this.sliderValue = optionIn.normalizeValue(minecraft.gameSettings.getOptionFloatValue(optionIn));
this.displayString = minecraft.gameSettings.getKeyBinding(optionIn);
}
/**
* Returns 0 if the button is disabled, 1 if the mouse is NOT hovering over this button and 2 if it IS hovering over
* this button.
*/
protected int getHoverState(boolean mouseOver)
{
return 0;
}
/**
* Fired when the mouse button is dragged. Equivalent of MouseListener.mouseDragged(MouseEvent e).
*/
protected void mouseDragged(Minecraft mc, int mouseX, int mouseY)
{
if (this.visible)
{
if (this.dragging)
{
this.sliderValue = (float)(mouseX - (this.x + 4)) / (float)(this.width - 8);
this.sliderValue = MathHelper.clamp(this.sliderValue, 0.0F, 1.0F);
float f = this.options.denormalizeValue(this.sliderValue);
mc.gameSettings.setOptionFloatValue(this.options, f);
this.sliderValue = this.options.normalizeValue(f);
this.displayString = mc.gameSettings.getKeyBinding(this.options);
}
mc.getTextureManager().bindTexture(BUTTON_TEXTURES);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(this.x + (int)(this.sliderValue * (float)(this.width - 8)), this.y, 0, 66, 4, 20);
this.drawTexturedModalRect(this.x + (int)(this.sliderValue * (float)(this.width - 8)) + 4, this.y, 196, 66, 4, 20);
}
}
/**
* Returns true if the mouse has been pressed on this control. Equivalent of MouseListener.mousePressed(MouseEvent
* e).
*/
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY)
{
if (super.mousePressed(mc, mouseX, mouseY))
{
this.sliderValue = (float)(mouseX - (this.x + 4)) / (float)(this.width - 8);
this.sliderValue = MathHelper.clamp(this.sliderValue, 0.0F, 1.0F);
mc.gameSettings.setOptionFloatValue(this.options, this.options.denormalizeValue(this.sliderValue));
this.displayString = mc.gameSettings.getKeyBinding(this.options);
this.dragging = true;
return true;
}
else
{
return false;
}
}
/**
* Fired when the mouse button is released. Equivalent of MouseListener.mouseReleased(MouseEvent e).
*/
public void mouseReleased(int mouseX, int mouseY)
{
this.dragging = false;
}
}

View File

@@ -0,0 +1,216 @@
package net.minecraft.client.gui;
import java.io.IOException;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.EnumDifficulty;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiOptions extends GuiScreen
{
private static final GameSettings.Options[] SCREEN_OPTIONS = new GameSettings.Options[] {GameSettings.Options.FOV};
private final GuiScreen lastScreen;
/** Reference to the GameSettings object. */
private final GameSettings settings;
private GuiButton difficultyButton;
private GuiLockIconButton lockButton;
protected String title = "Options";
public GuiOptions(GuiScreen p_i1046_1_, GameSettings p_i1046_2_)
{
this.lastScreen = p_i1046_1_;
this.settings = p_i1046_2_;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.title = I18n.format("options.title");
int i = 0;
for (GameSettings.Options gamesettings$options : SCREEN_OPTIONS)
{
if (gamesettings$options.isFloat())
{
this.buttonList.add(new GuiOptionSlider(gamesettings$options.getOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 - 12 + 24 * (i >> 1), gamesettings$options));
}
else
{
GuiOptionButton guioptionbutton = new GuiOptionButton(gamesettings$options.getOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 - 12 + 24 * (i >> 1), gamesettings$options, this.settings.getKeyBinding(gamesettings$options));
this.buttonList.add(guioptionbutton);
}
++i;
}
if (this.mc.world != null)
{
EnumDifficulty enumdifficulty = this.mc.world.getDifficulty();
this.difficultyButton = new GuiButton(108, this.width / 2 - 155 + i % 2 * 160, this.height / 6 - 12 + 24 * (i >> 1), 150, 20, this.getDifficultyText(enumdifficulty));
this.buttonList.add(this.difficultyButton);
if (this.mc.isSingleplayer() && !this.mc.world.getWorldInfo().isHardcoreModeEnabled())
{
this.difficultyButton.setWidth(this.difficultyButton.getButtonWidth() - 20);
this.lockButton = new GuiLockIconButton(109, this.difficultyButton.x + this.difficultyButton.getButtonWidth(), this.difficultyButton.y);
this.buttonList.add(this.lockButton);
this.lockButton.setLocked(this.mc.world.getWorldInfo().isDifficultyLocked());
this.lockButton.enabled = !this.lockButton.isLocked();
this.difficultyButton.enabled = !this.lockButton.isLocked();
}
else
{
this.difficultyButton.enabled = false;
}
}
else
{
this.buttonList.add(new GuiOptionButton(GameSettings.Options.REALMS_NOTIFICATIONS.getOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 - 12 + 24 * (i >> 1), GameSettings.Options.REALMS_NOTIFICATIONS, this.settings.getKeyBinding(GameSettings.Options.REALMS_NOTIFICATIONS)));
}
this.buttonList.add(new GuiButton(110, this.width / 2 - 155, this.height / 6 + 48 - 6, 150, 20, I18n.format("options.skinCustomisation")));
this.buttonList.add(new GuiButton(106, this.width / 2 + 5, this.height / 6 + 48 - 6, 150, 20, I18n.format("options.sounds")));
this.buttonList.add(new GuiButton(101, this.width / 2 - 155, this.height / 6 + 72 - 6, 150, 20, I18n.format("options.video")));
this.buttonList.add(new GuiButton(100, this.width / 2 + 5, this.height / 6 + 72 - 6, 150, 20, I18n.format("options.controls")));
this.buttonList.add(new GuiButton(102, this.width / 2 - 155, this.height / 6 + 96 - 6, 150, 20, I18n.format("options.language")));
this.buttonList.add(new GuiButton(103, this.width / 2 + 5, this.height / 6 + 96 - 6, 150, 20, I18n.format("options.chat.title")));
this.buttonList.add(new GuiButton(105, this.width / 2 - 155, this.height / 6 + 120 - 6, 150, 20, I18n.format("options.resourcepack")));
this.buttonList.add(new GuiButton(104, this.width / 2 + 5, this.height / 6 + 120 - 6, 150, 20, I18n.format("options.snooper.view")));
this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, I18n.format("gui.done")));
}
public String getDifficultyText(EnumDifficulty p_175355_1_)
{
ITextComponent itextcomponent = new TextComponentString("");
itextcomponent.appendSibling(new TextComponentTranslation("options.difficulty", new Object[0]));
itextcomponent.appendText(": ");
itextcomponent.appendSibling(new TextComponentTranslation(p_175355_1_.getDifficultyResourceKey(), new Object[0]));
return itextcomponent.getFormattedText();
}
public void confirmClicked(boolean result, int id)
{
this.mc.displayGuiScreen(this);
if (id == 109 && result && this.mc.world != null)
{
this.mc.world.getWorldInfo().setDifficultyLocked(true);
this.lockButton.setLocked(true);
this.lockButton.enabled = false;
this.difficultyButton.enabled = false;
}
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
if (keyCode == 1)
{
this.mc.gameSettings.saveOptions();
}
super.keyTyped(typedChar, keyCode);
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.enabled)
{
if (button.id < 100 && button instanceof GuiOptionButton)
{
GameSettings.Options gamesettings$options = ((GuiOptionButton)button).getOption();
this.settings.setOptionValue(gamesettings$options, 1);
button.displayString = this.settings.getKeyBinding(GameSettings.Options.byOrdinal(button.id));
}
if (button.id == 108)
{
this.mc.world.getWorldInfo().setDifficulty(EnumDifficulty.getDifficultyEnum(this.mc.world.getDifficulty().getDifficultyId() + 1));
this.difficultyButton.displayString = this.getDifficultyText(this.mc.world.getDifficulty());
}
if (button.id == 109)
{
this.mc.displayGuiScreen(new GuiYesNo(this, (new TextComponentTranslation("difficulty.lock.title", new Object[0])).getFormattedText(), (new TextComponentTranslation("difficulty.lock.question", new Object[] {new TextComponentTranslation(this.mc.world.getWorldInfo().getDifficulty().getDifficultyResourceKey(), new Object[0])})).getFormattedText(), 109));
}
if (button.id == 110)
{
this.mc.gameSettings.saveOptions();
this.mc.displayGuiScreen(new GuiCustomizeSkin(this));
}
if (button.id == 101)
{
this.mc.gameSettings.saveOptions();
this.mc.displayGuiScreen(new GuiVideoSettings(this, this.settings));
}
if (button.id == 100)
{
this.mc.gameSettings.saveOptions();
this.mc.displayGuiScreen(new GuiControls(this, this.settings));
}
if (button.id == 102)
{
this.mc.gameSettings.saveOptions();
this.mc.displayGuiScreen(new GuiLanguage(this, this.settings, this.mc.getLanguageManager()));
}
if (button.id == 103)
{
this.mc.gameSettings.saveOptions();
this.mc.displayGuiScreen(new ScreenChatOptions(this, this.settings));
}
if (button.id == 104)
{
this.mc.gameSettings.saveOptions();
this.mc.displayGuiScreen(new GuiSnooper(this, this.settings));
}
if (button.id == 200)
{
this.mc.gameSettings.saveOptions();
this.mc.displayGuiScreen(this.lastScreen);
}
if (button.id == 105)
{
this.mc.gameSettings.saveOptions();
this.mc.displayGuiScreen(new GuiScreenResourcePacks(this));
}
if (button.id == 106)
{
this.mc.gameSettings.saveOptions();
this.mc.displayGuiScreen(new GuiScreenOptionsSounds(this, this.settings));
}
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, this.title, this.width / 2, 15, 16777215);
super.drawScreen(mouseX, mouseY, partialTicks);
}
}

View File

@@ -0,0 +1,149 @@
package net.minecraft.client.gui;
import com.google.common.collect.Lists;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.GameSettings;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiOptionsRowList extends GuiListExtended
{
private final List<GuiOptionsRowList.Row> options = Lists.<GuiOptionsRowList.Row>newArrayList();
public GuiOptionsRowList(Minecraft mcIn, int p_i45015_2_, int p_i45015_3_, int p_i45015_4_, int p_i45015_5_, int p_i45015_6_, GameSettings.Options... p_i45015_7_)
{
super(mcIn, p_i45015_2_, p_i45015_3_, p_i45015_4_, p_i45015_5_, p_i45015_6_);
this.centerListVertically = false;
for (int i = 0; i < p_i45015_7_.length; i += 2)
{
GameSettings.Options gamesettings$options = p_i45015_7_[i];
GameSettings.Options gamesettings$options1 = i < p_i45015_7_.length - 1 ? p_i45015_7_[i + 1] : null;
GuiButton guibutton = this.createButton(mcIn, p_i45015_2_ / 2 - 155, 0, gamesettings$options);
GuiButton guibutton1 = this.createButton(mcIn, p_i45015_2_ / 2 - 155 + 160, 0, gamesettings$options1);
this.options.add(new GuiOptionsRowList.Row(guibutton, guibutton1));
}
}
private GuiButton createButton(Minecraft mcIn, int p_148182_2_, int p_148182_3_, GameSettings.Options options)
{
if (options == null)
{
return null;
}
else
{
int i = options.getOrdinal();
return (GuiButton)(options.isFloat() ? new GuiOptionSlider(i, p_148182_2_, p_148182_3_, options) : new GuiOptionButton(i, p_148182_2_, p_148182_3_, options, mcIn.gameSettings.getKeyBinding(options)));
}
}
/**
* Gets the IGuiListEntry object for the given index
*/
public GuiOptionsRowList.Row getListEntry(int index)
{
return this.options.get(index);
}
protected int getSize()
{
return this.options.size();
}
/**
* Gets the width of the list
*/
public int getListWidth()
{
return 400;
}
protected int getScrollBarX()
{
return super.getScrollBarX() + 32;
}
@SideOnly(Side.CLIENT)
public static class Row implements GuiListExtended.IGuiListEntry
{
private final Minecraft client = Minecraft.getMinecraft();
private final GuiButton buttonA;
private final GuiButton buttonB;
public Row(GuiButton buttonAIn, GuiButton buttonBIn)
{
this.buttonA = buttonAIn;
this.buttonB = buttonBIn;
}
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float partialTicks)
{
if (this.buttonA != null)
{
this.buttonA.y = y;
this.buttonA.drawButton(this.client, mouseX, mouseY, partialTicks);
}
if (this.buttonB != null)
{
this.buttonB.y = y;
this.buttonB.drawButton(this.client, mouseX, mouseY, partialTicks);
}
}
/**
* 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.buttonA.mousePressed(this.client, mouseX, mouseY))
{
if (this.buttonA instanceof GuiOptionButton)
{
this.client.gameSettings.setOptionValue(((GuiOptionButton)this.buttonA).getOption(), 1);
this.buttonA.displayString = this.client.gameSettings.getKeyBinding(GameSettings.Options.byOrdinal(this.buttonA.id));
}
return true;
}
else if (this.buttonB != null && this.buttonB.mousePressed(this.client, mouseX, mouseY))
{
if (this.buttonB instanceof GuiOptionButton)
{
this.client.gameSettings.setOptionValue(((GuiOptionButton)this.buttonB).getOption(), 1);
this.buttonB.displayString = this.client.gameSettings.getKeyBinding(GameSettings.Options.byOrdinal(this.buttonB.id));
}
return true;
}
else
{
return false;
}
}
/**
* Fired when the mouse button is released. Arguments: index, x, y, mouseEvent, relativeX, relativeY
*/
public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY)
{
if (this.buttonA != null)
{
this.buttonA.mouseReleased(x, y);
}
if (this.buttonB != null)
{
this.buttonB.mouseReleased(x, y);
}
}
public void updatePosition(int slotIndex, int x, int y, float partialTicks)
{
}
}
}

View File

@@ -0,0 +1,303 @@
package net.minecraft.client.gui;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.UnmodifiableIterator;
import java.util.List;
import java.util.Map.Entry;
import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.ClientBrandRetriever;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.FrameTimer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.WorldType;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.opengl.Display;
@SideOnly(Side.CLIENT)
public class GuiOverlayDebug extends Gui
{
private final Minecraft mc;
private final FontRenderer fontRenderer;
public GuiOverlayDebug(Minecraft mc)
{
this.mc = mc;
this.fontRenderer = mc.fontRenderer;
}
public void renderDebugInfo(ScaledResolution scaledResolutionIn)
{
this.mc.mcProfiler.startSection("debug");
GlStateManager.pushMatrix();
this.renderDebugInfoLeft();
this.renderDebugInfoRight(scaledResolutionIn);
GlStateManager.popMatrix();
if (this.mc.gameSettings.showLagometer)
{
this.renderLagometer();
}
this.mc.mcProfiler.endSection();
}
protected void renderDebugInfoLeft()
{
List<String> list = this.call();
list.add("");
list.add("Debug: Pie [shift]: " + (this.mc.gameSettings.showDebugProfilerChart ? "visible" : "hidden") + " FPS [alt]: " + (this.mc.gameSettings.showLagometer ? "visible" : "hidden"));
list.add("For help: press F3 + Q");
for (int i = 0; i < list.size(); ++i)
{
String s = list.get(i);
if (!Strings.isNullOrEmpty(s))
{
int j = this.fontRenderer.FONT_HEIGHT;
int k = this.fontRenderer.getStringWidth(s);
int l = 2;
int i1 = 2 + j * i;
drawRect(1, i1 - 1, 2 + k + 1, i1 + j - 1, -1873784752);
this.fontRenderer.drawString(s, 2, i1, 14737632);
}
}
}
protected void renderDebugInfoRight(ScaledResolution scaledRes)
{
List<String> list = this.getDebugInfoRight();
for (int i = 0; i < list.size(); ++i)
{
String s = list.get(i);
if (!Strings.isNullOrEmpty(s))
{
int j = this.fontRenderer.FONT_HEIGHT;
int k = this.fontRenderer.getStringWidth(s);
int l = scaledRes.getScaledWidth() - 2 - k;
int i1 = 2 + j * i;
drawRect(l - 1, i1 - 1, l + k + 1, i1 + j - 1, -1873784752);
this.fontRenderer.drawString(s, l, i1, 14737632);
}
}
}
@SuppressWarnings("incomplete-switch")
protected List<String> call()
{
BlockPos blockpos = new BlockPos(this.mc.getRenderViewEntity().posX, this.mc.getRenderViewEntity().getEntityBoundingBox().minY, this.mc.getRenderViewEntity().posZ);
if (this.mc.isReducedDebug())
{
return Lists.newArrayList("Minecraft 1.12.2 (" + this.mc.getVersion() + "/" + ClientBrandRetriever.getClientModName() + ")", this.mc.debug, this.mc.renderGlobal.getDebugInfoRenders(), this.mc.renderGlobal.getDebugInfoEntities(), "P: " + this.mc.effectRenderer.getStatistics() + ". T: " + this.mc.world.getDebugLoadedEntities(), this.mc.world.getProviderName(), "", String.format("Chunk-relative: %d %d %d", blockpos.getX() & 15, blockpos.getY() & 15, blockpos.getZ() & 15));
}
else
{
Entity entity = this.mc.getRenderViewEntity();
EnumFacing enumfacing = entity.getHorizontalFacing();
String s = "Invalid";
switch (enumfacing)
{
case NORTH:
s = "Towards negative Z";
break;
case SOUTH:
s = "Towards positive Z";
break;
case WEST:
s = "Towards negative X";
break;
case EAST:
s = "Towards positive X";
}
List<String> list = Lists.newArrayList("Minecraft 1.12.2 (" + this.mc.getVersion() + "/" + ClientBrandRetriever.getClientModName() + ("release".equalsIgnoreCase(this.mc.getVersionType()) ? "" : "/" + this.mc.getVersionType()) + ")", this.mc.debug, this.mc.renderGlobal.getDebugInfoRenders(), this.mc.renderGlobal.getDebugInfoEntities(), "P: " + this.mc.effectRenderer.getStatistics() + ". T: " + this.mc.world.getDebugLoadedEntities(), this.mc.world.getProviderName(), "", String.format("XYZ: %.3f / %.5f / %.3f", this.mc.getRenderViewEntity().posX, this.mc.getRenderViewEntity().getEntityBoundingBox().minY, this.mc.getRenderViewEntity().posZ), String.format("Block: %d %d %d", blockpos.getX(), blockpos.getY(), blockpos.getZ()), String.format("Chunk: %d %d %d in %d %d %d", blockpos.getX() & 15, blockpos.getY() & 15, blockpos.getZ() & 15, blockpos.getX() >> 4, blockpos.getY() >> 4, blockpos.getZ() >> 4), String.format("Facing: %s (%s) (%.1f / %.1f)", enumfacing, s, MathHelper.wrapDegrees(entity.rotationYaw), MathHelper.wrapDegrees(entity.rotationPitch)));
if (this.mc.world != null)
{
Chunk chunk = this.mc.world.getChunkFromBlockCoords(blockpos);
if (this.mc.world.isBlockLoaded(blockpos) && blockpos.getY() >= 0 && blockpos.getY() < 256)
{
if (!chunk.isEmpty())
{
list.add("Biome: " + chunk.getBiome(blockpos, this.mc.world.getBiomeProvider()).getBiomeName());
list.add("Light: " + chunk.getLightSubtracted(blockpos, 0) + " (" + chunk.getLightFor(EnumSkyBlock.SKY, blockpos) + " sky, " + chunk.getLightFor(EnumSkyBlock.BLOCK, blockpos) + " block)");
DifficultyInstance difficultyinstance = this.mc.world.getDifficultyForLocation(blockpos);
if (this.mc.isIntegratedServerRunning() && this.mc.getIntegratedServer() != null)
{
EntityPlayerMP entityplayermp = this.mc.getIntegratedServer().getPlayerList().getPlayerByUUID(this.mc.player.getUniqueID());
if (entityplayermp != null)
{
difficultyinstance = entityplayermp.world.getDifficultyForLocation(new BlockPos(entityplayermp));
}
}
list.add(String.format("Local Difficulty: %.2f // %.2f (Day %d)", difficultyinstance.getAdditionalDifficulty(), difficultyinstance.getClampedAdditionalDifficulty(), this.mc.world.getWorldTime() / 24000L));
}
else
{
list.add("Waiting for chunk...");
}
}
else
{
list.add("Outside of world...");
}
}
if (this.mc.entityRenderer != null && this.mc.entityRenderer.isShaderActive())
{
list.add("Shader: " + this.mc.entityRenderer.getShaderGroup().getShaderGroupName());
}
if (this.mc.objectMouseOver != null && this.mc.objectMouseOver.typeOfHit == RayTraceResult.Type.BLOCK && this.mc.objectMouseOver.getBlockPos() != null)
{
BlockPos blockpos1 = this.mc.objectMouseOver.getBlockPos();
list.add(String.format("Looking at: %d %d %d", blockpos1.getX(), blockpos1.getY(), blockpos1.getZ()));
}
return list;
}
}
protected <T extends Comparable<T>> List<String> getDebugInfoRight()
{
long i = Runtime.getRuntime().maxMemory();
long j = Runtime.getRuntime().totalMemory();
long k = Runtime.getRuntime().freeMemory();
long l = j - k;
List<String> list = Lists.newArrayList(String.format("Java: %s %dbit", System.getProperty("java.version"), this.mc.isJava64bit() ? 64 : 32), String.format("Mem: % 2d%% %03d/%03dMB", l * 100L / i, bytesToMb(l), bytesToMb(i)), String.format("Allocated: % 2d%% %03dMB", j * 100L / i, bytesToMb(j)), "", String.format("CPU: %s", OpenGlHelper.getCpu()), "", String.format("Display: %dx%d (%s)", Display.getWidth(), Display.getHeight(), GlStateManager.glGetString(7936)), GlStateManager.glGetString(7937), GlStateManager.glGetString(7938));
list.add("");
list.addAll(net.minecraftforge.fml.common.FMLCommonHandler.instance().getBrandings(false));
if (this.mc.isReducedDebug())
{
return list;
}
else
{
if (this.mc.objectMouseOver != null && this.mc.objectMouseOver.typeOfHit == RayTraceResult.Type.BLOCK && this.mc.objectMouseOver.getBlockPos() != null)
{
BlockPos blockpos = this.mc.objectMouseOver.getBlockPos();
IBlockState iblockstate = this.mc.world.getBlockState(blockpos);
if (this.mc.world.getWorldType() != WorldType.DEBUG_ALL_BLOCK_STATES)
{
iblockstate = iblockstate.getActualState(this.mc.world, blockpos);
}
list.add("");
list.add(String.valueOf(Block.REGISTRY.getNameForObject(iblockstate.getBlock())));
IProperty<T> iproperty;
String s;
for (UnmodifiableIterator unmodifiableiterator = iblockstate.getProperties().entrySet().iterator(); unmodifiableiterator.hasNext(); list.add(iproperty.getName() + ": " + s))
{
Entry < IProperty<?>, Comparable<? >> entry = (Entry)unmodifiableiterator.next();
iproperty = (IProperty)entry.getKey();
T t = (T)entry.getValue();
s = iproperty.getName(t);
if (Boolean.TRUE.equals(t))
{
s = TextFormatting.GREEN + s;
}
else if (Boolean.FALSE.equals(t))
{
s = TextFormatting.RED + s;
}
}
}
return list;
}
}
public void renderLagometer()
{
GlStateManager.disableDepth();
FrameTimer frametimer = this.mc.getFrameTimer();
int i = frametimer.getLastIndex();
int j = frametimer.getIndex();
long[] along = frametimer.getFrames();
ScaledResolution scaledresolution = new ScaledResolution(this.mc);
int k = i;
int l = 0;
drawRect(0, scaledresolution.getScaledHeight() - 60, 240, scaledresolution.getScaledHeight(), -1873784752);
while (k != j)
{
int i1 = frametimer.getLagometerValue(along[k], 30);
int j1 = this.getFrameColor(MathHelper.clamp(i1, 0, 60), 0, 30, 60);
this.drawVerticalLine(l, scaledresolution.getScaledHeight(), scaledresolution.getScaledHeight() - i1, j1);
++l;
k = frametimer.parseIndex(k + 1);
}
drawRect(1, scaledresolution.getScaledHeight() - 30 + 1, 14, scaledresolution.getScaledHeight() - 30 + 10, -1873784752);
this.fontRenderer.drawString("60", 2, scaledresolution.getScaledHeight() - 30 + 2, 14737632);
this.drawHorizontalLine(0, 239, scaledresolution.getScaledHeight() - 30, -1);
drawRect(1, scaledresolution.getScaledHeight() - 60 + 1, 14, scaledresolution.getScaledHeight() - 60 + 10, -1873784752);
this.fontRenderer.drawString("30", 2, scaledresolution.getScaledHeight() - 60 + 2, 14737632);
this.drawHorizontalLine(0, 239, scaledresolution.getScaledHeight() - 60, -1);
this.drawHorizontalLine(0, 239, scaledresolution.getScaledHeight() - 1, -1);
this.drawVerticalLine(0, scaledresolution.getScaledHeight() - 60, scaledresolution.getScaledHeight(), -1);
this.drawVerticalLine(239, scaledresolution.getScaledHeight() - 60, scaledresolution.getScaledHeight(), -1);
if (this.mc.gameSettings.limitFramerate <= 120)
{
this.drawHorizontalLine(0, 239, scaledresolution.getScaledHeight() - 60 + this.mc.gameSettings.limitFramerate / 2, -16711681);
}
GlStateManager.enableDepth();
}
private int getFrameColor(int p_181552_1_, int p_181552_2_, int p_181552_3_, int p_181552_4_)
{
return p_181552_1_ < p_181552_3_ ? this.blendColors(-16711936, -256, (float)p_181552_1_ / (float)p_181552_3_) : this.blendColors(-256, -65536, (float)(p_181552_1_ - p_181552_3_) / (float)(p_181552_4_ - p_181552_3_));
}
private int blendColors(int p_181553_1_, int p_181553_2_, float p_181553_3_)
{
int i = p_181553_1_ >> 24 & 255;
int j = p_181553_1_ >> 16 & 255;
int k = p_181553_1_ >> 8 & 255;
int l = p_181553_1_ & 255;
int i1 = p_181553_2_ >> 24 & 255;
int j1 = p_181553_2_ >> 16 & 255;
int k1 = p_181553_2_ >> 8 & 255;
int l1 = p_181553_2_ & 255;
int i2 = MathHelper.clamp((int)((float)i + (float)(i1 - i) * p_181553_3_), 0, 255);
int j2 = MathHelper.clamp((int)((float)j + (float)(j1 - j) * p_181553_3_), 0, 255);
int k2 = MathHelper.clamp((int)((float)k + (float)(k1 - k) * p_181553_3_), 0, 255);
int l2 = MathHelper.clamp((int)((float)l + (float)(l1 - l) * p_181553_3_), 0, 255);
return i2 << 24 | j2 << 16 | k2 << 8 | l2;
}
private static long bytesToMb(long bytes)
{
return bytes / 1024L / 1024L;
}
}

View File

@@ -0,0 +1,664 @@
package net.minecraft.client.gui;
import com.google.common.base.MoreObjects;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Lists;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.client.Minecraft;
import net.minecraft.util.IntHashMap;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiPageButtonList extends GuiListExtended
{
private final List<GuiPageButtonList.GuiEntry> entries = Lists.<GuiPageButtonList.GuiEntry>newArrayList();
private final IntHashMap<Gui> componentMap = new IntHashMap<Gui>();
private final List<GuiTextField> editBoxes = Lists.<GuiTextField>newArrayList();
private final GuiPageButtonList.GuiListEntry[][] pages;
private int page;
private final GuiPageButtonList.GuiResponder responder;
private Gui focusedControl;
public GuiPageButtonList(Minecraft mcIn, int widthIn, int heightIn, int topIn, int bottomIn, int slotHeightIn, GuiPageButtonList.GuiResponder p_i45536_7_, GuiPageButtonList.GuiListEntry[]... p_i45536_8_)
{
super(mcIn, widthIn, heightIn, topIn, bottomIn, slotHeightIn);
this.responder = p_i45536_7_;
this.pages = p_i45536_8_;
this.centerListVertically = false;
this.populateComponents();
this.populateEntries();
}
private void populateComponents()
{
for (GuiPageButtonList.GuiListEntry[] aguipagebuttonlist$guilistentry : this.pages)
{
for (int i = 0; i < aguipagebuttonlist$guilistentry.length; i += 2)
{
GuiPageButtonList.GuiListEntry guipagebuttonlist$guilistentry = aguipagebuttonlist$guilistentry[i];
GuiPageButtonList.GuiListEntry guipagebuttonlist$guilistentry1 = i < aguipagebuttonlist$guilistentry.length - 1 ? aguipagebuttonlist$guilistentry[i + 1] : null;
Gui gui = this.createEntry(guipagebuttonlist$guilistentry, 0, guipagebuttonlist$guilistentry1 == null);
Gui gui1 = this.createEntry(guipagebuttonlist$guilistentry1, 160, guipagebuttonlist$guilistentry == null);
GuiPageButtonList.GuiEntry guipagebuttonlist$guientry = new GuiPageButtonList.GuiEntry(gui, gui1);
this.entries.add(guipagebuttonlist$guientry);
if (guipagebuttonlist$guilistentry != null && gui != null)
{
this.componentMap.addKey(guipagebuttonlist$guilistentry.getId(), gui);
if (gui instanceof GuiTextField)
{
this.editBoxes.add((GuiTextField)gui);
}
}
if (guipagebuttonlist$guilistentry1 != null && gui1 != null)
{
this.componentMap.addKey(guipagebuttonlist$guilistentry1.getId(), gui1);
if (gui1 instanceof GuiTextField)
{
this.editBoxes.add((GuiTextField)gui1);
}
}
}
}
}
private void populateEntries()
{
this.entries.clear();
for (int i = 0; i < this.pages[this.page].length; i += 2)
{
GuiPageButtonList.GuiListEntry guipagebuttonlist$guilistentry = this.pages[this.page][i];
GuiPageButtonList.GuiListEntry guipagebuttonlist$guilistentry1 = i < this.pages[this.page].length - 1 ? this.pages[this.page][i + 1] : null;
Gui gui = this.componentMap.lookup(guipagebuttonlist$guilistentry.getId());
Gui gui1 = guipagebuttonlist$guilistentry1 != null ? (Gui)this.componentMap.lookup(guipagebuttonlist$guilistentry1.getId()) : null;
GuiPageButtonList.GuiEntry guipagebuttonlist$guientry = new GuiPageButtonList.GuiEntry(gui, gui1);
this.entries.add(guipagebuttonlist$guientry);
}
}
public void setPage(int p_181156_1_)
{
if (p_181156_1_ != this.page)
{
int i = this.page;
this.page = p_181156_1_;
this.populateEntries();
this.markVisibility(i, p_181156_1_);
this.amountScrolled = 0.0F;
}
}
public int getPage()
{
return this.page;
}
public int getPageCount()
{
return this.pages.length;
}
public Gui getFocusedControl()
{
return this.focusedControl;
}
public void previousPage()
{
if (this.page > 0)
{
this.setPage(this.page - 1);
}
}
public void nextPage()
{
if (this.page < this.pages.length - 1)
{
this.setPage(this.page + 1);
}
}
public Gui getComponent(int p_178061_1_)
{
return this.componentMap.lookup(p_178061_1_);
}
private void markVisibility(int p_178060_1_, int p_178060_2_)
{
for (GuiPageButtonList.GuiListEntry guipagebuttonlist$guilistentry : this.pages[p_178060_1_])
{
if (guipagebuttonlist$guilistentry != null)
{
this.setComponentVisibility(this.componentMap.lookup(guipagebuttonlist$guilistentry.getId()), false);
}
}
for (GuiPageButtonList.GuiListEntry guipagebuttonlist$guilistentry1 : this.pages[p_178060_2_])
{
if (guipagebuttonlist$guilistentry1 != null)
{
this.setComponentVisibility(this.componentMap.lookup(guipagebuttonlist$guilistentry1.getId()), true);
}
}
}
private void setComponentVisibility(Gui p_178066_1_, boolean p_178066_2_)
{
if (p_178066_1_ instanceof GuiButton)
{
((GuiButton)p_178066_1_).visible = p_178066_2_;
}
else if (p_178066_1_ instanceof GuiTextField)
{
((GuiTextField)p_178066_1_).setVisible(p_178066_2_);
}
else if (p_178066_1_ instanceof GuiLabel)
{
((GuiLabel)p_178066_1_).visible = p_178066_2_;
}
}
@Nullable
private Gui createEntry(@Nullable GuiPageButtonList.GuiListEntry p_178058_1_, int p_178058_2_, boolean p_178058_3_)
{
if (p_178058_1_ instanceof GuiPageButtonList.GuiSlideEntry)
{
return this.createSlider(this.width / 2 - 155 + p_178058_2_, 0, (GuiPageButtonList.GuiSlideEntry)p_178058_1_);
}
else if (p_178058_1_ instanceof GuiPageButtonList.GuiButtonEntry)
{
return this.createButton(this.width / 2 - 155 + p_178058_2_, 0, (GuiPageButtonList.GuiButtonEntry)p_178058_1_);
}
else if (p_178058_1_ instanceof GuiPageButtonList.EditBoxEntry)
{
return this.createTextField(this.width / 2 - 155 + p_178058_2_, 0, (GuiPageButtonList.EditBoxEntry)p_178058_1_);
}
else
{
return p_178058_1_ instanceof GuiPageButtonList.GuiLabelEntry ? this.createLabel(this.width / 2 - 155 + p_178058_2_, 0, (GuiPageButtonList.GuiLabelEntry)p_178058_1_, p_178058_3_) : null;
}
}
public void setActive(boolean p_181155_1_)
{
for (GuiPageButtonList.GuiEntry guipagebuttonlist$guientry : this.entries)
{
if (guipagebuttonlist$guientry.component1 instanceof GuiButton)
{
((GuiButton)guipagebuttonlist$guientry.component1).enabled = p_181155_1_;
}
if (guipagebuttonlist$guientry.component2 instanceof GuiButton)
{
((GuiButton)guipagebuttonlist$guientry.component2).enabled = p_181155_1_;
}
}
}
public boolean mouseClicked(int mouseX, int mouseY, int mouseEvent)
{
boolean flag = super.mouseClicked(mouseX, mouseY, mouseEvent);
int i = this.getSlotIndexFromScreenCoords(mouseX, mouseY);
if (i >= 0)
{
GuiPageButtonList.GuiEntry guipagebuttonlist$guientry = this.getListEntry(i);
if (this.focusedControl != guipagebuttonlist$guientry.focusedControl && this.focusedControl != null && this.focusedControl instanceof GuiTextField)
{
((GuiTextField)this.focusedControl).setFocused(false);
}
this.focusedControl = guipagebuttonlist$guientry.focusedControl;
}
return flag;
}
private GuiSlider createSlider(int p_178067_1_, int p_178067_2_, GuiPageButtonList.GuiSlideEntry p_178067_3_)
{
GuiSlider guislider = new GuiSlider(this.responder, p_178067_3_.getId(), p_178067_1_, p_178067_2_, p_178067_3_.getCaption(), p_178067_3_.getMinValue(), p_178067_3_.getMaxValue(), p_178067_3_.getInitalValue(), p_178067_3_.getFormatter());
guislider.visible = p_178067_3_.shouldStartVisible();
return guislider;
}
private GuiListButton createButton(int p_178065_1_, int p_178065_2_, GuiPageButtonList.GuiButtonEntry p_178065_3_)
{
GuiListButton guilistbutton = new GuiListButton(this.responder, p_178065_3_.getId(), p_178065_1_, p_178065_2_, p_178065_3_.getCaption(), p_178065_3_.getInitialValue());
guilistbutton.visible = p_178065_3_.shouldStartVisible();
return guilistbutton;
}
private GuiTextField createTextField(int p_178068_1_, int p_178068_2_, GuiPageButtonList.EditBoxEntry p_178068_3_)
{
GuiTextField guitextfield = new GuiTextField(p_178068_3_.getId(), this.mc.fontRenderer, p_178068_1_, p_178068_2_, 150, 20);
guitextfield.setText(p_178068_3_.getCaption());
guitextfield.setGuiResponder(this.responder);
guitextfield.setVisible(p_178068_3_.shouldStartVisible());
guitextfield.setValidator(p_178068_3_.getFilter());
return guitextfield;
}
private GuiLabel createLabel(int p_178063_1_, int p_178063_2_, GuiPageButtonList.GuiLabelEntry p_178063_3_, boolean p_178063_4_)
{
GuiLabel guilabel;
if (p_178063_4_)
{
guilabel = new GuiLabel(this.mc.fontRenderer, p_178063_3_.getId(), p_178063_1_, p_178063_2_, this.width - p_178063_1_ * 2, 20, -1);
}
else
{
guilabel = new GuiLabel(this.mc.fontRenderer, p_178063_3_.getId(), p_178063_1_, p_178063_2_, 150, 20, -1);
}
guilabel.visible = p_178063_3_.shouldStartVisible();
guilabel.addLine(p_178063_3_.getCaption());
guilabel.setCentered();
return guilabel;
}
public void onKeyPressed(char p_178062_1_, int p_178062_2_)
{
if (this.focusedControl instanceof GuiTextField)
{
GuiTextField guitextfield = (GuiTextField)this.focusedControl;
if (!GuiScreen.isKeyComboCtrlV(p_178062_2_))
{
if (p_178062_2_ == 15)
{
guitextfield.setFocused(false);
int k = this.editBoxes.indexOf(this.focusedControl);
if (GuiScreen.isShiftKeyDown())
{
if (k == 0)
{
k = this.editBoxes.size() - 1;
}
else
{
--k;
}
}
else if (k == this.editBoxes.size() - 1)
{
k = 0;
}
else
{
++k;
}
this.focusedControl = this.editBoxes.get(k);
guitextfield = (GuiTextField)this.focusedControl;
guitextfield.setFocused(true);
int l = guitextfield.y + this.slotHeight;
int i1 = guitextfield.y;
if (l > this.bottom)
{
this.amountScrolled += (float)(l - this.bottom);
}
else if (i1 < this.top)
{
this.amountScrolled = (float)i1;
}
}
else
{
guitextfield.textboxKeyTyped(p_178062_1_, p_178062_2_);
}
}
else
{
String s = GuiScreen.getClipboardString();
String[] astring = s.split(";");
int i = this.editBoxes.indexOf(this.focusedControl);
int j = i;
for (String s1 : astring)
{
GuiTextField guitextfield1 = this.editBoxes.get(j);
guitextfield1.setText(s1);
guitextfield1.setResponderEntryValue(guitextfield1.getId(), s1);
if (j == this.editBoxes.size() - 1)
{
j = 0;
}
else
{
++j;
}
if (j == i)
{
break;
}
}
}
}
}
/**
* Gets the IGuiListEntry object for the given index
*/
public GuiPageButtonList.GuiEntry getListEntry(int index)
{
return this.entries.get(index);
}
public int getSize()
{
return this.entries.size();
}
/**
* Gets the width of the list
*/
public int getListWidth()
{
return 400;
}
protected int getScrollBarX()
{
return super.getScrollBarX() + 32;
}
@SideOnly(Side.CLIENT)
public static class EditBoxEntry extends GuiPageButtonList.GuiListEntry
{
private final Predicate<String> filter;
public EditBoxEntry(int p_i45534_1_, String p_i45534_2_, boolean p_i45534_3_, Predicate<String> p_i45534_4_)
{
super(p_i45534_1_, p_i45534_2_, p_i45534_3_);
this.filter = (Predicate)MoreObjects.firstNonNull(p_i45534_4_, Predicates.alwaysTrue());
}
public Predicate<String> getFilter()
{
return this.filter;
}
}
@SideOnly(Side.CLIENT)
public static class GuiButtonEntry extends GuiPageButtonList.GuiListEntry
{
private final boolean initialValue;
public GuiButtonEntry(int p_i45535_1_, String p_i45535_2_, boolean p_i45535_3_, boolean p_i45535_4_)
{
super(p_i45535_1_, p_i45535_2_, p_i45535_3_);
this.initialValue = p_i45535_4_;
}
public boolean getInitialValue()
{
return this.initialValue;
}
}
@SideOnly(Side.CLIENT)
public static class GuiEntry implements GuiListExtended.IGuiListEntry
{
private final Minecraft client = Minecraft.getMinecraft();
private final Gui component1;
private final Gui component2;
private Gui focusedControl;
public GuiEntry(@Nullable Gui p_i45533_1_, @Nullable Gui p_i45533_2_)
{
this.component1 = p_i45533_1_;
this.component2 = p_i45533_2_;
}
public Gui getComponent1()
{
return this.component1;
}
public Gui getComponent2()
{
return this.component2;
}
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float partialTicks)
{
this.renderComponent(this.component1, y, mouseX, mouseY, false, partialTicks);
this.renderComponent(this.component2, y, mouseX, mouseY, false, partialTicks);
}
private void renderComponent(Gui p_192636_1_, int p_192636_2_, int p_192636_3_, int p_192636_4_, boolean p_192636_5_, float p_192636_6_)
{
if (p_192636_1_ != null)
{
if (p_192636_1_ instanceof GuiButton)
{
this.renderButton((GuiButton)p_192636_1_, p_192636_2_, p_192636_3_, p_192636_4_, p_192636_5_, p_192636_6_);
}
else if (p_192636_1_ instanceof GuiTextField)
{
this.renderTextField((GuiTextField)p_192636_1_, p_192636_2_, p_192636_5_);
}
else if (p_192636_1_ instanceof GuiLabel)
{
this.renderLabel((GuiLabel)p_192636_1_, p_192636_2_, p_192636_3_, p_192636_4_, p_192636_5_);
}
}
}
private void renderButton(GuiButton p_192635_1_, int p_192635_2_, int p_192635_3_, int p_192635_4_, boolean p_192635_5_, float p_192635_6_)
{
p_192635_1_.y = p_192635_2_;
if (!p_192635_5_)
{
p_192635_1_.drawButton(this.client, p_192635_3_, p_192635_4_, p_192635_6_);
}
}
private void renderTextField(GuiTextField p_178027_1_, int p_178027_2_, boolean p_178027_3_)
{
p_178027_1_.y = p_178027_2_;
if (!p_178027_3_)
{
p_178027_1_.drawTextBox();
}
}
private void renderLabel(GuiLabel p_178025_1_, int p_178025_2_, int p_178025_3_, int p_178025_4_, boolean p_178025_5_)
{
p_178025_1_.y = p_178025_2_;
if (!p_178025_5_)
{
p_178025_1_.drawLabel(this.client, p_178025_3_, p_178025_4_);
}
}
public void updatePosition(int slotIndex, int x, int y, float partialTicks)
{
this.renderComponent(this.component1, y, 0, 0, true, partialTicks);
this.renderComponent(this.component2, y, 0, 0, true, partialTicks);
}
/**
* 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)
{
boolean flag = this.clickComponent(this.component1, mouseX, mouseY, mouseEvent);
boolean flag1 = this.clickComponent(this.component2, mouseX, mouseY, mouseEvent);
return flag || flag1;
}
private boolean clickComponent(Gui p_178026_1_, int p_178026_2_, int p_178026_3_, int p_178026_4_)
{
if (p_178026_1_ == null)
{
return false;
}
else if (p_178026_1_ instanceof GuiButton)
{
return this.clickButton((GuiButton)p_178026_1_, p_178026_2_, p_178026_3_, p_178026_4_);
}
else
{
if (p_178026_1_ instanceof GuiTextField)
{
this.clickTextField((GuiTextField)p_178026_1_, p_178026_2_, p_178026_3_, p_178026_4_);
}
return false;
}
}
private boolean clickButton(GuiButton p_178023_1_, int p_178023_2_, int p_178023_3_, int p_178023_4_)
{
boolean flag = p_178023_1_.mousePressed(this.client, p_178023_2_, p_178023_3_);
if (flag)
{
this.focusedControl = p_178023_1_;
}
return flag;
}
private void clickTextField(GuiTextField p_178018_1_, int p_178018_2_, int p_178018_3_, int p_178018_4_)
{
p_178018_1_.mouseClicked(p_178018_2_, p_178018_3_, p_178018_4_);
if (p_178018_1_.isFocused())
{
this.focusedControl = p_178018_1_;
}
}
/**
* Fired when the mouse button is released. Arguments: index, x, y, mouseEvent, relativeX, relativeY
*/
public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY)
{
this.releaseComponent(this.component1, x, y, mouseEvent);
this.releaseComponent(this.component2, x, y, mouseEvent);
}
private void releaseComponent(Gui p_178016_1_, int p_178016_2_, int p_178016_3_, int p_178016_4_)
{
if (p_178016_1_ != null)
{
if (p_178016_1_ instanceof GuiButton)
{
this.releaseButton((GuiButton)p_178016_1_, p_178016_2_, p_178016_3_, p_178016_4_);
}
}
}
private void releaseButton(GuiButton p_178019_1_, int p_178019_2_, int p_178019_3_, int p_178019_4_)
{
p_178019_1_.mouseReleased(p_178019_2_, p_178019_3_);
}
}
@SideOnly(Side.CLIENT)
public static class GuiLabelEntry extends GuiPageButtonList.GuiListEntry
{
public GuiLabelEntry(int p_i45532_1_, String p_i45532_2_, boolean p_i45532_3_)
{
super(p_i45532_1_, p_i45532_2_, p_i45532_3_);
}
}
@SideOnly(Side.CLIENT)
public static class GuiListEntry
{
private final int id;
private final String caption;
private final boolean startVisible;
public GuiListEntry(int p_i45531_1_, String p_i45531_2_, boolean p_i45531_3_)
{
this.id = p_i45531_1_;
this.caption = p_i45531_2_;
this.startVisible = p_i45531_3_;
}
public int getId()
{
return this.id;
}
public String getCaption()
{
return this.caption;
}
public boolean shouldStartVisible()
{
return this.startVisible;
}
}
@SideOnly(Side.CLIENT)
public interface GuiResponder
{
void setEntryValue(int id, boolean value);
void setEntryValue(int id, float value);
void setEntryValue(int id, String value);
}
@SideOnly(Side.CLIENT)
public static class GuiSlideEntry extends GuiPageButtonList.GuiListEntry
{
private final GuiSlider.FormatHelper formatter;
private final float minValue;
private final float maxValue;
private final float initialValue;
public GuiSlideEntry(int p_i45530_1_, String p_i45530_2_, boolean p_i45530_3_, GuiSlider.FormatHelper p_i45530_4_, float p_i45530_5_, float p_i45530_6_, float p_i45530_7_)
{
super(p_i45530_1_, p_i45530_2_, p_i45530_3_);
this.formatter = p_i45530_4_;
this.minValue = p_i45530_5_;
this.maxValue = p_i45530_6_;
this.initialValue = p_i45530_7_;
}
public GuiSlider.FormatHelper getFormatter()
{
return this.formatter;
}
public float getMinValue()
{
return this.minValue;
}
public float getMaxValue()
{
return this.maxValue;
}
public float getInitalValue()
{
return this.initialValue;
}
}
}

View File

@@ -0,0 +1,401 @@
package net.minecraft.client.gui;
import com.google.common.collect.ComparisonChain;
import com.google.common.collect.Ordering;
import com.mojang.authlib.GameProfile;
import java.util.Comparator;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.client.Minecraft;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.client.network.NetworkPlayerInfo;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EnumPlayerModelParts;
import net.minecraft.scoreboard.IScoreCriteria;
import net.minecraft.scoreboard.ScoreObjective;
import net.minecraft.scoreboard.ScorePlayerTeam;
import net.minecraft.scoreboard.Scoreboard;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.GameType;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiPlayerTabOverlay extends Gui
{
private static final Ordering<NetworkPlayerInfo> ENTRY_ORDERING = Ordering.from(new GuiPlayerTabOverlay.PlayerComparator());
private final Minecraft mc;
private final GuiIngame guiIngame;
private ITextComponent footer;
private ITextComponent header;
/** The last time the playerlist was opened (went from not being renderd, to being rendered) */
private long lastTimeOpened;
/** Weither or not the playerlist is currently being rendered */
private boolean isBeingRendered;
public GuiPlayerTabOverlay(Minecraft mcIn, GuiIngame guiIngameIn)
{
this.mc = mcIn;
this.guiIngame = guiIngameIn;
}
/**
* Returns the name that should be renderd for the player supplied
*/
public String getPlayerName(NetworkPlayerInfo networkPlayerInfoIn)
{
return networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName());
}
/**
* Called by GuiIngame to update the information stored in the playerlist, does not actually render the list,
* however.
*/
public void updatePlayerList(boolean willBeRendered)
{
if (willBeRendered && !this.isBeingRendered)
{
this.lastTimeOpened = Minecraft.getSystemTime();
}
this.isBeingRendered = willBeRendered;
}
/**
* Renders the playerlist, its background, headers and footers.
*/
public void renderPlayerlist(int width, Scoreboard scoreboardIn, @Nullable ScoreObjective scoreObjectiveIn)
{
NetHandlerPlayClient nethandlerplayclient = this.mc.player.connection;
List<NetworkPlayerInfo> list = ENTRY_ORDERING.<NetworkPlayerInfo>sortedCopy(nethandlerplayclient.getPlayerInfoMap());
int i = 0;
int j = 0;
for (NetworkPlayerInfo networkplayerinfo : list)
{
int k = this.mc.fontRenderer.getStringWidth(this.getPlayerName(networkplayerinfo));
i = Math.max(i, k);
if (scoreObjectiveIn != null && scoreObjectiveIn.getRenderType() != IScoreCriteria.EnumRenderType.HEARTS)
{
k = this.mc.fontRenderer.getStringWidth(" " + scoreboardIn.getOrCreateScore(networkplayerinfo.getGameProfile().getName(), scoreObjectiveIn).getScorePoints());
j = Math.max(j, k);
}
}
list = list.subList(0, Math.min(list.size(), 80));
int l3 = list.size();
int i4 = l3;
int j4;
for (j4 = 1; i4 > 20; i4 = (l3 + j4 - 1) / j4)
{
++j4;
}
boolean flag = this.mc.isIntegratedServerRunning() || this.mc.getConnection().getNetworkManager().isEncrypted();
int l;
if (scoreObjectiveIn != null)
{
if (scoreObjectiveIn.getRenderType() == IScoreCriteria.EnumRenderType.HEARTS)
{
l = 90;
}
else
{
l = j;
}
}
else
{
l = 0;
}
int i1 = Math.min(j4 * ((flag ? 9 : 0) + i + l + 13), width - 50) / j4;
int j1 = width / 2 - (i1 * j4 + (j4 - 1) * 5) / 2;
int k1 = 10;
int l1 = i1 * j4 + (j4 - 1) * 5;
List<String> list1 = null;
if (this.header != null)
{
list1 = this.mc.fontRenderer.listFormattedStringToWidth(this.header.getFormattedText(), width - 50);
for (String s : list1)
{
l1 = Math.max(l1, this.mc.fontRenderer.getStringWidth(s));
}
}
List<String> list2 = null;
if (this.footer != null)
{
list2 = this.mc.fontRenderer.listFormattedStringToWidth(this.footer.getFormattedText(), width - 50);
for (String s1 : list2)
{
l1 = Math.max(l1, this.mc.fontRenderer.getStringWidth(s1));
}
}
if (list1 != null)
{
drawRect(width / 2 - l1 / 2 - 1, k1 - 1, width / 2 + l1 / 2 + 1, k1 + list1.size() * this.mc.fontRenderer.FONT_HEIGHT, Integer.MIN_VALUE);
for (String s2 : list1)
{
int i2 = this.mc.fontRenderer.getStringWidth(s2);
this.mc.fontRenderer.drawStringWithShadow(s2, (float)(width / 2 - i2 / 2), (float)k1, -1);
k1 += this.mc.fontRenderer.FONT_HEIGHT;
}
++k1;
}
drawRect(width / 2 - l1 / 2 - 1, k1 - 1, width / 2 + l1 / 2 + 1, k1 + i4 * 9, Integer.MIN_VALUE);
for (int k4 = 0; k4 < l3; ++k4)
{
int l4 = k4 / i4;
int i5 = k4 % i4;
int j2 = j1 + l4 * i1 + l4 * 5;
int k2 = k1 + i5 * 9;
drawRect(j2, k2, j2 + i1, k2 + 8, 553648127);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.enableAlpha();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
if (k4 < list.size())
{
NetworkPlayerInfo networkplayerinfo1 = list.get(k4);
GameProfile gameprofile = networkplayerinfo1.getGameProfile();
if (flag)
{
EntityPlayer entityplayer = this.mc.world.getPlayerEntityByUUID(gameprofile.getId());
boolean flag1 = entityplayer != null && entityplayer.isWearing(EnumPlayerModelParts.CAPE) && ("Dinnerbone".equals(gameprofile.getName()) || "Grumm".equals(gameprofile.getName()));
this.mc.getTextureManager().bindTexture(networkplayerinfo1.getLocationSkin());
int l2 = 8 + (flag1 ? 8 : 0);
int i3 = 8 * (flag1 ? -1 : 1);
Gui.drawScaledCustomSizeModalRect(j2, k2, 8.0F, (float)l2, 8, i3, 8, 8, 64.0F, 64.0F);
if (entityplayer != null && entityplayer.isWearing(EnumPlayerModelParts.HAT))
{
int j3 = 8 + (flag1 ? 8 : 0);
int k3 = 8 * (flag1 ? -1 : 1);
Gui.drawScaledCustomSizeModalRect(j2, k2, 40.0F, (float)j3, 8, k3, 8, 8, 64.0F, 64.0F);
}
j2 += 9;
}
String s4 = this.getPlayerName(networkplayerinfo1);
if (networkplayerinfo1.getGameType() == GameType.SPECTATOR)
{
this.mc.fontRenderer.drawStringWithShadow(TextFormatting.ITALIC + s4, (float)j2, (float)k2, -1862270977);
}
else
{
this.mc.fontRenderer.drawStringWithShadow(s4, (float)j2, (float)k2, -1);
}
if (scoreObjectiveIn != null && networkplayerinfo1.getGameType() != GameType.SPECTATOR)
{
int k5 = j2 + i + 1;
int l5 = k5 + l;
if (l5 - k5 > 5)
{
this.drawScoreboardValues(scoreObjectiveIn, k2, gameprofile.getName(), k5, l5, networkplayerinfo1);
}
}
this.drawPing(i1, j2 - (flag ? 9 : 0), k2, networkplayerinfo1);
}
}
if (list2 != null)
{
k1 = k1 + i4 * 9 + 1;
drawRect(width / 2 - l1 / 2 - 1, k1 - 1, width / 2 + l1 / 2 + 1, k1 + list2.size() * this.mc.fontRenderer.FONT_HEIGHT, Integer.MIN_VALUE);
for (String s3 : list2)
{
int j5 = this.mc.fontRenderer.getStringWidth(s3);
this.mc.fontRenderer.drawStringWithShadow(s3, (float)(width / 2 - j5 / 2), (float)k1, -1);
k1 += this.mc.fontRenderer.FONT_HEIGHT;
}
}
}
protected void drawPing(int p_175245_1_, int p_175245_2_, int p_175245_3_, NetworkPlayerInfo networkPlayerInfoIn)
{
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(ICONS);
int i = 0;
int j;
if (networkPlayerInfoIn.getResponseTime() < 0)
{
j = 5;
}
else if (networkPlayerInfoIn.getResponseTime() < 150)
{
j = 0;
}
else if (networkPlayerInfoIn.getResponseTime() < 300)
{
j = 1;
}
else if (networkPlayerInfoIn.getResponseTime() < 600)
{
j = 2;
}
else if (networkPlayerInfoIn.getResponseTime() < 1000)
{
j = 3;
}
else
{
j = 4;
}
this.zLevel += 100.0F;
this.drawTexturedModalRect(p_175245_2_ + p_175245_1_ - 11, p_175245_3_, 0, 176 + j * 8, 10, 8);
this.zLevel -= 100.0F;
}
private void drawScoreboardValues(ScoreObjective objective, int p_175247_2_, String name, int p_175247_4_, int p_175247_5_, NetworkPlayerInfo info)
{
int i = objective.getScoreboard().getOrCreateScore(name, objective).getScorePoints();
if (objective.getRenderType() == IScoreCriteria.EnumRenderType.HEARTS)
{
this.mc.getTextureManager().bindTexture(ICONS);
if (this.lastTimeOpened == info.getRenderVisibilityId())
{
if (i < info.getLastHealth())
{
info.setLastHealthTime(Minecraft.getSystemTime());
info.setHealthBlinkTime((long)(this.guiIngame.getUpdateCounter() + 20));
}
else if (i > info.getLastHealth())
{
info.setLastHealthTime(Minecraft.getSystemTime());
info.setHealthBlinkTime((long)(this.guiIngame.getUpdateCounter() + 10));
}
}
if (Minecraft.getSystemTime() - info.getLastHealthTime() > 1000L || this.lastTimeOpened != info.getRenderVisibilityId())
{
info.setLastHealth(i);
info.setDisplayHealth(i);
info.setLastHealthTime(Minecraft.getSystemTime());
}
info.setRenderVisibilityId(this.lastTimeOpened);
info.setLastHealth(i);
int j = MathHelper.ceil((float)Math.max(i, info.getDisplayHealth()) / 2.0F);
int k = Math.max(MathHelper.ceil((float)(i / 2)), Math.max(MathHelper.ceil((float)(info.getDisplayHealth() / 2)), 10));
boolean flag = info.getHealthBlinkTime() > (long)this.guiIngame.getUpdateCounter() && (info.getHealthBlinkTime() - (long)this.guiIngame.getUpdateCounter()) / 3L % 2L == 1L;
if (j > 0)
{
float f = Math.min((float)(p_175247_5_ - p_175247_4_ - 4) / (float)k, 9.0F);
if (f > 3.0F)
{
for (int l = j; l < k; ++l)
{
this.drawTexturedModalRect((float)p_175247_4_ + (float)l * f, (float)p_175247_2_, flag ? 25 : 16, 0, 9, 9);
}
for (int j1 = 0; j1 < j; ++j1)
{
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, flag ? 25 : 16, 0, 9, 9);
if (flag)
{
if (j1 * 2 + 1 < info.getDisplayHealth())
{
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, 70, 0, 9, 9);
}
if (j1 * 2 + 1 == info.getDisplayHealth())
{
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, 79, 0, 9, 9);
}
}
if (j1 * 2 + 1 < i)
{
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, j1 >= 10 ? 160 : 52, 0, 9, 9);
}
if (j1 * 2 + 1 == i)
{
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, j1 >= 10 ? 169 : 61, 0, 9, 9);
}
}
}
else
{
float f1 = MathHelper.clamp((float)i / 20.0F, 0.0F, 1.0F);
int i1 = (int)((1.0F - f1) * 255.0F) << 16 | (int)(f1 * 255.0F) << 8;
String s = "" + (float)i / 2.0F;
if (p_175247_5_ - this.mc.fontRenderer.getStringWidth(s + "hp") >= p_175247_4_)
{
s = s + "hp";
}
this.mc.fontRenderer.drawStringWithShadow(s, (float)((p_175247_5_ + p_175247_4_) / 2 - this.mc.fontRenderer.getStringWidth(s) / 2), (float)p_175247_2_, i1);
}
}
}
else
{
String s1 = TextFormatting.YELLOW + "" + i;
this.mc.fontRenderer.drawStringWithShadow(s1, (float)(p_175247_5_ - this.mc.fontRenderer.getStringWidth(s1)), (float)p_175247_2_, 16777215);
}
}
public void setFooter(@Nullable ITextComponent footerIn)
{
this.footer = footerIn;
}
public void setHeader(@Nullable ITextComponent headerIn)
{
this.header = headerIn;
}
public void resetFooterHeader()
{
this.header = null;
this.footer = null;
}
@SideOnly(Side.CLIENT)
static class PlayerComparator implements Comparator<NetworkPlayerInfo>
{
private PlayerComparator()
{
}
public int compare(NetworkPlayerInfo p_compare_1_, NetworkPlayerInfo p_compare_2_)
{
ScorePlayerTeam scoreplayerteam = p_compare_1_.getPlayerTeam();
ScorePlayerTeam scoreplayerteam1 = p_compare_2_.getPlayerTeam();
return ComparisonChain.start().compareTrueFirst(p_compare_1_.getGameType() != GameType.SPECTATOR, p_compare_2_.getGameType() != GameType.SPECTATOR).compare(scoreplayerteam != null ? scoreplayerteam.getName() : "", scoreplayerteam1 != null ? scoreplayerteam1.getName() : "").compare(p_compare_1_.getGameProfile().getName(), p_compare_2_.getGameProfile().getName()).result();
}
}
}

View File

@@ -0,0 +1,231 @@
package net.minecraft.client.gui;
import io.netty.buffer.Unpooled;
import java.io.IOException;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ContainerRepair;
import net.minecraft.inventory.IContainerListener;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.client.CPacketCustomPayload;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.input.Keyboard;
@SideOnly(Side.CLIENT)
public class GuiRepair extends GuiContainer implements IContainerListener
{
private static final ResourceLocation ANVIL_RESOURCE = new ResourceLocation("textures/gui/container/anvil.png");
private final ContainerRepair anvil;
private GuiTextField nameField;
private final InventoryPlayer playerInventory;
public GuiRepair(InventoryPlayer inventoryIn, World worldIn)
{
super(new ContainerRepair(inventoryIn, worldIn, Minecraft.getMinecraft().player));
this.playerInventory = inventoryIn;
this.anvil = (ContainerRepair)this.inventorySlots;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
super.initGui();
Keyboard.enableRepeatEvents(true);
int i = (this.width - this.xSize) / 2;
int j = (this.height - this.ySize) / 2;
this.nameField = new GuiTextField(0, this.fontRenderer, i + 62, j + 24, 103, 12);
this.nameField.setTextColor(-1);
this.nameField.setDisabledTextColour(-1);
this.nameField.setEnableBackgroundDrawing(false);
this.nameField.setMaxStringLength(35);
this.inventorySlots.removeListener(this);
this.inventorySlots.addListener(this);
}
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
super.onGuiClosed();
Keyboard.enableRepeatEvents(false);
this.inventorySlots.removeListener(this);
}
/**
* Draw the foreground layer for the GuiContainer (everything in front of the items)
*/
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
GlStateManager.disableLighting();
GlStateManager.disableBlend();
this.fontRenderer.drawString(I18n.format("container.repair"), 60, 6, 4210752);
if (this.anvil.maximumCost > 0)
{
int i = 8453920;
boolean flag = true;
String s = I18n.format("container.repair.cost", this.anvil.maximumCost);
if (this.anvil.maximumCost >= 40 && !this.mc.player.capabilities.isCreativeMode)
{
s = I18n.format("container.repair.expensive");
i = 16736352;
}
else if (!this.anvil.getSlot(2).getHasStack())
{
flag = false;
}
else if (!this.anvil.getSlot(2).canTakeStack(this.playerInventory.player))
{
i = 16736352;
}
if (flag)
{
int j = -16777216 | (i & 16579836) >> 2 | i & -16777216;
int k = this.xSize - 8 - this.fontRenderer.getStringWidth(s);
int l = 67;
if (this.fontRenderer.getUnicodeFlag())
{
drawRect(k - 3, 65, this.xSize - 7, 77, -16777216);
drawRect(k - 2, 66, this.xSize - 8, 76, -12895429);
}
else
{
this.fontRenderer.drawString(s, k, 68, j);
this.fontRenderer.drawString(s, k + 1, 67, j);
this.fontRenderer.drawString(s, k + 1, 68, j);
}
this.fontRenderer.drawString(s, k, 67, i);
}
}
GlStateManager.enableLighting();
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
if (this.nameField.textboxKeyTyped(typedChar, keyCode))
{
this.renameItem();
}
else
{
super.keyTyped(typedChar, keyCode);
}
}
private void renameItem()
{
String s = this.nameField.getText();
Slot slot = this.anvil.getSlot(0);
if (slot != null && slot.getHasStack() && !slot.getStack().hasDisplayName() && s.equals(slot.getStack().getDisplayName()))
{
s = "";
}
this.anvil.updateItemName(s);
this.mc.player.connection.sendPacket(new CPacketCustomPayload("MC|ItemName", (new PacketBuffer(Unpooled.buffer())).writeString(s)));
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
super.mouseClicked(mouseX, mouseY, mouseButton);
this.nameField.mouseClicked(mouseX, mouseY, mouseButton);
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
super.drawScreen(mouseX, mouseY, partialTicks);
this.renderHoveredToolTip(mouseX, mouseY);
GlStateManager.disableLighting();
GlStateManager.disableBlend();
this.nameField.drawTextBox();
}
/**
* Draws the background layer of this container (behind the items).
*/
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
{
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(ANVIL_RESOURCE);
int i = (this.width - this.xSize) / 2;
int j = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
this.drawTexturedModalRect(i + 59, j + 20, 0, this.ySize + (this.anvil.getSlot(0).getHasStack() ? 0 : 16), 110, 16);
if ((this.anvil.getSlot(0).getHasStack() || this.anvil.getSlot(1).getHasStack()) && !this.anvil.getSlot(2).getHasStack())
{
this.drawTexturedModalRect(i + 99, j + 45, this.xSize, 0, 28, 21);
}
}
/**
* update the crafting window inventory with the items in the list
*/
public void sendAllContents(Container containerToSend, NonNullList<ItemStack> itemsList)
{
this.sendSlotContents(containerToSend, 0, containerToSend.getSlot(0).getStack());
}
/**
* Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
* contents of that slot.
*/
public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack)
{
if (slotInd == 0)
{
this.nameField.setText(stack.isEmpty() ? "" : stack.getDisplayName());
this.nameField.setEnabled(!stack.isEmpty());
if (!stack.isEmpty())
{
this.renameItem();
}
}
}
/**
* Sends two ints to the client-side Container. Used for furnace burning time, smelting progress, brewing progress,
* and enchanting level. Normally the first int identifies which variable to update, and the second contains the new
* value. Both are truncated to shorts in non-local SMP.
*/
public void sendWindowProperty(Container containerIn, int varToUpdate, int newValue)
{
}
public void sendAllWindowProperties(Container containerIn, IInventory inventory)
{
}
}

View File

@@ -0,0 +1,22 @@
package net.minecraft.client.gui;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.resources.ResourcePackListEntry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiResourcePackAvailable extends GuiResourcePackList
{
public GuiResourcePackAvailable(Minecraft mcIn, int p_i45054_2_, int p_i45054_3_, List<ResourcePackListEntry> p_i45054_4_)
{
super(mcIn, p_i45054_2_, p_i45054_3_, p_i45054_4_);
}
protected String getListHeader()
{
return I18n.format("resourcePack.available.title");
}
}

View File

@@ -0,0 +1,67 @@
package net.minecraft.client.gui;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.resources.ResourcePackListEntry;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public abstract class GuiResourcePackList extends GuiListExtended
{
protected final Minecraft mc;
protected final List<ResourcePackListEntry> resourcePackEntries;
public GuiResourcePackList(Minecraft mcIn, int p_i45055_2_, int p_i45055_3_, List<ResourcePackListEntry> p_i45055_4_)
{
super(mcIn, p_i45055_2_, p_i45055_3_, 32, p_i45055_3_ - 55 + 4, 36);
this.mc = mcIn;
this.resourcePackEntries = p_i45055_4_;
this.centerListVertically = false;
this.setHasListHeader(true, (int)((float)mcIn.fontRenderer.FONT_HEIGHT * 1.5F));
}
/**
* Handles drawing a list's header row.
*/
protected void drawListHeader(int insideLeft, int insideTop, Tessellator tessellatorIn)
{
String s = TextFormatting.UNDERLINE + "" + TextFormatting.BOLD + this.getListHeader();
this.mc.fontRenderer.drawString(s, insideLeft + this.width / 2 - this.mc.fontRenderer.getStringWidth(s) / 2, Math.min(this.top + 3, insideTop), 16777215);
}
protected abstract String getListHeader();
public List<ResourcePackListEntry> getList()
{
return this.resourcePackEntries;
}
protected int getSize()
{
return this.getList().size();
}
/**
* Gets the IGuiListEntry object for the given index
*/
public ResourcePackListEntry getListEntry(int index)
{
return (ResourcePackListEntry)this.getList().get(index);
}
/**
* Gets the width of the list
*/
public int getListWidth()
{
return this.width;
}
protected int getScrollBarX()
{
return this.right - 6;
}
}

View File

@@ -0,0 +1,22 @@
package net.minecraft.client.gui;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.resources.ResourcePackListEntry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiResourcePackSelected extends GuiResourcePackList
{
public GuiResourcePackSelected(Minecraft mcIn, int p_i45056_2_, int p_i45056_3_, List<ResourcePackListEntry> p_i45056_4_)
{
super(mcIn, p_i45056_2_, p_i45056_3_, p_i45056_4_);
}
protected String getListHeader()
{
return I18n.format("resourcePack.selected.title");
}
}

View File

@@ -0,0 +1,795 @@
package net.minecraft.client.gui;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import java.awt.Toolkit;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.JsonToNBT;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTException;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.event.ClickEvent;
import net.minecraft.util.text.event.HoverEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
@SideOnly(Side.CLIENT)
public abstract class GuiScreen extends Gui implements GuiYesNoCallback
{
private static final Logger LOGGER = LogManager.getLogger();
private static final Set<String> PROTOCOLS = Sets.newHashSet("http", "https");
private static final Splitter NEWLINE_SPLITTER = Splitter.on('\n');
/** Reference to the Minecraft object. */
public Minecraft mc;
/** Holds a instance of RenderItem, used to draw the achievement icons on screen (is based on ItemStack) */
protected RenderItem itemRender;
/** The width of the screen object. */
public int width;
/** The height of the screen object. */
public int height;
/** A list of all the buttons in this container. */
protected List<GuiButton> buttonList = Lists.<GuiButton>newArrayList();
/** A list of all the labels in this container. */
protected List<GuiLabel> labelList = Lists.<GuiLabel>newArrayList();
public boolean allowUserInput;
/** The FontRenderer used by GuiScreen */
protected FontRenderer fontRenderer;
/** The button that was just pressed. */
protected GuiButton selectedButton;
private int eventButton;
private long lastMouseEvent;
/** Tracks the number of fingers currently on the screen. Prevents subsequent fingers registering as clicks. */
private int touchValue;
private URI clickedLinkURI;
private boolean focused;
protected boolean keyHandled, mouseHandled; // Forge: allow canceling key and mouse Post events from handleMouseInput and handleKeyboardInput
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
for (int i = 0; i < this.buttonList.size(); ++i)
{
((GuiButton)this.buttonList.get(i)).drawButton(this.mc, mouseX, mouseY, partialTicks);
}
for (int j = 0; j < this.labelList.size(); ++j)
{
((GuiLabel)this.labelList.get(j)).drawLabel(this.mc, mouseX, mouseY);
}
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
if (keyCode == 1)
{
this.mc.displayGuiScreen((GuiScreen)null);
if (this.mc.currentScreen == null)
{
this.mc.setIngameFocus();
}
}
}
/**
* Adds a control to this GUI's button list. Any type that subclasses button may be added (particularly, GuiSlider,
* but not text fields).
*
* @return The control passed in.
*
* @param buttonIn The control to add
*/
protected <T extends GuiButton> T addButton(T buttonIn)
{
this.buttonList.add(buttonIn);
return buttonIn;
}
/**
* Returns a string stored in the system clipboard.
*/
public static String getClipboardString()
{
try
{
Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents((Object)null);
if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor))
{
return (String)transferable.getTransferData(DataFlavor.stringFlavor);
}
}
catch (Exception var1)
{
;
}
return "";
}
/**
* Stores the given string in the system clipboard
*/
public static void setClipboardString(String copyText)
{
if (!StringUtils.isEmpty(copyText))
{
try
{
StringSelection stringselection = new StringSelection(copyText);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringselection, (ClipboardOwner)null);
}
catch (Exception var2)
{
;
}
}
}
protected void renderToolTip(ItemStack stack, int x, int y)
{
FontRenderer font = stack.getItem().getFontRenderer(stack);
net.minecraftforge.fml.client.config.GuiUtils.preItemToolTip(stack);
this.drawHoveringText(this.getItemToolTip(stack), x, y, (font == null ? fontRenderer : font));
net.minecraftforge.fml.client.config.GuiUtils.postItemToolTip();
}
public List<String> getItemToolTip(ItemStack p_191927_1_)
{
List<String> list = p_191927_1_.getTooltip(this.mc.player, this.mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL);
for (int i = 0; i < list.size(); ++i)
{
if (i == 0)
{
list.set(i, p_191927_1_.getRarity().rarityColor + (String)list.get(i));
}
else
{
list.set(i, TextFormatting.GRAY + (String)list.get(i));
}
}
return list;
}
/**
* Draws the given text as a tooltip.
*/
public void drawHoveringText(String text, int x, int y)
{
this.drawHoveringText(Arrays.asList(text), x, y);
}
public void setFocused(boolean hasFocusedControlIn)
{
this.focused = hasFocusedControlIn;
}
public boolean isFocused()
{
return this.focused;
}
/**
* Draws a List of strings as a tooltip. Every entry is drawn on a seperate line.
*/
public void drawHoveringText(List<String> textLines, int x, int y)
{
drawHoveringText(textLines, x, y, fontRenderer);
}
protected void drawHoveringText(List<String> textLines, int x, int y, FontRenderer font)
{
net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(textLines, x, y, width, height, -1, font);
if (false && !textLines.isEmpty())
{
GlStateManager.disableRescaleNormal();
RenderHelper.disableStandardItemLighting();
GlStateManager.disableLighting();
GlStateManager.disableDepth();
int i = 0;
for (String s : textLines)
{
int j = this.fontRenderer.getStringWidth(s);
if (j > i)
{
i = j;
}
}
int l1 = x + 12;
int i2 = y - 12;
int k = 8;
if (textLines.size() > 1)
{
k += 2 + (textLines.size() - 1) * 10;
}
if (l1 + i > this.width)
{
l1 -= 28 + i;
}
if (i2 + k + 6 > this.height)
{
i2 = this.height - k - 6;
}
this.zLevel = 300.0F;
this.itemRender.zLevel = 300.0F;
int l = -267386864;
this.drawGradientRect(l1 - 3, i2 - 4, l1 + i + 3, i2 - 3, -267386864, -267386864);
this.drawGradientRect(l1 - 3, i2 + k + 3, l1 + i + 3, i2 + k + 4, -267386864, -267386864);
this.drawGradientRect(l1 - 3, i2 - 3, l1 + i + 3, i2 + k + 3, -267386864, -267386864);
this.drawGradientRect(l1 - 4, i2 - 3, l1 - 3, i2 + k + 3, -267386864, -267386864);
this.drawGradientRect(l1 + i + 3, i2 - 3, l1 + i + 4, i2 + k + 3, -267386864, -267386864);
int i1 = 1347420415;
int j1 = 1344798847;
this.drawGradientRect(l1 - 3, i2 - 3 + 1, l1 - 3 + 1, i2 + k + 3 - 1, 1347420415, 1344798847);
this.drawGradientRect(l1 + i + 2, i2 - 3 + 1, l1 + i + 3, i2 + k + 3 - 1, 1347420415, 1344798847);
this.drawGradientRect(l1 - 3, i2 - 3, l1 + i + 3, i2 - 3 + 1, 1347420415, 1347420415);
this.drawGradientRect(l1 - 3, i2 + k + 2, l1 + i + 3, i2 + k + 3, 1344798847, 1344798847);
for (int k1 = 0; k1 < textLines.size(); ++k1)
{
String s1 = textLines.get(k1);
this.fontRenderer.drawStringWithShadow(s1, (float)l1, (float)i2, -1);
if (k1 == 0)
{
i2 += 2;
}
i2 += 10;
}
this.zLevel = 0.0F;
this.itemRender.zLevel = 0.0F;
GlStateManager.enableLighting();
GlStateManager.enableDepth();
RenderHelper.enableStandardItemLighting();
GlStateManager.enableRescaleNormal();
}
}
/**
* Draws the hover event specified by the given chat component
*/
protected void handleComponentHover(ITextComponent component, int x, int y)
{
if (component != null && component.getStyle().getHoverEvent() != null)
{
HoverEvent hoverevent = component.getStyle().getHoverEvent();
if (hoverevent.getAction() == HoverEvent.Action.SHOW_ITEM)
{
ItemStack itemstack = ItemStack.EMPTY;
try
{
NBTBase nbtbase = JsonToNBT.getTagFromJson(hoverevent.getValue().getUnformattedText());
if (nbtbase instanceof NBTTagCompound)
{
itemstack = new ItemStack((NBTTagCompound)nbtbase);
}
}
catch (NBTException var9)
{
;
}
if (itemstack.isEmpty())
{
this.drawHoveringText(TextFormatting.RED + "Invalid Item!", x, y);
}
else
{
this.renderToolTip(itemstack, x, y);
}
}
else if (hoverevent.getAction() == HoverEvent.Action.SHOW_ENTITY)
{
if (this.mc.gameSettings.advancedItemTooltips)
{
try
{
NBTTagCompound nbttagcompound = JsonToNBT.getTagFromJson(hoverevent.getValue().getUnformattedText());
List<String> list = Lists.<String>newArrayList();
list.add(nbttagcompound.getString("name"));
if (nbttagcompound.hasKey("type", 8))
{
String s = nbttagcompound.getString("type");
list.add("Type: " + s);
}
list.add(nbttagcompound.getString("id"));
this.drawHoveringText(list, x, y);
}
catch (NBTException var8)
{
this.drawHoveringText(TextFormatting.RED + "Invalid Entity!", x, y);
}
}
}
else if (hoverevent.getAction() == HoverEvent.Action.SHOW_TEXT)
{
this.drawHoveringText(this.mc.fontRenderer.listFormattedStringToWidth(hoverevent.getValue().getFormattedText(), Math.max(this.width / 2, 200)), x, y);
}
GlStateManager.disableLighting();
}
}
/**
* Sets the text of the chat
*/
protected void setText(String newChatText, boolean shouldOverwrite)
{
}
/**
* Executes the click event specified by the given chat component
*/
public boolean handleComponentClick(ITextComponent component)
{
if (component == null)
{
return false;
}
else
{
ClickEvent clickevent = component.getStyle().getClickEvent();
if (isShiftKeyDown())
{
if (component.getStyle().getInsertion() != null)
{
this.setText(component.getStyle().getInsertion(), false);
}
}
else if (clickevent != null)
{
if (clickevent.getAction() == ClickEvent.Action.OPEN_URL)
{
if (!this.mc.gameSettings.chatLinks)
{
return false;
}
try
{
URI uri = new URI(clickevent.getValue());
String s = uri.getScheme();
if (s == null)
{
throw new URISyntaxException(clickevent.getValue(), "Missing protocol");
}
if (!PROTOCOLS.contains(s.toLowerCase(Locale.ROOT)))
{
throw new URISyntaxException(clickevent.getValue(), "Unsupported protocol: " + s.toLowerCase(Locale.ROOT));
}
if (this.mc.gameSettings.chatLinksPrompt)
{
this.clickedLinkURI = uri;
this.mc.displayGuiScreen(new GuiConfirmOpenLink(this, clickevent.getValue(), 31102009, false));
}
else
{
this.openWebLink(uri);
}
}
catch (URISyntaxException urisyntaxexception)
{
LOGGER.error("Can't open url for {}", clickevent, urisyntaxexception);
}
}
else if (clickevent.getAction() == ClickEvent.Action.OPEN_FILE)
{
URI uri1 = (new File(clickevent.getValue())).toURI();
this.openWebLink(uri1);
}
else if (clickevent.getAction() == ClickEvent.Action.SUGGEST_COMMAND)
{
this.setText(clickevent.getValue(), true);
}
else if (clickevent.getAction() == ClickEvent.Action.RUN_COMMAND)
{
this.sendChatMessage(clickevent.getValue(), false);
}
else
{
LOGGER.error("Don't know how to handle {}", (Object)clickevent);
}
return true;
}
return false;
}
}
/**
* Used to add chat messages to the client's GuiChat.
*/
public void sendChatMessage(String msg)
{
this.sendChatMessage(msg, true);
}
public void sendChatMessage(String msg, boolean addToChat)
{
msg = net.minecraftforge.event.ForgeEventFactory.onClientSendMessage(msg);
if (msg.isEmpty()) return;
if (addToChat)
{
this.mc.ingameGUI.getChatGUI().addToSentMessages(msg);
}
if (net.minecraftforge.client.ClientCommandHandler.instance.executeCommand(mc.player, msg) != 0) return;
this.mc.player.sendChatMessage(msg);
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
if (mouseButton == 0)
{
for (int i = 0; i < this.buttonList.size(); ++i)
{
GuiButton guibutton = this.buttonList.get(i);
if (guibutton.mousePressed(this.mc, mouseX, mouseY))
{
net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Pre event = new net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Pre(this, guibutton, this.buttonList);
if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event))
break;
guibutton = event.getButton();
this.selectedButton = guibutton;
guibutton.playPressSound(this.mc.getSoundHandler());
this.actionPerformed(guibutton);
if (this.equals(this.mc.currentScreen))
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Post(this, event.getButton(), this.buttonList));
}
}
}
}
/**
* Called when a mouse button is released.
*/
protected void mouseReleased(int mouseX, int mouseY, int state)
{
if (this.selectedButton != null && state == 0)
{
this.selectedButton.mouseReleased(mouseX, mouseY);
this.selectedButton = null;
}
}
/**
* Called when a mouse button is pressed and the mouse is moved around. Parameters are : mouseX, mouseY,
* lastButtonClicked & timeSinceMouseClick.
*/
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick)
{
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
}
/**
* Causes the screen to lay out its subcomponents again. This is the equivalent of the Java call
* Container.validate()
*/
public void setWorldAndResolution(Minecraft mc, int width, int height)
{
this.mc = mc;
this.itemRender = mc.getRenderItem();
this.fontRenderer = mc.fontRenderer;
this.width = width;
this.height = height;
if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent.Pre(this, this.buttonList)))
{
this.buttonList.clear();
this.initGui();
}
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent.Post(this, this.buttonList));
}
/**
* Set the gui to the specified width and height
*/
public void setGuiSize(int w, int h)
{
this.width = w;
this.height = h;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
}
/**
* Delegates mouse and keyboard input.
*/
public void handleInput() throws IOException
{
if (Mouse.isCreated())
{
while (Mouse.next())
{
this.mouseHandled = false;
if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.MouseInputEvent.Pre(this))) continue;
this.handleMouseInput();
if (this.equals(this.mc.currentScreen) && !this.mouseHandled) net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.MouseInputEvent.Post(this));
}
}
if (Keyboard.isCreated())
{
while (Keyboard.next())
{
this.keyHandled = false;
if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.KeyboardInputEvent.Pre(this))) continue;
this.handleKeyboardInput();
if (this.equals(this.mc.currentScreen) && !this.keyHandled) net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.KeyboardInputEvent.Post(this));
}
}
}
/**
* Handles mouse input.
*/
public void handleMouseInput() throws IOException
{
int i = Mouse.getEventX() * this.width / this.mc.displayWidth;
int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
int k = Mouse.getEventButton();
if (Mouse.getEventButtonState())
{
if (this.mc.gameSettings.touchscreen && this.touchValue++ > 0)
{
return;
}
this.eventButton = k;
this.lastMouseEvent = Minecraft.getSystemTime();
this.mouseClicked(i, j, this.eventButton);
}
else if (k != -1)
{
if (this.mc.gameSettings.touchscreen && --this.touchValue > 0)
{
return;
}
this.eventButton = -1;
this.mouseReleased(i, j, k);
}
else if (this.eventButton != -1 && this.lastMouseEvent > 0L)
{
long l = Minecraft.getSystemTime() - this.lastMouseEvent;
this.mouseClickMove(i, j, this.eventButton, l);
}
}
/**
* Handles keyboard input.
*/
public void handleKeyboardInput() throws IOException
{
char c0 = Keyboard.getEventCharacter();
if (Keyboard.getEventKey() == 0 && c0 >= ' ' || Keyboard.getEventKeyState())
{
this.keyTyped(c0, Keyboard.getEventKey());
}
this.mc.dispatchKeypresses();
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
}
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
}
/**
* Draws either a gradient over the background screen (when it exists) or a flat gradient over background.png
*/
public void drawDefaultBackground()
{
this.drawWorldBackground(0);
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.BackgroundDrawnEvent(this));
}
public void drawWorldBackground(int tint)
{
if (this.mc.world != null)
{
this.drawGradientRect(0, 0, this.width, this.height, -1072689136, -804253680);
}
else
{
this.drawBackground(tint);
}
}
/**
* Draws the background (i is always 0 as of 1.2.2)
*/
public void drawBackground(int tint)
{
GlStateManager.disableLighting();
GlStateManager.disableFog();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
this.mc.getTextureManager().bindTexture(OPTIONS_BACKGROUND);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
float f = 32.0F;
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
bufferbuilder.pos(0.0D, (double)this.height, 0.0D).tex(0.0D, (double)((float)this.height / 32.0F + (float)tint)).color(64, 64, 64, 255).endVertex();
bufferbuilder.pos((double)this.width, (double)this.height, 0.0D).tex((double)((float)this.width / 32.0F), (double)((float)this.height / 32.0F + (float)tint)).color(64, 64, 64, 255).endVertex();
bufferbuilder.pos((double)this.width, 0.0D, 0.0D).tex((double)((float)this.width / 32.0F), (double)tint).color(64, 64, 64, 255).endVertex();
bufferbuilder.pos(0.0D, 0.0D, 0.0D).tex(0.0D, (double)tint).color(64, 64, 64, 255).endVertex();
tessellator.draw();
}
/**
* Returns true if this GUI should pause the game when it is displayed in single-player
*/
public boolean doesGuiPauseGame()
{
return true;
}
public void confirmClicked(boolean result, int id)
{
if (id == 31102009)
{
if (result)
{
this.openWebLink(this.clickedLinkURI);
}
this.clickedLinkURI = null;
this.mc.displayGuiScreen(this);
}
}
private void openWebLink(URI url)
{
try
{
Class<?> oclass = Class.forName("java.awt.Desktop");
Object object = oclass.getMethod("getDesktop").invoke((Object)null);
oclass.getMethod("browse", URI.class).invoke(object, url);
}
catch (Throwable throwable1)
{
Throwable throwable = throwable1.getCause();
LOGGER.error("Couldn't open link: {}", (Object)(throwable == null ? "<UNKNOWN>" : throwable.getMessage()));
}
}
/**
* Returns true if either windows ctrl key is down or if either mac meta key is down
*/
public static boolean isCtrlKeyDown()
{
if (Minecraft.IS_RUNNING_ON_MAC)
{
return Keyboard.isKeyDown(219) || Keyboard.isKeyDown(220);
}
else
{
return Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157);
}
}
/**
* Returns true if either shift key is down
*/
public static boolean isShiftKeyDown()
{
return Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54);
}
/**
* Returns true if either alt key is down
*/
public static boolean isAltKeyDown()
{
return Keyboard.isKeyDown(56) || Keyboard.isKeyDown(184);
}
public static boolean isKeyComboCtrlX(int keyID)
{
return keyID == 45 && isCtrlKeyDown() && !isShiftKeyDown() && !isAltKeyDown();
}
public static boolean isKeyComboCtrlV(int keyID)
{
return keyID == 47 && isCtrlKeyDown() && !isShiftKeyDown() && !isAltKeyDown();
}
public static boolean isKeyComboCtrlC(int keyID)
{
return keyID == 46 && isCtrlKeyDown() && !isShiftKeyDown() && !isAltKeyDown();
}
public static boolean isKeyComboCtrlA(int keyID)
{
return keyID == 30 && isCtrlKeyDown() && !isShiftKeyDown() && !isAltKeyDown();
}
/**
* Called when the GUI is resized in order to update the world and the resolution
*/
public void onResize(Minecraft mcIn, int w, int h)
{
this.setWorldAndResolution(mcIn, w, h);
}
}

View File

@@ -0,0 +1,169 @@
package net.minecraft.client.gui;
import com.google.common.base.Predicate;
import java.io.IOException;
import java.net.IDN;
import javax.annotation.Nullable;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.StringUtils;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.input.Keyboard;
@SideOnly(Side.CLIENT)
public class GuiScreenAddServer extends GuiScreen
{
private final GuiScreen parentScreen;
private final ServerData serverData;
private GuiTextField serverIPField;
private GuiTextField serverNameField;
private GuiButton serverResourcePacks;
private final Predicate<String> addressFilter = new Predicate<String>()
{
public boolean apply(@Nullable String p_apply_1_)
{
if (StringUtils.isNullOrEmpty(p_apply_1_))
{
return true;
}
else
{
String[] astring = p_apply_1_.split(":");
if (astring.length == 0)
{
return true;
}
else
{
try
{
String s = IDN.toASCII(astring[0]);
return true;
}
catch (IllegalArgumentException var4)
{
return false;
}
}
}
}
};
public GuiScreenAddServer(GuiScreen parentScreenIn, ServerData serverDataIn)
{
this.parentScreen = parentScreenIn;
this.serverData = serverDataIn;
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
this.serverNameField.updateCursorCounter();
this.serverIPField.updateCursorCounter();
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
Keyboard.enableRepeatEvents(true);
this.buttonList.clear();
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 18, I18n.format("addServer.add")));
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 18, I18n.format("gui.cancel")));
this.serverResourcePacks = this.addButton(new GuiButton(2, this.width / 2 - 100, this.height / 4 + 72, I18n.format("addServer.resourcePack") + ": " + this.serverData.getResourceMode().getMotd().getFormattedText()));
this.serverNameField = new GuiTextField(0, this.fontRenderer, this.width / 2 - 100, 66, 200, 20);
this.serverNameField.setFocused(true);
this.serverNameField.setText(this.serverData.serverName);
this.serverIPField = new GuiTextField(1, this.fontRenderer, this.width / 2 - 100, 106, 200, 20);
this.serverIPField.setMaxStringLength(128);
this.serverIPField.setText(this.serverData.serverIP);
this.serverIPField.setValidator(this.addressFilter);
(this.buttonList.get(0)).enabled = !this.serverIPField.getText().isEmpty() && this.serverIPField.getText().split(":").length > 0 && !this.serverNameField.getText().isEmpty();
}
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
Keyboard.enableRepeatEvents(false);
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.enabled)
{
if (button.id == 2)
{
this.serverData.setResourceMode(ServerData.ServerResourceMode.values()[(this.serverData.getResourceMode().ordinal() + 1) % ServerData.ServerResourceMode.values().length]);
this.serverResourcePacks.displayString = I18n.format("addServer.resourcePack") + ": " + this.serverData.getResourceMode().getMotd().getFormattedText();
}
else if (button.id == 1)
{
this.parentScreen.confirmClicked(false, 0);
}
else if (button.id == 0)
{
this.serverData.serverName = this.serverNameField.getText();
this.serverData.serverIP = this.serverIPField.getText();
this.parentScreen.confirmClicked(true, 0);
}
}
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
this.serverNameField.textboxKeyTyped(typedChar, keyCode);
this.serverIPField.textboxKeyTyped(typedChar, keyCode);
if (keyCode == 15)
{
this.serverNameField.setFocused(!this.serverNameField.isFocused());
this.serverIPField.setFocused(!this.serverIPField.isFocused());
}
if (keyCode == 28 || keyCode == 156)
{
this.actionPerformed(this.buttonList.get(0));
}
(this.buttonList.get(0)).enabled = !this.serverIPField.getText().isEmpty() && this.serverIPField.getText().split(":").length > 0 && !this.serverNameField.getText().isEmpty();
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
super.mouseClicked(mouseX, mouseY, mouseButton);
this.serverIPField.mouseClicked(mouseX, mouseY, mouseButton);
this.serverNameField.mouseClicked(mouseX, mouseY, mouseButton);
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, I18n.format("addServer.title"), this.width / 2, 17, 16777215);
this.drawString(this.fontRenderer, I18n.format("addServer.enterName"), this.width / 2 - 100, 53, 10526880);
this.drawString(this.fontRenderer, I18n.format("addServer.enterIp"), this.width / 2 - 100, 94, 10526880);
this.serverNameField.drawTextBox();
this.serverIPField.drawTextBox();
super.drawScreen(mouseX, mouseY, partialTicks);
}
}

View File

@@ -0,0 +1,657 @@
package net.minecraft.client.gui;
import com.google.common.collect.Lists;
import com.google.gson.JsonParseException;
import io.netty.buffer.Unpooled;
import java.io.IOException;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemWrittenBook;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.client.CPacketCustomPayload;
import net.minecraft.util.ChatAllowedCharacters;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.event.ClickEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.input.Keyboard;
@SideOnly(Side.CLIENT)
public class GuiScreenBook extends GuiScreen
{
private static final Logger LOGGER = LogManager.getLogger();
private static final ResourceLocation BOOK_GUI_TEXTURES = new ResourceLocation("textures/gui/book.png");
/** The player editing the book */
private final EntityPlayer editingPlayer;
private final ItemStack book;
/** Whether the book is signed or can still be edited */
private final boolean bookIsUnsigned;
/** Whether the book's title or contents has been modified since being opened */
private boolean bookIsModified;
/** Determines if the signing screen is open */
private boolean bookGettingSigned;
/** Update ticks since the gui was opened */
private int updateCount;
private final int bookImageWidth = 192;
private final int bookImageHeight = 192;
private int bookTotalPages = 1;
private int currPage;
private NBTTagList bookPages;
private String bookTitle = "";
private List<ITextComponent> cachedComponents;
private int cachedPage = -1;
private GuiScreenBook.NextPageButton buttonNextPage;
private GuiScreenBook.NextPageButton buttonPreviousPage;
private GuiButton buttonDone;
/** The GuiButton to sign this book. */
private GuiButton buttonSign;
private GuiButton buttonFinalize;
private GuiButton buttonCancel;
public GuiScreenBook(EntityPlayer player, ItemStack book, boolean isUnsigned)
{
this.editingPlayer = player;
this.book = book;
this.bookIsUnsigned = isUnsigned;
if (book.hasTagCompound())
{
NBTTagCompound nbttagcompound = book.getTagCompound();
this.bookPages = nbttagcompound.getTagList("pages", 8).copy();
this.bookTotalPages = this.bookPages.tagCount();
if (this.bookTotalPages < 1)
{
this.bookPages.appendTag(new NBTTagString("")); // Forge: fix MC-1685
this.bookTotalPages = 1;
}
}
if (this.bookPages == null && isUnsigned)
{
this.bookPages = new NBTTagList();
this.bookPages.appendTag(new NBTTagString(""));
this.bookTotalPages = 1;
}
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
super.updateScreen();
++this.updateCount;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.buttonList.clear();
Keyboard.enableRepeatEvents(true);
if (this.bookIsUnsigned)
{
this.buttonSign = this.addButton(new GuiButton(3, this.width / 2 - 100, 196, 98, 20, I18n.format("book.signButton")));
this.buttonDone = this.addButton(new GuiButton(0, this.width / 2 + 2, 196, 98, 20, I18n.format("gui.done")));
this.buttonFinalize = this.addButton(new GuiButton(5, this.width / 2 - 100, 196, 98, 20, I18n.format("book.finalizeButton")));
this.buttonCancel = this.addButton(new GuiButton(4, this.width / 2 + 2, 196, 98, 20, I18n.format("gui.cancel")));
}
else
{
this.buttonDone = this.addButton(new GuiButton(0, this.width / 2 - 100, 196, 200, 20, I18n.format("gui.done")));
}
int i = (this.width - 192) / 2;
int j = 2;
this.buttonNextPage = (GuiScreenBook.NextPageButton)this.addButton(new GuiScreenBook.NextPageButton(1, i + 120, 156, true));
this.buttonPreviousPage = (GuiScreenBook.NextPageButton)this.addButton(new GuiScreenBook.NextPageButton(2, i + 38, 156, false));
this.updateButtons();
}
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
Keyboard.enableRepeatEvents(false);
}
private void updateButtons()
{
this.buttonNextPage.visible = !this.bookGettingSigned && (this.currPage < this.bookTotalPages - 1 || this.bookIsUnsigned);
this.buttonPreviousPage.visible = !this.bookGettingSigned && this.currPage > 0;
this.buttonDone.visible = !this.bookIsUnsigned || !this.bookGettingSigned;
if (this.bookIsUnsigned)
{
this.buttonSign.visible = !this.bookGettingSigned;
this.buttonCancel.visible = this.bookGettingSigned;
this.buttonFinalize.visible = this.bookGettingSigned;
this.buttonFinalize.enabled = !this.bookTitle.trim().isEmpty();
}
}
private void sendBookToServer(boolean publish) throws IOException
{
if (this.bookIsUnsigned && this.bookIsModified)
{
if (this.bookPages != null)
{
while (this.bookPages.tagCount() > 1)
{
String s = this.bookPages.getStringTagAt(this.bookPages.tagCount() - 1);
if (!s.isEmpty())
{
break;
}
this.bookPages.removeTag(this.bookPages.tagCount() - 1);
}
if (this.book.hasTagCompound())
{
NBTTagCompound nbttagcompound = this.book.getTagCompound();
nbttagcompound.setTag("pages", this.bookPages);
}
else
{
this.book.setTagInfo("pages", this.bookPages);
}
String s1 = "MC|BEdit";
if (publish)
{
s1 = "MC|BSign";
this.book.setTagInfo("author", new NBTTagString(this.editingPlayer.getName()));
this.book.setTagInfo("title", new NBTTagString(this.bookTitle.trim()));
}
PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
packetbuffer.writeItemStack(this.book);
this.mc.getConnection().sendPacket(new CPacketCustomPayload(s1, packetbuffer));
}
}
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.enabled)
{
if (button.id == 0)
{
this.mc.displayGuiScreen((GuiScreen)null);
this.sendBookToServer(false);
}
else if (button.id == 3 && this.bookIsUnsigned)
{
this.bookGettingSigned = true;
}
else if (button.id == 1)
{
if (this.currPage < this.bookTotalPages - 1)
{
++this.currPage;
}
else if (this.bookIsUnsigned)
{
this.addNewPage();
if (this.currPage < this.bookTotalPages - 1)
{
++this.currPage;
}
}
}
else if (button.id == 2)
{
if (this.currPage > 0)
{
--this.currPage;
}
}
else if (button.id == 5 && this.bookGettingSigned)
{
this.sendBookToServer(true);
this.mc.displayGuiScreen((GuiScreen)null);
}
else if (button.id == 4 && this.bookGettingSigned)
{
this.bookGettingSigned = false;
}
this.updateButtons();
}
}
private void addNewPage()
{
if (this.bookPages != null && this.bookPages.tagCount() < 50)
{
this.bookPages.appendTag(new NBTTagString(""));
++this.bookTotalPages;
this.bookIsModified = true;
}
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
super.keyTyped(typedChar, keyCode);
if (this.bookIsUnsigned)
{
if (this.bookGettingSigned)
{
this.keyTypedInTitle(typedChar, keyCode);
}
else
{
this.keyTypedInBook(typedChar, keyCode);
}
}
}
/**
* Processes keystrokes when editing the text of a book
*/
private void keyTypedInBook(char typedChar, int keyCode)
{
if (GuiScreen.isKeyComboCtrlV(keyCode))
{
this.pageInsertIntoCurrent(GuiScreen.getClipboardString());
}
else
{
switch (keyCode)
{
case 14:
String s = this.pageGetCurrent();
if (!s.isEmpty())
{
this.pageSetCurrent(s.substring(0, s.length() - 1));
}
return;
case 28:
case 156:
this.pageInsertIntoCurrent("\n");
return;
default:
if (ChatAllowedCharacters.isAllowedCharacter(typedChar))
{
this.pageInsertIntoCurrent(Character.toString(typedChar));
}
}
}
}
/**
* Processes keystrokes when editing the title of a book
*/
private void keyTypedInTitle(char typedChar, int keyCode) throws IOException
{
switch (keyCode)
{
case 14:
if (!this.bookTitle.isEmpty())
{
this.bookTitle = this.bookTitle.substring(0, this.bookTitle.length() - 1);
this.updateButtons();
}
return;
case 28:
case 156:
if (!this.bookTitle.isEmpty())
{
this.sendBookToServer(true);
this.mc.displayGuiScreen((GuiScreen)null);
}
return;
default:
if (this.bookTitle.length() < 16 && ChatAllowedCharacters.isAllowedCharacter(typedChar))
{
this.bookTitle = this.bookTitle + Character.toString(typedChar);
this.updateButtons();
this.bookIsModified = true;
}
}
}
/**
* Returns the entire text of the current page as determined by currPage
*/
private String pageGetCurrent()
{
return this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount() ? this.bookPages.getStringTagAt(this.currPage) : "";
}
/**
* Sets the text of the current page as determined by currPage
*/
private void pageSetCurrent(String p_146457_1_)
{
if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount())
{
this.bookPages.set(this.currPage, new NBTTagString(p_146457_1_));
this.bookIsModified = true;
}
}
/**
* Processes any text getting inserted into the current page, enforcing the page size limit
*/
private void pageInsertIntoCurrent(String p_146459_1_)
{
String s = this.pageGetCurrent();
String s1 = s + p_146459_1_;
int i = this.fontRenderer.getWordWrappedHeight(s1 + "" + TextFormatting.BLACK + "_", 118);
if (i <= 128 && s1.length() < 256)
{
this.pageSetCurrent(s1);
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(BOOK_GUI_TEXTURES);
int i = (this.width - 192) / 2;
int j = 2;
this.drawTexturedModalRect(i, 2, 0, 0, 192, 192);
if (this.bookGettingSigned)
{
String s = this.bookTitle;
if (this.bookIsUnsigned)
{
if (this.updateCount / 6 % 2 == 0)
{
s = s + "" + TextFormatting.BLACK + "_";
}
else
{
s = s + "" + TextFormatting.GRAY + "_";
}
}
String s1 = I18n.format("book.editTitle");
int k = this.fontRenderer.getStringWidth(s1);
this.fontRenderer.drawString(s1, i + 36 + (116 - k) / 2, 34, 0);
int l = this.fontRenderer.getStringWidth(s);
this.fontRenderer.drawString(s, i + 36 + (116 - l) / 2, 50, 0);
String s2 = I18n.format("book.byAuthor", this.editingPlayer.getName());
int i1 = this.fontRenderer.getStringWidth(s2);
this.fontRenderer.drawString(TextFormatting.DARK_GRAY + s2, i + 36 + (116 - i1) / 2, 60, 0);
String s3 = I18n.format("book.finalizeWarning");
this.fontRenderer.drawSplitString(s3, i + 36, 82, 116, 0);
}
else
{
String s4 = I18n.format("book.pageIndicator", this.currPage + 1, this.bookTotalPages);
String s5 = "";
if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount())
{
s5 = this.bookPages.getStringTagAt(this.currPage);
}
if (this.bookIsUnsigned)
{
if (this.fontRenderer.getBidiFlag())
{
s5 = s5 + "_";
}
else if (this.updateCount / 6 % 2 == 0)
{
s5 = s5 + "" + TextFormatting.BLACK + "_";
}
else
{
s5 = s5 + "" + TextFormatting.GRAY + "_";
}
}
else if (this.cachedPage != this.currPage)
{
if (ItemWrittenBook.validBookTagContents(this.book.getTagCompound()))
{
try
{
ITextComponent itextcomponent = ITextComponent.Serializer.jsonToComponent(s5);
this.cachedComponents = itextcomponent != null ? GuiUtilRenderComponents.splitText(itextcomponent, 116, this.fontRenderer, true, true) : null;
}
catch (JsonParseException var13)
{
this.cachedComponents = null;
}
}
else
{
TextComponentString textcomponentstring = new TextComponentString(TextFormatting.DARK_RED + "* Invalid book tag *");
this.cachedComponents = Lists.newArrayList(textcomponentstring);
}
this.cachedPage = this.currPage;
}
int j1 = this.fontRenderer.getStringWidth(s4);
this.fontRenderer.drawString(s4, i - j1 + 192 - 44, 18, 0);
if (this.cachedComponents == null)
{
this.fontRenderer.drawSplitString(s5, i + 36, 34, 116, 0);
}
else
{
int k1 = Math.min(128 / this.fontRenderer.FONT_HEIGHT, this.cachedComponents.size());
for (int l1 = 0; l1 < k1; ++l1)
{
ITextComponent itextcomponent2 = this.cachedComponents.get(l1);
this.fontRenderer.drawString(itextcomponent2.getUnformattedText(), i + 36, 34 + l1 * this.fontRenderer.FONT_HEIGHT, 0);
}
ITextComponent itextcomponent1 = this.getClickedComponentAt(mouseX, mouseY);
if (itextcomponent1 != null)
{
this.handleComponentHover(itextcomponent1, mouseX, mouseY);
}
}
}
super.drawScreen(mouseX, mouseY, partialTicks);
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
if (mouseButton == 0)
{
ITextComponent itextcomponent = this.getClickedComponentAt(mouseX, mouseY);
if (itextcomponent != null && this.handleComponentClick(itextcomponent))
{
return;
}
}
super.mouseClicked(mouseX, mouseY, mouseButton);
}
/**
* Executes the click event specified by the given chat component
*/
public boolean handleComponentClick(ITextComponent component)
{
ClickEvent clickevent = component.getStyle().getClickEvent();
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(component);
if (flag && clickevent.getAction() == ClickEvent.Action.RUN_COMMAND)
{
this.mc.displayGuiScreen((GuiScreen)null);
}
return flag;
}
}
@Nullable
public ITextComponent getClickedComponentAt(int p_175385_1_, int p_175385_2_)
{
if (this.cachedComponents == null)
{
return null;
}
else
{
int i = p_175385_1_ - (this.width - 192) / 2 - 36;
int j = p_175385_2_ - 2 - 16 - 16;
if (i >= 0 && j >= 0)
{
int k = Math.min(128 / this.fontRenderer.FONT_HEIGHT, this.cachedComponents.size());
if (i <= 116 && j < this.mc.fontRenderer.FONT_HEIGHT * k + k)
{
int l = j / this.mc.fontRenderer.FONT_HEIGHT;
if (l >= 0 && l < this.cachedComponents.size())
{
ITextComponent itextcomponent = this.cachedComponents.get(l);
int i1 = 0;
for (ITextComponent itextcomponent1 : itextcomponent)
{
if (itextcomponent1 instanceof TextComponentString)
{
i1 += this.mc.fontRenderer.getStringWidth(((TextComponentString)itextcomponent1).getText());
if (i1 > i)
{
return itextcomponent1;
}
}
}
}
return null;
}
else
{
return null;
}
}
else
{
return null;
}
}
}
@SideOnly(Side.CLIENT)
static class NextPageButton extends GuiButton
{
private final boolean isForward;
public NextPageButton(int buttonId, int x, int y, boolean isForwardIn)
{
super(buttonId, x, y, 23, 13, "");
this.isForward = isForwardIn;
}
/**
* Draws this button to the screen.
*/
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks)
{
if (this.visible)
{
boolean flag = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(GuiScreenBook.BOOK_GUI_TEXTURES);
int i = 0;
int j = 192;
if (flag)
{
i += 23;
}
if (!this.isForward)
{
j += 13;
}
this.drawTexturedModalRect(this.x, this.y, i, j, 23, 13);
}
}
}
}

View File

@@ -0,0 +1,246 @@
package net.minecraft.client.gui;
import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.List;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.gen.ChunkGeneratorSettings;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.input.Keyboard;
@SideOnly(Side.CLIENT)
public class GuiScreenCustomizePresets extends GuiScreen
{
private static final List<GuiScreenCustomizePresets.Info> PRESETS = Lists.<GuiScreenCustomizePresets.Info>newArrayList();
private GuiScreenCustomizePresets.ListPreset list;
private GuiButton select;
private GuiTextField export;
private final GuiCustomizeWorldScreen parent;
protected String title = "Customize World Presets";
private String shareText;
private String listText;
public GuiScreenCustomizePresets(GuiCustomizeWorldScreen parentIn)
{
this.parent = parentIn;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.buttonList.clear();
Keyboard.enableRepeatEvents(true);
this.title = I18n.format("createWorld.customize.custom.presets.title");
this.shareText = I18n.format("createWorld.customize.presets.share");
this.listText = I18n.format("createWorld.customize.presets.list");
this.export = new GuiTextField(2, this.fontRenderer, 50, 40, this.width - 100, 20);
this.list = new GuiScreenCustomizePresets.ListPreset();
this.export.setMaxStringLength(2000);
this.export.setText(this.parent.saveValues());
this.select = this.addButton(new GuiButton(0, this.width / 2 - 102, this.height - 27, 100, 20, I18n.format("createWorld.customize.presets.select")));
this.buttonList.add(new GuiButton(1, this.width / 2 + 3, this.height - 27, 100, 20, I18n.format("gui.cancel")));
this.updateButtonValidity();
}
/**
* Handles mouse input.
*/
public void handleMouseInput() throws IOException
{
super.handleMouseInput();
this.list.handleMouseInput();
}
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
Keyboard.enableRepeatEvents(false);
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
this.export.mouseClicked(mouseX, mouseY, mouseButton);
super.mouseClicked(mouseX, mouseY, mouseButton);
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
if (!this.export.textboxKeyTyped(typedChar, keyCode))
{
super.keyTyped(typedChar, keyCode);
}
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
switch (button.id)
{
case 0:
this.parent.loadValues(this.export.getText());
this.mc.displayGuiScreen(this.parent);
break;
case 1:
this.mc.displayGuiScreen(this.parent);
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.list.drawScreen(mouseX, mouseY, partialTicks);
this.drawCenteredString(this.fontRenderer, this.title, this.width / 2, 8, 16777215);
this.drawString(this.fontRenderer, this.shareText, 50, 30, 10526880);
this.drawString(this.fontRenderer, this.listText, 50, 70, 10526880);
this.export.drawTextBox();
super.drawScreen(mouseX, mouseY, partialTicks);
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
this.export.updateCursorCounter();
super.updateScreen();
}
public void updateButtonValidity()
{
this.select.enabled = this.hasValidSelection();
}
private boolean hasValidSelection()
{
return this.list.selected > -1 && this.list.selected < PRESETS.size() || this.export.getText().length() > 1;
}
static
{
ChunkGeneratorSettings.Factory chunkgeneratorsettings$factory = ChunkGeneratorSettings.Factory.jsonToFactory("{ \"coordinateScale\":684.412, \"heightScale\":684.412, \"upperLimitScale\":512.0, \"lowerLimitScale\":512.0, \"depthNoiseScaleX\":200.0, \"depthNoiseScaleZ\":200.0, \"depthNoiseScaleExponent\":0.5, \"mainNoiseScaleX\":5000.0, \"mainNoiseScaleY\":1000.0, \"mainNoiseScaleZ\":5000.0, \"baseSize\":8.5, \"stretchY\":8.0, \"biomeDepthWeight\":2.0, \"biomeDepthOffset\":0.5, \"biomeScaleWeight\":2.0, \"biomeScaleOffset\":0.375, \"useCaves\":true, \"useDungeons\":true, \"dungeonChance\":8, \"useStrongholds\":true, \"useVillages\":true, \"useMineShafts\":true, \"useTemples\":true, \"useRavines\":true, \"useWaterLakes\":true, \"waterLakeChance\":4, \"useLavaLakes\":true, \"lavaLakeChance\":80, \"useLavaOceans\":false, \"seaLevel\":255 }");
ResourceLocation resourcelocation = new ResourceLocation("textures/gui/presets/water.png");
PRESETS.add(new GuiScreenCustomizePresets.Info(I18n.format("createWorld.customize.custom.preset.waterWorld"), resourcelocation, chunkgeneratorsettings$factory));
chunkgeneratorsettings$factory = ChunkGeneratorSettings.Factory.jsonToFactory("{\"coordinateScale\":3000.0, \"heightScale\":6000.0, \"upperLimitScale\":250.0, \"lowerLimitScale\":512.0, \"depthNoiseScaleX\":200.0, \"depthNoiseScaleZ\":200.0, \"depthNoiseScaleExponent\":0.5, \"mainNoiseScaleX\":80.0, \"mainNoiseScaleY\":160.0, \"mainNoiseScaleZ\":80.0, \"baseSize\":8.5, \"stretchY\":10.0, \"biomeDepthWeight\":1.0, \"biomeDepthOffset\":0.0, \"biomeScaleWeight\":1.0, \"biomeScaleOffset\":0.0, \"useCaves\":true, \"useDungeons\":true, \"dungeonChance\":8, \"useStrongholds\":true, \"useVillages\":true, \"useMineShafts\":true, \"useTemples\":true, \"useRavines\":true, \"useWaterLakes\":true, \"waterLakeChance\":4, \"useLavaLakes\":true, \"lavaLakeChance\":80, \"useLavaOceans\":false, \"seaLevel\":63 }");
resourcelocation = new ResourceLocation("textures/gui/presets/isles.png");
PRESETS.add(new GuiScreenCustomizePresets.Info(I18n.format("createWorld.customize.custom.preset.isleLand"), resourcelocation, chunkgeneratorsettings$factory));
chunkgeneratorsettings$factory = ChunkGeneratorSettings.Factory.jsonToFactory("{\"coordinateScale\":684.412, \"heightScale\":684.412, \"upperLimitScale\":512.0, \"lowerLimitScale\":512.0, \"depthNoiseScaleX\":200.0, \"depthNoiseScaleZ\":200.0, \"depthNoiseScaleExponent\":0.5, \"mainNoiseScaleX\":5000.0, \"mainNoiseScaleY\":1000.0, \"mainNoiseScaleZ\":5000.0, \"baseSize\":8.5, \"stretchY\":5.0, \"biomeDepthWeight\":2.0, \"biomeDepthOffset\":1.0, \"biomeScaleWeight\":4.0, \"biomeScaleOffset\":1.0, \"useCaves\":true, \"useDungeons\":true, \"dungeonChance\":8, \"useStrongholds\":true, \"useVillages\":true, \"useMineShafts\":true, \"useTemples\":true, \"useRavines\":true, \"useWaterLakes\":true, \"waterLakeChance\":4, \"useLavaLakes\":true, \"lavaLakeChance\":80, \"useLavaOceans\":false, \"seaLevel\":63 }");
resourcelocation = new ResourceLocation("textures/gui/presets/delight.png");
PRESETS.add(new GuiScreenCustomizePresets.Info(I18n.format("createWorld.customize.custom.preset.caveDelight"), resourcelocation, chunkgeneratorsettings$factory));
chunkgeneratorsettings$factory = ChunkGeneratorSettings.Factory.jsonToFactory("{\"coordinateScale\":738.41864, \"heightScale\":157.69133, \"upperLimitScale\":801.4267, \"lowerLimitScale\":1254.1643, \"depthNoiseScaleX\":374.93652, \"depthNoiseScaleZ\":288.65228, \"depthNoiseScaleExponent\":1.2092624, \"mainNoiseScaleX\":1355.9908, \"mainNoiseScaleY\":745.5343, \"mainNoiseScaleZ\":1183.464, \"baseSize\":1.8758626, \"stretchY\":1.7137525, \"biomeDepthWeight\":1.7553768, \"biomeDepthOffset\":3.4701107, \"biomeScaleWeight\":1.0, \"biomeScaleOffset\":2.535211, \"useCaves\":true, \"useDungeons\":true, \"dungeonChance\":8, \"useStrongholds\":true, \"useVillages\":true, \"useMineShafts\":true, \"useTemples\":true, \"useRavines\":true, \"useWaterLakes\":true, \"waterLakeChance\":4, \"useLavaLakes\":true, \"lavaLakeChance\":80, \"useLavaOceans\":false, \"seaLevel\":63 }");
resourcelocation = new ResourceLocation("textures/gui/presets/madness.png");
PRESETS.add(new GuiScreenCustomizePresets.Info(I18n.format("createWorld.customize.custom.preset.mountains"), resourcelocation, chunkgeneratorsettings$factory));
chunkgeneratorsettings$factory = ChunkGeneratorSettings.Factory.jsonToFactory("{\"coordinateScale\":684.412, \"heightScale\":684.412, \"upperLimitScale\":512.0, \"lowerLimitScale\":512.0, \"depthNoiseScaleX\":200.0, \"depthNoiseScaleZ\":200.0, \"depthNoiseScaleExponent\":0.5, \"mainNoiseScaleX\":1000.0, \"mainNoiseScaleY\":3000.0, \"mainNoiseScaleZ\":1000.0, \"baseSize\":8.5, \"stretchY\":10.0, \"biomeDepthWeight\":1.0, \"biomeDepthOffset\":0.0, \"biomeScaleWeight\":1.0, \"biomeScaleOffset\":0.0, \"useCaves\":true, \"useDungeons\":true, \"dungeonChance\":8, \"useStrongholds\":true, \"useVillages\":true, \"useMineShafts\":true, \"useTemples\":true, \"useRavines\":true, \"useWaterLakes\":true, \"waterLakeChance\":4, \"useLavaLakes\":true, \"lavaLakeChance\":80, \"useLavaOceans\":false, \"seaLevel\":20 }");
resourcelocation = new ResourceLocation("textures/gui/presets/drought.png");
PRESETS.add(new GuiScreenCustomizePresets.Info(I18n.format("createWorld.customize.custom.preset.drought"), resourcelocation, chunkgeneratorsettings$factory));
chunkgeneratorsettings$factory = ChunkGeneratorSettings.Factory.jsonToFactory("{\"coordinateScale\":684.412, \"heightScale\":684.412, \"upperLimitScale\":2.0, \"lowerLimitScale\":64.0, \"depthNoiseScaleX\":200.0, \"depthNoiseScaleZ\":200.0, \"depthNoiseScaleExponent\":0.5, \"mainNoiseScaleX\":80.0, \"mainNoiseScaleY\":160.0, \"mainNoiseScaleZ\":80.0, \"baseSize\":8.5, \"stretchY\":12.0, \"biomeDepthWeight\":1.0, \"biomeDepthOffset\":0.0, \"biomeScaleWeight\":1.0, \"biomeScaleOffset\":0.0, \"useCaves\":true, \"useDungeons\":true, \"dungeonChance\":8, \"useStrongholds\":true, \"useVillages\":true, \"useMineShafts\":true, \"useTemples\":true, \"useRavines\":true, \"useWaterLakes\":true, \"waterLakeChance\":4, \"useLavaLakes\":true, \"lavaLakeChance\":80, \"useLavaOceans\":false, \"seaLevel\":6 }");
resourcelocation = new ResourceLocation("textures/gui/presets/chaos.png");
PRESETS.add(new GuiScreenCustomizePresets.Info(I18n.format("createWorld.customize.custom.preset.caveChaos"), resourcelocation, chunkgeneratorsettings$factory));
chunkgeneratorsettings$factory = ChunkGeneratorSettings.Factory.jsonToFactory("{\"coordinateScale\":684.412, \"heightScale\":684.412, \"upperLimitScale\":512.0, \"lowerLimitScale\":512.0, \"depthNoiseScaleX\":200.0, \"depthNoiseScaleZ\":200.0, \"depthNoiseScaleExponent\":0.5, \"mainNoiseScaleX\":80.0, \"mainNoiseScaleY\":160.0, \"mainNoiseScaleZ\":80.0, \"baseSize\":8.5, \"stretchY\":12.0, \"biomeDepthWeight\":1.0, \"biomeDepthOffset\":0.0, \"biomeScaleWeight\":1.0, \"biomeScaleOffset\":0.0, \"useCaves\":true, \"useDungeons\":true, \"dungeonChance\":8, \"useStrongholds\":true, \"useVillages\":true, \"useMineShafts\":true, \"useTemples\":true, \"useRavines\":true, \"useWaterLakes\":true, \"waterLakeChance\":4, \"useLavaLakes\":true, \"lavaLakeChance\":80, \"useLavaOceans\":true, \"seaLevel\":40 }");
resourcelocation = new ResourceLocation("textures/gui/presets/luck.png");
PRESETS.add(new GuiScreenCustomizePresets.Info(I18n.format("createWorld.customize.custom.preset.goodLuck"), resourcelocation, chunkgeneratorsettings$factory));
}
@SideOnly(Side.CLIENT)
static class Info
{
public String name;
public ResourceLocation texture;
public ChunkGeneratorSettings.Factory settings;
public Info(String nameIn, ResourceLocation textureIn, ChunkGeneratorSettings.Factory settingsIn)
{
this.name = nameIn;
this.texture = textureIn;
this.settings = settingsIn;
}
}
@SideOnly(Side.CLIENT)
class ListPreset extends GuiSlot
{
public int selected = -1;
public ListPreset()
{
super(GuiScreenCustomizePresets.this.mc, GuiScreenCustomizePresets.this.width, GuiScreenCustomizePresets.this.height, 80, GuiScreenCustomizePresets.this.height - 32, 38);
}
protected int getSize()
{
return GuiScreenCustomizePresets.PRESETS.size();
}
/**
* The element in the slot that was clicked, boolean for whether it was double clicked or not
*/
protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY)
{
this.selected = slotIndex;
GuiScreenCustomizePresets.this.updateButtonValidity();
GuiScreenCustomizePresets.this.export.setText((GuiScreenCustomizePresets.PRESETS.get(GuiScreenCustomizePresets.this.list.selected)).settings.toString());
}
/**
* Returns true if the element passed in is currently selected
*/
protected boolean isSelected(int slotIndex)
{
return slotIndex == this.selected;
}
protected void drawBackground()
{
}
private void blitIcon(int p_178051_1_, int p_178051_2_, ResourceLocation texture)
{
int i = p_178051_1_ + 5;
GuiScreenCustomizePresets.this.drawHorizontalLine(i - 1, i + 32, p_178051_2_ - 1, -2039584);
GuiScreenCustomizePresets.this.drawHorizontalLine(i - 1, i + 32, p_178051_2_ + 32, -6250336);
GuiScreenCustomizePresets.this.drawVerticalLine(i - 1, p_178051_2_ - 1, p_178051_2_ + 32, -2039584);
GuiScreenCustomizePresets.this.drawVerticalLine(i + 32, p_178051_2_ - 1, p_178051_2_ + 32, -6250336);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(texture);
int j = 32;
int k = 32;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
bufferbuilder.pos((double)(i + 0), (double)(p_178051_2_ + 32), 0.0D).tex(0.0D, 1.0D).endVertex();
bufferbuilder.pos((double)(i + 32), (double)(p_178051_2_ + 32), 0.0D).tex(1.0D, 1.0D).endVertex();
bufferbuilder.pos((double)(i + 32), (double)(p_178051_2_ + 0), 0.0D).tex(1.0D, 0.0D).endVertex();
bufferbuilder.pos((double)(i + 0), (double)(p_178051_2_ + 0), 0.0D).tex(0.0D, 0.0D).endVertex();
tessellator.draw();
}
protected void drawSlot(int slotIndex, int xPos, int yPos, int heightIn, int mouseXIn, int mouseYIn, float partialTicks)
{
GuiScreenCustomizePresets.Info guiscreencustomizepresets$info = GuiScreenCustomizePresets.PRESETS.get(slotIndex);
this.blitIcon(xPos, yPos, guiscreencustomizepresets$info.texture);
GuiScreenCustomizePresets.this.fontRenderer.drawString(guiscreencustomizepresets$info.name, xPos + 32 + 10, yPos + 14, 16777215);
}
}
}

View File

@@ -0,0 +1,91 @@
package net.minecraft.client.gui;
import java.io.IOException;
import java.net.URI;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@SideOnly(Side.CLIENT)
public class GuiScreenDemo extends GuiScreen
{
private static final Logger LOGGER = LogManager.getLogger();
private static final ResourceLocation DEMO_BACKGROUND_LOCATION = new ResourceLocation("textures/gui/demo_background.png");
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.buttonList.clear();
int i = -16;
this.buttonList.add(new GuiButton(1, this.width / 2 - 116, this.height / 2 + 62 + -16, 114, 20, I18n.format("demo.help.buy")));
this.buttonList.add(new GuiButton(2, this.width / 2 + 2, this.height / 2 + 62 + -16, 114, 20, I18n.format("demo.help.later")));
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
switch (button.id)
{
case 1:
button.enabled = false;
try
{
Class<?> oclass = Class.forName("java.awt.Desktop");
Object object = oclass.getMethod("getDesktop").invoke((Object)null);
oclass.getMethod("browse", URI.class).invoke(object, new URI("http://www.minecraft.net/store?source=demo"));
}
catch (Throwable throwable)
{
LOGGER.error("Couldn't open link", throwable);
}
break;
case 2:
this.mc.displayGuiScreen((GuiScreen)null);
this.mc.setIngameFocus();
}
}
/**
* Draws either a gradient over the background screen (when it exists) or a flat gradient over background.png
*/
public void drawDefaultBackground()
{
super.drawDefaultBackground();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(DEMO_BACKGROUND_LOCATION);
int i = (this.width - 248) / 2;
int j = (this.height - 166) / 2;
this.drawTexturedModalRect(i, j, 0, 0, 248, 166);
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
int i = (this.width - 248) / 2 + 10;
int j = (this.height - 166) / 2 + 8;
this.fontRenderer.drawString(I18n.format("demo.help.title"), i, j, 2039583);
j = j + 12;
GameSettings gamesettings = this.mc.gameSettings;
this.fontRenderer.drawString(I18n.format("demo.help.movementShort", gamesettings.keyBindForward.getDisplayName(), gamesettings.keyBindLeft.getDisplayName(), gamesettings.keyBindBack.getDisplayName(), gamesettings.keyBindRight.getDisplayName()), i, j, 5197647);
this.fontRenderer.drawString(I18n.format("demo.help.movementMouse"), i, j + 12, 5197647);
this.fontRenderer.drawString(I18n.format("demo.help.jump", gamesettings.keyBindJump.getDisplayName()), i, j + 24, 5197647);
this.fontRenderer.drawString(I18n.format("demo.help.inventory", gamesettings.keyBindInventory.getDisplayName()), i, j + 36, 5197647);
this.fontRenderer.drawSplitString(I18n.format("demo.help.fullWrapped"), i, j + 68, 218, 2039583);
super.drawScreen(mouseX, mouseY, partialTicks);
}
}

View File

@@ -0,0 +1,197 @@
package net.minecraft.client.gui;
import java.io.IOException;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.audio.SoundHandler;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.init.SoundEvents;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiScreenOptionsSounds extends GuiScreen
{
private final GuiScreen parent;
/** Reference to the GameSettings object. */
private final GameSettings game_settings_4;
protected String title = "Options";
private String offDisplayString;
public GuiScreenOptionsSounds(GuiScreen parentIn, GameSettings settingsIn)
{
this.parent = parentIn;
this.game_settings_4 = settingsIn;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.title = I18n.format("options.sounds.title");
this.offDisplayString = I18n.format("options.off");
int i = 0;
this.buttonList.add(new GuiScreenOptionsSounds.Button(SoundCategory.MASTER.ordinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 - 12 + 24 * (i >> 1), SoundCategory.MASTER, true));
i = i + 2;
for (SoundCategory soundcategory : SoundCategory.values())
{
if (soundcategory != SoundCategory.MASTER)
{
this.buttonList.add(new GuiScreenOptionsSounds.Button(soundcategory.ordinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 - 12 + 24 * (i >> 1), soundcategory, false));
++i;
}
}
int j = this.width / 2 - 75;
int k = this.height / 6 - 12;
++i;
this.buttonList.add(new GuiOptionButton(201, j, k + 24 * (i >> 1), GameSettings.Options.SHOW_SUBTITLES, this.game_settings_4.getKeyBinding(GameSettings.Options.SHOW_SUBTITLES)));
this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, I18n.format("gui.done")));
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
if (keyCode == 1)
{
this.mc.gameSettings.saveOptions();
}
super.keyTyped(typedChar, keyCode);
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.enabled)
{
if (button.id == 200)
{
this.mc.gameSettings.saveOptions();
this.mc.displayGuiScreen(this.parent);
}
else if (button.id == 201)
{
this.mc.gameSettings.setOptionValue(GameSettings.Options.SHOW_SUBTITLES, 1);
button.displayString = this.mc.gameSettings.getKeyBinding(GameSettings.Options.SHOW_SUBTITLES);
this.mc.gameSettings.saveOptions();
}
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, this.title, this.width / 2, 15, 16777215);
super.drawScreen(mouseX, mouseY, partialTicks);
}
protected String getDisplayString(SoundCategory category)
{
float f = this.game_settings_4.getSoundLevel(category);
return f == 0.0F ? this.offDisplayString : (int)(f * 100.0F) + "%";
}
@SideOnly(Side.CLIENT)
class Button extends GuiButton
{
private final SoundCategory category;
private final String categoryName;
public float volume = 1.0F;
public boolean pressed;
public Button(int buttonId, int x, int y, SoundCategory categoryIn, boolean master)
{
super(buttonId, x, y, master ? 310 : 150, 20, "");
this.category = categoryIn;
this.categoryName = I18n.format("soundCategory." + categoryIn.getName());
this.displayString = this.categoryName + ": " + GuiScreenOptionsSounds.this.getDisplayString(categoryIn);
this.volume = GuiScreenOptionsSounds.this.game_settings_4.getSoundLevel(categoryIn);
}
/**
* Returns 0 if the button is disabled, 1 if the mouse is NOT hovering over this button and 2 if it IS hovering
* over this button.
*/
protected int getHoverState(boolean mouseOver)
{
return 0;
}
/**
* Fired when the mouse button is dragged. Equivalent of MouseListener.mouseDragged(MouseEvent e).
*/
protected void mouseDragged(Minecraft mc, int mouseX, int mouseY)
{
if (this.visible)
{
if (this.pressed)
{
this.volume = (float)(mouseX - (this.x + 4)) / (float)(this.width - 8);
this.volume = MathHelper.clamp(this.volume, 0.0F, 1.0F);
mc.gameSettings.setSoundLevel(this.category, this.volume);
mc.gameSettings.saveOptions();
this.displayString = this.categoryName + ": " + GuiScreenOptionsSounds.this.getDisplayString(this.category);
}
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(this.x + (int)(this.volume * (float)(this.width - 8)), this.y, 0, 66, 4, 20);
this.drawTexturedModalRect(this.x + (int)(this.volume * (float)(this.width - 8)) + 4, this.y, 196, 66, 4, 20);
}
}
/**
* Returns true if the mouse has been pressed on this control. Equivalent of
* MouseListener.mousePressed(MouseEvent e).
*/
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY)
{
if (super.mousePressed(mc, mouseX, mouseY))
{
this.volume = (float)(mouseX - (this.x + 4)) / (float)(this.width - 8);
this.volume = MathHelper.clamp(this.volume, 0.0F, 1.0F);
mc.gameSettings.setSoundLevel(this.category, this.volume);
mc.gameSettings.saveOptions();
this.displayString = this.categoryName + ": " + GuiScreenOptionsSounds.this.getDisplayString(this.category);
this.pressed = true;
return true;
}
else
{
return false;
}
}
public void playPressSound(SoundHandler soundHandlerIn)
{
}
/**
* Fired when the mouse button is released. Equivalent of MouseListener.mouseReleased(MouseEvent e).
*/
public void mouseReleased(int mouseX, int mouseY)
{
if (this.pressed)
{
GuiScreenOptionsSounds.this.mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
}
this.pressed = false;
}
}
}

View File

@@ -0,0 +1,254 @@
package net.minecraft.client.gui;
import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.realms.RealmsButton;
import net.minecraft.realms.RealmsScreen;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiScreenRealmsProxy extends GuiScreen
{
private final RealmsScreen proxy;
public GuiScreenRealmsProxy(RealmsScreen proxyIn)
{
this.proxy = proxyIn;
this.buttonList = Collections.<GuiButton>synchronizedList(Lists.newArrayList());
}
public RealmsScreen getProxy()
{
return this.proxy;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.proxy.init();
super.initGui();
}
public void drawCenteredString(String text, int x, int y, int color)
{
super.drawCenteredString(this.fontRenderer, text, x, y, color);
}
public void drawString(String text, int x, int y, int color, boolean p_154322_5_)
{
if (p_154322_5_)
{
super.drawString(this.fontRenderer, text, x, y, color);
}
else
{
this.fontRenderer.drawString(text, x, y, color);
}
}
/**
* Draws a textured rectangle at the current z-value.
*/
public void drawTexturedModalRect(int x, int y, int textureX, int textureY, int width, int height)
{
this.proxy.blit(x, y, textureX, textureY, width, height);
super.drawTexturedModalRect(x, y, textureX, textureY, width, height);
}
/**
* Draws a rectangle with a vertical gradient between the specified colors (ARGB format). Args : x1, y1, x2, y2,
* topColor, bottomColor
*/
public void drawGradientRect(int left, int top, int right, int bottom, int startColor, int endColor)
{
super.drawGradientRect(left, top, right, bottom, startColor, endColor);
}
/**
* Draws either a gradient over the background screen (when it exists) or a flat gradient over background.png
*/
public void drawDefaultBackground()
{
super.drawDefaultBackground();
}
/**
* Returns true if this GUI should pause the game when it is displayed in single-player
*/
public boolean doesGuiPauseGame()
{
return super.doesGuiPauseGame();
}
public void drawWorldBackground(int tint)
{
super.drawWorldBackground(tint);
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.proxy.render(mouseX, mouseY, partialTicks);
}
public void renderToolTip(ItemStack stack, int x, int y)
{
super.renderToolTip(stack, x, y);
}
/**
* Draws the given text as a tooltip.
*/
public void drawHoveringText(String text, int x, int y)
{
super.drawHoveringText(text, x, y);
}
/**
* Draws a List of strings as a tooltip. Every entry is drawn on a seperate line.
*/
public void drawHoveringText(List<String> textLines, int x, int y)
{
super.drawHoveringText(textLines, x, y);
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
this.proxy.tick();
super.updateScreen();
}
public int getFontHeight()
{
return this.fontRenderer.FONT_HEIGHT;
}
public int getStringWidth(String text)
{
return this.fontRenderer.getStringWidth(text);
}
public void fontDrawShadow(String text, int x, int y, int color)
{
this.fontRenderer.drawStringWithShadow(text, (float)x, (float)y, color);
}
public List<String> fontSplit(String text, int wrapWidth)
{
return this.fontRenderer.listFormattedStringToWidth(text, wrapWidth);
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
public final void actionPerformed(GuiButton button) throws IOException
{
this.proxy.buttonClicked(((GuiButtonRealmsProxy)button).getRealmsButton());
}
public void buttonsClear()
{
this.buttonList.clear();
}
public void buttonsAdd(RealmsButton button)
{
this.buttonList.add(button.getProxy());
}
public List<RealmsButton> buttons()
{
List<RealmsButton> list = Lists.<RealmsButton>newArrayListWithExpectedSize(this.buttonList.size());
for (GuiButton guibutton : this.buttonList)
{
list.add(((GuiButtonRealmsProxy)guibutton).getRealmsButton());
}
return list;
}
public void buttonsRemove(RealmsButton button)
{
this.buttonList.remove(button.getProxy());
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
this.proxy.mouseClicked(mouseX, mouseY, mouseButton);
super.mouseClicked(mouseX, mouseY, mouseButton);
}
/**
* Handles mouse input.
*/
public void handleMouseInput() throws IOException
{
this.proxy.mouseEvent();
super.handleMouseInput();
}
/**
* Handles keyboard input.
*/
public void handleKeyboardInput() throws IOException
{
this.proxy.keyboardEvent();
super.handleKeyboardInput();
}
/**
* Called when a mouse button is released.
*/
public void mouseReleased(int mouseX, int mouseY, int state)
{
this.proxy.mouseReleased(mouseX, mouseY, state);
}
/**
* Called when a mouse button is pressed and the mouse is moved around. Parameters are : mouseX, mouseY,
* lastButtonClicked & timeSinceMouseClick.
*/
public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick)
{
this.proxy.mouseDragged(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
public void keyTyped(char typedChar, int keyCode) throws IOException
{
this.proxy.keyPressed(typedChar, keyCode);
}
public void confirmClicked(boolean result, int id)
{
this.proxy.confirmResult(result, id);
}
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
this.proxy.removed();
super.onGuiClosed();
}
}

View File

@@ -0,0 +1,211 @@
package net.minecraft.client.gui;
import com.google.common.collect.Lists;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.resources.ResourcePackListEntry;
import net.minecraft.client.resources.ResourcePackListEntryDefault;
import net.minecraft.client.resources.ResourcePackListEntryFound;
import net.minecraft.client.resources.ResourcePackListEntryServer;
import net.minecraft.client.resources.ResourcePackRepository;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiScreenResourcePacks extends GuiScreen
{
private final GuiScreen parentScreen;
/** List of available resource packs */
private List<ResourcePackListEntry> availableResourcePacks;
/** List of selected resource packs */
private List<ResourcePackListEntry> selectedResourcePacks;
/** List component that contains the available resource packs */
private GuiResourcePackAvailable availableResourcePacksList;
/** List component that contains the selected resource packs */
private GuiResourcePackSelected selectedResourcePacksList;
private boolean changed;
public GuiScreenResourcePacks(GuiScreen parentScreenIn)
{
this.parentScreen = parentScreenIn;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.buttonList.add(new GuiOptionButton(2, this.width / 2 - 154, this.height - 48, I18n.format("resourcePack.openFolder")));
this.buttonList.add(new GuiOptionButton(1, this.width / 2 + 4, this.height - 48, I18n.format("gui.done")));
if (!this.changed)
{
this.availableResourcePacks = Lists.<ResourcePackListEntry>newArrayList();
this.selectedResourcePacks = Lists.<ResourcePackListEntry>newArrayList();
ResourcePackRepository resourcepackrepository = this.mc.getResourcePackRepository();
resourcepackrepository.updateRepositoryEntriesAll();
List<ResourcePackRepository.Entry> list = Lists.newArrayList(resourcepackrepository.getRepositoryEntriesAll());
list.removeAll(resourcepackrepository.getRepositoryEntries());
for (ResourcePackRepository.Entry resourcepackrepository$entry : list)
{
this.availableResourcePacks.add(new ResourcePackListEntryFound(this, resourcepackrepository$entry));
}
ResourcePackRepository.Entry resourcepackrepository$entry2 = resourcepackrepository.getResourcePackEntry();
if (resourcepackrepository$entry2 != null)
{
this.selectedResourcePacks.add(new ResourcePackListEntryServer(this, resourcepackrepository.getServerResourcePack()));
}
for (ResourcePackRepository.Entry resourcepackrepository$entry1 : Lists.reverse(resourcepackrepository.getRepositoryEntries()))
{
this.selectedResourcePacks.add(new ResourcePackListEntryFound(this, resourcepackrepository$entry1));
}
this.selectedResourcePacks.add(new ResourcePackListEntryDefault(this));
}
this.availableResourcePacksList = new GuiResourcePackAvailable(this.mc, 200, this.height, this.availableResourcePacks);
this.availableResourcePacksList.setSlotXBoundsFromLeft(this.width / 2 - 4 - 200);
this.availableResourcePacksList.registerScrollButtons(7, 8);
this.selectedResourcePacksList = new GuiResourcePackSelected(this.mc, 200, this.height, this.selectedResourcePacks);
this.selectedResourcePacksList.setSlotXBoundsFromLeft(this.width / 2 + 4);
this.selectedResourcePacksList.registerScrollButtons(7, 8);
}
/**
* Handles mouse input.
*/
public void handleMouseInput() throws IOException
{
super.handleMouseInput();
this.selectedResourcePacksList.handleMouseInput();
this.availableResourcePacksList.handleMouseInput();
}
public boolean hasResourcePackEntry(ResourcePackListEntry resourcePackEntry)
{
return this.selectedResourcePacks.contains(resourcePackEntry);
}
/**
* Returns the list containing the resource pack entry, returns the selected list if it is selected, otherwise
* returns the available list
*/
public List<ResourcePackListEntry> getListContaining(ResourcePackListEntry resourcePackEntry)
{
return this.hasResourcePackEntry(resourcePackEntry) ? this.selectedResourcePacks : this.availableResourcePacks;
}
/**
* Returns a list containing the available resource packs
*/
public List<ResourcePackListEntry> getAvailableResourcePacks()
{
return this.availableResourcePacks;
}
/**
* Returns a list containing the selected resource packs
*/
public List<ResourcePackListEntry> getSelectedResourcePacks()
{
return this.selectedResourcePacks;
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.enabled)
{
if (button.id == 2)
{
File file1 = this.mc.getResourcePackRepository().getDirResourcepacks();
OpenGlHelper.openFile(file1);
}
else if (button.id == 1)
{
if (this.changed)
{
List<ResourcePackRepository.Entry> list = Lists.<ResourcePackRepository.Entry>newArrayList();
for (ResourcePackListEntry resourcepacklistentry : this.selectedResourcePacks)
{
if (resourcepacklistentry instanceof ResourcePackListEntryFound)
{
list.add(((ResourcePackListEntryFound)resourcepacklistentry).getResourcePackEntry());
}
}
Collections.reverse(list);
this.mc.getResourcePackRepository().setRepositories(list);
this.mc.gameSettings.resourcePacks.clear();
this.mc.gameSettings.incompatibleResourcePacks.clear();
for (ResourcePackRepository.Entry resourcepackrepository$entry : list)
{
this.mc.gameSettings.resourcePacks.add(resourcepackrepository$entry.getResourcePackName());
if (resourcepackrepository$entry.getPackFormat() != 3)
{
this.mc.gameSettings.incompatibleResourcePacks.add(resourcepackrepository$entry.getResourcePackName());
}
}
this.mc.gameSettings.saveOptions();
this.mc.refreshResources();
}
this.mc.displayGuiScreen(this.parentScreen);
}
}
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
super.mouseClicked(mouseX, mouseY, mouseButton);
this.availableResourcePacksList.mouseClicked(mouseX, mouseY, mouseButton);
this.selectedResourcePacksList.mouseClicked(mouseX, mouseY, mouseButton);
}
/**
* Called when a mouse button is released.
*/
protected void mouseReleased(int mouseX, int mouseY, int state)
{
super.mouseReleased(mouseX, mouseY, state);
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawBackground(0);
this.availableResourcePacksList.drawScreen(mouseX, mouseY, partialTicks);
this.selectedResourcePacksList.drawScreen(mouseX, mouseY, partialTicks);
this.drawCenteredString(this.fontRenderer, I18n.format("resourcePack.title"), this.width / 2, 16, 16777215);
this.drawCenteredString(this.fontRenderer, I18n.format("resourcePack.folderInfo"), this.width / 2 - 77, this.height - 26, 8421504);
super.drawScreen(mouseX, mouseY, partialTicks);
}
/**
* Marks the selected resource packs list as changed to trigger a resource reload when the screen is closed
*/
public void markChanged()
{
this.changed = true;
}
}

View File

@@ -0,0 +1,113 @@
package net.minecraft.client.gui;
import java.io.IOException;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.input.Keyboard;
@SideOnly(Side.CLIENT)
public class GuiScreenServerList extends GuiScreen
{
private final GuiScreen lastScreen;
private final ServerData serverData;
private GuiTextField ipEdit;
public GuiScreenServerList(GuiScreen lastScreenIn, ServerData serverDataIn)
{
this.lastScreen = lastScreenIn;
this.serverData = serverDataIn;
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
this.ipEdit.updateCursorCounter();
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
Keyboard.enableRepeatEvents(true);
this.buttonList.clear();
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, I18n.format("selectServer.select")));
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, I18n.format("gui.cancel")));
this.ipEdit = new GuiTextField(2, this.fontRenderer, this.width / 2 - 100, 116, 200, 20);
this.ipEdit.setMaxStringLength(128);
this.ipEdit.setFocused(true);
this.ipEdit.setText(this.mc.gameSettings.lastServer);
(this.buttonList.get(0)).enabled = !this.ipEdit.getText().isEmpty() && this.ipEdit.getText().split(":").length > 0;
}
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
Keyboard.enableRepeatEvents(false);
this.mc.gameSettings.lastServer = this.ipEdit.getText();
this.mc.gameSettings.saveOptions();
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.enabled)
{
if (button.id == 1)
{
this.lastScreen.confirmClicked(false, 0);
}
else if (button.id == 0)
{
this.serverData.serverIP = this.ipEdit.getText();
this.lastScreen.confirmClicked(true, 0);
}
}
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
if (this.ipEdit.textboxKeyTyped(typedChar, keyCode))
{
(this.buttonList.get(0)).enabled = !this.ipEdit.getText().isEmpty() && this.ipEdit.getText().split(":").length > 0;
}
else if (keyCode == 28 || keyCode == 156)
{
this.actionPerformed(this.buttonList.get(0));
}
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
super.mouseClicked(mouseX, mouseY, mouseButton);
this.ipEdit.mouseClicked(mouseX, mouseY, mouseButton);
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, I18n.format("selectServer.direct"), this.width / 2, 20, 16777215);
this.drawString(this.fontRenderer, I18n.format("addServer.enterIp"), this.width / 2 - 100, 100, 10526880);
this.ipEdit.drawTextBox();
super.drawScreen(mouseX, mouseY, partialTicks);
}
}

View File

@@ -0,0 +1,75 @@
package net.minecraft.client.gui;
import net.minecraft.util.IProgressUpdate;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiScreenWorking extends GuiScreen implements IProgressUpdate
{
private String title = "";
private String stage = "";
private int progress;
private boolean doneWorking;
/**
* Shows the 'Saving level' string.
*/
public void displaySavingString(String message)
{
this.resetProgressAndMessage(message);
}
/**
* this string, followed by "working..." and then the "% complete" are the 3 lines shown. This resets progress to 0,
* and the WorkingString to "working...".
*/
public void resetProgressAndMessage(String message)
{
this.title = message;
this.displayLoadingString("Working...");
}
/**
* Displays a string on the loading screen supposed to indicate what is being done currently.
*/
public void displayLoadingString(String message)
{
this.stage = message;
this.setLoadingProgress(0);
}
/**
* Updates the progress bar on the loading screen to the specified amount.
*/
public void setLoadingProgress(int progress)
{
this.progress = progress;
}
public void setDoneWorking()
{
this.doneWorking = true;
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
if (this.doneWorking)
{
if (!this.mc.isConnectedToRealms())
{
this.mc.displayGuiScreen((GuiScreen)null);
}
}
else
{
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, this.title, this.width / 2, 70, 16777215);
this.drawCenteredString(this.fontRenderer, this.stage + " " + this.progress + "%", this.width / 2, 90, 16777215);
super.drawScreen(mouseX, mouseY, partialTicks);
}
}
}

View File

@@ -0,0 +1,119 @@
package net.minecraft.client.gui;
import java.io.IOException;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.GameType;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiShareToLan extends GuiScreen
{
private final GuiScreen lastScreen;
private GuiButton allowCheatsButton;
private GuiButton gameModeButton;
private String gameMode = "survival";
private boolean allowCheats;
public GuiShareToLan(GuiScreen lastScreenIn)
{
this.lastScreen = lastScreenIn;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.buttonList.clear();
this.buttonList.add(new GuiButton(101, this.width / 2 - 155, this.height - 28, 150, 20, I18n.format("lanServer.start")));
this.buttonList.add(new GuiButton(102, this.width / 2 + 5, this.height - 28, 150, 20, I18n.format("gui.cancel")));
this.gameModeButton = this.addButton(new GuiButton(104, this.width / 2 - 155, 100, 150, 20, I18n.format("selectWorld.gameMode")));
this.allowCheatsButton = this.addButton(new GuiButton(103, this.width / 2 + 5, 100, 150, 20, I18n.format("selectWorld.allowCommands")));
this.updateDisplayNames();
}
private void updateDisplayNames()
{
this.gameModeButton.displayString = I18n.format("selectWorld.gameMode") + ": " + I18n.format("selectWorld.gameMode." + this.gameMode);
this.allowCheatsButton.displayString = I18n.format("selectWorld.allowCommands") + " ";
if (this.allowCheats)
{
this.allowCheatsButton.displayString = this.allowCheatsButton.displayString + I18n.format("options.on");
}
else
{
this.allowCheatsButton.displayString = this.allowCheatsButton.displayString + I18n.format("options.off");
}
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.id == 102)
{
this.mc.displayGuiScreen(this.lastScreen);
}
else if (button.id == 104)
{
if ("spectator".equals(this.gameMode))
{
this.gameMode = "creative";
}
else if ("creative".equals(this.gameMode))
{
this.gameMode = "adventure";
}
else if ("adventure".equals(this.gameMode))
{
this.gameMode = "survival";
}
else
{
this.gameMode = "spectator";
}
this.updateDisplayNames();
}
else if (button.id == 103)
{
this.allowCheats = !this.allowCheats;
this.updateDisplayNames();
}
else if (button.id == 101)
{
this.mc.displayGuiScreen((GuiScreen)null);
String s = this.mc.getIntegratedServer().shareToLAN(GameType.getByName(this.gameMode), this.allowCheats);
ITextComponent itextcomponent;
if (s != null)
{
itextcomponent = new TextComponentTranslation("commands.publish.started", new Object[] {s});
}
else
{
itextcomponent = new TextComponentString("commands.publish.failed");
}
this.mc.ingameGUI.getChatGUI().printChatMessage(itextcomponent);
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, I18n.format("lanServer.title"), this.width / 2, 50, 16777215);
this.drawCenteredString(this.fontRenderer, I18n.format("lanServer.otherPlayers"), this.width / 2, 82, 16777215);
super.drawScreen(mouseX, mouseY, partialTicks);
}
}

View File

@@ -0,0 +1,159 @@
package net.minecraft.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.realms.RealmsSimpleScrolledSelectionList;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiSimpleScrolledSelectionListProxy extends GuiSlot
{
private final RealmsSimpleScrolledSelectionList realmsScrolledSelectionList;
public GuiSimpleScrolledSelectionListProxy(RealmsSimpleScrolledSelectionList realmsScrolledSelectionListIn, int widthIn, int heightIn, int topIn, int bottomIn, int slotHeightIn)
{
super(Minecraft.getMinecraft(), widthIn, heightIn, topIn, bottomIn, slotHeightIn);
this.realmsScrolledSelectionList = realmsScrolledSelectionListIn;
}
protected int getSize()
{
return this.realmsScrolledSelectionList.getItemCount();
}
/**
* The element in the slot that was clicked, boolean for whether it was double clicked or not
*/
protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY)
{
this.realmsScrolledSelectionList.selectItem(slotIndex, isDoubleClick, mouseX, mouseY);
}
/**
* Returns true if the element passed in is currently selected
*/
protected boolean isSelected(int slotIndex)
{
return this.realmsScrolledSelectionList.isSelectedItem(slotIndex);
}
protected void drawBackground()
{
this.realmsScrolledSelectionList.renderBackground();
}
protected void drawSlot(int slotIndex, int xPos, int yPos, int heightIn, int mouseXIn, int mouseYIn, float partialTicks)
{
this.realmsScrolledSelectionList.renderItem(slotIndex, xPos, yPos, heightIn, mouseXIn, mouseYIn);
}
public int getWidth()
{
return this.width;
}
public int getMouseY()
{
return this.mouseY;
}
public int getMouseX()
{
return this.mouseX;
}
/**
* Return the height of the content being scrolled
*/
protected int getContentHeight()
{
return this.realmsScrolledSelectionList.getMaxPosition();
}
protected int getScrollBarX()
{
return this.realmsScrolledSelectionList.getScrollbarPosition();
}
public void handleMouseInput()
{
super.handleMouseInput();
}
public void drawScreen(int mouseXIn, int mouseYIn, float partialTicks)
{
if (this.visible)
{
this.mouseX = mouseXIn;
this.mouseY = mouseYIn;
this.drawBackground();
int i = this.getScrollBarX();
int j = i + 6;
this.bindAmountScrolled();
GlStateManager.disableLighting();
GlStateManager.disableFog();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
int k = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
int l = this.top + 4 - (int)this.amountScrolled;
if (this.hasListHeader)
{
this.drawListHeader(k, l, tessellator);
}
this.drawSelectionBox(k, l, mouseXIn, mouseYIn, partialTicks);
GlStateManager.disableDepth();
this.overlayBackground(0, this.top, 255, 255);
this.overlayBackground(this.bottom, this.height, 255, 255);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ZERO, GlStateManager.DestFactor.ONE);
GlStateManager.disableAlpha();
GlStateManager.shadeModel(7425);
GlStateManager.disableTexture2D();
int i1 = this.getMaxScroll();
if (i1 > 0)
{
int j1 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight();
j1 = MathHelper.clamp(j1, 32, this.bottom - this.top - 8);
int k1 = (int)this.amountScrolled * (this.bottom - this.top - j1) / i1 + this.top;
if (k1 < this.top)
{
k1 = this.top;
}
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
bufferbuilder.pos((double)i, (double)this.bottom, 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex();
bufferbuilder.pos((double)j, (double)this.bottom, 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
bufferbuilder.pos((double)j, (double)this.top, 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex();
bufferbuilder.pos((double)i, (double)this.top, 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex();
tessellator.draw();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
bufferbuilder.pos((double)i, (double)(k1 + j1), 0.0D).tex(0.0D, 1.0D).color(128, 128, 128, 255).endVertex();
bufferbuilder.pos((double)j, (double)(k1 + j1), 0.0D).tex(1.0D, 1.0D).color(128, 128, 128, 255).endVertex();
bufferbuilder.pos((double)j, (double)k1, 0.0D).tex(1.0D, 0.0D).color(128, 128, 128, 255).endVertex();
bufferbuilder.pos((double)i, (double)k1, 0.0D).tex(0.0D, 0.0D).color(128, 128, 128, 255).endVertex();
tessellator.draw();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
bufferbuilder.pos((double)i, (double)(k1 + j1 - 1), 0.0D).tex(0.0D, 1.0D).color(192, 192, 192, 255).endVertex();
bufferbuilder.pos((double)(j - 1), (double)(k1 + j1 - 1), 0.0D).tex(1.0D, 1.0D).color(192, 192, 192, 255).endVertex();
bufferbuilder.pos((double)(j - 1), (double)k1, 0.0D).tex(1.0D, 0.0D).color(192, 192, 192, 255).endVertex();
bufferbuilder.pos((double)i, (double)k1, 0.0D).tex(0.0D, 0.0D).color(192, 192, 192, 255).endVertex();
tessellator.draw();
}
this.renderDecorations(mouseXIn, mouseYIn);
GlStateManager.enableTexture2D();
GlStateManager.shadeModel(7424);
GlStateManager.enableAlpha();
GlStateManager.disableBlend();
}
}
}

View File

@@ -0,0 +1,71 @@
package net.minecraft.client.gui;
import java.io.IOException;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.client.resources.I18n;
import net.minecraft.network.play.client.CPacketEntityAction;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiSleepMP extends GuiChat
{
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
super.initGui();
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height - 40, I18n.format("multiplayer.stopSleeping")));
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
if (keyCode == 1)
{
this.wakeFromSleep();
}
else if (keyCode != 28 && keyCode != 156)
{
super.keyTyped(typedChar, keyCode);
}
else
{
String s = this.inputField.getText().trim();
if (!s.isEmpty())
{
this.sendChatMessage(s); // Forge: fix vanilla not adding messages to the sent list while sleeping
}
this.inputField.setText("");
this.mc.ingameGUI.getChatGUI().resetScroll();
}
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.id == 1)
{
this.wakeFromSleep();
}
else
{
super.actionPerformed(button);
}
}
private void wakeFromSleep()
{
NetHandlerPlayClient nethandlerplayclient = this.mc.player.connection;
nethandlerplayclient.sendPacket(new CPacketEntityAction(this.mc.player, CPacketEntityAction.Action.STOP_SLEEPING));
}
}

View File

@@ -0,0 +1,167 @@
package net.minecraft.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiSlider extends GuiButton
{
private float sliderPosition = 1.0F;
public boolean isMouseDown;
private final String name;
private final float min;
private final float max;
private final GuiPageButtonList.GuiResponder responder;
private GuiSlider.FormatHelper formatHelper;
public GuiSlider(GuiPageButtonList.GuiResponder guiResponder, int idIn, int x, int y, String nameIn, float minIn, float maxIn, float defaultValue, GuiSlider.FormatHelper formatter)
{
super(idIn, x, y, 150, 20, "");
this.name = nameIn;
this.min = minIn;
this.max = maxIn;
this.sliderPosition = (defaultValue - minIn) / (maxIn - minIn);
this.formatHelper = formatter;
this.responder = guiResponder;
this.displayString = this.getDisplayString();
}
/**
* Gets the value of the slider.
* @return A value that will under normal circumstances be between the slider's {@link #min} and {@link #max}
* values, unless it was manually set out of that range.
*/
public float getSliderValue()
{
return this.min + (this.max - this.min) * this.sliderPosition;
}
/**
* Sets the slider's value, optionally notifying the associated {@linkplain GuiPageButtonList.GuiResponder
* responder} of the change.
*/
public void setSliderValue(float value, boolean notifyResponder)
{
this.sliderPosition = (value - this.min) / (this.max - this.min);
this.displayString = this.getDisplayString();
if (notifyResponder)
{
this.responder.setEntryValue(this.id, this.getSliderValue());
}
}
/**
* Gets the slider's position.
* @return The position of the slider, which will under normal circumstances be between 0 and 1, unless it was
* manually set out of that range.
*/
public float getSliderPosition()
{
return this.sliderPosition;
}
private String getDisplayString()
{
return this.formatHelper == null ? I18n.format(this.name) + ": " + this.getSliderValue() : this.formatHelper.getText(this.id, I18n.format(this.name), this.getSliderValue());
}
/**
* Returns 0 if the button is disabled, 1 if the mouse is NOT hovering over this button and 2 if it IS hovering over
* this button.
*/
protected int getHoverState(boolean mouseOver)
{
return 0;
}
/**
* Fired when the mouse button is dragged. Equivalent of MouseListener.mouseDragged(MouseEvent e).
*/
protected void mouseDragged(Minecraft mc, int mouseX, int mouseY)
{
if (this.visible)
{
if (this.isMouseDown)
{
this.sliderPosition = (float)(mouseX - (this.x + 4)) / (float)(this.width - 8);
if (this.sliderPosition < 0.0F)
{
this.sliderPosition = 0.0F;
}
if (this.sliderPosition > 1.0F)
{
this.sliderPosition = 1.0F;
}
this.displayString = this.getDisplayString();
this.responder.setEntryValue(this.id, this.getSliderValue());
}
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(this.x + (int)(this.sliderPosition * (float)(this.width - 8)), this.y, 0, 66, 4, 20);
this.drawTexturedModalRect(this.x + (int)(this.sliderPosition * (float)(this.width - 8)) + 4, this.y, 196, 66, 4, 20);
}
}
/**
* Sets the position of the slider and notifies the associated {@linkplain GuiPageButtonList.GuiResponder responder}
* of the change
*/
public void setSliderPosition(float position)
{
this.sliderPosition = position;
this.displayString = this.getDisplayString();
this.responder.setEntryValue(this.id, this.getSliderValue());
}
/**
* Returns true if the mouse has been pressed on this control. Equivalent of MouseListener.mousePressed(MouseEvent
* e).
*/
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY)
{
if (super.mousePressed(mc, mouseX, mouseY))
{
this.sliderPosition = (float)(mouseX - (this.x + 4)) / (float)(this.width - 8);
if (this.sliderPosition < 0.0F)
{
this.sliderPosition = 0.0F;
}
if (this.sliderPosition > 1.0F)
{
this.sliderPosition = 1.0F;
}
this.displayString = this.getDisplayString();
this.responder.setEntryValue(this.id, this.getSliderValue());
this.isMouseDown = true;
return true;
}
else
{
return false;
}
}
/**
* Fired when the mouse button is released. Equivalent of MouseListener.mouseReleased(MouseEvent e).
*/
public void mouseReleased(int mouseX, int mouseY)
{
this.isMouseDown = false;
}
@SideOnly(Side.CLIENT)
public interface FormatHelper
{
String getText(int id, String name, float value);
}
}

View File

@@ -0,0 +1,522 @@
package net.minecraft.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.input.Mouse;
@SideOnly(Side.CLIENT)
public abstract class GuiSlot
{
protected final Minecraft mc;
public int width;
public int height;
/** The top of the slot container. Affects the overlays and scrolling. */
public int top;
/** The bottom of the slot container. Affects the overlays and scrolling. */
public int bottom;
public int right;
public int left;
/** The height of a slot. */
public final int slotHeight;
/** The buttonID of the button used to scroll up */
private int scrollUpButtonID;
/** The buttonID of the button used to scroll down */
private int scrollDownButtonID;
protected int mouseX;
protected int mouseY;
protected boolean centerListVertically = true;
/** Where the mouse was in the window when you first clicked to scroll */
protected int initialClickY = -2;
/**
* What to multiply the amount you moved your mouse by (used for slowing down scrolling when over the items and not
* on the scroll bar)
*/
protected float scrollMultiplier;
/** How far down this slot has been scrolled */
protected float amountScrolled;
/** The element in the list that was selected */
protected int selectedElement = -1;
/** The time when this button was last clicked. */
protected long lastClicked;
protected boolean visible = true;
/** Set to true if a selected element in this gui will show an outline box */
protected boolean showSelectionBox = true;
protected boolean hasListHeader;
public int headerPadding;
private boolean enabled = true;
public GuiSlot(Minecraft mcIn, int width, int height, int topIn, int bottomIn, int slotHeightIn)
{
this.mc = mcIn;
this.width = width;
this.height = height;
this.top = topIn;
this.bottom = bottomIn;
this.slotHeight = slotHeightIn;
this.left = 0;
this.right = width;
}
public void setDimensions(int widthIn, int heightIn, int topIn, int bottomIn)
{
this.width = widthIn;
this.height = heightIn;
this.top = topIn;
this.bottom = bottomIn;
this.left = 0;
this.right = widthIn;
}
public void setShowSelectionBox(boolean showSelectionBoxIn)
{
this.showSelectionBox = showSelectionBoxIn;
}
/**
* Sets hasListHeader and headerHeight. Params: hasListHeader, headerHeight. If hasListHeader is false headerHeight
* is set to 0.
*/
protected void setHasListHeader(boolean hasListHeaderIn, int headerPaddingIn)
{
this.hasListHeader = hasListHeaderIn;
this.headerPadding = headerPaddingIn;
if (!hasListHeaderIn)
{
this.headerPadding = 0;
}
}
protected abstract int getSize();
/**
* The element in the slot that was clicked, boolean for whether it was double clicked or not
*/
protected abstract void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY);
/**
* Returns true if the element passed in is currently selected
*/
protected abstract boolean isSelected(int slotIndex);
/**
* Return the height of the content being scrolled
*/
protected int getContentHeight()
{
return this.getSize() * this.slotHeight + this.headerPadding;
}
protected abstract void drawBackground();
protected void updateItemPos(int entryID, int insideLeft, int yPos, float partialTicks)
{
}
protected abstract void drawSlot(int slotIndex, int xPos, int yPos, int heightIn, int mouseXIn, int mouseYIn, float partialTicks);
/**
* Handles drawing a list's header row.
*/
protected void drawListHeader(int insideLeft, int insideTop, Tessellator tessellatorIn)
{
}
protected void clickedHeader(int p_148132_1_, int p_148132_2_)
{
}
protected void renderDecorations(int mouseXIn, int mouseYIn)
{
}
public int getSlotIndexFromScreenCoords(int posX, int posY)
{
int i = this.left + this.width / 2 - this.getListWidth() / 2;
int j = this.left + this.width / 2 + this.getListWidth() / 2;
int k = posY - this.top - this.headerPadding + (int)this.amountScrolled - 4;
int l = k / this.slotHeight;
return posX < this.getScrollBarX() && posX >= i && posX <= j && l >= 0 && k >= 0 && l < this.getSize() ? l : -1;
}
/**
* Registers the IDs that can be used for the scrollbar's up/down buttons.
*/
public void registerScrollButtons(int scrollUpButtonIDIn, int scrollDownButtonIDIn)
{
this.scrollUpButtonID = scrollUpButtonIDIn;
this.scrollDownButtonID = scrollDownButtonIDIn;
}
/**
* Stop the thing from scrolling out of bounds
*/
protected void bindAmountScrolled()
{
this.amountScrolled = MathHelper.clamp(this.amountScrolled, 0.0F, (float)this.getMaxScroll());
}
public int getMaxScroll()
{
return Math.max(0, this.getContentHeight() - (this.bottom - this.top - 4));
}
/**
* Returns the amountScrolled field as an integer.
*/
public int getAmountScrolled()
{
return (int)this.amountScrolled;
}
public boolean isMouseYWithinSlotBounds(int p_148141_1_)
{
return p_148141_1_ >= this.top && p_148141_1_ <= this.bottom && this.mouseX >= this.left && this.mouseX <= this.right;
}
/**
* Scrolls the slot by the given amount. A positive value scrolls down, and a negative value scrolls up.
*/
public void scrollBy(int amount)
{
this.amountScrolled += (float)amount;
this.bindAmountScrolled();
this.initialClickY = -2;
}
public void actionPerformed(GuiButton button)
{
if (button.enabled)
{
if (button.id == this.scrollUpButtonID)
{
this.amountScrolled -= (float)(this.slotHeight * 2 / 3);
this.initialClickY = -2;
this.bindAmountScrolled();
}
else if (button.id == this.scrollDownButtonID)
{
this.amountScrolled += (float)(this.slotHeight * 2 / 3);
this.initialClickY = -2;
this.bindAmountScrolled();
}
}
}
public void drawScreen(int mouseXIn, int mouseYIn, float partialTicks)
{
if (this.visible)
{
this.mouseX = mouseXIn;
this.mouseY = mouseYIn;
this.drawBackground();
int i = this.getScrollBarX();
int j = i + 6;
this.bindAmountScrolled();
GlStateManager.disableLighting();
GlStateManager.disableFog();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
// Forge: background rendering moved into separate method.
this.drawContainerBackground(tessellator);
int k = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
int l = this.top + 4 - (int)this.amountScrolled;
if (this.hasListHeader)
{
this.drawListHeader(k, l, tessellator);
}
this.drawSelectionBox(k, l, mouseXIn, mouseYIn, partialTicks);
GlStateManager.disableDepth();
this.overlayBackground(0, this.top, 255, 255);
this.overlayBackground(this.bottom, this.height, 255, 255);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ZERO, GlStateManager.DestFactor.ONE);
GlStateManager.disableAlpha();
GlStateManager.shadeModel(7425);
GlStateManager.disableTexture2D();
int i1 = 4;
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
bufferbuilder.pos((double)this.left, (double)(this.top + 4), 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 0).endVertex();
bufferbuilder.pos((double)this.right, (double)(this.top + 4), 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 0).endVertex();
bufferbuilder.pos((double)this.right, (double)this.top, 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex();
bufferbuilder.pos((double)this.left, (double)this.top, 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex();
tessellator.draw();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
bufferbuilder.pos((double)this.left, (double)this.bottom, 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex();
bufferbuilder.pos((double)this.right, (double)this.bottom, 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
bufferbuilder.pos((double)this.right, (double)(this.bottom - 4), 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 0).endVertex();
bufferbuilder.pos((double)this.left, (double)(this.bottom - 4), 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 0).endVertex();
tessellator.draw();
int j1 = this.getMaxScroll();
if (j1 > 0)
{
int k1 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight();
k1 = MathHelper.clamp(k1, 32, this.bottom - this.top - 8);
int l1 = (int)this.amountScrolled * (this.bottom - this.top - k1) / j1 + this.top;
if (l1 < this.top)
{
l1 = this.top;
}
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
bufferbuilder.pos((double)i, (double)this.bottom, 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex();
bufferbuilder.pos((double)j, (double)this.bottom, 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
bufferbuilder.pos((double)j, (double)this.top, 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex();
bufferbuilder.pos((double)i, (double)this.top, 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex();
tessellator.draw();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
bufferbuilder.pos((double)i, (double)(l1 + k1), 0.0D).tex(0.0D, 1.0D).color(128, 128, 128, 255).endVertex();
bufferbuilder.pos((double)j, (double)(l1 + k1), 0.0D).tex(1.0D, 1.0D).color(128, 128, 128, 255).endVertex();
bufferbuilder.pos((double)j, (double)l1, 0.0D).tex(1.0D, 0.0D).color(128, 128, 128, 255).endVertex();
bufferbuilder.pos((double)i, (double)l1, 0.0D).tex(0.0D, 0.0D).color(128, 128, 128, 255).endVertex();
tessellator.draw();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
bufferbuilder.pos((double)i, (double)(l1 + k1 - 1), 0.0D).tex(0.0D, 1.0D).color(192, 192, 192, 255).endVertex();
bufferbuilder.pos((double)(j - 1), (double)(l1 + k1 - 1), 0.0D).tex(1.0D, 1.0D).color(192, 192, 192, 255).endVertex();
bufferbuilder.pos((double)(j - 1), (double)l1, 0.0D).tex(1.0D, 0.0D).color(192, 192, 192, 255).endVertex();
bufferbuilder.pos((double)i, (double)l1, 0.0D).tex(0.0D, 0.0D).color(192, 192, 192, 255).endVertex();
tessellator.draw();
}
this.renderDecorations(mouseXIn, mouseYIn);
GlStateManager.enableTexture2D();
GlStateManager.shadeModel(7424);
GlStateManager.enableAlpha();
GlStateManager.disableBlend();
}
}
public void handleMouseInput()
{
if (this.isMouseYWithinSlotBounds(this.mouseY))
{
if (Mouse.getEventButton() == 0 && Mouse.getEventButtonState() && this.mouseY >= this.top && this.mouseY <= this.bottom)
{
int i = (this.width - this.getListWidth()) / 2;
int j = (this.width + this.getListWidth()) / 2;
int k = this.mouseY - this.top - this.headerPadding + (int)this.amountScrolled - 4;
int l = k / this.slotHeight;
if (l < this.getSize() && this.mouseX >= i && this.mouseX <= j && l >= 0 && k >= 0)
{
this.elementClicked(l, false, this.mouseX, this.mouseY);
this.selectedElement = l;
}
else if (this.mouseX >= i && this.mouseX <= j && k < 0)
{
this.clickedHeader(this.mouseX - i, this.mouseY - this.top + (int)this.amountScrolled - 4);
}
}
if (Mouse.isButtonDown(0) && this.getEnabled())
{
if (this.initialClickY == -1)
{
boolean flag1 = true;
if (this.mouseY >= this.top && this.mouseY <= this.bottom)
{
int j2 = (this.width - this.getListWidth()) / 2;
int k2 = (this.width + this.getListWidth()) / 2;
int l2 = this.mouseY - this.top - this.headerPadding + (int)this.amountScrolled - 4;
int i1 = l2 / this.slotHeight;
if (i1 < this.getSize() && this.mouseX >= j2 && this.mouseX <= k2 && i1 >= 0 && l2 >= 0)
{
boolean flag = i1 == this.selectedElement && Minecraft.getSystemTime() - this.lastClicked < 250L;
this.elementClicked(i1, flag, this.mouseX, this.mouseY);
this.selectedElement = i1;
this.lastClicked = Minecraft.getSystemTime();
}
else if (this.mouseX >= j2 && this.mouseX <= k2 && l2 < 0)
{
this.clickedHeader(this.mouseX - j2, this.mouseY - this.top + (int)this.amountScrolled - 4);
flag1 = false;
}
int i3 = this.getScrollBarX();
int j1 = i3 + 6;
if (this.mouseX >= i3 && this.mouseX <= j1)
{
this.scrollMultiplier = -1.0F;
int k1 = this.getMaxScroll();
if (k1 < 1)
{
k1 = 1;
}
int l1 = (int)((float)((this.bottom - this.top) * (this.bottom - this.top)) / (float)this.getContentHeight());
l1 = MathHelper.clamp(l1, 32, this.bottom - this.top - 8);
this.scrollMultiplier /= (float)(this.bottom - this.top - l1) / (float)k1;
}
else
{
this.scrollMultiplier = 1.0F;
}
if (flag1)
{
this.initialClickY = this.mouseY;
}
else
{
this.initialClickY = -2;
}
}
else
{
this.initialClickY = -2;
}
}
else if (this.initialClickY >= 0)
{
this.amountScrolled -= (float)(this.mouseY - this.initialClickY) * this.scrollMultiplier;
this.initialClickY = this.mouseY;
}
}
else
{
this.initialClickY = -1;
}
int i2 = Mouse.getEventDWheel();
if (i2 != 0)
{
if (i2 > 0)
{
i2 = -1;
}
else if (i2 < 0)
{
i2 = 1;
}
this.amountScrolled += (float)(i2 * this.slotHeight / 2);
}
}
}
public void setEnabled(boolean enabledIn)
{
this.enabled = enabledIn;
}
public boolean getEnabled()
{
return this.enabled;
}
/**
* Gets the width of the list
*/
public int getListWidth()
{
return 220;
}
/**
* Draws the selection box around the selected slot element.
*/
protected void drawSelectionBox(int insideLeft, int insideTop, int mouseXIn, int mouseYIn, float partialTicks)
{
int i = this.getSize();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
for (int j = 0; j < i; ++j)
{
int k = insideTop + j * this.slotHeight + this.headerPadding;
int l = this.slotHeight - 4;
if (k > this.bottom || k + l < this.top)
{
this.updateItemPos(j, insideLeft, k, partialTicks);
}
if (this.showSelectionBox && this.isSelected(j))
{
int i1 = this.left + (this.width / 2 - this.getListWidth() / 2);
int j1 = this.left + this.width / 2 + this.getListWidth() / 2;
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.disableTexture2D();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
bufferbuilder.pos((double)i1, (double)(k + l + 2), 0.0D).tex(0.0D, 1.0D).color(128, 128, 128, 255).endVertex();
bufferbuilder.pos((double)j1, (double)(k + l + 2), 0.0D).tex(1.0D, 1.0D).color(128, 128, 128, 255).endVertex();
bufferbuilder.pos((double)j1, (double)(k - 2), 0.0D).tex(1.0D, 0.0D).color(128, 128, 128, 255).endVertex();
bufferbuilder.pos((double)i1, (double)(k - 2), 0.0D).tex(0.0D, 0.0D).color(128, 128, 128, 255).endVertex();
bufferbuilder.pos((double)(i1 + 1), (double)(k + l + 1), 0.0D).tex(0.0D, 1.0D).color(0, 0, 0, 255).endVertex();
bufferbuilder.pos((double)(j1 - 1), (double)(k + l + 1), 0.0D).tex(1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
bufferbuilder.pos((double)(j1 - 1), (double)(k - 1), 0.0D).tex(1.0D, 0.0D).color(0, 0, 0, 255).endVertex();
bufferbuilder.pos((double)(i1 + 1), (double)(k - 1), 0.0D).tex(0.0D, 0.0D).color(0, 0, 0, 255).endVertex();
tessellator.draw();
GlStateManager.enableTexture2D();
}
this.drawSlot(j, insideLeft, k, l, mouseXIn, mouseYIn, partialTicks);
}
}
protected int getScrollBarX()
{
return this.width / 2 + 124;
}
/**
* Overlays the background to hide scrolled items
*/
protected void overlayBackground(int startY, int endY, int startAlpha, int endAlpha)
{
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
this.mc.getTextureManager().bindTexture(Gui.OPTIONS_BACKGROUND);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
float f = 32.0F;
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
bufferbuilder.pos((double)this.left, (double)endY, 0.0D).tex(0.0D, (double)((float)endY / 32.0F)).color(64, 64, 64, endAlpha).endVertex();
bufferbuilder.pos((double)(this.left + this.width), (double)endY, 0.0D).tex((double)((float)this.width / 32.0F), (double)((float)endY / 32.0F)).color(64, 64, 64, endAlpha).endVertex();
bufferbuilder.pos((double)(this.left + this.width), (double)startY, 0.0D).tex((double)((float)this.width / 32.0F), (double)((float)startY / 32.0F)).color(64, 64, 64, startAlpha).endVertex();
bufferbuilder.pos((double)this.left, (double)startY, 0.0D).tex(0.0D, (double)((float)startY / 32.0F)).color(64, 64, 64, startAlpha).endVertex();
tessellator.draw();
}
/**
* Sets the left and right bounds of the slot. Param is the left bound, right is calculated as left + width.
*/
public void setSlotXBoundsFromLeft(int leftIn)
{
this.left = leftIn;
this.right = leftIn + this.width;
}
public int getSlotHeight()
{
return this.slotHeight;
}
protected void drawContainerBackground(Tessellator tessellator)
{
BufferBuilder buffer = tessellator.getBuffer();
this.mc.getTextureManager().bindTexture(Gui.OPTIONS_BACKGROUND);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
float f = 32.0F;
buffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
buffer.pos((double)this.left, (double)this.bottom, 0.0D).tex((double)((float)this.left / f), (double)((float)(this.bottom + (int)this.amountScrolled) / f)).color(32, 32, 32, 255).endVertex();
buffer.pos((double)this.right, (double)this.bottom, 0.0D).tex((double)((float)this.right / f), (double)((float)(this.bottom + (int)this.amountScrolled) / f)).color(32, 32, 32, 255).endVertex();
buffer.pos((double)this.right, (double)this.top, 0.0D).tex((double)((float)this.right / f), (double)((float)(this.top + (int)this.amountScrolled) / f)).color(32, 32, 32, 255).endVertex();
buffer.pos((double)this.left, (double)this.top, 0.0D).tex((double)((float)this.left / f), (double)((float)(this.top + (int)this.amountScrolled) / f)).color(32, 32, 32, 255).endVertex();
tessellator.draw();
}
}

View File

@@ -0,0 +1,82 @@
package net.minecraft.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.realms.RealmsScrolledSelectionList;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiSlotRealmsProxy extends GuiSlot
{
private final RealmsScrolledSelectionList selectionList;
public GuiSlotRealmsProxy(RealmsScrolledSelectionList selectionListIn, int widthIn, int heightIn, int topIn, int bottomIn, int slotHeightIn)
{
super(Minecraft.getMinecraft(), widthIn, heightIn, topIn, bottomIn, slotHeightIn);
this.selectionList = selectionListIn;
}
protected int getSize()
{
return this.selectionList.getItemCount();
}
/**
* The element in the slot that was clicked, boolean for whether it was double clicked or not
*/
protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY)
{
this.selectionList.selectItem(slotIndex, isDoubleClick, mouseX, mouseY);
}
/**
* Returns true if the element passed in is currently selected
*/
protected boolean isSelected(int slotIndex)
{
return this.selectionList.isSelectedItem(slotIndex);
}
protected void drawBackground()
{
this.selectionList.renderBackground();
}
protected void drawSlot(int slotIndex, int xPos, int yPos, int heightIn, int mouseXIn, int mouseYIn, float partialTicks)
{
this.selectionList.renderItem(slotIndex, xPos, yPos, heightIn, mouseXIn, mouseYIn);
}
public int getWidth()
{
return this.width;
}
public int getMouseY()
{
return this.mouseY;
}
public int getMouseX()
{
return this.mouseX;
}
/**
* Return the height of the content being scrolled
*/
protected int getContentHeight()
{
return this.selectionList.getMaxPosition();
}
protected int getScrollBarX()
{
return this.selectionList.getScrollbarPosition();
}
public void handleMouseInput()
{
super.handleMouseInput();
}
}

View File

@@ -0,0 +1,164 @@
package net.minecraft.client.gui;
import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.TreeMap;
import java.util.Map.Entry;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.GameSettings;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiSnooper extends GuiScreen
{
private final GuiScreen lastScreen;
/** Reference to the GameSettings object. */
private final GameSettings game_settings_2;
private final java.util.List<String> keys = Lists.<String>newArrayList();
private final java.util.List<String> values = Lists.<String>newArrayList();
private String title;
private String[] desc;
private GuiSnooper.List list;
private GuiButton toggleButton;
public GuiSnooper(GuiScreen p_i1061_1_, GameSettings p_i1061_2_)
{
this.lastScreen = p_i1061_1_;
this.game_settings_2 = p_i1061_2_;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.title = I18n.format("options.snooper.title");
String s = I18n.format("options.snooper.desc");
java.util.List<String> list = Lists.<String>newArrayList();
for (String s1 : this.fontRenderer.listFormattedStringToWidth(s, this.width - 30))
{
list.add(s1);
}
this.desc = (String[])list.toArray(new String[list.size()]);
this.keys.clear();
this.values.clear();
this.toggleButton = this.addButton(new GuiButton(1, this.width / 2 - 152, this.height - 30, 150, 20, this.game_settings_2.getKeyBinding(GameSettings.Options.SNOOPER_ENABLED)));
this.buttonList.add(new GuiButton(2, this.width / 2 + 2, this.height - 30, 150, 20, I18n.format("gui.done")));
boolean flag = this.mc.getIntegratedServer() != null && this.mc.getIntegratedServer().getPlayerUsageSnooper() != null;
for (Entry<String, String> entry : (new TreeMap<String, String>(this.mc.getPlayerUsageSnooper().getCurrentStats())).entrySet())
{
this.keys.add((flag ? "C " : "") + (String)entry.getKey());
this.values.add(this.fontRenderer.trimStringToWidth(entry.getValue(), this.width - 220));
}
if (flag)
{
for (Entry<String, String> entry1 : (new TreeMap<String, String>(this.mc.getIntegratedServer().getPlayerUsageSnooper().getCurrentStats())).entrySet())
{
this.keys.add("S " + (String)entry1.getKey());
this.values.add(this.fontRenderer.trimStringToWidth(entry1.getValue(), this.width - 220));
}
}
this.list = new GuiSnooper.List();
}
/**
* Handles mouse input.
*/
public void handleMouseInput() throws IOException
{
super.handleMouseInput();
this.list.handleMouseInput();
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.enabled)
{
if (button.id == 2)
{
this.game_settings_2.saveOptions();
this.game_settings_2.saveOptions();
this.mc.displayGuiScreen(this.lastScreen);
}
if (button.id == 1)
{
this.game_settings_2.setOptionValue(GameSettings.Options.SNOOPER_ENABLED, 1);
this.toggleButton.displayString = this.game_settings_2.getKeyBinding(GameSettings.Options.SNOOPER_ENABLED);
}
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.list.drawScreen(mouseX, mouseY, partialTicks);
this.drawCenteredString(this.fontRenderer, this.title, this.width / 2, 8, 16777215);
int i = 22;
for (String s : this.desc)
{
this.drawCenteredString(this.fontRenderer, s, this.width / 2, i, 8421504);
i += this.fontRenderer.FONT_HEIGHT;
}
super.drawScreen(mouseX, mouseY, partialTicks);
}
@SideOnly(Side.CLIENT)
class List extends GuiSlot
{
public List()
{
super(GuiSnooper.this.mc, GuiSnooper.this.width, GuiSnooper.this.height, 80, GuiSnooper.this.height - 40, GuiSnooper.this.fontRenderer.FONT_HEIGHT + 1);
}
protected int getSize()
{
return GuiSnooper.this.keys.size();
}
/**
* The element in the slot that was clicked, boolean for whether it was double clicked or not
*/
protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY)
{
}
/**
* Returns true if the element passed in is currently selected
*/
protected boolean isSelected(int slotIndex)
{
return false;
}
protected void drawBackground()
{
}
protected void drawSlot(int slotIndex, int xPos, int yPos, int heightIn, int mouseXIn, int mouseYIn, float partialTicks)
{
GuiSnooper.this.fontRenderer.drawString(GuiSnooper.this.keys.get(slotIndex), 10, yPos, 16777215);
GuiSnooper.this.fontRenderer.drawString(GuiSnooper.this.values.get(slotIndex), 230, yPos, 16777215);
}
protected int getScrollBarX()
{
return this.width - 10;
}
}
}

View File

@@ -0,0 +1,189 @@
package net.minecraft.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.spectator.ISpectatorMenuObject;
import net.minecraft.client.gui.spectator.ISpectatorMenuRecipient;
import net.minecraft.client.gui.spectator.SpectatorMenu;
import net.minecraft.client.gui.spectator.categories.SpectatorDetails;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiSpectator extends Gui implements ISpectatorMenuRecipient
{
private static final ResourceLocation WIDGETS = new ResourceLocation("textures/gui/widgets.png");
public static final ResourceLocation SPECTATOR_WIDGETS = new ResourceLocation("textures/gui/spectator_widgets.png");
private final Minecraft mc;
private long lastSelectionTime;
private SpectatorMenu menu;
public GuiSpectator(Minecraft mcIn)
{
this.mc = mcIn;
}
public void onHotbarSelected(int p_175260_1_)
{
this.lastSelectionTime = Minecraft.getSystemTime();
if (this.menu != null)
{
this.menu.selectSlot(p_175260_1_);
}
else
{
this.menu = new SpectatorMenu(this);
}
}
private float getHotbarAlpha()
{
long i = this.lastSelectionTime - Minecraft.getSystemTime() + 5000L;
return MathHelper.clamp((float)i / 2000.0F, 0.0F, 1.0F);
}
public void renderTooltip(ScaledResolution p_175264_1_, float p_175264_2_)
{
if (this.menu != null)
{
float f = this.getHotbarAlpha();
if (f <= 0.0F)
{
this.menu.exit();
}
else
{
int i = p_175264_1_.getScaledWidth() / 2;
float f1 = this.zLevel;
this.zLevel = -90.0F;
float f2 = (float)p_175264_1_.getScaledHeight() - 22.0F * f;
SpectatorDetails spectatordetails = this.menu.getCurrentPage();
this.renderPage(p_175264_1_, f, i, f2, spectatordetails);
this.zLevel = f1;
}
}
}
protected void renderPage(ScaledResolution p_175258_1_, float p_175258_2_, int p_175258_3_, float p_175258_4_, SpectatorDetails p_175258_5_)
{
GlStateManager.enableRescaleNormal();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.color(1.0F, 1.0F, 1.0F, p_175258_2_);
this.mc.getTextureManager().bindTexture(WIDGETS);
this.drawTexturedModalRect((float)(p_175258_3_ - 91), p_175258_4_, 0, 0, 182, 22);
if (p_175258_5_.getSelectedSlot() >= 0)
{
this.drawTexturedModalRect((float)(p_175258_3_ - 91 - 1 + p_175258_5_.getSelectedSlot() * 20), p_175258_4_ - 1.0F, 0, 22, 24, 22);
}
RenderHelper.enableGUIStandardItemLighting();
for (int i = 0; i < 9; ++i)
{
this.renderSlot(i, p_175258_1_.getScaledWidth() / 2 - 90 + i * 20 + 2, p_175258_4_ + 3.0F, p_175258_2_, p_175258_5_.getObject(i));
}
RenderHelper.disableStandardItemLighting();
GlStateManager.disableRescaleNormal();
GlStateManager.disableBlend();
}
private void renderSlot(int p_175266_1_, int p_175266_2_, float p_175266_3_, float p_175266_4_, ISpectatorMenuObject p_175266_5_)
{
this.mc.getTextureManager().bindTexture(SPECTATOR_WIDGETS);
if (p_175266_5_ != SpectatorMenu.EMPTY_SLOT)
{
int i = (int)(p_175266_4_ * 255.0F);
GlStateManager.pushMatrix();
GlStateManager.translate((float)p_175266_2_, p_175266_3_, 0.0F);
float f = p_175266_5_.isEnabled() ? 1.0F : 0.25F;
GlStateManager.color(f, f, f, p_175266_4_);
p_175266_5_.renderIcon(f, i);
GlStateManager.popMatrix();
String s = String.valueOf(this.mc.gameSettings.keyBindsHotbar[p_175266_1_].getDisplayName());
if (i > 3 && p_175266_5_.isEnabled())
{
this.mc.fontRenderer.drawStringWithShadow(s, (float)(p_175266_2_ + 19 - 2 - this.mc.fontRenderer.getStringWidth(s)), p_175266_3_ + 6.0F + 3.0F, 16777215 + (i << 24));
}
}
}
public void renderSelectedItem(ScaledResolution p_175263_1_)
{
int i = (int)(this.getHotbarAlpha() * 255.0F);
if (i > 3 && this.menu != null)
{
ISpectatorMenuObject ispectatormenuobject = this.menu.getSelectedItem();
String s = ispectatormenuobject == SpectatorMenu.EMPTY_SLOT ? this.menu.getSelectedCategory().getPrompt().getFormattedText() : ispectatormenuobject.getSpectatorName().getFormattedText();
if (s != null)
{
int j = (p_175263_1_.getScaledWidth() - this.mc.fontRenderer.getStringWidth(s)) / 2;
int k = p_175263_1_.getScaledHeight() - 35;
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
this.mc.fontRenderer.drawStringWithShadow(s, (float)j, (float)k, 16777215 + (i << 24));
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}
}
}
public void onSpectatorMenuClosed(SpectatorMenu menu)
{
this.menu = null;
this.lastSelectionTime = 0L;
}
public boolean isMenuActive()
{
return this.menu != null;
}
public void onMouseScroll(int p_175259_1_)
{
int i;
for (i = this.menu.getSelectedSlot() + p_175259_1_; i >= 0 && i <= 8 && (this.menu.getItem(i) == SpectatorMenu.EMPTY_SLOT || !this.menu.getItem(i).isEnabled()); i += p_175259_1_)
{
;
}
if (i >= 0 && i <= 8)
{
this.menu.selectSlot(i);
this.lastSelectionTime = Minecraft.getSystemTime();
}
}
public void onMiddleClick()
{
this.lastSelectionTime = Minecraft.getSystemTime();
if (this.isMenuActive())
{
int i = this.menu.getSelectedSlot();
if (i != -1)
{
this.menu.selectSlot(i);
}
}
else
{
this.menu = new SpectatorMenu(this);
}
}
}

View File

@@ -0,0 +1,170 @@
package net.minecraft.client.gui;
import com.google.common.collect.Lists;
import java.util.Iterator;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.ISound;
import net.minecraft.client.audio.ISoundEventListener;
import net.minecraft.client.audio.SoundEventAccessor;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiSubtitleOverlay extends Gui implements ISoundEventListener
{
private final Minecraft client;
private final List<GuiSubtitleOverlay.Subtitle> subtitles = Lists.<GuiSubtitleOverlay.Subtitle>newArrayList();
private boolean enabled;
public GuiSubtitleOverlay(Minecraft clientIn)
{
this.client = clientIn;
}
public void renderSubtitles(ScaledResolution resolution)
{
if (!this.enabled && this.client.gameSettings.showSubtitles)
{
this.client.getSoundHandler().addListener(this);
this.enabled = true;
}
else if (this.enabled && !this.client.gameSettings.showSubtitles)
{
this.client.getSoundHandler().removeListener(this);
this.enabled = false;
}
if (this.enabled && !this.subtitles.isEmpty())
{
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
Vec3d vec3d = new Vec3d(this.client.player.posX, this.client.player.posY + (double)this.client.player.getEyeHeight(), this.client.player.posZ);
Vec3d vec3d1 = (new Vec3d(0.0D, 0.0D, -1.0D)).rotatePitch(-this.client.player.rotationPitch * 0.017453292F).rotateYaw(-this.client.player.rotationYaw * 0.017453292F);
Vec3d vec3d2 = (new Vec3d(0.0D, 1.0D, 0.0D)).rotatePitch(-this.client.player.rotationPitch * 0.017453292F).rotateYaw(-this.client.player.rotationYaw * 0.017453292F);
Vec3d vec3d3 = vec3d1.crossProduct(vec3d2);
int i = 0;
int j = 0;
Iterator<GuiSubtitleOverlay.Subtitle> iterator = this.subtitles.iterator();
while (iterator.hasNext())
{
GuiSubtitleOverlay.Subtitle guisubtitleoverlay$subtitle = iterator.next();
if (guisubtitleoverlay$subtitle.getStartTime() + 3000L <= Minecraft.getSystemTime())
{
iterator.remove();
}
else
{
j = Math.max(j, this.client.fontRenderer.getStringWidth(guisubtitleoverlay$subtitle.getString()));
}
}
j = j + this.client.fontRenderer.getStringWidth("<") + this.client.fontRenderer.getStringWidth(" ") + this.client.fontRenderer.getStringWidth(">") + this.client.fontRenderer.getStringWidth(" ");
for (GuiSubtitleOverlay.Subtitle guisubtitleoverlay$subtitle1 : this.subtitles)
{
int k = 255;
String s = guisubtitleoverlay$subtitle1.getString();
Vec3d vec3d4 = guisubtitleoverlay$subtitle1.getLocation().subtract(vec3d).normalize();
double d0 = -vec3d3.dotProduct(vec3d4);
double d1 = -vec3d1.dotProduct(vec3d4);
boolean flag = d1 > 0.5D;
int l = j / 2;
int i1 = this.client.fontRenderer.FONT_HEIGHT;
int j1 = i1 / 2;
float f = 1.0F;
int k1 = this.client.fontRenderer.getStringWidth(s);
int l1 = MathHelper.floor(MathHelper.clampedLerp(255.0D, 75.0D, (double)((float)(Minecraft.getSystemTime() - guisubtitleoverlay$subtitle1.getStartTime()) / 3000.0F)));
int i2 = l1 << 16 | l1 << 8 | l1;
GlStateManager.pushMatrix();
GlStateManager.translate((float)resolution.getScaledWidth() - (float)l * 1.0F - 2.0F, (float)(resolution.getScaledHeight() - 30) - (float)(i * (i1 + 1)) * 1.0F, 0.0F);
GlStateManager.scale(1.0F, 1.0F, 1.0F);
drawRect(-l - 1, -j1 - 1, l + 1, j1 + 1, -872415232);
GlStateManager.enableBlend();
if (!flag)
{
if (d0 > 0.0D)
{
this.client.fontRenderer.drawString(">", l - this.client.fontRenderer.getStringWidth(">"), -j1, i2 + -16777216);
}
else if (d0 < 0.0D)
{
this.client.fontRenderer.drawString("<", -l, -j1, i2 + -16777216);
}
}
this.client.fontRenderer.drawString(s, -k1 / 2, -j1, i2 + -16777216);
GlStateManager.popMatrix();
++i;
}
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}
}
public void soundPlay(ISound soundIn, SoundEventAccessor accessor)
{
if (accessor.getSubtitle() != null)
{
String s = accessor.getSubtitle().getFormattedText();
if (!this.subtitles.isEmpty())
{
for (GuiSubtitleOverlay.Subtitle guisubtitleoverlay$subtitle : this.subtitles)
{
if (guisubtitleoverlay$subtitle.getString().equals(s))
{
guisubtitleoverlay$subtitle.refresh(new Vec3d((double)soundIn.getXPosF(), (double)soundIn.getYPosF(), (double)soundIn.getZPosF()));
return;
}
}
}
this.subtitles.add(new GuiSubtitleOverlay.Subtitle(s, new Vec3d((double)soundIn.getXPosF(), (double)soundIn.getYPosF(), (double)soundIn.getZPosF())));
}
}
@SideOnly(Side.CLIENT)
public class Subtitle
{
private final String subtitle;
private long startTime;
private Vec3d location;
public Subtitle(String subtitleIn, Vec3d locationIn)
{
this.subtitle = subtitleIn;
this.location = locationIn;
this.startTime = Minecraft.getSystemTime();
}
public String getString()
{
return this.subtitle;
}
public long getStartTime()
{
return this.startTime;
}
public Vec3d getLocation()
{
return this.location;
}
public void refresh(Vec3d locationIn)
{
this.location = locationIn;
this.startTime = Minecraft.getSystemTime();
}
}
}

View File

@@ -0,0 +1,830 @@
package net.minecraft.client.gui;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.ChatAllowedCharacters;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiTextField extends Gui
{
private final int id;
private final FontRenderer fontRenderer;
public int x;
public int y;
/** The width of this text field. */
public int width;
public int height;
/** Has the current text being edited on the textbox. */
private String text = "";
private int maxStringLength = 32;
private int cursorCounter;
private boolean enableBackgroundDrawing = true;
/** if true the textbox can lose focus by clicking elsewhere on the screen */
private boolean canLoseFocus = true;
/** If this value is true along with isEnabled, keyTyped will process the keys. */
private boolean isFocused;
/** If this value is true along with isFocused, keyTyped will process the keys. */
private boolean isEnabled = true;
/** The current character index that should be used as start of the rendered text. */
private int lineScrollOffset;
private int cursorPosition;
/** other selection position, maybe the same as the cursor */
private int selectionEnd;
private int enabledColor = 14737632;
private int disabledColor = 7368816;
/** True if this textbox is visible */
private boolean visible = true;
private GuiPageButtonList.GuiResponder guiResponder;
/** Called to check if the text is valid */
private Predicate<String> validator = Predicates.<String>alwaysTrue();
public GuiTextField(int componentId, FontRenderer fontrendererObj, int x, int y, int par5Width, int par6Height)
{
this.id = componentId;
this.fontRenderer = fontrendererObj;
this.x = x;
this.y = y;
this.width = par5Width;
this.height = par6Height;
}
/**
* Sets the GuiResponder associated with this text box.
*/
public void setGuiResponder(GuiPageButtonList.GuiResponder guiResponderIn)
{
this.guiResponder = guiResponderIn;
}
/**
* Increments the cursor counter
*/
public void updateCursorCounter()
{
++this.cursorCounter;
}
/**
* Sets the text of the textbox, and moves the cursor to the end.
*/
public void setText(String textIn)
{
if (this.validator.apply(textIn))
{
if (textIn.length() > this.maxStringLength)
{
this.text = textIn.substring(0, this.maxStringLength);
}
else
{
this.text = textIn;
}
this.setCursorPositionEnd();
}
}
/**
* Returns the contents of the textbox
*/
public String getText()
{
return this.text;
}
/**
* returns the text between the cursor and selectionEnd
*/
public String getSelectedText()
{
int i = this.cursorPosition < this.selectionEnd ? this.cursorPosition : this.selectionEnd;
int j = this.cursorPosition < this.selectionEnd ? this.selectionEnd : this.cursorPosition;
return this.text.substring(i, j);
}
public void setValidator(Predicate<String> theValidator)
{
this.validator = theValidator;
}
/**
* Adds the given text after the cursor, or replaces the currently selected text if there is a selection.
*/
public void writeText(String textToWrite)
{
String s = "";
String s1 = ChatAllowedCharacters.filterAllowedCharacters(textToWrite);
int i = this.cursorPosition < this.selectionEnd ? this.cursorPosition : this.selectionEnd;
int j = this.cursorPosition < this.selectionEnd ? this.selectionEnd : this.cursorPosition;
int k = this.maxStringLength - this.text.length() - (i - j);
if (!this.text.isEmpty())
{
s = s + this.text.substring(0, i);
}
int l;
if (k < s1.length())
{
s = s + s1.substring(0, k);
l = k;
}
else
{
s = s + s1;
l = s1.length();
}
if (!this.text.isEmpty() && j < this.text.length())
{
s = s + this.text.substring(j);
}
if (this.validator.apply(s))
{
this.text = s;
this.moveCursorBy(i - this.selectionEnd + l);
this.setResponderEntryValue(this.id, this.text);
}
}
/**
* Notifies this text box's {@linkplain GuiPageButtonList.GuiResponder responder} that the text has changed.
*/
public void setResponderEntryValue(int idIn, String textIn)
{
if (this.guiResponder != null)
{
this.guiResponder.setEntryValue(idIn, textIn);
}
}
/**
* Deletes the given number of words from the current cursor's position, unless there is currently a selection, in
* which case the selection is deleted instead.
*/
public void deleteWords(int num)
{
if (!this.text.isEmpty())
{
if (this.selectionEnd != this.cursorPosition)
{
this.writeText("");
}
else
{
this.deleteFromCursor(this.getNthWordFromCursor(num) - this.cursorPosition);
}
}
}
/**
* Deletes the given number of characters from the current cursor's position, unless there is currently a selection,
* in which case the selection is deleted instead.
*/
public void deleteFromCursor(int num)
{
if (!this.text.isEmpty())
{
if (this.selectionEnd != this.cursorPosition)
{
this.writeText("");
}
else
{
boolean flag = num < 0;
int i = flag ? this.cursorPosition + num : this.cursorPosition;
int j = flag ? this.cursorPosition : this.cursorPosition + num;
String s = "";
if (i >= 0)
{
s = this.text.substring(0, i);
}
if (j < this.text.length())
{
s = s + this.text.substring(j);
}
if (this.validator.apply(s))
{
this.text = s;
if (flag)
{
this.moveCursorBy(num);
}
this.setResponderEntryValue(this.id, this.text);
}
}
}
}
public int getId()
{
return this.id;
}
/**
* Gets the starting index of the word at the specified number of words away from the cursor position.
*/
public int getNthWordFromCursor(int numWords)
{
return this.getNthWordFromPos(numWords, this.getCursorPosition());
}
/**
* Gets the starting index of the word at a distance of the specified number of words away from the given position.
*/
public int getNthWordFromPos(int n, int pos)
{
return this.getNthWordFromPosWS(n, pos, true);
}
/**
* Like getNthWordFromPos (which wraps this), but adds option for skipping consecutive spaces
*/
public int getNthWordFromPosWS(int n, int pos, boolean skipWs)
{
int i = pos;
boolean flag = n < 0;
int j = Math.abs(n);
for (int k = 0; k < j; ++k)
{
if (!flag)
{
int l = this.text.length();
i = this.text.indexOf(32, i);
if (i == -1)
{
i = l;
}
else
{
while (skipWs && i < l && this.text.charAt(i) == ' ')
{
++i;
}
}
}
else
{
while (skipWs && i > 0 && this.text.charAt(i - 1) == ' ')
{
--i;
}
while (i > 0 && this.text.charAt(i - 1) != ' ')
{
--i;
}
}
}
return i;
}
/**
* Moves the text cursor by a specified number of characters and clears the selection
*/
public void moveCursorBy(int num)
{
this.setCursorPosition(this.selectionEnd + num);
}
/**
* Sets the current position of the cursor.
*/
public void setCursorPosition(int pos)
{
this.cursorPosition = pos;
int i = this.text.length();
this.cursorPosition = MathHelper.clamp(this.cursorPosition, 0, i);
this.setSelectionPos(this.cursorPosition);
}
/**
* Moves the cursor to the very start of this text box.
*/
public void setCursorPositionZero()
{
this.setCursorPosition(0);
}
/**
* Moves the cursor to the very end of this text box.
*/
public void setCursorPositionEnd()
{
this.setCursorPosition(this.text.length());
}
/**
* Call this method from your GuiScreen to process the keys into the textbox
*/
public boolean textboxKeyTyped(char typedChar, int keyCode)
{
if (!this.isFocused)
{
return false;
}
else if (GuiScreen.isKeyComboCtrlA(keyCode))
{
this.setCursorPositionEnd();
this.setSelectionPos(0);
return true;
}
else if (GuiScreen.isKeyComboCtrlC(keyCode))
{
GuiScreen.setClipboardString(this.getSelectedText());
return true;
}
else if (GuiScreen.isKeyComboCtrlV(keyCode))
{
if (this.isEnabled)
{
this.writeText(GuiScreen.getClipboardString());
}
return true;
}
else if (GuiScreen.isKeyComboCtrlX(keyCode))
{
GuiScreen.setClipboardString(this.getSelectedText());
if (this.isEnabled)
{
this.writeText("");
}
return true;
}
else
{
switch (keyCode)
{
case 14:
if (GuiScreen.isCtrlKeyDown())
{
if (this.isEnabled)
{
this.deleteWords(-1);
}
}
else if (this.isEnabled)
{
this.deleteFromCursor(-1);
}
return true;
case 199:
if (GuiScreen.isShiftKeyDown())
{
this.setSelectionPos(0);
}
else
{
this.setCursorPositionZero();
}
return true;
case 203:
if (GuiScreen.isShiftKeyDown())
{
if (GuiScreen.isCtrlKeyDown())
{
this.setSelectionPos(this.getNthWordFromPos(-1, this.getSelectionEnd()));
}
else
{
this.setSelectionPos(this.getSelectionEnd() - 1);
}
}
else if (GuiScreen.isCtrlKeyDown())
{
this.setCursorPosition(this.getNthWordFromCursor(-1));
}
else
{
this.moveCursorBy(-1);
}
return true;
case 205:
if (GuiScreen.isShiftKeyDown())
{
if (GuiScreen.isCtrlKeyDown())
{
this.setSelectionPos(this.getNthWordFromPos(1, this.getSelectionEnd()));
}
else
{
this.setSelectionPos(this.getSelectionEnd() + 1);
}
}
else if (GuiScreen.isCtrlKeyDown())
{
this.setCursorPosition(this.getNthWordFromCursor(1));
}
else
{
this.moveCursorBy(1);
}
return true;
case 207:
if (GuiScreen.isShiftKeyDown())
{
this.setSelectionPos(this.text.length());
}
else
{
this.setCursorPositionEnd();
}
return true;
case 211:
if (GuiScreen.isCtrlKeyDown())
{
if (this.isEnabled)
{
this.deleteWords(1);
}
}
else if (this.isEnabled)
{
this.deleteFromCursor(1);
}
return true;
default:
if (ChatAllowedCharacters.isAllowedCharacter(typedChar))
{
if (this.isEnabled)
{
this.writeText(Character.toString(typedChar));
}
return true;
}
else
{
return false;
}
}
}
}
/**
* Called when mouse is clicked, regardless as to whether it is over this button or not.
*/
public boolean mouseClicked(int mouseX, int mouseY, int mouseButton)
{
boolean flag = mouseX >= this.x && mouseX < this.x + this.width && mouseY >= this.y && mouseY < this.y + this.height;
if (this.canLoseFocus)
{
this.setFocused(flag);
}
if (this.isFocused && flag && mouseButton == 0)
{
int i = mouseX - this.x;
if (this.enableBackgroundDrawing)
{
i -= 4;
}
String s = this.fontRenderer.trimStringToWidth(this.text.substring(this.lineScrollOffset), this.getWidth());
this.setCursorPosition(this.fontRenderer.trimStringToWidth(s, i).length() + this.lineScrollOffset);
return true;
}
else
{
return false;
}
}
/**
* Draws the textbox
*/
public void drawTextBox()
{
if (this.getVisible())
{
if (this.getEnableBackgroundDrawing())
{
drawRect(this.x - 1, this.y - 1, this.x + this.width + 1, this.y + this.height + 1, -6250336);
drawRect(this.x, this.y, this.x + this.width, this.y + this.height, -16777216);
}
int i = this.isEnabled ? this.enabledColor : this.disabledColor;
int j = this.cursorPosition - this.lineScrollOffset;
int k = this.selectionEnd - this.lineScrollOffset;
String s = this.fontRenderer.trimStringToWidth(this.text.substring(this.lineScrollOffset), this.getWidth());
boolean flag = j >= 0 && j <= s.length();
boolean flag1 = this.isFocused && this.cursorCounter / 6 % 2 == 0 && flag;
int l = this.enableBackgroundDrawing ? this.x + 4 : this.x;
int i1 = this.enableBackgroundDrawing ? this.y + (this.height - 8) / 2 : this.y;
int j1 = l;
if (k > s.length())
{
k = s.length();
}
if (!s.isEmpty())
{
String s1 = flag ? s.substring(0, j) : s;
j1 = this.fontRenderer.drawStringWithShadow(s1, (float)l, (float)i1, i);
}
boolean flag2 = this.cursorPosition < this.text.length() || this.text.length() >= this.getMaxStringLength();
int k1 = j1;
if (!flag)
{
k1 = j > 0 ? l + this.width : l;
}
else if (flag2)
{
k1 = j1 - 1;
--j1;
}
if (!s.isEmpty() && flag && j < s.length())
{
j1 = this.fontRenderer.drawStringWithShadow(s.substring(j), (float)j1, (float)i1, i);
}
if (flag1)
{
if (flag2)
{
Gui.drawRect(k1, i1 - 1, k1 + 1, i1 + 1 + this.fontRenderer.FONT_HEIGHT, -3092272);
}
else
{
this.fontRenderer.drawStringWithShadow("_", (float)k1, (float)i1, i);
}
}
if (k != j)
{
int l1 = l + this.fontRenderer.getStringWidth(s.substring(0, k));
this.drawSelectionBox(k1, i1 - 1, l1 - 1, i1 + 1 + this.fontRenderer.FONT_HEIGHT);
}
}
}
/**
* Draws the blue selection box.
*/
private void drawSelectionBox(int startX, int startY, int endX, int endY)
{
if (startX < endX)
{
int i = startX;
startX = endX;
endX = i;
}
if (startY < endY)
{
int j = startY;
startY = endY;
endY = j;
}
if (endX > this.x + this.width)
{
endX = this.x + this.width;
}
if (startX > this.x + this.width)
{
startX = this.x + this.width;
}
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
GlStateManager.color(0.0F, 0.0F, 255.0F, 255.0F);
GlStateManager.disableTexture2D();
GlStateManager.enableColorLogic();
GlStateManager.colorLogicOp(GlStateManager.LogicOp.OR_REVERSE);
bufferbuilder.begin(7, DefaultVertexFormats.POSITION);
bufferbuilder.pos((double)startX, (double)endY, 0.0D).endVertex();
bufferbuilder.pos((double)endX, (double)endY, 0.0D).endVertex();
bufferbuilder.pos((double)endX, (double)startY, 0.0D).endVertex();
bufferbuilder.pos((double)startX, (double)startY, 0.0D).endVertex();
tessellator.draw();
GlStateManager.disableColorLogic();
GlStateManager.enableTexture2D();
}
/**
* Sets the maximum length for the text in this text box. If the current text is longer than this length, the
* current text will be trimmed.
*/
public void setMaxStringLength(int length)
{
this.maxStringLength = length;
if (this.text.length() > length)
{
this.text = this.text.substring(0, length);
}
}
/**
* returns the maximum number of character that can be contained in this textbox
*/
public int getMaxStringLength()
{
return this.maxStringLength;
}
/**
* returns the current position of the cursor
*/
public int getCursorPosition()
{
return this.cursorPosition;
}
/**
* Gets whether the background and outline of this text box should be drawn (true if so).
*/
public boolean getEnableBackgroundDrawing()
{
return this.enableBackgroundDrawing;
}
/**
* Sets whether or not the background and outline of this text box should be drawn.
*/
public void setEnableBackgroundDrawing(boolean enableBackgroundDrawingIn)
{
this.enableBackgroundDrawing = enableBackgroundDrawingIn;
}
/**
* Sets the color to use when drawing this text box's text. A different color is used if this text box is disabled.
*/
public void setTextColor(int color)
{
this.enabledColor = color;
}
/**
* Sets the color to use for text in this text box when this text box is disabled.
*/
public void setDisabledTextColour(int color)
{
this.disabledColor = color;
}
/**
* Sets focus to this gui element
*/
public void setFocused(boolean isFocusedIn)
{
if (isFocusedIn && !this.isFocused)
{
this.cursorCounter = 0;
}
this.isFocused = isFocusedIn;
if (Minecraft.getMinecraft().currentScreen != null)
{
Minecraft.getMinecraft().currentScreen.setFocused(isFocusedIn);
}
}
/**
* Getter for the focused field
*/
public boolean isFocused()
{
return this.isFocused;
}
/**
* Sets whether this text box is enabled. Disabled text boxes cannot be typed in.
*/
public void setEnabled(boolean enabled)
{
this.isEnabled = enabled;
}
/**
* the side of the selection that is not the cursor, may be the same as the cursor
*/
public int getSelectionEnd()
{
return this.selectionEnd;
}
/**
* returns the width of the textbox depending on if background drawing is enabled
*/
public int getWidth()
{
return this.getEnableBackgroundDrawing() ? this.width - 8 : this.width;
}
/**
* Sets the position of the selection anchor (the selection anchor and the cursor position mark the edges of the
* selection). If the anchor is set beyond the bounds of the current text, it will be put back inside.
*/
public void setSelectionPos(int position)
{
int i = this.text.length();
if (position > i)
{
position = i;
}
if (position < 0)
{
position = 0;
}
this.selectionEnd = position;
if (this.fontRenderer != null)
{
if (this.lineScrollOffset > i)
{
this.lineScrollOffset = i;
}
int j = this.getWidth();
String s = this.fontRenderer.trimStringToWidth(this.text.substring(this.lineScrollOffset), j);
int k = s.length() + this.lineScrollOffset;
if (position == this.lineScrollOffset)
{
this.lineScrollOffset -= this.fontRenderer.trimStringToWidth(this.text, j, true).length();
}
if (position > k)
{
this.lineScrollOffset += position - k;
}
else if (position <= this.lineScrollOffset)
{
this.lineScrollOffset -= this.lineScrollOffset - position;
}
this.lineScrollOffset = MathHelper.clamp(this.lineScrollOffset, 0, i);
}
}
/**
* Sets whether this text box loses focus when something other than it is clicked.
*/
public void setCanLoseFocus(boolean canLoseFocusIn)
{
this.canLoseFocus = canLoseFocusIn;
}
/**
* returns true if this textbox is visible
*/
public boolean getVisible()
{
return this.visible;
}
/**
* Sets whether or not this textbox is visible
*/
public void setVisible(boolean isVisible)
{
this.visible = isVisible;
}
}

View File

@@ -0,0 +1,110 @@
package net.minecraft.client.gui;
import com.google.common.collect.Lists;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiUtilRenderComponents
{
public static String removeTextColorsIfConfigured(String text, boolean forceColor)
{
return !forceColor && !Minecraft.getMinecraft().gameSettings.chatColours ? TextFormatting.getTextWithoutFormattingCodes(text) : text;
}
public static List<ITextComponent> splitText(ITextComponent textComponent, int maxTextLenght, FontRenderer fontRendererIn, boolean p_178908_3_, boolean forceTextColor)
{
int i = 0;
ITextComponent itextcomponent = new TextComponentString("");
List<ITextComponent> list = Lists.<ITextComponent>newArrayList();
List<ITextComponent> list1 = Lists.newArrayList(textComponent);
for (int j = 0; j < list1.size(); ++j)
{
ITextComponent itextcomponent1 = list1.get(j);
String s = itextcomponent1.getUnformattedComponentText();
boolean flag = false;
if (s.contains("\n"))
{
int k = s.indexOf(10);
String s1 = s.substring(k + 1);
s = s.substring(0, k + 1);
ITextComponent itextcomponent2 = new TextComponentString(s1);
itextcomponent2.setStyle(itextcomponent1.getStyle().createShallowCopy());
list1.add(j + 1, itextcomponent2);
flag = true;
}
String s4 = removeTextColorsIfConfigured(itextcomponent1.getStyle().getFormattingCode() + s, forceTextColor);
String s5 = s4.endsWith("\n") ? s4.substring(0, s4.length() - 1) : s4;
int i1 = fontRendererIn.getStringWidth(s5);
TextComponentString textcomponentstring = new TextComponentString(s5);
textcomponentstring.setStyle(itextcomponent1.getStyle().createShallowCopy());
if (i + i1 > maxTextLenght)
{
String s2 = fontRendererIn.trimStringToWidth(s4, maxTextLenght - i, false);
String s3 = s2.length() < s4.length() ? s4.substring(s2.length()) : null;
if (s3 != null && !s3.isEmpty())
{
int l = s2.lastIndexOf(32);
if (l >= 0 && fontRendererIn.getStringWidth(s4.substring(0, l)) > 0)
{
s2 = s4.substring(0, l);
if (p_178908_3_)
{
++l;
}
s3 = s4.substring(l);
}
else if (i > 0 && !s4.contains(" "))
{
s2 = "";
s3 = s4;
}
s3 = FontRenderer.getFormatFromString(s2) + s3; //Forge: Fix chat formatting not surviving line wrapping.
TextComponentString textcomponentstring1 = new TextComponentString(s3);
textcomponentstring1.setStyle(itextcomponent1.getStyle().createShallowCopy());
list1.add(j + 1, textcomponentstring1);
}
i1 = fontRendererIn.getStringWidth(s2);
textcomponentstring = new TextComponentString(s2);
textcomponentstring.setStyle(itextcomponent1.getStyle().createShallowCopy());
flag = true;
}
if (i + i1 <= maxTextLenght)
{
i += i1;
itextcomponent.appendSibling(textcomponentstring);
}
else
{
flag = true;
}
if (flag)
{
list.add(itextcomponent);
i = 0;
itextcomponent = new TextComponentString("");
}
}
list.add(itextcomponent);
return list;
}
}

View File

@@ -0,0 +1,155 @@
package net.minecraft.client.gui;
import java.io.IOException;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.GameSettings;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiVideoSettings extends GuiScreen
{
private final GuiScreen parentGuiScreen;
protected String screenTitle = "Video Settings";
private final GameSettings guiGameSettings;
private GuiListExtended optionsRowList;
/** An array of all of GameSettings.Options's video options. */
private static final GameSettings.Options[] VIDEO_OPTIONS = new GameSettings.Options[] {GameSettings.Options.GRAPHICS, GameSettings.Options.RENDER_DISTANCE, GameSettings.Options.AMBIENT_OCCLUSION, GameSettings.Options.FRAMERATE_LIMIT, GameSettings.Options.ANAGLYPH, GameSettings.Options.VIEW_BOBBING, GameSettings.Options.GUI_SCALE, GameSettings.Options.ATTACK_INDICATOR, GameSettings.Options.GAMMA, GameSettings.Options.RENDER_CLOUDS, GameSettings.Options.PARTICLES, GameSettings.Options.USE_FULLSCREEN, GameSettings.Options.ENABLE_VSYNC, GameSettings.Options.MIPMAP_LEVELS, GameSettings.Options.USE_VBO, GameSettings.Options.ENTITY_SHADOWS};
public GuiVideoSettings(GuiScreen parentScreenIn, GameSettings gameSettingsIn)
{
this.parentGuiScreen = parentScreenIn;
this.guiGameSettings = gameSettingsIn;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.screenTitle = I18n.format("options.videoTitle");
this.buttonList.clear();
this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height - 27, I18n.format("gui.done")));
if (OpenGlHelper.vboSupported)
{
this.optionsRowList = new GuiOptionsRowList(this.mc, this.width, this.height, 32, this.height - 32, 25, VIDEO_OPTIONS);
}
else
{
GameSettings.Options[] agamesettings$options = new GameSettings.Options[VIDEO_OPTIONS.length - 1];
int i = 0;
for (GameSettings.Options gamesettings$options : VIDEO_OPTIONS)
{
if (gamesettings$options == GameSettings.Options.USE_VBO)
{
break;
}
agamesettings$options[i] = gamesettings$options;
++i;
}
this.optionsRowList = new GuiOptionsRowList(this.mc, this.width, this.height, 32, this.height - 32, 25, agamesettings$options);
}
}
/**
* Handles mouse input.
*/
public void handleMouseInput() throws IOException
{
super.handleMouseInput();
this.optionsRowList.handleMouseInput();
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
if (keyCode == 1)
{
this.mc.gameSettings.saveOptions();
}
super.keyTyped(typedChar, keyCode);
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.enabled)
{
if (button.id == 200)
{
this.mc.gameSettings.saveOptions();
this.mc.displayGuiScreen(this.parentGuiScreen);
}
}
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
int i = this.guiGameSettings.guiScale;
super.mouseClicked(mouseX, mouseY, mouseButton);
this.optionsRowList.mouseClicked(mouseX, mouseY, mouseButton);
if (this.guiGameSettings.guiScale != i)
{
ScaledResolution scaledresolution = new ScaledResolution(this.mc);
int j = scaledresolution.getScaledWidth();
int k = scaledresolution.getScaledHeight();
this.setWorldAndResolution(this.mc, j, k);
}
}
/**
* Called when a mouse button is released.
*/
protected void mouseReleased(int mouseX, int mouseY, int state)
{
int i = this.guiGameSettings.guiScale;
super.mouseReleased(mouseX, mouseY, state);
this.optionsRowList.mouseReleased(mouseX, mouseY, state);
if (this.guiGameSettings.guiScale != i)
{
ScaledResolution scaledresolution = new ScaledResolution(this.mc);
int j = scaledresolution.getScaledWidth();
int k = scaledresolution.getScaledHeight();
this.setWorldAndResolution(this.mc, j, k);
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.optionsRowList.drawScreen(mouseX, mouseY, partialTicks);
this.drawCenteredString(this.fontRenderer, this.screenTitle, this.width / 2, 5, 16777215);
super.drawScreen(mouseX, mouseY, partialTicks);
}
// FORGE: fix for MC-64581 very laggy mipmap slider
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
@Override
public void onGuiClosed()
{
super.onGuiClosed();
this.mc.gameSettings.onGuiClosed();
}
}

View File

@@ -0,0 +1,268 @@
package net.minecraft.client.gui;
import com.google.common.collect.Lists;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Random;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.resources.IResource;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.io.IOUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@SideOnly(Side.CLIENT)
public class GuiWinGame extends GuiScreen
{
private static final Logger LOGGER = LogManager.getLogger();
private static final ResourceLocation MINECRAFT_LOGO = new ResourceLocation("textures/gui/title/minecraft.png");
private static final ResourceLocation field_194401_g = new ResourceLocation("textures/gui/title/edition.png");
private static final ResourceLocation VIGNETTE_TEXTURE = new ResourceLocation("textures/misc/vignette.png");
private final boolean poem;
private final Runnable onFinished;
private float time;
private List<String> lines;
private int totalScrollLength;
private float scrollSpeed = 0.5F;
public GuiWinGame(boolean poemIn, Runnable onFinishedIn)
{
this.poem = poemIn;
this.onFinished = onFinishedIn;
if (!poemIn)
{
this.scrollSpeed = 0.75F;
}
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
this.mc.getMusicTicker().update();
this.mc.getSoundHandler().update();
float f = (float)(this.totalScrollLength + this.height + this.height + 24) / this.scrollSpeed;
if (this.time > f)
{
this.sendRespawnPacket();
}
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
if (keyCode == 1)
{
this.sendRespawnPacket();
}
}
private void sendRespawnPacket()
{
this.onFinished.run();
this.mc.displayGuiScreen((GuiScreen)null);
}
/**
* Returns true if this GUI should pause the game when it is displayed in single-player
*/
public boolean doesGuiPauseGame()
{
return true;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
if (this.lines == null)
{
this.lines = Lists.<String>newArrayList();
IResource iresource = null;
try
{
String s = "" + TextFormatting.WHITE + TextFormatting.OBFUSCATED + TextFormatting.GREEN + TextFormatting.AQUA;
int i = 274;
if (this.poem)
{
iresource = this.mc.getResourceManager().getResource(new ResourceLocation("texts/end.txt"));
InputStream inputstream = iresource.getInputStream();
BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(inputstream, StandardCharsets.UTF_8));
Random random = new Random(8124371L);
String s1;
while ((s1 = bufferedreader.readLine()) != null)
{
String s2;
String s3;
for (s1 = s1.replaceAll("PLAYERNAME", this.mc.getSession().getUsername()); s1.contains(s); s1 = s2 + TextFormatting.WHITE + TextFormatting.OBFUSCATED + "XXXXXXXX".substring(0, random.nextInt(4) + 3) + s3)
{
int j = s1.indexOf(s);
s2 = s1.substring(0, j);
s3 = s1.substring(j + s.length());
}
this.lines.addAll(this.mc.fontRenderer.listFormattedStringToWidth(s1, 274));
this.lines.add("");
}
inputstream.close();
for (int k = 0; k < 8; ++k)
{
this.lines.add("");
}
}
InputStream inputstream1 = this.mc.getResourceManager().getResource(new ResourceLocation("texts/credits.txt")).getInputStream();
BufferedReader bufferedreader1 = new BufferedReader(new InputStreamReader(inputstream1, StandardCharsets.UTF_8));
String s4;
while ((s4 = bufferedreader1.readLine()) != null)
{
s4 = s4.replaceAll("PLAYERNAME", this.mc.getSession().getUsername());
s4 = s4.replaceAll("\t", " ");
this.lines.addAll(this.mc.fontRenderer.listFormattedStringToWidth(s4, 274));
this.lines.add("");
}
inputstream1.close();
this.totalScrollLength = this.lines.size() * 12;
}
catch (Exception exception)
{
LOGGER.error("Couldn't load credits", (Throwable)exception);
}
finally
{
IOUtils.closeQuietly((Closeable)iresource);
}
}
}
private void drawWinGameScreen(int p_146575_1_, int p_146575_2_, float p_146575_3_)
{
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
this.mc.getTextureManager().bindTexture(Gui.OPTIONS_BACKGROUND);
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
int i = this.width;
float f = -this.time * 0.5F * this.scrollSpeed;
float f1 = (float)this.height - this.time * 0.5F * this.scrollSpeed;
float f2 = 0.015625F;
float f3 = this.time * 0.02F;
float f4 = (float)(this.totalScrollLength + this.height + this.height + 24) / this.scrollSpeed;
float f5 = (f4 - 20.0F - this.time) * 0.005F;
if (f5 < f3)
{
f3 = f5;
}
if (f3 > 1.0F)
{
f3 = 1.0F;
}
f3 = f3 * f3;
f3 = f3 * 96.0F / 255.0F;
bufferbuilder.pos(0.0D, (double)this.height, (double)this.zLevel).tex(0.0D, (double)(f * 0.015625F)).color(f3, f3, f3, 1.0F).endVertex();
bufferbuilder.pos((double)i, (double)this.height, (double)this.zLevel).tex((double)((float)i * 0.015625F), (double)(f * 0.015625F)).color(f3, f3, f3, 1.0F).endVertex();
bufferbuilder.pos((double)i, 0.0D, (double)this.zLevel).tex((double)((float)i * 0.015625F), (double)(f1 * 0.015625F)).color(f3, f3, f3, 1.0F).endVertex();
bufferbuilder.pos(0.0D, 0.0D, (double)this.zLevel).tex(0.0D, (double)(f1 * 0.015625F)).color(f3, f3, f3, 1.0F).endVertex();
tessellator.draw();
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawWinGameScreen(mouseX, mouseY, partialTicks);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
int i = 274;
int j = this.width / 2 - 137;
int k = this.height + 50;
this.time += partialTicks;
float f = -this.time * this.scrollSpeed;
GlStateManager.pushMatrix();
GlStateManager.translate(0.0F, f, 0.0F);
this.mc.getTextureManager().bindTexture(MINECRAFT_LOGO);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.enableAlpha();
this.drawTexturedModalRect(j, k, 0, 0, 155, 44);
this.drawTexturedModalRect(j + 155, k, 0, 45, 155, 44);
this.mc.getTextureManager().bindTexture(field_194401_g);
drawModalRectWithCustomSizedTexture(j + 88, k + 37, 0.0F, 0.0F, 98, 14, 128.0F, 16.0F);
GlStateManager.disableAlpha();
int l = k + 100;
for (int i1 = 0; i1 < this.lines.size(); ++i1)
{
if (i1 == this.lines.size() - 1)
{
float f1 = (float)l + f - (float)(this.height / 2 - 6);
if (f1 < 0.0F)
{
GlStateManager.translate(0.0F, -f1, 0.0F);
}
}
if ((float)l + f + 12.0F + 8.0F > 0.0F && (float)l + f < (float)this.height)
{
String s = this.lines.get(i1);
if (s.startsWith("[C]"))
{
this.fontRenderer.drawStringWithShadow(s.substring(3), (float)(j + (274 - this.fontRenderer.getStringWidth(s.substring(3))) / 2), (float)l, 16777215);
}
else
{
this.fontRenderer.fontRandom.setSeed((long)((float)((long)i1 * 4238972211L) + this.time / 4.0F));
this.fontRenderer.drawStringWithShadow(s, (float)j, (float)l, 16777215);
}
}
l += 12;
}
GlStateManager.popMatrix();
this.mc.getTextureManager().bindTexture(VIGNETTE_TEXTURE);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GlStateManager.SourceFactor.ZERO, GlStateManager.DestFactor.ONE_MINUS_SRC_COLOR);
int j1 = this.width;
int k1 = this.height;
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
bufferbuilder.pos(0.0D, (double)k1, (double)this.zLevel).tex(0.0D, 1.0D).color(1.0F, 1.0F, 1.0F, 1.0F).endVertex();
bufferbuilder.pos((double)j1, (double)k1, (double)this.zLevel).tex(1.0D, 1.0D).color(1.0F, 1.0F, 1.0F, 1.0F).endVertex();
bufferbuilder.pos((double)j1, 0.0D, (double)this.zLevel).tex(1.0D, 0.0D).color(1.0F, 1.0F, 1.0F, 1.0F).endVertex();
bufferbuilder.pos(0.0D, 0.0D, (double)this.zLevel).tex(0.0D, 0.0D).color(1.0F, 1.0F, 1.0F, 1.0F).endVertex();
tessellator.draw();
GlStateManager.disableBlend();
super.drawScreen(mouseX, mouseY, partialTicks);
}
}

View File

@@ -0,0 +1,129 @@
package net.minecraft.client.gui;
import java.io.IOException;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.resources.I18n;
import net.minecraft.world.storage.ISaveFormat;
import net.minecraft.world.storage.WorldInfo;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.io.FileUtils;
import org.lwjgl.input.Keyboard;
@SideOnly(Side.CLIENT)
public class GuiWorldEdit extends GuiScreen
{
private final GuiScreen lastScreen;
private GuiTextField nameEdit;
private final String worldId;
public GuiWorldEdit(GuiScreen p_i46593_1_, String p_i46593_2_)
{
this.lastScreen = p_i46593_1_;
this.worldId = p_i46593_2_;
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
this.nameEdit.updateCursorCounter();
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
Keyboard.enableRepeatEvents(true);
this.buttonList.clear();
GuiButton guibutton = this.addButton(new GuiButton(3, this.width / 2 - 100, this.height / 4 + 24 + 12, I18n.format("selectWorld.edit.resetIcon")));
this.buttonList.add(new GuiButton(4, this.width / 2 - 100, this.height / 4 + 48 + 12, I18n.format("selectWorld.edit.openFolder")));
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, I18n.format("selectWorld.edit.save")));
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, I18n.format("gui.cancel")));
guibutton.enabled = this.mc.getSaveLoader().getFile(this.worldId, "icon.png").isFile();
ISaveFormat isaveformat = this.mc.getSaveLoader();
WorldInfo worldinfo = isaveformat.getWorldInfo(this.worldId);
String s = worldinfo == null ? "" : worldinfo.getWorldName();
this.nameEdit = new GuiTextField(2, this.fontRenderer, this.width / 2 - 100, 60, 200, 20);
this.nameEdit.setFocused(true);
this.nameEdit.setText(s);
}
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
Keyboard.enableRepeatEvents(false);
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.enabled)
{
if (button.id == 1)
{
this.mc.displayGuiScreen(this.lastScreen);
}
else if (button.id == 0)
{
ISaveFormat isaveformat = this.mc.getSaveLoader();
isaveformat.renameWorld(this.worldId, this.nameEdit.getText().trim());
this.mc.displayGuiScreen(this.lastScreen);
}
else if (button.id == 3)
{
ISaveFormat isaveformat1 = this.mc.getSaveLoader();
FileUtils.deleteQuietly(isaveformat1.getFile(this.worldId, "icon.png"));
button.enabled = false;
}
else if (button.id == 4)
{
ISaveFormat isaveformat2 = this.mc.getSaveLoader();
OpenGlHelper.openFile(isaveformat2.getFile(this.worldId, "icon.png").getParentFile());
}
}
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
this.nameEdit.textboxKeyTyped(typedChar, keyCode);
(this.buttonList.get(2)).enabled = !this.nameEdit.getText().trim().isEmpty();
if (keyCode == 28 || keyCode == 156)
{
this.actionPerformed(this.buttonList.get(2));
}
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
super.mouseClicked(mouseX, mouseY, mouseButton);
this.nameEdit.mouseClicked(mouseX, mouseY, mouseButton);
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, I18n.format("selectWorld.edit.title"), this.width / 2, 20, 16777215);
this.drawString(this.fontRenderer, I18n.format("selectWorld.enterName"), this.width / 2 - 100, 47, 10526880);
this.nameEdit.drawTextBox();
super.drawScreen(mouseX, mouseY, partialTicks);
}
}

View File

@@ -0,0 +1,162 @@
package net.minecraft.client.gui;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import java.io.IOException;
import javax.annotation.Nullable;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@SideOnly(Side.CLIENT)
public class GuiWorldSelection extends GuiScreen
{
private static final Logger LOGGER = LogManager.getLogger();
/** The screen to return to when this closes (always Main Menu). */
protected GuiScreen prevScreen;
protected String title = "Select world";
/** Tooltip displayed a world whose version is different from this client's */
private String worldVersTooltip;
private GuiButton deleteButton;
private GuiButton selectButton;
private GuiButton renameButton;
private GuiButton copyButton;
private GuiListWorldSelection selectionList;
public GuiWorldSelection(GuiScreen screenIn)
{
this.prevScreen = screenIn;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.title = I18n.format("selectWorld.title");
this.selectionList = new GuiListWorldSelection(this, this.mc, this.width, this.height, 32, this.height - 64, 36);
this.postInit();
}
/**
* Handles mouse input.
*/
public void handleMouseInput() throws IOException
{
super.handleMouseInput();
this.selectionList.handleMouseInput();
}
public void postInit()
{
this.selectButton = this.addButton(new GuiButton(1, this.width / 2 - 154, this.height - 52, 150, 20, I18n.format("selectWorld.select")));
this.addButton(new GuiButton(3, this.width / 2 + 4, this.height - 52, 150, 20, I18n.format("selectWorld.create")));
this.renameButton = this.addButton(new GuiButton(4, this.width / 2 - 154, this.height - 28, 72, 20, I18n.format("selectWorld.edit")));
this.deleteButton = this.addButton(new GuiButton(2, this.width / 2 - 76, this.height - 28, 72, 20, I18n.format("selectWorld.delete")));
this.copyButton = this.addButton(new GuiButton(5, this.width / 2 + 4, this.height - 28, 72, 20, I18n.format("selectWorld.recreate")));
this.addButton(new GuiButton(0, this.width / 2 + 82, this.height - 28, 72, 20, I18n.format("gui.cancel")));
this.selectButton.enabled = false;
this.deleteButton.enabled = false;
this.renameButton.enabled = false;
this.copyButton.enabled = false;
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.enabled)
{
GuiListWorldSelectionEntry guilistworldselectionentry = this.selectionList.getSelectedWorld();
if (button.id == 2)
{
if (guilistworldselectionentry != null)
{
guilistworldselectionentry.deleteWorld();
}
}
else if (button.id == 1)
{
if (guilistworldselectionentry != null)
{
guilistworldselectionentry.joinWorld();
}
}
else if (button.id == 3)
{
this.mc.displayGuiScreen(new GuiCreateWorld(this));
}
else if (button.id == 4)
{
if (guilistworldselectionentry != null)
{
guilistworldselectionentry.editWorld();
}
}
else if (button.id == 0)
{
this.mc.displayGuiScreen(this.prevScreen);
}
else if (button.id == 5 && guilistworldselectionentry != null)
{
guilistworldselectionentry.recreateWorld();
}
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.worldVersTooltip = null;
this.selectionList.drawScreen(mouseX, mouseY, partialTicks);
this.drawCenteredString(this.fontRenderer, this.title, this.width / 2, 20, 16777215);
super.drawScreen(mouseX, mouseY, partialTicks);
if (this.worldVersTooltip != null)
{
this.drawHoveringText(Lists.newArrayList(Splitter.on("\n").split(this.worldVersTooltip)), mouseX, mouseY);
}
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
super.mouseClicked(mouseX, mouseY, mouseButton);
this.selectionList.mouseClicked(mouseX, mouseY, mouseButton);
}
/**
* Called when a mouse button is released.
*/
protected void mouseReleased(int mouseX, int mouseY, int state)
{
super.mouseReleased(mouseX, mouseY, state);
this.selectionList.mouseReleased(mouseX, mouseY, state);
}
/**
* Called back by selectionList when we call its drawScreen method, from ours.
*/
public void setVersionTooltip(String p_184861_1_)
{
this.worldVersTooltip = p_184861_1_;
}
public void selectWorld(@Nullable GuiListWorldSelectionEntry entry)
{
boolean flag = entry != null;
this.selectButton.enabled = flag;
this.deleteButton.enabled = flag;
this.renameButton.enabled = flag;
this.copyButton.enabled = flag;
}
}

View File

@@ -0,0 +1,111 @@
package net.minecraft.client.gui;
import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.List;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiYesNo extends GuiScreen
{
/** A reference to the screen object that created this. Used for navigating between screens. */
protected GuiYesNoCallback parentScreen;
protected String messageLine1;
private final String messageLine2;
private final List<String> listLines = Lists.<String>newArrayList();
/** The text shown for the first button in GuiYesNo */
protected String confirmButtonText;
/** The text shown for the second button in GuiYesNo */
protected String cancelButtonText;
protected int parentButtonClickedId;
private int ticksUntilEnable;
public GuiYesNo(GuiYesNoCallback parentScreenIn, String messageLine1In, String messageLine2In, int parentButtonClickedIdIn)
{
this.parentScreen = parentScreenIn;
this.messageLine1 = messageLine1In;
this.messageLine2 = messageLine2In;
this.parentButtonClickedId = parentButtonClickedIdIn;
this.confirmButtonText = I18n.format("gui.yes");
this.cancelButtonText = I18n.format("gui.no");
}
public GuiYesNo(GuiYesNoCallback parentScreenIn, String messageLine1In, String messageLine2In, String confirmButtonTextIn, String cancelButtonTextIn, int parentButtonClickedIdIn)
{
this.parentScreen = parentScreenIn;
this.messageLine1 = messageLine1In;
this.messageLine2 = messageLine2In;
this.confirmButtonText = confirmButtonTextIn;
this.cancelButtonText = cancelButtonTextIn;
this.parentButtonClickedId = parentButtonClickedIdIn;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.buttonList.add(new GuiOptionButton(0, this.width / 2 - 155, this.height / 6 + 96, this.confirmButtonText));
this.buttonList.add(new GuiOptionButton(1, this.width / 2 - 155 + 160, this.height / 6 + 96, this.cancelButtonText));
this.listLines.clear();
this.listLines.addAll(this.fontRenderer.listFormattedStringToWidth(this.messageLine2, this.width - 50));
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
this.parentScreen.confirmClicked(button.id == 0, this.parentButtonClickedId);
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, this.messageLine1, this.width / 2, 70, 16777215);
int i = 90;
for (String s : this.listLines)
{
this.drawCenteredString(this.fontRenderer, s, this.width / 2, i, 16777215);
i += this.fontRenderer.FONT_HEIGHT;
}
super.drawScreen(mouseX, mouseY, partialTicks);
}
/**
* Sets the number of ticks to wait before enabling the buttons.
*/
public void setButtonDelay(int ticksUntilEnableIn)
{
this.ticksUntilEnable = ticksUntilEnableIn;
for (GuiButton guibutton : this.buttonList)
{
guibutton.enabled = false;
}
}
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
super.updateScreen();
if (--this.ticksUntilEnable == 0)
{
for (GuiButton guibutton : this.buttonList)
{
guibutton.enabled = true;
}
}
}
}

View File

@@ -0,0 +1,10 @@
package net.minecraft.client.gui;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public interface GuiYesNoCallback
{
void confirmClicked(boolean result, int id);
}

View File

@@ -0,0 +1,12 @@
package net.minecraft.client.gui;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public interface IProgressMeter
{
String[] LOADING_STRINGS = new String[] {"oooooo", "Oooooo", "oOoooo", "ooOooo", "oooOoo", "ooooOo", "oooooO"};
void onStatsUpdated();
}

View File

@@ -0,0 +1,187 @@
package net.minecraft.client.gui;
import com.google.common.collect.Maps;
import java.util.Map;
import javax.annotation.Nullable;
import net.minecraft.block.material.MapColor;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.storage.MapData;
import net.minecraft.world.storage.MapDecoration;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class MapItemRenderer
{
private static final ResourceLocation TEXTURE_MAP_ICONS = new ResourceLocation("textures/map/map_icons.png");
private final TextureManager textureManager;
private final Map<String, MapItemRenderer.Instance> loadedMaps = Maps.<String, MapItemRenderer.Instance>newHashMap();
public MapItemRenderer(TextureManager textureManagerIn)
{
this.textureManager = textureManagerIn;
}
/**
* Updates a map texture
*/
public void updateMapTexture(MapData mapdataIn)
{
this.getMapRendererInstance(mapdataIn).updateMapTexture();
}
public void renderMap(MapData mapdataIn, boolean noOverlayRendering)
{
this.getMapRendererInstance(mapdataIn).render(noOverlayRendering);
}
/**
* Returns {@link net.minecraft.client.gui.MapItemRenderer.Instance MapItemRenderer.Instance} with given map data
*/
private MapItemRenderer.Instance getMapRendererInstance(MapData mapdataIn)
{
MapItemRenderer.Instance mapitemrenderer$instance = this.loadedMaps.get(mapdataIn.mapName);
if (mapitemrenderer$instance == null)
{
mapitemrenderer$instance = new MapItemRenderer.Instance(mapdataIn);
this.loadedMaps.put(mapdataIn.mapName, mapitemrenderer$instance);
}
return mapitemrenderer$instance;
}
@Nullable
public MapItemRenderer.Instance getMapInstanceIfExists(String p_191205_1_)
{
return this.loadedMaps.get(p_191205_1_);
}
/**
* Clears the currently loaded maps and removes their corresponding textures
*/
public void clearLoadedMaps()
{
for (MapItemRenderer.Instance mapitemrenderer$instance : this.loadedMaps.values())
{
this.textureManager.deleteTexture(mapitemrenderer$instance.location);
}
this.loadedMaps.clear();
}
@Nullable
public MapData getData(@Nullable MapItemRenderer.Instance p_191207_1_)
{
return p_191207_1_ != null ? p_191207_1_.mapData : null;
}
@SideOnly(Side.CLIENT)
class Instance
{
private final MapData mapData;
private final DynamicTexture mapTexture;
private final ResourceLocation location;
private final int[] mapTextureData;
private Instance(MapData mapdataIn)
{
this.mapData = mapdataIn;
this.mapTexture = new DynamicTexture(128, 128);
this.mapTextureData = this.mapTexture.getTextureData();
this.location = MapItemRenderer.this.textureManager.getDynamicTextureLocation("map/" + mapdataIn.mapName, this.mapTexture);
for (int i = 0; i < this.mapTextureData.length; ++i)
{
this.mapTextureData[i] = 0;
}
}
/**
* Updates a map {@link net.minecraft.client.gui.MapItemRenderer.Instance#mapTexture texture}
*/
private void updateMapTexture()
{
for (int i = 0; i < 16384; ++i)
{
int j = this.mapData.colors[i] & 255;
if (j / 4 == 0)
{
this.mapTextureData[i] = (i + i / 128 & 1) * 8 + 16 << 24;
}
else
{
this.mapTextureData[i] = MapColor.COLORS[j / 4].getMapColor(j & 3);
}
}
this.mapTexture.updateDynamicTexture();
}
/**
* Renders map and players to it
*/
private void render(boolean noOverlayRendering)
{
int i = 0;
int j = 0;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
float f = 0.0F;
MapItemRenderer.this.textureManager.bindTexture(this.location);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ZERO, GlStateManager.DestFactor.ONE);
GlStateManager.disableAlpha();
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
bufferbuilder.pos(0.0D, 128.0D, -0.009999999776482582D).tex(0.0D, 1.0D).endVertex();
bufferbuilder.pos(128.0D, 128.0D, -0.009999999776482582D).tex(1.0D, 1.0D).endVertex();
bufferbuilder.pos(128.0D, 0.0D, -0.009999999776482582D).tex(1.0D, 0.0D).endVertex();
bufferbuilder.pos(0.0D, 0.0D, -0.009999999776482582D).tex(0.0D, 0.0D).endVertex();
tessellator.draw();
GlStateManager.enableAlpha();
GlStateManager.disableBlend();
MapItemRenderer.this.textureManager.bindTexture(MapItemRenderer.TEXTURE_MAP_ICONS);
int k = 0;
for (MapDecoration mapdecoration : this.mapData.mapDecorations.values())
{
if (!noOverlayRendering || mapdecoration.renderOnFrame())
{
if (mapdecoration.render(k)) { k++; continue; }
MapItemRenderer.this.textureManager.bindTexture(MapItemRenderer.TEXTURE_MAP_ICONS); // Rebind in case custom render changes it
GlStateManager.pushMatrix();
GlStateManager.translate(0.0F + (float)mapdecoration.getX() / 2.0F + 64.0F, 0.0F + (float)mapdecoration.getY() / 2.0F + 64.0F, -0.02F);
GlStateManager.rotate((float)(mapdecoration.getRotation() * 360) / 16.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.scale(4.0F, 4.0F, 3.0F);
GlStateManager.translate(-0.125F, 0.125F, 0.0F);
byte b0 = mapdecoration.getImage();
float f1 = (float)(b0 % 4 + 0) / 4.0F;
float f2 = (float)(b0 / 4 + 0) / 4.0F;
float f3 = (float)(b0 % 4 + 1) / 4.0F;
float f4 = (float)(b0 / 4 + 1) / 4.0F;
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
float f5 = -0.001F;
bufferbuilder.pos(-1.0D, 1.0D, (double)((float)k * -0.001F)).tex((double)f1, (double)f2).endVertex();
bufferbuilder.pos(1.0D, 1.0D, (double)((float)k * -0.001F)).tex((double)f3, (double)f2).endVertex();
bufferbuilder.pos(1.0D, -1.0D, (double)((float)k * -0.001F)).tex((double)f3, (double)f4).endVertex();
bufferbuilder.pos(-1.0D, -1.0D, (double)((float)k * -0.001F)).tex((double)f1, (double)f4).endVertex();
tessellator.draw();
GlStateManager.popMatrix();
++k;
}
}
GlStateManager.pushMatrix();
GlStateManager.translate(0.0F, 0.0F, -0.04F);
GlStateManager.scale(1.0F, 1.0F, 1.0F);
GlStateManager.popMatrix();
}
}
}

View File

@@ -0,0 +1,70 @@
package net.minecraft.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ScaledResolution
{
private final double scaledWidthD;
private final double scaledHeightD;
private int scaledWidth;
private int scaledHeight;
private int scaleFactor;
public ScaledResolution(Minecraft minecraftClient)
{
this.scaledWidth = minecraftClient.displayWidth;
this.scaledHeight = minecraftClient.displayHeight;
this.scaleFactor = 1;
boolean flag = minecraftClient.isUnicode();
int i = minecraftClient.gameSettings.guiScale;
if (i == 0)
{
i = 1000;
}
while (this.scaleFactor < i && this.scaledWidth / (this.scaleFactor + 1) >= 320 && this.scaledHeight / (this.scaleFactor + 1) >= 240)
{
++this.scaleFactor;
}
if (flag && this.scaleFactor % 2 != 0 && this.scaleFactor != 1)
{
--this.scaleFactor;
}
this.scaledWidthD = (double)this.scaledWidth / (double)this.scaleFactor;
this.scaledHeightD = (double)this.scaledHeight / (double)this.scaleFactor;
this.scaledWidth = MathHelper.ceil(this.scaledWidthD);
this.scaledHeight = MathHelper.ceil(this.scaledHeightD);
}
public int getScaledWidth()
{
return this.scaledWidth;
}
public int getScaledHeight()
{
return this.scaledHeight;
}
public double getScaledWidth_double()
{
return this.scaledWidthD;
}
public double getScaledHeight_double()
{
return this.scaledHeightD;
}
public int getScaleFactor()
{
return this.scaleFactor;
}
}

View File

@@ -0,0 +1,107 @@
package net.minecraft.client.gui;
import java.io.IOException;
import net.minecraft.client.gui.chat.NarratorChatListener;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.GameSettings;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ScreenChatOptions extends GuiScreen
{
private static final GameSettings.Options[] CHAT_OPTIONS = new GameSettings.Options[] {GameSettings.Options.CHAT_VISIBILITY, GameSettings.Options.CHAT_COLOR, GameSettings.Options.CHAT_LINKS, GameSettings.Options.CHAT_OPACITY, GameSettings.Options.CHAT_LINKS_PROMPT, GameSettings.Options.CHAT_SCALE, GameSettings.Options.CHAT_HEIGHT_FOCUSED, GameSettings.Options.CHAT_HEIGHT_UNFOCUSED, GameSettings.Options.CHAT_WIDTH, GameSettings.Options.REDUCED_DEBUG_INFO, GameSettings.Options.NARRATOR};
private final GuiScreen parentScreen;
private final GameSettings game_settings;
private String chatTitle;
private GuiOptionButton narratorButton;
public ScreenChatOptions(GuiScreen parentScreenIn, GameSettings gameSettingsIn)
{
this.parentScreen = parentScreenIn;
this.game_settings = gameSettingsIn;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.chatTitle = I18n.format("options.chat.title");
int i = 0;
for (GameSettings.Options gamesettings$options : CHAT_OPTIONS)
{
if (gamesettings$options.isFloat())
{
this.buttonList.add(new GuiOptionSlider(gamesettings$options.getOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), gamesettings$options));
}
else
{
GuiOptionButton guioptionbutton = new GuiOptionButton(gamesettings$options.getOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), gamesettings$options, this.game_settings.getKeyBinding(gamesettings$options));
this.buttonList.add(guioptionbutton);
if (gamesettings$options == GameSettings.Options.NARRATOR)
{
this.narratorButton = guioptionbutton;
guioptionbutton.enabled = NarratorChatListener.INSTANCE.isActive();
}
}
++i;
}
this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 144, I18n.format("gui.done")));
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
if (keyCode == 1)
{
this.mc.gameSettings.saveOptions();
}
super.keyTyped(typedChar, keyCode);
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.enabled)
{
if (button.id < 100 && button instanceof GuiOptionButton)
{
this.game_settings.setOptionValue(((GuiOptionButton)button).getOption(), 1);
button.displayString = this.game_settings.getKeyBinding(GameSettings.Options.byOrdinal(button.id));
}
if (button.id == 200)
{
this.mc.gameSettings.saveOptions();
this.mc.displayGuiScreen(this.parentScreen);
}
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, this.chatTitle, this.width / 2, 20, 16777215);
super.drawScreen(mouseX, mouseY, partialTicks);
}
public void updateNarratorButton()
{
this.narratorButton.displayString = this.game_settings.getKeyBinding(GameSettings.Options.byOrdinal(this.narratorButton.id));
}
}

View File

@@ -0,0 +1,71 @@
package net.minecraft.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.network.LanServerInfo;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ServerListEntryLanDetected implements GuiListExtended.IGuiListEntry
{
private final GuiMultiplayer screen;
protected final Minecraft mc;
protected final LanServerInfo serverData;
private long lastClickTime;
protected ServerListEntryLanDetected(GuiMultiplayer p_i47141_1_, LanServerInfo p_i47141_2_)
{
this.screen = p_i47141_1_;
this.serverData = p_i47141_2_;
this.mc = Minecraft.getMinecraft();
}
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float partialTicks)
{
this.mc.fontRenderer.drawString(I18n.format("lanServer.title"), x + 32 + 3, y + 1, 16777215);
this.mc.fontRenderer.drawString(this.serverData.getServerMotd(), x + 32 + 3, y + 12, 8421504);
if (this.mc.gameSettings.hideServerAddress)
{
this.mc.fontRenderer.drawString(I18n.format("selectServer.hiddenAddress"), x + 32 + 3, y + 12 + 11, 3158064);
}
else
{
this.mc.fontRenderer.drawString(this.serverData.getServerIpPort(), x + 32 + 3, y + 12 + 11, 3158064);
}
}
/**
* 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)
{
this.screen.selectServer(slotIndex);
if (Minecraft.getSystemTime() - this.lastClickTime < 250L)
{
this.screen.connectToSelected();
}
this.lastClickTime = Minecraft.getSystemTime();
return false;
}
public void updatePosition(int slotIndex, int x, int y, float partialTicks)
{
}
/**
* Fired when the mouse button is released. Arguments: index, x, y, mouseEvent, relativeX, relativeY
*/
public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY)
{
}
public LanServerInfo getServerData()
{
return this.serverData;
}
}

View File

@@ -0,0 +1,55 @@
package net.minecraft.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ServerListEntryLanScan implements GuiListExtended.IGuiListEntry
{
private final Minecraft mc = Minecraft.getMinecraft();
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float partialTicks)
{
int i = y + slotHeight / 2 - this.mc.fontRenderer.FONT_HEIGHT / 2;
this.mc.fontRenderer.drawString(I18n.format("lanServer.scanning"), this.mc.currentScreen.width / 2 - this.mc.fontRenderer.getStringWidth(I18n.format("lanServer.scanning")) / 2, i, 16777215);
String s;
switch ((int)(Minecraft.getSystemTime() / 300L % 4L))
{
case 0:
default:
s = "O o o";
break;
case 1:
case 3:
s = "o O o";
break;
case 2:
s = "o o O";
}
this.mc.fontRenderer.drawString(s, this.mc.currentScreen.width / 2 - this.mc.fontRenderer.getStringWidth(s) / 2, i + this.mc.fontRenderer.FONT_HEIGHT, 8421504);
}
public void updatePosition(int slotIndex, int x, int y, float partialTicks)
{
}
/**
* 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)
{
return false;
}
/**
* Fired when the mouse button is released. Arguments: index, x, y, mouseEvent, relativeX, relativeY
*/
public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY)
{
}
}

View File

@@ -0,0 +1,358 @@
package net.minecraft.client.gui;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.Unpooled;
import io.netty.handler.codec.base64.Base64;
import java.awt.image.BufferedImage;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadPoolExecutor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.Validate;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@SideOnly(Side.CLIENT)
public class ServerListEntryNormal implements GuiListExtended.IGuiListEntry
{
private static final Logger LOGGER = LogManager.getLogger();
private static final ThreadPoolExecutor EXECUTOR = new ScheduledThreadPoolExecutor(5, (new ThreadFactoryBuilder()).setNameFormat("Server Pinger #%d").setDaemon(true).build());
private static final ResourceLocation UNKNOWN_SERVER = new ResourceLocation("textures/misc/unknown_server.png");
private static final ResourceLocation SERVER_SELECTION_BUTTONS = new ResourceLocation("textures/gui/server_selection.png");
private final GuiMultiplayer owner;
private final Minecraft mc;
private final ServerData server;
private final ResourceLocation serverIcon;
private String lastIconB64;
private DynamicTexture icon;
private long lastClickTime;
protected ServerListEntryNormal(GuiMultiplayer ownerIn, ServerData serverIn)
{
this.owner = ownerIn;
this.server = serverIn;
this.mc = Minecraft.getMinecraft();
this.serverIcon = new ResourceLocation("servers/" + serverIn.serverIP + "/icon");
this.icon = (DynamicTexture)this.mc.getTextureManager().getTexture(this.serverIcon);
}
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float partialTicks)
{
if (!this.server.pinged)
{
this.server.pinged = true;
this.server.pingToServer = -2L;
this.server.serverMOTD = "";
this.server.populationInfo = "";
EXECUTOR.submit(new Runnable()
{
public void run()
{
try
{
ServerListEntryNormal.this.owner.getOldServerPinger().ping(ServerListEntryNormal.this.server);
}
catch (UnknownHostException var2)
{
ServerListEntryNormal.this.server.pingToServer = -1L;
ServerListEntryNormal.this.server.serverMOTD = TextFormatting.DARK_RED + I18n.format("multiplayer.status.cannot_resolve");
}
catch (Exception var3)
{
ServerListEntryNormal.this.server.pingToServer = -1L;
ServerListEntryNormal.this.server.serverMOTD = TextFormatting.DARK_RED + I18n.format("multiplayer.status.cannot_connect");
}
}
});
}
boolean flag = this.server.version > 340;
boolean flag1 = this.server.version < 340;
boolean flag2 = flag || flag1;
this.mc.fontRenderer.drawString(this.server.serverName, x + 32 + 3, y + 1, 16777215);
List<String> list = this.mc.fontRenderer.listFormattedStringToWidth(net.minecraftforge.fml.client.FMLClientHandler.instance().fixDescription(this.server.serverMOTD), listWidth - 32 - 2);
for (int i = 0; i < Math.min(list.size(), 2); ++i)
{
this.mc.fontRenderer.drawString(list.get(i), x + 32 + 3, y + 12 + this.mc.fontRenderer.FONT_HEIGHT * i, 8421504);
}
String s2 = flag2 ? TextFormatting.DARK_RED + this.server.gameVersion : this.server.populationInfo;
int j = this.mc.fontRenderer.getStringWidth(s2);
this.mc.fontRenderer.drawString(s2, x + listWidth - j - 15 - 2, y + 1, 8421504);
int k = 0;
String s = null;
int l;
String s1;
if (flag2)
{
l = 5;
s1 = I18n.format(flag ? "multiplayer.status.client_out_of_date" : "multiplayer.status.server_out_of_date");
s = this.server.playerList;
}
else if (this.server.pinged && this.server.pingToServer != -2L)
{
if (this.server.pingToServer < 0L)
{
l = 5;
}
else if (this.server.pingToServer < 150L)
{
l = 0;
}
else if (this.server.pingToServer < 300L)
{
l = 1;
}
else if (this.server.pingToServer < 600L)
{
l = 2;
}
else if (this.server.pingToServer < 1000L)
{
l = 3;
}
else
{
l = 4;
}
if (this.server.pingToServer < 0L)
{
s1 = I18n.format("multiplayer.status.no_connection");
}
else
{
s1 = this.server.pingToServer + "ms";
s = this.server.playerList;
}
}
else
{
k = 1;
l = (int)(Minecraft.getSystemTime() / 100L + (long)(slotIndex * 2) & 7L);
if (l > 4)
{
l = 8 - l;
}
s1 = I18n.format("multiplayer.status.pinging");
}
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(Gui.ICONS);
Gui.drawModalRectWithCustomSizedTexture(x + listWidth - 15, y, (float)(k * 10), (float)(176 + l * 8), 10, 8, 256.0F, 256.0F);
if (this.server.getBase64EncodedIconData() != null && !this.server.getBase64EncodedIconData().equals(this.lastIconB64))
{
this.lastIconB64 = this.server.getBase64EncodedIconData();
this.prepareServerIcon();
this.owner.getServerList().saveServerList();
}
if (this.icon != null)
{
this.drawTextureAt(x, y, this.serverIcon);
}
else
{
this.drawTextureAt(x, y, UNKNOWN_SERVER);
}
int i1 = mouseX - x;
int j1 = mouseY - y;
String tooltip = net.minecraftforge.fml.client.FMLClientHandler.instance().enhanceServerListEntry(this, this.server, x, listWidth, y, i1, j1);
if (tooltip != null)
{
this.owner.setHoveringText(tooltip);
} else
if (i1 >= listWidth - 15 && i1 <= listWidth - 5 && j1 >= 0 && j1 <= 8)
{
this.owner.setHoveringText(s1);
}
else if (i1 >= listWidth - j - 15 - 2 && i1 <= listWidth - 15 - 2 && j1 >= 0 && j1 <= 8)
{
this.owner.setHoveringText(s);
}
if (this.mc.gameSettings.touchscreen || isSelected)
{
this.mc.getTextureManager().bindTexture(SERVER_SELECTION_BUTTONS);
Gui.drawRect(x, y, x + 32, y + 32, -1601138544);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
int k1 = mouseX - x;
int l1 = mouseY - y;
if (this.canJoin())
{
if (k1 < 32 && k1 > 16)
{
Gui.drawModalRectWithCustomSizedTexture(x, y, 0.0F, 32.0F, 32, 32, 256.0F, 256.0F);
}
else
{
Gui.drawModalRectWithCustomSizedTexture(x, y, 0.0F, 0.0F, 32, 32, 256.0F, 256.0F);
}
}
if (this.owner.canMoveUp(this, slotIndex))
{
if (k1 < 16 && l1 < 16)
{
Gui.drawModalRectWithCustomSizedTexture(x, y, 96.0F, 32.0F, 32, 32, 256.0F, 256.0F);
}
else
{
Gui.drawModalRectWithCustomSizedTexture(x, y, 96.0F, 0.0F, 32, 32, 256.0F, 256.0F);
}
}
if (this.owner.canMoveDown(this, slotIndex))
{
if (k1 < 16 && l1 > 16)
{
Gui.drawModalRectWithCustomSizedTexture(x, y, 64.0F, 32.0F, 32, 32, 256.0F, 256.0F);
}
else
{
Gui.drawModalRectWithCustomSizedTexture(x, y, 64.0F, 0.0F, 32, 32, 256.0F, 256.0F);
}
}
}
}
protected void drawTextureAt(int p_178012_1_, int p_178012_2_, ResourceLocation p_178012_3_)
{
this.mc.getTextureManager().bindTexture(p_178012_3_);
GlStateManager.enableBlend();
Gui.drawModalRectWithCustomSizedTexture(p_178012_1_, p_178012_2_, 0.0F, 0.0F, 32, 32, 32.0F, 32.0F);
GlStateManager.disableBlend();
}
private boolean canJoin()
{
return true;
}
private void prepareServerIcon()
{
if (this.server.getBase64EncodedIconData() == null)
{
this.mc.getTextureManager().deleteTexture(this.serverIcon);
this.icon = null;
}
else
{
ByteBuf bytebuf = Unpooled.copiedBuffer((CharSequence)this.server.getBase64EncodedIconData(), StandardCharsets.UTF_8);
ByteBuf bytebuf1 = null;
BufferedImage bufferedimage;
label99:
{
try
{
bytebuf1 = Base64.decode(bytebuf);
bufferedimage = TextureUtil.readBufferedImage(new ByteBufInputStream(bytebuf1));
Validate.validState(bufferedimage.getWidth() == 64, "Must be 64 pixels wide");
Validate.validState(bufferedimage.getHeight() == 64, "Must be 64 pixels high");
break label99;
}
catch (Throwable throwable)
{
LOGGER.error("Invalid icon for server {} ({})", this.server.serverName, this.server.serverIP, throwable);
this.server.setBase64EncodedIconData((String)null);
}
finally
{
bytebuf.release();
if (bytebuf1 != null)
{
bytebuf1.release();
}
}
return;
}
if (this.icon == null)
{
this.icon = new DynamicTexture(bufferedimage.getWidth(), bufferedimage.getHeight());
this.mc.getTextureManager().loadTexture(this.serverIcon, this.icon);
}
bufferedimage.getRGB(0, 0, bufferedimage.getWidth(), bufferedimage.getHeight(), this.icon.getTextureData(), 0, bufferedimage.getWidth());
this.icon.updateDynamicTexture();
}
}
/**
* 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 (relativeX <= 32)
{
if (relativeX < 32 && relativeX > 16 && this.canJoin())
{
this.owner.selectServer(slotIndex);
this.owner.connectToSelected();
return true;
}
if (relativeX < 16 && relativeY < 16 && this.owner.canMoveUp(this, slotIndex))
{
this.owner.moveServerUp(this, slotIndex, GuiScreen.isShiftKeyDown());
return true;
}
if (relativeX < 16 && relativeY > 16 && this.owner.canMoveDown(this, slotIndex))
{
this.owner.moveServerDown(this, slotIndex, GuiScreen.isShiftKeyDown());
return true;
}
}
this.owner.selectServer(slotIndex);
if (Minecraft.getSystemTime() - this.lastClickTime < 250L)
{
this.owner.connectToSelected();
}
this.lastClickTime = Minecraft.getSystemTime();
return false;
}
public void updatePosition(int slotIndex, int x, int y, float partialTicks)
{
}
/**
* Fired when the mouse button is released. Arguments: index, x, y, mouseEvent, relativeX, relativeY
*/
public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY)
{
}
public ServerData getServerData()
{
return this.server;
}
}

View File

@@ -0,0 +1,106 @@
package net.minecraft.client.gui;
import com.google.common.collect.Lists;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ServerList;
import net.minecraft.client.network.LanServerInfo;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ServerSelectionList extends GuiListExtended
{
private final GuiMultiplayer owner;
private final List<ServerListEntryNormal> serverListInternet = Lists.<ServerListEntryNormal>newArrayList();
private final List<ServerListEntryLanDetected> serverListLan = Lists.<ServerListEntryLanDetected>newArrayList();
private final GuiListExtended.IGuiListEntry lanScanEntry = new ServerListEntryLanScan();
private int selectedSlotIndex = -1;
public ServerSelectionList(GuiMultiplayer ownerIn, Minecraft mcIn, int widthIn, int heightIn, int topIn, int bottomIn, int slotHeightIn)
{
super(mcIn, widthIn, heightIn, topIn, bottomIn, slotHeightIn);
this.owner = ownerIn;
}
/**
* Gets the IGuiListEntry object for the given index
*/
public GuiListExtended.IGuiListEntry getListEntry(int index)
{
if (index < this.serverListInternet.size())
{
return this.serverListInternet.get(index);
}
else
{
index = index - this.serverListInternet.size();
if (index == 0)
{
return this.lanScanEntry;
}
else
{
--index;
return this.serverListLan.get(index);
}
}
}
protected int getSize()
{
return this.serverListInternet.size() + 1 + this.serverListLan.size();
}
public void setSelectedSlotIndex(int selectedSlotIndexIn)
{
this.selectedSlotIndex = selectedSlotIndexIn;
}
/**
* Returns true if the element passed in is currently selected
*/
protected boolean isSelected(int slotIndex)
{
return slotIndex == this.selectedSlotIndex;
}
public int getSelected()
{
return this.selectedSlotIndex;
}
public void updateOnlineServers(ServerList p_148195_1_)
{
this.serverListInternet.clear();
for (int i = 0; i < p_148195_1_.countServers(); ++i)
{
this.serverListInternet.add(new ServerListEntryNormal(this.owner, p_148195_1_.getServerData(i)));
}
}
public void updateNetworkServers(List<LanServerInfo> p_148194_1_)
{
this.serverListLan.clear();
for (LanServerInfo lanserverinfo : p_148194_1_)
{
this.serverListLan.add(new ServerListEntryLanDetected(this.owner, lanserverinfo));
}
}
protected int getScrollBarX()
{
return super.getScrollBarX() + 30;
}
/**
* Gets the width of the list
*/
public int getListWidth()
{
return super.getListWidth() + 85;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
// Auto generated package-info by MCP
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package net.minecraft.client.gui.achievement;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View File

@@ -0,0 +1,23 @@
package net.minecraft.client.gui.advancements;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public enum AdvancementState
{
OBTAINED(0),
UNOBTAINED(1);
private final int id;
private AdvancementState(int id)
{
this.id = id;
}
public int getId()
{
return this.id;
}
}

View File

@@ -0,0 +1,136 @@
package net.minecraft.client.gui.advancements;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
enum AdvancementTabType
{
ABOVE(0, 0, 28, 32, 8),
BELOW(84, 0, 28, 32, 8),
LEFT(0, 64, 32, 28, 5),
RIGHT(96, 64, 32, 28, 5);
public static final int MAX_TABS;
private final int textureX;
private final int textureY;
private final int width;
private final int height;
private final int max;
private AdvancementTabType(int p_i47386_3_, int p_i47386_4_, int widthIn, int heightIn, int p_i47386_7_)
{
this.textureX = p_i47386_3_;
this.textureY = p_i47386_4_;
this.width = widthIn;
this.height = heightIn;
this.max = p_i47386_7_;
}
public int getMax()
{
return this.max;
}
public void draw(Gui guiIn, int x, int y, boolean p_192651_4_, int p_192651_5_)
{
int i = this.textureX;
if (p_192651_5_ > 0)
{
i += this.width;
}
if (p_192651_5_ == this.max - 1)
{
i += this.width;
}
int j = p_192651_4_ ? this.textureY + this.height : this.textureY;
guiIn.drawTexturedModalRect(x + this.getX(p_192651_5_), y + this.getY(p_192651_5_), i, j, this.width, this.height);
}
public void drawIcon(int p_192652_1_, int p_192652_2_, int p_192652_3_, RenderItem renderItemIn, ItemStack stack)
{
int i = p_192652_1_ + this.getX(p_192652_3_);
int j = p_192652_2_ + this.getY(p_192652_3_);
switch (this)
{
case ABOVE:
i += 6;
j += 9;
break;
case BELOW:
i += 6;
j += 6;
break;
case LEFT:
i += 10;
j += 5;
break;
case RIGHT:
i += 6;
j += 5;
}
renderItemIn.renderItemAndEffectIntoGUI((EntityLivingBase)null, stack, i, j);
}
public int getX(int p_192648_1_)
{
switch (this)
{
case ABOVE:
return (this.width + 4) * p_192648_1_;
case BELOW:
return (this.width + 4) * p_192648_1_;
case LEFT:
return -this.width + 4;
case RIGHT:
return 248;
default:
throw new UnsupportedOperationException("Don't know what this tab type is!" + this);
}
}
public int getY(int p_192653_1_)
{
switch (this)
{
case ABOVE:
return -this.height + 4;
case BELOW:
return 136;
case LEFT:
return this.height * p_192653_1_;
case RIGHT:
return this.height * p_192653_1_;
default:
throw new UnsupportedOperationException("Don't know what this tab type is!" + this);
}
}
public boolean isMouseOver(int p_192654_1_, int p_192654_2_, int p_192654_3_, int p_192654_4_, int p_192654_5_)
{
int i = p_192654_1_ + this.getX(p_192654_3_);
int j = p_192654_2_ + this.getY(p_192654_3_);
return p_192654_4_ > i && p_192654_4_ < i + this.width && p_192654_5_ > j && p_192654_5_ < j + this.height;
}
static
{
int i = 0;
for (AdvancementTabType advancementtabtype : values())
{
i += advancementtabtype.max;
}
MAX_TABS = i;
}
}

View File

@@ -0,0 +1,386 @@
package net.minecraft.client.gui.advancements;
import com.google.common.collect.Lists;
import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.AdvancementProgress;
import net.minecraft.advancements.DisplayInfo;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiAdvancement extends Gui
{
private static final ResourceLocation WIDGETS = new ResourceLocation("textures/gui/advancements/widgets.png");
private static final Pattern PATTERN = Pattern.compile("(.+) \\S+");
private final GuiAdvancementTab guiAdvancementTab;
private final Advancement advancement;
private final DisplayInfo displayInfo;
private final String title;
private final int width;
private final List<String> description;
private final Minecraft minecraft;
private GuiAdvancement parent;
private final List<GuiAdvancement> children = Lists.<GuiAdvancement>newArrayList();
private AdvancementProgress advancementProgress;
private final int x;
private final int y;
public GuiAdvancement(GuiAdvancementTab p_i47385_1_, Minecraft p_i47385_2_, Advancement p_i47385_3_, DisplayInfo p_i47385_4_)
{
this.guiAdvancementTab = p_i47385_1_;
this.advancement = p_i47385_3_;
this.displayInfo = p_i47385_4_;
this.minecraft = p_i47385_2_;
this.title = p_i47385_2_.fontRenderer.trimStringToWidth(p_i47385_4_.getTitle().getFormattedText(), 163);
this.x = MathHelper.floor(p_i47385_4_.getX() * 28.0F);
this.y = MathHelper.floor(p_i47385_4_.getY() * 27.0F);
int i = p_i47385_3_.getRequirementCount();
int j = String.valueOf(i).length();
int k = i > 1 ? p_i47385_2_.fontRenderer.getStringWidth(" ") + p_i47385_2_.fontRenderer.getStringWidth("0") * j * 2 + p_i47385_2_.fontRenderer.getStringWidth("/") : 0;
int l = 29 + p_i47385_2_.fontRenderer.getStringWidth(this.title) + k;
String s = p_i47385_4_.getDescription().getFormattedText();
this.description = this.findOptimalLines(s, l);
for (String s1 : this.description)
{
l = Math.max(l, p_i47385_2_.fontRenderer.getStringWidth(s1));
}
this.width = l + 3 + 5;
}
private List<String> findOptimalLines(String p_192995_1_, int p_192995_2_)
{
if (p_192995_1_.isEmpty())
{
return Collections.<String>emptyList();
}
else
{
List<String> list = this.minecraft.fontRenderer.listFormattedStringToWidth(p_192995_1_, p_192995_2_);
if (list.size() < 2)
{
return list;
}
else
{
String s = list.get(0);
String s1 = list.get(1);
int i = this.minecraft.fontRenderer.getStringWidth(s + ' ' + s1.split(" ")[0]);
if (i - p_192995_2_ <= 10)
{
return this.minecraft.fontRenderer.listFormattedStringToWidth(p_192995_1_, i);
}
else
{
Matcher matcher = PATTERN.matcher(s);
if (matcher.matches())
{
int j = this.minecraft.fontRenderer.getStringWidth(matcher.group(1));
if (p_192995_2_ - j <= 10)
{
return this.minecraft.fontRenderer.listFormattedStringToWidth(p_192995_1_, j);
}
}
return list;
}
}
}
}
@Nullable
private GuiAdvancement getFirstVisibleParent(Advancement advancementIn)
{
while (true)
{
advancementIn = advancementIn.getParent();
if (advancementIn == null || advancementIn.getDisplay() != null)
{
break;
}
}
if (advancementIn != null && advancementIn.getDisplay() != null)
{
return this.guiAdvancementTab.getAdvancementGui(advancementIn);
}
else
{
return null;
}
}
public void drawConnectivity(int p_191819_1_, int p_191819_2_, boolean p_191819_3_)
{
if (this.parent != null)
{
int i = p_191819_1_ + this.parent.x + 13;
int j = p_191819_1_ + this.parent.x + 26 + 4;
int k = p_191819_2_ + this.parent.y + 13;
int l = p_191819_1_ + this.x + 13;
int i1 = p_191819_2_ + this.y + 13;
int j1 = p_191819_3_ ? -16777216 : -1;
if (p_191819_3_)
{
this.drawHorizontalLine(j, i, k - 1, j1);
this.drawHorizontalLine(j + 1, i, k, j1);
this.drawHorizontalLine(j, i, k + 1, j1);
this.drawHorizontalLine(l, j - 1, i1 - 1, j1);
this.drawHorizontalLine(l, j - 1, i1, j1);
this.drawHorizontalLine(l, j - 1, i1 + 1, j1);
this.drawVerticalLine(j - 1, i1, k, j1);
this.drawVerticalLine(j + 1, i1, k, j1);
}
else
{
this.drawHorizontalLine(j, i, k, j1);
this.drawHorizontalLine(l, j, i1, j1);
this.drawVerticalLine(j, i1, k, j1);
}
}
for (GuiAdvancement guiadvancement : this.children)
{
guiadvancement.drawConnectivity(p_191819_1_, p_191819_2_, p_191819_3_);
}
}
public void draw(int p_191817_1_, int p_191817_2_)
{
if (!this.displayInfo.isHidden() || this.advancementProgress != null && this.advancementProgress.isDone())
{
float f = this.advancementProgress == null ? 0.0F : this.advancementProgress.getPercent();
AdvancementState advancementstate;
if (f >= 1.0F)
{
advancementstate = AdvancementState.OBTAINED;
}
else
{
advancementstate = AdvancementState.UNOBTAINED;
}
this.minecraft.getTextureManager().bindTexture(WIDGETS);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.enableBlend();
this.drawTexturedModalRect(p_191817_1_ + this.x + 3, p_191817_2_ + this.y, this.displayInfo.getFrame().getIcon(), 128 + advancementstate.getId() * 26, 26, 26);
RenderHelper.enableGUIStandardItemLighting();
this.minecraft.getRenderItem().renderItemAndEffectIntoGUI((EntityLivingBase)null, this.displayInfo.getIcon(), p_191817_1_ + this.x + 8, p_191817_2_ + this.y + 5);
}
for (GuiAdvancement guiadvancement : this.children)
{
guiadvancement.draw(p_191817_1_, p_191817_2_);
}
}
public void getAdvancementProgress(AdvancementProgress advancementProgressIn)
{
this.advancementProgress = advancementProgressIn;
}
public void addGuiAdvancement(GuiAdvancement guiAdvancementIn)
{
this.children.add(guiAdvancementIn);
}
public void drawHover(int p_191821_1_, int p_191821_2_, float p_191821_3_, int p_191821_4_, int p_191821_5_)
{
boolean flag = p_191821_4_ + p_191821_1_ + this.x + this.width + 26 >= this.guiAdvancementTab.getScreen().width;
String s = this.advancementProgress == null ? null : this.advancementProgress.getProgressText();
int i = s == null ? 0 : this.minecraft.fontRenderer.getStringWidth(s);
boolean flag1 = 113 - p_191821_2_ - this.y - 26 <= 6 + this.description.size() * this.minecraft.fontRenderer.FONT_HEIGHT;
float f = this.advancementProgress == null ? 0.0F : this.advancementProgress.getPercent();
int j = MathHelper.floor(f * (float)this.width);
AdvancementState advancementstate;
AdvancementState advancementstate1;
AdvancementState advancementstate2;
if (f >= 1.0F)
{
j = this.width / 2;
advancementstate = AdvancementState.OBTAINED;
advancementstate1 = AdvancementState.OBTAINED;
advancementstate2 = AdvancementState.OBTAINED;
}
else if (j < 2)
{
j = this.width / 2;
advancementstate = AdvancementState.UNOBTAINED;
advancementstate1 = AdvancementState.UNOBTAINED;
advancementstate2 = AdvancementState.UNOBTAINED;
}
else if (j > this.width - 2)
{
j = this.width / 2;
advancementstate = AdvancementState.OBTAINED;
advancementstate1 = AdvancementState.OBTAINED;
advancementstate2 = AdvancementState.UNOBTAINED;
}
else
{
advancementstate = AdvancementState.OBTAINED;
advancementstate1 = AdvancementState.UNOBTAINED;
advancementstate2 = AdvancementState.UNOBTAINED;
}
int k = this.width - j;
this.minecraft.getTextureManager().bindTexture(WIDGETS);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.enableBlend();
int l = p_191821_2_ + this.y;
int i1;
if (flag)
{
i1 = p_191821_1_ + this.x - this.width + 26 + 6;
}
else
{
i1 = p_191821_1_ + this.x;
}
int j1 = 32 + this.description.size() * this.minecraft.fontRenderer.FONT_HEIGHT;
if (!this.description.isEmpty())
{
if (flag1)
{
this.render9Sprite(i1, l + 26 - j1, this.width, j1, 10, 200, 26, 0, 52);
}
else
{
this.render9Sprite(i1, l, this.width, j1, 10, 200, 26, 0, 52);
}
}
this.drawTexturedModalRect(i1, l, 0, advancementstate.getId() * 26, j, 26);
this.drawTexturedModalRect(i1 + j, l, 200 - k, advancementstate1.getId() * 26, k, 26);
this.drawTexturedModalRect(p_191821_1_ + this.x + 3, p_191821_2_ + this.y, this.displayInfo.getFrame().getIcon(), 128 + advancementstate2.getId() * 26, 26, 26);
if (flag)
{
this.minecraft.fontRenderer.drawString(this.title, (float)(i1 + 5), (float)(p_191821_2_ + this.y + 9), -1, true);
if (s != null)
{
this.minecraft.fontRenderer.drawString(s, (float)(p_191821_1_ + this.x - i), (float)(p_191821_2_ + this.y + 9), -1, true);
}
}
else
{
this.minecraft.fontRenderer.drawString(this.title, (float)(p_191821_1_ + this.x + 32), (float)(p_191821_2_ + this.y + 9), -1, true);
if (s != null)
{
this.minecraft.fontRenderer.drawString(s, (float)(p_191821_1_ + this.x + this.width - i - 5), (float)(p_191821_2_ + this.y + 9), -1, true);
}
}
if (flag1)
{
for (int k1 = 0; k1 < this.description.size(); ++k1)
{
this.minecraft.fontRenderer.drawString(this.description.get(k1), (float)(i1 + 5), (float)(l + 26 - j1 + 7 + k1 * this.minecraft.fontRenderer.FONT_HEIGHT), -5592406, false);
}
}
else
{
for (int l1 = 0; l1 < this.description.size(); ++l1)
{
this.minecraft.fontRenderer.drawString(this.description.get(l1), (float)(i1 + 5), (float)(p_191821_2_ + this.y + 9 + 17 + l1 * this.minecraft.fontRenderer.FONT_HEIGHT), -5592406, false);
}
}
RenderHelper.enableGUIStandardItemLighting();
this.minecraft.getRenderItem().renderItemAndEffectIntoGUI((EntityLivingBase)null, this.displayInfo.getIcon(), p_191821_1_ + this.x + 8, p_191821_2_ + this.y + 5);
}
protected void render9Sprite(int p_192994_1_, int p_192994_2_, int p_192994_3_, int p_192994_4_, int p_192994_5_, int p_192994_6_, int p_192994_7_, int p_192994_8_, int p_192994_9_)
{
this.drawTexturedModalRect(p_192994_1_, p_192994_2_, p_192994_8_, p_192994_9_, p_192994_5_, p_192994_5_);
this.renderRepeating(p_192994_1_ + p_192994_5_, p_192994_2_, p_192994_3_ - p_192994_5_ - p_192994_5_, p_192994_5_, p_192994_8_ + p_192994_5_, p_192994_9_, p_192994_6_ - p_192994_5_ - p_192994_5_, p_192994_7_);
this.drawTexturedModalRect(p_192994_1_ + p_192994_3_ - p_192994_5_, p_192994_2_, p_192994_8_ + p_192994_6_ - p_192994_5_, p_192994_9_, p_192994_5_, p_192994_5_);
this.drawTexturedModalRect(p_192994_1_, p_192994_2_ + p_192994_4_ - p_192994_5_, p_192994_8_, p_192994_9_ + p_192994_7_ - p_192994_5_, p_192994_5_, p_192994_5_);
this.renderRepeating(p_192994_1_ + p_192994_5_, p_192994_2_ + p_192994_4_ - p_192994_5_, p_192994_3_ - p_192994_5_ - p_192994_5_, p_192994_5_, p_192994_8_ + p_192994_5_, p_192994_9_ + p_192994_7_ - p_192994_5_, p_192994_6_ - p_192994_5_ - p_192994_5_, p_192994_7_);
this.drawTexturedModalRect(p_192994_1_ + p_192994_3_ - p_192994_5_, p_192994_2_ + p_192994_4_ - p_192994_5_, p_192994_8_ + p_192994_6_ - p_192994_5_, p_192994_9_ + p_192994_7_ - p_192994_5_, p_192994_5_, p_192994_5_);
this.renderRepeating(p_192994_1_, p_192994_2_ + p_192994_5_, p_192994_5_, p_192994_4_ - p_192994_5_ - p_192994_5_, p_192994_8_, p_192994_9_ + p_192994_5_, p_192994_6_, p_192994_7_ - p_192994_5_ - p_192994_5_);
this.renderRepeating(p_192994_1_ + p_192994_5_, p_192994_2_ + p_192994_5_, p_192994_3_ - p_192994_5_ - p_192994_5_, p_192994_4_ - p_192994_5_ - p_192994_5_, p_192994_8_ + p_192994_5_, p_192994_9_ + p_192994_5_, p_192994_6_ - p_192994_5_ - p_192994_5_, p_192994_7_ - p_192994_5_ - p_192994_5_);
this.renderRepeating(p_192994_1_ + p_192994_3_ - p_192994_5_, p_192994_2_ + p_192994_5_, p_192994_5_, p_192994_4_ - p_192994_5_ - p_192994_5_, p_192994_8_ + p_192994_6_ - p_192994_5_, p_192994_9_ + p_192994_5_, p_192994_6_, p_192994_7_ - p_192994_5_ - p_192994_5_);
}
protected void renderRepeating(int p_192993_1_, int p_192993_2_, int p_192993_3_, int p_192993_4_, int p_192993_5_, int p_192993_6_, int p_192993_7_, int p_192993_8_)
{
for (int i = 0; i < p_192993_3_; i += p_192993_7_)
{
int j = p_192993_1_ + i;
int k = Math.min(p_192993_7_, p_192993_3_ - i);
for (int l = 0; l < p_192993_4_; l += p_192993_8_)
{
int i1 = p_192993_2_ + l;
int j1 = Math.min(p_192993_8_, p_192993_4_ - l);
this.drawTexturedModalRect(j, i1, p_192993_5_, p_192993_6_, k, j1);
}
}
}
public boolean isMouseOver(int p_191816_1_, int p_191816_2_, int p_191816_3_, int p_191816_4_)
{
if (!this.displayInfo.isHidden() || this.advancementProgress != null && this.advancementProgress.isDone())
{
int i = p_191816_1_ + this.x;
int j = i + 26;
int k = p_191816_2_ + this.y;
int l = k + 26;
return p_191816_3_ >= i && p_191816_3_ <= j && p_191816_4_ >= k && p_191816_4_ <= l;
}
else
{
return false;
}
}
public void attachToParent()
{
if (this.parent == null && this.advancement.getParent() != null)
{
this.parent = this.getFirstVisibleParent(this.advancement);
if (this.parent != null)
{
this.parent.addGuiAdvancement(this);
}
}
}
public int getY()
{
return this.y;
}
public int getX()
{
return this.x;
}
}

View File

@@ -0,0 +1,239 @@
package net.minecraft.client.gui.advancements;
import com.google.common.collect.Maps;
import java.util.Map;
import javax.annotation.Nullable;
import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.DisplayInfo;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiAdvancementTab extends Gui
{
private final Minecraft minecraft;
private final GuiScreenAdvancements screen;
private final AdvancementTabType type;
private final int index;
private final Advancement advancement;
private final DisplayInfo display;
private final ItemStack icon;
private final String title;
private final GuiAdvancement root;
private final Map<Advancement, GuiAdvancement> guis = Maps.<Advancement, GuiAdvancement>newLinkedHashMap();
private int scrollX;
private int scrollY;
private int minX = Integer.MAX_VALUE;
private int minY = Integer.MAX_VALUE;
private int maxX = Integer.MIN_VALUE;
private int maxY = Integer.MIN_VALUE;
private float fade;
private boolean centered;
private int page;
public GuiAdvancementTab(Minecraft p_i47589_1_, GuiScreenAdvancements p_i47589_2_, AdvancementTabType p_i47589_3_, int p_i47589_4_, Advancement p_i47589_5_, DisplayInfo p_i47589_6_)
{
this.minecraft = p_i47589_1_;
this.screen = p_i47589_2_;
this.type = p_i47589_3_;
this.index = p_i47589_4_;
this.advancement = p_i47589_5_;
this.display = p_i47589_6_;
this.icon = p_i47589_6_.getIcon();
this.title = p_i47589_6_.getTitle().getFormattedText();
this.root = new GuiAdvancement(this, p_i47589_1_, p_i47589_5_, p_i47589_6_);
this.addGuiAdvancement(this.root, p_i47589_5_);
}
public Advancement getAdvancement()
{
return this.advancement;
}
public String getTitle()
{
return this.title;
}
public void drawTab(int p_191798_1_, int p_191798_2_, boolean p_191798_3_)
{
this.type.draw(this, p_191798_1_, p_191798_2_, p_191798_3_, this.index);
}
public void drawIcon(int p_191796_1_, int p_191796_2_, RenderItem p_191796_3_)
{
this.type.drawIcon(p_191796_1_, p_191796_2_, this.index, p_191796_3_, this.icon);
}
public void drawContents()
{
if (!this.centered)
{
this.scrollX = 117 - (this.maxX + this.minX) / 2;
this.scrollY = 56 - (this.maxY + this.minY) / 2;
this.centered = true;
}
GlStateManager.depthFunc(518);
drawRect(0, 0, 234, 113, -16777216);
GlStateManager.depthFunc(515);
ResourceLocation resourcelocation = this.display.getBackground();
if (resourcelocation != null)
{
this.minecraft.getTextureManager().bindTexture(resourcelocation);
}
else
{
this.minecraft.getTextureManager().bindTexture(TextureManager.RESOURCE_LOCATION_EMPTY);
}
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
int i = this.scrollX % 16;
int j = this.scrollY % 16;
for (int k = -1; k <= 15; ++k)
{
for (int l = -1; l <= 8; ++l)
{
drawModalRectWithCustomSizedTexture(i + 16 * k, j + 16 * l, 0.0F, 0.0F, 16, 16, 16.0F, 16.0F);
}
}
this.root.drawConnectivity(this.scrollX, this.scrollY, true);
this.root.drawConnectivity(this.scrollX, this.scrollY, false);
this.root.draw(this.scrollX, this.scrollY);
}
public void drawToolTips(int p_192991_1_, int p_192991_2_, int p_192991_3_, int p_192991_4_)
{
GlStateManager.pushMatrix();
GlStateManager.translate(0.0F, 0.0F, 200.0F);
drawRect(0, 0, 234, 113, MathHelper.floor(this.fade * 255.0F) << 24);
boolean flag = false;
if (p_192991_1_ > 0 && p_192991_1_ < 234 && p_192991_2_ > 0 && p_192991_2_ < 113)
{
for (GuiAdvancement guiadvancement : this.guis.values())
{
if (guiadvancement.isMouseOver(this.scrollX, this.scrollY, p_192991_1_, p_192991_2_))
{
flag = true;
guiadvancement.drawHover(this.scrollX, this.scrollY, this.fade, p_192991_3_, p_192991_4_);
break;
}
}
}
GlStateManager.popMatrix();
if (flag)
{
this.fade = MathHelper.clamp(this.fade + 0.02F, 0.0F, 0.3F);
}
else
{
this.fade = MathHelper.clamp(this.fade - 0.04F, 0.0F, 1.0F);
}
}
public boolean isMouseOver(int p_191793_1_, int p_191793_2_, int p_191793_3_, int p_191793_4_)
{
return this.type.isMouseOver(p_191793_1_, p_191793_2_, this.index, p_191793_3_, p_191793_4_);
}
@Nullable
public static GuiAdvancementTab create(Minecraft p_193936_0_, GuiScreenAdvancements p_193936_1_, int p_193936_2_, Advancement p_193936_3_)
{
if (p_193936_3_.getDisplay() == null)
{
return null;
}
else
{
for (AdvancementTabType advancementtabtype : AdvancementTabType.values())
{
if ((p_193936_2_ % AdvancementTabType.MAX_TABS) < advancementtabtype.getMax())
{
return new GuiAdvancementTab(p_193936_0_, p_193936_1_, advancementtabtype, p_193936_2_ % AdvancementTabType.MAX_TABS, p_193936_2_ / AdvancementTabType.MAX_TABS, p_193936_3_, p_193936_3_.getDisplay());
}
p_193936_2_ -= advancementtabtype.getMax();
}
return null;
}
}
public void scroll(int p_191797_1_, int p_191797_2_)
{
if (this.maxX - this.minX > 234)
{
this.scrollX = MathHelper.clamp(this.scrollX + p_191797_1_, -(this.maxX - 234), 0);
}
if (this.maxY - this.minY > 113)
{
this.scrollY = MathHelper.clamp(this.scrollY + p_191797_2_, -(this.maxY - 113), 0);
}
}
public void addAdvancement(Advancement p_191800_1_)
{
if (p_191800_1_.getDisplay() != null)
{
GuiAdvancement guiadvancement = new GuiAdvancement(this, this.minecraft, p_191800_1_, p_191800_1_.getDisplay());
this.addGuiAdvancement(guiadvancement, p_191800_1_);
}
}
private void addGuiAdvancement(GuiAdvancement p_193937_1_, Advancement p_193937_2_)
{
this.guis.put(p_193937_2_, p_193937_1_);
int i = p_193937_1_.getX();
int j = i + 28;
int k = p_193937_1_.getY();
int l = k + 27;
this.minX = Math.min(this.minX, i);
this.maxX = Math.max(this.maxX, j);
this.minY = Math.min(this.minY, k);
this.maxY = Math.max(this.maxY, l);
for (GuiAdvancement guiadvancement : this.guis.values())
{
guiadvancement.attachToParent();
}
}
@Nullable
public GuiAdvancement getAdvancementGui(Advancement p_191794_1_)
{
return this.guis.get(p_191794_1_);
}
public GuiScreenAdvancements getScreen()
{
return this.screen;
}
/* ======================================== FORGE START =====================================*/
public int getPage()
{
return this.page;
}
public GuiAdvancementTab(Minecraft p_i47589_1_, GuiScreenAdvancements p_i47589_2_, AdvancementTabType p_i47589_3_, int p_i47589_4_, int page, Advancement p_i47589_5_, DisplayInfo p_i47589_6_)
{
this(p_i47589_1_, p_i47589_2_, p_i47589_3_, p_i47589_4_, p_i47589_5_, p_i47589_6_);
this.page = page;
}
/* ======================================== FORGE END =====================================*/
}

View File

@@ -0,0 +1,324 @@
package net.minecraft.client.gui.advancements;
import com.google.common.collect.Maps;
import java.io.IOException;
import java.util.Map;
import javax.annotation.Nullable;
import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.AdvancementProgress;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.multiplayer.ClientAdvancementManager;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.resources.I18n;
import net.minecraft.network.play.client.CPacketSeenAdvancements;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.input.Mouse;
@SideOnly(Side.CLIENT)
public class GuiScreenAdvancements extends GuiScreen implements ClientAdvancementManager.IListener
{
private static final ResourceLocation WINDOW = new ResourceLocation("textures/gui/advancements/window.png");
private static final ResourceLocation TABS = new ResourceLocation("textures/gui/advancements/tabs.png");
private final ClientAdvancementManager clientAdvancementManager;
private final Map<Advancement, GuiAdvancementTab> tabs = Maps.<Advancement, GuiAdvancementTab>newLinkedHashMap();
private GuiAdvancementTab selectedTab;
private int scrollMouseX;
private int scrollMouseY;
private boolean isScrolling;
private static int tabPage, maxPages;
public GuiScreenAdvancements(ClientAdvancementManager p_i47383_1_)
{
this.clientAdvancementManager = p_i47383_1_;
}
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.tabs.clear();
this.selectedTab = null;
this.clientAdvancementManager.setListener(this);
if (this.selectedTab == null && !this.tabs.isEmpty())
{
this.clientAdvancementManager.setSelectedTab(((GuiAdvancementTab)this.tabs.values().iterator().next()).getAdvancement(), true);
}
else
{
this.clientAdvancementManager.setSelectedTab(this.selectedTab == null ? null : this.selectedTab.getAdvancement(), true);
}
if (this.tabs.size() > AdvancementTabType.MAX_TABS)
{
int guiLeft = (this.width - 252) / 2;
int guiTop = (this.height - 140) / 2;
this.buttonList.add(new net.minecraft.client.gui.GuiButton(101, guiLeft, guiTop - 50, 20, 20, "<"));
this.buttonList.add(new net.minecraft.client.gui.GuiButton(102, guiLeft + 252 - 20, guiTop - 50, 20, 20, ">"));
maxPages = this.tabs.size() / AdvancementTabType.MAX_TABS;
}
}
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
this.clientAdvancementManager.setListener((ClientAdvancementManager.IListener)null);
NetHandlerPlayClient nethandlerplayclient = this.mc.getConnection();
if (nethandlerplayclient != null)
{
nethandlerplayclient.sendPacket(CPacketSeenAdvancements.closedScreen());
}
}
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
if (mouseButton == 0)
{
int i = (this.width - 252) / 2;
int j = (this.height - 140) / 2;
for (GuiAdvancementTab guiadvancementtab : this.tabs.values())
{
if (guiadvancementtab.getPage() == tabPage && guiadvancementtab.isMouseOver(i, j, mouseX, mouseY))
{
this.clientAdvancementManager.setSelectedTab(guiadvancementtab.getAdvancement(), true);
break;
}
}
}
super.mouseClicked(mouseX, mouseY, mouseButton);
}
/**
* Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
* KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
*/
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
if (keyCode == this.mc.gameSettings.keyBindAdvancements.getKeyCode())
{
this.mc.displayGuiScreen((GuiScreen)null);
this.mc.setIngameFocus();
}
else
{
super.keyTyped(typedChar, keyCode);
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
int i = (this.width - 252) / 2;
int j = (this.height - 140) / 2;
if (Mouse.isButtonDown(0))
{
if (!this.isScrolling)
{
this.isScrolling = true;
}
else if (this.selectedTab != null)
{
this.selectedTab.scroll(mouseX - this.scrollMouseX, mouseY - this.scrollMouseY);
}
this.scrollMouseX = mouseX;
this.scrollMouseY = mouseY;
}
else
{
this.isScrolling = false;
}
this.drawDefaultBackground();
this.renderInside(mouseX, mouseY, i, j);
this.renderWindow(i, j);
super.drawScreen(mouseX, mouseY, partialTicks);
if (maxPages != 0)
{
String page = String.format("%d / %d", tabPage + 1, maxPages + 1);
int width = this.fontRenderer.getStringWidth(page);
GlStateManager.disableLighting();
this.fontRenderer.drawStringWithShadow(page, i + (252 / 2) - (width / 2), j - 44, -1);
}
this.renderToolTips(mouseX, mouseY, i, j);
}
private void renderInside(int p_191936_1_, int p_191936_2_, int p_191936_3_, int p_191936_4_)
{
GuiAdvancementTab guiadvancementtab = this.selectedTab;
if (guiadvancementtab == null)
{
drawRect(p_191936_3_ + 9, p_191936_4_ + 18, p_191936_3_ + 9 + 234, p_191936_4_ + 18 + 113, -16777216);
String s = I18n.format("advancements.empty");
int i = this.fontRenderer.getStringWidth(s);
this.fontRenderer.drawString(s, p_191936_3_ + 9 + 117 - i / 2, p_191936_4_ + 18 + 56 - this.fontRenderer.FONT_HEIGHT / 2, -1);
this.fontRenderer.drawString(":(", p_191936_3_ + 9 + 117 - this.fontRenderer.getStringWidth(":(") / 2, p_191936_4_ + 18 + 113 - this.fontRenderer.FONT_HEIGHT, -1);
}
else
{
GlStateManager.pushMatrix();
GlStateManager.translate((float)(p_191936_3_ + 9), (float)(p_191936_4_ + 18), -400.0F);
GlStateManager.enableDepth();
guiadvancementtab.drawContents();
GlStateManager.popMatrix();
GlStateManager.depthFunc(515);
GlStateManager.disableDepth();
}
}
public void renderWindow(int p_191934_1_, int p_191934_2_)
{
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.enableBlend();
RenderHelper.disableStandardItemLighting();
this.mc.getTextureManager().bindTexture(WINDOW);
this.drawTexturedModalRect(p_191934_1_, p_191934_2_, 0, 0, 252, 140);
if (this.tabs.size() > 1)
{
this.mc.getTextureManager().bindTexture(TABS);
for (GuiAdvancementTab guiadvancementtab : this.tabs.values())
{
if(guiadvancementtab.getPage() == tabPage)
guiadvancementtab.drawTab(p_191934_1_, p_191934_2_, guiadvancementtab == this.selectedTab);
}
GlStateManager.enableRescaleNormal();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
RenderHelper.enableGUIStandardItemLighting();
for (GuiAdvancementTab guiadvancementtab1 : this.tabs.values())
{
if(guiadvancementtab1.getPage() == tabPage)
guiadvancementtab1.drawIcon(p_191934_1_, p_191934_2_, this.itemRender);
}
GlStateManager.disableBlend();
}
this.fontRenderer.drawString(I18n.format("gui.advancements"), p_191934_1_ + 8, p_191934_2_ + 6, 4210752);
}
private void renderToolTips(int p_191937_1_, int p_191937_2_, int p_191937_3_, int p_191937_4_)
{
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
if (this.selectedTab != null)
{
GlStateManager.pushMatrix();
GlStateManager.enableDepth();
GlStateManager.translate((float)(p_191937_3_ + 9), (float)(p_191937_4_ + 18), 400.0F);
this.selectedTab.drawToolTips(p_191937_1_ - p_191937_3_ - 9, p_191937_2_ - p_191937_4_ - 18, p_191937_3_, p_191937_4_);
GlStateManager.disableDepth();
GlStateManager.popMatrix();
}
if (this.tabs.size() > 1)
{
for (GuiAdvancementTab guiadvancementtab : this.tabs.values())
{
if (guiadvancementtab.getPage() == tabPage && guiadvancementtab.isMouseOver(p_191937_3_, p_191937_4_, p_191937_1_, p_191937_2_))
{
this.drawHoveringText(guiadvancementtab.getTitle(), p_191937_1_, p_191937_2_);
}
}
}
}
public void rootAdvancementAdded(Advancement advancementIn)
{
GuiAdvancementTab guiadvancementtab = GuiAdvancementTab.create(this.mc, this, this.tabs.size(), advancementIn);
if (guiadvancementtab != null)
{
this.tabs.put(advancementIn, guiadvancementtab);
}
}
public void rootAdvancementRemoved(Advancement advancementIn)
{
}
public void nonRootAdvancementAdded(Advancement advancementIn)
{
GuiAdvancementTab guiadvancementtab = this.getTab(advancementIn);
if (guiadvancementtab != null)
{
guiadvancementtab.addAdvancement(advancementIn);
}
}
public void nonRootAdvancementRemoved(Advancement advancementIn)
{
}
public void onUpdateAdvancementProgress(Advancement p_191933_1_, AdvancementProgress p_191933_2_)
{
GuiAdvancement guiadvancement = this.getAdvancementGui(p_191933_1_);
if (guiadvancement != null)
{
guiadvancement.getAdvancementProgress(p_191933_2_);
}
}
public void setSelectedTab(@Nullable Advancement p_193982_1_)
{
this.selectedTab = this.tabs.get(p_193982_1_);
}
public void advancementsCleared()
{
this.tabs.clear();
this.selectedTab = null;
}
@Nullable
public GuiAdvancement getAdvancementGui(Advancement p_191938_1_)
{
GuiAdvancementTab guiadvancementtab = this.getTab(p_191938_1_);
return guiadvancementtab == null ? null : guiadvancementtab.getAdvancementGui(p_191938_1_);
}
@Nullable
private GuiAdvancementTab getTab(Advancement p_191935_1_)
{
while (p_191935_1_.getParent() != null)
{
p_191935_1_ = p_191935_1_.getParent();
}
return this.tabs.get(p_191935_1_);
}
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
@Override
protected void actionPerformed(net.minecraft.client.gui.GuiButton button) throws IOException
{
if(button.id == 101)
tabPage = Math.max(tabPage - 1, 0);
else if(button.id == 102)
tabPage = Math.min(tabPage + 1, maxPages);
}
}

View File

@@ -0,0 +1,7 @@
// Auto generated package-info by MCP
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package net.minecraft.client.gui.advancements;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View File

@@ -0,0 +1,19 @@
package net.minecraft.client.gui.chat;
import net.minecraft.util.text.ChatType;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public interface IChatListener
{
/**
* Called whenever this listener receives a chat message, if this listener is registered to the given type in {@link
* net.minecraft.client.gui.GuiIngame#chatListeners chatListeners}
*
* @param chatTypeIn The type of chat message
* @param message The chat message.
*/
void say(ChatType chatTypeIn, ITextComponent message);
}

View File

@@ -0,0 +1,79 @@
package net.minecraft.client.gui.chat;
import com.mojang.text2speech.Narrator;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.toasts.GuiToast;
import net.minecraft.client.gui.toasts.SystemToast;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.util.text.ChatType;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class NarratorChatListener implements IChatListener
{
public static final NarratorChatListener INSTANCE = new NarratorChatListener();
private final Narrator narrator = Narrator.getNarrator();
/**
* Called whenever this listener receives a chat message, if this listener is registered to the given type in {@link
* net.minecraft.client.gui.GuiIngame#chatListeners chatListeners}
*
* @param chatTypeIn The type of chat message
* @param message The chat message.
*/
public void say(ChatType chatTypeIn, ITextComponent message)
{
int i = Minecraft.getMinecraft().gameSettings.narrator;
if (i != 0 && this.narrator.active())
{
if (i == 1 || i == 2 && chatTypeIn == ChatType.CHAT || i == 3 && chatTypeIn == ChatType.SYSTEM)
{
if (message instanceof TextComponentTranslation && "chat.type.text".equals(((TextComponentTranslation)message).getKey()))
{
this.narrator.say((new TextComponentTranslation("chat.type.text.narrate", ((TextComponentTranslation)message).getFormatArgs())).getUnformattedText());
}
else
{
this.narrator.say(message.getUnformattedText());
}
}
}
}
public void announceMode(int p_193641_1_)
{
this.narrator.clear();
this.narrator.say((new TextComponentTranslation("options.narrator", new Object[0])).getUnformattedText() + " : " + (new TextComponentTranslation(GameSettings.NARRATOR_MODES[p_193641_1_], new Object[0])).getUnformattedText());
GuiToast guitoast = Minecraft.getMinecraft().getToastGui();
if (this.narrator.active())
{
if (p_193641_1_ == 0)
{
SystemToast.addOrUpdate(guitoast, SystemToast.Type.NARRATOR_TOGGLE, new TextComponentTranslation("narrator.toast.disabled", new Object[0]), (ITextComponent)null);
}
else
{
SystemToast.addOrUpdate(guitoast, SystemToast.Type.NARRATOR_TOGGLE, new TextComponentTranslation("narrator.toast.enabled", new Object[0]), new TextComponentTranslation(GameSettings.NARRATOR_MODES[p_193641_1_], new Object[0]));
}
}
else
{
SystemToast.addOrUpdate(guitoast, SystemToast.Type.NARRATOR_TOGGLE, new TextComponentTranslation("narrator.toast.disabled", new Object[0]), new TextComponentTranslation("options.narrator.notavailable", new Object[0]));
}
}
public boolean isActive()
{
return this.narrator.active();
}
public void clear()
{
this.narrator.clear();
}
}

View File

@@ -0,0 +1,30 @@
package net.minecraft.client.gui.chat;
import net.minecraft.client.Minecraft;
import net.minecraft.util.text.ChatType;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class NormalChatListener implements IChatListener
{
private final Minecraft mc;
public NormalChatListener(Minecraft p_i47393_1_)
{
this.mc = p_i47393_1_;
}
/**
* Called whenever this listener receives a chat message, if this listener is registered to the given type in {@link
* net.minecraft.client.gui.GuiIngame#chatListeners chatListeners}
*
* @param chatTypeIn The type of chat message
* @param message The chat message.
*/
public void say(ChatType chatTypeIn, ITextComponent message)
{
this.mc.ingameGUI.getChatGUI().printChatMessage(message);
}
}

View File

@@ -0,0 +1,30 @@
package net.minecraft.client.gui.chat;
import net.minecraft.client.Minecraft;
import net.minecraft.util.text.ChatType;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class OverlayChatListener implements IChatListener
{
private final Minecraft mc;
public OverlayChatListener(Minecraft minecraftIn)
{
this.mc = minecraftIn;
}
/**
* Called whenever this listener receives a chat message, if this listener is registered to the given type in {@link
* net.minecraft.client.gui.GuiIngame#chatListeners chatListeners}
*
* @param chatTypeIn The type of chat message
* @param message The chat message.
*/
public void say(ChatType chatTypeIn, ITextComponent message)
{
this.mc.ingameGUI.setOverlayMessage(message, false);
}
}

View File

@@ -0,0 +1,7 @@
// Auto generated package-info by MCP
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package net.minecraft.client.gui.chat;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

Some files were not shown because too many files have changed in this diff Show More