mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-27 15:33:10 +00:00
Add initial break progress bar
This commit is contained in:
1 parent
fae07b5ca2
commit
5bcb9174fa
10 files changed
+62
-2
No files matched your search
+1
-1
@@ -39,7 +39,7 @@ apiPackage = api
|
||||
|
||||
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
|
||||
# Example value: mymodid_at.cfg
|
||||
accessTransformersFile =
|
||||
accessTransformersFile = Waila_at.cfg
|
||||
|
||||
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
|
||||
usesMixins = false
|
||||
|
||||
@@ -49,4 +49,6 @@ public interface IWailaDataAccessor {
|
||||
ForgeDirection getSide();
|
||||
|
||||
ItemStack getStack();
|
||||
|
||||
float getBlockBreakDamage();
|
||||
}
|
||||
@@ -150,6 +150,8 @@ public class ConfigHandler implements IWailaConfigHandler {
|
||||
OverlayConfig.posY = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSY, 100).getInt();
|
||||
|
||||
OverlayConfig.alpha = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_ALPHA, 80).getInt();
|
||||
OverlayConfig.breakprogress = config
|
||||
.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_BREAK_PROGRESS, true).getBoolean();
|
||||
OverlayConfig.bgcolor = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_BGCOLOR, 0x100010)
|
||||
.getInt();
|
||||
OverlayConfig.gradient1 = config.get(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_GRADIENT1, 0x5000ff)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mcp.mobius.waila.api.impl;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -21,6 +22,7 @@ import mcp.mobius.waila.utils.NBTUtil;
|
||||
|
||||
public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAccessor, IWailaEntityAccessor {
|
||||
|
||||
private static final Minecraft MC = Minecraft.getMinecraft();
|
||||
public World world;
|
||||
public EntityPlayer player;
|
||||
public MovingObjectPosition mop;
|
||||
@@ -37,6 +39,7 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
|
||||
public ItemStack stack;
|
||||
|
||||
public static DataAccessorCommon instance = new DataAccessorCommon();
|
||||
public float blockBreakDamage;
|
||||
|
||||
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop) {
|
||||
this.set(_world, _player, _mop, null, 0.0);
|
||||
@@ -55,6 +58,7 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
|
||||
this.entity = null;
|
||||
this.blockID = Block.getIdFromBlock(this.block);
|
||||
this.blockResource = GameData.getBlockRegistry().getNameForObject(this.block);
|
||||
this.blockBreakDamage = MC.playerController.curBlockDamageMP;
|
||||
try {
|
||||
this.stack = new ItemStack(this.block, 1, this.metadata);
|
||||
} catch (Exception e) {}
|
||||
@@ -200,6 +204,11 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
|
||||
return this.stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockBreakDamage() {
|
||||
return this.blockBreakDamage;
|
||||
}
|
||||
|
||||
public boolean isTimeElapsed(long time) {
|
||||
return System.currentTimeMillis() - this.timeLastUpdate >= time;
|
||||
}
|
||||
|
||||
@@ -124,6 +124,37 @@ public class DisplayUtil {
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
public static void drawGradientRect(int x, int y, double w, double h, int grad1, int grad2) {
|
||||
float zLevel = 0.0f;
|
||||
|
||||
float f = (float) (grad1 >> 24 & 255) / 255.0F;
|
||||
float f1 = (float) (grad1 >> 16 & 255) / 255.0F;
|
||||
float f2 = (float) (grad1 >> 8 & 255) / 255.0F;
|
||||
float f3 = (float) (grad1 & 255) / 255.0F;
|
||||
float f4 = (float) (grad2 >> 24 & 255) / 255.0F;
|
||||
float f5 = (float) (grad2 >> 16 & 255) / 255.0F;
|
||||
float f6 = (float) (grad2 >> 8 & 255) / 255.0F;
|
||||
float f7 = (float) (grad2 & 255) / 255.0F;
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA_F(f1, f2, f3, f);
|
||||
tessellator.addVertex((x + w), y, zLevel);
|
||||
tessellator.addVertex(x, y, zLevel);
|
||||
tessellator.setColorRGBA_F(f5, f6, f7, f4);
|
||||
tessellator.addVertex(x, y + h, zLevel);
|
||||
tessellator.addVertex(x + w, y + h, zLevel);
|
||||
tessellator.draw();
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
public static void drawTexturedModalRect(int x, int y, int u, int v, int w, int h, int tw, int th) {
|
||||
float f = 0.00390625F;
|
||||
float f1 = 0.00390625F;
|
||||
|
||||
@@ -15,6 +15,7 @@ public class OverlayConfig {
|
||||
public static int gradient2;
|
||||
public static int fontcolor;
|
||||
public static float scale;
|
||||
public static boolean breakprogress;
|
||||
|
||||
public static void updateColors() {
|
||||
OverlayConfig.alpha = (int) (ConfigHandler.instance()
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
|
||||
public class OverlayRenderer {
|
||||
@@ -62,6 +63,19 @@ public class OverlayRenderer {
|
||||
OverlayConfig.gradient1,
|
||||
OverlayConfig.gradient2);
|
||||
|
||||
if (OverlayConfig.breakprogress && tooltip.accessor instanceof IWailaDataAccessor) {
|
||||
IWailaDataAccessor data = ((IWailaDataAccessor) tooltip.accessor);
|
||||
if (data.getBlockBreakDamage() > 0) {
|
||||
DisplayUtil.drawGradientRect(
|
||||
tooltip.x + 1,
|
||||
tooltip.y + tooltip.h,
|
||||
(double) (tooltip.w - 1) * (data.getBlockBreakDamage()),
|
||||
1,
|
||||
0xffffffff,
|
||||
0xffffffff);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
tooltip.draw();
|
||||
|
||||
@@ -78,7 +78,6 @@ public class WailaTickHandler {
|
||||
accessor.set(world, player, target);
|
||||
ItemStack targetStack = RayTracing.instance().getTargetStack(); // Here we get either the proper stack
|
||||
// or the override
|
||||
|
||||
if (targetStack != null) {
|
||||
this.currenttip = new TipList<String, String>();
|
||||
this.currenttipHead = new TipList<String, String>();
|
||||
|
||||
@@ -30,6 +30,7 @@ public final class Constants {
|
||||
public static String CFG_WAILA_NHEARTS = "waila.cfg.heartsperline";
|
||||
public static String CFG_WAILA_MAXHP = "waila.cfg.maxhpbeforetext";
|
||||
public static String CFG_WAILA_NEWFILTERS = "waila.cfg.newfilters";
|
||||
public static String CFG_WAILA_BREAK_PROGRESS = "waila.cfg.breakprogress";
|
||||
|
||||
public static String CFG_WAILA_ALPHA = "waila.cfg.alpha";
|
||||
public static String CFG_WAILA_BGCOLOR = "waila.cfg.bgcolor";
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
public net.minecraft.client.multiplayer.PlayerControllerMP field_78770_f # curBlockDamageMP
|
||||
Reference in new issue
Block a user