use of net.minecraft.nbt.NbtElement in project Hypnotic-Client by Hypnotic-Development.
the class Nametags method drawInv.
private void drawInv(LivingEntity player, float posX, float posY, EventRenderGUI eventRender2D) {
int itemWidth = 16;
int totalCount = getItems(player).size();
float startX = (posX - ((totalCount * itemWidth) / 2.f));
posY = (posY - 28);
count = 0;
for (ItemStack itemStack : getItems(player)) {
if (!(itemStack.getItem() instanceof AirBlockItem)) {
float newX = startX + (count * 16);
RenderUtils.drawItem(itemStack, newX, posY);
if (itemStack.hasEnchantments()) {
float scale = 0.5f;
MatrixStack matrixStack = eventRender2D.getMatrices();
matrixStack.push();
matrixStack.scale(scale, scale, 1);
int enchCount = 1;
for (NbtElement tag : itemStack.getEnchantments()) {
try {
NbtCompound compoundTag = (NbtCompound) tag;
float newY = ((posY - ((10 * scale) * enchCount) + 0.5f) / scale);
float newerX = (newX / scale);
String name = getEnchantName(compoundTag);
float nameWidth = font.getStringWidth(name);
RenderUtils.fill(eventRender2D.getMatrices(), newerX, newY - 1, newerX + nameWidth, newY + 9, 0x35000000);
font.draw(eventRender2D.getMatrices(), name, newerX, newY - 3, -1);
enchCount++;
} catch (Exception ignored) {
}
}
matrixStack.pop();
}
count++;
}
}
}
Aggregations