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

@ -20,8 +20,12 @@ import common.inventory.InventoryHelper;
import common.item.CheatTab;
import common.item.ItemStack;
import common.item.tool.ItemKey;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.packet.SPacketSoundEffect;
import common.properties.Property;
import common.properties.PropertyBool;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityChest;
import common.util.BlockPos;
@ -31,9 +35,11 @@ import common.vars.Vars;
import common.world.State;
import common.world.World;
import common.world.AWorldServer;
import common.world.IWorldAccess;
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 final int width;
@ -46,7 +52,7 @@ public class BlockChest extends Block implements ITileEntityProvider, Rotatable
public BlockChest(int width, int height)
{
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.height = height;
this.setTab(CheatTab.TECHNOLOGY);
@ -74,11 +80,6 @@ public class BlockChest extends Block implements ITileEntityProvider, Rotatable
return false;
}
public int getRenderType()
{
return 2;
}
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());
@ -230,15 +231,65 @@ public class BlockChest extends Block implements ITileEntityProvider, Rotatable
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()
{
return true;
}
public String getFallbackTexture() {
return "oak_planks";
public Model getModel(ModelProvider provider, String name, State state) {
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 String code;
public float lidAngle;
public float prevLidAngle;
public boolean wasOpen;
public int numPlayersUsing;
private int ticksSinceSync;
private String customName;
@ -216,49 +215,11 @@ public class TileEntityChest extends TileEntity implements ITickable, IInventory
}
}
this.prevLidAngle = this.lidAngle;
float f1 = 0.1F;
if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F)
if ((this.numPlayersUsing <= 0 && this.wasOpen) || (this.numPlayersUsing > 0 && !this.wasOpen))
{
double d1 = (double)i + 0.5D;
double d2 = (double)k + 0.5D;
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;
}
double d3 = (double)i + 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);
}
}