Skip to content
This repository has been archived by the owner on Jun 23, 2024. It is now read-only.

Commit

Permalink
changes suggested by mysticdrew; render potions on different event th…
Browse files Browse the repository at this point in the history
…an everything else
  • Loading branch information
gbl committed Sep 28, 2021
1 parent 82b356d commit 40e4dcc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
repositories {
maven { url = "http://files.minecraftforge.net/maven" }
maven { url = "https://files.minecraftforge.net/maven" }
jcenter()
mavenCentral()
}
Expand All @@ -18,7 +18,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = "1.16.4-forge35.0.7-1.10"
version = "1.16.4-forge35.0.7-1.10.1"
group = "de.guntram.mcmod.DurabilityViewer" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "durabilityviewer"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,10 @@ public void onRender(final RenderGameOverlayEvent.Post event) {
glfwSetWindowTitle(minecraft.getMainWindow().getHandle(), newTitle);
}


if (!visible
|| event.isCanceled()
// || minecraft.player.abilities.isCreativeMode
|| event.getType()!=RenderGameOverlayEvent.ElementType.POTION_ICONS)
|| event.getType()!=RenderGameOverlayEvent.ElementType.HOTBAR)
return;

ClientPlayerEntity effectivePlayer = (ClientPlayerEntity) minecraft.player;
Expand Down Expand Up @@ -228,15 +227,43 @@ public void onRender(final RenderGameOverlayEvent.Post event) {
}

RenderHelper.disableStandardItemLighting();
}

private void renderItemBreakingOverlay(MatrixStack matrices, ItemStack itemStack, long timeDelta) {
MainWindow mainWindow=Minecraft.getInstance().getMainWindow();
float alpha = 1.0f-((float)timeDelta/1000.0f);
float xWarn = mainWindow.getScaledWidth()/2;
float yWarn = mainWindow.getScaledHeight()/2;
float scale = 5.0f;

AbstractGui.fill(matrices, 0, 0, mainWindow.getScaledWidth(), mainWindow.getScaledHeight(),
0xff0000+ ((int)(alpha*128)<<24));

RenderSystem.pushMatrix();
RenderSystem.scalef(scale, scale, scale);
itemRenderer.renderItemAndEffectIntoGUI(itemStack, (int)((xWarn)/scale-8), (int)((yWarn)/scale-8));
// System.out.println("rendering at "+xWarn+"/"+yWarn+", scale="+scale+", alpha="+alpha);
RenderSystem.popMatrix();
GlStateManager.color4f(1.0f, 1.0f, 1.0f, 1.0f);
}

@SubscribeEvent(priority = EventPriority.NORMAL)
public void afterRenderStatusEffects(final RenderGameOverlayEvent.Post event) {
if (!visible
|| event.isCanceled()
// || minecraft.player.abilities.isCreativeMode
|| event.getType() != RenderGameOverlayEvent.ElementType.POTION_ICONS)
return;
if (ConfigurationHandler.showEffectDuration()) {
// a lot of this is copied from net/minecraft/client/gui/GuiIngame.java
MainWindow mainWindow=Minecraft.getInstance().getMainWindow();
Collection<EffectInstance> collection = minecraft.player.getActivePotionEffects();
int posGood=0, posBad=0;
for (EffectInstance potioneffect : Ordering.natural().reverse().sortedCopy(collection)) {
if (potioneffect.doesShowParticles()) {
Effect potion = potioneffect.getPotion();
xpos=mainWindow.getScaledWidth();
int xpos=mainWindow.getScaledWidth();
int ypos;
if (potion.isBeneficial()) {
posGood+=25; xpos-=posGood; ypos=15;
} else {
Expand All @@ -252,24 +279,6 @@ public void onRender(final RenderGameOverlayEvent.Post event) {
}
}
}
}

private void renderItemBreakingOverlay(MatrixStack matrices, ItemStack itemStack, long timeDelta) {
MainWindow mainWindow=Minecraft.getInstance().getMainWindow();
float alpha = 1.0f-((float)timeDelta/1000.0f);
float xWarn = mainWindow.getScaledWidth()/2;
float yWarn = mainWindow.getScaledHeight()/2;
float scale = 5.0f;

AbstractGui.fill(matrices, 0, 0, mainWindow.getScaledWidth(), mainWindow.getScaledHeight(),
0xff0000+ ((int)(alpha*128)<<24));

RenderSystem.pushMatrix();
RenderSystem.scalef(scale, scale, scale);
itemRenderer.renderItemAndEffectIntoGUI(itemStack, (int)((xWarn)/scale-8), (int)((yWarn)/scale-8));
// System.out.println("rendering at "+xWarn+"/"+yWarn+", scale="+scale+", alpha="+alpha);
RenderSystem.popMatrix();
GlStateManager.color4f(1.0f, 1.0f, 1.0f, 1.0f);
}

private RenderSize renderItems(MatrixStack stack, int xpos, int ypos, boolean reallyDraw, RenderPos numberPos, int maxWidth, ItemIndicator... items) {
Expand Down

0 comments on commit 40e4dcc

Please sign in to comment.