mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 09:55:11 +00:00
Custom Item NBT Renderers for TileColorable for Block Picking its NBT Colors
This commit is contained in:
1 parent
768f494631
commit
a2d4c4fd5a
17 files changed
+513
-158
No files matched your search
@@ -12,10 +12,12 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
@@ -25,6 +27,7 @@ import noppes.npcs.blocks.tiles.TileColorable;
|
||||
import java.util.List;
|
||||
|
||||
import static kamkeel.npcs.util.ColorUtil.colorTableInts;
|
||||
import static noppes.npcs.items.ItemNpcTool.BRUSH_COLOR_TAG;
|
||||
|
||||
public class BlockBanner extends BlockContainer{
|
||||
|
||||
@@ -94,6 +97,10 @@ public class BlockBanner extends BlockContainer{
|
||||
TileBanner tile = (TileBanner) par1World.getTileEntity(par2, par3, par4);
|
||||
tile.rotation = l;
|
||||
tile.color = colorTableInts[15 - par6ItemStack.getItemDamage()];
|
||||
if(par6ItemStack.hasTagCompound() && par6ItemStack.getTagCompound().hasKey(BRUSH_COLOR_TAG)){
|
||||
tile.color = par6ItemStack.getTagCompound().getInteger(BRUSH_COLOR_TAG);
|
||||
}
|
||||
|
||||
tile.time = System.currentTimeMillis();
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
|
||||
@@ -156,4 +163,23 @@ public class BlockBanner extends BlockContainer{
|
||||
else if (p_149681_5_ < 7 && p_149681_1_.getBlock(p_149681_2_, p_149681_3_ + 1, p_149681_4_) == this)
|
||||
p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ + 1, p_149681_4_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if(meta >= 7)
|
||||
y--;
|
||||
|
||||
TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
ItemStack stack = new ItemStack(this, 1, world.getBlockMetadata(x, y, z));
|
||||
if (tileentity instanceof TileBanner) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tileentity.writeToNBT(compound);
|
||||
|
||||
NBTTagCompound brushCompound = new NBTTagCompound();
|
||||
brushCompound.setInteger(BRUSH_COLOR_TAG, compound.getInteger(BRUSH_COLOR_TAG));
|
||||
stack.setTagCompound(brushCompound);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
@@ -13,10 +13,12 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.blocks.tiles.TileColorable;
|
||||
@@ -25,6 +27,7 @@ import noppes.npcs.blocks.tiles.TileCouchWool;
|
||||
import java.util.List;
|
||||
|
||||
import static kamkeel.npcs.util.ColorUtil.colorTableInts;
|
||||
import static noppes.npcs.items.ItemNpcTool.BRUSH_COLOR_TAG;
|
||||
|
||||
public class BlockCouchWool extends BlockContainer {
|
||||
|
||||
@@ -75,15 +78,18 @@ public class BlockCouchWool extends BlockContainer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack itemStack)
|
||||
{
|
||||
int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
l %= 4;
|
||||
TileCouchWool tile = (TileCouchWool) par1World.getTileEntity(par2, par3, par4);
|
||||
tile.rotation = l;
|
||||
tile.color = colorTableInts[15 - par6ItemStack.getItemDamage()];
|
||||
tile.color = colorTableInts[15 - itemStack.getItemDamage()];
|
||||
if(itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey(BRUSH_COLOR_TAG)){
|
||||
tile.color = itemStack.getTagCompound().getInteger(BRUSH_COLOR_TAG);
|
||||
}
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2);
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, itemStack.getItemDamage(), 2);
|
||||
updateModel(par1World, par2, par3, par4, tile);
|
||||
onNeighborBlockChange(par1World, par2 + 1, par3, par4, this);
|
||||
onNeighborBlockChange(par1World, par2 - 1, par3, par4, this);
|
||||
@@ -192,4 +198,18 @@ public class BlockCouchWool extends BlockContainer {
|
||||
return new TileCouchWool();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
|
||||
TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
ItemStack stack = new ItemStack(this, 1, world.getBlockMetadata(x, y, z));
|
||||
if (tileentity instanceof TileCouchWool) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tileentity.writeToNBT(compound);
|
||||
|
||||
NBTTagCompound brushCompound = new NBTTagCompound();
|
||||
brushCompound.setInteger(BRUSH_COLOR_TAG, compound.getInteger(BRUSH_COLOR_TAG));
|
||||
stack.setTagCompound(brushCompound);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
@@ -12,19 +12,23 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.blocks.tiles.TileColorable;
|
||||
import noppes.npcs.blocks.tiles.TileShortLamp;
|
||||
import noppes.npcs.blocks.tiles.TileTallLamp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static kamkeel.npcs.util.ColorUtil.colorTableInts;
|
||||
import static noppes.npcs.items.ItemNpcTool.BRUSH_COLOR_TAG;
|
||||
|
||||
public class BlockShortLamp extends BlockContainer {
|
||||
|
||||
@@ -81,6 +85,10 @@ public class BlockShortLamp extends BlockContainer {
|
||||
TileColorable tile = (TileColorable) world.getTileEntity(x, y, z);
|
||||
tile.rotation = l;
|
||||
tile.color = colorTableInts[15 - stack.getItemDamage()];
|
||||
if(stack.hasTagCompound() && stack.getTagCompound().hasKey(BRUSH_COLOR_TAG)){
|
||||
tile.color = stack.getTagCompound().getInteger(BRUSH_COLOR_TAG);
|
||||
}
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, stack.getItemDamage(), 2);
|
||||
}
|
||||
|
||||
@@ -133,4 +141,19 @@ public class BlockShortLamp extends BlockContainer {
|
||||
public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) {
|
||||
super.onBlockHarvested(world, x, y, z, meta, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
|
||||
TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
ItemStack stack = new ItemStack(this, 1, world.getBlockMetadata(x, y, z));
|
||||
if (tileentity instanceof TileShortLamp) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tileentity.writeToNBT(compound);
|
||||
|
||||
NBTTagCompound brushCompound = new NBTTagCompound();
|
||||
brushCompound.setInteger(BRUSH_COLOR_TAG, compound.getInteger(BRUSH_COLOR_TAG));
|
||||
stack.setTagCompound(brushCompound);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
@@ -12,19 +12,23 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.blocks.tiles.TileBanner;
|
||||
import noppes.npcs.blocks.tiles.TileColorable;
|
||||
import noppes.npcs.blocks.tiles.TileTallLamp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static kamkeel.npcs.util.ColorUtil.colorTableInts;
|
||||
import static noppes.npcs.items.ItemNpcTool.BRUSH_COLOR_TAG;
|
||||
|
||||
public class BlockTallLamp extends BlockContainer {
|
||||
|
||||
@@ -90,8 +94,11 @@ public class BlockTallLamp extends BlockContainer {
|
||||
TileColorable tile = (TileColorable) par1World.getTileEntity(par2, par3, par4);
|
||||
tile.rotation = l;
|
||||
tile.color = colorTableInts[15 - par6ItemStack.getItemDamage()];
|
||||
if(par6ItemStack.hasTagCompound() && par6ItemStack.getTagCompound().hasKey(BRUSH_COLOR_TAG)){
|
||||
tile.color = par6ItemStack.getTagCompound().getInteger(BRUSH_COLOR_TAG);
|
||||
}
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
|
||||
par1World.setBlock(par2, par3 + 1, par4, this, par6ItemStack.getItemDamage() + 7, 2);
|
||||
}
|
||||
}
|
||||
@@ -157,4 +164,23 @@ public class BlockTallLamp extends BlockContainer {
|
||||
else if (p_149681_5_ < 7 && p_149681_1_.getBlock(p_149681_2_, p_149681_3_ + 1, p_149681_4_) == this)
|
||||
p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ + 1, p_149681_4_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if(meta >= 7)
|
||||
y--;
|
||||
|
||||
TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
ItemStack stack = new ItemStack(this, 1, world.getBlockMetadata(x, y, z));
|
||||
if (tileentity instanceof TileTallLamp) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tileentity.writeToNBT(compound);
|
||||
|
||||
NBTTagCompound brushCompound = new NBTTagCompound();
|
||||
brushCompound.setInteger(BRUSH_COLOR_TAG, compound.getInteger(BRUSH_COLOR_TAG));
|
||||
stack.setTagCompound(brushCompound);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
@@ -12,19 +12,19 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.blocks.tiles.TileColorable;
|
||||
import noppes.npcs.blocks.tiles.TileCouchWool;
|
||||
import noppes.npcs.blocks.tiles.TileWallBanner;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static kamkeel.npcs.util.ColorUtil.colorTableInts;
|
||||
import static noppes.npcs.items.ItemNpcTool.BRUSH_COLOR_TAG;
|
||||
|
||||
public class BlockWallBanner extends BlockContainer{
|
||||
|
||||
@@ -61,6 +61,10 @@ public class BlockWallBanner extends BlockContainer{
|
||||
TileWallBanner tile = (TileWallBanner) par1World.getTileEntity(par2, par3, par4);
|
||||
tile.rotation = l;
|
||||
tile.color = colorTableInts[15 - par6ItemStack.getItemDamage()];
|
||||
if(par6ItemStack.hasTagCompound() && par6ItemStack.getTagCompound().hasKey(BRUSH_COLOR_TAG)){
|
||||
tile.color = par6ItemStack.getTagCompound().getInteger(BRUSH_COLOR_TAG);
|
||||
}
|
||||
|
||||
tile.time = System.currentTimeMillis();
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2);
|
||||
@@ -130,4 +134,19 @@ public class BlockWallBanner extends BlockContainer{
|
||||
public TileEntity createNewTileEntity(World var1, int var2) {
|
||||
return new TileWallBanner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
|
||||
TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
ItemStack stack = new ItemStack(this, 1, world.getBlockMetadata(x, y, z));
|
||||
if (tileentity instanceof TileWallBanner) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tileentity.writeToNBT(compound);
|
||||
|
||||
NBTTagCompound brushCompound = new NBTTagCompound();
|
||||
brushCompound.setInteger(BRUSH_COLOR_TAG, compound.getInteger(BRUSH_COLOR_TAG));
|
||||
stack.setTagCompound(brushCompound);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
@@ -58,9 +58,7 @@ import noppes.npcs.client.gui.script.GuiScriptItem;
|
||||
import noppes.npcs.client.model.*;
|
||||
import noppes.npcs.client.renderer.*;
|
||||
import noppes.npcs.client.renderer.blocks.*;
|
||||
import noppes.npcs.client.renderer.items.CustomItemRenderer;
|
||||
import noppes.npcs.client.renderer.items.NpcItemToolRenderer;
|
||||
import noppes.npcs.client.renderer.items.ScriptedBlockItemRenderer;
|
||||
import noppes.npcs.client.renderer.items.*;
|
||||
import noppes.npcs.config.ConfigClient;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.config.StringCache;
|
||||
@@ -138,6 +136,13 @@ public class ClientProxy extends CommonProxy {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileBook.class, new BlockBookRenderer());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TilePedestal.class, new BlockPedestalRenderer());
|
||||
RenderingRegistry.registerBlockHandler(new BlockBloodRenderer());
|
||||
|
||||
// Tile Item Renderers
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(CustomItems.couchWool), new ItemCouchWoolRenderer());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(CustomItems.banner), new ItemBannerRenderer());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(CustomItems.wallBanner), new ItemBannerWallRenderer());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(CustomItems.shortLamp), new ItemShortLampRenderer());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(CustomItems.tallLamp), new ItemTallLampRenderer());
|
||||
}
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
|
||||
@@ -27,11 +27,11 @@ import org.lwjgl.opengl.GL12;
|
||||
|
||||
public class BlockBannerRenderer extends BlockRendererInterface{
|
||||
|
||||
private final ModelLegacyBanner legacyBanner = new ModelLegacyBanner();
|
||||
private final ModelLegacyBannerFlag legacyFlag = new ModelLegacyBannerFlag();
|
||||
public static final ModelLegacyBanner legacyBanner = new ModelLegacyBanner();
|
||||
public static final ModelLegacyBannerFlag legacyFlag = new ModelLegacyBannerFlag();
|
||||
|
||||
private final ModelBannerFloor banner = new ModelBannerFloor();
|
||||
private final ModelBannerFloorFlag flag = new ModelBannerFloorFlag();
|
||||
public static final ModelBannerFloor banner = new ModelBannerFloor();
|
||||
public static final ModelBannerFloorFlag flag = new ModelBannerFloorFlag();
|
||||
|
||||
public static final ResourceLocation legacyFlagResource = new ResourceLocation("customnpcs","textures/models/legacy/banner.png");
|
||||
|
||||
@@ -183,35 +183,7 @@ public class BlockBannerRenderer extends BlockRendererInterface{
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId,
|
||||
RenderBlocks renderer) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0, 0.44f, 0);
|
||||
GL11.glScalef(0.76f, 0.66f, 0.76f);
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
GL11.glRotatef(180, 0, 1, 0);
|
||||
|
||||
if(ConfigClient.LegacyBanner){
|
||||
setMaterialTexture(metadata);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
legacyBanner.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
|
||||
this.bindTexture(legacyFlagResource);
|
||||
float[] color = ColorUtil.hexToRGB(ColorUtil.colorTableInts[15 - metadata]);
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
legacyFlag.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
}
|
||||
else {
|
||||
setBannerMaterial(metadata);
|
||||
banner.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
|
||||
this.bindTexture(normalFlag);
|
||||
float[] color = ColorUtil.hexToRGB(ColorUtil.colorTableInts[15 - metadata]);
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
flag.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
RenderBlocks renderer) {}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
|
||||
@@ -23,11 +23,11 @@ public class BlockCouchWoolRenderer extends BlockRendererInterface{
|
||||
private final ModelCouchLeft modelCouchLeft = new ModelCouchLeft();
|
||||
private final ModelCouchRight modelCouchRight = new ModelCouchRight();
|
||||
private final ModelCouchCorner modelCouchCorner = new ModelCouchCorner();
|
||||
private final ModelCouchMiddle modelCouch = new ModelCouchMiddle();
|
||||
public static final ModelCouchMiddle modelCouch = new ModelCouchMiddle();
|
||||
private final ModelCouchSingle modelCouchSingle = new ModelCouchSingle();
|
||||
|
||||
private final ModelBase modelLegacyCouchMiddle = new ModelLegacyCouchMiddle();
|
||||
private final ModelBase modelLegacyCouchMiddleWool = new ModelLegacyCouchMiddleWool();
|
||||
public static final ModelBase modelLegacyCouchMiddle = new ModelLegacyCouchMiddle();
|
||||
public static final ModelBase modelLegacyCouchMiddleWool = new ModelLegacyCouchMiddleWool();
|
||||
|
||||
private final ModelBase modelLegacyCouchLeft = new ModelLegacyCouchLeft();
|
||||
private final ModelBase modelLegacyCouchLeftWool = new ModelLegacyCouchLeftWool();
|
||||
@@ -39,14 +39,14 @@ public class BlockCouchWoolRenderer extends BlockRendererInterface{
|
||||
private final ModelBase modelLegacyCouchCornerWool = new ModelLegacyCouchCornerWool();
|
||||
|
||||
|
||||
private static final ResourceLocation oak = new ResourceLocation("customnpcs","textures/models/couch/oak.png");
|
||||
private static final ResourceLocation spruce = new ResourceLocation("customnpcs","textures/models/couch/spruce.png");
|
||||
private static final ResourceLocation birch = new ResourceLocation("customnpcs","textures/models/couch/birch.png");
|
||||
private static final ResourceLocation jungle = new ResourceLocation("customnpcs","textures/models/couch/jungle.png");
|
||||
private static final ResourceLocation acacia = new ResourceLocation("customnpcs","textures/models/couch/acacia.png");
|
||||
private static final ResourceLocation dark_oak = new ResourceLocation("customnpcs","textures/models/couch/dark_oak.png");
|
||||
public static final ResourceLocation oak = new ResourceLocation("customnpcs","textures/models/couch/oak.png");
|
||||
public static final ResourceLocation spruce = new ResourceLocation("customnpcs","textures/models/couch/spruce.png");
|
||||
public static final ResourceLocation birch = new ResourceLocation("customnpcs","textures/models/couch/birch.png");
|
||||
public static final ResourceLocation jungle = new ResourceLocation("customnpcs","textures/models/couch/jungle.png");
|
||||
public static final ResourceLocation acacia = new ResourceLocation("customnpcs","textures/models/couch/acacia.png");
|
||||
public static final ResourceLocation dark_oak = new ResourceLocation("customnpcs","textures/models/couch/dark_oak.png");
|
||||
|
||||
private static final ResourceLocation wool = new ResourceLocation("customnpcs","textures/models/couch/wool.png");
|
||||
public static final ResourceLocation wool = new ResourceLocation("customnpcs","textures/models/couch/wool.png");
|
||||
|
||||
public BlockCouchWoolRenderer(){
|
||||
((BlockCouchWool)CustomItems.couchWool).renderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
@@ -139,26 +139,6 @@ public class BlockCouchWoolRenderer extends BlockRendererInterface{
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId,
|
||||
RenderBlocks renderer) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0, 0.9f, 0.1f);
|
||||
GL11.glScalef(0.9f, 0.9f, 0.9f);
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
GL11.glRotatef(180, 0, 1, 0);
|
||||
|
||||
setWoodTexture(metadata);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
modelLegacyCouchMiddle.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
|
||||
this.bindTexture(BlockTallLampRenderer.resourceTop);
|
||||
float[] color = ColorUtil.hexToRGB(ColorUtil.colorTableInts[15 - metadata]);
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
modelLegacyCouchMiddleWool.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void setCouchWood(int meta){
|
||||
TextureManager manager = Minecraft.getMinecraft().getTextureManager();
|
||||
if(meta == 1)
|
||||
@@ -175,7 +155,10 @@ public class BlockCouchWoolRenderer extends BlockRendererInterface{
|
||||
manager.bindTexture(oak);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return CustomItems.couchWool.getRenderType();
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public abstract class BlockRendererInterface extends TileEntitySpecialRenderer i
|
||||
public int specialRenderDistance(){
|
||||
return 20;
|
||||
}
|
||||
public void setWoodTexture(int meta){
|
||||
public static void setWoodTexture(int meta){
|
||||
TextureManager manager = Minecraft.getMinecraft().getTextureManager();
|
||||
if(meta == 1)
|
||||
manager.bindTexture(PlanksSpruce);
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.lwjgl.opengl.GL12;
|
||||
|
||||
public class BlockShortLampRenderer extends BlockRendererInterface {
|
||||
|
||||
private final ModelShortLamp model = new ModelShortLamp();
|
||||
public static final ModelShortLamp model = new ModelShortLamp();
|
||||
|
||||
public static final ResourceLocation wood = new ResourceLocation("customnpcs","textures/models/lamp/short/wood.png");
|
||||
public static final ResourceLocation stone = new ResourceLocation("customnpcs","textures/models/lamp/short/stone.png");
|
||||
@@ -65,25 +65,9 @@ public class BlockShortLampRenderer extends BlockRendererInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
GL11.glPushMatrix();
|
||||
// Adjust transformation for inventory rendering.
|
||||
GL11.glTranslatef(0, 0.42f, 0);
|
||||
GL11.glScalef(0.76f, 0.76f, 0.76f);
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
GL11.glRotatef(180, 0, 1, 0);
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {}
|
||||
|
||||
setLampTexture(metadata);
|
||||
model.Lamp.render(0.0625F);
|
||||
model.Light.render(0.0625F);
|
||||
float[] color = ColorUtil.hexToRGB(ColorUtil.colorTableInts[15 - metadata]);
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
model.Shade.render(0.0625F);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void setLampTexture(int meta){
|
||||
public static void setLampTexture(int meta){
|
||||
TextureManager manager = Minecraft.getMinecraft().getTextureManager();
|
||||
if(meta == 1)
|
||||
manager.bindTexture(stone);
|
||||
|
||||
@@ -21,12 +21,12 @@ import org.lwjgl.opengl.GL12;
|
||||
|
||||
public class BlockTallLampRenderer extends BlockRendererInterface{
|
||||
|
||||
private final ModelLegacyTallLamp modelLegacy = new ModelLegacyTallLamp();
|
||||
private final ModelLegacyTallLampTop topLegacy = new ModelLegacyTallLampTop();
|
||||
public static final ModelLegacyTallLamp modelLegacy = new ModelLegacyTallLamp();
|
||||
public static final ModelLegacyTallLampTop topLegacy = new ModelLegacyTallLampTop();
|
||||
public static final ResourceLocation resourceTop = new ResourceLocation("customnpcs","textures/cache/wool_colored_white.png");
|
||||
|
||||
|
||||
private final ModelTallLamp model = new ModelTallLamp();
|
||||
public static final ModelTallLamp model = new ModelTallLamp();
|
||||
|
||||
public static final ResourceLocation wood = new ResourceLocation("customnpcs","textures/models/lamp/tall/wood.png");
|
||||
public static final ResourceLocation stone = new ResourceLocation("customnpcs","textures/models/lamp/tall/stone.png");
|
||||
@@ -85,34 +85,9 @@ public class BlockTallLampRenderer extends BlockRendererInterface{
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId,
|
||||
RenderBlocks renderer) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0, 0.42f, 0);
|
||||
GL11.glScalef(0.76f, 0.66f, 0.76f);
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
GL11.glRotatef(180, 0, 1, 0);
|
||||
if(ConfigClient.LegacyTallLamp){
|
||||
setMaterialTexture(metadata);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
modelLegacy.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
RenderBlocks renderer) {}
|
||||
|
||||
this.bindTexture(resourceTop);
|
||||
float[] color = ColorUtil.hexToRGB(ColorUtil.colorTableInts[15 - metadata]);
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
topLegacy.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
} else {
|
||||
setLampTexture(metadata);
|
||||
model.Lamp.render(0.0625F);
|
||||
model.Light.render(0.0625F);
|
||||
float[] color = ColorUtil.hexToRGB(ColorUtil.colorTableInts[15 - metadata]);
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
model.Shade.render(0.0625F);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void setLampTexture(int meta){
|
||||
public static void setLampTexture(int meta){
|
||||
TextureManager manager = Minecraft.getMinecraft().getTextureManager();
|
||||
if(meta == 1)
|
||||
manager.bindTexture(stone);
|
||||
|
||||
@@ -27,11 +27,11 @@ import org.lwjgl.opengl.GL12;
|
||||
|
||||
public class BlockWallBannerRenderer extends BlockRendererInterface{
|
||||
|
||||
private final ModelLegacyWallBanner modelLegacyWallBanner = new ModelLegacyWallBanner();
|
||||
private final ModelLegacyWallBannerFlag modelLegacyWallBannerFlag = new ModelLegacyWallBannerFlag();
|
||||
public static final ModelLegacyWallBanner modelLegacyWallBanner = new ModelLegacyWallBanner();
|
||||
public static final ModelLegacyWallBannerFlag modelLegacyWallBannerFlag = new ModelLegacyWallBannerFlag();
|
||||
|
||||
private final ModelBannerWall model = new ModelBannerWall();
|
||||
private final ModelBannerWallFlag flag = new ModelBannerWallFlag();
|
||||
public static final ModelBannerWall model = new ModelBannerWall();
|
||||
public static final ModelBannerWallFlag flag = new ModelBannerWallFlag();
|
||||
|
||||
public BlockWallBannerRenderer(){
|
||||
((BlockWallBanner)CustomItems.wallBanner).renderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
@@ -188,35 +188,7 @@ public class BlockWallBannerRenderer extends BlockRendererInterface{
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId,
|
||||
RenderBlocks renderer) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0, 0.26f, 0.3f);
|
||||
GL11.glScalef(0.95f, 0.85f, 0.95f);
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
GL11.glRotatef(180, 0, 1, 0);
|
||||
|
||||
if(ConfigClient.LegacyBanner){
|
||||
setMaterialTexture(metadata);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
modelLegacyWallBanner.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
|
||||
this.bindTexture(BlockBannerRenderer.legacyFlagResource);
|
||||
float[] color = ColorUtil.hexToRGB(ColorUtil.colorTableInts[15 - metadata]);
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
modelLegacyWallBannerFlag.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
}
|
||||
else {
|
||||
flag.BannerFlag.rotateAngleX = 0;
|
||||
BlockBannerRenderer.setBannerMaterial(metadata);
|
||||
model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
|
||||
this.bindTexture(BlockBannerRenderer.normalFlag);
|
||||
float[] color = ColorUtil.hexToRGB(ColorUtil.colorTableInts[15 - metadata]);
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
flag.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
RenderBlocks renderer) {}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package noppes.npcs.client.renderer.items;
|
||||
|
||||
import kamkeel.npcs.util.ColorUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import noppes.npcs.client.renderer.blocks.BlockBannerRenderer;
|
||||
import noppes.npcs.client.renderer.blocks.BlockShortLampRenderer;
|
||||
import noppes.npcs.config.ConfigClient;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class ItemBannerRenderer implements IItemRenderer {
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
int meta = item.getItemDamage();
|
||||
int colorValue = ColorUtil.colorTableInts[15 - meta];
|
||||
if (item.hasTagCompound() && item.getTagCompound().hasKey("BrushColor")) {
|
||||
colorValue = item.getTagCompound().getInteger("BrushColor");
|
||||
}
|
||||
float[] color = ColorUtil.hexToRGB(colorValue);
|
||||
|
||||
TextureManager manager = Minecraft.getMinecraft().getTextureManager();
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0, 0.44f, 0);
|
||||
GL11.glScalef(0.76f, 0.66f, 0.76f);
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
GL11.glRotatef(180, 0, 1, 0);
|
||||
|
||||
if(ConfigClient.LegacyBanner){
|
||||
BlockBannerRenderer.setMaterialTexture(meta);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
BlockBannerRenderer.legacyBanner.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
|
||||
manager.bindTexture(BlockBannerRenderer.legacyFlagResource);
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
BlockBannerRenderer.legacyFlag.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
}
|
||||
else {
|
||||
BlockBannerRenderer.setBannerMaterial(meta);
|
||||
BlockBannerRenderer.banner.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
|
||||
manager.bindTexture(BlockBannerRenderer.normalFlag);
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
BlockBannerRenderer.flag.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glPopAttrib();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package noppes.npcs.client.renderer.items;
|
||||
|
||||
import kamkeel.npcs.util.ColorUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import noppes.npcs.client.renderer.blocks.BlockBannerRenderer;
|
||||
import noppes.npcs.client.renderer.blocks.BlockWallBannerRenderer;
|
||||
import noppes.npcs.config.ConfigClient;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class ItemBannerWallRenderer implements IItemRenderer {
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
int meta = item.getItemDamage();
|
||||
int colorValue = ColorUtil.colorTableInts[15 - meta];
|
||||
if (item.hasTagCompound() && item.getTagCompound().hasKey("BrushColor")) {
|
||||
colorValue = item.getTagCompound().getInteger("BrushColor");
|
||||
}
|
||||
float[] color = ColorUtil.hexToRGB(colorValue);
|
||||
|
||||
TextureManager manager = Minecraft.getMinecraft().getTextureManager();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0, 0.26f, 0.3f);
|
||||
GL11.glScalef(0.95f, 0.85f, 0.95f);
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
GL11.glRotatef(180, 0, 1, 0);
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
if(ConfigClient.LegacyBanner){
|
||||
BlockWallBannerRenderer.setMaterialTexture(meta);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
BlockWallBannerRenderer.modelLegacyWallBanner.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
|
||||
manager.bindTexture(BlockBannerRenderer.legacyFlagResource);
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
BlockWallBannerRenderer.modelLegacyWallBannerFlag.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
}
|
||||
else {
|
||||
BlockWallBannerRenderer.flag.BannerFlag.rotateAngleX = 0;
|
||||
BlockBannerRenderer.setBannerMaterial(meta);
|
||||
BlockWallBannerRenderer.model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
|
||||
manager.bindTexture(BlockBannerRenderer.normalFlag);
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
BlockWallBannerRenderer.flag.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glPopAttrib();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package noppes.npcs.client.renderer.items;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import noppes.npcs.client.renderer.blocks.BlockCouchWoolRenderer;
|
||||
import noppes.npcs.client.renderer.blocks.BlockRendererInterface;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import noppes.npcs.client.renderer.blocks.BlockTallLampRenderer;
|
||||
import noppes.npcs.config.ConfigClient;
|
||||
import kamkeel.npcs.util.ColorUtil;
|
||||
|
||||
public class ItemCouchWoolRenderer implements IItemRenderer {
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
int meta = item.getItemDamage();
|
||||
int colorValue = ColorUtil.colorTableInts[15 - meta];
|
||||
if (item.hasTagCompound() && item.getTagCompound().hasKey("BrushColor")) {
|
||||
colorValue = item.getTagCompound().getInteger("BrushColor");
|
||||
}
|
||||
float[] color = ColorUtil.hexToRGB(colorValue);
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glTranslatef(0, 0.9f, 0.1f);
|
||||
GL11.glScalef(0.9f, 0.9f, 0.9f);
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
GL11.glRotatef(180, 0, 1, 0);
|
||||
|
||||
if (ConfigClient.LegacyCouch) {
|
||||
setWoodTexture(meta);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
BlockCouchWoolRenderer.modelLegacyCouchMiddle.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
|
||||
// Bind the top texture (for the wool overlay)
|
||||
mc.getTextureManager().bindTexture(BlockTallLampRenderer.resourceTop);
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
BlockCouchWoolRenderer.modelLegacyCouchMiddleWool.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
} else {
|
||||
setCouchWood(meta);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
// Render the main couch model (assumes modelCouch has parts CouchBack and Cussion)
|
||||
BlockCouchWoolRenderer.modelCouch.CouchBack.render(0.0625F);
|
||||
mc.getTextureManager().bindTexture(BlockCouchWoolRenderer.wool);
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
BlockCouchWoolRenderer. modelCouch.Cussion.render(0.0625F);
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glPopAttrib();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void setCouchWood(int meta) {
|
||||
TextureManager manager = Minecraft.getMinecraft().getTextureManager();
|
||||
if (meta == 1)
|
||||
manager.bindTexture(BlockCouchWoolRenderer.spruce);
|
||||
else if (meta == 2)
|
||||
manager.bindTexture(BlockCouchWoolRenderer.birch);
|
||||
else if (meta == 3)
|
||||
manager.bindTexture(BlockCouchWoolRenderer.jungle);
|
||||
else if (meta == 4)
|
||||
manager.bindTexture(BlockCouchWoolRenderer.acacia);
|
||||
else if (meta == 5)
|
||||
manager.bindTexture(BlockCouchWoolRenderer.dark_oak);
|
||||
else
|
||||
manager.bindTexture(BlockCouchWoolRenderer.oak);
|
||||
}
|
||||
|
||||
private void setWoodTexture(int meta) {
|
||||
BlockRendererInterface.setWoodTexture(meta);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package noppes.npcs.client.renderer.items;
|
||||
|
||||
import kamkeel.npcs.util.ColorUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import noppes.npcs.client.renderer.blocks.BlockRendererInterface;
|
||||
import noppes.npcs.client.renderer.blocks.BlockShortLampRenderer;
|
||||
import noppes.npcs.client.renderer.blocks.BlockTallLampRenderer;
|
||||
import noppes.npcs.config.ConfigClient;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class ItemShortLampRenderer implements IItemRenderer {
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
int meta = item.getItemDamage();
|
||||
int colorValue = ColorUtil.colorTableInts[15 - meta];
|
||||
if (item.hasTagCompound() && item.getTagCompound().hasKey("BrushColor")) {
|
||||
colorValue = item.getTagCompound().getInteger("BrushColor");
|
||||
}
|
||||
float[] color = ColorUtil.hexToRGB(colorValue);
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
// Adjust transformation for inventory rendering.
|
||||
GL11.glTranslatef(0, 0.42f, 0);
|
||||
GL11.glScalef(0.76f, 0.76f, 0.76f);
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
GL11.glRotatef(180, 0, 1, 0);
|
||||
|
||||
BlockShortLampRenderer.setLampTexture(meta);
|
||||
BlockShortLampRenderer.model.Lamp.render(0.0625F);
|
||||
BlockShortLampRenderer.model.Light.render(0.0625F);
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
BlockShortLampRenderer.model.Shade.render(0.0625F);
|
||||
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glPopAttrib();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package noppes.npcs.client.renderer.items;
|
||||
|
||||
import kamkeel.npcs.util.ColorUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import noppes.npcs.client.renderer.blocks.BlockCouchWoolRenderer;
|
||||
import noppes.npcs.client.renderer.blocks.BlockRendererInterface;
|
||||
import noppes.npcs.client.renderer.blocks.BlockTallLampRenderer;
|
||||
import noppes.npcs.config.ConfigClient;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class ItemTallLampRenderer implements IItemRenderer {
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
int meta = item.getItemDamage();
|
||||
int colorValue = ColorUtil.colorTableInts[15 - meta];
|
||||
if (item.hasTagCompound() && item.getTagCompound().hasKey("BrushColor")) {
|
||||
colorValue = item.getTagCompound().getInteger("BrushColor");
|
||||
}
|
||||
float[] color = ColorUtil.hexToRGB(colorValue);
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0, 0.42f, 0);
|
||||
GL11.glScalef(0.76f, 0.66f, 0.76f);
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
GL11.glRotatef(180, 0, 1, 0);
|
||||
|
||||
TextureManager manager = Minecraft.getMinecraft().getTextureManager();
|
||||
if(ConfigClient.LegacyTallLamp){
|
||||
BlockRendererInterface.setMaterialTexture(meta);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
BlockTallLampRenderer.modelLegacy.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
|
||||
manager.bindTexture(BlockTallLampRenderer.resourceTop);
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
BlockTallLampRenderer.topLegacy.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
} else {
|
||||
BlockTallLampRenderer.setLampTexture(meta);
|
||||
BlockTallLampRenderer.model.Lamp.render(0.0625F);
|
||||
BlockTallLampRenderer.model.Light.render(0.0625F);
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
BlockTallLampRenderer. model.Shade.render(0.0625F);
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glPopAttrib();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user