Revamped Model Table

This commit is contained in:
Kam committed 2025-02-04 15:39:25 -05:00
1 parent a973eca54c
commit dfb4c511cc
10 files changed
+197 -62

No files matched your search

@@ -2,25 +2,31 @@ 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.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.BlockTable;
import noppes.npcs.blocks.tiles.TileColorable;
import noppes.npcs.client.model.blocks.ModelTable;
import noppes.npcs.client.model.blocks.legacy.ModelLegacyTable;
import noppes.npcs.config.ConfigClient;
import org.lwjgl.opengl.GL11;
public class BlockTableRenderer extends BlockRendererInterface{
private final ModelTable model = new ModelTable();
private static final ResourceLocation resource1 = new ResourceLocation("customnpcs","textures/cache/planks_oak.png");
private static final ResourceLocation resource2 = new ResourceLocation("customnpcs","textures/cache/planks_big_oak.png");
private static final ResourceLocation resource3 = new ResourceLocation("customnpcs","textures/cache/planks_spruce.png");
private static final ResourceLocation resource4 = new ResourceLocation("customnpcs","textures/cache/planks_birch.png");
private static final ResourceLocation resource5 = new ResourceLocation("customnpcs","textures/cache/planks_acacia.png");
private static final ResourceLocation resource6 = new ResourceLocation("customnpcs","textures/cache/planks_jungle.png");
private final ModelLegacyTable legacyTable = new ModelLegacyTable();
private final ModelTable table = new ModelTable();
private static final ResourceLocation oak = new ResourceLocation("customnpcs","textures/models/table/oak.png");
private static final ResourceLocation spruce = new ResourceLocation("customnpcs","textures/models/table/spruce.png");
private static final ResourceLocation birch = new ResourceLocation("customnpcs","textures/models/table/birch.png");
private static final ResourceLocation jungle = new ResourceLocation("customnpcs","textures/models/table/jungle.png");
private static final ResourceLocation acacia = new ResourceLocation("customnpcs","textures/models/table/acacia.png");
private static final ResourceLocation dark_oak = new ResourceLocation("customnpcs","textures/models/table/dark_oak.png");
public BlockTableRenderer(){
((BlockTable)CustomItems.table).renderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(this);
@@ -39,15 +45,29 @@ public class BlockTableRenderer extends BlockRendererInterface{
boolean east = var1.getWorldObj().getBlock(var1.xCoord, var1.yCoord, var1.zCoord + 1) == CustomItems.table;
boolean west = var1.getWorldObj().getBlock(var1.xCoord, var1.yCoord, var1.zCoord - 1) == CustomItems.table;
model.Shape1.showModel = !south && !east;
model.Shape3.showModel = !north && !west;
model.Shape4.showModel = !north && !east;
model.Shape5.showModel = !south && !west;
setWoodTexture(var1.getBlockMetadata());
model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
GL11.glRotatef(90 * tile.rotation, 0, 1, 0);
model.Table.render(0.0625f);
legacyTable.Shape1.showModel = !south && !east;
legacyTable.Shape3.showModel = !north && !west;
legacyTable.Shape4.showModel = !north && !east;
legacyTable.Shape5.showModel = !south && !west;
table.Shape1.showModel = !south && !east;
table.Shape2.showModel = !south && !west;
table.Shape3.showModel = !north && !west;
table.Shape4.showModel = !north && !east;
if(ConfigClient.LegacyTable){
setWoodTexture(var1.getBlockMetadata());
legacyTable.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
GL11.glRotatef(90 * tile.rotation, 0, 1, 0);
legacyTable.Table.render(0.0625f);
} else {
GL11.glEnable(GL11.GL_ALPHA_TEST);
setTableTexture(var1.getBlockMetadata());
table.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
GL11.glRotatef(90 * tile.rotation, 0, 1, 0);
table.Table.render(0.0625f);
GL11.glDisable(GL11.GL_ALPHA_TEST);
}
GL11.glPopMatrix();
}
@@ -60,18 +80,45 @@ public class BlockTableRenderer extends BlockRendererInterface{
GL11.glRotatef(180, 0, 0, 1);
GL11.glRotatef(180, 0, 1, 0);
setWoodTexture(metadata);
GL11.glColor3f(1, 1, 1);
model.Table.render(0.0625f);
model.Shape1.showModel = true;
model.Shape3.showModel = true;
model.Shape4.showModel = true;
model.Shape5.showModel = true;
model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
if(ConfigClient.LegacyTable){
setWoodTexture(metadata);
GL11.glColor3f(1, 1, 1);
legacyTable.Table.render(0.0625f);
legacyTable.Shape1.showModel = true;
legacyTable.Shape3.showModel = true;
legacyTable.Shape4.showModel = true;
legacyTable.Shape5.showModel = true;
legacyTable.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
} else {
setTableTexture(metadata);
GL11.glColor3f(1, 1, 1);
table.Table.render(0.0625f);
table.Shape1.showModel = true;
table.Shape2.showModel = true;
table.Shape3.showModel = true;
table.Shape4.showModel = true;
table.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
}
GL11.glPopMatrix();
}
public void setTableTexture(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);
}
@Override
public int getRenderId() {
return CustomItems.table.getRenderType();