Search in sources :

Example 1 with ITagRender

use of com.builtbroken.mc.api.tile.client.ITagRender in project Engine by VoltzEngine-Project.

the class RenderTaggedTile method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f) {
    if (t != null) {
        if (t instanceof ITagRender && this.getPlayer().getDistance(t.xCoord, t.yCoord, t.zCoord) <= RendererLivingEntity.NAME_TAG_RANGE) {
            HashMap<String, Integer> tags = new HashMap<>();
            float height = ((ITagRender) t).addInformation(tags, this.getPlayer());
            EntityPlayer player = Minecraft.getMinecraft().thePlayer;
            if (player.ridingEntity == null) {
                MovingObjectPosition objectPosition = player.rayTrace(8, 1);
                if (objectPosition != null) {
                    boolean isLooking = false;
                    for (int h = 0; h < height; h++) {
                        if (objectPosition.blockX == t.xCoord && objectPosition.blockY == t.yCoord + h && objectPosition.blockZ == t.zCoord) {
                            isLooking = true;
                        }
                    }
                    if (isLooking) {
                        Iterator<Entry<String, Integer>> it = tags.entrySet().iterator();
                        int i = 0;
                        while (it.hasNext()) {
                            Entry<String, Integer> entry = it.next();
                            if (entry.getKey() != null) {
                                RenderUtility.renderFloatingText(entry.getKey(), new Pos(x, y, z).add(new Pos(0.5, i * 0.25f + height, 0.5f)), entry.getValue());
                            }
                            i++;
                        }
                    }
                }
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) ITagRender(com.builtbroken.mc.api.tile.client.ITagRender) Entry(java.util.Map.Entry) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) Pos(com.builtbroken.mc.imp.transform.vector.Pos) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Aggregations

ITagRender (com.builtbroken.mc.api.tile.client.ITagRender)1 Pos (com.builtbroken.mc.imp.transform.vector.Pos)1 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)1