Move config option check for placement fix into packet handlers (#4248)

Fixes the config option breaking when using the reload command, also changes the message when using the /reload sub command.
This commit is contained in:
EnZaXD 2024-11-06 15:46:11 +01:00 committed by GitHub
parent 1620fc35f5
commit 8e4da81022
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 4 deletions

View File

@ -35,7 +35,7 @@ public class ReloadSubCmd implements ViaSubCommand {
@Override @Override
public boolean execute(ViaCommandSender sender, String[] args) { public boolean execute(ViaCommandSender sender, String[] args) {
Via.getManager().getConfigurationProvider().reloadConfigs(); Via.getManager().getConfigurationProvider().reloadConfigs();
sendMessage(sender, "&6Configuration successfully reloaded! Some features may need a restart."); sendMessage(sender, "&6Configuration successfully reloaded! Some config options may require a restart to take effect.");
return true; return true;
} }
} }

View File

@ -125,10 +125,10 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPa
}); });
// Tracks on ground state for block interactions // Tracks on ground state for block interactions
protocol.registerServerbound(ServerboundPackets1_20_5.MOVE_PLAYER_POS, wrapper -> {
if (!Via.getConfig().fix1_21PlacementRotation()) { if (!Via.getConfig().fix1_21PlacementRotation()) {
return; return;
} }
protocol.registerServerbound(ServerboundPackets1_20_5.MOVE_PLAYER_POS, wrapper -> {
wrapper.passthrough(Types.DOUBLE); // X wrapper.passthrough(Types.DOUBLE); // X
wrapper.passthrough(Types.DOUBLE); // Y wrapper.passthrough(Types.DOUBLE); // Y
wrapper.passthrough(Types.DOUBLE); // Z wrapper.passthrough(Types.DOUBLE); // Z
@ -136,12 +136,18 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPa
wrapper.user().get(OnGroundTracker.class).setOnGround(wrapper.passthrough(Types.BOOLEAN)); wrapper.user().get(OnGroundTracker.class).setOnGround(wrapper.passthrough(Types.BOOLEAN));
}); });
protocol.registerServerbound(ServerboundPackets1_20_5.MOVE_PLAYER_ROT, wrapper -> { protocol.registerServerbound(ServerboundPackets1_20_5.MOVE_PLAYER_ROT, wrapper -> {
if (!Via.getConfig().fix1_21PlacementRotation()) {
return;
}
wrapper.passthrough(Types.FLOAT); // Yaw wrapper.passthrough(Types.FLOAT); // Yaw
wrapper.passthrough(Types.FLOAT); // Pitch wrapper.passthrough(Types.FLOAT); // Pitch
wrapper.user().get(OnGroundTracker.class).setOnGround(wrapper.passthrough(Types.BOOLEAN)); wrapper.user().get(OnGroundTracker.class).setOnGround(wrapper.passthrough(Types.BOOLEAN));
}); });
protocol.registerServerbound(ServerboundPackets1_20_5.MOVE_PLAYER_POS_ROT, wrapper -> { protocol.registerServerbound(ServerboundPackets1_20_5.MOVE_PLAYER_POS_ROT, wrapper -> {
if (!Via.getConfig().fix1_21PlacementRotation()) {
return;
}
wrapper.passthrough(Types.DOUBLE); // X wrapper.passthrough(Types.DOUBLE); // X
wrapper.passthrough(Types.DOUBLE); // Y wrapper.passthrough(Types.DOUBLE); // Y
wrapper.passthrough(Types.DOUBLE); // Z wrapper.passthrough(Types.DOUBLE); // Z
@ -151,6 +157,9 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPa
wrapper.user().get(OnGroundTracker.class).setOnGround(wrapper.passthrough(Types.BOOLEAN)); wrapper.user().get(OnGroundTracker.class).setOnGround(wrapper.passthrough(Types.BOOLEAN));
}); });
protocol.registerServerbound(ServerboundPackets1_20_5.MOVE_PLAYER_STATUS_ONLY, wrapper -> { protocol.registerServerbound(ServerboundPackets1_20_5.MOVE_PLAYER_STATUS_ONLY, wrapper -> {
if (!Via.getConfig().fix1_21PlacementRotation()) {
return;
}
wrapper.user().get(OnGroundTracker.class).setOnGround(wrapper.passthrough(Types.BOOLEAN)); wrapper.user().get(OnGroundTracker.class).setOnGround(wrapper.passthrough(Types.BOOLEAN));
}); });
} }