本文整理汇总了Java中net.minecraft.client.gui.Gui.drawRect方法的典型用法代码示例。如果您正苦于以下问题:Java Gui.drawRect方法的具体用法?Java Gui.drawRect怎么用?Java Gui.drawRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.client.gui.Gui
的用法示例。
在下文中一共展示了Gui.drawRect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: func_178663_a
import net.minecraft.client.gui.Gui; //导入方法依赖的package包/类
public void func_178663_a(float p_178663_1_, int alpha)
{
int i = -1;
String s = FontRenderer.getFormatFromString(this.field_178676_b.getColorPrefix());
if (s.length() >= 2)
{
i = Minecraft.getMinecraft().fontRendererObj.getColorCode(s.charAt(1));
}
if (i >= 0)
{
float f = (float)(i >> 16 & 255) / 255.0F;
float f1 = (float)(i >> 8 & 255) / 255.0F;
float f2 = (float)(i & 255) / 255.0F;
Gui.drawRect(1, 1, 15, 15, MathHelper.func_180183_b(f * p_178663_1_, f1 * p_178663_1_, f2 * p_178663_1_) | alpha << 24);
}
Minecraft.getMinecraft().getTextureManager().bindTexture(this.field_178677_c);
GlStateManager.color(p_178663_1_, p_178663_1_, p_178663_1_, (float)alpha / 255.0F);
Gui.drawScaledCustomSizeModalRect(2, 2, 8.0F, 8.0F, 8, 8, 12, 12, 64.0F, 64.0F);
Gui.drawScaledCustomSizeModalRect(2, 2, 40.0F, 8.0F, 8, 8, 12, 12, 64.0F, 64.0F);
}
示例2: drawButton
import net.minecraft.client.gui.Gui; //导入方法依赖的package包/类
@Override
public void drawButton(Minecraft mc, int x, int y, float partialTicks) {
if (thisVisible) super.drawButton(mc, x, y, partialTicks);
if (visible) {
if (renderedStacks != null) {
int middleX = this.x + width / 2;
int startX = middleX - renderedStacks.length * 9 + 1;
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.enableGUIStandardItemLighting();
for (int i = 0; i < renderedStacks.length; i++) {
itemRenderer.renderItemAndEffectIntoGUI(renderedStacks[i], startX + i * 18, this.y + 2);
}
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
}
if (resLoc != null) {
mc.getTextureManager().bindTexture(resLoc);
drawModalRectWithCustomSizedTexture(this.x + width / 2 - 8, this.y + 2, 0, 0, 16, 16, 16, 16);
}
if (enabled && !thisVisible && x >= this.x && y >= this.y && x < this.x + width && y < this.y + height) {
Gui.drawRect(this.x, this.y, this.x + width, this.y + height, invisibleHoverColor);
}
}
}
示例3: drawScreen
import net.minecraft.client.gui.Gui; //导入方法依赖的package包/类
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
mc.getTextureManager().bindTexture(gui_top);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, WIDTH, 10);
int y = guiTop+10;
drawTexturedModalRect(guiLeft, y, 0, 25, WIDTH, 15);
String label = I18n.format("message.meecreeps.gui.name_label") + " ";
mc.fontRenderer.drawString(label + text, guiLeft+15, guiTop+7, 0);
int w = mc.fontRenderer.getStringWidth(text.substring(0, cursor));
int xx = guiLeft+10+mc.fontRenderer.getStringWidth(label);
int yy = guiTop+3;
Gui.drawRect(xx + 5 + w, yy + 2, xx + 5 + w + 1, yy + 14, 0xff000000);
}
示例4: renderLithiumControl
import net.minecraft.client.gui.Gui; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
@Override
public void renderLithiumControl(LProgressBar control, GuiScreen gui) {
Point loc = NewLithiumGUI.centerControl(control);
int left = loc.getX();
int top = loc.getY();
int right = left + control.getSize().getWidth();
int bottom = top + control.getSize().getHeight();
//Render outside of the progressbar
Gui.drawRect(left, top, right, bottom, (int) control.getBorderColor().getHexColor());
//Draw the inside of the progressbar
Gui.drawRect(left + 1, top + 1, right - 1, bottom - 1, (int) control.getInsideColor().getHexColor());
int startX = left + 2;
int endX = right - 2;
//Calculate the size of the progress and fill it
Gui.drawRect(startX, top + 2, MiscUtils.ConvertRange(control.getMinValue(), control.getMaxValue(), startX, endX, control.getProgress()), bottom - 2, (int) control.getProgressColor().getHexColor());
}
示例5: renderIcon
import net.minecraft.client.gui.Gui; //导入方法依赖的package包/类
public void renderIcon(float p_178663_1_, int alpha)
{
int i = -1;
String s = FontRenderer.getFormatFromString(this.team.getColorPrefix());
if (s.length() >= 2)
{
i = Minecraft.getMinecraft().fontRendererObj.getColorCode(s.charAt(1));
}
if (i >= 0)
{
float f = (float)(i >> 16 & 255) / 255.0F;
float f1 = (float)(i >> 8 & 255) / 255.0F;
float f2 = (float)(i & 255) / 255.0F;
Gui.drawRect(1, 1, 15, 15, MathHelper.rgb(f * p_178663_1_, f1 * p_178663_1_, f2 * p_178663_1_) | alpha << 24);
}
Minecraft.getMinecraft().getTextureManager().bindTexture(this.location);
GlStateManager.color(p_178663_1_, p_178663_1_, p_178663_1_, (float)alpha / 255.0F);
Gui.drawScaledCustomSizeModalRect(2, 2, 8.0F, 8.0F, 8, 8, 12, 12, 64.0F, 64.0F);
Gui.drawScaledCustomSizeModalRect(2, 2, 40.0F, 8.0F, 8, 8, 12, 12, 64.0F, 64.0F);
}
示例6: drawGuiContainerForegroundLayer
import net.minecraft.client.gui.Gui; //导入方法依赖的package包/类
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
//String s = this.entity.getDisplayName().getUnformattedText();
//this.fontRendererObj.drawString(s, 88 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752); //#404040
//this.fontRendererObj.drawString(this.playerInv.getDisplayName().getUnformattedText(), 8, 72, 4210752); //#404040
int rfBarX = 231;
int rfBarY = 20;
int rfBarHeight = 88;
int rfBarWidth = 14;
int usedHeight = (int)(this.entity.getEnergyStored(EnumFacing.DOWN) / (double)this.entity.getMaxEnergyStored(EnumFacing.DOWN) * rfBarHeight);
Gui.drawRect(rfBarX, rfBarY, rfBarX + rfBarWidth, rfBarY + rfBarHeight - usedHeight, 0xFF000000);
Operation<BundlerEntity> op = this.entity.getCurrentOperation();
String statusStr;
if (op != null) {
int width = (int)(32 * op.getPercentage() / (double)100);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(new ResourceLocation("rezolve:textures/gui/container/arrow.png"));
GlStateManager.enableBlend();
this.drawModalRectWithCustomSizedTexture(133, 54, 0, 0, width, 32, 32, 32);
statusStr = "Operation: "+op.getPercentage()+"%";
} else {
statusStr = "Idle.";
}
this.fontRendererObj.drawString(statusStr, 7, 102, 0xFF000000);
}
示例7: drawGuiContainerForegroundLayer
import net.minecraft.client.gui.Gui; //导入方法依赖的package包/类
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
int rfBarX = 231;
int rfBarY = 20;
int rfBarHeight = 88;
int rfBarWidth = 14;
int usedHeight = rfBarHeight - (int)(this.entity.getEnergyStored(EnumFacing.DOWN) / (double)this.entity.getMaxEnergyStored(EnumFacing.DOWN) * rfBarHeight);
Gui.drawRect(rfBarX, rfBarY, rfBarX + rfBarWidth, rfBarY + usedHeight, 0xFF000000);
DatabaseServerEntity db = this.entity.getDatabase();
this.nameField.setVisible(this.selectedMachine != null && db != null);
if (this.selectedMachine != null) {
BlockPos pos = this.selectedMachine;
ItemStack stack = getItemFromBlock(this.entity, pos);
if (stack != null) {
String name = stack.getDisplayName();
String stackName = stack.getDisplayName();
String position = pos.getX()+", "+pos.getY()+", "+pos.getZ();
if (!this.nameField.getVisible()) {
this.fontRendererObj.drawString(stackName, 10, 126, 0xFF000000);
this.fontRendererObj.drawString(position, 10, 141, 0xFF666666);
} else {
this.fontRendererObj.drawString(stackName, 10, 141, 0xFF666666);
this.fontRendererObj.drawString(position, 10, 153, 0xFF666666);
}
}
} else {
this.fontRendererObj.drawString("Right click a machine for info.", 10, 126, 0xFF666666);
}
}
示例8: drawOutline
import net.minecraft.client.gui.Gui; //导入方法依赖的package包/类
private void drawOutline() {
int color = isHovering() ? lightGrey : lighterGrey;
Gui.drawRect(x, y, x + WIDTH, y + 1, color);
Gui.drawRect(x, y, x + 1, y + HEIGHT + 1, color);
Gui.drawRect(x + WIDTH, y, x + WIDTH + 1, y + HEIGHT + 1, color);
Gui.drawRect(x, y + HEIGHT, x + WIDTH, y + HEIGHT + 1, color);
}
示例9: drawBeveledBox
import net.minecraft.client.gui.Gui; //导入方法依赖的package包/类
/**
* Draw a beveled box. x2 and y2 are not included.
*/
public static void drawBeveledBox(int x1, int y1, int x2, int y2, int topleftcolor, int botrightcolor, int fillcolor) {
if (fillcolor != -1) {
Gui.drawRect(x1 + 1, y1 + 1, x2 - 1, y2 - 1, fillcolor);
}
drawHorizontalLine(x1, y1, x2 - 1, topleftcolor);
drawVerticalLine(x1, y1, y2 - 1, topleftcolor);
drawVerticalLine(x2 - 1, y1, y2 - 1, botrightcolor);
drawHorizontalLine(x1, y2 - 1, x2, botrightcolor);
}
示例10: drawThickBeveledBox
import net.minecraft.client.gui.Gui; //导入方法依赖的package包/类
/**
* Draw a thick beveled box. x2 and y2 are not included.
*/
public static void drawThickBeveledBox(int x1, int y1, int x2, int y2, int thickness, int topleftcolor, int botrightcolor, int fillcolor) {
if (fillcolor != -1) {
Gui.drawRect(x1 + 1, y1 + 1, x2 - 1, y2 - 1, fillcolor);
}
Gui.drawRect(x1, y1, x2 - 1, y1 + thickness, topleftcolor);
Gui.drawRect(x1, y1, x1 + thickness, y2 - 1, topleftcolor);
Gui.drawRect(x2 - thickness, y1, x2, y2 - 1, botrightcolor);
Gui.drawRect(x1, y2 - thickness, x2, y2, botrightcolor);
}
示例11: renderLithiumControl
import net.minecraft.client.gui.Gui; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
@Override
public void renderLithiumControl(LSlider control, GuiScreen gui) {
Point loc = NewLithiumGUI.centerControl(control);
Rectangle rect = new Rectangle(loc.getX(), loc.getY(), control.getSize().getWidth(), control.getSize().getHeight());
Rectangle rect2 = rect.inflate(-1, -1);
//Draw border
Gui.drawRect(rect.getLeft(), rect.getTop(), rect.getRight(), rect.getBottom(), (int) control.getBorderColor().getHexColor());
//Draw inside of the control
Gui.drawRect(rect2.getLeft(), rect2.getTop(), rect2.getRight(), rect2.getBottom(), (int) control.getBackgroundColor().getHexColor());
int startX = 0;
int endX = 0;
//Do some MATH to correctly render the slider
switch (control.getSliderType()) {
case HORIZONTAL:
startX = rect.getLeft() + 1;
endX = rect.getRight() - HANDLE_LENGHT - 1;
break;
case VERTICAL:
startX = rect.getTop() + 1;
endX = rect.getBottom() - HANDLE_LENGHT - 1;
break;
}
switch (control.getSliderType()) {
case HORIZONTAL:
//Render stuff
ButtonRenderer.drawButton(
gui,
"",
0,
0,
MiscUtils.ConvertRange(control.getMinValue(), control.getMaxValue(), startX, endX, control.getValue()),
rect.getY() + 1,
HANDLE_LENGHT,
rect.getHeight() - 2
);
break;
case VERTICAL:
//Render stuff
ButtonRenderer.drawButton(
gui,
"",
0,
0,
rect.getX() + 1,
MiscUtils.ConvertRange(control.getMinValue(), control.getMaxValue(), startX, endX, control.getValue()),
rect.getWidth() - 2,
HANDLE_LENGHT
);
break;
}
}
示例12: drawGuiContainerForegroundLayer
import net.minecraft.client.gui.Gui; //导入方法依赖的package包/类
@Override
protected void drawGuiContainerForegroundLayer(int x, int y) {
super.drawGuiContainerForegroundLayer(x, y);
fontRenderer.drawString("Item Filter", 115, 15, 4210752);
fontRenderer.drawString("Upgr.", 24, 16, 4210752);
creativeTabButton.visible = false;
switch (te.filterMode) {
case ITEM:
filterButton.displayString = "Items";
nameFilterField.setFocused(false);
nameFilterField.setVisible(false);
break;
case CREATIVE_TAB:
filterButton.displayString = "Creative Tab";
fontRenderer.drawString("Tab Name:", 106, 45, 4210752);
String tabName = I18n.format(CreativeTabs.CREATIVE_TAB_ARRAY[te.creativeTabID].getTranslatedTabLabel());
if (fontRenderer.getStringWidth(tabName) > 75) {
while (fontRenderer.getStringWidth(tabName) > 75) {
tabName = tabName.substring(0, tabName.length() - 2);
}
tabName = tabName + ".";
}
creativeTabButton.displayString = tabName;
creativeTabButton.visible = true;
nameFilterField.setFocused(false);
nameFilterField.setVisible(false);
break;
case NAME_BEGINS:
filterButton.displayString = "Item Name (begins with)";
fontRenderer.drawString("Item Name", 106, 35, 4210752);
fontRenderer.drawString("begins with:", 103, 45, 4210752);
nameFilterField.setVisible(true);
break;
case NAME_CONTAINS:
filterButton.displayString = "Item Name (contains)";
fontRenderer.drawString("Item Name", 106, 35, 4210752);
fontRenderer.drawString("contains:", 108, 45, 4210752);
nameFilterField.setVisible(true);
}
int inputShift = (int) ((1F - (float) Math.cos((float) te.inputProgress / (float) TileEntityPressureChamberInterface.MAX_PROGRESS * Math.PI)) * 11);
int outputShift = (int) ((1F - (float) Math.cos((float) te.outputProgress / (float) TileEntityPressureChamberInterface.MAX_PROGRESS * Math.PI)) * 11);
Gui.drawRect(63 + inputShift, 30, 87 + inputShift, 32, 0xFF5a62ff);
Gui.drawRect(63 + outputShift, 54, 87 + outputShift, 56, 0xFFffa800);
}
示例13: drawTextBox
import net.minecraft.client.gui.Gui; //导入方法依赖的package包/类
/**
* Draws the textbox
*/
public void drawTextBox()
{
if (this.getVisible())
{
if (this.getEnableBackgroundDrawing())
{
drawRect(this.xPosition - 1, this.yPosition - 1, this.xPosition + this.width + 1, this.yPosition + this.height + 1, -6250336);
drawRect(this.xPosition, this.yPosition, this.xPosition + this.width, this.yPosition + 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.fontRendererInstance.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.xPosition + 4 : this.xPosition;
int i1 = this.enableBackgroundDrawing ? this.yPosition + (this.height - 8) / 2 : this.yPosition;
int j1 = l;
if (k > s.length())
{
k = s.length();
}
if (!s.isEmpty())
{
String s1 = flag ? s.substring(0, j) : s;
j1 = this.fontRendererInstance.drawStringWithShadow(s1.replaceAll("(?s).", "*"), (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.fontRendererInstance.drawStringWithShadow(s.substring(j), (float)j1, (float)i1, i);
}
if (flag1)
{
if (flag2)
{
Gui.drawRect(k1, i1 - 1, k1 + 1, i1 + 1 + this.fontRendererInstance.FONT_HEIGHT, -3092272);
}
else
{
this.fontRendererInstance.drawStringWithShadow("_", (float)k1, (float)i1, i);
}
}
if (k != j)
{
int l1 = l + this.fontRendererInstance.getStringWidth(s.substring(0, k));
this.drawCursorVertical(k1, i1 - 1, l1 - 1, i1 + 1 + this.fontRendererInstance.FONT_HEIGHT);
}
}
}
示例14: drawTextBox
import net.minecraft.client.gui.Gui; //导入方法依赖的package包/类
/**
* Draws the textbox
*/
public void drawTextBox() {
if (this.getVisible()) {
if (this.getEnableBackgroundDrawing()) {
if (this.isEnabled) {
drawRect(this.xPosition, this.yPosition, this.xPosition + width, this.yPosition + height, new Color(0, 148, 255, 75).getRGB());
} else {
drawRect(this.xPosition, this.yPosition, this.xPosition + width, this.yPosition + height, new Color(0, 125, 215, 75).getRGB());
}
}
int i = this.isEnabled ? this.enabledColor : this.disabledColor;
int j = this.cursorPosition - this.lineScrollOffset;
int k = this.selectionEnd - this.lineScrollOffset;
String displayString = this.fontRendererInstance.trimStringToWidth(this.text.substring(this.lineScrollOffset), this.getWidth());
boolean flag = j >= 0 && j <= displayString.length();
boolean flag1 = this.isFocused && this.cursorCounter / 6 % 2 == 0 && flag;
int l = this.enableBackgroundDrawing ? this.xPosition + 4 : this.xPosition;
int i1 = this.enableBackgroundDrawing ? this.yPosition + (this.height - 8) / 2 : this.yPosition;
int j1 = l;
if (k > displayString.length()) {
k = displayString.length();
}
if (!alertMessage.isEmpty()) {
this.fontRendererInstance.drawString(alertMessage, ((this.xPosition + this.width / 2) - fontRendererInstance.getStringWidth(alertMessage) / 2), this.yPosition + this.height / 2 - 4, enabledColor, false);
return;
}
if (displayString.isEmpty() && !isFocused && isEnabled) {
this.fontRendererInstance.drawString("Write here!", ((this.xPosition + this.width / 2) - fontRendererInstance.getStringWidth("Write here!") / 2), this.yPosition + this.height / 2 - 4, i, false);
return;
}
if (displayString.length() > 0) {
String s1 = flag ? displayString.substring(0, j) : displayString;
j1 = this.fontRendererInstance.drawString(s1, (float) l, (float) i1, i, false);
}
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 (displayString.length() > 0 && flag && j < displayString.length()) {
this.fontRendererInstance.drawString(displayString.substring(j), (float) j1, (float) i1, i, false);
}
if (flag1) {
if (flag2) {
Gui.drawRect(k1, i1 -1, k1 + 1, i1 + 1 + this.fontRendererInstance.FONT_HEIGHT, -3092272);
}
else {
this.fontRendererInstance.drawString("_", (float) k1, (float) i1, i, false);
}
}
if (k != j) {
int l1 = l + this.fontRendererInstance.getStringWidth(displayString.substring(0, k));
this.drawCursorVertical(k1, i1 -1, l1 -1, i1 + 1 + this.fontRendererInstance.FONT_HEIGHT);
}
}
}
示例15: drawDankNullSlot
import net.minecraft.client.gui.Gui; //导入方法依赖的package包/类
private void drawDankNullSlot(Slot slotIn) {
GuiContainer gui = this;
int i = EasyMappings.slotPosX(slotIn);
int j = EasyMappings.slotPosY(slotIn);
ItemStack itemstack = slotIn.getStack();
boolean flag = false;
boolean flag1 = (slotIn == MCPrivateUtils.getGuiClickedSlot(gui)) && (MCPrivateUtils.getGuiDraggedStack(gui) != null) && (!MCPrivateUtils.getGuiIsRightMouseClick(gui));
ItemStack itemstack1 = EasyMappings.player().inventory.getItemStack();
String s = null;
if ((slotIn == MCPrivateUtils.getGuiClickedSlot(gui)) && (MCPrivateUtils.getGuiDraggedStack(gui) != null) && (MCPrivateUtils.getGuiIsRightMouseClick(gui)) && (!itemstack.isEmpty())) {
itemstack = itemstack.copy();
itemstack.setCount(itemstack.getCount() / 2);
}
else if ((MCPrivateUtils.getGuiDragSplitting(gui)) && (MCPrivateUtils.getGuiDragSplittingSlots(gui).contains(slotIn)) && (!itemstack1.isEmpty())) {
if (MCPrivateUtils.getGuiDragSplittingSlots(gui).size() == 1) {
return;
}
MCPrivateUtils.getGuiDragSplittingSlots(gui).remove(slotIn);
GuiUtils.updateDragSplitting(gui);
}
MCPrivateUtils.setGuiZLevel(gui, 100.0F);
MCPrivateUtils.setGuiScreenRendererZLevel(gui, 100.0F);
if (itemstack.isEmpty()) {
TextureAtlasSprite textureatlassprite = slotIn.getBackgroundSprite();
if (textureatlassprite != null) {
GlStateManager.disableLighting();
GuiUtils.bindTexture(slotIn.getBackgroundLocation());
GuiUtils.drawTexturedModalRect(gui, i, j, textureatlassprite, 16, 16);
GlStateManager.enableLighting();
flag1 = true;
}
}
if (!flag1) {
if (flag) {
Gui.drawRect(i, j, i + 16, j + 16, -2130706433);
}
GlStateManager.enableDepth();
Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(itemstack, i, j);
pRenderItem.renderItemOverlayIntoGUI(RenderUtils.getFontRenderer(), itemstack, i, j, s);
}
MCPrivateUtils.setGuiScreenRendererZLevel(gui, 0.0F);
MCPrivateUtils.setGuiZLevel(gui, 0.0F);
}