remove chest renderer

This commit is contained in:
Sen 2025-07-20 16:20:24 +02:00
parent e92e74336e
commit ba3e80b15c
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
14 changed files with 70 additions and 209 deletions

View file

@ -136,12 +136,7 @@ public class RenderItem
} }
private void renderBuiltin(ItemStack stack) { private void renderBuiltin(ItemStack stack) {
if(stack.getItem().getBlock() instanceof BlockChest chest) { if(stack.getItem().getBlock() instanceof BlockStandingSign sign) {
this.state = chest.getState().withProperty(BlockChest.FACING, Facing.SOUTH);
TileEntityRenderer.instance.renderItem(this.chest, 0.0D, 0.0D, 0.0D, 0.0F);
this.state = null;
}
else if(stack.getItem().getBlock() instanceof BlockStandingSign sign) {
this.state = sign.getState().withProperty(BlockStandingSign.ROTATION, 8); this.state = sign.getState().withProperty(BlockStandingSign.ROTATION, 8);
TileEntityRenderer.instance.renderItem(this.sign, 0.0D, 0.0D, 0.0D, 0.0F); TileEntityRenderer.instance.renderItem(this.sign, 0.0D, 0.0D, 0.0D, 0.0F);
this.state = null; this.state = null;

View file

@ -1,42 +0,0 @@
package client.renderer.model;
public class ModelChest extends ModelBase
{
/** The chest lid in the chest's model. */
public ModelRenderer chestLid = (new ModelRenderer(this, 0, 0)).setTextureSize(64, 64);
/** The model of the bottom of the chest. */
public ModelRenderer chestBelow;
/** The chest's knob in the chest model. */
public ModelRenderer chestKnob;
public ModelChest()
{
this.chestLid.addBox(0.0F, -5.0F, -14.0F, 14, 5, 14, 0.0F);
this.chestLid.rotationPointX = 1.0F;
this.chestLid.rotationPointY = 7.0F;
this.chestLid.rotationPointZ = 15.0F;
this.chestKnob = (new ModelRenderer(this, 0, 0)).setTextureSize(64, 64);
this.chestKnob.addBox(-1.0F, -2.0F, -15.0F, 2, 4, 1, 0.0F);
this.chestKnob.rotationPointX = 8.0F;
this.chestKnob.rotationPointY = 7.0F;
this.chestKnob.rotationPointZ = 15.0F;
this.chestBelow = (new ModelRenderer(this, 0, 19)).setTextureSize(64, 64);
this.chestBelow.addBox(0.0F, 0.0F, 0.0F, 14, 10, 14, 0.0F);
this.chestBelow.rotationPointX = 1.0F;
this.chestBelow.rotationPointY = 6.0F;
this.chestBelow.rotationPointZ = 1.0F;
}
/**
* This method renders out all parts of the chest model.
*/
public void renderAll()
{
this.chestKnob.rotateAngleX = this.chestLid.rotateAngleX;
this.chestLid.render(0.0625F);
this.chestKnob.render(0.0625F);
this.chestBelow.render(0.0625F);
}
}

View file

@ -1,105 +0,0 @@
package client.renderer.tileentity;
import org.lwjgl.opengl.GL11;
import client.renderer.GlState;
import client.renderer.model.ModelChest;
import common.block.tech.BlockChest;
import common.init.BlockRegistry;
import common.init.Blocks;
import common.tileentity.TileEntityChest;
import common.world.State;
public class ChestRenderer extends TileRenderer<TileEntityChest>
{
private final ModelChest model = new ModelChest();
public ChestRenderer(TileEntityRenderer renderer) {
super(renderer);
}
public void renderTileEntityAt(TileEntityChest te, double x, double y, double z, float partialTicks, int destroyStage)
{
GlState.enableDepth();
GlState.depthFunc(GL11.GL_LEQUAL);
GlState.depthMask(true);
int i = 0;
BlockChest block = Blocks.chest;
if (te.hasWorldObj())
{
State state = te.getBlockState();
if(state.getBlock() instanceof BlockChest chest) {
i = state.getValue(BlockChest.FACING).getIndex();
block = chest;
}
}
if (destroyStage >= 0)
{
this.bindTexture(DESTROY_STAGES[destroyStage]);
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPushMatrix();
GL11.glScalef(4.0F, 4.0F, 1.0F);
GL11.glTranslatef(0.0625F, 0.0625F, 0.0625F);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
else
{
this.bindTexture("textures/blocks/" + BlockRegistry.getName(block) + ".png");
}
GL11.glPushMatrix();
GlState.enableRescaleNormal();
if (destroyStage < 0)
{
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
}
GL11.glTranslatef((float)x, (float)y + 1.0F, (float)z + 1.0F);
GL11.glScalef(1.0F, -1.0F, -1.0F);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
int j = 0;
if (i == 2)
{
j = 180;
}
if (i == 3)
{
j = 0;
}
if (i == 4)
{
j = 90;
}
if (i == 5)
{
j = -90;
}
GL11.glRotatef((float)j, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
float f = te.prevLidAngle + (te.lidAngle - te.prevLidAngle) * partialTicks;
f = 1.0F - f;
f = 1.0F - f * f * f;
this.model.chestLid.rotateAngleX = -(f * (float)Math.PI / 2.0F);
this.model.renderAll();
GlState.disableRescaleNormal();
GL11.glPopMatrix();
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
if (destroyStage >= 0)
{
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
}
}

View file

@ -32,7 +32,6 @@ public class TileEntityRenderer {
private TileEntityRenderer() { private TileEntityRenderer() {
this.renderers.put(TileEntitySign.class, new SignRenderer(this)); this.renderers.put(TileEntitySign.class, new SignRenderer(this));
this.renderers.put(TileEntityDisplay.class, new DisplayRenderer(this)); this.renderers.put(TileEntityDisplay.class, new DisplayRenderer(this));
this.renderers.put(TileEntityChest.class, new ChestRenderer(this));
} }
private <T extends TileEntity> TileRenderer<T> getRenderer(Class<? extends TileEntity> clazz) { private <T extends TileEntity> TileRenderer<T> getRenderer(Class<? extends TileEntity> clazz) {

View file

@ -664,8 +664,10 @@ public class WorldClient extends AWorldClient
case 2016: case 2016:
TileEntity te = this.getTileEntity(blockPosIn); TileEntity te = this.getTileEntity(blockPosIn);
if(te instanceof TileEntityChest chest) if(te instanceof TileEntityChest chest) {
chest.setUsing(data); chest.setUsing(data);
this.markBlockForUpdate(blockPosIn);
}
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -20,8 +20,12 @@ import common.inventory.InventoryHelper;
import common.item.CheatTab; import common.item.CheatTab;
import common.item.ItemStack; import common.item.ItemStack;
import common.item.tool.ItemKey; import common.item.tool.ItemKey;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.packet.SPacketSoundEffect; import common.packet.SPacketSoundEffect;
import common.properties.Property; import common.properties.Property;
import common.properties.PropertyBool;
import common.tileentity.TileEntity; import common.tileentity.TileEntity;
import common.tileentity.TileEntityChest; import common.tileentity.TileEntityChest;
import common.util.BlockPos; import common.util.BlockPos;
@ -31,9 +35,11 @@ import common.vars.Vars;
import common.world.State; import common.world.State;
import common.world.World; import common.world.World;
import common.world.AWorldServer; import common.world.AWorldServer;
import common.world.IWorldAccess;
public class BlockChest extends Block implements ITileEntityProvider, Rotatable public class BlockChest extends Block implements ITileEntityProvider, Rotatable
{ {
public static final PropertyBool OPEN = PropertyBool.create("open");
private static final Map<Integer, BlockChest> CHESTS = Maps.newHashMap(); private static final Map<Integer, BlockChest> CHESTS = Maps.newHashMap();
private final int width; private final int width;
@ -46,7 +52,7 @@ public class BlockChest extends Block implements ITileEntityProvider, Rotatable
public BlockChest(int width, int height) public BlockChest(int width, int height)
{ {
super(Material.WOOD); super(Material.WOOD);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH)); this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH).withProperty(OPEN, false));
this.width = width; this.width = width;
this.height = height; this.height = height;
this.setTab(CheatTab.TECHNOLOGY); this.setTab(CheatTab.TECHNOLOGY);
@ -74,11 +80,6 @@ public class BlockChest extends Block implements ITileEntityProvider, Rotatable
return false; return false;
} }
public int getRenderType()
{
return 2;
}
public State getPlacedState(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer) public State getPlacedState(World worldIn, BlockPos pos, Facing facing, float hitX, float hitY, float hitZ, EntityLiving placer)
{ {
return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
@ -230,15 +231,65 @@ public class BlockChest extends Block implements ITileEntityProvider, Rotatable
protected Property[] getProperties() protected Property[] getProperties()
{ {
return new Property[] {FACING}; return new Property[] {FACING, OPEN};
} }
protected Property[] getUnsavedProperties()
{
return new Property[] {OPEN};
}
public State getState(State state, IWorldAccess world, BlockPos pos) {
TileEntity te = world.getTileEntity(pos);
if(te instanceof TileEntityChest chest)
return state.withProperty(OPEN, chest.numPlayersUsing > 0);
return state;
}
public boolean isXrayVisible() public boolean isXrayVisible()
{ {
return true; return true;
} }
public String getFallbackTexture() { public Model getModel(ModelProvider provider, String name, State state) {
return "oak_planks"; return !state.getValue(OPEN) ?
provider.getModel(name + "_top")
.add(1, 0, 1, 15, 14, 15)
.d().noCull()
.u().noCull()
.n(name + "_front").noCull()
.s(name + "_side").noCull()
.w(name + "_side").noCull()
.e(name + "_side").noCull()
.add(7, 7, 0, 9, 11, 1)
.d(name + "_handle").uv(7, 8, 9, 9).noCull()
.u(name + "_handle").uv(7, 5, 9, 6).noCull()
.n(name + "_handle").noCull()
.w(name + "_handle").uv(8, 5, 9, 9).noCull()
.e(name + "_handle").uv(7, 5, 8, 9).noCull()
.rotate(ModelRotation.getNorthRot(state.getValue(FACING))) :
provider.getModel(name + "_top")
.add(1, 0, 1, 15, 10, 15)
.d().noCull()
.u(name + "_inner").noCull()
.n(name + "_front").noCull()
.s(name + "_side").noCull()
.w(name + "_side").noCull()
.e(name + "_side").noCull()
.add(1, 9, 15, 15, 23, 20)
.d(name + "_side").uv(1, 2, 15, 7).noCull()
.u(name + "_front").uv(1, 2, 15, 7).rot(180).noCull()
.n(name + "_inner").uv(1, 1, 15, 15).noCull()
.s().uv(1, 1, 15, 15).noCull()
.w(name + "_side").uv(1, 2, 15, 7).rot(90).noCull()
.e(name + "_side").uv(1, 2, 15, 7).rot(270).noCull()
.add(7, 23, 13, 9, 24, 17)
.n(name + "_handle").uv(7, 8, 9, 9).noCull()
.s(name + "_handle").uv(7, 5, 9, 6).rot(180).noCull()
.u(name + "_handle").uv(7, 5, 9, 9).rot(180).noCull()
.d(name + "_handle").uv(9, 5, 7, 9).noCull()
.w(name + "_handle").uv(8, 5, 9, 9).rot(90).noCull()
.e(name + "_handle").uv(7, 5, 8, 9).rot(270).noCull()
.rotate(ModelRotation.getNorthRot(state.getValue(FACING)));
} }
} }

View file

@ -18,8 +18,7 @@ public class TileEntityChest extends TileEntity implements ITickable, IInventory
private ItemStack[] chestContents; private ItemStack[] chestContents;
private String code; private String code;
public float lidAngle; public boolean wasOpen;
public float prevLidAngle;
public int numPlayersUsing; public int numPlayersUsing;
private int ticksSinceSync; private int ticksSinceSync;
private String customName; private String customName;
@ -216,49 +215,11 @@ public class TileEntityChest extends TileEntity implements ITickable, IInventory
} }
} }
this.prevLidAngle = this.lidAngle; if ((this.numPlayersUsing <= 0 && this.wasOpen) || (this.numPlayersUsing > 0 && !this.wasOpen))
float f1 = 0.1F;
if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F)
{ {
double d1 = (double)i + 0.5D; double d3 = (double)i + 0.5D;
double d2 = (double)k + 0.5D; double d0 = (double)k + 0.5D;
this.worldObj.playSound((this.wasOpen = this.numPlayersUsing > 0) ? SoundEvent.CHESTOPEN : SoundEvent.CHESTCLOSED, d3, (double)j + 0.5D, d0, 0.5F);
this.worldObj.playSound(SoundEvent.CHESTOPEN, d1, (double)j + 0.5D, d2, 0.5F);
}
if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F)
{
float f2 = this.lidAngle;
if (this.numPlayersUsing > 0)
{
this.lidAngle += f1;
}
else
{
this.lidAngle -= f1;
}
if (this.lidAngle > 1.0F)
{
this.lidAngle = 1.0F;
}
float f3 = 0.5F;
if (this.lidAngle < f3 && f2 >= f3)
{
double d3 = (double)i + 0.5D;
double d0 = (double)k + 0.5D;
this.worldObj.playSound(SoundEvent.CHESTCLOSED, d3, (double)j + 0.5D, d0, 0.5F);
}
if (this.lidAngle < 0.0F)
{
this.lidAngle = 0.0F;
}
} }
} }