2018-09-13 12:03:28 -04:00
|
|
|
package noppes.npcs.client.renderer.blocks;
|
|
|
|
|
|
2023-01-12 21:33:06 -05:00
|
|
|
import cpw.mods.fml.client.registry.RenderingRegistry;
|
2018-09-13 12:03:28 -04:00
|
|
|
import net.minecraft.block.Block;
|
2025-01-28 01:12:41 -05:00
|
|
|
import net.minecraft.client.Minecraft;
|
2018-09-13 12:03:28 -04:00
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
2025-01-28 01:12:41 -05:00
|
|
|
import net.minecraft.client.renderer.texture.TextureManager;
|
2018-09-13 12:03:28 -04:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2025-01-28 01:12:41 -05:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2018-09-13 12:03:28 -04:00
|
|
|
import noppes.npcs.CustomItems;
|
|
|
|
|
import noppes.npcs.blocks.BlockChair;
|
2025-02-13 03:12:46 -05:00
|
|
|
import noppes.npcs.blocks.tiles.TileVariant;
|
2025-01-28 01:12:41 -05:00
|
|
|
import noppes.npcs.client.model.blocks.chair.ModelChair;
|
|
|
|
|
import noppes.npcs.client.model.blocks.chair.ModelChairSpoof;
|
2025-01-26 17:39:04 -05:00
|
|
|
import noppes.npcs.client.model.blocks.legacy.ModelLegacyChair;
|
|
|
|
|
import noppes.npcs.config.ConfigClient;
|
2018-09-13 12:03:28 -04:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
import org.lwjgl.opengl.GL12;
|
|
|
|
|
|
|
|
|
|
public class BlockChairRenderer extends BlockRendererInterface{
|
|
|
|
|
|
2025-01-26 17:39:04 -05:00
|
|
|
private final ModelLegacyChair legacyModel = new ModelLegacyChair();
|
2025-01-28 01:12:41 -05:00
|
|
|
|
|
|
|
|
private final ModelChairSpoof chairSpoof = new ModelChairSpoof();
|
|
|
|
|
private final ModelChair chair = new ModelChair();
|
|
|
|
|
|
|
|
|
|
private static final ResourceLocation oak = new ResourceLocation("customnpcs","textures/models/chair/oak.png");
|
|
|
|
|
private static final ResourceLocation spruce = new ResourceLocation("customnpcs","textures/models/chair/spruce.png");
|
|
|
|
|
private static final ResourceLocation birch = new ResourceLocation("customnpcs","textures/models/chair/birch.png");
|
|
|
|
|
private static final ResourceLocation jungle = new ResourceLocation("customnpcs","textures/models/chair/jungle.png");
|
|
|
|
|
private static final ResourceLocation dark_oak = new ResourceLocation("customnpcs","textures/models/chair/dark_oak.png");
|
|
|
|
|
private static final ResourceLocation acacia = new ResourceLocation("customnpcs","textures/models/chair/acacia.png");
|
2025-01-22 12:42:35 -05:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public BlockChairRenderer(){
|
|
|
|
|
((BlockChair)CustomItems.chair).renderId = RenderingRegistry.getNextAvailableRenderId();
|
|
|
|
|
RenderingRegistry.registerBlockHandler(this);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void renderTileEntityAt(TileEntity var1, double var2, double var4,
|
|
|
|
|
double var6, float var8) {
|
2025-02-13 03:12:46 -05:00
|
|
|
TileVariant tile = (TileVariant) var1;
|
2025-02-12 17:39:33 -05:00
|
|
|
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
2018-09-13 12:03:28 -04:00
|
|
|
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
|
|
|
|
GL11.glPushMatrix();
|
2025-02-21 20:00:55 -05:00
|
|
|
GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.5f, (float)var6 + 0.5f);
|
|
|
|
|
// GL11.glScalef(1.2f, 1.1f, 1.2f);
|
2018-09-13 12:03:28 -04:00
|
|
|
GL11.glRotatef(180, 0, 0, 1);
|
|
|
|
|
GL11.glRotatef(90 * tile.rotation, 0, 1, 0);
|
|
|
|
|
GL11.glColor3f(1, 1, 1);
|
2025-01-22 12:42:35 -05:00
|
|
|
|
2025-01-27 17:21:11 -05:00
|
|
|
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
2018-09-13 12:03:28 -04:00
|
|
|
setWoodTexture(var1.getBlockMetadata());
|
2025-01-26 17:39:04 -05:00
|
|
|
if(ConfigClient.LegacyChair)
|
|
|
|
|
legacyModel.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
2025-01-28 01:12:41 -05:00
|
|
|
else {
|
|
|
|
|
if(ConfigClient.WoodTextures)
|
|
|
|
|
chairSpoof.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
|
|
|
|
else {
|
|
|
|
|
setChairTexture(var1.getBlockMetadata());
|
|
|
|
|
chair.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-01-27 17:21:11 -05:00
|
|
|
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
2025-02-12 17:39:33 -05:00
|
|
|
GL11.glPopAttrib();
|
2018-09-13 12:03:28 -04:00
|
|
|
GL11.glPopMatrix();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void renderInventoryBlock(Block block, int metadata, int modelId,
|
|
|
|
|
RenderBlocks renderer) {
|
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
|
GL11.glTranslatef(0, 1f, 0);
|
|
|
|
|
GL11.glColor3f(1, 1, 1);
|
2025-02-12 18:39:24 -05:00
|
|
|
if(ConfigClient.LegacyChair){
|
|
|
|
|
setWoodTexture(metadata);
|
|
|
|
|
GL11.glScalef(1.2f, 1.1f, 1.2f);
|
|
|
|
|
GL11.glRotatef(180, 0, 0, 1);
|
|
|
|
|
GL11.glRotatef(180, 0, 1, 0);
|
2025-01-26 17:39:04 -05:00
|
|
|
legacyModel.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
2025-02-12 18:39:24 -05:00
|
|
|
}
|
2025-01-28 01:12:41 -05:00
|
|
|
else {
|
2025-02-12 18:39:24 -05:00
|
|
|
GL11.glTranslatef(0, -0.15f, 0);
|
|
|
|
|
GL11.glScalef(1f, 0.9f, 1f);
|
|
|
|
|
GL11.glRotatef(180, 0, 0, 1);
|
|
|
|
|
GL11.glRotatef(180, 0, 1, 0);
|
2025-01-28 01:12:41 -05:00
|
|
|
if(ConfigClient.WoodTextures)
|
|
|
|
|
chairSpoof.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
|
|
|
|
else {
|
|
|
|
|
setChairTexture(metadata);
|
|
|
|
|
chair.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
GL11.glPopMatrix();
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-28 01:12:41 -05:00
|
|
|
public void setChairTexture(int meta){
|
|
|
|
|
TextureManager manager = Minecraft.getMinecraft().getTextureManager();
|
|
|
|
|
if(meta == 1)
|
|
|
|
|
manager.bindTexture(spruce);
|
|
|
|
|
else if(meta == 2)
|
|
|
|
|
manager.bindTexture(birch);
|
|
|
|
|
else if(meta == 3)
|
|
|
|
|
manager.bindTexture(jungle);
|
|
|
|
|
else if(meta == 4)
|
|
|
|
|
manager.bindTexture(acacia);
|
|
|
|
|
else if(meta == 5)
|
|
|
|
|
manager.bindTexture(dark_oak);
|
|
|
|
|
else
|
|
|
|
|
manager.bindTexture(oak);
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getRenderId() {
|
|
|
|
|
return CustomItems.chair.getRenderType();
|
|
|
|
|
}
|
|
|
|
|
}
|