mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2025-01-08 16:57:54 +01:00
added PlayerAbilities Provider (#3311)
This commit is contained in:
parent
638378cddf
commit
7adadc0d21
@ -25,6 +25,7 @@ import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16Types;
|
||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
@ -40,6 +41,7 @@ import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.metadata.Metadat
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets.EntityPackets;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets.InventoryPackets;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets.WorldPackets;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.provider.PlayerAbilitiesProvider;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.storage.InventoryTracker1_16;
|
||||
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||
@ -195,10 +197,11 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
}
|
||||
|
||||
registerServerbound(ServerboundPackets1_16.PLAYER_ABILITIES, wrapper -> {
|
||||
wrapper.passthrough(Type.BYTE);
|
||||
// Flying and walking speed - not important anyways
|
||||
wrapper.write(Type.FLOAT, 0.05F);
|
||||
wrapper.write(Type.FLOAT, 0.1F);
|
||||
wrapper.passthrough(Type.BYTE); // Flags
|
||||
|
||||
final PlayerAbilitiesProvider playerAbilities = Via.getManager().getProviders().get(PlayerAbilitiesProvider.class);
|
||||
wrapper.write(Type.FLOAT, playerAbilities.getFlyingSpeed());
|
||||
wrapper.write(Type.FLOAT, playerAbilities.getWalkingSpeed());
|
||||
});
|
||||
|
||||
cancelServerbound(ServerboundPackets1_16.GENERATE_JIGSAW);
|
||||
@ -257,6 +260,11 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
.reader("item", ParticleType.Readers.VAR_INT_ITEM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(ViaProviders providers) {
|
||||
providers.register(PlayerAbilitiesProvider.class, new PlayerAbilitiesProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
userConnection.addEntityTracker(this.getClass(), new EntityTrackerBase(userConnection, Entity1_16Types.PLAYER));
|
||||
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2023 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viaversion.protocols.protocol1_16to1_15_2.provider;
|
||||
|
||||
import com.viaversion.viaversion.api.platform.providers.Provider;
|
||||
|
||||
public class PlayerAbilitiesProvider implements Provider {
|
||||
|
||||
public float getFlyingSpeed() {
|
||||
return 0.05F;
|
||||
}
|
||||
|
||||
public float getWalkingSpeed() {
|
||||
return 0.1F;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user