Skip to content

Commit

Permalink
fixed some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Tfarcenim committed Apr 7, 2019
1 parent 7e53ad9 commit e04502d
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 12 deletions.
2 changes: 1 addition & 1 deletion 1.12/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.


version = "0.1.11a"
version = "0.1.12"
group = "com.tfar.classicbar" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "classicbar"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void renderArmorBar(RenderGameOverlayEvent.Pre event) {
double armor = calculateArmorValue();
if (armor < 1)return;
boolean warning = false;
for (ItemStack stack : player.getEquipmentAndArmor()){
for (ItemStack stack : player.inventory.armorInventory){
int max = stack.getMaxDamage();
int current = stack.getItemDamage();
int percentage = 100;
Expand All @@ -55,7 +55,7 @@ public void renderArmorBar(RenderGameOverlayEvent.Pre event) {
else alpha-=.05;
if (alpha<0)increase=true;
else if(alpha>1)increase=false;
}
}else alpha=1;
int absorb = MathHelper.ceil(player.getAbsorptionAmount());
if (general.overlays.swap)absorb=0;
int xStart = scaledWidth / 2 - 91;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public void renderHealthBarMount(RenderGameOverlayEvent.Pre event) {
}

this.mountHealth = mountHealth;
double j = lasMountHealth;
IAttributeInstance maxHealthAttribute = mount.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH);
int xStart = scaledWidth / 2 + 10;
int yStart = scaledHeight - 39;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,13 @@ public void renderHungerBar(RenderGameOverlayEvent.Pre event) {


//Draw Potential hunger
double hungerWidth = Math.min(20-hunger,hungerOverlay);
f = xStart - getWidth(hungerWidth+hunger,20) + 80;
double hungerWidth = Math.min(20-hunger,hungerOverlay);
//don't render the bar at all if hunger is full
if (hunger <20) {
f = xStart - getWidth(hungerWidth+hunger,20) + 80;
cU.color2Gla(cU.hex2Color(colors.hungerBarColor),alpha);
drawPotential(f, yStart+1, 1, 10, getWidth(hungerWidth,20), 7,general.style);
drawPotential(f, yStart + 1, 1, 10, getWidth(hungerWidth, 20)+1, 7, general.style);
}

//Draw Potential saturation
if (general.overlays.hunger.showSaturationBar){
Expand All @@ -107,7 +110,7 @@ public void renderHungerBar(RenderGameOverlayEvent.Pre event) {
//offset used to decide where to place the bar
f = xStart - getWidth(saturationWidth+currentSat,20) + 80;
cU.color2Gla(cU.hex2Color(colors.saturationBarColor),alpha);
drawPotential(f, yStart+1, 1, 10, getWidth(saturationWidth,20), 7,general.style);
drawPotential(f, yStart+1, 1, 10, getWidth(saturationWidth,20)+1, 7,general.style);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
package tfar.classicbar.overlays.modoverlays;

import lumien.randomthings.item.ItemLavaCharm;
import lumien.randomthings.item.ItemLavaWader;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.client.GuiIngameForge;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.common.config.Config;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import static tfar.classicbar.ColorUtilities.cU;
import static tfar.classicbar.ModUtils.*;
import static tfar.classicbar.config.ModConfig.general;
import static tfar.classicbar.config.ModConfig.numbers;

/*
Class handles the drawing of the lava charm
*/
public class LavaCharmNoBaublesRenderer {
private final Minecraft mc = Minecraft.getMinecraft();

@Config.Name("Random Things Options")
public static ConfigRandomThings configRandomThings = new ConfigRandomThings();

public static class ConfigRandomThings {
@Config.Name("Lava Bar Color")
public String lavaBarColor = "#FF8000";
}

public static final ResourceLocation ICON_LAVA = new ResourceLocation("randomthings", "textures/gui/lavacharmbar.png");

public LavaCharmNoBaublesRenderer() {
}

@SubscribeEvent(priority = EventPriority.LOW)
public void renderLavaBar(RenderGameOverlayEvent.Pre event) {

Entity renderViewEnity = this.mc.getRenderViewEntity();
if (event.isCanceled()
|| !(renderViewEnity instanceof EntityPlayer)) return;
EntityPlayer player = (EntityPlayer) mc.getRenderViewEntity();
if (player.capabilities.isCreativeMode)return;

ItemStack stack = getLavaCharm(player);
if (stack == null)return;

int charge;
NBTTagCompound nbt = stack.getTagCompound();
if (nbt == null) {
System.out.println("error");
return;
}
charge = nbt.getInteger("charge");
int scaledWidth = event.getResolution().getScaledWidth();
int scaledHeight = event.getResolution().getScaledHeight();
//Push to avoid lasting changes

int absorb = MathHelper.ceil(player.getAbsorptionAmount());

int xStart = scaledWidth / 2 - 91;
int yStart = scaledHeight - 49;
if (absorb > 0) yStart -= 10;
if (player.getEntityAttribute(SharedMonsterAttributes.ARMOR).getAttributeValue() > 0) yStart -= 10;
mc.profiler.startSection("charge");
//GlStateManager.pushMatrix();
GlStateManager.enableBlend();

//Bind our Custom bar
mc.getTextureManager().bindTexture(ICON_BAR);
//Bar background
GlStateManager.color(1, 1, 1,1);
drawTexturedModalRect(xStart, yStart, 0, 0, 81, 9,general.style,false,true);

//Pass 1, draw bar portion
cU.color2Gl(cU.hex2Color(configRandomThings.lavaBarColor));
//calculate bar color
//draw portion of bar based on charge amount
drawTexturedModalRect(xStart + 1, yStart + 1, 1, 10, getWidth(charge, 200), 7,general.style,true,true);
int i2 = charge;
//draw charge amount
if (numbers.showPercent)i2 /= 3;
int i3 = getStringLength(i2+"");
int i4 = (general.displayIcons) ? 1 : 0;
int c = Integer.decode(configRandomThings.lavaBarColor);
drawStringOnHUD(i2 + "", xStart - 9 * i4 - i3 + leftTextOffset, yStart - 1, c);

mc.getTextureManager().bindTexture(ICON_LAVA);
GlStateManager.color(1, 1, 1, 1);

if (general.displayIcons)
//Draw charge icon
drawTexturedModalRect(xStart - 10, yStart, 1, 1, 9, 9,0,false,true);
//Reset back to normal settings

mc.getTextureManager().bindTexture(ICON_VANILLA);

GuiIngameForge.left_height += 10;
//GlStateManager.disableBlend();
//Revert our state back
//GlStateManager.popMatrix();
mc.profiler.endSection();
}

private ItemStack getLavaCharm(EntityPlayer player) {
ItemStack stack1 = player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
if (isWader(stack1))return stack1;
ItemStack stack2 = player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND);
if (isCharm(stack2))return stack2;
return null;
}
private boolean isCharm(ItemStack stack){
return (stack.getItem() instanceof ItemLavaCharm);
}
private boolean isWader(ItemStack stack){
return (stack.getItem() instanceof ItemLavaWader);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.client.GuiIngameForge;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
Expand All @@ -21,6 +20,7 @@
import static tfar.classicbar.ColorUtilities.cU;
import static tfar.classicbar.ModUtils.*;
import static tfar.classicbar.config.ModConfig.*;
import static tfar.classicbar.overlays.modoverlays.LavaCharmNoBaublesRenderer.ICON_LAVA;

/*
Class handles the drawing of the lava charm
Expand All @@ -37,8 +37,6 @@ public static class ConfigRandomThings {
public String lavaBarColor = "#FF8000";
}

private static final ResourceLocation ICON_LAVA = new ResourceLocation("randomthings", "textures/gui/lavacharmbar.png");

public LavaCharmRenderer() {
}

Expand Down
6 changes: 5 additions & 1 deletion 1.12/src/main/java/tfar/classicbar/proxy/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraftforge.fml.relauncher.Side;
import tfar.classicbar.ClassicBar;
import tfar.classicbar.overlays.*;
import tfar.classicbar.overlays.modoverlays.LavaCharmNoBaublesRenderer;
import tfar.classicbar.overlays.modoverlays.LavaCharmRenderer;
//import tfar.classicbar.overlays.modoverlays.SuperiorShieldRenderer;
import tfar.classicbar.overlays.modoverlays.ThirstBarRenderer;
Expand All @@ -30,8 +31,11 @@ public void postInit(FMLPostInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(new HungerBarRenderer());

//mod renderers
if (Loader.isModLoaded("randomthings"))
if (Loader.isModLoaded("randomthings")) {
if (Loader.isModLoaded("baubles"))
MinecraftForge.EVENT_BUS.register(new LavaCharmRenderer());
else MinecraftForge.EVENT_BUS.register(new LavaCharmNoBaublesRenderer());
}
//if (Loader.isModLoaded("superiorshields"))
// MinecraftForge.EVENT_BUS.register(new SuperiorShieldRenderer());
if (Loader.isModLoaded("toughasnails"))
Expand Down

0 comments on commit e04502d

Please sign in to comment.