Updated Tall Lamp + New Short Lamp

This commit is contained in:
Kam committed 2025-02-12 21:44:14 -05:00
1 parent 6d61c64cb6
commit 0dfcae05f4
22 files changed
+518 -58

No files matched your search

@@ -0,0 +1,135 @@
package noppes.npcs.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockColored;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
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 java.util.List;
public class BlockShortLamp extends BlockContainer {
public int renderId = -1;
public BlockShortLamp() {
super(Material.wood);
setLightLevel(1);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player,
int side, float hitX, float hitY, float hitZ) {
ItemStack item = player.inventory.getCurrentItem();
if (item == null || item.getItem() != Items.dye)
return false;
int meta = world.getBlockMetadata(x, y, z);
TileColorable tile = (TileColorable) world.getTileEntity(x, y, z);
int color = BlockColored.func_150031_c(item.getItemDamage());
if (tile.color != color) {
NoppesUtilServer.consumeItemStack(1, player);
tile.color = color;
world.markBlockForUpdate(x, y, z);
}
return true;
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
setBlockBoundsBasedOnState(world, x, y, z);
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
}
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
list.add(new ItemStack(item, 1, 0));
list.add(new ItemStack(item, 1, 1));
list.add(new ItemStack(item, 1, 2));
list.add(new ItemStack(item, 1, 3));
list.add(new ItemStack(item, 1, 4));
}
@Override
public int damageDropped(int meta) {
return meta;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z,
EntityLivingBase entity, ItemStack stack) {
int l = MathHelper.floor_double((double)(entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
l %= 4;
TileColorable tile = (TileColorable) world.getTileEntity(x, y, z);
tile.rotation = l;
tile.color = 15 - stack.getItemDamage();
world.setBlockMetadataWithNotify(x, y, z, stack.getItemDamage(), 2);
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
// Always one block tall.
setBlockBounds(0, 0, 0, 1, 1, 1);
}
@Override
public boolean isOpaqueCube(){
return false;
}
@Override
public boolean renderAsNormalBlock(){
return false;
}
@Override
public int getRenderType(){
return renderId;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
// Optional icon registration
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
if(meta == 1)
return Blocks.stone.getIcon(side, 0);
else if(meta == 2)
return Blocks.iron_block.getIcon(side, 0);
else if(meta == 3)
return Blocks.gold_block.getIcon(side, 0);
else if(meta == 4)
return Blocks.diamond_block.getIcon(side, 0);
return Blocks.planks.getIcon(side, 0);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileShortLamp();
}
@Override
public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) {
super.onBlockHarvested(world, x, y, z, meta, player);
}
}
@@ -25,8 +25,8 @@ import noppes.npcs.blocks.tiles.TileTallLamp;
import java.util.List;
public class BlockTallLamp extends BlockContainer{
public class BlockTallLamp extends BlockContainer {
public int renderId = -1;
public BlockTallLamp() {
@@ -34,7 +34,7 @@ public class BlockTallLamp extends BlockContainer{
setBlockBounds(0, 0, 0, 1, 2, 1);
setLightLevel(1);
}
@Override
@Override
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){
ItemStack item = player.inventory.getCurrentItem();
if(item == null || item.getItem() != Items.dye)
@@ -56,7 +56,7 @@ public class BlockTallLamp extends BlockContainer{
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
}
@Override
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){
par3List.add(new ItemStack(par1, 1, 0));
par3List.add(new ItemStack(par1, 1, 1));
@@ -65,32 +65,37 @@ public class BlockTallLamp extends BlockContainer{
par3List.add(new ItemStack(par1, 1, 4));
}
@Override
@Override
public int damageDropped(int par1){
return par1 % 7;
}
@Override
@Override
public boolean canPlaceBlockAt(World world, int x, int y, int z) {
return super.canPlaceBlockAt(world, x, y, z) && world.isAirBlock(x, y + 1, z);
}
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
{
if(!par1World.isAirBlock(par2, par3 + 1, par4)){
par1World.setBlockToAir(par2, par3, par4);
}
else{
int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
l %= 4;
TileColorable tile = (TileColorable) par1World.getTileEntity(par2, par3, par4);
tile.rotation = l;
tile.color = 15 - par6ItemStack.getItemDamage();
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
par1World.setBlock(par2, par3 + 1, par4, this, par6ItemStack.getItemDamage() + 7, 2);
}
}
@Override
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){
int meta = world.getBlockMetadata(x, y, z);
if(meta >= 7)
@@ -99,26 +104,24 @@ public class BlockTallLamp extends BlockContainer{
setBlockBounds(0, 0, 0, 1, 2, 1);
}
@Override
@Override
public boolean isOpaqueCube(){
return false;
}
@Override
@Override
public boolean renderAsNormalBlock(){
return false;
}
@Override
@Override
public int getRenderType(){
return renderId;
return renderId;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister par1IconRegister)
{
}
{}
@Override
@SideOnly(Side.CLIENT)
@@ -149,7 +152,7 @@ public class BlockTallLamp extends BlockContainer{
{
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_);
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_);
}
@@ -0,0 +1,3 @@
package noppes.npcs.blocks.tiles;
public class TileShortLamp extends TileColorable { }
@@ -108,6 +108,7 @@ public class ClientProxy extends CommonProxy {
ClientRegistry.bindTileEntitySpecialRenderer(TileBanner.class, new BlockBannerRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileWallBanner.class, new BlockWallBannerRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileTallLamp.class, new BlockTallLampRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileShortLamp.class, new BlockShortLampRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileChair.class, new BlockChairRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileWeaponRack.class, new BlockWeaponRackRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileCrate.class, new BlockCrateRenderer());
@@ -0,0 +1,78 @@
package noppes.npcs.client.model.blocks.lamp;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBox;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
public class ModelShortLamp extends ModelBase {
public final ModelRenderer Shade;
private final ModelRenderer cube_r1;
private final ModelRenderer cube_r2;
public final ModelRenderer Lamp;
private final ModelRenderer cube_r3;
private final ModelRenderer cube_r4;
private final ModelRenderer cube_r5;
public final ModelRenderer Light;
public ModelShortLamp() {
textureWidth = 64;
textureHeight = 64;
Shade = new ModelRenderer(this);
Shade.setRotationPoint(-4.0F, 12.0F, 0.0F);
Shade.cubeList.add(new ModelBox(Shade, 0, 8, 0.0F, -4.0F, -4.0F, 8, 8, 0, 0.0F));
Shade.cubeList.add(new ModelBox(Shade, -8, 0, 0.0F, -4.0F, -4.0F, 8, 0, 8, 0.0F));
Shade.cubeList.add(new ModelBox(Shade, 0, 8, 0.0F, -4.0F, 4.0F, 8, 8, 0, 0.0F));
cube_r1 = new ModelRenderer(this);
cube_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
Shade.addChild(cube_r1);
setRotationAngle(cube_r1, 0.0F, 1.5708F, 0.0F);
cube_r1.cubeList.add(new ModelBox(cube_r1, 0, 8, -4.0F, -4.0F, 0.0F, 8, 8, 0, 0.0F));
cube_r2 = new ModelRenderer(this);
cube_r2.setRotationPoint(8.0F, 0.0F, 0.0F);
Shade.addChild(cube_r2);
setRotationAngle(cube_r2, 0.0F, 1.5708F, 0.0F);
cube_r2.cubeList.add(new ModelBox(cube_r2, 0, 8, -4.0F, -4.0F, 0.0F, 8, 8, 0, 0.0F));
Lamp = new ModelRenderer(this);
Lamp.setRotationPoint(0.0F, 24.0F, 0.0F);
Lamp.cubeList.add(new ModelBox(Lamp, 28, 8, -3.0F, -6.0F, -3.0F, 6, 6, 6, 0.0F));
Lamp.cubeList.add(new ModelBox(Lamp, 20, 5, -1.0F, -9.0F, -1.0F, 2, 3, 2, 0.0F));
Lamp.cubeList.add(new ModelBox(Lamp, 20, 0, -1.0F, -16.0F, -1.0F, 2, 3, 2, 0.0F));
Lamp.cubeList.add(new ModelBox(Lamp, 14, 0, -3.0F, -16.0F, -1.0F, 2, 0, 2, 0.0F));
cube_r3 = new ModelRenderer(this);
cube_r3.setRotationPoint(0.0F, -16.0F, -2.5F);
Lamp.addChild(cube_r3);
setRotationAngle(cube_r3, 0.0F, -1.5708F, 0.0F);
cube_r3.cubeList.add(new ModelBox(cube_r3, 14, 0, -0.5F, 0.0F, -1.0F, 2, 0, 2, 0.0F));
cube_r4 = new ModelRenderer(this);
cube_r4.setRotationPoint(0.0F, -16.0F, 2.5F);
Lamp.addChild(cube_r4);
setRotationAngle(cube_r4, 0.0F, 1.5708F, 0.0F);
cube_r4.cubeList.add(new ModelBox(cube_r4, 14, 0, -0.5F, 0.0F, -1.0F, 2, 0, 2, 0.0F));
cube_r5 = new ModelRenderer(this);
cube_r5.setRotationPoint(2.5F, -16.0F, 0.0F);
Lamp.addChild(cube_r5);
setRotationAngle(cube_r5, -3.1416F, 0.0F, 0.0F);
cube_r5.cubeList.add(new ModelBox(cube_r5, 14, 0, -1.5F, 0.0F, -1.0F, 2, 0, 2, 0.0F));
Light = new ModelRenderer(this);
Light.setRotationPoint(0.0F, 24.0F, 0.0F);
Light.cubeList.add(new ModelBox(Light, 28, 0, -2.0F, -13.0F, -2.0F, 4, 4, 4, 0.0F));
}
@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {}
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
modelRenderer.rotateAngleX = x;
modelRenderer.rotateAngleY = y;
modelRenderer.rotateAngleZ = z;
}
}
@@ -0,0 +1,78 @@
package noppes.npcs.client.model.blocks.lamp;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBox;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
public class ModelTallLamp extends ModelBase {
public final ModelRenderer Shade;
private final ModelRenderer cube_r1;
private final ModelRenderer cube_r2;
public final ModelRenderer Lamp;
private final ModelRenderer cube_r3;
private final ModelRenderer cube_r4;
private final ModelRenderer cube_r5;
public final ModelRenderer Light;
public ModelTallLamp() {
textureWidth = 64;
textureHeight = 64;
Shade = new ModelRenderer(this);
Shade.setRotationPoint(0.0F, -6.0F, 7.0F);
Shade.cubeList.add(new ModelBox(Shade, 0, 12, -6.0F, -2.0F, -13.0F, 12, 12, 0, 0.0F));
Shade.cubeList.add(new ModelBox(Shade, -12, 0, -6.0F, -2.0F, -13.0F, 12, 0, 12, 0.0F));
Shade.cubeList.add(new ModelBox(Shade, 0, 12, -6.0F, -2.0F, -1.0F, 12, 12, 0, 0.0F));
cube_r1 = new ModelRenderer(this);
cube_r1.setRotationPoint(6.0F, 4.0F, -7.0F);
Shade.addChild(cube_r1);
setRotationAngle(cube_r1, 0.0F, 1.5708F, 0.0F);
cube_r1.cubeList.add(new ModelBox(cube_r1, 0, 12, -6.0F, -6.0F, 0.0F, 12, 12, 0, 0.0F));
cube_r2 = new ModelRenderer(this);
cube_r2.setRotationPoint(-6.0F, 4.0F, -7.0F);
Shade.addChild(cube_r2);
setRotationAngle(cube_r2, 0.0F, 1.5708F, 0.0F);
cube_r2.cubeList.add(new ModelBox(cube_r2, 0, 12, -6.0F, -6.0F, 0.0F, 12, 12, 0, 0.0F));
Lamp = new ModelRenderer(this);
Lamp.setRotationPoint(0.0F, 24.0F, 0.0F);
Lamp.cubeList.add(new ModelBox(Lamp, 40, 22, -3.0F, -2.0F, -3.0F, 6, 2, 6, 0.0F));
Lamp.cubeList.add(new ModelBox(Lamp, 32, 5, -1.0F, -25.0F, -1.0F, 2, 23, 2, 0.0F));
Lamp.cubeList.add(new ModelBox(Lamp, 32, 0, -1.0F, -32.0F, -1.0F, 2, 3, 2, 0.0F));
Lamp.cubeList.add(new ModelBox(Lamp, 22, 0, -4.0F, -32.0F, -1.0F, 3, 0, 2, 0.0F));
cube_r3 = new ModelRenderer(this);
cube_r3.setRotationPoint(0.0F, -32.0F, -2.5F);
Lamp.addChild(cube_r3);
setRotationAngle(cube_r3, 0.0F, -1.5708F, 0.0F);
cube_r3.cubeList.add(new ModelBox(cube_r3, 22, 0, -1.5F, 0.0F, -1.0F, 3, 0, 2, 0.0F));
cube_r4 = new ModelRenderer(this);
cube_r4.setRotationPoint(0.0F, -32.0F, 2.5F);
Lamp.addChild(cube_r4);
setRotationAngle(cube_r4, 0.0F, 1.5708F, 0.0F);
cube_r4.cubeList.add(new ModelBox(cube_r4, 22, 0, -1.5F, 0.0F, -1.0F, 3, 0, 2, 0.0F));
cube_r5 = new ModelRenderer(this);
cube_r5.setRotationPoint(2.5F, -32.0F, 0.0F);
Lamp.addChild(cube_r5);
setRotationAngle(cube_r5, -3.1416F, 0.0F, 0.0F);
cube_r5.cubeList.add(new ModelBox(cube_r5, 22, 0, -1.5F, 0.0F, -1.0F, 3, 0, 2, 0.0F));
Light = new ModelRenderer(this);
Light.setRotationPoint(0.0F, 24.0F, 0.0F);
Light.cubeList.add(new ModelBox(Light, 40, 14, -2.0F, -29.0F, -2.0F, 4, 4, 4, 0.0F));
}
@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {}
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
modelRenderer.rotateAngleX = x;
modelRenderer.rotateAngleY = y;
modelRenderer.rotateAngleZ = z;
}
}
@@ -1,10 +1,10 @@
package noppes.npcs.client.model.blocks;
package noppes.npcs.client.model.blocks.legacy;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
public class ModelTallLamp extends ModelBase
public class ModelLegacyTallLamp extends ModelBase
{
//fields
ModelRenderer Base;
@@ -13,37 +13,37 @@ public class ModelTallLamp extends ModelBase
ModelRenderer LampShadeStick2;
ModelRenderer LampShadeStick3;
ModelRenderer LampShadeStick4;
public ModelTallLamp()
public ModelLegacyTallLamp()
{
Base = new ModelRenderer(this, 6, 2);
Base.addBox(-6F, 0F, -6F, 12, 1, 12);
Base.setRotationPoint(0F, 23F, 0F);
MiddleStick = new ModelRenderer(this, 12, 2);
MiddleStick.addBox(-1F, 0F, -1F, 2, 28, 2);
MiddleStick.setRotationPoint(0F, -5F, 0F);
LampShadeStick1 = new ModelRenderer(this, 0, 30);
LampShadeStick1.addBox(0F, 0F, 0F, 5, 1, 1);
LampShadeStick1.setRotationPoint(1F, -1F, -0.5F);
LampShadeStick2 = new ModelRenderer(this, 0, 30);
LampShadeStick2.addBox(0F, 0F, 0F, 5, 1, 1);
LampShadeStick2.setRotationPoint(-0.5F, -1F, -1F);
setRotation(LampShadeStick2, 0F, 1.570796F, 0F);
LampShadeStick3 = new ModelRenderer(this, 0, 30);
LampShadeStick3.addBox(0F, 0F, 0F, 5, 1, 1);
LampShadeStick3.setRotationPoint(-1F, -1F, 0.5F);
setRotation(LampShadeStick3, 0F, 3.141593F, 0F);
LampShadeStick4 = new ModelRenderer(this, 0, 30);
LampShadeStick4.addBox(0F, 0F, 0F, 5, 1, 1);
LampShadeStick4.setRotationPoint(0.5F, -1F, 1F);
setRotation(LampShadeStick4, 0F, -1.570796F, 0F);
}
@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
@@ -55,7 +55,7 @@ public class ModelTallLamp extends ModelBase
LampShadeStick3.render(f5);
LampShadeStick4.render(f5);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
@@ -1,35 +1,35 @@
package noppes.npcs.client.model.blocks;
package noppes.npcs.client.model.blocks.legacy;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
public class ModelTallLampTop extends ModelBase
public class ModelLegacyTallLampTop extends ModelBase
{
ModelRenderer LampShade1;
ModelRenderer LampShade3;
ModelRenderer LampShade2;
ModelRenderer LampShade4;
public ModelTallLampTop()
public ModelLegacyTallLampTop()
{
LampShade1 = new ModelRenderer(this, 0, 0);
LampShade1.addBox(-.5F, -6F, -6F, 1, 12, 12);
LampShade1.setRotationPoint(6F, -1F, 0F);
LampShade3 = new ModelRenderer(this, 0, 0);
LampShade3.addBox(-6F, -6F, -.5F, 12, 12, 1);
LampShade3.setRotationPoint(0F, -1F, -6F);
LampShade2 = new ModelRenderer(this, 0, 0);
LampShade2.addBox(-.5F, -6F, -6F, 1, 12, 12);
LampShade2.setRotationPoint(-6F, -1F, 0F);
LampShade4 = new ModelRenderer(this, 0, 0);
LampShade4.addBox(-6F, -6F, -.5F, 12, 12, 1);
LampShade4.setRotationPoint(0F, -1F, 6F);
}
@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
@@ -39,7 +39,7 @@ public class ModelTallLampTop extends ModelBase
LampShade2.render(f5);
LampShade4.render(f5);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
@@ -0,0 +1,104 @@
package noppes.npcs.client.renderer.blocks;
import cpw.mods.fml.client.registry.RenderingRegistry;
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.texture.TextureManager;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.CustomItems;
import noppes.npcs.blocks.BlockShortLamp;
import noppes.npcs.blocks.tiles.TileShortLamp;
import noppes.npcs.client.model.blocks.lamp.ModelShortLamp;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
public class BlockShortLampRenderer extends BlockRendererInterface {
private 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");
public static final ResourceLocation iron = new ResourceLocation("customnpcs","textures/models/lamp/short/iron.png");
public static final ResourceLocation gold = new ResourceLocation("customnpcs","textures/models/lamp/short/gold.png");
public static final ResourceLocation diamond = new ResourceLocation("customnpcs","textures/models/lamp/short/diamond.png");
public BlockShortLampRenderer(){
((BlockShortLamp)CustomItems.shortLamp).renderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(this);
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTicks) {
TileShortLamp tile = (TileShortLamp) tileEntity;
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5f, (float)y + 1.5f, (float)z + 0.5f);
GL11.glRotatef(180, 0, 0, 1);
GL11.glRotatef(90 * tile.rotation, 0, 1, 0);
GL11.glColor3f(1, 1, 1);
setLampTexture(tileEntity.getBlockMetadata());
model.Lamp.render(0.0625F);
int light = tileEntity.getWorldObj().getLightBrightnessForSkyBlocks(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, 0);
int brightX = light % 65536;
int brightY = light / 65536;
// Set full brightness for the light
int fullBright = 0xF000F0;
int fullBrightX = fullBright % 65536;
int fullBrightY = fullBright / 65536;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)fullBrightX, (float)fullBrightY);
model.Light.render(0.0625F);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)brightX, (float)brightY);
float[] color = BlockBannerRenderer.colorTable[tile.color];
GL11.glColor3f(color[0], color[1], color[2]);
model.Shade.render(0.0625F);
GL11.glPopAttrib();
GL11.glPopMatrix();
}
@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);
setLampTexture(metadata);
model.Lamp.render(0.0625F);
model.Light.render(0.0625F);
float[] color = BlockBannerRenderer.colorTable[15 - metadata];
GL11.glColor3f(color[0], color[1], color[2]);
model.Shade.render(0.0625F);
GL11.glPopMatrix();
}
public void setLampTexture(int meta){
TextureManager manager = Minecraft.getMinecraft().getTextureManager();
if(meta == 1)
manager.bindTexture(stone);
else if(meta == 2)
manager.bindTexture(iron);
else if(meta == 3)
manager.bindTexture(gold);
else if(meta == 4)
manager.bindTexture(diamond);
else
manager.bindTexture(wood);
}
@Override
public int getRenderId() {
return CustomItems.shortLamp.getRenderType();
}
}
@@ -2,24 +2,37 @@ package noppes.npcs.client.renderer.blocks;
import cpw.mods.fml.client.registry.RenderingRegistry;
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.texture.TextureManager;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.CustomItems;
import noppes.npcs.blocks.BlockTallLamp;
import noppes.npcs.blocks.tiles.TileTallLamp;
import noppes.npcs.client.model.blocks.ModelTallLamp;
import noppes.npcs.client.model.blocks.ModelTallLampTop;
import noppes.npcs.client.model.blocks.lamp.ModelTallLamp;
import noppes.npcs.client.model.blocks.legacy.ModelLegacyTallLamp;
import noppes.npcs.client.model.blocks.legacy.ModelLegacyTallLampTop;
import noppes.npcs.config.ConfigClient;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
public class BlockTallLampRenderer extends BlockRendererInterface{
private final ModelTallLamp model = new ModelTallLamp();
private final ModelTallLampTop top = new ModelTallLampTop();
private final ModelLegacyTallLamp modelLegacy = new ModelLegacyTallLamp();
private 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 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");
public static final ResourceLocation iron = new ResourceLocation("customnpcs","textures/models/lamp/tall/iron.png");
public static final ResourceLocation gold = new ResourceLocation("customnpcs","textures/models/lamp/tall/gold.png");
public static final ResourceLocation diamond = new ResourceLocation("customnpcs","textures/models/lamp/tall/diamond.png");
public BlockTallLampRenderer(){
((BlockTallLamp)CustomItems.tallLamp).renderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(this);
@@ -33,18 +46,38 @@ public class BlockTallLampRenderer extends BlockRendererInterface{
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPushMatrix();
GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.5f, (float)var6 + 0.5f);
//GL11.glScalef(0.95f, 0.95f, 0.95f);
GL11.glRotatef(180, 0, 0, 1);
GL11.glRotatef(90 * tile.rotation, 0, 1, 0);
GL11.glColor3f(1, 1, 1);
setMaterialTexture(var1.getBlockMetadata());
model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
if(ConfigClient.LegacyTallLamp){
setMaterialTexture(var1.getBlockMetadata());
modelLegacy.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
this.bindTexture(resourceTop);
float[] color = BlockBannerRenderer.colorTable[tile.color];
GL11.glColor3f(color[0], color[1], color[2]);
topLegacy.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
} else {
setLampTexture(var1.getBlockMetadata());
model.Lamp.render(0.0625F);
int light = var1.getWorldObj().getLightBrightnessForSkyBlocks(var1.xCoord, var1.yCoord, var1.zCoord, 0);
int brightX = light % 65536;
int brightY = light / 65536;
// Set full brightness for the light
int fullBright = 0xF000F0;
int fullBrightX = fullBright % 65536;
int fullBrightY = fullBright / 65536;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)fullBrightX, (float)fullBrightY);
model.Light.render(0.0625F);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)brightX, (float)brightY);
float[] color = BlockBannerRenderer.colorTable[tile.color];
GL11.glColor3f(color[0], color[1], color[2]);
model.Shade.render(0.0625F);
}
this.bindTexture(resourceTop);
float[] color = BlockBannerRenderer.colorTable[tile.color];
GL11.glColor3f(color[0], color[1], color[2]);
top.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
GL11.glPopAttrib();
GL11.glPopMatrix();
}
@@ -57,18 +90,40 @@ public class BlockTallLampRenderer extends BlockRendererInterface{
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);
setMaterialTexture(metadata);
GL11.glColor3f(1, 1, 1);
model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
this.bindTexture(resourceTop);
float[] color = BlockBannerRenderer.colorTable[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 = BlockBannerRenderer.colorTable[15 - metadata];
GL11.glColor3f(color[0], color[1], color[2]);
model.Shade.render(0.0625F);
}
this.bindTexture(resourceTop);
float[] color = BlockBannerRenderer.colorTable[15 - metadata];
GL11.glColor3f(color[0], color[1], color[2]);
top.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
GL11.glPopMatrix();
}
public void setLampTexture(int meta){
TextureManager manager = Minecraft.getMinecraft().getTextureManager();
if(meta == 1)
manager.bindTexture(stone);
else if(meta == 2)
manager.bindTexture(iron);
else if(meta == 3)
manager.bindTexture(gold);
else if(meta == 4)
manager.bindTexture(diamond);
else
manager.bindTexture(wood);
}
@Override
public int getRenderId() {
@@ -93,6 +93,7 @@ public class ConfigClient
public static boolean LegacyAnvil = false;
public static boolean LegacyLantern = false;
public static boolean LegacyCandle = false;
public static boolean LegacyTallLamp = false;
public static void init(File configFile)
{
@@ -163,6 +164,7 @@ public class ConfigClient
LegacyCarpentryBench = config.get(MODEL, "Legacy Carpentry Bench Model", false).getBoolean(false);
LegacyLantern = config.get(MODEL, "Legacy Lantern Model", false).getBoolean(false);
LegacyCandle = config.get(MODEL, "Legacy Candle Model", false).getBoolean(false);
LegacyTallLamp = config.get(MODEL, "Legacy Tall Lamp Model", false).getBoolean(false);
// Convert to Legacy
if(CustomNpcs.legacyExist){