mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 11:49:37 +00:00
Client HUD unification and fixes.
This commit is contained in:
1 parent
b2e4041b42
commit
e1d8683ff6
4 files changed
+40
-62
No files matched your search
@@ -15,10 +15,14 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
|
||||
public final class HUDHandler {
|
||||
@@ -36,6 +40,29 @@ public final class HUDHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res) {
|
||||
int type = 0;
|
||||
if(mana >= 0) {
|
||||
type = 1;
|
||||
double percentage = (double) mana / (double) maxMana * 100;
|
||||
if(percentage == 100)
|
||||
type = 5;
|
||||
else if(percentage >= 75)
|
||||
type = 4;
|
||||
else if(percentage >= 50)
|
||||
type = 3;
|
||||
else if(percentage > 0)
|
||||
type = 2;
|
||||
}
|
||||
String filling = StatCollector.translateToLocal("botaniamisc.status" + type);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.fontRenderer.drawStringWithShadow(name, res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(name) / 2, res.getScaledHeight() / 2 + 10, color);
|
||||
mc.fontRenderer.drawStringWithShadow(filling, res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(filling) / 2, res.getScaledHeight() / 2 + 20, color);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
public interface IHUD {
|
||||
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.api.mana.IManaCollector;
|
||||
import vazkii.botania.api.subtile.SubTileEntity;
|
||||
import vazkii.botania.client.core.handler.HUDHandler;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.core.handler.ManaNetworkHandler;
|
||||
|
||||
@@ -134,26 +135,8 @@ public class SubTileGenerating extends SubTileEntity {
|
||||
@Override
|
||||
public void renderHUD(Minecraft mc, ScaledResolution res) {
|
||||
String name = StatCollector.translateToLocal("tile.botania:flower." + getUnlocalizedName() + ".name");
|
||||
int type = 0;
|
||||
if(knownMana >= 0) {
|
||||
type = 1;
|
||||
double percentage = (double) knownMana / (double) getMaxMana() * 100;
|
||||
if(percentage == 100)
|
||||
type = 5;
|
||||
else if(percentage >= 75)
|
||||
type = 4;
|
||||
else if(percentage >= 50)
|
||||
type = 3;
|
||||
else if(percentage > 0)
|
||||
type = 2;
|
||||
}
|
||||
String filling = StatCollector.translateToLocal("botaniamisc.status" + type);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
int color = 0x66000000 | getColor();
|
||||
mc.fontRenderer.drawStringWithShadow(name, res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(name) / 2, res.getScaledHeight() / 2 + 10, color);
|
||||
mc.fontRenderer.drawStringWithShadow(filling, res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(filling) / 2, res.getScaledHeight() / 2 + 20, color);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
HUDHandler.drawSimpleManaHUD(color, knownMana, getMaxMana(), name, res);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import vazkii.botania.api.internal.ManaNetworkEvent;
|
||||
import vazkii.botania.api.mana.IManaPool;
|
||||
import vazkii.botania.client.core.handler.HUDHandler;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
@@ -103,26 +104,8 @@ public class TilePool extends TileSimpleInventory implements IManaPool {
|
||||
|
||||
public void renderHUD(Minecraft mc, ScaledResolution res) {
|
||||
String name = ModBlocks.pool.getLocalizedName();
|
||||
int type = 0;
|
||||
if(knownMana >= 0) {
|
||||
type = 1;
|
||||
double percentage = (double) knownMana / (double) MAX_MANA * 100;
|
||||
if(percentage == 100)
|
||||
type = 5;
|
||||
else if(percentage >= 75)
|
||||
type = 4;
|
||||
else if(percentage >= 50)
|
||||
type = 3;
|
||||
else if(percentage > 0)
|
||||
type = 2;
|
||||
}
|
||||
String filling = StatCollector.translateToLocal("botaniamisc.status" + type);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
int color = 0x66FFFFFF;
|
||||
mc.fontRenderer.drawStringWithShadow(name, res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(name) / 2, res.getScaledHeight() / 2 + 10, color);
|
||||
mc.fontRenderer.drawStringWithShadow(filling, res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(filling) / 2, res.getScaledHeight() / 2 + 20, color);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
int color = 0x660000FF;
|
||||
HUDHandler.drawSimpleManaHUD(color, knownMana, MAX_MANA, name, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,6 +33,7 @@ import vazkii.botania.api.internal.ManaNetworkEvent;
|
||||
import vazkii.botania.api.mana.IManaCollector;
|
||||
import vazkii.botania.api.mana.IManaPool;
|
||||
import vazkii.botania.api.mana.IManaReceiver;
|
||||
import vazkii.botania.client.core.handler.HUDHandler;
|
||||
import vazkii.botania.client.core.helper.Vector3;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.entity.EntityManaBurst;
|
||||
@@ -123,7 +124,7 @@ public class TileSpreader extends TileMod implements IManaCollector {
|
||||
if(cmp.hasKey(TAG_KNOWN_MANA))
|
||||
knownMana = cmp.getInteger(TAG_KNOWN_MANA);
|
||||
|
||||
if(worldObj.isRemote) {
|
||||
if(worldObj != null && worldObj.isRemote) {
|
||||
EntityManaBurst fakeBurst = getBurst(true);
|
||||
TileEntity receiver = fakeBurst.getCollidedTile(true);
|
||||
if(receiver != null && receiver instanceof IManaReceiver)
|
||||
@@ -263,31 +264,15 @@ public class TileSpreader extends TileMod implements IManaCollector {
|
||||
|
||||
public void renderHUD(Minecraft mc, ScaledResolution res) {
|
||||
String name = ModBlocks.spreader.getLocalizedName();
|
||||
int type = 0;
|
||||
if(knownMana >= 0) {
|
||||
type = 1;
|
||||
double percentage = (double) knownMana / (double) MAX_MANA * 100;
|
||||
if(percentage == 100)
|
||||
type = 5;
|
||||
else if(percentage >= 75)
|
||||
type = 4;
|
||||
else if(percentage >= 50)
|
||||
type = 3;
|
||||
else if(percentage > 0)
|
||||
type = 2;
|
||||
}
|
||||
String filling = StatCollector.translateToLocal("botaniamisc.status" + type);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
int color = 0x66FFFFFF;
|
||||
mc.fontRenderer.drawStringWithShadow(name, res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(name) / 2, res.getScaledHeight() / 2 + 10, color);
|
||||
mc.fontRenderer.drawStringWithShadow(filling, res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(filling) / 2, res.getScaledHeight() / 2 + 20, color);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
int color = 0x6600FF00;
|
||||
HUDHandler.drawSimpleManaHUD(color, knownMana, MAX_MANA, name, res);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClientDisplayTick() {
|
||||
EntityManaBurst burst = getBurst(true);
|
||||
burst.getCollidedTile(false);
|
||||
if(worldObj != null) {
|
||||
EntityManaBurst burst = getBurst(true);
|
||||
burst.getCollidedTile(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user