Compare commits

..
Author SHA1 Message Date
boubou19andMalTeeez 0c07be8b84 Add 3D entity icon to tooltip (#80) (#83)
Co-authored-by: MalTeeez <[email protected]>
2026-11-19 04:30:39 +01:00
UltraProdigy a66217e064 ci: run build and test on release branches 2026-11-09 01:43:47 -05:00
13 changed files with 200 additions and 232 deletions

No files matched your search

+2 -2
View File
@@ -3,9 +3,9 @@ name: Build and test
on:
pull_request:
branches: [ master, main ]
branches: [ master, main, release/** ]
push:
branches: [ master, main ]
branches: [ master, main, release/** ]
jobs:
build-and-test:
@@ -17,7 +17,6 @@ import cpw.mods.fml.common.registry.GameData;
import mcp.mobius.waila.api.IWailaCommonAccessor;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaEntityAccessor;
import mcp.mobius.waila.handlers.HUDHandlerInventory;
import mcp.mobius.waila.utils.NBTUtil;
public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAccessor, IWailaEntityAccessor {
@@ -124,23 +123,9 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
@Override
public NBTTagCompound getNBTData() {
if ((this.tileEntity != null) && this.isTagCorrectTileEntity(this.remoteNbt)) {
if (!remoteNbt.getBoolean(HUDHandlerInventory.TAG_SUMMARY_ONLY)) return remoteNbt;
NBTTagCompound tag = new NBTTagCompound();
try {
this.tileEntity.writeToNBT(tag);
} catch (Exception ignored) {}
return HUDHandlerInventory.mergeSummary(remoteNbt, tag);
}
if ((this.tileEntity != null) && this.isTagCorrectTileEntity(this.remoteNbt)) return remoteNbt;
if ((this.entity != null) && this.isTagCorrectEntity(this.remoteNbt)) {
if (!remoteNbt.getBoolean(HUDHandlerInventory.TAG_SUMMARY_ONLY)) return remoteNbt;
NBTTagCompound tag = new NBTTagCompound();
try {
this.entity.writeToNBT(tag);
} catch (Exception ignored) {}
return HUDHandlerInventory.mergeSummary(remoteNbt, tag);
}
if ((this.entity != null) && this.isTagCorrectEntity(this.remoteNbt)) return remoteNbt;
if (this.tileEntity != null) {
NBTTagCompound tag = new NBTTagCompound();
@@ -21,7 +21,6 @@ import mcp.mobius.waila.api.IWailaEntityProvider;
import mcp.mobius.waila.cbcore.LangUtil;
import mcp.mobius.waila.cbcore.Layout;
import mcp.mobius.waila.client.KeyEvent;
import mcp.mobius.waila.handlers.HUDHandlerInventory;
import mcp.mobius.waila.network.Message0x01TERequest;
import mcp.mobius.waila.network.Message0x03EntRequest;
import mcp.mobius.waila.network.WailaPacketHandler;
@@ -81,8 +80,7 @@ public class MetaDataProvider {
keys.addAll(ModuleRegistrar.instance().getSyncedNBTKeys(accessor.getTileEntity()));
if (!keys.isEmpty() || ModuleRegistrar.instance().hasNBTProviders(block)
|| ModuleRegistrar.instance().hasNBTProviders(accessor.getTileEntity())
|| HUDHandlerInventory.shouldRequest(accessor.getTileEntity()))
|| ModuleRegistrar.instance().hasNBTProviders(accessor.getTileEntity()))
WailaPacketHandler.INSTANCE.sendToServer(new Message0x01TERequest(accessor.getTileEntity(), keys));
} else if (accessor.getTileEntity() != null && !Waila.instance.serverPresent
@@ -195,8 +193,7 @@ public class MetaDataProvider {
if (ModuleRegistrar.instance().hasSyncedNBTKeys(accessor.getEntity()))
keys.addAll(ModuleRegistrar.instance().getSyncedNBTKeys(accessor.getEntity()));
if (!keys.isEmpty() || ModuleRegistrar.instance().hasNBTEntityProviders(accessor.getEntity())
|| HUDHandlerInventory.shouldRequest(accessor.getEntity()))
if (!keys.isEmpty() || ModuleRegistrar.instance().hasNBTEntityProviders(accessor.getEntity()))
WailaPacketHandler.INSTANCE.sendToServer(new Message0x03EntRequest(accessor.getEntity(), keys));
} else if (accessor.getEntity() != null && !Waila.instance.serverPresent && accessor.isTimeElapsed(250)) {
@@ -16,6 +16,7 @@ import mcp.mobius.waila.handlers.HUDHandlerBlocks;
import mcp.mobius.waila.handlers.HUDHandlerEntities;
import mcp.mobius.waila.handlers.VanillaTooltipHandler;
import mcp.mobius.waila.handlers.nei.NEIHandler;
import mcp.mobius.waila.overlay.EntityIconRenderer;
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderAspectString;
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderBar;
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderFluidBar;
@@ -53,6 +54,7 @@ public class ProxyClient extends ProxyServer {
ModuleRegistrar.instance().addConfig("General", "general.showents");
ModuleRegistrar.instance().addConfig("General", "general.showhp");
ModuleRegistrar.instance().addConfig("General", "general.showcrop");
ModuleRegistrar.instance().addConfig("General", EntityIconRenderer.CFG_SHOW, true);
ModuleRegistrar.instance().registerTooltipRenderer("waila.health", new TTRenderHealth());
ModuleRegistrar.instance().registerTooltipRenderer("waila.stack", new TTRenderStack());
@@ -1,175 +0,0 @@
package mcp.mobius.waila.handlers;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryLargeChest;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.IWailaEntityAccessor;
import mcp.mobius.waila.api.IWailaEntityProvider;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.cbcore.LangUtil;
import mcp.mobius.waila.utils.WailaExceptionHandler;
/**
* Shows "X items in Y of Z slots" for every block and entity that is an {@link IInventory}.
* <p>
* The server always adds the summary to the NBT answer of a {@link IInventory} target (see
* {@link #writeSummary(Object, World, int, int, int, NBTTagCompound)}). This is not done with an NBT provider, because
* an NBT provider would stop the synced NBT keys of other mods for all inventories.
* <p>
* If the client only asked because of the summary, the answer has only the summary and {@link #TAG_SUMMARY_ONLY}. The
* client then adds the summary to its own NBT of the target, so that other mods still get the same NBT as before.
*/
public class HUDHandlerInventory implements IWailaDataProvider, IWailaEntityProvider {
public static final String CFG_SHOW = "general.showinventory";
private static final String TAG_ITEMS = "WailaInvItems";
private static final String TAG_USED = "WailaInvUsed";
private static final String TAG_SLOTS = "WailaInvSlots";
public static final String TAG_SUMMARY_ONLY = "WailaInvOnly";
/**
* @return true if the client must ask the server for the summary of this target.
*/
public static boolean shouldRequest(Object target) {
// Players implement IInventory, so this also summarises player inventories. Test instanceof EntityPlayer to
// skip.
return target instanceof IInventory && ConfigHandler.instance().getConfig(CFG_SHOW, true);
}
/**
* Server side: adds the item count, the used slots and the total slots of the target to the tag.
*/
public static void writeSummary(Object target, NBTTagCompound tag) {
if (!(target instanceof IInventory)) return;
try {
IInventory inv = (IInventory) target;
// Count both halves of a double chest. The chest updates its neighbours every tick.
if (target instanceof TileEntityChest chest) {
TileEntityChest other = chest.adjacentChestXNeg != null ? chest.adjacentChestXNeg
: chest.adjacentChestXPos != null ? chest.adjacentChestXPos
: chest.adjacentChestZNeg != null ? chest.adjacentChestZNeg : chest.adjacentChestZPos;
if (other != null) inv = new InventoryLargeChest("", chest, other);
}
long items = 0;
int used = 0;
int slots = inv.getSizeInventory();
for (int i = 0; i < slots; i++) {
ItemStack stack = inv.getStackInSlot(i);
if (stack == null || stack.getItem() == null || stack.stackSize <= 0) continue;
items += stack.stackSize;
used++;
}
tag.setLong(TAG_ITEMS, items);
tag.setInteger(TAG_USED, used);
tag.setInteger(TAG_SLOTS, slots);
} catch (Exception e) {
// Do not lose the data of the other providers because of one bad inventory
WailaExceptionHandler.handleErr(e, "HUDHandlerInventory | " + target.getClass().getName(), null);
}
}
/**
* Client side: adds the values of a summary only answer to the local NBT of the target.
*/
public static NBTTagCompound mergeSummary(NBTTagCompound remote, NBTTagCompound local) {
for (String key : new String[] { TAG_ITEMS, TAG_USED, TAG_SLOTS }) {
NBTBase tag = remote.getTag(key);
if (tag != null) local.setTag(key, tag.copy());
}
return local;
}
private static void addLine(NBTTagCompound tag, List<String> currenttip, IWailaConfigHandler config) {
if (tag == null || !config.getConfig(CFG_SHOW, true) || !tag.hasKey(TAG_SLOTS)) return;
int slots = tag.getInteger(TAG_SLOTS);
if (slots <= 0) return;
long items = tag.getLong(TAG_ITEMS);
int used = tag.getInteger(TAG_USED);
String key = items == 1 ? "hud.msg.inventory.single" : "hud.msg.inventory";
currenttip.add(String.format(LangUtil.translateG(key), items, used, slots));
}
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
return currenttip;
}
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
addLine(accessor.getNBTData(), currenttip, config);
return currenttip;
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
return currenttip;
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
int y, int z) {
return tag;
}
@Override
public Entity getWailaOverride(IWailaEntityAccessor accessor, IWailaConfigHandler config) {
return null;
}
@Override
public List<String> getWailaHead(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor,
IWailaConfigHandler config) {
return currenttip;
}
@Override
public List<String> getWailaBody(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor,
IWailaConfigHandler config) {
addLine(accessor.getNBTData(), currenttip, config);
return currenttip;
}
@Override
public List<String> getWailaTail(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor,
IWailaConfigHandler config) {
return currenttip;
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, Entity ent, NBTTagCompound tag, World world) {
return tag;
}
public static void register() {
HUDHandlerInventory provider = new HUDHandlerInventory();
ModuleRegistrar.instance().addConfig("General", CFG_SHOW, true);
ModuleRegistrar.instance().registerBodyProvider((IWailaDataProvider) provider, IInventory.class);
ModuleRegistrar.instance().registerBodyProvider((IWailaEntityProvider) provider, IInventory.class);
}
}
@@ -20,7 +20,6 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.handlers.HUDHandlerInventory;
import mcp.mobius.waila.utils.AccessHelper;
import mcp.mobius.waila.utils.NBTUtil;
import mcp.mobius.waila.utils.WailaExceptionHandler;
@@ -126,16 +125,11 @@ public class Message0x01TERequest extends SimpleChannelInboundHandler<Message0x0
}
}
} else if (msg.keys.isEmpty()) {
// The client asked only for the inventory summary
tag.setBoolean(HUDHandlerInventory.TAG_SUMMARY_ONLY, true);
} else {
entity.writeToNBT(tag);
tag = NBTUtil.createTag(tag, msg.keys);
}
HUDHandlerInventory.writeSummary(entity, tag);
tag.setInteger("WailaX", msg.posX);
tag.setInteger("WailaY", msg.posY);
tag.setInteger("WailaZ", msg.posZ);
@@ -16,7 +16,6 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import mcp.mobius.waila.api.IWailaEntityProvider;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.handlers.HUDHandlerInventory;
import mcp.mobius.waila.utils.AccessHelper;
import mcp.mobius.waila.utils.NBTUtil;
import mcp.mobius.waila.utils.WailaExceptionHandler;
@@ -84,16 +83,11 @@ public class Message0x03EntRequest extends SimpleChannelInboundHandler<Message0x
}
}
} else if (msg.keys.isEmpty()) {
// The client asked only for the inventory summary
tag.setBoolean(HUDHandlerInventory.TAG_SUMMARY_ONLY, true);
} else {
entity.writeToNBT(tag);
tag = NBTUtil.createTag(tag, msg.keys);
}
HUDHandlerInventory.writeSummary(entity, tag);
tag.setInteger("WailaEntityID", entity.getEntityId());
WailaPacketHandler.INSTANCE.sendTo(new Message0x04EntNBTData(tag), WailaPacketHandler.getPlayer(ctx));
@@ -0,0 +1,162 @@
package mcp.mobius.waila.overlay;
import java.nio.FloatBuffer;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.utils.WailaExceptionHandler;
/**
* Draws a small turning 3D model of an entity as the tooltip icon. Based on {@code GuiInventory.func_147046_a} and the
* entity icon of WDMla (https://github.com/GTNewHorizons/WDMla).
*/
public final class EntityIconRenderer {
public static final String CFG_SHOW = "general.showentityicon";
/** Degrees per second */
private static final float TURN_SPEED = 45f;
private static final Set<Class<?>> failedClasses = new HashSet<>();
private static final FloatBuffer modelview = GLAllocation.createDirectFloatBuffer(16);
private EntityIconRenderer() {}
public static boolean isEnabled() {
return ConfigHandler.instance().getConfig(CFG_SHOW, true);
}
/**
* Draws the entity in the square with the top left corner (x, y) and the side length size.
*/
public static void render(int x, int y, int size, Entity entity) {
if (entity == null || failedClasses.contains(entity.getClass())) return;
final Minecraft mc = Minecraft.getMinecraft();
// The body of most mobs is longer than the bounding box is wide, and the model turns
float extent = Math.max(Math.max(entity.height, entity.width * 1.5f), 0.1f);
float scale = size / extent;
float angle = (Minecraft.getSystemTime() % 360000L) / 1000f * TURN_SPEED;
float yaw = entity.rotationYaw;
float prevYaw = entity.prevRotationYaw;
float pitch = entity.rotationPitch;
float prevPitch = entity.prevRotationPitch;
float bodyYaw = 0, prevBodyYaw = 0, headYaw = 0, prevHeadYaw = 0;
EntityLivingBase living = entity instanceof EntityLivingBase l ? l : null;
if (living != null) {
bodyYaw = living.renderYawOffset;
prevBodyYaw = living.prevRenderYawOffset;
headYaw = living.rotationYawHead;
prevHeadYaw = living.prevRotationYawHead;
}
float playerViewY = RenderManager.instance.playerViewY;
float infoX = ActiveRenderInfo.rotationX, infoZ = ActiveRenderInfo.rotationZ;
float infoYZ = ActiveRenderInfo.rotationYZ, infoXZ = ActiveRenderInfo.rotationXZ,
infoXY = ActiveRenderInfo.rotationXY;
boolean hideGui = mc.gameSettings.hideGUI;
// Entity renderers change blend, depth, alpha and lighting state (so save all of it)
int matrixDepth = GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH);
int attribDepth = GL11.glGetInteger(GL11.GL_ATTRIB_STACK_DEPTH);
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
try {
// Models can be larger than their bounding box, do not draw over the text
ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
float factor = res.getScaleFactor() * OverlayConfig.scale;
int margin = 3;
GL11.glEnable(GL11.GL_SCISSOR_TEST);
GL11.glScissor(
(int) ((x - margin) * factor),
(int) (mc.displayHeight - (y + size + margin) * factor),
(int) ((size + 2 * margin) * factor),
(int) ((size + 2 * margin) * factor));
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glColor4f(1f, 1f, 1f, 1f);
GL11.glTranslatef(x + size / 2f, y + size / 2f + entity.height * scale / 2f, 100f);
GL11.glScalef(-scale, scale, scale);
GL11.glRotatef(180f, 0f, 0f, 1f);
GL11.glRotatef(-15f, 1f, 0f, 0f);
GL11.glRotatef(135f, 0f, 1f, 0f);
RenderHelper.enableStandardItemLighting();
GL11.glRotatef(-135f + angle, 0f, 1f, 0f);
GL11.glTranslatef(0f, entity.yOffset, 0f);
entity.rotationYaw = entity.prevRotationYaw = 0f;
entity.rotationPitch = entity.prevRotationPitch = 0f;
if (living != null) {
living.renderYawOffset = living.prevRenderYawOffset = 0f;
living.rotationYawHead = living.prevRotationYawHead = 0f;
}
RenderManager.instance.playerViewY = 180f;
setBillboardAxes();
// Hide name tags
mc.gameSettings.hideGUI = true;
RenderManager.instance.renderEntityWithPosYaw(entity, 0d, 0d, 0d, 0f, 1f);
} catch (Exception e) {
failedClasses.add(entity.getClass());
WailaExceptionHandler.handleErr(e, "EntityIconRenderer | " + entity.getClass().getName(), null);
} finally {
mc.gameSettings.hideGUI = hideGui;
RenderManager.instance.playerViewY = playerViewY;
ActiveRenderInfo.rotationX = infoX;
ActiveRenderInfo.rotationZ = infoZ;
ActiveRenderInfo.rotationYZ = infoYZ;
ActiveRenderInfo.rotationXZ = infoXZ;
ActiveRenderInfo.rotationXY = infoXY;
entity.rotationYaw = yaw;
entity.prevRotationYaw = prevYaw;
entity.rotationPitch = pitch;
entity.prevRotationPitch = prevPitch;
if (living != null) {
living.renderYawOffset = bodyYaw;
living.prevRenderYawOffset = prevBodyYaw;
living.rotationYawHead = headYaw;
living.prevRotationYawHead = prevHeadYaw;
}
// A renderer can leave unbalanced pushes behind, but should never pop the caller's. Query each
// stack once and pop down to where it started.
for (int i = GL11.glGetInteger(GL11.GL_ATTRIB_STACK_DEPTH) - attribDepth; i > 0; i--) GL11.glPopAttrib();
for (int i = GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH) - matrixDepth; i > 0; i--) GL11.glPopMatrix();
}
}
/**
* Billboards (like Thaumcraft wisps) face the camera with the axes in {@link ActiveRenderInfo}, which belong to the
* world view. Point them at the screen of the icon instead.
*/
private static void setBillboardAxes() {
modelview.clear();
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelview);
// The rows of the rotation are the screen right and down axes in model space, all with the same length
float len = (float) Math.sqrt(
modelview.get(0) * modelview.get(0) + modelview.get(4) * modelview.get(4)
+ modelview.get(8) * modelview.get(8));
// Vanilla stores the left axis in rotationX/Z and the up axis in rotationYZ/XZ/XY
ActiveRenderInfo.rotationX = -modelview.get(0) / len;
ActiveRenderInfo.rotationZ = -modelview.get(8) / len;
ActiveRenderInfo.rotationYZ = -modelview.get(1) / len;
ActiveRenderInfo.rotationXZ = -modelview.get(5) / len;
ActiveRenderInfo.rotationXY = -modelview.get(9) / len;
}
}
@@ -2,6 +2,7 @@ package mcp.mobius.waila.overlay;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.Entity;
import net.minecraft.util.MovingObjectPosition;
import org.lwjgl.opengl.GL11;
@@ -11,8 +12,6 @@ import mcp.mobius.waila.api.impl.ConfigHandler;
public class OverlayRenderer {
private static boolean hasBlending;
private static boolean hasDepthTest;
private static int boundTexIndex;
public static boolean isOverlayVisible() {
@@ -69,8 +68,11 @@ public class OverlayRenderer {
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
Entity entity = tooltip.entity;
if (tooltip.hasIcon && tooltip.stack != null && tooltip.stack.getItem() != null)
DisplayUtil.renderStack(tooltip.x + 5, tooltip.y + tooltip.h / 2 - 8, tooltip.stack);
else if (tooltip.hasIcon && entity != null)
EntityIconRenderer.render(tooltip.x + 5, tooltip.y + tooltip.h / 2 - 8, 16, entity);
loadGLState();
GL11.glPopMatrix();
@@ -78,17 +80,12 @@ public class OverlayRenderer {
}
private static void saveGLState() {
hasBlending = GL11.glGetBoolean(GL11.GL_BLEND);
hasDepthTest = GL11.glGetBoolean(GL11.GL_DEPTH_TEST);
boundTexIndex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
GL11.glPushAttrib(GL11.GL_CURRENT_BIT);
// Icons turn on lighting, lights, color material and rescale normal
GL11.glPushAttrib(GL11.GL_CURRENT_BIT | GL11.GL_ENABLE_BIT | GL11.GL_LIGHTING_BIT | GL11.GL_COLOR_BUFFER_BIT);
}
private static void loadGLState() {
if (hasBlending) GL11.glEnable(GL11.GL_BLEND);
else GL11.glDisable(GL11.GL_BLEND);
if (hasDepthTest) GL11.glEnable(GL11.GL_DEPTH_TEST);
else GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, boundTexIndex);
GL11.glPopAttrib();
}
@@ -14,6 +14,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Configuration;
@@ -49,6 +50,7 @@ public class Tooltip {
Point pos;
boolean hasIcon = false;
ItemStack stack;
Entity entity;
IWailaCommonAccessor accessor = DataAccessorCommon.instance;
@@ -106,6 +108,11 @@ public class Tooltip {
this.stack = stack;
}
public Tooltip(List<String> textData, Entity entity) {
this(textData, entity != null && EntityIconRenderer.isEnabled());
this.entity = entity;
}
public Tooltip(List<String> textData, boolean hasIcon) {
if (hasIcon) hasIcon = ConfigHandler.instance().showIcon();
@@ -23,9 +23,15 @@ import mcp.mobius.waila.utils.Constants;
public class WailaTickHandler {
private Tooltip tooltip = null;
private static Tooltip tooltip = null;
private static World lastWorld = null;
private final MetaDataProvider handler = new MetaDataProvider();
private static void reset() {
tooltip = null;
RayTracing.instance().clear();
}
@SubscribeEvent
public void tickRender(TickEvent.RenderTickEvent event) {
if (event.phase == TickEvent.Phase.END) {
@@ -37,17 +43,20 @@ public class WailaTickHandler {
public void tickClient(TickEvent.ClientTickEvent event) {
if (event.phase == TickEvent.Phase.START) return;
Minecraft mc = Minecraft.getMinecraft();
World world = mc.theWorld;
// The tooltip and the ray trace target hold the entity, which holds the world
if (world != lastWorld) reset();
lastWorld = world;
if (!OverlayRenderer.isOverlayVisible()) {
this.tooltip = null;
RayTracing.instance().clear();
reset();
return;
}
RayTracing.instance().fire();
MovingObjectPosition target = RayTracing.instance().getTarget();
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.thePlayer;
World world = mc.theWorld;
List<String> currenttip;
List<String> currenttipHead;
@@ -96,7 +105,7 @@ public class WailaTickHandler {
currenttip.addAll(currenttipBody);
currenttip.addAll(currenttipTail);
this.tooltip = new Tooltip(currenttip, targetStack);
tooltip = new Tooltip(currenttip, targetStack);
}
} else if (target != null && target.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
DataAccessorCommon accessor = DataAccessorCommon.instance;
@@ -142,7 +151,7 @@ public class WailaTickHandler {
currenttip.addAll(currenttipBody);
currenttip.addAll(currenttipTail);
this.tooltip = new Tooltip(currenttip, false);
tooltip = new Tooltip(currenttip, targetEnt);
}
}
@@ -29,7 +29,6 @@ import mcp.mobius.waila.api.IWailaRegistrar;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.handlers.DecoratorFMP;
import mcp.mobius.waila.handlers.HUDHandlerFMP;
import mcp.mobius.waila.handlers.HUDHandlerInventory;
import mcp.mobius.waila.utils.LoadedMods;
public class ProxyServer {
@@ -42,7 +41,6 @@ public class ProxyServer {
HUDHandlerVanilla.register();
HUDHandlerFurnace.register();
HUDHandlerInventory.register();
/* BUILDCRAFT */
BCModule.register();
@@ -43,8 +43,6 @@ client.msg.nousage=No usage found.
hud.msg.holdkeymoreinfo=Hold %s for more info
hud.msg.empty=Empty
hud.msg.inventory=%d items in %d of %d slots
hud.msg.inventory.single=%d item in %d of %d slots
hud.msg.output=Output
hud.msg.input=Input
hud.msg.out=Out
@@ -155,7 +153,7 @@ option.stevescarts.shifttoggle=Shift toggle
option.general.showents=Show entities
option.general.showhp=Show entities health
option.general.showcrop=Show crop growth
option.general.showinventory=Show inventory summary
option.general.showentityicon=Show entity icon
option.thaumcraft.aspects=Show aspects
nei.options.keys.showenchant=Show enchanting values