mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
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:
parent
ad596cdccb
commit
0ac4789f2c
1 changed files with 6 additions and 1 deletions
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
package org.geysermc.connector.network.translators.java.world;
|
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.math.vector.Vector3i;
|
||||||
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
||||||
import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
|
import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
|
||||||
|
@ -42,10 +43,14 @@ public class JavaBlockChangeTranslator extends PacketTranslator<ServerBlockChang
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(ServerBlockChangePacket packet, GeyserSession session) {
|
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());
|
ChunkUtils.updateBlock(session, packet.getRecord().getBlock(), packet.getRecord().getPosition());
|
||||||
this.checkInteract(session, packet);
|
if (updatePlacement) {
|
||||||
this.checkPlace(session, packet);
|
this.checkPlace(session, packet);
|
||||||
}
|
}
|
||||||
|
this.checkInteract(session, packet);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean checkPlace(GeyserSession session, ServerBlockChangePacket packet) {
|
private boolean checkPlace(GeyserSession session, ServerBlockChangePacket packet) {
|
||||||
Vector3i lastPlacePos = session.getLastBlockPlacePosition();
|
Vector3i lastPlacePos = session.getLastBlockPlacePosition();
|
||||||
|
|
Loading…
Reference in a new issue