-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added potion HUD, disabling inventory shift when you have potion effe…
…cts, and fixed crash when clicking an emoji out of range in the emoji picker
- Loading branch information
1 parent
a2bf534
commit 4680270
Showing
13 changed files
with
293 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#Wed Apr 07 10:57:56 PDT 2021 | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-all.zip | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
src/main/java/com/palight/playerinfo/gui/ingame/widgets/impl/PotionsWidget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package com.palight.playerinfo.gui.ingame.widgets.impl; | ||
|
||
import com.palight.playerinfo.PlayerInfo; | ||
import com.palight.playerinfo.gui.ingame.widgets.GuiIngameWidget; | ||
import com.palight.playerinfo.modules.impl.gui.PotionsMod; | ||
import com.palight.playerinfo.util.MCUtil; | ||
import com.palight.playerinfo.util.NumberUtil; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.ScaledResolution; | ||
import net.minecraft.client.renderer.GlStateManager; | ||
import net.minecraft.client.resources.I18n; | ||
import net.minecraft.potion.Potion; | ||
import net.minecraft.potion.PotionEffect; | ||
import net.minecraft.util.ResourceLocation; | ||
|
||
import java.util.Collection; | ||
import java.util.Iterator; | ||
|
||
public class PotionsWidget extends GuiIngameWidget { | ||
protected static final ResourceLocation inventoryBackground = new ResourceLocation("textures/gui/container/inventory.png"); | ||
|
||
private PotionsMod module; | ||
|
||
public PotionsWidget() { | ||
super(0, -1, 140, 64); | ||
} | ||
|
||
@Override | ||
public void render(Minecraft mc) { | ||
if (module == null) { | ||
module = (PotionsMod) getModule(); | ||
} | ||
if (this.getPosition().getY() == -1) { | ||
ScaledResolution res = new ScaledResolution(mc); | ||
this.getPosition().setY((res.getScaledHeight() - this.height) / 2); | ||
} | ||
Collection<PotionEffect> collection = mc.thePlayer.getActivePotionEffects(); | ||
|
||
if (!collection.isEmpty()) { | ||
int itemHeight = 33; | ||
if (collection.size() > 5) { | ||
itemHeight = 132 / (collection.size() - 1); | ||
} | ||
|
||
if (module.renderTransparentBackground) { | ||
this.height = collection.size() * itemHeight; | ||
super.render(mc); | ||
} | ||
|
||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); | ||
GlStateManager.disableLighting(); | ||
|
||
Iterator potionEffectIterator = mc.thePlayer.getActivePotionEffects().iterator(); | ||
|
||
int yPosition = this.getPosition().getY(); | ||
int xPosition = this.getPosition().getX(); | ||
|
||
while(potionEffectIterator.hasNext()) { | ||
PotionEffect effect = (PotionEffect)potionEffectIterator.next(); | ||
Potion potion = Potion.potionTypes[effect.getPotionID()]; | ||
|
||
if (potion.shouldRender(effect)) { | ||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); | ||
mc.getTextureManager().bindTexture(inventoryBackground); | ||
|
||
if (module.renderBackground) { | ||
this.drawTexturedModalRect(xPosition, yPosition, 0, 166, 140, 32); | ||
} | ||
|
||
if (potion.hasStatusIcon()) { | ||
int iconIndex = potion.getStatusIconIndex(); | ||
this.drawTexturedModalRect(xPosition + 6, yPosition + 7, iconIndex % 8 * 18, 198 + iconIndex / 8 * 18, 18, 18); | ||
} | ||
|
||
potion.renderInventoryEffect(xPosition, yPosition, effect, mc); | ||
|
||
if (potion.shouldRenderInvText(effect)) { | ||
String formattedName = I18n.format(potion.getName()); | ||
if (module.renderLevelAsNumber) { | ||
formattedName += " " + (effect.getAmplifier() + 1); | ||
} else { | ||
formattedName += " " + NumberUtil.integerToRoman(effect.getAmplifier() + 1); | ||
} | ||
|
||
PlayerInfo.instance.fontRendererObj.drawStringWithShadow(formattedName, (float) (xPosition + 10 + 18), (float) (yPosition + 6), 16777215); | ||
String durationString = Potion.getDurationString(effect); | ||
PlayerInfo.instance.fontRendererObj.drawStringWithShadow(durationString, (float) (xPosition + 10 + 18), (float) (yPosition + 6 + 10), 8355711); | ||
} | ||
|
||
yPosition += itemHeight; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/main/java/com/palight/playerinfo/gui/screens/impl/options/modules/gui/PotionsGui.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.palight.playerinfo.gui.screens.impl.options.modules.gui; | ||
|
||
import com.palight.playerinfo.PlayerInfo; | ||
import com.palight.playerinfo.gui.screens.CustomGuiScreenScrollable; | ||
import com.palight.playerinfo.gui.widgets.GuiCustomWidget; | ||
import com.palight.playerinfo.gui.widgets.impl.GuiCheckBox; | ||
import com.palight.playerinfo.modules.impl.gui.CustomMainMenuMod; | ||
import com.palight.playerinfo.modules.impl.gui.PotionsMod; | ||
import com.palight.playerinfo.options.ModConfiguration; | ||
|
||
import java.util.Arrays; | ||
|
||
public class PotionsGui extends CustomGuiScreenScrollable { | ||
private int buttonX; | ||
private int buttonY; | ||
|
||
private GuiCheckBox renderBackground; | ||
private GuiCheckBox renderLevelAsNumber; | ||
private GuiCheckBox renderTransparentBackground; | ||
|
||
private PotionsMod module; | ||
|
||
public PotionsGui() { | ||
super("screen.potions"); | ||
} | ||
|
||
@Override | ||
public void initGui() { | ||
super.initGui(); | ||
|
||
if (module == null) { | ||
module = (PotionsMod) PlayerInfo.getModules().get("potions"); | ||
} | ||
|
||
buttonX = guiX + 32; | ||
buttonY = guiY + 32; | ||
|
||
renderBackground = new GuiCheckBox(0, buttonX, buttonY, "Show background", module.renderBackground); | ||
renderLevelAsNumber = new GuiCheckBox(1, buttonX, buttonY + 32, "Show level as number", module.renderLevelAsNumber); | ||
renderTransparentBackground = new GuiCheckBox(2, buttonX, buttonY + 64, "Show transparent background", module.renderTransparentBackground); | ||
|
||
this.guiElements.addAll(Arrays.asList( | ||
this.renderBackground, | ||
this.renderLevelAsNumber, | ||
this.renderTransparentBackground | ||
)); | ||
} | ||
|
||
@Override | ||
protected void widgetClicked(GuiCustomWidget widget) { | ||
if (module == null) { | ||
module = (PotionsMod) PlayerInfo.getModules().get("potions"); | ||
} | ||
|
||
super.widgetClicked(widget); | ||
|
||
if (widget.id == renderBackground.id) { | ||
module.renderBackground = renderBackground.checked; | ||
} else if (widget.id == renderLevelAsNumber.id) { | ||
module.renderLevelAsNumber = renderLevelAsNumber.checked; | ||
} else if (widget.id == renderTransparentBackground.id) { | ||
module.renderTransparentBackground = renderTransparentBackground.checked; | ||
} | ||
|
||
ModConfiguration.syncFromGUI(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/main/java/com/palight/playerinfo/mixin/client/gui/MixinInventoryEffectRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.palight.playerinfo.mixin.client.gui; | ||
|
||
import com.palight.playerinfo.PlayerInfo; | ||
import com.palight.playerinfo.modules.impl.gui.DisplayTweaksMod; | ||
import net.minecraft.client.gui.inventory.GuiContainer; | ||
import net.minecraft.client.renderer.InventoryEffectRenderer; | ||
import net.minecraft.inventory.Container; | ||
import net.minecraft.potion.Potion; | ||
import net.minecraft.potion.PotionEffect; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
|
||
@Mixin(InventoryEffectRenderer.class) | ||
public class MixinInventoryEffectRenderer extends GuiContainer { | ||
@Shadow private boolean hasActivePotionEffects; | ||
|
||
private DisplayTweaksMod module; | ||
|
||
public MixinInventoryEffectRenderer(Container p_i1072_1_) { | ||
super(p_i1072_1_); | ||
} | ||
|
||
/** | ||
* @reason Disable inventory GUI shifting when the player has potion effects | ||
* @author palight | ||
*/ | ||
@Overwrite | ||
protected void updateActivePotionEffects() { | ||
if (module == null) { | ||
module = (DisplayTweaksMod) PlayerInfo.getModules().get("displayTweaks"); | ||
} | ||
boolean hasVisibleEffect = false; | ||
|
||
for (PotionEffect effect : this.mc.thePlayer.getActivePotionEffects()) { | ||
Potion potion = Potion.potionTypes[effect.getPotionID()]; | ||
if (potion.shouldRender(effect)) { | ||
hasVisibleEffect = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!this.mc.thePlayer.getActivePotionEffects().isEmpty() && hasVisibleEffect) { | ||
if (module.disableInventoryShift) { | ||
this.guiLeft = (this.width - this.xSize) / 2; | ||
} else { | ||
this.guiLeft = 160 + (this.width - this.xSize - 200) / 2; | ||
} | ||
this.hasActivePotionEffects = true; | ||
} else { | ||
this.guiLeft = (this.width - this.xSize) / 2; | ||
this.hasActivePotionEffects = false; | ||
} | ||
|
||
} | ||
|
||
@Override | ||
protected void drawGuiContainerBackgroundLayer(float v, int i, int i1) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/java/com/palight/playerinfo/modules/impl/gui/PotionsMod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.palight.playerinfo.modules.impl.gui; | ||
|
||
import com.palight.playerinfo.gui.ingame.widgets.impl.PotionsWidget; | ||
import com.palight.playerinfo.gui.screens.impl.options.modules.gui.PotionsGui; | ||
import com.palight.playerinfo.modules.Module; | ||
import com.palight.playerinfo.options.ConfigOption; | ||
|
||
public class PotionsMod extends Module { | ||
@ConfigOption | ||
public boolean renderBackground = true; | ||
@ConfigOption | ||
public boolean renderLevelAsNumber = false; | ||
@ConfigOption | ||
public boolean renderTransparentBackground = false; | ||
|
||
public PotionsMod() { | ||
super("potions", "Potions", "Displays active potion effects.", ModuleType.GUI, new PotionsGui(), new PotionsWidget()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters