diff --git a/src/main/java/mcp/mobius/waila/api/IWailaDataAccessor.java b/src/main/java/mcp/mobius/waila/api/IWailaDataAccessor.java index 2273082..15c1224 100644 --- a/src/main/java/mcp/mobius/waila/api/IWailaDataAccessor.java +++ b/src/main/java/mcp/mobius/waila/api/IWailaDataAccessor.java @@ -18,7 +18,7 @@ import net.minecraftforge.common.util.ForgeDirection; * */ -public interface IWailaDataAccessor { +public interface IWailaDataAccessor{ World getWorld(); EntityPlayer getPlayer(); diff --git a/src/main/java/mcp/mobius/waila/api/SpecialChars.java b/src/main/java/mcp/mobius/waila/api/SpecialChars.java index 99b9893..e2779fe 100644 --- a/src/main/java/mcp/mobius/waila/api/SpecialChars.java +++ b/src/main/java/mcp/mobius/waila/api/SpecialChars.java @@ -51,5 +51,5 @@ public class SpecialChars { public static final Pattern patternRight = Pattern.compile("(?i)" + ALIGNRIGHT); public static final Pattern patternCenter = Pattern.compile("(?i)" + ALIGNCENTER); public static final Pattern patternIcon = Pattern.compile("(?i)(" + WailaStyle + WailaIcon + "(?[0-9A-Z]))"); - public static final Pattern patternLineSplit = Pattern.compile("(?i)(" + WailaStyle + WailaStyle + "[^" + WailaStyle + "]+|" + WailaStyle + WailaRenderer + "a\\{([^,}]*),?([^}]*)\\}|[^" + WailaStyle + "]+)"); + public static final Pattern patternLineSplit = Pattern.compile("(?i)(" + WailaStyle + WailaStyle + "[^" + WailaStyle + "]+|" + WailaStyle + WailaIcon + "[0-9A-Z]|" + WailaStyle + WailaRenderer + "a\\{([^,}]*),?([^}]*)\\}|[^" + WailaStyle + "]+)"); } diff --git a/src/main/java/mcp/mobius/waila/api/impl/DataAccessorBlock.java b/src/main/java/mcp/mobius/waila/api/impl/DataAccessorBlock.java deleted file mode 100644 index 7daaf76..0000000 --- a/src/main/java/mcp/mobius/waila/api/impl/DataAccessorBlock.java +++ /dev/null @@ -1,174 +0,0 @@ -package mcp.mobius.waila.api.impl; - -import net.minecraft.block.Block; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.Vec3; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import mcp.mobius.waila.api.IWailaDataAccessor; -import mcp.mobius.waila.utils.NBTUtil; - -public class DataAccessorBlock implements IWailaDataAccessor { - - World world; - EntityPlayer player; - MovingObjectPosition mop; - Vec3 renderingvec = null; - Block block; - int blockID; - int metadata; - TileEntity entity; - NBTTagCompound remoteNbt = null; - long timeLastUpdate = System.currentTimeMillis(); - double partialFrame; - ItemStack stack; - - public static DataAccessorBlock instance = new DataAccessorBlock(); - - public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop) { - this.set(_world, _player, _mop, null, 0.0); - } - - public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop, EntityLivingBase viewEntity, double partialTicks) { - this.world = _world; - this.player = _player; - this.mop = _mop; - //this.blockID = world.getBlockId(_mop.blockX, _mop.blockY, _mop.blockZ); - //this.block = Block.blocksList[this.blockID]; - this.block = world.getBlock(_mop.blockX, _mop.blockY, _mop.blockZ); - this.metadata = world.getBlockMetadata(_mop.blockX, _mop.blockY, _mop.blockZ); - this.entity = world.getTileEntity(_mop.blockX, _mop.blockY, _mop.blockZ); - try{ this.stack = new ItemStack(this.block, 1, this.metadata); } catch (Exception e) {} - - - if (viewEntity != null){ - double px = viewEntity.lastTickPosX + (viewEntity.posX - viewEntity.lastTickPosX) * partialTicks; - double py = viewEntity.lastTickPosY + (viewEntity.posY - viewEntity.lastTickPosY) * partialTicks; - double pz = viewEntity.lastTickPosZ + (viewEntity.posZ - viewEntity.lastTickPosZ) * partialTicks; - this.renderingvec = Vec3.createVectorHelper(_mop.blockX - px, _mop.blockY - py, _mop.blockZ - pz); - this.partialFrame = partialTicks; - } - } - - @Override - public World getWorld() { - return this.world; - } - - @Override - public EntityPlayer getPlayer() { - return this.player; - } - - @Override - public Block getBlock() { - return this.block; - } - - @Override - public int getBlockID() { - return this.blockID; - } - - @Override - public int getMetadata() { - return this.metadata; - } - - public void setBlock(Block block) { - this.block = block; - } - - public void setBlockID(int val) { - this.blockID = val; - } - - public void setMetadata(int val) { - this.metadata = val; - } - - @Override - public TileEntity getTileEntity() { - return this.entity; - } - - @Override - public MovingObjectPosition getPosition() { - return this.mop; - } - - @Override - public NBTTagCompound getNBTData() { - if (this.entity == null) return null; - - if (this.isTagCorrect(this.remoteNbt)) - return this.remoteNbt; - - NBTTagCompound tag = new NBTTagCompound(); - try{ - this.entity.writeToNBT(tag); - } catch (Exception e){} - return tag; - } - - public void setNBTData(NBTTagCompound tag){ - this.remoteNbt = tag; - } - - @Override - public int getNBTInteger(NBTTagCompound tag, String keyname){ - return NBTUtil.getNBTInteger(tag, keyname); - } - - private boolean isTagCorrect(NBTTagCompound tag){ - if (tag == null){ - this.timeLastUpdate = System.currentTimeMillis() - 250; - return false; - } - - int x = tag.getInteger("WailaX"); - int y = tag.getInteger("WailaY"); - int z = tag.getInteger("WailaZ"); - - if (x == this.mop.blockX && y == this.mop.blockY && z == this.mop.blockZ) - return true; - else { - this.timeLastUpdate = System.currentTimeMillis() - 250; - return false; - } - } - - @Override - public Vec3 getRenderingPosition() { - return this.renderingvec; - } - - @Override - public double getPartialFrame() { - return this.partialFrame; - } - - @Override - public ForgeDirection getSide(){ - return ForgeDirection.getOrientation(this.getPosition().sideHit); - } - - public boolean isTimeElapsed(long time){ - return System.currentTimeMillis() - this.timeLastUpdate >= time; - } - - public void resetTimer(){ - this.timeLastUpdate = System.currentTimeMillis(); - } - - @Override - public ItemStack getStack() { - return this.stack; - } - -} diff --git a/src/main/java/mcp/mobius/waila/api/impl/DataAccessorCommon.java b/src/main/java/mcp/mobius/waila/api/impl/DataAccessorCommon.java index 7efdb0d..f141ab4 100644 --- a/src/main/java/mcp/mobius/waila/api/impl/DataAccessorCommon.java +++ b/src/main/java/mcp/mobius/waila/api/impl/DataAccessorCommon.java @@ -15,6 +15,7 @@ import net.minecraftforge.common.util.ForgeDirection; import mcp.mobius.waila.api.IWailaCommonAccessor; import mcp.mobius.waila.api.IWailaDataAccessor; import mcp.mobius.waila.api.IWailaEntityAccessor; +import mcp.mobius.waila.utils.NBTUtil; public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAccessor, IWailaEntityAccessor{ @@ -44,14 +45,18 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces this.mop = _mop; if (this.mop.typeOfHit == MovingObjectType.BLOCK){ - //this.blockID = world.getBlockId(_mop.blockX, _mop.blockY, _mop.blockZ); - //this.block = Block.blocksList[this.blockID]; this.block = world.getBlock(_mop.blockX, _mop.blockY, _mop.blockZ); this.metadata = world.getBlockMetadata(_mop.blockX, _mop.blockY, _mop.blockZ); this.tileEntity = world.getTileEntity(_mop.blockX, _mop.blockY, _mop.blockZ); + this.entity = null; try{ this.stack = new ItemStack(this.block, 1, this.metadata); } catch (Exception e) {} + } else if (this.mop.typeOfHit == MovingObjectType.ENTITY){ - this.entity = _mop.entityHit; + this.block = null; + this.metadata = -1; + this.tileEntity = null; + this.stack = null; + this.entity = _mop.entityHit; } if (viewEntity != null){ @@ -64,45 +69,121 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces } @Override - public World getWorld() {return null;} + public World getWorld() {return this.world;} @Override - public EntityPlayer getPlayer() {return null;} + public EntityPlayer getPlayer() {return this.player;} @Override - public Block getBlock() {return null;} + public Block getBlock() {return this.block;} @Override - public int getBlockID() {return 0;} + public int getBlockID() {return this.blockID;} @Override - public int getMetadata() {return 0;} + public int getMetadata() {return this.metadata;} @Override - public TileEntity getTileEntity() {return null;} + public TileEntity getTileEntity() { return this.tileEntity;} @Override - public Entity getEntity() {return null;} + public Entity getEntity() {return this.entity;} @Override - public MovingObjectPosition getPosition() {return null;} + public MovingObjectPosition getPosition() {return this.mop;} @Override - public Vec3 getRenderingPosition() {return null;} + public Vec3 getRenderingPosition() {return this.renderingvec;} @Override - public NBTTagCompound getNBTData() {return null;} + public NBTTagCompound getNBTData() { + if ((this.tileEntity != null) && this.isTagCorrectTileEntity(this.remoteNbt)) + return remoteNbt; + + if ((this.entity != null) && this.isTagCorrectEntity(this.remoteNbt)) + return remoteNbt; + + if (this.tileEntity != null){ + NBTTagCompound tag = new NBTTagCompound(); + try{ + this.tileEntity.writeToNBT(tag); + } catch (Exception e){} + return tag; + } + + if (this.entity != null){ + NBTTagCompound tag = new NBTTagCompound(); + this.entity.writeToNBT(tag); + return tag; + } + + return null; + } + + public void setNBTData(NBTTagCompound tag){ + this.remoteNbt = tag; + } + + private boolean isTagCorrectTileEntity(NBTTagCompound tag){ + if (tag == null || !tag.hasKey("WailaX")){ + this.timeLastUpdate = System.currentTimeMillis() - 250; + return false; + } + + int x = tag.getInteger("WailaX"); + int y = tag.getInteger("WailaY"); + int z = tag.getInteger("WailaZ"); + + if (x == this.mop.blockX && y == this.mop.blockY && z == this.mop.blockZ) + return true; + else { + this.timeLastUpdate = System.currentTimeMillis() - 250; + return false; + } + } + + private boolean isTagCorrectEntity(NBTTagCompound tag){ + if (tag == null || !tag.hasKey("WailaEntityID")){ + this.timeLastUpdate = System.currentTimeMillis() - 250; + return false; + } + + int id = tag.getInteger("WailaEntityID"); + + if (id == this.entity.getEntityId()) + return true; + else { + this.timeLastUpdate = System.currentTimeMillis() - 250; + return false; + } + } + + @Override + public int getNBTInteger(NBTTagCompound tag, String keyname) { + return NBTUtil.getNBTInteger(tag, keyname); + } @Override - public int getNBTInteger(NBTTagCompound tag, String keyname) {return 0;} + public double getPartialFrame() { + return this.partialFrame; + } @Override - public double getPartialFrame() {return 0;} + public ForgeDirection getSide() { + return ForgeDirection.getOrientation(this.getPosition().sideHit); + } @Override - public ForgeDirection getSide() {return null;} - - @Override - public ItemStack getStack() {return null;} + public ItemStack getStack() { + return this.stack; + } + public boolean isTimeElapsed(long time){ + return System.currentTimeMillis() - this.timeLastUpdate >= time; + } + + public void resetTimer(){ + this.timeLastUpdate = System.currentTimeMillis(); + } + } diff --git a/src/main/java/mcp/mobius/waila/api/impl/DataAccessorEntity.java b/src/main/java/mcp/mobius/waila/api/impl/DataAccessorEntity.java deleted file mode 100644 index ea4b8e8..0000000 --- a/src/main/java/mcp/mobius/waila/api/impl/DataAccessorEntity.java +++ /dev/null @@ -1,122 +0,0 @@ -package mcp.mobius.waila.api.impl; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.Vec3; -import net.minecraft.world.World; -import mcp.mobius.waila.api.IWailaEntityAccessor; -import mcp.mobius.waila.utils.NBTUtil; - -public class DataAccessorEntity implements IWailaEntityAccessor { - - World world; - EntityPlayer player; - MovingObjectPosition mop; - Vec3 renderingvec = null; - Entity entity; - NBTTagCompound remoteNbt = null; - long timeLastUpdate = System.currentTimeMillis(); - double partialFrame; - - public static DataAccessorEntity instance = new DataAccessorEntity(); - - public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop) { - this.set(_world, _player, _mop, null, 0.0); - } - - public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop, EntityLivingBase viewEntity, double partialTicks) { - this.world = _world; - this.player = _player; - this.mop = _mop; - this.entity = _mop.entityHit; - - if (viewEntity != null){ - double px = viewEntity.lastTickPosX + (viewEntity.posX - viewEntity.lastTickPosX) * partialTicks; - double py = viewEntity.lastTickPosY + (viewEntity.posY - viewEntity.lastTickPosY) * partialTicks; - double pz = viewEntity.lastTickPosZ + (viewEntity.posZ - viewEntity.lastTickPosZ) * partialTicks; - this.renderingvec = Vec3.createVectorHelper(_mop.blockX - px, _mop.blockY - py, _mop.blockZ - pz); - this.partialFrame = partialTicks; - } - } - - @Override - public World getWorld() { - return this.world; - } - - @Override - public EntityPlayer getPlayer() { - return this.player; - } - - @Override - public Entity getEntity() { - return this.entity; - } - - @Override - public MovingObjectPosition getPosition() { - return this.mop; - } - - @Override - public NBTTagCompound getNBTData() { - if (this.entity == null) return null; - - if (this.isTagCorrect(this.remoteNbt)) - return this.remoteNbt; - - NBTTagCompound tag = new NBTTagCompound(); - this.entity.writeToNBT(tag); - return tag; - } - - private boolean isTagCorrect(NBTTagCompound tag){ - if (tag == null){ - this.timeLastUpdate = System.currentTimeMillis() - 250; - return false; - } - - int x = tag.getInteger("x"); - int y = tag.getInteger("y"); - int z = tag.getInteger("z"); - - if (x == this.mop.blockX && y == this.mop.blockY && z == this.mop.blockZ) - return true; - else { - this.timeLastUpdate = System.currentTimeMillis() - 250; - return false; - } - } - - @Override - public int getNBTInteger(NBTTagCompound tag, String keyname){ - return NBTUtil.getNBTInteger(tag, keyname); - } - - public void setNBTData(NBTTagCompound tag){ - this.remoteNbt = tag; - } - - @Override - public Vec3 getRenderingPosition() { - return this.renderingvec; - } - - @Override - public double getPartialFrame() { - return this.partialFrame; - } - - public boolean isTimeElapsed(long time){ - return System.currentTimeMillis() - this.timeLastUpdate >= time; - } - - public void resetTimer(){ - this.timeLastUpdate = System.currentTimeMillis(); - } - -} diff --git a/src/main/java/mcp/mobius/waila/api/impl/MetaDataProvider.java b/src/main/java/mcp/mobius/waila/api/impl/MetaDataProvider.java index ff36f15..223e048 100644 --- a/src/main/java/mcp/mobius/waila/api/impl/MetaDataProvider.java +++ b/src/main/java/mcp/mobius/waila/api/impl/MetaDataProvider.java @@ -35,7 +35,7 @@ public class MetaDataProvider{ private Class prevBlock = null; private Class prevTile = null; - public ItemStack identifyBlockHighlight(World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorBlock accessor) { + public ItemStack identifyBlockHighlight(World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorCommon accessor) { Block block = accessor.getBlock(); int blockID = accessor.getBlockID(); @@ -61,7 +61,7 @@ public class MetaDataProvider{ return null; } - public List handleBlockTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorBlock accessor, List currenttip, Layout layout) { + public List handleBlockTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorCommon accessor, List currenttip, Layout layout) { Block block = accessor.getBlock(); if (accessor.getTileEntity() != null && Waila.instance.serverPresent && accessor.isTimeElapsed(250)){ @@ -164,7 +164,7 @@ public class MetaDataProvider{ return currenttip; } - public List handleEntityTextData(Entity entity, World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorEntity accessor, List currenttip, Layout layout) { + public List handleEntityTextData(Entity entity, World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorCommon accessor, List currenttip, Layout layout) { if (accessor.getEntity() != null && Waila.instance.serverPresent && accessor.isTimeElapsed(250)){ accessor.resetTimer(); diff --git a/src/main/java/mcp/mobius/waila/network/Message0x02TENBTData.java b/src/main/java/mcp/mobius/waila/network/Message0x02TENBTData.java index 67cf0fe..263808b 100644 --- a/src/main/java/mcp/mobius/waila/network/Message0x02TENBTData.java +++ b/src/main/java/mcp/mobius/waila/network/Message0x02TENBTData.java @@ -1,6 +1,6 @@ package mcp.mobius.waila.network; -import mcp.mobius.waila.api.impl.DataAccessorBlock; +import mcp.mobius.waila.api.impl.DataAccessorCommon; import mcp.mobius.waila.utils.WailaExceptionHandler; import net.minecraft.nbt.NBTTagCompound; import io.netty.buffer.ByteBuf; @@ -34,7 +34,7 @@ public class Message0x02TENBTData extends SimpleChannelInboundHandler 0) return ents.get(0); @@ -142,13 +141,13 @@ public class RayTracing { if (mouseoverBlock == null) return items; if (ModuleRegistrar.instance().hasStackProviders(mouseoverBlock)){ - ItemStack providerStack = ModuleRegistrar.instance().getStackProviders(mouseoverBlock).get(0).getWailaStack(DataAccessorBlock.instance, ConfigHandler.instance()); + ItemStack providerStack = ModuleRegistrar.instance().getStackProviders(mouseoverBlock).get(0).getWailaStack(DataAccessorCommon.instance, ConfigHandler.instance()); if (providerStack != null) items.add(providerStack); } if (tileEntity != null && ModuleRegistrar.instance().hasStackProviders(tileEntity)){ - ItemStack providerStack = ModuleRegistrar.instance().getStackProviders(tileEntity).get(0).getWailaStack(DataAccessorBlock.instance, ConfigHandler.instance()); + ItemStack providerStack = ModuleRegistrar.instance().getStackProviders(tileEntity).get(0).getWailaStack(DataAccessorCommon.instance, ConfigHandler.instance()); if (providerStack != null) items.add(providerStack); } diff --git a/src/main/java/mcp/mobius/waila/overlay/Tooltip.java b/src/main/java/mcp/mobius/waila/overlay/Tooltip.java index bc315ea..3431ba3 100644 --- a/src/main/java/mcp/mobius/waila/overlay/Tooltip.java +++ b/src/main/java/mcp/mobius/waila/overlay/Tooltip.java @@ -14,9 +14,9 @@ import mcp.mobius.waila.api.IWailaCommonAccessor; import mcp.mobius.waila.api.IWailaDataAccessor; import mcp.mobius.waila.api.IWailaTooltipRenderer; import mcp.mobius.waila.api.impl.ConfigHandler; -import mcp.mobius.waila.api.impl.DataAccessorBlock; import mcp.mobius.waila.api.impl.DataAccessorCommon; import mcp.mobius.waila.api.impl.ModuleRegistrar; +import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderIcon; import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderString; import mcp.mobius.waila.utils.Constants; import static mcp.mobius.waila.api.SpecialChars.*; @@ -91,6 +91,7 @@ public class Tooltip { columnsPos.add(0); for (String s : textData){ + ArrayList line = new ArrayList(Arrays.asList(patternTab.split(s))); ArrayList size = new ArrayList(); for (String ss : line) @@ -138,6 +139,7 @@ public class Tooltip { String cs = lineMatcher.group(); Renderable renderable = null; Matcher renderMatcher = patternRender.matcher(cs); //We keep a matcher here to be able to check if we have a Renderer. Might be better to do a startWith + full matcher init after the check + Matcher iconMatcher = patternIcon.matcher(cs); if (renderMatcher.find()){ String renderName = renderMatcher.group("name"); @@ -146,7 +148,8 @@ public class Tooltip { if (renderer != null){ renderable = new Renderable(renderer, new Point(offsetX, offsetY), renderMatcher.group("args").split(",")); } - + } else if (iconMatcher.find()){ + renderable = new Renderable(new TTRenderIcon(iconMatcher.group("type")), new Point(offsetX, offsetY)); } else { // Todo : The added offset should be based on the remaining of the column, not just the current string ! if (cs.startsWith(ALIGNRIGHT)) @@ -196,13 +199,13 @@ public class Tooltip { ty = (h - this.getRenderableTotalHeight())/2; } - public void drawStrings(){ + public void draw(){ for (Renderable r : this.elements) r.draw(accessor, x + offsetX, y + ty); } - - public void drawIcons(){ + /* + public void drawIcons(){ for (int i = 0; i < lines.size(); i++){ for (int c = 0; c < lines.get(i).ncolumns; c++){ int offX = 0; @@ -222,6 +225,6 @@ public class Tooltip { } } } - */ - } + } + */ } diff --git a/src/main/java/mcp/mobius/waila/overlay/WailaTickHandler.java b/src/main/java/mcp/mobius/waila/overlay/WailaTickHandler.java index 58a7b2d..35de0dc 100644 --- a/src/main/java/mcp/mobius/waila/overlay/WailaTickHandler.java +++ b/src/main/java/mcp/mobius/waila/overlay/WailaTickHandler.java @@ -5,8 +5,7 @@ import java.util.List; import org.lwjgl.input.Keyboard; import mcp.mobius.waila.api.impl.ConfigHandler; -import mcp.mobius.waila.api.impl.DataAccessorBlock; -import mcp.mobius.waila.api.impl.DataAccessorEntity; +import mcp.mobius.waila.api.impl.DataAccessorCommon; import mcp.mobius.waila.api.impl.MetaDataProvider; import mcp.mobius.waila.api.impl.TipList; import mcp.mobius.waila.client.KeyEvent; @@ -71,7 +70,7 @@ public class WailaTickHandler{ MovingObjectPosition target = RayTracing.instance().getTarget(); if (target != null && target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK){ - DataAccessorBlock accessor = DataAccessorBlock.instance; + DataAccessorCommon accessor = DataAccessorCommon.instance; accessor.set(world, player, target); ItemStack targetStack = RayTracing.instance().getTargetStack(); // Here we get either the proper stack or the override @@ -100,7 +99,7 @@ public class WailaTickHandler{ } } else if (target != null && target.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY){ - DataAccessorEntity accessor = DataAccessorEntity.instance; + DataAccessorCommon accessor = DataAccessorCommon.instance; accessor.set(world, player, target); Entity targetEnt = RayTracing.instance().getTargetEntity(); // This need to be replaced by the override check. diff --git a/src/main/java/mcp/mobius/waila/overlay/tooltiprenderers/TTRenderIcon.java b/src/main/java/mcp/mobius/waila/overlay/tooltiprenderers/TTRenderIcon.java index 4d42e05..24679c3 100644 --- a/src/main/java/mcp/mobius/waila/overlay/tooltiprenderers/TTRenderIcon.java +++ b/src/main/java/mcp/mobius/waila/overlay/tooltiprenderers/TTRenderIcon.java @@ -2,19 +2,31 @@ package mcp.mobius.waila.overlay.tooltiprenderers; import java.awt.Dimension; +import org.lwjgl.opengl.GL11; + import mcp.mobius.waila.api.IWailaCommonAccessor; import mcp.mobius.waila.api.IWailaDataAccessor; import mcp.mobius.waila.api.IWailaTooltipRenderer; +import mcp.mobius.waila.overlay.OverlayRenderer; +import mcp.mobius.waila.overlay.IconUI; public class TTRenderIcon implements IWailaTooltipRenderer { + final String type; + final int IconSize = 8; + + public TTRenderIcon(String type){ + this.type = type; + } + @Override public Dimension getSize(String[] params, IWailaCommonAccessor accessor) { - return null; + return new Dimension(IconSize, IconSize); } @Override public void draw(String[] params, IWailaCommonAccessor accessor, int x, int y) { + OverlayRenderer.renderIcon(x, y, IconSize, IconSize, IconUI.bySymbol(type)); } }