mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-25 12:58:33 +01:00
added back overlay rendering
This commit is contained in:
parent
5b7df8bd45
commit
1469e4ca5f
3 changed files with 140 additions and 144 deletions
|
@ -1,5 +1,6 @@
|
||||||
package de.ellpeck.naturesaura;
|
package de.ellpeck.naturesaura;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
||||||
import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
|
import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
|
||||||
|
@ -8,6 +9,7 @@ import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl;
|
||||||
import de.ellpeck.naturesaura.chunk.AuraChunk;
|
import de.ellpeck.naturesaura.chunk.AuraChunk;
|
||||||
import de.ellpeck.naturesaura.compat.Compat;
|
import de.ellpeck.naturesaura.compat.Compat;
|
||||||
import de.ellpeck.naturesaura.misc.LevelData;
|
import de.ellpeck.naturesaura.misc.LevelData;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -41,7 +43,6 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import net.minecraftforge.registries.IForgeRegistry;
|
import net.minecraftforge.registries.IForgeRegistry;
|
||||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||||
import org.apache.commons.lang3.tuple.ImmutableTriple;
|
import org.apache.commons.lang3.tuple.ImmutableTriple;
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
import top.theillusivec4.curios.api.CuriosApi;
|
import top.theillusivec4.curios.api.CuriosApi;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
@ -116,6 +117,19 @@ public final class Helper {
|
||||||
return !nbt || ItemStack.tagMatches(first, second);
|
return !nbt || ItemStack.tagMatches(first, second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public static void renderItemInGui(ItemStack stack, int x, int y, float scale) {
|
||||||
|
var poseStack = RenderSystem.getModelViewStack();
|
||||||
|
poseStack.pushPose();
|
||||||
|
poseStack.translate(x, y, 0);
|
||||||
|
poseStack.scale(scale, scale, scale);
|
||||||
|
RenderSystem.applyModelViewMatrix();
|
||||||
|
Minecraft.getInstance().getItemRenderer().renderGuiItem(stack, 0, 0);
|
||||||
|
Minecraft.getInstance().getItemRenderer().renderGuiItemDecorations(Minecraft.getInstance().font, stack, 0, 0, null);
|
||||||
|
poseStack.popPose();
|
||||||
|
RenderSystem.applyModelViewMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
public static InteractionResult putStackOnTile(Player player, InteractionHand hand, BlockPos pos, int slot, boolean sound) {
|
public static InteractionResult putStackOnTile(Player player, InteractionHand hand, BlockPos pos, int slot, boolean sound) {
|
||||||
var tile = player.level.getBlockEntity(pos);
|
var tile = player.level.getBlockEntity(pos);
|
||||||
if (tile instanceof BlockEntityImpl) {
|
if (tile instanceof BlockEntityImpl) {
|
||||||
|
@ -226,34 +240,6 @@ public final class Helper {
|
||||||
return highestAmount;
|
return highestAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
public static void renderWeirdBox(double x, double y, double z, double width, double height, double depth) {
|
|
||||||
GL11.glVertex3d(x, y + height, z);
|
|
||||||
GL11.glVertex3d(x + width, y + height, z);
|
|
||||||
GL11.glVertex3d(x + width, y, z);
|
|
||||||
GL11.glVertex3d(x, y, z);
|
|
||||||
GL11.glVertex3d(x + width, y, z + depth);
|
|
||||||
GL11.glVertex3d(x + width, y, z);
|
|
||||||
GL11.glVertex3d(x + width, y + height, z);
|
|
||||||
GL11.glVertex3d(x + width, y + height, z + depth);
|
|
||||||
GL11.glVertex3d(x + width, y + height, z + depth);
|
|
||||||
GL11.glVertex3d(x, y + height, z + depth);
|
|
||||||
GL11.glVertex3d(x, y, z + depth);
|
|
||||||
GL11.glVertex3d(x + width, y, z + depth);
|
|
||||||
GL11.glVertex3d(x, y + height, z + depth);
|
|
||||||
GL11.glVertex3d(x, y + height, z);
|
|
||||||
GL11.glVertex3d(x, y, z);
|
|
||||||
GL11.glVertex3d(x, y, z + depth);
|
|
||||||
GL11.glVertex3d(x, y + height, z);
|
|
||||||
GL11.glVertex3d(x, y + height, z + depth);
|
|
||||||
GL11.glVertex3d(x + width, y + height, z + depth);
|
|
||||||
GL11.glVertex3d(x + width, y + height, z);
|
|
||||||
GL11.glVertex3d(x + width, y, z);
|
|
||||||
GL11.glVertex3d(x + width, y, z + depth);
|
|
||||||
GL11.glVertex3d(x, y, z + depth);
|
|
||||||
GL11.glVertex3d(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isHoldingItem(Player player, Item item) {
|
public static boolean isHoldingItem(Player player, Item item) {
|
||||||
for (var hand : InteractionHand.values()) {
|
for (var hand : InteractionHand.values()) {
|
||||||
var stack = player.getItemInHand(hand);
|
var stack = player.getItemInHand(hand);
|
||||||
|
|
|
@ -138,8 +138,7 @@ public class PatchouliCompat implements ICompat {
|
||||||
var r = ((info.color() >> 16) & 255) / 255F;
|
var r = ((info.color() >> 16) & 255) / 255F;
|
||||||
var g = ((info.color() >> 8) & 255) / 255F;
|
var g = ((info.color() >> 8) & 255) / 255F;
|
||||||
var b = (info.color() & 255) / 255F;
|
var b = (info.color() & 255) / 255F;
|
||||||
// TODO apply leaf color, we probably have to blit manually using the texture + color shader
|
RenderSystem.setShaderColor(r, g, b, 1);
|
||||||
//RenderSystem.color3f(r, g, b);
|
|
||||||
Screen.blit(event.getPoseStack(), x, y, 496 - 32, 44, 16, 18, 512, 256);
|
Screen.blit(event.getPoseStack(), x, y, 496 - 32, 44, 16, 18, 512, 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,32 +1,44 @@
|
||||||
package de.ellpeck.naturesaura.events;
|
package de.ellpeck.naturesaura.events;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.platform.Window;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import de.ellpeck.naturesaura.Helper;
|
import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.ModConfig;
|
import de.ellpeck.naturesaura.ModConfig;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
|
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
||||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||||
|
import de.ellpeck.naturesaura.blocks.tiles.*;
|
||||||
import de.ellpeck.naturesaura.items.ItemAuraCache;
|
import de.ellpeck.naturesaura.items.ItemAuraCache;
|
||||||
import de.ellpeck.naturesaura.items.ItemRangeVisualizer;
|
import de.ellpeck.naturesaura.items.ItemRangeVisualizer;
|
||||||
import de.ellpeck.naturesaura.items.ModItems;
|
import de.ellpeck.naturesaura.items.ModItems;
|
||||||
import de.ellpeck.naturesaura.packet.PacketAuraChunk;
|
import de.ellpeck.naturesaura.packet.PacketAuraChunk;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.screens.ChatScreen;
|
||||||
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.client.renderer.BiomeColors;
|
import net.minecraft.client.renderer.BiomeColors;
|
||||||
|
import net.minecraft.client.resources.language.I18n;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.util.Tuple;
|
import net.minecraft.util.Tuple;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.world.level.block.*;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.BonemealableBlock;
|
||||||
|
import net.minecraft.world.level.block.LeavesBlock;
|
||||||
|
import net.minecraft.world.level.block.MyceliumBlock;
|
||||||
import net.minecraft.world.level.levelgen.Heightmap;
|
import net.minecraft.world.level.levelgen.Heightmap;
|
||||||
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||||
import net.minecraftforge.client.event.RenderLevelLastEvent;
|
import net.minecraftforge.client.event.RenderLevelLastEvent;
|
||||||
import net.minecraftforge.common.IPlantable;
|
import net.minecraftforge.common.IPlantable;
|
||||||
|
import net.minecraftforge.energy.EnergyStorage;
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.minecraftforge.event.TickEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import org.apache.commons.lang3.mutable.MutableInt;
|
import org.apache.commons.lang3.mutable.MutableInt;
|
||||||
|
@ -236,131 +248,132 @@ public class ClientEvents {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onOverlayRender(RenderGameOverlayEvent.Post event) {
|
public void onOverlayRender(RenderGameOverlayEvent.Post event) {
|
||||||
// TODO raw rendering bleh, should be easy enough to convert to PoseStack stuff
|
var mc = Minecraft.getInstance();
|
||||||
/*Minecraft mc = Minecraft.getInstance();
|
var stack = event.getMatrixStack();
|
||||||
PoseStack stack = event.getMatrixStack();
|
if (event.getType() == RenderGameOverlayEvent.ElementType.ALL) {
|
||||||
if (event.getType() == ElementType.ALL) {
|
|
||||||
var res = event.getWindow();
|
var res = event.getWindow();
|
||||||
if (mc.player != null) {
|
if (mc.player != null) {
|
||||||
if (!heldCache.isEmpty()) {
|
if (!heldCache.isEmpty()) {
|
||||||
IAuraContainer container = heldCache.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
|
var container = heldCache.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
|
||||||
int width = Mth.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80);
|
var width = Mth.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80);
|
||||||
|
|
||||||
int conf = ModConfig.instance.cacheBarLocation.get();
|
int conf = ModConfig.instance.cacheBarLocation.get();
|
||||||
int x = res.getGuiScaledWidth() / 2 + (conf == 0 ? -173 - (mc.player.getOffhandItem().isEmpty() ? 0 : 29) : 93);
|
var x = res.getGuiScaledWidth() / 2 + (conf == 0 ? -173 - (mc.player.getOffhandItem().isEmpty() ? 0 : 29) : 93);
|
||||||
int y = res.getScreenHeight() - 8;
|
var y = res.getGuiScaledHeight() - 8;
|
||||||
|
|
||||||
RenderSystem.pushMatrix();
|
stack.pushPose();
|
||||||
|
|
||||||
int color = container.getAuraColor();
|
var color = container.getAuraColor();
|
||||||
RenderSystem.color4f((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 1);
|
RenderSystem.setShaderColor((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 1);
|
||||||
mc.getTextureManager().bindTexture(OVERLAYS);
|
RenderSystem.setShaderTexture(0, OVERLAYS);
|
||||||
if (width < 80)
|
if (width < 80)
|
||||||
AbstractGui.blit(stack, x + width, y, width, 0, 80 - width, 6, 256, 256);
|
Screen.blit(stack, x + width, y, width, 0, 80 - width, 6, 256, 256);
|
||||||
if (width > 0)
|
if (width > 0)
|
||||||
AbstractGui.blit(stack, x, y, 0, 6, width, 6, 256, 256);
|
Screen.blit(stack, x, y, 0, 6, width, 6, 256, 256);
|
||||||
|
|
||||||
float scale = 0.75F;
|
var scale = 0.75F;
|
||||||
RenderSystem.scalef(scale, scale, scale);
|
stack.pushPose();
|
||||||
String s = heldCache.getDisplayName().getString();
|
stack.scale(scale, scale, scale);
|
||||||
mc.fontRenderer.drawStringWithShadow(stack, s, conf == 1 ? x / scale : (x + 80) / scale - mc.fontRenderer.getStringWidth(s), (y - 7) / scale, color);
|
var s = heldCache.getDisplayName().getString();
|
||||||
|
mc.font.drawShadow(stack, s, conf == 1 ? x / scale : (x + 80) / scale - mc.font.width(s), (y - 7) / scale, color);
|
||||||
|
stack.popPose();
|
||||||
|
|
||||||
RenderSystem.color4f(1F, 1F, 1F, 1);
|
RenderSystem.setShaderColor(1F, 1F, 1F, 1);
|
||||||
RenderSystem.popMatrix();
|
stack.pushPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!heldEye.isEmpty() || !heldOcular.isEmpty()) {
|
if (!heldEye.isEmpty() || !heldOcular.isEmpty()) {
|
||||||
RenderSystem.pushMatrix();
|
stack.pushPose();
|
||||||
mc.getTextureManager().bindTexture(OVERLAYS);
|
RenderSystem.setShaderTexture(0, OVERLAYS);
|
||||||
|
|
||||||
int conf = ModConfig.instance.auraBarLocation.get();
|
int conf = ModConfig.instance.auraBarLocation.get();
|
||||||
if (!mc.gameSettings.showDebugInfo && (conf != 2 || !(mc.currentScreen instanceof ChatScreen))) {
|
if (!mc.options.renderDebug && (conf != 2 || !(mc.screen instanceof ChatScreen))) {
|
||||||
int color = IAuraType.forLevel(mc.level).getColor();
|
var color = IAuraType.forLevel(mc.level).getColor();
|
||||||
RenderSystem.color4f((color >> 16 & 0xFF) / 255F, (color >> 8 & 0xFF) / 255F, (color & 0xFF) / 255F, 1);
|
RenderSystem.setShaderColor((color >> 16 & 0xFF) / 255F, (color >> 8 & 0xFF) / 255F, (color & 0xFF) / 255F, 1);
|
||||||
|
|
||||||
int totalAmount = IAuraChunk.triangulateAuraInArea(mc.level, mc.player.getPosition(), 35);
|
var totalAmount = IAuraChunk.triangulateAuraInArea(mc.level, mc.player.blockPosition(), 35);
|
||||||
float totalPercentage = totalAmount / (IAuraChunk.DEFAULT_AURA * 2F);
|
var totalPercentage = totalAmount / (IAuraChunk.DEFAULT_AURA * 2F);
|
||||||
String text = I18n.format("info." + NaturesAura.MOD_ID + ".aura_in_area");
|
var text = I18n.get("info." + NaturesAura.MOD_ID + ".aura_in_area");
|
||||||
float textScale = 0.75F;
|
var textScale = 0.75F;
|
||||||
|
|
||||||
int startX = conf % 2 == 0 ? 3 : res.getScaledWidth() - 3 - 6;
|
var startX = conf % 2 == 0 ? 3 : res.getGuiScaledWidth() - 3 - 6;
|
||||||
int startY = conf < 2 ? 10 : (!heldOcular.isEmpty() && (totalPercentage > 1F || totalPercentage < 0) ? -26 : 0) + res.getScaledHeight() - 60;
|
var startY = conf < 2 ? 10 : (!heldOcular.isEmpty() && (totalPercentage > 1F || totalPercentage < 0) ? -26 : 0) + res.getGuiScaledHeight() - 60;
|
||||||
float plusOffX = conf % 2 == 0 ? 7 : -1 - 6;
|
float plusOffX = conf % 2 == 0 ? 7 : -1 - 6;
|
||||||
float textX = conf % 2 == 0 ? 3 : res.getScaledWidth() - 3 - mc.fontRenderer.getStringWidth(text) * textScale;
|
var textX = conf % 2 == 0 ? 3 : res.getGuiScaledWidth() - 3 - mc.font.width(text) * textScale;
|
||||||
float textY = conf < 2 ? 3 : res.getScaledHeight() - 3 - 6;
|
float textY = conf < 2 ? 3 : res.getGuiScaledHeight() - 3 - 6;
|
||||||
|
|
||||||
int tHeight = Mth.ceil(Mth.clamp(totalPercentage, 0F, 1F) * 50);
|
var tHeight = Mth.ceil(Mth.clamp(totalPercentage, 0F, 1F) * 50);
|
||||||
int y = !heldOcular.isEmpty() && totalPercentage > 1F ? startY + 26 : startY;
|
var y = !heldOcular.isEmpty() && totalPercentage > 1F ? startY + 26 : startY;
|
||||||
if (tHeight < 50)
|
if (tHeight < 50)
|
||||||
AbstractGui.blit(stack, startX, y, 6, 12, 6, 50 - tHeight, 256, 256);
|
Screen.blit(stack, startX, y, 6, 12, 6, 50 - tHeight, 256, 256);
|
||||||
if (tHeight > 0)
|
if (tHeight > 0)
|
||||||
AbstractGui.blit(stack, startX, y + 50 - tHeight, 0, 12 + 50 - tHeight, 6, tHeight, 256, 256);
|
Screen.blit(stack, startX, y + 50 - tHeight, 0, 12 + 50 - tHeight, 6, tHeight, 256, 256);
|
||||||
|
|
||||||
if (!heldOcular.isEmpty()) {
|
if (!heldOcular.isEmpty()) {
|
||||||
int topHeight = Mth.ceil(Mth.clamp((totalPercentage - 1F) * 2F, 0F, 1F) * 25);
|
var topHeight = Mth.ceil(Mth.clamp((totalPercentage - 1F) * 2F, 0F, 1F) * 25);
|
||||||
if (topHeight > 0) {
|
if (topHeight > 0) {
|
||||||
if (topHeight < 25)
|
if (topHeight < 25)
|
||||||
AbstractGui.blit(stack, startX, startY, 18, 12, 6, 25 - topHeight, 256, 256);
|
Screen.blit(stack, startX, startY, 18, 12, 6, 25 - topHeight, 256, 256);
|
||||||
AbstractGui.blit(stack, startX, startY + 25 - topHeight, 12, 12 + 25 - topHeight, 6, topHeight, 256, 256);
|
Screen.blit(stack, startX, startY + 25 - topHeight, 12, 12 + 25 - topHeight, 6, topHeight, 256, 256);
|
||||||
}
|
}
|
||||||
int bottomHeight = Mth.floor(Mth.clamp((totalPercentage + 1F) * 2F - 1F, 0F, 1F) * 25);
|
var bottomHeight = Mth.floor(Mth.clamp((totalPercentage + 1F) * 2F - 1F, 0F, 1F) * 25);
|
||||||
if (bottomHeight < 25) {
|
if (bottomHeight < 25) {
|
||||||
AbstractGui.blit(stack, startX, startY + 51, 18, 12, 6, 25 - bottomHeight, 256, 256);
|
Screen.blit(stack, startX, startY + 51, 18, 12, 6, 25 - bottomHeight, 256, 256);
|
||||||
if (bottomHeight > 0)
|
if (bottomHeight > 0)
|
||||||
AbstractGui.blit(stack, startX, startY + 51 + 25 - bottomHeight, 12, 12 + 25 - bottomHeight, 6, bottomHeight, 256, 256);
|
Screen.blit(stack, startX, startY + 51 + 25 - bottomHeight, 12, 12 + 25 - bottomHeight, 6, bottomHeight, 256, 256);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (totalPercentage > (heldOcular.isEmpty() ? 1F : 1.5F))
|
if (totalPercentage > (heldOcular.isEmpty() ? 1F : 1.5F))
|
||||||
mc.fontRenderer.drawStringWithShadow(stack, "+", startX + plusOffX, startY - 0.5F, color);
|
mc.font.drawShadow(stack, "+", startX + plusOffX, startY - 0.5F, color);
|
||||||
if (totalPercentage < (heldOcular.isEmpty() ? 0F : -0.5F))
|
if (totalPercentage < (heldOcular.isEmpty() ? 0F : -0.5F))
|
||||||
mc.fontRenderer.drawStringWithShadow(stack, "-", startX + plusOffX, startY - 0.5F + (heldOcular.isEmpty() ? 44 : 70), color);
|
mc.font.drawShadow(stack, "-", startX + plusOffX, startY - 0.5F + (heldOcular.isEmpty() ? 44 : 70), color);
|
||||||
|
|
||||||
RenderSystem.pushMatrix();
|
stack.pushPose();
|
||||||
RenderSystem.scalef(textScale, textScale, textScale);
|
stack.scale(textScale, textScale, textScale);
|
||||||
mc.fontRenderer.drawStringWithShadow(stack, text, textX / textScale, textY / textScale, color);
|
mc.font.drawShadow(stack, text, textX / textScale, textY / textScale, color);
|
||||||
RenderSystem.popMatrix();
|
stack.popPose();
|
||||||
|
|
||||||
if (!heldOcular.isEmpty()) {
|
if (!heldOcular.isEmpty()) {
|
||||||
float scale = 0.75F;
|
var scale = 0.75F;
|
||||||
RenderSystem.pushMatrix();
|
stack.pushPose();
|
||||||
RenderSystem.scalef(scale, scale, scale);
|
stack.scale(scale, scale, scale);
|
||||||
int stackX = conf % 2 == 0 ? 10 : res.getScaledWidth() - 22;
|
var stackX = conf % 2 == 0 ? 10 : res.getGuiScaledWidth() - 22;
|
||||||
int stackY = conf < 2 ? 15 : res.getScaledHeight() - 55;
|
var stackY = conf < 2 ? 15 : res.getGuiScaledHeight() - 55;
|
||||||
for (Tuple<ItemStack, Boolean> effect : SHOWING_EFFECTS.values()) {
|
for (var effect : SHOWING_EFFECTS.values()) {
|
||||||
int theX = (int) (stackX / scale);
|
var theX = (int) (stackX / scale);
|
||||||
int theY = (int) (stackY / scale);
|
var theY = (int) (stackY / scale);
|
||||||
ItemStack itemStack = effect.getA();
|
var itemStack = effect.getA();
|
||||||
Helper.renderItemInGui(itemStack, theX, theY, 1F);
|
Helper.renderItemInGui(itemStack, theX, theY, 1F);
|
||||||
if (effect.getB()) {
|
if (effect.getB()) {
|
||||||
GlStateManager.disableDepthTest();
|
RenderSystem.disableDepthTest();
|
||||||
mc.getTextureManager().bindTexture(OVERLAYS);
|
RenderSystem.setShaderTexture(0, OVERLAYS);
|
||||||
AbstractGui.blit(stack, theX, theY, 240, 0, 16, 16, 256, 256);
|
Screen.blit(stack, theX, theY, 240, 0, 16, 16, 256, 256);
|
||||||
GlStateManager.enableDepthTest();
|
RenderSystem.enableDepthTest();
|
||||||
}
|
}
|
||||||
stackY += 8;
|
stackY += 8;
|
||||||
}
|
}
|
||||||
RenderSystem.popMatrix();
|
stack.popPose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mc.objectMouseOver instanceof BlockRayTraceResult) {
|
if (mc.hitResult instanceof BlockHitResult blockHitResult) {
|
||||||
BlockPos pos = ((BlockRayTraceResult) mc.objectMouseOver).getPos();
|
var pos = blockHitResult.getBlockPos();
|
||||||
if (pos != null) {
|
if (pos != null) {
|
||||||
BlockEntity tile = mc.level.getBlockEntity(pos);
|
var tile = mc.level.getBlockEntity(pos);
|
||||||
IAuraContainer container;
|
IAuraContainer container;
|
||||||
int x = res.getScaledWidth() / 2;
|
var x = res.getGuiScaledWidth() / 2;
|
||||||
int y = res.getScaledHeight() / 2;
|
var y = res.getGuiScaledHeight() / 2;
|
||||||
if (tile != null && (container = tile.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null)) != null) {
|
if (tile != null && (container = tile.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null)) != null) {
|
||||||
BlockState state = mc.level.getBlockState(pos);
|
var state = mc.level.getBlockState(pos);
|
||||||
ItemStack blockStack = state.getBlock().getPickBlock(state, mc.objectMouseOver, mc.level, pos, mc.player);
|
var blockStack = state.getBlock().getCloneItemStack(state, blockHitResult, mc.level, pos, mc.player);
|
||||||
this.drawContainerInfo(stack, container.getStoredAura(), container.getMaxAura(), container.getAuraColor(),
|
this.drawContainerInfo(stack, container.getStoredAura(), container.getMaxAura(), container.getAuraColor(),
|
||||||
mc, res, 35, blockStack.getDisplayName().getString(), null);
|
mc, res, 35, blockStack.getDisplayName().getString(), null);
|
||||||
|
|
||||||
if (tile instanceof BlockEntityNatureAltar) {
|
if (tile instanceof BlockEntityNatureAltar) {
|
||||||
ItemStack tileStack = ((BlockEntityNatureAltar) tile).getItemHandler().getStackInSlot(0);
|
var tileStack = ((BlockEntityNatureAltar) tile).getItemHandler().getStackInSlot(0);
|
||||||
if (!tileStack.isEmpty()) {
|
if (!tileStack.isEmpty()) {
|
||||||
IAuraContainer stackCont = tileStack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
|
var stackCont = tileStack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
|
||||||
if (stackCont != null) {
|
if (stackCont != null) {
|
||||||
this.drawContainerInfo(stack, stackCont.getStoredAura(), stackCont.getMaxAura(), stackCont.getAuraColor(),
|
this.drawContainerInfo(stack, stackCont.getStoredAura(), stackCont.getMaxAura(), stackCont.getAuraColor(),
|
||||||
mc, res, 55, tileStack.getDisplayName().getString(), null);
|
mc, res, 55, tileStack.getDisplayName().getString(), null);
|
||||||
|
@ -370,50 +383,48 @@ public class ClientEvents {
|
||||||
} else if (tile instanceof BlockEntityRFConverter) {
|
} else if (tile instanceof BlockEntityRFConverter) {
|
||||||
EnergyStorage storage = ((BlockEntityRFConverter) tile).storage;
|
EnergyStorage storage = ((BlockEntityRFConverter) tile).storage;
|
||||||
this.drawContainerInfo(stack, storage.getEnergyStored(), storage.getMaxEnergyStored(), 0xcc4916,
|
this.drawContainerInfo(stack, storage.getEnergyStored(), storage.getMaxEnergyStored(), 0xcc4916,
|
||||||
mc, res, 35, I18n.format("block.naturesaura.rf_converter"),
|
mc, res, 35, I18n.get("block.naturesaura.rf_converter"),
|
||||||
storage.getEnergyStored() + " / " + storage.getMaxEnergyStored() + " RF");
|
storage.getEnergyStored() + " / " + storage.getMaxEnergyStored() + " RF");
|
||||||
} else if (tile instanceof BlockEntityGratedChute) {
|
} else if (tile instanceof BlockEntityGratedChute chute) {
|
||||||
BlockEntityGratedChute chute = (BlockEntityGratedChute) tile;
|
var itemStack = chute.getItemHandler().getStackInSlot(0);
|
||||||
ItemStack itemStack = chute.getItemHandler().getStackInSlot(0);
|
|
||||||
|
|
||||||
if (itemStack.isEmpty())
|
if (itemStack.isEmpty()) {
|
||||||
mc.fontRenderer.drawStringWithShadow(stack,
|
mc.font.drawShadow(stack,
|
||||||
TextFormatting.GRAY.toString() + TextFormatting.ITALIC + I18n.format("info.naturesaura.empty"),
|
ChatFormatting.GRAY.toString() + ChatFormatting.ITALIC + I18n.get("info.naturesaura.empty"),
|
||||||
x + 5, y - 11, 0xFFFFFF);
|
x + 5, y - 11, 0xFFFFFF);
|
||||||
else
|
} else {
|
||||||
Helper.renderItemInGui(itemStack, x + 2, y - 18, 1F);
|
Helper.renderItemInGui(itemStack, x + 2, y - 18, 1F);
|
||||||
|
}
|
||||||
|
|
||||||
Helper.renderItemInGui(ITEM_FRAME, x - 24, y - 24, 1F);
|
Helper.renderItemInGui(ITEM_FRAME, x - 24, y - 24, 1F);
|
||||||
mc.getTextureManager().bindTexture(OVERLAYS);
|
RenderSystem.setShaderTexture(0, OVERLAYS);
|
||||||
int u = chute.isBlacklist ? 240 : 224;
|
var u = chute.isBlacklist ? 240 : 224;
|
||||||
GlStateManager.disableDepthTest();
|
RenderSystem.disableDepthTest();
|
||||||
AbstractGui.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256);
|
Screen.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256);
|
||||||
GlStateManager.enableDepthTest();
|
RenderSystem.enableDepthTest();
|
||||||
} else if (tile instanceof BlockEntityItemDistributor) {
|
} else if (tile instanceof BlockEntityItemDistributor distributor) {
|
||||||
BlockEntityItemDistributor distributor = (BlockEntityItemDistributor) tile;
|
|
||||||
Helper.renderItemInGui(DISPENSER, x - 24, y - 24, 1F);
|
Helper.renderItemInGui(DISPENSER, x - 24, y - 24, 1F);
|
||||||
mc.getTextureManager().bindTexture(OVERLAYS);
|
RenderSystem.setShaderTexture(0, OVERLAYS);
|
||||||
int u = !distributor.isRandomMode ? 240 : 224;
|
var u = !distributor.isRandomMode ? 240 : 224;
|
||||||
GlStateManager.disableDepthTest();
|
RenderSystem.disableDepthTest();
|
||||||
AbstractGui.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256);
|
Screen.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256);
|
||||||
GlStateManager.enableDepthTest();
|
RenderSystem.enableDepthTest();
|
||||||
} else if (tile instanceof BlockEntityAuraTimer) {
|
} else if (tile instanceof BlockEntityAuraTimer timer) {
|
||||||
BlockEntityAuraTimer timer = (BlockEntityAuraTimer) tile;
|
var itemStack = timer.getItemHandler().getStackInSlot(0);
|
||||||
ItemStack itemStack = timer.getItemHandler().getStackInSlot(0);
|
|
||||||
if (!itemStack.isEmpty()) {
|
if (!itemStack.isEmpty()) {
|
||||||
Helper.renderItemInGui(itemStack, x - 20, y - 20, 1);
|
Helper.renderItemInGui(itemStack, x - 20, y - 20, 1);
|
||||||
mc.fontRenderer.drawStringWithShadow(stack, TextFormatting.GRAY + this.createTimeString(timer.getTotalTime()), x + 5, y - 11, 0xFFFFFF);
|
mc.font.drawShadow(stack, ChatFormatting.GRAY + this.createTimeString(timer.getTotalTime()), x + 5, y - 11, 0xFFFFFF);
|
||||||
mc.fontRenderer.drawStringWithShadow(stack, TextFormatting.GRAY + I18n.format("info.naturesaura.remaining", this.createTimeString(timer.getTimeLeft())), x + 5, y + 3, 0xFFFFFF);
|
mc.font.drawShadow(stack, ChatFormatting.GRAY + I18n.get("info.naturesaura.remaining", this.createTimeString(timer.getTimeLeft())), x + 5, y + 3, 0xFFFFFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderSystem.color4f(1F, 1F, 1F, 1);
|
RenderSystem.setShaderColor(1F, 1F, 1F, 1);
|
||||||
RenderSystem.popMatrix();
|
stack.popPose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createTimeString(int totalTicks) {
|
private String createTimeString(int totalTicks) {
|
||||||
|
@ -424,22 +435,22 @@ public class ClientEvents {
|
||||||
return String.format("%02d:%02d:%02d.%02d", hours, minutes, seconds, ticks);
|
return String.format("%02d:%02d:%02d.%02d", hours, minutes, seconds, ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* private void drawContainerInfo(PoseStack stack, int stored, int max, int color, Minecraft mc, MainWindow res, int yOffset, String name, String textBelow) {
|
private void drawContainerInfo(PoseStack stack, int stored, int max, int color, Minecraft mc, Window res, int yOffset, String name, String textBelow) {
|
||||||
RenderSystem.color3f((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F);
|
RenderSystem.setShaderColor((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 1);
|
||||||
|
|
||||||
int x = res.getScaledWidth() / 2 - 40;
|
var x = res.getGuiScaledWidth() / 2 - 40;
|
||||||
int y = res.getScaledHeight() / 2 + yOffset;
|
var y = res.getGuiScaledHeight() / 2 + yOffset;
|
||||||
int width = Mth.ceil(stored / (float) max * 80);
|
var width = Mth.ceil(stored / (float) max * 80);
|
||||||
|
|
||||||
mc.getTextureManager().bindTexture(OVERLAYS);
|
RenderSystem.setShaderTexture(0, OVERLAYS);
|
||||||
if (width < 80)
|
if (width < 80)
|
||||||
AbstractGui.blit(stack, x + width, y, width, 0, 80 - width, 6, 256, 256);
|
Screen.blit(stack, x + width, y, width, 0, 80 - width, 6, 256, 256);
|
||||||
if (width > 0)
|
if (width > 0)
|
||||||
AbstractGui.blit(stack, x, y, 0, 6, width, 6, 256, 256);
|
Screen.blit(stack, x, y, 0, 6, width, 6, 256, 256);
|
||||||
|
|
||||||
mc.fontRenderer.drawStringWithShadow(stack, name, x + 40 - mc.fontRenderer.getStringWidth(name) / 2F, y - 9, color);
|
mc.font.drawShadow(stack, name, x + 40 - mc.font.width(name) / 2F, y - 9, color);
|
||||||
|
|
||||||
if (textBelow != null)
|
if (textBelow != null)
|
||||||
mc.fontRenderer.drawStringWithShadow(stack, textBelow, x + 40 - mc.fontRenderer.getStringWidth(textBelow) / 2F, y + 7, color);
|
mc.font.drawShadow(stack, textBelow, x + 40 - mc.font.width(textBelow) / 2F, y + 7, color);
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue