1
0
Fork 0

remove block break progress sending

This commit is contained in:
Sen 2025-08-29 09:45:25 +02:00
parent 01ceef058c
commit 9b0bc17a95
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
12 changed files with 46 additions and 354 deletions

View file

@ -85,7 +85,6 @@ import common.packet.SPacketPlayerAbilities;
import common.packet.SPacketTabComplete;
import common.packet.SPacketUpdateEntityTags;
import common.packet.SPacketAnimation;
import common.packet.SPacketBlockBreakAnim;
import common.packet.SPacketBlockChange;
import common.packet.SPacketCamera;
import common.packet.SPacketCelestials;
@ -1315,15 +1314,6 @@ public class ClientPlayer implements IClientPlayer
this.gm.show(null);
}
/**
* Updates all registered IWorldAccess instances with destroyBlockInWorldPartially
*/
public void handleBlockBreakAnim(SPacketBlockBreakAnim packetIn)
{
NetHandler.checkThread(packetIn, this, this.gm, this.world);
this.gm.renderer.setBreakProgress(packetIn.getBreakerId(), packetIn.getPosition(), packetIn.getProgress());
}
public void handleMapChunkBulk(SPacketMapChunkBulk packetIn)
{
NetHandler.checkThread(packetIn, this, this.gm, this.world);

View file

@ -17,7 +17,6 @@ public class RenderBuffer
private int vertexCount;
private VertexFormatElement vertexFormatElement;
private int vertexFormatIndex;
private boolean noColor;
private int drawMode;
private double xOffset;
private double yOffset;
@ -100,7 +99,6 @@ public class RenderBuffer
this.drawMode = glMode;
this.vertexFormat = format;
this.vertexFormatElement = format.getElement(this.vertexFormatIndex);
this.noColor = false;
this.byteBuffer.limit(this.byteBuffer.capacity());
}
}
@ -233,11 +231,6 @@ public class RenderBuffer
}
}
public void noColor()
{
this.noColor = true;
}
public RenderBuffer color(float red, float green, float blue, float alpha)
{
return this.color((int)(red * 255.0F), (int)(green * 255.0F), (int)(blue * 255.0F), (int)(alpha * 255.0F));
@ -250,60 +243,53 @@ public class RenderBuffer
public RenderBuffer color(int red, int green, int blue, int alpha)
{
if (this.noColor)
int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
switch (this.vertexFormatElement.type())
{
return this;
case FLOAT:
this.byteBuffer.putFloat(i, (float)red / 255.0F);
this.byteBuffer.putFloat(i + 4, (float)green / 255.0F);
this.byteBuffer.putFloat(i + 8, (float)blue / 255.0F);
this.byteBuffer.putFloat(i + 12, (float)alpha / 255.0F);
break;
case UINT:
case INT:
this.byteBuffer.putFloat(i, (float)red);
this.byteBuffer.putFloat(i + 4, (float)green);
this.byteBuffer.putFloat(i + 8, (float)blue);
this.byteBuffer.putFloat(i + 12, (float)alpha);
break;
case USHORT:
case SHORT:
this.byteBuffer.putShort(i, (short)red);
this.byteBuffer.putShort(i + 2, (short)green);
this.byteBuffer.putShort(i + 4, (short)blue);
this.byteBuffer.putShort(i + 6, (short)alpha);
break;
case UBYTE:
case BYTE:
if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN)
{
this.byteBuffer.put(i, (byte)red);
this.byteBuffer.put(i + 1, (byte)green);
this.byteBuffer.put(i + 2, (byte)blue);
this.byteBuffer.put(i + 3, (byte)alpha);
}
else
{
this.byteBuffer.put(i, (byte)alpha);
this.byteBuffer.put(i + 1, (byte)blue);
this.byteBuffer.put(i + 2, (byte)green);
this.byteBuffer.put(i + 3, (byte)red);
}
}
else
{
int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
switch (this.vertexFormatElement.type())
{
case FLOAT:
this.byteBuffer.putFloat(i, (float)red / 255.0F);
this.byteBuffer.putFloat(i + 4, (float)green / 255.0F);
this.byteBuffer.putFloat(i + 8, (float)blue / 255.0F);
this.byteBuffer.putFloat(i + 12, (float)alpha / 255.0F);
break;
case UINT:
case INT:
this.byteBuffer.putFloat(i, (float)red);
this.byteBuffer.putFloat(i + 4, (float)green);
this.byteBuffer.putFloat(i + 8, (float)blue);
this.byteBuffer.putFloat(i + 12, (float)alpha);
break;
case USHORT:
case SHORT:
this.byteBuffer.putShort(i, (short)red);
this.byteBuffer.putShort(i + 2, (short)green);
this.byteBuffer.putShort(i + 4, (short)blue);
this.byteBuffer.putShort(i + 6, (short)alpha);
break;
case UBYTE:
case BYTE:
if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN)
{
this.byteBuffer.put(i, (byte)red);
this.byteBuffer.put(i + 1, (byte)green);
this.byteBuffer.put(i + 2, (byte)blue);
this.byteBuffer.put(i + 3, (byte)alpha);
}
else
{
this.byteBuffer.put(i, (byte)alpha);
this.byteBuffer.put(i + 1, (byte)blue);
this.byteBuffer.put(i + 2, (byte)green);
this.byteBuffer.put(i + 3, (byte)red);
}
}
this.nextVertexFormatIndex();
return this;
}
this.nextVertexFormatIndex();
return this;
}
public void addVertexData(int[] vertexData)

