mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-25 01:44:27 +00:00
Scripted & Linked Items now Rendering Images in Banners + Wall Banners
This commit is contained in:
1 parent
5dfe061bad
commit
aeee864bf7
2 files changed
+89
-9
No files matched your search
@@ -6,6 +6,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -14,14 +15,19 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.api.item.IItemCustomizable;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
import noppes.npcs.blocks.BlockBanner;
|
||||
import noppes.npcs.blocks.tiles.TileBanner;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
import noppes.npcs.client.model.blocks.banner.ModelBannerFloor;
|
||||
import noppes.npcs.client.model.blocks.banner.ModelBannerFloorFlag;
|
||||
import noppes.npcs.client.model.blocks.legacy.ModelLegacyBanner;
|
||||
import noppes.npcs.client.model.blocks.legacy.ModelLegacyBannerFlag;
|
||||
import noppes.npcs.client.renderer.ImageData;
|
||||
import noppes.npcs.config.ConfigClient;
|
||||
import noppes.npcs.constants.EnumBannerVariant;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
@@ -129,11 +135,44 @@ public class BlockBannerRenderer extends BlockRendererInterface{
|
||||
float f2 = 0.05f;
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
GL11.glScalef(f2, f2, f2);
|
||||
renderItemBanner(mc.renderEngine, iicon, -8, -8, false);
|
||||
IItemStack iItemStack = NpcAPI.Instance().getIItemStack(iicon);
|
||||
if (iItemStack instanceof IItemCustomizable) {
|
||||
IItemCustomizable custom = (IItemCustomizable) iItemStack;
|
||||
ImageData imageData = ClientCacheHandler.getImageData(custom.getTexture());
|
||||
if (imageData.imageLoaded()) {
|
||||
imageData.bindTexture();
|
||||
int color = custom.getColor();
|
||||
float[] colors = ColorUtil.hexToRGB(color);
|
||||
renderCustomItemInBanner(colors[0], colors[1], colors[2]);
|
||||
GL11.glColor3f(1.0f, 1.0f, 1.0f);
|
||||
} else {
|
||||
renderItemBanner(mc.renderEngine, iicon, -8, -8, false);
|
||||
}
|
||||
} else {
|
||||
renderItemBanner(mc.renderEngine, iicon, -8, -8, false);
|
||||
}
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void renderCustomItemInBanner(float red, float green, float blue) {
|
||||
// Ensure lighting isn't interfering
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
// Force the texture to use the current color
|
||||
GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA_F(red, green, blue, 1.0F);
|
||||
tessellator.addVertexWithUV(-8, 8, 0, 0, 1);
|
||||
tessellator.addVertexWithUV(8, 8, 0, 1, 1);
|
||||
tessellator.addVertexWithUV(8, -8, 0, 1, 0);
|
||||
tessellator.addVertexWithUV(-8, -8, 0, 0, 0);
|
||||
tessellator.draw();
|
||||
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
}
|
||||
|
||||
public void renderItemBanner(TextureManager txtMng, ItemStack item, int p_77015_4_, int p_77015_5_, boolean renderEffect)
|
||||
{
|
||||
Object object = item.getIconIndex();
|
||||
|
||||
Reference in new issue
Block a user