mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-19 03:49:12 +00:00
rework rendering
This commit is contained in:
1 parent
29fe442671
commit
f1518102bc
5 files changed
+230
-241
No files matched your search
@@ -1,128 +0,0 @@
|
||||
package codechicken.nei.drawable;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
/*
|
||||
* Taken from Just Enough Items 1.12 under the MIT License
|
||||
*
|
||||
* The MIT License (MIT) Copyright (c) 2014-2015 mezz
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Breaks a texture into 9 pieces so that it can be scaled to any size.
|
||||
* Draws the corners and then repeats any middle textures to fill the remaining area.
|
||||
*/
|
||||
public class DrawableNineSliceTexture {
|
||||
private final TextureInfo info;
|
||||
private final int T_SIZE = 256;
|
||||
|
||||
public DrawableNineSliceTexture(TextureInfo info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public void draw(int xOffset, int yOffset, int width, int height) {
|
||||
ResourceLocation location = info.getLocation();
|
||||
int leftWidth = info.getSliceLeft();
|
||||
int rightWidth = info.getSliceRight();
|
||||
int topHeight = info.getSliceTop();
|
||||
int bottomHeight = info.getSliceBottom();
|
||||
int textureWidth = info.getWidth();
|
||||
int textureHeight = info.getHeight();
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(location);
|
||||
|
||||
float uMin = (float) xOffset / T_SIZE;
|
||||
float uMax = (float) (xOffset + textureWidth) / T_SIZE;
|
||||
float vMin = (float) yOffset / T_SIZE;
|
||||
float vMax = (float) (yOffset + textureHeight) / T_SIZE;
|
||||
float uSize = uMax - uMin;
|
||||
float vSize = vMax - vMin;
|
||||
|
||||
float uLeft = uMin + uSize * (leftWidth / (float) textureWidth);
|
||||
float uRight = uMax - uSize * (rightWidth / (float) textureWidth);
|
||||
float vTop = vMin + vSize * (topHeight / (float) textureHeight);
|
||||
float vBottom = vMax - vSize * (bottomHeight / (float) textureHeight);
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
|
||||
// left top
|
||||
draw(tessellator, uMin, vMin, uLeft, vTop, xOffset, yOffset, leftWidth, topHeight);
|
||||
// left bottom
|
||||
draw(tessellator, uMin, vBottom, uLeft, vMax, xOffset, yOffset + height - bottomHeight, leftWidth, bottomHeight);
|
||||
// right top
|
||||
draw(tessellator, uRight, vMin, uMax, vTop, xOffset + width - rightWidth, yOffset, rightWidth, topHeight);
|
||||
// right bottom
|
||||
draw(tessellator, uRight, vBottom, uMax, vMax, xOffset + width - rightWidth, yOffset + height - bottomHeight, rightWidth, bottomHeight);
|
||||
|
||||
int middleWidth = textureWidth - leftWidth - rightWidth;
|
||||
int middleHeight = textureWidth - topHeight - bottomHeight;
|
||||
int tiledMiddleWidth = width - leftWidth - rightWidth;
|
||||
int tiledMiddleHeight = height - topHeight - bottomHeight;
|
||||
if (tiledMiddleWidth > 0) {
|
||||
// top edge
|
||||
drawTiled(tessellator, uLeft, vMin, uRight, vTop, xOffset + leftWidth, yOffset, tiledMiddleWidth, topHeight, middleWidth, topHeight);
|
||||
// bottom edge
|
||||
drawTiled(tessellator, uLeft, vBottom, uRight, vMax, xOffset + leftWidth, yOffset + height - bottomHeight, tiledMiddleWidth, bottomHeight, middleWidth, bottomHeight);
|
||||
}
|
||||
if (tiledMiddleHeight > 0) {
|
||||
// left side
|
||||
drawTiled(tessellator, uMin, vTop, uLeft, vBottom, xOffset, yOffset + topHeight, leftWidth, tiledMiddleHeight, leftWidth, middleHeight);
|
||||
// right side
|
||||
drawTiled(tessellator, uRight, vTop, uMax, vBottom, xOffset + width - rightWidth, yOffset + topHeight, rightWidth, tiledMiddleHeight, rightWidth, middleHeight);
|
||||
}
|
||||
if (tiledMiddleHeight > 0 && tiledMiddleWidth > 0) {
|
||||
// middle area
|
||||
drawTiled(tessellator, uLeft, vTop, uRight, vBottom, xOffset + leftWidth, yOffset + topHeight, tiledMiddleWidth, tiledMiddleHeight, middleWidth, middleHeight);
|
||||
}
|
||||
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
private void drawTiled(Tessellator tessellator, float uMin, float vMin, float uMax, float vMax, int xOffset, int yOffset, int tiledWidth, int tiledHeight, int width, int height) {
|
||||
int xTileCount = tiledWidth / width;
|
||||
int xRemainder = tiledWidth - (xTileCount * width);
|
||||
int yTileCount = tiledHeight / height;
|
||||
int yRemainder = tiledHeight - (yTileCount * height);
|
||||
|
||||
int yStart = yOffset + tiledHeight;
|
||||
|
||||
float uSize = uMax - uMin;
|
||||
float vSize = vMax - vMin;
|
||||
|
||||
for (int xTile = 0; xTile <= xTileCount; xTile++) {
|
||||
for (int yTile = 0; yTile <= yTileCount; yTile++) {
|
||||
int tileWidth = (xTile == xTileCount) ? xRemainder : width;
|
||||
int tileHeight = (yTile == yTileCount) ? yRemainder : height;
|
||||
int x = xOffset + (xTile * width);
|
||||
int y = yStart - ((yTile + 1) * height);
|
||||
if (tileWidth > 0 && tileHeight > 0) {
|
||||
int maskRight = width - tileWidth;
|
||||
int maskTop = height - tileHeight;
|
||||
float uOffset = (maskRight / (float) width) * uSize;
|
||||
float vOffset = (maskTop / (float) height) * vSize;
|
||||
|
||||
draw(tessellator, uMin, vMin + vOffset, uMax - uOffset, vMax, x, y + maskTop, tileWidth, tileHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void draw(Tessellator tessellator, float minU, double minV, float maxU, float maxV, int xOffset, int yOffset, int width, int height) {
|
||||
tessellator.addVertexWithUV(xOffset, yOffset + height, 0, minU, minV);
|
||||
tessellator.addVertexWithUV(xOffset + width, yOffset + height, 0, maxU, maxV);
|
||||
tessellator.addVertexWithUV(xOffset + width, yOffset, 0, maxU, minV);
|
||||
tessellator.addVertexWithUV(xOffset, yOffset, 0, minU, minV);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package codechicken.nei.drawable;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
/*
|
||||
* Taken from Mantle 1.12-1.3.3.49 under the MIT License
|
||||
*
|
||||
* The MIT License (MIT) Copyright (c) 2013-2014 Slime Knights (mDiyo, fuj1n, Sunstrike, progwml6, pillbox, alexbegt)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiElementDuex {
|
||||
|
||||
// this is totally completely ugly but it's a simple solution that doesn't clutter everything too much >_>
|
||||
public static int defaultTexW = 256;
|
||||
public static int defaultTexH = 256;
|
||||
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int w;
|
||||
public final int h;
|
||||
|
||||
public int texW;
|
||||
public int texH;
|
||||
|
||||
public GuiElementDuex(int x, int y, int w, int h, int texW, int texH) {
|
||||
this(x, y, w, h);
|
||||
setTextureSize(texW, texH);
|
||||
|
||||
defaultTexW = texW;
|
||||
defaultTexH = texH;
|
||||
}
|
||||
|
||||
public GuiElementDuex(int x, int y, int w, int h) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
setTextureSize(defaultTexW, defaultTexH);
|
||||
}
|
||||
|
||||
public GuiElementDuex setTextureSize(int w, int h) {
|
||||
texW = w;
|
||||
texH = h;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public GuiElementDuex shift(int xd, int yd) {
|
||||
return new GuiElementDuex(this.x + xd, this.y + yd, this.w, this.h, this.texW, this.texH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the element at the given x/y coordinates
|
||||
*
|
||||
* @param xPos X-Coordinate on the screen
|
||||
* @param yPos Y-Coordinate on the screen
|
||||
*/
|
||||
public int draw(int xPos, int yPos) {
|
||||
// drawModalRectWithCustomSizedTexture
|
||||
GuiScreen.func_146110_a(xPos, yPos, x, y, w, h, texW, texH);
|
||||
return w;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
public int w;
|
||||
public int h;
|
||||
|
||||
public Builder(int w, int h) {
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
}
|
||||
|
||||
public GuiElementDuex get(int x, int y, int w, int h) {
|
||||
return new GuiElementDuex(x, y, w, h, this.w, this.h);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package codechicken.nei.drawable;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
/*
|
||||
* Taken from Mantle 1.12-1.3.3.49 under the MIT License
|
||||
*
|
||||
* The MIT License (MIT) Copyright (c) 2013-2014 Slime Knights (mDiyo, fuj1n, Sunstrike, progwml6, pillbox, alexbegt)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiElementScalable extends GuiElementDuex {
|
||||
|
||||
public GuiElementScalable(int x, int y, int w, int h, int texW, int texH) {
|
||||
super(x, y, w, h, texW, texH);
|
||||
}
|
||||
|
||||
public GuiElementScalable(int x, int y, int w, int h) {
|
||||
super(x, y, w, h);
|
||||
}
|
||||
|
||||
public int drawScaledX(int xPos, int yPos, int width) {
|
||||
for(int i = 0; i < width / w; i++) {
|
||||
draw(xPos + i * w, yPos);
|
||||
}
|
||||
// remainder that doesn't fit total width
|
||||
int remainder = width % w;
|
||||
if(remainder > 0) {
|
||||
GuiScreen.func_146110_a(xPos + width - remainder, yPos, x, y, remainder, h, texW, texH);
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
public int drawScaledY(int xPos, int yPos, int height) {
|
||||
for(int i = 0; i < height / h; i++) {
|
||||
draw(xPos, yPos + i * h);
|
||||
}
|
||||
// remainder that doesn't fit total width
|
||||
int remainder = height % h;
|
||||
if(remainder > 0) {
|
||||
// drawModalRectWithCustomSizedTexture
|
||||
GuiScreen.func_146110_a(xPos, yPos + height - remainder, x, y, w, remainder, texW, texH);
|
||||
}
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
public int drawScaled(int xPos, int yPos, int width, int height) {
|
||||
// we draw full height row-wise
|
||||
int full = height / this.h;
|
||||
for(int i = 0; i < full; i++) {
|
||||
drawScaledX(xPos, yPos + i * this.h, width);
|
||||
}
|
||||
|
||||
yPos += full * this.h;
|
||||
|
||||
// and the remainder is drawn manually
|
||||
int yRest = height % this.h;
|
||||
// the same as drawScaledX but with the remaining height
|
||||
for(int i = 0; i < width / w; i++) {
|
||||
drawScaledY(xPos + i * w, yPos, yRest);
|
||||
}
|
||||
// remainder that doesn't fit total width
|
||||
int remainder = width % w;
|
||||
if(remainder > 0) {
|
||||
// drawModalRectWithCustomSizedTexture
|
||||
GuiScreen.func_146110_a(xPos + width - remainder, yPos, x, y, remainder, yRest, texW, texH);
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiElementScalable shift(int xd, int yd) {
|
||||
GuiElementScalable element = new GuiElementScalable(this.x + xd, this.y + yd, this.w, this.h);
|
||||
element.setTextureSize(texW, texH);
|
||||
return element;
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
package codechicken.nei.drawable;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
/*
|
||||
* Taken from Just Enough Items 1.12 under the MIT License
|
||||
*
|
||||
* The MIT License (MIT) Copyright (c) 2014-2015 mezz
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class TextureInfo {
|
||||
private final ResourceLocation location;
|
||||
private final int width;
|
||||
private final int height;
|
||||
private int sliceLeft;
|
||||
private int sliceRight;
|
||||
private int sliceTop;
|
||||
private int sliceBottom;
|
||||
private int trimLeft;
|
||||
private int trimRight;
|
||||
private int trimTop;
|
||||
private int trimBottom;
|
||||
|
||||
public TextureInfo(ResourceLocation location, int width, int height) {
|
||||
this.location = location;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public TextureInfo slice(int left, int right, int top, int bottom) {
|
||||
this.sliceLeft = left;
|
||||
this.sliceRight = right;
|
||||
this.sliceTop = top;
|
||||
this.sliceBottom = bottom;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TextureInfo trim(int left, int right, int top, int bottom) {
|
||||
this.trimLeft = sliceLeft;
|
||||
this.trimRight = sliceRight;
|
||||
this.trimTop = sliceTop;
|
||||
this.trimBottom = sliceBottom;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResourceLocation getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public int getSliceLeft() {
|
||||
return sliceLeft;
|
||||
}
|
||||
|
||||
public int getSliceRight() {
|
||||
return sliceRight;
|
||||
}
|
||||
|
||||
public int getSliceTop() {
|
||||
return sliceTop;
|
||||
}
|
||||
|
||||
public int getSliceBottom() {
|
||||
return sliceBottom;
|
||||
}
|
||||
|
||||
public int getTrimLeft() {
|
||||
return trimLeft;
|
||||
}
|
||||
|
||||
public int getTrimRight() {
|
||||
return trimRight;
|
||||
}
|
||||
|
||||
public int getTrimTop() {
|
||||
return trimTop;
|
||||
}
|
||||
|
||||
public int getTrimBottom() {
|
||||
return trimBottom;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,14 @@
|
||||
package codechicken.nei.recipe;
|
||||
|
||||
import codechicken.nei.api.INEIGuiAdapter;
|
||||
import codechicken.nei.drawable.DrawableNineSliceTexture;
|
||||
import codechicken.nei.drawable.TextureInfo;
|
||||
import codechicken.nei.drawable.GuiElementDuex;
|
||||
import codechicken.nei.drawable.GuiElementScalable;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.util.Rectangle;
|
||||
|
||||
public class GuiRecipeCatalyst extends INEIGuiAdapter {
|
||||
private final DrawableNineSliceTexture catalystTabImage = new DrawableNineSliceTexture(getTextureInfo("catalyst_tab.png", 28, 28).slice(6, 6, 6, 6));
|
||||
private final DrawableNineSliceTexture slotImage = new DrawableNineSliceTexture(getTextureInfo("slot.png", 18, 18).slice(1, 1, 1, 1));
|
||||
|
||||
private GuiRecipe guiRecipe;
|
||||
public static final int ingredientSize = 16;
|
||||
public static final int ingredientBorder = 1;
|
||||
@@ -32,19 +30,19 @@ public class GuiRecipeCatalyst extends INEIGuiAdapter {
|
||||
int availableHeight = RecipeCatalysts.getHeight();
|
||||
int columnCount = RecipeCatalysts.getColumnCount(availableHeight, catalystsSize);
|
||||
int rowCount = RecipeCatalysts.getRowCount(availableHeight, catalystsSize);
|
||||
int width, height, xOffset, yOffset;
|
||||
int width, height, xPos, yPos;
|
||||
|
||||
width = (ingredientBorder * 2) + (tabBorder * 2) + (columnCount * ingredientSize);
|
||||
height = (ingredientBorder * 2) + (tabBorder * 2) + (rowCount * ingredientSize);
|
||||
xOffset = guiRecipe.guiLeft - width + tabBorder;
|
||||
yOffset = guiRecipe.guiTop;
|
||||
catalystTabImage.draw(xOffset, yOffset, width, height);
|
||||
xPos = guiRecipe.guiLeft - width + tabBorder;
|
||||
yPos = guiRecipe.guiTop;
|
||||
drawBordered("nei:textures/catalyst_tab.png", xPos, yPos, width, height, 28, 28, 6, 7, 6, 6);
|
||||
|
||||
width = (ingredientBorder * 2) + (columnCount * ingredientSize);
|
||||
height = (ingredientBorder * 2) + (rowCount * ingredientSize);
|
||||
xOffset = guiRecipe.guiLeft - width + ingredientBorder;
|
||||
yOffset = guiRecipe.guiTop + fullBorder - ingredientBorder;
|
||||
slotImage.draw(xOffset, yOffset, width, height);
|
||||
xPos = guiRecipe.guiLeft - width + ingredientBorder;
|
||||
yPos = guiRecipe.guiTop + fullBorder - ingredientBorder;
|
||||
drawBordered("nei:textures/slot.png", xPos, yPos, width, height, 18, 18, 1, 1, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,8 +66,42 @@ public class GuiRecipeCatalyst extends INEIGuiAdapter {
|
||||
return targetRect.intersects(catalystRect);
|
||||
}
|
||||
|
||||
private TextureInfo getTextureInfo(String name, int width, int height) {
|
||||
ResourceLocation location = new ResourceLocation("nei:textures/" + name);
|
||||
return new TextureInfo(location, width, height);
|
||||
private void drawBordered(String location, int xPos, int yPos, int width, int height, int texWidth, int texHeight, int sliceLeft, int sliceRight, int sliceTop, int sliceBottom) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(location));
|
||||
|
||||
GuiElementDuex cornerTopLeft = new GuiElementDuex(0, 0, sliceLeft, sliceTop, texWidth, texHeight);
|
||||
GuiElementDuex cornerTopRight = new GuiElementDuex(texWidth - sliceRight, 0, sliceRight, sliceTop, texWidth, texHeight);
|
||||
GuiElementDuex cornerBottomLeft = new GuiElementDuex(0, texHeight - sliceBottom, sliceLeft, sliceBottom, texWidth, texHeight);
|
||||
GuiElementDuex cornerBottomRight = new GuiElementDuex(texWidth - sliceRight, texHeight - sliceBottom, sliceRight, sliceBottom, texWidth, texHeight);
|
||||
|
||||
GuiElementScalable borderTop = new GuiElementScalable(sliceLeft, 0, texWidth - sliceLeft - sliceRight, sliceTop, texWidth, texHeight);
|
||||
GuiElementScalable borderBottom = new GuiElementScalable(sliceLeft, texHeight - sliceBottom, texWidth - sliceLeft - sliceRight, sliceBottom, texWidth, texHeight);
|
||||
GuiElementScalable borderLeft = new GuiElementScalable(0, sliceTop, sliceLeft, texHeight - sliceTop - sliceBottom, texWidth, texHeight);
|
||||
GuiElementScalable borderRight = new GuiElementScalable(texWidth - sliceRight, sliceTop, sliceRight, texHeight - sliceTop - sliceBottom, texWidth, texHeight);
|
||||
GuiElementScalable center = new GuiElementScalable(sliceLeft, sliceTop, texWidth - sliceLeft - sliceRight, texHeight - sliceTop - sliceBottom, texWidth, texHeight);
|
||||
|
||||
int midW = width - borderLeft.w - borderRight.w;
|
||||
int midH = height - borderTop.h - borderBottom.h;
|
||||
|
||||
// top row
|
||||
int x = xPos;
|
||||
int y = yPos;
|
||||
x += cornerTopLeft.draw(x, y);
|
||||
x += borderTop.drawScaledX(x, y, midW);
|
||||
cornerTopRight.draw(x, y);
|
||||
|
||||
// center row
|
||||
x = xPos;
|
||||
y += borderTop.h;
|
||||
x += borderLeft.drawScaledY(x, y, midH);
|
||||
x += center.drawScaled(x, y, midW, midH);
|
||||
borderRight.drawScaledY(x, y, midH);
|
||||
|
||||
// bottom row
|
||||
x = xPos;
|
||||
y += midH;
|
||||
x += cornerBottomLeft.draw(x, y);
|
||||
x += borderBottom.drawScaledX(x, y, midW);
|
||||
cornerBottomRight.draw(x, y);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user