View file

@ -20,7 +20,6 @@ import org.lwjgl.opengl.GL46;
import client.Client;
import client.renderer.Shader.ShaderContext;
import client.renderer.blockmodel.BakedModel;
import client.renderer.blockmodel.BakedQuad;
import client.renderer.blockmodel.IBakedModel;
import client.renderer.blockmodel.ModelManager;
@ -91,39 +90,6 @@ public class Renderer {
}
}
private static class DestroyProgress {
private final int id;
private final BlockPos pos;
private int damage;
private int time;
public DestroyProgress(int id, BlockPos pos) {
this.id = id;
this.pos = pos;
}
public BlockPos getPosition() {
return this.pos;
}
public void setDamage(int damage) {
this.damage = damage > 10 ? 10 : damage;
}
public int getDamage() {
return this.damage;
}
public void setTime(int time) {
this.time = time;
}
public int getTime() {
return this.time;
}
}
private static final String TEX_MOLTEN = "textures/world/molten.png";
private static final String TEX_RAIN = "textures/world/rain.png";
private static final String TEX_HAIL = "textures/world/hail.png";
@ -148,10 +114,8 @@ public class Renderer {
private final RenderManager renderManager;
private final ModelManager manager;
private final Set<TileEntity> setTileEntities = Sets.<TileEntity>newHashSet();
private final Map<Integer, DestroyProgress> damagedBlocks = Maps.<Integer, DestroyProgress>newHashMap();
private final Map<BlockPos, Sound> mapSoundPositions = Maps.<BlockPos, Sound>newHashMap();
private final Map<BlockLiquid, Sprite[]> fluids = Maps.newHashMap();
private final Sprite[] destroyBlockIcons = new Sprite[10];
private float farPlaneDistance;
private int rendererUpdateCount;
@ -309,8 +273,6 @@ public class Renderer {
if(this.lastLightning > 0)
this.lastLightning -= 1;
++this.cloudTickCounter;
if (this.cloudTickCounter % 20 == 0)
this.cleanupDamagedBlocks(this.damagedBlocks.values().iterator());
}
public void getMouseOver(float partialTicks)
@ -1284,9 +1246,8 @@ public class Renderer {
this.drawSelectionBox(entityplayer1, this.gm.pointed, partialTicks);
GlState.enableAlpha();
}
GlState.enableBlend();
// GlState.enableBlend();
GlState.tryBlendFuncSeparate(GL46.GL_SRC_ALPHA, GL46.GL_ONE, GL46.GL_ONE, GL46.GL_ZERO);
this.drawBlockDamageTexture(Tessellator.getBuffer(), entity, partialTicks);
GlState.disableBlend();
// if (!this.debugView)
@ -1837,9 +1798,6 @@ public class Renderer {
this.fluids.put(liquid.second(), sprites);
this.fluids.put(liquid.first(), sprites);
}
for(int i = 0; i < this.destroyBlockIcons.length; ++i) {
this.destroyBlockIcons[i] = texturemap.getAtlasSprite("blocks/destroy_stage_" + i);
}
}
private void generateSky2()
@ -2663,20 +2621,6 @@ public class Renderer {
return l;
}
private void cleanupDamagedBlocks(Iterator<DestroyProgress> iteratorIn)
{
while (iteratorIn.hasNext())
{
DestroyProgress destroyblockprogress = (DestroyProgress)iteratorIn.next();
int i = destroyblockprogress.getTime();
if (this.cloudTickCounter - i > 400)
{
iteratorIn.remove();
}
}
}
private void renderSkyBox(String texture)
{
GlState.disableFog();
@ -3125,75 +3069,6 @@ public class Renderer {
}
}
private void preRenderDamagedBlocks()
{
GlState.tryBlendFuncSeparate(GL46.GL_DST_COLOR, GL46.GL_SRC_COLOR, GL46.GL_ONE, GL46.GL_ZERO);
GlState.enableBlend();
GlState.color(1.0F, 1.0F, 1.0F, 0.5F);
GlState.doPolygonOffset(-3.0F, -3.0F);
GlState.enablePolygonOffset();
GlState.alphaFunc(GL46.GL_GREATER, 0.1F);
GlState.enableAlpha();
GL46.glPushMatrix();
}
private void postRenderDamagedBlocks()
{
GlState.disableAlpha();
GlState.doPolygonOffset(0.0F, 0.0F);
GlState.disablePolygonOffset();
GlState.enableAlpha();
GlState.depthMask(true);
GL46.glPopMatrix();
}
private void drawBlockDamageTexture(RenderBuffer worldRendererIn, Entity entityIn, float partialTicks)
{
double d0 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double)partialTicks;
double d1 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double)partialTicks;
double d2 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double)partialTicks;
if (!this.damagedBlocks.isEmpty())
{
this.renderEngine.bindTexture(TextureMap.BLOCKS);
this.preRenderDamagedBlocks();
worldRendererIn.begin(GL46.GL_QUADS, DefaultVertexFormats.BLOCK);
worldRendererIn.setTranslation(-d0, -d1, -d2);
worldRendererIn.noColor();
Iterator<DestroyProgress> iterator = this.damagedBlocks.values().iterator();
while (iterator.hasNext())
{
DestroyProgress destroyblockprogress = (DestroyProgress)iterator.next();
BlockPos blockpos = destroyblockprogress.getPosition();
double d3 = (double)blockpos.getX() - d0;
double d4 = (double)blockpos.getY() - d1;
double d5 = (double)blockpos.getZ() - d2;
Block block = this.theWorld.getState(blockpos).getBlock();
if (d3 * d3 + d4 * d4 + d5 * d5 > 1024.0D)
{
iterator.remove();
}
else
{
State iblockstate = this.theWorld.getState(blockpos);
if (iblockstate.getBlock() != Blocks.air)
{
int i = destroyblockprogress.getDamage();
Sprite textureatlassprite = this.destroyBlockIcons[i];
this.renderBlockDamage(iblockstate, blockpos, textureatlassprite, this.theWorld);
}
}
}
Tessellator.draw();
worldRendererIn.setTranslation(0.0D, 0.0D, 0.0D);
this.postRenderDamagedBlocks();
}
}
/**
* Draws the selection box for the player. Args: entityPlayer, rayTraceHit, i, itemStack, partialTickTime
*
@ -3293,27 +3168,6 @@ public class Renderer {
this.viewFrustum.markBlocksForUpdate(x1, y1, z1, x2, y2, z2);
}
public void setBreakProgress(int breakerId, BlockPos pos, int progress)
{
if (progress >= 0 && progress < 10)
{
DestroyProgress destroyblockprogress = (DestroyProgress)this.damagedBlocks.get(Integer.valueOf(breakerId));
if (destroyblockprogress == null || destroyblockprogress.getPosition().getX() != pos.getX() || destroyblockprogress.getPosition().getY() != pos.getY() || destroyblockprogress.getPosition().getZ() != pos.getZ())
{
destroyblockprogress = new DestroyProgress(breakerId, pos);
this.damagedBlocks.put(Integer.valueOf(breakerId), destroyblockprogress);
}
destroyblockprogress.setDamage(progress);
destroyblockprogress.setTime(this.cloudTickCounter);
}
else
{
this.damagedBlocks.remove(Integer.valueOf(breakerId));
}
}
public void setDisplayListEntitiesDirty()
{
this.displayListEntitiesDirty = true;
@ -3418,18 +3272,6 @@ public class Renderer {
}
}
private void renderBlockDamage(State state, BlockPos pos, Sprite texture, IWorldAccess world)
{
Block block = state.getBlock();
if (block != Blocks.air && !block.getMaterial().isLiquid())
{
state = block.getState(state, world, pos);
IBakedModel model = new BakedModel.Builder(this.manager.getModelForState(state), texture).makeBakedModel();
block.setBlockBounds(world, pos);
this.renderModel(world, model, state, pos, Tessellator.getBuffer(), true);
}
}
public boolean renderBlock(State state, BlockPos pos, IWorldAccess world, RenderBuffer rb) {
Block block = state.getBlock();
if(this.gm.xrayActive && !block.isXrayVisible())

View file

@ -29,13 +29,7 @@ import common.world.State;
public abstract class ModelBakery
{
private static final Set<String> BUILTINS = Sets.newHashSet(
"blocks/destroy_stage_0", "blocks/destroy_stage_1",
"blocks/destroy_stage_2", "blocks/destroy_stage_3",
"blocks/destroy_stage_4", "blocks/destroy_stage_5",
"blocks/destroy_stage_6", "blocks/destroy_stage_7",
"blocks/destroy_stage_8", "blocks/destroy_stage_9"
);
private static final Set<String> BUILTINS = Sets.newHashSet();
protected static final String MISSING = "builtin/missing";
public static final ModelBlock MODEL_GENERATED = (ModelBlock)new ModelBlock(null).add().d("");
public static final ModelBlock MODEL_ENTITY = (ModelBlock)new ModelBlock(null).add().d("");

View file

@ -109,7 +109,6 @@ public class PlayerController {
this.stack = this.gm.player.getHeldItem();
this.damage = 0.0F;
this.stepCounter = 0.0F;
this.gm.renderer.setBreakProgress(this.gm.player.getId(), this.position, (int)(this.damage * 10.0F) - 1);
}
}
@ -122,7 +121,6 @@ public class PlayerController {
this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.ABORT_DESTROY_BLOCK, this.position, Facing.DOWN));
this.hitting = false;
this.damage = 0.0F;
this.gm.renderer.setBreakProgress(this.gm.player.getId(), this.position, -1);
}
}
@ -164,8 +162,6 @@ public class PlayerController {
this.stepCounter = 0.0F;
this.delay = 5;
}
this.gm.renderer.setBreakProgress(this.gm.player.getId(), this.position, (int)(this.damage * 10.0F) - 1);
return true;
}
}

View file

@ -1,8 +0,0 @@
out vec4 FragColor;
uniform float fog;
uniform vec3 color;
void main() {
FragColor = vec4(color, fog);
}

View file

@ -1,7 +0,0 @@
layout (location = 0) in vec2 coords;
uniform vec2 size;
void main() {
gl_Position = vec4(coords * 2.0 / size, 0.0, 1.0);
}

View file

@ -12,7 +12,6 @@ out float brightness;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
uniform sampler2D tex;
uniform vec3 offset;
uniform int chunk_x;
uniform int chunk_y;

View file

@ -29,7 +29,6 @@ import common.packet.SPacketPlayerAbilities;
import common.packet.SPacketTabComplete;
import common.packet.SPacketUpdateEntityTags;
import common.packet.SPacketAnimation;
import common.packet.SPacketBlockBreakAnim;
import common.packet.SPacketBlockChange;
import common.packet.SPacketCamera;
import common.packet.SPacketCelestials;
@ -118,7 +117,6 @@ public interface IClientPlayer extends NetHandler {
void handleWindowProperty(SPacketWindowProperty packet);
void handleEntityEquipment(SPacketEntityEquipment packet);
void handleCloseWindow(SPacketCloseWindow packet);
void handleBlockBreakAnim(SPacketBlockBreakAnim packet);
void handleMapChunkBulk(SPacketMapChunkBulk packet);
void handleChangeGameState(SPacketChangeGameState packet);
void handleEffect(SPacketEffect packet);

View file

@ -66,7 +66,6 @@ import common.packet.SPacketPlayerAbilities;
import common.packet.SPacketTabComplete;
import common.packet.SPacketUpdateEntityTags;
import common.packet.SPacketAnimation;
import common.packet.SPacketBlockBreakAnim;
import common.packet.SPacketBlockChange;
import common.packet.SPacketCamera;
import common.packet.SPacketCelestials;
@ -152,7 +151,6 @@ public enum PacketRegistry {
this.server(SPacketChunkData.class);
this.server(SPacketMultiBlockChange.class);
this.server(SPacketBlockChange.class);
this.server(SPacketBlockBreakAnim.class);
this.server(SPacketMapChunkBulk.class);
this.server(SPacketExplosion.class);
this.server(SPacketEffect.class);

View file

@ -1,69 +0,0 @@
package common.packet;
import java.io.IOException;
import common.network.IClientPlayer;
import common.network.Packet;
import common.network.PacketBuffer;
import common.util.BlockPos;
public class SPacketBlockBreakAnim implements Packet<IClientPlayer>
{
private int breakerId;
private BlockPos position;
private int progress;
public SPacketBlockBreakAnim()
{
}
public SPacketBlockBreakAnim(int breakerId, BlockPos pos, int progress)
{
this.breakerId = breakerId;
this.position = pos;
this.progress = progress;
}
/**
* Reads the raw packet data from the data stream.
*/
public void readPacketData(PacketBuffer buf) throws IOException
{
this.breakerId = buf.readVarInt();
this.position = buf.readBlockPos();
this.progress = buf.readUnsignedByte();
}
/**
* Writes the raw packet data to the data stream.
*/
public void writePacketData(PacketBuffer buf) throws IOException
{
buf.writeVarInt(this.breakerId);
buf.writeBlockPos(this.position);
buf.writeByte(this.progress);
}
/**
* Passes this Packet on to the NetHandler for processing.
*/
public void processPacket(IClientPlayer handler)
{
handler.handleBlockBreakAnim(this);
}
public int getBreakerId()
{
return this.breakerId;
}
public BlockPos getPosition()
{
return this.position;
}
public int getProgress()
{
return this.progress;
}
}

