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.
This commit is contained in:
RednedEpic 2020-04-30 00:45:27 -05:00
parent ad596cdccb
commit 0ac4789f2c
1 changed files with 6 additions and 1 deletions

View File

@ -25,6 +25,7 @@
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,9 +43,13 @@ 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());
if (updatePlacement) {
this.checkPlace(session, packet);
}
this.checkInteract(session, packet);
this.checkPlace(session, packet);
}
private boolean checkPlace(GeyserSession session, ServerBlockChangePacket packet) {