Custom Barrel Rendering

This commit is contained in:
Kam committed 2024-05-09 05:02:01 -04:00
1 parent eaf7c3f333
commit cd3d8ccdbb
5 files changed
+162 -18

No files matched your search

@@ -11,6 +11,8 @@ import noppes.npcs.blocks.BlockBarrel;
import noppes.npcs.blocks.tiles.TileColorable;
import noppes.npcs.client.model.blocks.ModelBarrel;
import noppes.npcs.client.model.blocks.ModelBarrelLit;
import noppes.npcs.client.model.blocks.barrel.BarrelCore;
import noppes.npcs.client.model.blocks.barrel.BarrelTrim;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
@@ -19,12 +21,17 @@ public class BlockBarrelRenderer extends BlockRendererInterface{
private final ModelBarrel model = new ModelBarrel();
private final ModelBarrelLit modelLit = new ModelBarrelLit();
private static final ResourceLocation resource1 = new ResourceLocation("customnpcs","textures/models/Barrel.png");
private final BarrelCore core = new BarrelCore();
private final BarrelTrim trim = new BarrelTrim();
private static final ResourceLocation trimTexture = new ResourceLocation("customnpcs","textures/models/BarrelTrim.png");
public BlockBarrelRenderer(){
((BlockBarrel)CustomItems.barrel).renderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(this);
}
@Override
public void renderTileEntityAt(TileEntity var1, double var2, double var4,
double var6, float var8) {
@@ -33,16 +40,16 @@ public class BlockBarrelRenderer extends BlockRendererInterface{
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glPushMatrix();
GL11.glTranslatef((float)var2 + 0.5f, (float)var4 + 1.42f, (float)var6 + 0.5f);
GL11.glScalef(1f, 0.94f,1f);
GL11.glScalef(1.2f, 0.94f,1.2f);
GL11.glRotatef(180, 0, 0, 1);
GL11.glRotatef(45 * tile.rotation, 0, 1, 0);
GL11.glColor3f(1, 1, 1);
GL11.glEnable(GL11.GL_CULL_FACE);
setWoodTexture(var1.getBlockMetadata());
model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
Minecraft.getMinecraft().getTextureManager().bindTexture(resource1);
modelLit.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
core.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
Minecraft.getMinecraft().getTextureManager().bindTexture(trimTexture);
trim.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
GL11.glPopMatrix();
}
@@ -51,18 +58,16 @@ public class BlockBarrelRenderer extends BlockRendererInterface{
public void renderInventoryBlock(Block block, int metadata, int modelId,
RenderBlocks renderer) {
GL11.glPushMatrix();
GL11.glTranslatef(0, 0.75f, 0);
GL11.glScalef(0.7f, 0.7f, 0.7f);
GL11.glTranslatef(0, 1.05f, 0);
GL11.glScalef(1f, 1f, 1f);
GL11.glRotatef(180, 0, 0, 1);
GL11.glRotatef(180, 0, 1, 0);
setWoodTexture(metadata);
GL11.glColor3f(1, 1, 1);
model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
Minecraft.getMinecraft().getTextureManager().bindTexture(resource1);
modelLit.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
core.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
Minecraft.getMinecraft().getTextureManager().bindTexture(trimTexture);
trim.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
GL11.glPopMatrix();
}
@@ -24,9 +24,17 @@ public abstract class BlockRendererInterface extends TileEntitySpecialRenderer i
protected static final ResourceLocation PlanksAcacia = new ResourceLocation("customnpcs","textures/cache/planks_acacia.png");
protected static final ResourceLocation PlanksJungle = new ResourceLocation("customnpcs","textures/cache/planks_jungle.png");
protected static final ResourceLocation MCPlanksOak = new ResourceLocation("customnpcs","textures/cache/planks_oak.png");
protected static final ResourceLocation MCPlanksBigOak = new ResourceLocation("customnpcs","textures/cache/planks_big_oak.png");
protected static final ResourceLocation MCPlanksSpruce = new ResourceLocation("customnpcs","textures/cache/planks_spruce.png");
protected static final ResourceLocation MCPlanksBirch = new ResourceLocation("customnpcs","textures/cache/planks_birch.png");
protected static final ResourceLocation MCPlanksAcacia = new ResourceLocation("customnpcs","textures/cache/planks_acacia.png");
protected static final ResourceLocation MCPlanksJungle = new ResourceLocation("customnpcs","textures/cache/planks_jungle.png");
protected static final ResourceLocation Steel = new ResourceLocation("customnpcs","textures/models/Steel.png");
protected static final RenderItem renderer = new RenderItem();
public static float colorTable[][] = {
{
1.0F, 1.0F, 1.0F
@@ -73,8 +81,8 @@ public abstract class BlockRendererInterface extends TileEntitySpecialRenderer i
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
public boolean playerTooFar(TileEntity tile){
Minecraft mc = Minecraft.getMinecraft();
double d6 = mc.renderViewEntity.posX - tile.xCoord;
@@ -83,7 +91,7 @@ public abstract class BlockRendererInterface extends TileEntitySpecialRenderer i
return d6 * d6 + d7 * d7 + d8 * d8 > specialRenderDistance() * specialRenderDistance();
}
public int specialRenderDistance(){
return 20;
}
@@ -103,6 +111,22 @@ public abstract class BlockRendererInterface extends TileEntitySpecialRenderer i
manager.bindTexture(PlanksOak);
}
public void setDefaultWoodTexture(int meta){
TextureManager manager = Minecraft.getMinecraft().getTextureManager();
if(meta == 1)
manager.bindTexture(PlanksSpruce);
else if(meta == 2)
manager.bindTexture(PlanksBirch);
else if(meta == 3)
manager.bindTexture(PlanksJungle);
else if(meta == 4)
manager.bindTexture(PlanksAcacia);
else if(meta == 5)
manager.bindTexture(PlanksBigOak);
else
manager.bindTexture(PlanksOak);
}
public static void setMaterialTexture(int meta){
TextureManager manager = Minecraft.getMinecraft().getTextureManager();
if(meta == 1)
@@ -115,6 +139,5 @@ public abstract class BlockRendererInterface extends TileEntitySpecialRenderer i
manager.bindTexture(Diamond);
else
manager.bindTexture(PlanksOak);
}
}