View file

@ -84,7 +84,6 @@ import common.packet.SPacketSignEditorOpen;
import common.packet.SPacketPlayerAbilities;
import common.packet.SPacketTabComplete;
import common.packet.SPacketAnimation;
import common.packet.SPacketBlockBreakAnim;
import common.packet.SPacketBlockChange;
import common.packet.SPacketCamera;
import common.packet.SPacketCharacterList;
@ -956,26 +955,6 @@ public class Player extends User implements Executor, IPlayer
return new SPacketMapChunkBulk(xPositions, zPositions, chunksData);
}
private void sendBlockBreakProgress(BlockPos pos, int progress)
{
for (Player conn : this.server.getPlayers())
{
EntityNPC player = conn.getPresentEntity();
if (player != null && player.worldObj == this.entity.worldObj && player != this.entity)
{
double d0 = (double)pos.getX() - player.posX;
double d1 = (double)pos.getY() - player.posY;
double d2 = (double)pos.getZ() - player.posZ;
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D)
{
conn.sendPacket(new SPacketBlockBreakAnim(this.entity.getId(), pos, progress));
}
}
}
}
public void updateEntity()
{
if (this.entity.hurtResistance > 0)
@ -1093,7 +1072,6 @@ public class Player extends User implements Executor, IPlayer
if (j != this.durabilityRemainingOnBlock)
{
this.sendBlockBreakProgress(this.removingPos, j);
this.durabilityRemainingOnBlock = j;
}
@ -1110,7 +1088,6 @@ public class Player extends User implements Executor, IPlayer
if (block1 == Blocks.air)
{
this.sendBlockBreakProgress(this.startPos, -1);
this.durabilityRemainingOnBlock = -1;
this.isDestroyingBlock = false;
}
@ -1122,7 +1099,6 @@ public class Player extends User implements Executor, IPlayer
if (l != this.durabilityRemainingOnBlock)
{
this.sendBlockBreakProgress(this.startPos, l);
this.durabilityRemainingOnBlock = l;
}
}
@ -1169,7 +1145,6 @@ public class Player extends User implements Executor, IPlayer
this.isDestroyingBlock = true;
this.startPos = pos;
int i = (int)(f * 10.0F);
this.sendBlockBreakProgress(pos, i);
this.durabilityRemainingOnBlock = i;
}
// }
@ -1189,7 +1164,6 @@ public class Player extends User implements Executor, IPlayer
if (f >= 0.7F)
{
this.isDestroyingBlock = false;
this.sendBlockBreakProgress(pos, -1);
this.tryHarvestBlock(pos);
}
else if (!this.receivedFinishDiggingPacket)
@ -1206,7 +1180,6 @@ public class Player extends User implements Executor, IPlayer
public void cancelDestroyingBlock()
{
this.isDestroyingBlock = false;
this.sendBlockBreakProgress(this.startPos, -1);
}
private boolean removeBlock(BlockPos pos)