Don't send sound updates if block of the same type already exists in placing position
This prevents the block place sound (most notably buttons or blocks that don't occupy one whole block) from spamming the client if they have their place button held down.
package org.geysermc.connector.network.translators.java.world;
+import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
import com.nukkitx.math.vector.Vector3i;
import com.nukkitx.protocol.bedrock.data.SoundEvent;
import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
@@ -42,10 +43,14 @@ public class JavaBlockChangeTranslator extends PacketTranslator<ServerBlockChang
@Override
public void translate(ServerBlockChangePacket packet, GeyserSession session) {
+ Position pos = packet.getRecord().getPosition();
+ boolean updatePlacement = !(session.getConnector().getConfig().isCacheChunks() && session.getConnector().getWorldManager().getBlockAt(session, pos.getX(), pos.getY(), pos.getZ()).getId() == packet.getRecord().getBlock().getId());
ChunkUtils.updateBlock(session, packet.getRecord().getBlock(), packet.getRecord().getPosition());
- this.checkInteract(session, packet);
+ if (updatePlacement) {
this.checkPlace(session, packet);
}
+ this.checkInteract(session, packet);
+ }
private boolean checkPlace(GeyserSession session, ServerBlockChangePacket packet) {
Vector3i lastPlacePos = session.getLastBlockPlacePosition();
