Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-16 04:50:08 +01:00
Add cancel-block-sounds option for 1.8->1.9 place/break fix (#4011)
Dieser Commit ist enthalten in:
Ursprung
323f0fa087
Commit
20f7738f08
@ -457,4 +457,11 @@ public interface ViaVersionConfig extends Config {
|
|||||||
* @return true if enabled
|
* @return true if enabled
|
||||||
*/
|
*/
|
||||||
boolean handleInvalidItemCount();
|
boolean handleInvalidItemCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to cancel block break/place sounds sent by 1.8 servers to 1.9+ clients to prevent them from playing twice
|
||||||
|
*
|
||||||
|
* @return true if enabled
|
||||||
|
*/
|
||||||
|
boolean cancelBlockSounds();
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,9 @@ public class BukkitViaLoader implements ViaPlatformLoader {
|
|||||||
if (serverProtocolVersion.olderThan(ProtocolVersion.v1_9)) {
|
if (serverProtocolVersion.olderThan(ProtocolVersion.v1_9)) {
|
||||||
new ArmorListener(plugin).register();
|
new ArmorListener(plugin).register();
|
||||||
new DeathListener(plugin).register();
|
new DeathListener(plugin).register();
|
||||||
|
if (plugin.getConf().cancelBlockSounds()) {
|
||||||
new BlockListener(plugin).register();
|
new BlockListener(plugin).register();
|
||||||
|
}
|
||||||
|
|
||||||
if (plugin.getConf().isItemCache()) {
|
if (plugin.getConf().isItemCache()) {
|
||||||
handItemCache = new HandItemCache();
|
handItemCache = new HandItemCache();
|
||||||
|
@ -93,6 +93,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
|
|||||||
private boolean translateOcelotToCat;
|
private boolean translateOcelotToCat;
|
||||||
private boolean enforceSecureChat;
|
private boolean enforceSecureChat;
|
||||||
private boolean handleInvalidItemCount;
|
private boolean handleInvalidItemCount;
|
||||||
|
private boolean cancelBlockSounds;
|
||||||
|
|
||||||
protected AbstractViaConfig(final File configFile, final Logger logger) {
|
protected AbstractViaConfig(final File configFile, final Logger logger) {
|
||||||
super(configFile, logger);
|
super(configFile, logger);
|
||||||
@ -159,6 +160,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
|
|||||||
translateOcelotToCat = getBoolean("translate-ocelot-to-cat", true);
|
translateOcelotToCat = getBoolean("translate-ocelot-to-cat", true);
|
||||||
enforceSecureChat = getBoolean("enforce-secure-chat", false);
|
enforceSecureChat = getBoolean("enforce-secure-chat", false);
|
||||||
handleInvalidItemCount = getBoolean("handle-invalid-item-count", false);
|
handleInvalidItemCount = getBoolean("handle-invalid-item-count", false);
|
||||||
|
cancelBlockSounds = getBoolean("cancel-block-sounds", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlockedProtocolVersions loadBlockedProtocolVersions() {
|
private BlockedProtocolVersions loadBlockedProtocolVersions() {
|
||||||
@ -535,4 +537,9 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
|
|||||||
public boolean handleInvalidItemCount() {
|
public boolean handleInvalidItemCount() {
|
||||||
return handleInvalidItemCount;
|
return handleInvalidItemCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean cancelBlockSounds() {
|
||||||
|
return cancelBlockSounds;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,10 @@ public class WorldPacketRewriter1_9 {
|
|||||||
}
|
}
|
||||||
wrapper.set(Types.STRING, 0, newname);
|
wrapper.set(Types.STRING, 0, newname);
|
||||||
wrapper.write(Types.VAR_INT, catid); // Write Category ID
|
wrapper.write(Types.VAR_INT, catid); // Write Category ID
|
||||||
|
|
||||||
|
if (!Via.getConfig().cancelBlockSounds()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (effect != null && effect.isBreakSound()) {
|
if (effect != null && effect.isBreakSound()) {
|
||||||
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class);
|
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class);
|
||||||
int x = wrapper.passthrough(Types.INT); //Position X
|
int x = wrapper.passthrough(Types.INT); //Position X
|
||||||
@ -358,7 +362,27 @@ public class WorldPacketRewriter1_9 {
|
|||||||
map(Types.UNSIGNED_BYTE); // 5 - Y
|
map(Types.UNSIGNED_BYTE); // 5 - Y
|
||||||
map(Types.UNSIGNED_BYTE); // 6 - Z
|
map(Types.UNSIGNED_BYTE); // 6 - Z
|
||||||
|
|
||||||
//Register block place to fix sounds
|
// Handle CommandBlocks
|
||||||
|
handler(wrapper -> {
|
||||||
|
CommandBlockProvider provider = Via.getManager().getProviders().get(CommandBlockProvider.class);
|
||||||
|
|
||||||
|
BlockPosition pos = wrapper.get(Types.BLOCK_POSITION1_8, 0);
|
||||||
|
Optional<CompoundTag> tag = provider.get(wrapper.user(), pos);
|
||||||
|
// Send the Update Block Entity packet if present
|
||||||
|
if (tag.isPresent()) {
|
||||||
|
PacketWrapper updateBlockEntity = PacketWrapper.create(ClientboundPackets1_9.BLOCK_ENTITY_DATA, null, wrapper.user());
|
||||||
|
|
||||||
|
updateBlockEntity.write(Types.BLOCK_POSITION1_8, pos);
|
||||||
|
updateBlockEntity.write(Types.UNSIGNED_BYTE, (short) 2);
|
||||||
|
updateBlockEntity.write(Types.NAMED_COMPOUND_TAG, tag.get());
|
||||||
|
|
||||||
|
updateBlockEntity.scheduleSend(Protocol1_8To1_9.class);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!Via.getConfig().cancelBlockSounds()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
int face = wrapper.get(Types.UNSIGNED_BYTE, 0);
|
int face = wrapper.get(Types.UNSIGNED_BYTE, 0);
|
||||||
if (face == 255)
|
if (face == 255)
|
||||||
@ -378,25 +402,6 @@ public class WorldPacketRewriter1_9 {
|
|||||||
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class);
|
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_8To1_9.class);
|
||||||
tracker.addBlockInteraction(new BlockPosition(x, y, z));
|
tracker.addBlockInteraction(new BlockPosition(x, y, z));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle CommandBlocks
|
|
||||||
handler(wrapper -> {
|
|
||||||
CommandBlockProvider provider = Via.getManager().getProviders().get(CommandBlockProvider.class);
|
|
||||||
|
|
||||||
BlockPosition pos = wrapper.get(Types.BLOCK_POSITION1_8, 0);
|
|
||||||
Optional<CompoundTag> tag = provider.get(wrapper.user(), pos);
|
|
||||||
// Send the Update Block Entity packet if present
|
|
||||||
if (tag.isPresent()) {
|
|
||||||
PacketWrapper updateBlockEntity = PacketWrapper.create(ClientboundPackets1_9.BLOCK_ENTITY_DATA, null, wrapper.user());
|
|
||||||
|
|
||||||
updateBlockEntity.write(Types.BLOCK_POSITION1_8, pos);
|
|
||||||
updateBlockEntity.write(Types.UNSIGNED_BYTE, (short) 2);
|
|
||||||
updateBlockEntity.write(Types.NAMED_COMPOUND_TAG, tag.get());
|
|
||||||
|
|
||||||
updateBlockEntity.scheduleSend(Protocol1_8To1_9.class);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -207,3 +207,5 @@ replacement-piston-id: 0
|
|||||||
chunk-border-fix: false
|
chunk-border-fix: false
|
||||||
# Allows 1.9+ left-handedness (main hand) on 1.8 servers
|
# Allows 1.9+ left-handedness (main hand) on 1.8 servers
|
||||||
left-handed-handling: true
|
left-handed-handling: true
|
||||||
|
# Tries to cancel block break/place sounds sent by 1.8 servers to 1.9+ clients to prevent them from playing twice
|
||||||
|
cancel-block-sounds: true
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren