More sprites!
|
@ -389,17 +389,4 @@ public class GuiBase<T extends ScreenHandler> extends HandledScreen<T> {
|
|||
public static Sprite getSprite(SpriteIdentifier spriteIdentifier) {
|
||||
return GuiSpriteAtlasHolder.INSTANCE.getSprite(spriteIdentifier.getTextureId());
|
||||
}
|
||||
|
||||
public void drawSprite(DrawContext drawContext, SpriteIdentifier spriteIdentifier, int x, int y) {
|
||||
final Sprite sprite = getSprite(spriteIdentifier);
|
||||
|
||||
drawContext.drawSprite(
|
||||
x,
|
||||
y,
|
||||
0,
|
||||
sprite.getContents().getWidth(),
|
||||
sprite.getContents().getHeight(),
|
||||
sprite
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,18 +40,19 @@ import net.minecraft.util.Formatting;
|
|||
import net.minecraft.util.Identifier;
|
||||
import reborncore.api.IListInfoProvider;
|
||||
import reborncore.client.gui.config.GuiTab;
|
||||
import reborncore.client.gui.config.elements.GuiSprites;
|
||||
import reborncore.common.fluid.FluidUtils;
|
||||
import reborncore.common.fluid.FluidValue;
|
||||
import reborncore.common.fluid.container.FluidInstance;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import reborncore.common.powerSystem.PowerSystem.EnergySystem;
|
||||
import reborncore.common.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static reborncore.client.gui.GuiSprites.drawSprite;
|
||||
|
||||
/**
|
||||
* Created by Gigabit101 on 08/08/2016.
|
||||
*/
|
||||
|
@ -67,19 +68,6 @@ public class GuiBuilder {
|
|||
height / 2);
|
||||
}
|
||||
|
||||
public void drawSprite(DrawContext drawContext, SpriteIdentifier spriteIdentifier, int x, int y) {
|
||||
final Sprite sprite = GuiBase.getSprite(spriteIdentifier);
|
||||
|
||||
drawContext.drawSprite(
|
||||
x,
|
||||
y,
|
||||
0,
|
||||
sprite.getContents().getWidth(),
|
||||
sprite.getContents().getHeight(),
|
||||
sprite
|
||||
);
|
||||
}
|
||||
|
||||
public void drawPlayerSlots(DrawContext drawContext, Screen gui, int posX, int posY, boolean center) {
|
||||
if (center) {
|
||||
posX -= 81;
|
||||
|
@ -420,7 +408,7 @@ public class GuiBuilder {
|
|||
if (gui.hideGuiElements()) return;
|
||||
Text text = Text.literal(PowerSystem.getLocalizedPowerNoSuffix(maxOutput))
|
||||
.append(SPACE_TEXT)
|
||||
.append(PowerSystem.getDisplayPower().abbreviation)
|
||||
.append(PowerSystem.ABBREVIATION)
|
||||
.append("\t");
|
||||
|
||||
int width = gui.getTextRenderer().getWidth(text);
|
||||
|
@ -452,30 +440,20 @@ public class GuiBuilder {
|
|||
y += gui.getGuiTop();
|
||||
}
|
||||
|
||||
drawContext.drawTexture(resourceLocation, x, y, direction.x, direction.y, direction.width, direction.height);
|
||||
drawSprite(drawContext, direction.baseSprite, x, y);
|
||||
int j = (int) ((double) progress / (double) maxProgress * 16);
|
||||
if (j < 0) {
|
||||
j = 0;
|
||||
}
|
||||
|
||||
switch (direction) {
|
||||
case RIGHT:
|
||||
drawContext.drawTexture(resourceLocation, x, y, direction.xActive, direction.yActive, j, 10);
|
||||
break;
|
||||
case LEFT:
|
||||
drawContext.drawTexture(resourceLocation, x + 16 - j, y, direction.xActive + 16 - j, direction.yActive, j, 10);
|
||||
break;
|
||||
case UP:
|
||||
drawContext.drawTexture(resourceLocation, x, y + 16 - j, direction.xActive, direction.yActive + 16 - j, 10, j);
|
||||
break;
|
||||
case DOWN:
|
||||
drawContext.drawTexture(resourceLocation, x, y, direction.xActive, direction.yActive, 10, j);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
case RIGHT, LEFT -> drawSprite(drawContext, direction.overlaySprite, x, y, j, 10, gui);
|
||||
case UP, DOWN -> drawSprite(drawContext, direction.overlaySprite, x, y, 10, j, gui);
|
||||
}
|
||||
|
||||
if (gui.isPointInRect(x, y, direction.width, direction.height, mouseX, mouseY)) {
|
||||
final Sprite sprite = GuiBase.getSprite(direction.baseSprite);
|
||||
|
||||
if (gui.isPointInRect(x, y, sprite.getContents().getWidth(), sprite.getContents().getHeight(), mouseX, mouseY)) {
|
||||
int percentage = percentage(maxProgress, progress);
|
||||
List<Text> list = new ArrayList<>();
|
||||
list.add(
|
||||
|
@ -512,13 +490,15 @@ public class GuiBuilder {
|
|||
y += gui.getGuiTop();
|
||||
}
|
||||
|
||||
EnergySystem displayPower = PowerSystem.getDisplayPower();
|
||||
drawContext.drawTexture(resourceLocation, x, y, displayPower.xBar - 15, displayPower.yBar - 1, 14, 50);
|
||||
int draw = (int) ((double) energyStored / (double) maxEnergyStored * (48));
|
||||
drawSprite(drawContext, GuiSprites.POWER_BAR_BASE, x, y);
|
||||
|
||||
int barHeight = 48;
|
||||
int draw = (int) ((double) energyStored / (double) maxEnergyStored * (barHeight));
|
||||
if (energyStored > maxEnergyStored) {
|
||||
draw = 48;
|
||||
draw = barHeight;
|
||||
}
|
||||
drawContext.drawTexture(resourceLocation, x + 1, y + 49 - draw, displayPower.xBar, 48 + displayPower.yBar - draw, 12, draw);
|
||||
drawSprite(drawContext, GuiSprites.POWER_BAR_OVERLAY, x + 1, y + 49 - draw, 12, draw, gui);
|
||||
|
||||
int percentage = percentage(maxEnergyStored, energyStored);
|
||||
if (gui.isPointInRect(x + 1, y + 1, 11, 48, mouseX, mouseY)) {
|
||||
List<Text> list = Lists.newArrayList();
|
||||
|
@ -729,24 +709,17 @@ public class GuiBuilder {
|
|||
}
|
||||
|
||||
public enum ProgressDirection {
|
||||
RIGHT(58, 150, 74, 150, 16, 10),
|
||||
LEFT(74, 160, 58, 160, 16, 10),
|
||||
DOWN(78, 170, 88, 170, 10, 16),
|
||||
UP(58, 170, 68, 170, 10, 16);
|
||||
public int x;
|
||||
public int y;
|
||||
public int xActive;
|
||||
public int yActive;
|
||||
public int width;
|
||||
public int height;
|
||||
RIGHT,
|
||||
LEFT,
|
||||
DOWN,
|
||||
UP;
|
||||
|
||||
ProgressDirection(int x, int y, int xActive, int yActive, int width, int height) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.xActive = xActive;
|
||||
this.yActive = yActive;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
public final SpriteIdentifier baseSprite;
|
||||
public final SpriteIdentifier overlaySprite;
|
||||
|
||||
ProgressDirection() {
|
||||
baseSprite = GuiSprites.create("progress_%s_base".formatted(name().toLowerCase(Locale.ROOT)));
|
||||
overlaySprite = GuiSprites.create("progress_%s_overlay".formatted(name().toLowerCase(Locale.ROOT)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,10 +22,15 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package reborncore.client.gui.config.elements;
|
||||
package reborncore.client.gui;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.texture.SpriteAtlasHolder;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.util.Identifier;
|
||||
import reborncore.client.gui.config.elements.GuiSpriteAtlasHolder;
|
||||
|
||||
public final class GuiSprites {
|
||||
public static final SpriteIdentifier CHARGE_SLOT_ICON = create("charge_slot_icon");
|
||||
|
@ -62,6 +67,8 @@ public final class GuiSprites {
|
|||
public static final SpriteIdentifier SLOT_BAR_RIGHT = create("slot_bar_right");
|
||||
public static final SpriteIdentifier SLOT_BAR_CENTER = create("slot_bar_center");
|
||||
public static final SpriteIdentifier SLOT_BAR_LEFT = create("slot_bar_left");
|
||||
public static final SpriteIdentifier POWER_BAR_BASE = create("power_bar_base");
|
||||
public static final SpriteIdentifier POWER_BAR_OVERLAY = create("power_bar_overlay");
|
||||
|
||||
public static final SpriteIdentifier EXIT_BUTTON_NORMAL = create("exit_button_normal");
|
||||
public static final SpriteIdentifier EXIT_BUTTON_HOVERED = create("exit_button_hovered");
|
||||
|
@ -75,13 +82,45 @@ public final class GuiSprites {
|
|||
public static final SpriteIdentifier LIGHT_CHECK_BOX_TICKED = create("light_check_box_ticked");
|
||||
public static final CheckBox LIGHT_CHECK_BOX = new CheckBox(LIGHT_CHECK_BOX_NORMAL, LIGHT_CHECK_BOX_TICKED);
|
||||
|
||||
private static SpriteIdentifier create(String name) {
|
||||
public static SpriteIdentifier create(String name) {
|
||||
return new SpriteIdentifier(GuiSpriteAtlasHolder.ATLAS_ID, new Identifier("reborncore", name));
|
||||
}
|
||||
|
||||
record Button(SpriteIdentifier normal, SpriteIdentifier hovered) {
|
||||
public static void drawSprite(DrawContext drawContext, SpriteIdentifier spriteIdentifier, int x, int y) {
|
||||
final Sprite sprite = GuiBase.getSprite(spriteIdentifier);
|
||||
|
||||
drawContext.drawSprite(
|
||||
x,
|
||||
y,
|
||||
0,
|
||||
sprite.getContents().getWidth(),
|
||||
sprite.getContents().getHeight(),
|
||||
sprite
|
||||
);
|
||||
}
|
||||
|
||||
record CheckBox(SpriteIdentifier normal, SpriteIdentifier ticked) {
|
||||
public static void drawSprite(DrawContext drawContext, SpriteIdentifier spriteIdentifier, int x, int y, int width, int height) {
|
||||
drawSprite(drawContext, spriteIdentifier, x, y, width, height, 0, 0);
|
||||
}
|
||||
|
||||
public static void drawSprite(DrawContext drawContext, SpriteIdentifier spriteIdentifier, int x, int y, int width, int height, GuiBase<?> gui) {
|
||||
drawSprite(drawContext, spriteIdentifier, x, y, width, height, gui.getGuiLeft(), gui.getGuiTop());
|
||||
}
|
||||
|
||||
public static void drawSprite(DrawContext drawContext, SpriteIdentifier spriteIdentifier, int x, int y, int width, int height, int sx, int sy) {
|
||||
drawContext.enableScissor(x + sx, y + sy, x + width+ sx, y + height+ sy);
|
||||
drawSprite(
|
||||
drawContext,
|
||||
spriteIdentifier,
|
||||
x,
|
||||
y
|
||||
);
|
||||
drawContext.disableScissor();
|
||||
}
|
||||
|
||||
public record Button(SpriteIdentifier normal, SpriteIdentifier hovered) {
|
||||
}
|
||||
|
||||
public record CheckBox(SpriteIdentifier normal, SpriteIdentifier ticked) {
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ package reborncore.client.gui.config.elements;
|
|||
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import reborncore.client.gui.GuiBase;
|
||||
import reborncore.client.gui.GuiSprites;
|
||||
|
||||
public class ButtonElement extends ElementBase {
|
||||
private final GuiSprites.Button buttonSprite;
|
||||
|
|
|
@ -28,6 +28,7 @@ import net.minecraft.client.gui.DrawContext;
|
|||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.text.Text;
|
||||
import reborncore.client.gui.GuiBase;
|
||||
import reborncore.client.gui.GuiSprites;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ package reborncore.client.gui.config.elements;
|
|||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.text.Text;
|
||||
import reborncore.client.gui.GuiBase;
|
||||
import reborncore.client.gui.GuiSprites;
|
||||
|
||||
public class ConfigFluidElement extends ParentElement {
|
||||
private final SlotType type;
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.inventory.Inventory;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.text.Text;
|
||||
import reborncore.client.gui.GuiBase;
|
||||
import reborncore.client.gui.GuiSprites;
|
||||
import reborncore.common.blockentity.SlotConfiguration;
|
||||
import reborncore.common.screen.slot.BaseSlot;
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import net.minecraft.client.util.SpriteIdentifier;
|
|||
import net.minecraft.text.Text;
|
||||
import reborncore.client.gui.GuiBase;
|
||||
import reborncore.client.gui.GuiBuilder;
|
||||
import reborncore.client.gui.GuiSprites;
|
||||
|
||||
public class ElementBase {
|
||||
private final int x;
|
||||
|
@ -93,7 +94,7 @@ public class ElementBase {
|
|||
}
|
||||
|
||||
public void drawSprite(DrawContext drawContext, GuiBase<?> gui, SpriteIdentifier spriteIdentifier, int x, int y) {
|
||||
gui.drawSprite(drawContext, spriteIdentifier, x + gui.getGuiLeft(), y + gui.getGuiTop());
|
||||
GuiSprites.drawSprite(drawContext, spriteIdentifier, x + gui.getGuiLeft(), y + gui.getGuiTop());
|
||||
}
|
||||
|
||||
public void drawDefaultBackground(DrawContext drawContext, Screen gui, int x, int y, int width, int height) {
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.util.math.Direction;
|
|||
import reborncore.RebornCore;
|
||||
import reborncore.client.ClientNetworkManager;
|
||||
import reborncore.client.gui.GuiBase;
|
||||
import reborncore.client.gui.GuiSprites;
|
||||
import reborncore.common.blockentity.FluidConfiguration;
|
||||
import reborncore.common.network.IdentifiedPacket;
|
||||
import reborncore.common.network.ServerBoundPackets;
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.util.math.Direction;
|
|||
import reborncore.RebornCore;
|
||||
import reborncore.client.ClientNetworkManager;
|
||||
import reborncore.client.gui.GuiBase;
|
||||
import reborncore.client.gui.GuiSprites;
|
||||
import reborncore.common.blockentity.SlotConfiguration;
|
||||
import reborncore.common.network.IdentifiedPacket;
|
||||
import reborncore.common.network.ServerBoundPackets;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
package reborncore.client.gui.config.elements;
|
||||
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import reborncore.client.gui.GuiSprites;
|
||||
|
||||
public enum SlotType {
|
||||
NORMAL(1, 1, GuiSprites.SLOT, GuiSprites.BUTTON_SLOT_NORMAL, GuiSprites.BUTTON_HOVER_OVERLAY_SLOT_NORMAL);
|
||||
|
|
|
@ -29,7 +29,9 @@ import net.minecraft.client.gui.widget.ButtonWidget;
|
|||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.text.Text;
|
||||
import reborncore.client.gui.GuiBase;
|
||||
import reborncore.client.gui.config.elements.GuiSprites;
|
||||
import reborncore.client.gui.GuiSprites;
|
||||
|
||||
import static reborncore.client.gui.GuiSprites.drawSprite;
|
||||
|
||||
/**
|
||||
* @author drcrazy
|
||||
|
@ -47,7 +49,7 @@ public class GuiButtonUpDown extends GuiButtonExtended {
|
|||
@Override
|
||||
public void renderButton(DrawContext drawContext, int mouseX, int mouseY, float partialTicks) {
|
||||
if (gui.hideGuiElements()) return;
|
||||
gui.drawSprite(drawContext, type.spriteIdentifier, getX(), getY());
|
||||
drawSprite(drawContext, type.spriteIdentifier, getX(), getY());
|
||||
}
|
||||
|
||||
public enum UpDownButtonType {
|
||||
|
|
|
@ -71,7 +71,6 @@ public class RebornCore implements ModInitializer {
|
|||
@Override
|
||||
public void onInitialize() {
|
||||
new Configuration(RebornCoreConfig.class, MOD_ID);
|
||||
PowerSystem.init();
|
||||
CalenderUtils.loadCalender(); // Done early as some features need this
|
||||
|
||||
ToolManager.INSTANCE.customToolHandlerList.add(new GenericWrenchHelper(new Identifier("ic2:wrench"), true));
|
||||
|
|
|
@ -25,20 +25,17 @@
|
|||
package reborncore.common.powerSystem;
|
||||
|
||||
import reborncore.RebornCore;
|
||||
import reborncore.common.RebornCoreConfig;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class PowerSystem {
|
||||
private static EnergySystem selectedSystem = EnergySystem.values()[0];
|
||||
public static final String ABBREVIATION = "E";
|
||||
|
||||
private static final char[] magnitude = new char[] { 'k', 'M', 'G', 'T' };
|
||||
|
||||
public static String getLocalizedPower(double power) {
|
||||
|
||||
return getRoundedString(power, selectedSystem.abbreviation, true);
|
||||
return getRoundedString(power, ABBREVIATION, true);
|
||||
}
|
||||
|
||||
public static String getLocalizedPowerNoSuffix(double power) {
|
||||
|
@ -46,7 +43,7 @@ public class PowerSystem {
|
|||
}
|
||||
|
||||
public static String getLocalizedPowerNoFormat(double power){
|
||||
return getRoundedString(power, selectedSystem.abbreviation, false);
|
||||
return getRoundedString(power, ABBREVIATION, false);
|
||||
}
|
||||
|
||||
public static String getLocalizedPowerNoSuffixNoFormat(double power){
|
||||
|
@ -54,7 +51,7 @@ public class PowerSystem {
|
|||
}
|
||||
|
||||
public static String getLocalizedPowerFull(double power){
|
||||
return getFullPower(power, selectedSystem.abbreviation);
|
||||
return getFullPower(power, ABBREVIATION);
|
||||
}
|
||||
|
||||
public static String getLocalizedPowerFullNoSuffix(double power){
|
||||
|
@ -131,45 +128,4 @@ public class PowerSystem {
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static EnergySystem getDisplayPower() {
|
||||
if(!selectedSystem.enabled.get()){
|
||||
bumpPowerConfig();
|
||||
}
|
||||
return selectedSystem;
|
||||
}
|
||||
|
||||
public static void bumpPowerConfig() {
|
||||
int value = selectedSystem.ordinal() + 1;
|
||||
if (value == EnergySystem.values().length) {
|
||||
value = 0;
|
||||
}
|
||||
selectedSystem = EnergySystem.values()[value];
|
||||
}
|
||||
|
||||
public static void init(){
|
||||
selectedSystem = Arrays.stream(EnergySystem.values()).filter(energySystem -> energySystem.abbreviation.equalsIgnoreCase(RebornCoreConfig.selectedSystem)).findFirst().orElse(EnergySystem.values()[0]);
|
||||
if(!selectedSystem.enabled.get()){
|
||||
bumpPowerConfig();
|
||||
}
|
||||
}
|
||||
|
||||
public enum EnergySystem {
|
||||
EU(0xFF800600, "E", 141, 151, 0xFF670000);
|
||||
|
||||
public int colour;
|
||||
public int altColour;
|
||||
public String abbreviation;
|
||||
public int xBar;
|
||||
public int yBar;
|
||||
public Supplier<Boolean> enabled = () -> true;
|
||||
|
||||
EnergySystem(int colour, String abbreviation, int xBar, int yBar, int altColour) {
|
||||
this.colour = colour;
|
||||
this.abbreviation = abbreviation;
|
||||
this.xBar = xBar;
|
||||
this.yBar = yBar;
|
||||
this.altColour = altColour;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
After Width: | Height: | Size: 670 B |
After Width: | Height: | Size: 831 B |
After Width: | Height: | Size: 119 B |
After Width: | Height: | Size: 316 B |
After Width: | Height: | Size: 94 B |
After Width: | Height: | Size: 305 B |
After Width: | Height: | Size: 92 B |
After Width: | Height: | Size: 302 B |
After Width: | Height: | Size: 121 B |
After Width: | Height: | Size: 316 B |
|
@ -24,7 +24,6 @@
|
|||
|
||||
package techreborn.client.compat.rei;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import dev.architectury.event.CompoundEventResult;
|
||||
import dev.architectury.fluid.FluidStack;
|
||||
import me.shedaniel.math.Rectangle;
|
||||
|
@ -54,20 +53,19 @@ import net.minecraft.client.texture.Sprite;
|
|||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.screen.PlayerScreenHandler;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import reborncore.api.blockentity.IUpgradeable;
|
||||
import reborncore.client.gui.GuiBase;
|
||||
import reborncore.client.gui.config.GuiTab;
|
||||
import reborncore.client.gui.GuiBuilder;
|
||||
import reborncore.client.gui.GuiSprites;
|
||||
import reborncore.client.gui.config.GuiTab;
|
||||
import reborncore.common.crafting.RebornRecipe;
|
||||
import reborncore.common.crafting.RebornRecipeType;
|
||||
import reborncore.common.crafting.RecipeManager;
|
||||
import reborncore.common.fluid.container.ItemFluidInfo;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.api.generator.GeneratorRecipeHelper;
|
||||
|
@ -91,6 +89,8 @@ import java.util.Map;
|
|||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static reborncore.client.gui.GuiSprites.drawSprite;
|
||||
|
||||
public class ReiPlugin implements REIClientPlugin {
|
||||
public static final Map<RebornRecipeType<?>, ItemConvertible> iconMap = new HashMap<>();
|
||||
|
||||
|
@ -270,17 +270,15 @@ public class ReiPlugin implements REIClientPlugin {
|
|||
|
||||
public static Widget createProgressBar(int x, int y, double animationDuration, GuiBuilder.ProgressDirection direction) {
|
||||
return Widgets.createDrawableWidget((drawContext, mouseX, mouseY, delta) -> {
|
||||
drawContext.drawTexture(GuiBuilder.resourceLocation, x, y, direction.x, direction.y, direction.width, direction.height);
|
||||
drawSprite(drawContext, direction.baseSprite, x, y);
|
||||
int j = (int) ((System.currentTimeMillis() / animationDuration) % 1.0 * 16.0);
|
||||
if (j < 0) {
|
||||
j = 0;
|
||||
}
|
||||
|
||||
switch (direction) {
|
||||
case RIGHT -> drawContext.drawTexture(GuiBuilder.resourceLocation, x, y, direction.xActive, direction.yActive, j, 10);
|
||||
case LEFT -> drawContext.drawTexture(GuiBuilder.resourceLocation, x + 16 - j, y, direction.xActive + 16 - j, direction.yActive, j, 10);
|
||||
case UP -> drawContext.drawTexture(GuiBuilder.resourceLocation, x, y + 16 - j, direction.xActive, direction.yActive + 16 - j, 10, j);
|
||||
case DOWN -> drawContext.drawTexture(GuiBuilder.resourceLocation, x, y, direction.xActive, direction.yActive, 10, j);
|
||||
case RIGHT, LEFT -> drawSprite(drawContext, direction.overlaySprite, x, y, j, 10);
|
||||
case UP, DOWN -> drawSprite(drawContext, direction.overlaySprite, x, y, 10, j);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -297,105 +295,87 @@ public class ReiPlugin implements REIClientPlugin {
|
|||
return Widgets.createSlot(bounds).entry(copy);
|
||||
}
|
||||
|
||||
private static class EnergyEntryRenderer implements Renderer {
|
||||
private final EntryAnimation animation;
|
||||
private final Function<TooltipContext, Tooltip> tooltipBuilder;
|
||||
|
||||
protected EnergyEntryRenderer(EntryAnimation animation, Function<TooltipContext, Tooltip> tooltipBuilder) {
|
||||
this.animation = animation;
|
||||
this.tooltipBuilder = tooltipBuilder;
|
||||
}
|
||||
|
||||
private record EnergyEntryRenderer(EntryAnimation animation, Function<TooltipContext, Tooltip> tooltipBuilder) implements Renderer {
|
||||
@Override
|
||||
public void render(DrawContext drawContext, Rectangle bounds, int mouseX, int mouseY, float delta) {
|
||||
int width = bounds.width + 2;
|
||||
int height = bounds.height + 2;
|
||||
int innerHeight = height - 2;
|
||||
public void render(DrawContext drawContext, Rectangle bounds, int mouseX, int mouseY, float delta) {
|
||||
int width = bounds.width + 2;
|
||||
int height = bounds.height + 2;
|
||||
int innerHeight = height - 2;
|
||||
|
||||
PowerSystem.EnergySystem displayPower = PowerSystem.getDisplayPower();
|
||||
drawContext.drawTexture(GuiBuilder.resourceLocation, bounds.x - 1, bounds.y - 1, displayPower.xBar - 15, displayPower.yBar - 1, width, height);
|
||||
int innerDisplayHeight;
|
||||
if (animation.animationType != EntryAnimationType.NONE) {
|
||||
innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / (float) innerHeight) % innerHeight));
|
||||
if (animation.animationType == EntryAnimationType.DOWNWARDS)
|
||||
innerDisplayHeight = innerHeight - innerDisplayHeight;
|
||||
} else innerDisplayHeight = innerHeight;
|
||||
drawContext.drawTexture(GuiBuilder.resourceLocation, bounds.x, bounds.y + innerHeight - innerDisplayHeight, displayPower.xBar, innerHeight + displayPower.yBar - innerDisplayHeight, width - 2, innerDisplayHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Tooltip getTooltip(TooltipContext context) {
|
||||
return this.tooltipBuilder.apply(context);
|
||||
}
|
||||
}
|
||||
|
||||
private static class FluidStackRenderer implements EntryRenderer<FluidStack> {
|
||||
private final EntryAnimation animation;
|
||||
private final EntryRenderer<FluidStack> parent;
|
||||
|
||||
public FluidStackRenderer(EntryAnimation animation, EntryRenderer<FluidStack> parent) {
|
||||
this.animation = animation;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(EntryStack<FluidStack> entry, DrawContext drawContext, Rectangle bounds, int mouseX, int mouseY, float delta) {
|
||||
int width = bounds.width;
|
||||
int height = bounds.height;
|
||||
|
||||
drawContext.drawTexture(GuiBuilder.resourceLocation, bounds.x - 4, bounds.y - 4, 194, 26, width + 8, height + 8);
|
||||
drawContext.drawTexture(GuiBuilder.resourceLocation, bounds.x - 1, bounds.y - 1, 194, 82, width + 2, height + 2);
|
||||
int innerDisplayHeight;
|
||||
if (animation.animationType != EntryAnimationType.NONE) {
|
||||
innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / (float) height) % height));
|
||||
if (animation.animationType == EntryAnimationType.DOWNWARDS)
|
||||
innerDisplayHeight = height - innerDisplayHeight;
|
||||
} else innerDisplayHeight = height;
|
||||
drawFluid(drawContext, entry.getValue().getFluid(), innerDisplayHeight, bounds.x, bounds.y, width, height);
|
||||
}
|
||||
|
||||
public void drawFluid(DrawContext drawContext, Fluid fluid, int drawHeight, int x, int y, int width, int height) {
|
||||
RenderSystem.setShaderTexture(0, PlayerScreenHandler.BLOCK_ATLAS_TEXTURE);
|
||||
y += height;
|
||||
|
||||
FluidRenderHandler handler = FluidRenderHandlerRegistry.INSTANCE.get(fluid);
|
||||
|
||||
// If registry can't find it, don't render.
|
||||
if (handler == null) {
|
||||
return;
|
||||
drawSprite(drawContext, GuiSprites.POWER_BAR_BASE, bounds.x - 1, bounds.y - 1);
|
||||
int innerDisplayHeight;
|
||||
if (animation.animationType != EntryAnimationType.NONE) {
|
||||
innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / (float) innerHeight) % innerHeight));
|
||||
if (animation.animationType == EntryAnimationType.DOWNWARDS)
|
||||
innerDisplayHeight = innerHeight - innerDisplayHeight;
|
||||
} else innerDisplayHeight = innerHeight;
|
||||
drawSprite(drawContext, GuiSprites.POWER_BAR_OVERLAY, bounds.x, bounds.y + innerHeight - innerDisplayHeight, width - 2, innerDisplayHeight);
|
||||
}
|
||||
|
||||
final Sprite sprite = handler.getFluidSprites(MinecraftClient.getInstance().world, BlockPos.ORIGIN, fluid.getDefaultState())[0];
|
||||
int color = FluidRenderHandlerRegistry.INSTANCE.get(fluid).getFluidColor(MinecraftClient.getInstance().world, BlockPos.ORIGIN, fluid.getDefaultState());
|
||||
@Override
|
||||
@Nullable
|
||||
public Tooltip getTooltip(TooltipContext context) {
|
||||
return this.tooltipBuilder.apply(context);
|
||||
}
|
||||
}
|
||||
|
||||
final int iconHeight = sprite.getContents().getHeight();
|
||||
int offsetHeight = drawHeight;
|
||||
private record FluidStackRenderer(EntryAnimation animation, EntryRenderer<FluidStack> parent) implements EntryRenderer<FluidStack> {
|
||||
@Override
|
||||
public void render(EntryStack<FluidStack> entry, DrawContext drawContext, Rectangle bounds, int mouseX, int mouseY, float delta) {
|
||||
int width = bounds.width;
|
||||
int height = bounds.height;
|
||||
|
||||
RenderSystem.setShaderColor((color >> 16 & 255) / 255.0F, (float) (color >> 8 & 255) / 255.0F, (float) (color & 255) / 255.0F, 1F);
|
||||
drawSprite(drawContext, GuiSprites.TANK_BACKGROUND, bounds.x - 4, bounds.y - 4);
|
||||
int innerDisplayHeight;
|
||||
if (animation.animationType != EntryAnimationType.NONE) {
|
||||
innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / (float) height) % height));
|
||||
if (animation.animationType == EntryAnimationType.DOWNWARDS)
|
||||
innerDisplayHeight = height - innerDisplayHeight;
|
||||
} else innerDisplayHeight = height;
|
||||
drawFluid(drawContext, entry.getValue().getFluid(), innerDisplayHeight, bounds.x, bounds.y, width, height);
|
||||
drawSprite(drawContext, GuiSprites.TANK_FOREGROUND, bounds.x - 1, bounds.y - 1);
|
||||
}
|
||||
|
||||
int iteration = 0;
|
||||
while (offsetHeight != 0) {
|
||||
final int curHeight = Math.min(offsetHeight, iconHeight);
|
||||
public void drawFluid(DrawContext drawContext, Fluid fluid, int drawHeight, int x, int y, int width, int height) {
|
||||
y += height;
|
||||
|
||||
drawContext.drawSprite(x, y - offsetHeight, 0, width, curHeight, sprite);
|
||||
offsetHeight -= curHeight;
|
||||
iteration++;
|
||||
if (iteration > 50) {
|
||||
break;
|
||||
FluidRenderHandler handler = FluidRenderHandlerRegistry.INSTANCE.get(fluid);
|
||||
|
||||
// If registry can't find it, don't render.
|
||||
if (handler == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Sprite sprite = handler.getFluidSprites(MinecraftClient.getInstance().world, BlockPos.ORIGIN, fluid.getDefaultState())[0];
|
||||
int color = FluidRenderHandlerRegistry.INSTANCE.get(fluid).getFluidColor(MinecraftClient.getInstance().world, BlockPos.ORIGIN, fluid.getDefaultState());
|
||||
|
||||
final int iconHeight = sprite.getContents().getHeight();
|
||||
int offsetHeight = drawHeight;
|
||||
|
||||
drawContext.setShaderColor((color >> 16 & 255) / 255.0F, (float) (color >> 8 & 255) / 255.0F, (float) (color & 255) / 255.0F, 1F);
|
||||
|
||||
int iteration = 0;
|
||||
while (offsetHeight != 0) {
|
||||
final int curHeight = Math.min(offsetHeight, iconHeight);
|
||||
|
||||
drawContext.drawSprite(x, y - offsetHeight, 0, width, curHeight, sprite);
|
||||
offsetHeight -= curHeight;
|
||||
iteration++;
|
||||
if (iteration > 50) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
drawContext.setShaderColor(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Tooltip getTooltip(EntryStack<FluidStack> entry, TooltipContext context) {
|
||||
return parent.getTooltip(entry, context);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Tooltip getTooltip(EntryStack<FluidStack> entry, TooltipContext context) {
|
||||
return parent.getTooltip(entry, context);
|
||||
}
|
||||
}
|
||||
|
||||
public record EntryAnimation(EntryAnimationType animationType, long duration) {
|
||||
|
||||
public static EntryAnimation upwards(long duration) {
|
||||
return new EntryAnimation(EntryAnimationType.UPWARDS, duration);
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ public class GuiAESU extends GuiBase<BuiltScreenHandler> {
|
|||
.append("/")
|
||||
.append(PowerSystem.getLocalizedPowerNoSuffix(blockEntity.getMaxStoredPower()))
|
||||
.append(" ")
|
||||
.append(PowerSystem.getDisplayPower().abbreviation);
|
||||
.append(PowerSystem.ABBREVIATION);
|
||||
|
||||
drawCentredText(drawContext, text, 35, 0, 58, layer);
|
||||
matrices.pop();
|
||||
|
|
|
@ -66,7 +66,7 @@ public class GuiIDSU extends GuiBase<BuiltScreenHandler> {
|
|||
.append("/")
|
||||
.append(PowerSystem.getLocalizedPowerNoSuffix(idsu.getMaxStoredPower()))
|
||||
.append(" ")
|
||||
.append(PowerSystem.getDisplayPower().abbreviation);
|
||||
.append(PowerSystem.ABBREVIATION);
|
||||
|
||||
drawCentredText(drawContext, text, 35, 0, 58, layer);
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public class GuiLESU extends GuiBase<BuiltScreenHandler> {
|
|||
.append("/")
|
||||
.append(PowerSystem.getLocalizedPowerNoSuffix(blockEntity.getMaxStoredPower()))
|
||||
.append(" ")
|
||||
.append(PowerSystem.getDisplayPower().abbreviation),
|
||||
.append(PowerSystem.ABBREVIATION),
|
||||
35, 0, 58, layer);
|
||||
matrices.pop();
|
||||
|
||||
|
|