aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java')
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java51
1 files changed, 29 insertions, 22 deletions
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java
index 72b042f63..5d4341fdb 100644
--- a/src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java
+++ b/src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java
@@ -1,10 +1,8 @@
package me.shedaniel.rei.gui.widget;
import com.mojang.blaze3d.platform.GlStateManager;
-import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.GuiLighting;
import net.minecraft.util.Identifier;
-import net.minecraft.util.math.MathHelper;
import java.awt.*;
import java.util.Collections;
@@ -19,6 +17,8 @@ public class RecipeBaseWidget extends HighlightableWidget {
public RecipeBaseWidget(Rectangle bounds) {
this.bounds = bounds;
+ if (bounds.width < 8 || bounds.height < 8)
+ throw new IllegalArgumentException("Base too small, at least 8x8!");
}
@Override
@@ -39,26 +39,33 @@ public class RecipeBaseWidget extends HighlightableWidget {
public void render(int mouseX, int mouseY, float delta) {
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
GuiLighting.disable();
- MinecraftClient.getInstance().getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
- blit(bounds.x, bounds.y, 106, 190, bounds.width / 2, bounds.height / 2);
- blit(bounds.x + bounds.width / 2, bounds.y, 256 - bounds.width / 2, 190, bounds.width / 2, bounds.height / 2);
- blit(bounds.x, bounds.y + bounds.height / 2, 106, 190 + 66 - bounds.height / 2, bounds.width / 2, bounds.height / 2);
- blit(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, 256 - bounds.width / 2, 190 + 66 - bounds.height / 2, bounds.width / 2, bounds.height / 2);
- if (bounds.height > 40)
- for(int i = 20; i < bounds.height - 20; i += MathHelper.clamp(20, 0, bounds.height - 20 - i)) {
- int height = MathHelper.clamp(20, 0, bounds.height - 20 - i);
- blit(bounds.x, bounds.y + i, 106, 230, bounds.width / 2, height);
- blit(bounds.x + bounds.width / 2, bounds.y + i, 256 - bounds.width / 2, 210, bounds.width / 2, height);
- }
- if (bounds.width > 40)
- for(int i = 20; i < bounds.width - 20; i += MathHelper.clamp(40, 0, bounds.width - 20 - i)) {
- int width = MathHelper.clamp(40, 0, bounds.width - 20 - i);
- GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
- GuiLighting.disable();
- blit(bounds.x + i, bounds.y, 113, 190, width, MathHelper.clamp(4, 0, bounds.height / 2));
- blit(bounds.x + i, bounds.y + bounds.height - 4, 113, 252, width, MathHelper.clamp(4, 0, bounds.height / 2));
- fill(bounds.x + i, bounds.y + 4, bounds.x + i + width, bounds.y + bounds.height - 4, INNER_COLOR.getRGB());
- }
+ minecraft.getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
+ int x = bounds.x, y = bounds.y, width = bounds.width, height = bounds.height;
+ int textureOffset = getTextureOffset();
+
+ //Four Corners
+ this.blit(x, y, 106, 124 + textureOffset, 4, 4);
+ this.blit(x + width - 4, y, 252, 124 + textureOffset, 4, 4);
+ this.blit(x, y + height - 4, 106, 186 + textureOffset, 4, 4);
+ this.blit(x + width - 4, y + height - 4, 252, 186 + textureOffset, 4, 4);
+
+ //Sides
+ for(int xx = 4; xx < width - 4; xx += 128) {
+ int thisWidth = Math.min(128, width - 4 - xx);
+ this.blit(x + xx, y, 110, 124 + textureOffset, thisWidth, 4);
+ this.blit(x + xx, y + height - 4, 110, 186 + textureOffset, thisWidth, 4);
+ }
+ for(int yy = 4; yy < height - 4; yy += 50) {
+ int thisHeight = Math.min(50, height - 4 - yy);
+ this.blit(x, y + yy, 106, 128 + textureOffset, 4, thisHeight);
+ this.blit(x + width - 4, y + yy, 252, 128 + textureOffset, 4, thisHeight);
+ }
+ fillGradient(x + 4, y + 4, x + width - 4, y + height - 4, INNER_COLOR.getRGB(), INNER_COLOR.getRGB());
}
+ protected int getTextureOffset() {
+ return 0;
+ }
+
+
}