mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-12-31 18:18:04 +01:00
Implemented 7adadc0d21
This commit is contained in:
parent
34454a9e0a
commit
b44713b9b2
@ -25,7 +25,7 @@ snake_yml_version=2.0
|
||||
|
||||
# raphimc libs
|
||||
vialegacy_version=2.2.16
|
||||
viaaprilfools_version=2.0.6
|
||||
viaaprilfools_version=2.0.7-SNAPSHOT
|
||||
viabedrock_version=0.0.1-SNAPSHOT
|
||||
minecraftauth_version=2.0.1
|
||||
|
||||
|
@ -19,40 +19,28 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.packet;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.player.PlayerAbilities;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.network.packet.c2s.play.UpdatePlayerAbilitiesC2SPacket;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(UpdatePlayerAbilitiesC2SPacket.class)
|
||||
public class MixinUpdatePlayerAbilitiesC2SPacket {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private boolean flying;
|
||||
|
||||
@Inject(method = "write", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketByteBuf;writeByte(I)Lio/netty/buffer/ByteBuf;", shift = At.Shift.BEFORE), cancellable = true)
|
||||
public void injectWrite(PacketByteBuf buf, CallbackInfo ci) {
|
||||
final PlayerAbilities abilities = MinecraftClient.getInstance().player.getAbilities();
|
||||
|
||||
byte b = 0;
|
||||
|
||||
@Redirect(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketByteBuf;writeByte(I)Lio/netty/buffer/ByteBuf;"))
|
||||
public ByteBuf implementFlags(PacketByteBuf instance, int value) {
|
||||
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(ProtocolVersion.v1_15_2)) {
|
||||
if (this.flying) b = (byte) (b | 2); // Minecraft
|
||||
final PlayerAbilities playerAbilities = MinecraftClient.getInstance().player.getAbilities();
|
||||
|
||||
if (abilities.invulnerable) b |= 1;
|
||||
if (abilities.allowFlying) b |= 4;
|
||||
if (abilities.creativeMode) b |= 8; // Protocol Hack Fixes
|
||||
|
||||
buf.writeByte(b);
|
||||
ci.cancel();
|
||||
if (playerAbilities.invulnerable) value |= 1;
|
||||
if (playerAbilities.allowFlying) value |= 4;
|
||||
if (playerAbilities.creativeMode) value |= 8;
|
||||
}
|
||||
|
||||
return instance.writeByte(value);
|
||||
}
|
||||
}
|
||||
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD 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 de.florianmichael.viafabricplus.injection.mixin.fixes.viaaprilfools;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.player.PlayerAbilities;
|
||||
import net.raphimc.viaaprilfools.protocols.protocol1_16to20w14infinite.ClientboundPackets20w14infinite;
|
||||
import net.raphimc.viaaprilfools.protocols.protocol1_16to20w14infinite.Protocol1_16to20w14infinite;
|
||||
import net.raphimc.viaaprilfools.protocols.protocol1_16to20w14infinite.ServerboundPackets20w14infinite;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(value = Protocol1_16to20w14infinite.class, remap = false)
|
||||
public class MixinProtocol1_16to20w14infinite extends BackwardsProtocol<ClientboundPackets20w14infinite, ClientboundPackets1_16, ServerboundPackets20w14infinite, ServerboundPackets1_16> {
|
||||
|
||||
@Inject(method = "registerPackets", at = @At("RETURN"))
|
||||
public void fixPlayerAbilities(CallbackInfo ci) {
|
||||
this.registerServerbound(ServerboundPackets1_16.PLAYER_ABILITIES, ServerboundPackets20w14infinite.PLAYER_ABILITIES, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
handler(wrapper -> {
|
||||
wrapper.passthrough(Type.BYTE);
|
||||
|
||||
final PlayerAbilities abilities = MinecraftClient.getInstance().player.getAbilities();
|
||||
|
||||
wrapper.write(Type.FLOAT, abilities.getFlySpeed());
|
||||
wrapper.write(Type.FLOAT, abilities.getWalkSpeed());
|
||||
});
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD 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 de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion.protocol1_16to1_15_2;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.player.PlayerAbilities;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Protocol1_16To1_15_2.class)
|
||||
public class MixinProtocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_15, ClientboundPackets1_16, ServerboundPackets1_14, ServerboundPackets1_16> {
|
||||
|
||||
@Inject(method = "registerPackets", at = @At("RETURN"), remap = false)
|
||||
public void injectRegisterPackets(CallbackInfo ci) {
|
||||
this.registerServerbound(ServerboundPackets1_16.PLAYER_ABILITIES, ServerboundPackets1_14.PLAYER_ABILITIES, new PacketHandlers() {
|
||||
public void register() {
|
||||
this.handler((wrapper) -> {
|
||||
wrapper.passthrough(Type.BYTE);
|
||||
final PlayerAbilities abilities = MinecraftClient.getInstance().player.getAbilities();
|
||||
|
||||
wrapper.write(Type.FLOAT, abilities.getFlySpeed());
|
||||
wrapper.write(Type.FLOAT, abilities.getWalkSpeed());
|
||||
});
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
}
|
@ -29,6 +29,7 @@ import com.viaversion.viaversion.libs.gson.JsonArray;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers.PlayerLookTargetProvider;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.provider.PlayerAbilitiesProvider;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemProvider;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
||||
import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
@ -48,6 +49,7 @@ import de.florianmichael.viafabricplus.protocolhack.provider.vialegacy.*;
|
||||
import de.florianmichael.viafabricplus.protocolhack.provider.viaversion.ViaFabricPlusHandItemProvider;
|
||||
import de.florianmichael.viafabricplus.protocolhack.provider.viaversion.ViaFabricPlusMovementTransmitterProvider;
|
||||
import de.florianmichael.viafabricplus.protocolhack.provider.vialoadingbase.ViaFabricPlusVLBBaseVersionProvider;
|
||||
import de.florianmichael.viafabricplus.protocolhack.provider.viaversion.ViaFabricPlusPlayerAbilitiesProvider;
|
||||
import de.florianmichael.viafabricplus.protocolhack.provider.viaversion.ViaFabricPlusPlayerLookTargetProvider;
|
||||
import de.florianmichael.vialoadingbase.ViaLoadingBase;
|
||||
import de.florianmichael.vialoadingbase.model.ComparableProtocolVersion;
|
||||
@ -173,6 +175,7 @@ public class ProtocolHack {
|
||||
providers.use(MovementTransmitterProvider.class, new ViaFabricPlusMovementTransmitterProvider());
|
||||
providers.use(HandItemProvider.class, new ViaFabricPlusHandItemProvider());
|
||||
providers.use(PlayerLookTargetProvider.class, new ViaFabricPlusPlayerLookTargetProvider());
|
||||
providers.use(PlayerAbilitiesProvider.class, new ViaFabricPlusPlayerAbilitiesProvider());
|
||||
|
||||
providers.use(CommandArgumentsProvider.class, new ViaFabricPlusCommandArgumentsProvider());
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD 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 de.florianmichael.viafabricplus.protocolhack.provider.viaversion;
|
||||
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.provider.PlayerAbilitiesProvider;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
||||
public class ViaFabricPlusPlayerAbilitiesProvider extends PlayerAbilitiesProvider {
|
||||
|
||||
@Override
|
||||
public float getFlyingSpeed() {
|
||||
return MinecraftClient.getInstance().player.getAbilities().getFlySpeed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWalkingSpeed() {
|
||||
return MinecraftClient.getInstance().player.getAbilities().getWalkSpeed();
|
||||
}
|
||||
}
|
@ -119,7 +119,6 @@
|
||||
"fixes.minecraft.screen.screenhandler.MixinPlayerScreenHandler",
|
||||
"fixes.minecraft.screen.screenhandler.MixinScreenHandler",
|
||||
"fixes.sodium.MixinChunkTracker",
|
||||
"fixes.viaaprilfools.MixinProtocol1_16to20w14infinite",
|
||||
"fixes.viabedrock.MixinBedrockProtocol",
|
||||
"fixes.viabedrock.MixinJoinPackets",
|
||||
"fixes.vialegacy.MixinClassicProtocolExtension",
|
||||
@ -142,7 +141,6 @@
|
||||
"fixes.viaversion.protocol1_14to1_13_2.MixinInventoryPackets_2",
|
||||
"fixes.viaversion.protocol1_15to1_14_4.MixinMetadataRewriter1_15To1_14_4",
|
||||
"fixes.viaversion.protocol1_16_2to1_16_1.MixinWorldPackets_2",
|
||||
"fixes.viaversion.protocol1_16to1_15_2.MixinProtocol1_16To1_15_2",
|
||||
"fixes.viaversion.protocol1_17to1_16_4.MixinEntityPackets1_17",
|
||||
"fixes.viaversion.protocol1_17to1_16_4.MixinInventoryAcknowledgements",
|
||||
"fixes.viaversion.protocol1_17to1_16_4.MixinWorldPackets1_17",
|
||||
|
Loading…
Reference in New Issue
Block a user