code cleanup

This commit is contained in:
Sen 2025-07-23 14:23:06 +02:00
parent 76e018b4ed
commit 9688d1d802
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
102 changed files with 290 additions and 356 deletions

View file

@ -290,30 +290,25 @@ public class Client implements IThreadListener {
this.updatePhysics();
}
public boolean spawnEntityInWorld(Entity entityIn) {
boolean flag = super.spawnEntityInWorld(entityIn);
Client.this.spawnEntityInWorld(flag, entityIn);
return flag;
}
public void removeEntity(Entity entityIn) {
super.removeEntity(entityIn);
Client.this.removeEntity(entityIn);
}
protected void onEntityAdded(Entity entityIn) {
Client.this.onEntityAdded(entityIn);
if(Client.this.spawnQueue.contains(entityIn))
Client.this.spawnQueue.remove(entityIn);
}
protected void onEntityRemoved(Entity entityIn) {
Client.this.onEntityRemoved(entityIn);
if(Client.this.entityList.contains(entityIn)) {
if(entityIn.isEntityAlive())
Client.this.spawnQueue.add(entityIn);
else
Client.this.entityList.remove(entityIn);
}
}
public Entity getEntityByID(int id) {
return id == Client.this.player.getId() ? Client.this.player : super.getEntityByID(id);
}
public void playSound(double x, double y, double z, SoundEvent sound, float volume) {
public void clientSound(SoundEvent sound, double x, double y, double z, float volume) {
Client.this.getSoundManager().playSound(new PositionedSound(sound, volume, (float)x, (float)y, (float)z));
}
@ -336,11 +331,11 @@ public class Client implements IThreadListener {
return allowEmpty || !Client.this.getChunk(x, z).isDummy();
}
public void spawnParticle(ParticleType particle, double xCoord, double yCoord, double zCoord, int data) {
public void clientParticle(ParticleType particle, double xCoord, double yCoord, double zCoord, int data) {
Client.this.effectRenderer.spawnParticle(Client.this.getRenderViewEntity(), particle, xCoord, yCoord, zCoord, data);
}
public void playAuxSFX(EntityNPC player, int sfxType, BlockPos blockPosIn, int data) {
public void playEffect(EntityNPC player, int sfxType, BlockPos blockPosIn, int data) {
if(Client.this.getNetHandler() != null)
Client.this.getNetHandler().playAuxSFX(sfxType, blockPosIn, data);
}
@ -352,14 +347,14 @@ public class Client implements IThreadListener {
Client.this.renderGlobal.markBlocksForUpdate(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1);
}
public void notifyLightSet(BlockPos pos) {
public void clientNotifyLight(BlockPos pos) {
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
Client.this.renderGlobal.markBlocksForUpdate(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1);
}
public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2) {
public void clientRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2) {
Client.this.renderGlobal.markBlocksForUpdate(x1 - 1, y1 - 1, z1 - 1, x2 + 1, y2 + 1, z2 + 1);
}
@ -1629,7 +1624,7 @@ public class Client implements IThreadListener {
}
this.player.preparePlayerToSpawn();
world.spawnEntityInWorld(this.player);
this.spawnEntity(this.player);
this.viewEntity = this.player;
System.gc();
@ -1645,6 +1640,7 @@ public class Client implements IThreadListener {
{
i = this.player.getId();
this.world.removeEntity(this.player);
this.entityList.remove(this.player);
}
this.viewEntity = null;
@ -1653,7 +1649,7 @@ public class Client implements IThreadListener {
this.player.getDataWatcher().updateWatchedObjectsFromList(entityplayersp.getDataWatcher().getAllWatched());
this.viewEntity = this.player;
this.player.preparePlayerToSpawn();
this.world.spawnEntityInWorld(this.player);
this.spawnEntity(this.player);
this.player.rotYaw = -180.0F;
this.player.setId(i);
}
@ -3340,7 +3336,7 @@ public class Client implements IThreadListener {
float y = (posY < -32 ? (float)posY - 32.0f : -64.0f) + rand.floatv() * 65.0f;
float z = ((float)posZ) + (rand.floatv() - rand.floatv() - 0.5f) * 32.0f;
if(y < -64.0f || rand.floatv() >= (64.0f + y) / 64.0f)
this.world.spawnParticle(ParticleType.DEPTH, (double)x, (double)y, (double)z);
this.world.clientParticle(ParticleType.DEPTH, (double)x, (double)y, (double)z);
}
}
}
@ -3519,15 +3515,13 @@ public class Client implements IThreadListener {
if (entity != null)
{
this.world.removeEntity(entity);
this.entityList.remove(entity);
}
this.entityList.add(entityToSpawn);
entityToSpawn.setId(entityID);
if (!this.world.spawnEntityInWorld(entityToSpawn))
{
this.spawnQueue.add(entityToSpawn);
}
this.spawnEntity(entityToSpawn);
this.entityIds.addKey(entityID, entityToSpawn);
}
@ -3540,6 +3534,7 @@ public class Client implements IThreadListener {
{
this.entityList.remove(entity);
this.world.removeEntity(entity);
this.entityList.remove(entity);
}
return entity;
@ -3563,7 +3558,13 @@ public class Client implements IThreadListener {
for (int l = 0; l < this.unloaded.size(); ++l)
{
this.onEntityRemoved(this.unloaded.get(l));
Entity entity2 = this.unloaded.get(l);
if(this.entityList.contains(entity2)) {
if(entity2.isEntityAlive())
this.spawnQueue.add(entity2);
else
this.entityList.remove(entity2);
}
}
this.unloaded.clear();
@ -3594,54 +3595,20 @@ public class Client implements IThreadListener {
}
this.entities.remove(i1--);
this.onEntityRemoved(entity1);
if(this.entityList.contains(entity1))
Client.this.entityList.remove(entity1);
}
}
}
private void spawnEntityInWorld(boolean flag, Entity entityIn)
{
this.entityList.add(entityIn);
if (!flag)
{
this.spawnQueue.add(entityIn);
}
else if (entityIn instanceof EntityCart)
{
this.soundManager.playSound(new MovingSoundMinecart((EntityCart)entityIn));
}
}
private void removeEntity(Entity entityIn)
{
this.entityList.remove(entityIn);
}
private void onEntityAdded(Entity entityIn)
{
if (this.spawnQueue.contains(entityIn))
{
this.spawnQueue.remove(entityIn);
}
}
private void onEntityRemoved(Entity entityIn)
{
boolean flag = false;
if (this.entityList.contains(entityIn))
{
if (entityIn.isEntityAlive())
{
this.spawnQueue.add(entityIn);
flag = true;
}
else
{
this.entityList.remove(entityIn);
}
}
}
private void spawnEntity(Entity entityIn) {
boolean flag = this.world.spawnEntityInWorld(entityIn);
this.entityList.add(entityIn);
if(!flag)
this.spawnQueue.add(entityIn);
else if(entityIn instanceof EntityCart)
this.soundManager.playSound(new MovingSoundMinecart((EntityCart)entityIn));
}
private void ensureAreaLoaded(Entity entity) {
int x = ExtMath.floord(entity.posX / 16.0D);

View file

@ -1998,7 +1998,7 @@ public class ClientPlayer implements IClientPlayer
try
{
this.world.spawnParticle(packetIn.getParticleType(), packetIn.getXCoordinate(), packetIn.getYCoordinate(), packetIn.getZCoordinate(), packetIn.getParticleArg());
this.world.clientParticle(packetIn.getParticleType(), packetIn.getXCoordinate(), packetIn.getYCoordinate(), packetIn.getZCoordinate(), packetIn.getParticleArg());
}
catch (Throwable var17)
{

View file

@ -495,7 +495,7 @@ public class EffectRenderer {
float f = (float)this.age / (float)this.lifetime;
if(rng.floatv() > f) {
world.spawnParticle(ParticleType.SMOKE, this.posX, this.posY, this.posZ);
world.clientParticle(ParticleType.SMOKE, this.posX, this.posY, this.posZ);
}
this.motionY -= 0.03D;
@ -888,7 +888,7 @@ public class EffectRenderer {
double y = (double)(rng.floatv() * 2.0F - 1.0F);
double z = (double)(rng.floatv() * 2.0F - 1.0F);
if(x * x + y * y + z * z <= 1.0D)
world.spawnParticle(ParticleType.CRIT, this.entity.posX + x * (double)this.entity.width / 4.0D,
world.clientParticle(ParticleType.CRIT, this.entity.posX + x * (double)this.entity.width / 4.0D,
this.entity.getEntityBoundingBox().minY + (double)(this.entity.height / 2.0F) + y * (double)this.entity.height / 4.0D,
this.entity.posZ + z * (double)this.entity.width / 4.0D);
}
@ -910,7 +910,7 @@ public class EffectRenderer {
double x = this.posX + (rng.doublev() - rng.doublev()) * 4.0D;
double y = this.posY + (rng.doublev() - rng.doublev()) * 4.0D;
double z = this.posZ + (rng.doublev() - rng.doublev()) * 4.0D;
world.spawnParticle(ParticleType.EXPLOSION_LARGE, x, y, z, (int)(100.0f * (float)this.age / (float)this.lifetime));
world.clientParticle(ParticleType.EXPLOSION_LARGE, x, y, z, (int)(100.0f * (float)this.age / (float)this.lifetime));
}
}

View file

@ -1354,7 +1354,7 @@ public class EntityRenderer {
}
}
if(temp < 194.0f || this.random.chance(8))
this.gm.world.spawnParticle(temp >= 194.0f && this.random.chance(20) ? ParticleType.LAVA : ParticleType.SMOKE, (double)blockpos1.getX() + d3, (double)((float)blockpos1.getY() + 0.1F) - block.getBlockBoundsMinY(), (double)blockpos1.getZ() + d4);
this.gm.world.clientParticle(temp >= 194.0f && this.random.chance(20) ? ParticleType.LAVA : ParticleType.SMOKE, (double)blockpos1.getX() + d3, (double)((float)blockpos1.getY() + 0.1F) - block.getBlockBoundsMinY(), (double)blockpos1.getZ() + d4);
}
else if (block != Blocks.air)
{
@ -1368,7 +1368,7 @@ public class EntityRenderer {
d2 = (double)blockpos2.getZ() + d4;
}
this.gm.world.spawnParticle(temp <= 5.0f ? ParticleType.HAIL_CORN : ParticleType.WATER_DROP, (double)blockpos2.getX() + d3, (double)((float)blockpos2.getY() + 0.1F) + block.getBlockBoundsMaxY(), (double)blockpos2.getZ() + d4);
this.gm.world.clientParticle(temp <= 5.0f ? ParticleType.HAIL_CORN : ParticleType.WATER_DROP, (double)blockpos2.getX() + d3, (double)((float)blockpos2.getY() + 0.1F) + block.getBlockBoundsMaxY(), (double)blockpos2.getZ() + d4);
}
}
}

View file

@ -54,7 +54,7 @@ public class PlayerController {
return false;
}
else {
world.playAuxSFX(2001, pos, BlockRegistry.getId(state));
world.playEffect(2001, pos, BlockRegistry.getId(state));
boolean flag = world.setBlockToAir(pos);
if(flag) {