JEI cleanup

- JEI screens render individual widgets instead of the full white background. Adresses #8
This commit is contained in:
simibubi 2019-12-13 20:52:42 +01:00
parent fca3b74909
commit 9bd07d4ed0
11 changed files with 119 additions and 54 deletions

View file

@ -2,6 +2,7 @@ package com.simibubi.create;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.util.ResourceLocation;
public enum ScreenResources {
@ -62,13 +63,14 @@ public enum ScreenResources {
SELECTED_SLOT_INNER("index.png", 18, 172, 18, 18),
// JEI
CRUSHING_RECIPE("recipes1.png", 177, 109),
FAN_RECIPE("recipes1.png", 0, 128, 177, 109),
BLOCKZAPPER_UPGRADE_RECIPE("recipes2.png", 144, 66),
PRESSER_RECIPE("recipes2.png", 0, 108, 177, 109),
WASHING_RECIPE("recipes3.png", 177, 109),
PROCESSING_RECIPE_SLOT("recipes3.png", 177, 0, 20, 20),
JEI_SLOT("jei/widgets.png", 18, 18),
JEI_ARROW("jei/widgets.png", 19, 10, 42, 10),
JEI_LONG_ARROW("jei/widgets.png", 19, 0, 71, 10),
JEI_DOWN_ARROW("jei/widgets.png", 0, 21, 18, 14),
JEI_LIGHT("jei/widgets.png", 0, 42, 52, 11),
JEI_SHADOW("jei/widgets.png", 0, 56, 52, 11),
BLOCKZAPPER_UPGRADE_RECIPE("jei/widgets.png", 0, 75, 144, 66),
// Widgets
PALETTE_BUTTON("palette_picker.png", 0, 236, 20, 20),
TEXT_INPUT("widgets.png", 0, 28, 194, 47),
@ -128,7 +130,7 @@ public enum ScreenResources {
I_PRIORITY_VERY_HIGH(112, 0),
I_ACTIVE(64, 16),
I_PASSIVE(80, 16),
;
public static final int FONT_COLOR = 0x575F7A;
@ -136,6 +138,8 @@ public enum ScreenResources {
public final ResourceLocation location;
public int width, height;
public int startX, startY;
static Screen renderer = new Screen(null) {
};
private ScreenResources(String location, int width, int height) {
this(location, 0, 0, width, height);
@ -157,9 +161,13 @@ public enum ScreenResources {
Minecraft.getInstance().getTextureManager().bindTexture(location);
}
public void draw(AbstractGui screen, int i, int j) {
public void draw(AbstractGui screen, int x, int y) {
bind();
screen.blit(i, j, startX, startY, width, height);
screen.blit(x, y, startX, startY, width, height);
}
public void draw(int x, int y) {
draw(renderer, x, y);
}
}

View file

@ -3,7 +3,6 @@ package com.simibubi.create.compat.jei;
import com.mojang.blaze3d.platform.GlStateManager;
import com.simibubi.create.AllItems;
import com.simibubi.create.Create;
import com.simibubi.create.ScreenResources;
import com.simibubi.create.foundation.gui.ScreenElementRenderer;
import com.simibubi.create.foundation.utility.Lang;
@ -46,15 +45,9 @@ public class BlastingViaFanCategory extends ProcessingViaFanCategory<AbstractCoo
return Lang.translate("recipe.blastingViaFan");
}
@Override
public IDrawable getBackground() {
return new ScreenResourceWrapper(ScreenResources.FAN_RECIPE);
}
@Override
public void renderAttachedBlock() {
BlockState state = Blocks.LAVA.getDefaultState().with(FlowingFluidBlock.LEVEL, 8);
// This is stupid
GlStateManager.pushMatrix();
GlStateManager.translated(0, 0, 200);
GlStateManager.enableRescaleNormal();

View file

@ -26,12 +26,18 @@ public class CrushingCategory implements IRecipeCategory<CrushingRecipe> {
private static ResourceLocation ID = new ResourceLocation(Create.ID, "crushing");
private AnimatedCrushingWheels crushingWheels = new AnimatedCrushingWheels();
private IDrawable icon;
private IDrawable background = new EmptyBackground(177, 100);
public CrushingCategory() {
icon = new DoubleItemIcon(() -> new ItemStack(AllBlocks.CRUSHING_WHEEL.get()),
() -> new ItemStack(AllItems.FLOUR.get()));
}
@Override
public IDrawable getBackground() {
return background;
}
@Override
public ResourceLocation getUid() {
return ID;
@ -47,11 +53,6 @@ public class CrushingCategory implements IRecipeCategory<CrushingRecipe> {
return Lang.translate("recipe.crushing");
}
@Override
public IDrawable getBackground() {
return new ScreenResourceWrapper(ScreenResources.CRUSHING_RECIPE);
}
@Override
public IDrawable getIcon() {
return icon;
@ -66,12 +67,14 @@ public class CrushingCategory implements IRecipeCategory<CrushingRecipe> {
@Override
public void setRecipe(IRecipeLayout recipeLayout, CrushingRecipe recipe, IIngredients ingredients) {
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
itemStacks.init(0, true, 60, 2);
itemStacks.init(0, true, 50, 2);
itemStacks.set(0, Arrays.asList(recipe.getIngredients().get(0).getMatchingStacks()));
List<StochasticOutput> results = recipe.getRollableResults();
for (int outputIndex = 0; outputIndex < results.size(); outputIndex++) {
itemStacks.init(outputIndex + 1, false, 60 + 18 * outputIndex, 78);
int size = results.size();
int offset = -size * 19 / 2;
for (int outputIndex = 0; outputIndex < size; outputIndex++) {
itemStacks.init(outputIndex + 1, false, getBackground().getWidth() / 2 + offset + 19 * outputIndex, 78);
itemStacks.set(outputIndex + 1, results.get(outputIndex).getStack());
}
@ -87,7 +90,16 @@ public class CrushingCategory implements IRecipeCategory<CrushingRecipe> {
@Override
public void draw(CrushingRecipe recipe, double mouseX, double mouseY) {
crushingWheels.draw(100, 47);
List<StochasticOutput> results = recipe.getRollableResults();
ScreenResources.JEI_SLOT.draw(50, 2);
ScreenResources.JEI_DOWN_ARROW.draw(72, 7);
int size = results.size();
int offset = -size * 19 / 2;
for (int outputIndex = 0; outputIndex < results.size(); outputIndex++)
ScreenResources.JEI_SLOT.draw(getBackground().getWidth() / 2 + offset + 19 * outputIndex, 78);
crushingWheels.draw(92, 49);
}
}

View file

@ -0,0 +1,29 @@
package com.simibubi.create.compat.jei;
import mezz.jei.api.gui.drawable.IDrawable;
public class EmptyBackground implements IDrawable {
private int width;
private int height;
public EmptyBackground(int width, int height) {
this.width = width;
this.height = height;
}
@Override
public int getWidth() {
return width;
}
@Override
public int getHeight() {
return height;
}
@Override
public void draw(int xOffset, int yOffset) {
}
}

View file

@ -25,6 +25,7 @@ public class PressingCategory implements IRecipeCategory<PressingRecipe> {
private AnimatedPress press;
private static ResourceLocation ID = new ResourceLocation(Create.ID, "pressing");
private IDrawable icon;
private IDrawable background = new EmptyBackground(177, 70);
public PressingCategory() {
icon = new DoubleItemIcon(() -> new ItemStack(AllBlocks.MECHANICAL_PRESS.get()),
@ -54,7 +55,7 @@ public class PressingCategory implements IRecipeCategory<PressingRecipe> {
@Override
public IDrawable getBackground() {
return new ScreenResourceWrapper(ScreenResources.PRESSER_RECIPE);
return background;
}
@Override
@ -66,20 +67,24 @@ public class PressingCategory implements IRecipeCategory<PressingRecipe> {
@Override
public void setRecipe(IRecipeLayout recipeLayout, PressingRecipe recipe, IIngredients ingredients) {
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
itemStacks.init(0, true, 27, 60);
itemStacks.init(0, true, 26, 50);
itemStacks.set(0, Arrays.asList(recipe.getIngredients().get(0).getMatchingStacks()));
List<StochasticOutput> results = recipe.getRollableResults();
for (int outputIndex = 0; outputIndex < results.size(); outputIndex++) {
itemStacks.init(outputIndex + 1, false, 113 + 19 * outputIndex, 60);
itemStacks.init(outputIndex + 1, false, 131 + 19 * outputIndex, 50);
itemStacks.set(outputIndex + 1, results.get(outputIndex).getStack());
}
}
@Override
public void draw(PressingRecipe recipe, double mouseX, double mouseY) {
press.draw(ScreenResources.PRESSER_RECIPE.width / 2, 30);
ScreenResources.JEI_SLOT.draw(26, 50);
ScreenResources.JEI_SLOT.draw(131, 50);
if (recipe.getRollableResults().size() > 1)
ScreenResources.JEI_SLOT.draw(131 + 19, 50);
ScreenResources.JEI_LONG_ARROW.draw(52, 54);
press.draw(getBackground().getWidth() / 2, 20);
}
}

View file

@ -20,9 +20,11 @@ import net.minecraft.util.Direction;
public abstract class ProcessingViaFanCategory<T extends IRecipe<?>> implements IRecipeCategory<T> {
private IDrawable background = new EmptyBackground(177, 70);
@Override
public IDrawable getBackground() {
return new ScreenResourceWrapper(ScreenResources.FAN_RECIPE);
return background;
}
@Override
@ -34,20 +36,30 @@ public abstract class ProcessingViaFanCategory<T extends IRecipe<?>> implements
@Override
public void setRecipe(IRecipeLayout recipeLayout, T recipe, IIngredients ingredients) {
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
itemStacks.init(0, true, 20, 67);
itemStacks.init(0, true, 20, 47);
itemStacks.set(0, Arrays.asList(recipe.getIngredients().get(0).getMatchingStacks()));
itemStacks.init(1, false, 139, 67);
itemStacks.init(1, false, 139, 47);
itemStacks.set(1, recipe.getRecipeOutput());
}
protected void renderWidgets(T recipe, double mouseX, double mouseY) {
ScreenResources.JEI_SLOT.draw(20, 47);
ScreenResources.JEI_SLOT.draw(139, 47);
ScreenResources.JEI_SHADOW.draw(47, 29);
ScreenResources.JEI_LIGHT.draw(66, 39);
ScreenResources.JEI_LONG_ARROW.draw(53, 51);
}
@Override
public void draw(T recipe, double mouseX, double mouseY) {
renderWidgets(recipe, mouseX, mouseY);
GlStateManager.pushMatrix();
GlStateManager.color3f(1, 1, 1);
GlStateManager.enableDepthTest();
GlStateManager.translated(28, 42, 0);
GlStateManager.translated(28, 18, 0);
GlStateManager.rotated(10.5, -1f, 0, 0);
GlStateManager.rotated(15.5, 0, 1, 0);
GlStateManager.scaled(.6f, .6f, .6f);
@ -71,12 +83,10 @@ public abstract class ProcessingViaFanCategory<T extends IRecipe<?>> implements
}
protected BlockState renderFanCasing() {
return AllBlocks.ENCASED_FAN.get().getDefaultState().with(BlockStateProperties.FACING, Direction.WEST);
}
protected BlockState renderFanInner() {
return AllBlocks.ENCASED_FAN_INNER.get().getDefaultState().with(BlockStateProperties.FACING, Direction.WEST);
}

View file

@ -29,14 +29,18 @@ public class SplashingCategory extends ProcessingViaFanCategory<SplashingRecipe>
private static ResourceLocation ID = new ResourceLocation(Create.ID, "splashing");
private IDrawable icon;
private IDrawable slot;
private IDrawable background = new EmptyBackground(177, 70);
public SplashingCategory() {
slot = new ScreenResourceWrapper(ScreenResources.PROCESSING_RECIPE_SLOT);
icon = new DoubleItemIcon(() -> new ItemStack(AllItems.PROPELLER.get()),
() -> new ItemStack(Items.WATER_BUCKET));
}
@Override
public IDrawable getBackground() {
return background;
}
@Override
public IDrawable getIcon() {
return icon;
@ -66,15 +70,16 @@ public class SplashingCategory extends ProcessingViaFanCategory<SplashingRecipe>
@Override
public void setRecipe(IRecipeLayout recipeLayout, SplashingRecipe recipe, IIngredients ingredients) {
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
itemStacks.init(0, true, 20, 67);
itemStacks.init(0, true, 20, 47);
itemStacks.set(0, Arrays.asList(recipe.getIngredients().get(0).getMatchingStacks()));
List<StochasticOutput> results = recipe.getRollableResults();
boolean single = results.size() == 1;
for (int outputIndex = 0; outputIndex < results.size(); outputIndex++) {
int xOffset = outputIndex % 2 == 0 ? 0 : 19;
int yOffset = (outputIndex / 2) * -19;
itemStacks.init(outputIndex + 1, false, 132 + xOffset, 77 + yOffset);
itemStacks.init(outputIndex + 1, false, single ? 139 : 133 + xOffset, 47 + yOffset);
itemStacks.set(outputIndex + 1, results.get(outputIndex).getStack());
}
@ -89,25 +94,28 @@ public class SplashingCategory extends ProcessingViaFanCategory<SplashingRecipe>
}
@Override
public IDrawable getBackground() {
return new ScreenResourceWrapper(ScreenResources.WASHING_RECIPE);
}
@Override
public void draw(SplashingRecipe recipe, double mouseX, double mouseY) {
super.draw(recipe, mouseX, mouseY);
protected void renderWidgets(SplashingRecipe recipe, double mouseX, double mouseY) {
int size = recipe.getPossibleOutputs().size();
for (int i = 4; i < size; i++) {
int xOffset = i % 2 == 0 ? 0 : 19;
int yOffset = (i / 2) * -19;
slot.draw(131 + xOffset, 76 + yOffset);
ScreenResources.JEI_SLOT.draw(20, 47);
ScreenResources.JEI_SHADOW.draw(47, 29);
ScreenResources.JEI_SHADOW.draw(66, 39);
ScreenResources.JEI_LONG_ARROW.draw(53, 51);
if (size > 1) {
for (int i = 0; i < size; i++) {
int xOffset = i % 2 == 0 ? 0 : 19;
int yOffset = (i / 2) * -19;
ScreenResources.JEI_SLOT.draw(133 + xOffset, 47 + yOffset);
}
} else {
ScreenResources.JEI_SLOT.draw(139, 47);
}
}
@Override
public void renderAttachedBlock() {
BlockState state = Blocks.WATER.getDefaultState().with(FlowingFluidBlock.LEVEL, 8);
// This is stupid
GlStateManager.pushMatrix();
GlStateManager.translated(0, 0, 200);

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB