mirror of
https://github.com/ViaVersion/ViaForge.git
synced 2025-02-18 02:02:24 +01:00
Added proper fix for the idle packet in <= 1.8
This commit is contained in:
parent
484c8ba9a8
commit
3fed59dbda
@ -37,13 +37,18 @@ public class ViaForgeConfig extends Config {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(String path, Object value) {
|
||||||
|
super.set(path, value);
|
||||||
|
save(); // Automatically save the config when something changes
|
||||||
|
}
|
||||||
|
|
||||||
public int getClientSideVersion() {
|
public int getClientSideVersion() {
|
||||||
return getInt(CLIENT_SIDE_VERSION, 0);
|
return getInt(CLIENT_SIDE_VERSION, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClientSideVersion(final int version) {
|
public void setClientSideVersion(final int version) {
|
||||||
set(CLIENT_SIDE_VERSION, version);
|
set(CLIENT_SIDE_VERSION, version);
|
||||||
save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowMainMenuButton() {
|
public boolean isShowMainMenuButton() {
|
||||||
|
@ -18,8 +18,10 @@
|
|||||||
package de.florianmichael.viaforge.common.protocolhack;
|
package de.florianmichael.viaforge.common.protocolhack;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||||
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
|
||||||
import de.florianmichael.viaforge.common.protocolhack.provider.ViaForgeVersionProvider;
|
import de.florianmichael.viaforge.common.protocolhack.provider.ViaForgeVersionProvider;
|
||||||
import net.raphimc.vialoader.impl.viaversion.VLLoader;
|
import net.raphimc.vialoader.impl.viaversion.VLLoader;
|
||||||
|
|
||||||
@ -32,5 +34,12 @@ public class ViaForgeVLLoader extends VLLoader {
|
|||||||
final ViaProviders providers = Via.getManager().getProviders();
|
final ViaProviders providers = Via.getManager().getProviders();
|
||||||
|
|
||||||
providers.use(VersionProvider.class, new ViaForgeVersionProvider());
|
providers.use(VersionProvider.class, new ViaForgeVersionProvider());
|
||||||
|
providers.use(MovementTransmitterProvider.class, new MovementTransmitterProvider() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendPlayer(UserConnection userConnection) {
|
||||||
|
// We are on the client side, so we can handle the idle packet properly
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package de.florianmichael.viaforge.mixin.impl.fixes;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||||
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.raphimc.vialoader.util.VersionEnum;
|
||||||
|
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.Redirect;
|
||||||
|
|
||||||
|
@Mixin(EntityPlayerSP.class)
|
||||||
|
public class MixinEntityPlayerSP extends AbstractClientPlayer {
|
||||||
|
|
||||||
|
@Shadow private boolean prevOnGround;
|
||||||
|
|
||||||
|
public MixinEntityPlayerSP(World worldIn, GameProfile playerProfile) {
|
||||||
|
super(worldIn, playerProfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "onUpdateWalkingPlayer", at = @At(value = "FIELD", target = "Lnet/minecraft/client/entity/EntityPlayerSP;prevOnGround:Z", ordinal = 0))
|
||||||
|
public boolean emulateIdlePacket(EntityPlayerSP instance) {
|
||||||
|
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||||
|
// <= 1.8 spams the idle packet instead of only sending it when the ground state changes
|
||||||
|
// So we invert the original logic:
|
||||||
|
// if (prevOnGround != onGround) sendPacket
|
||||||
|
// To be like:
|
||||||
|
// if (!onGround != onGround) sendPacket
|
||||||
|
// Which is the same as:
|
||||||
|
// if (true) sendPacket
|
||||||
|
return !onGround;
|
||||||
|
}
|
||||||
|
return prevOnGround;
|
||||||
|
}
|
||||||
|
}
|
@ -5,11 +5,14 @@
|
|||||||
"package": "de.florianmichael.viaforge.mixin.impl",
|
"package": "de.florianmichael.viaforge.mixin.impl",
|
||||||
"refmap": "mixins.viaforge-mc112.refmap.json",
|
"refmap": "mixins.viaforge-mc112.refmap.json",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"MixinNetworkManager",
|
|
||||||
"MixinNetworkManager_5",
|
|
||||||
"MixinGuiMainMenu",
|
"MixinGuiMainMenu",
|
||||||
"MixinGuiMultiplayer",
|
"MixinGuiMultiplayer",
|
||||||
"MixinGuiScreenServerList"
|
"MixinGuiScreenServerList",
|
||||||
|
"MixinNetworkManager",
|
||||||
|
"MixinNetworkManager_5"
|
||||||
],
|
],
|
||||||
"verbose": true
|
"verbose": true,
|
||||||
|
"client": [
|
||||||
|
"fixes.MixinEntityPlayerSP"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package de.florianmichael.viaforge.mixin.fixes;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
|
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
|
||||||
|
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||||
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
import net.raphimc.vialoader.util.VersionEnum;
|
||||||
|
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.Redirect;
|
||||||
|
|
||||||
|
@Mixin(ClientPlayerEntity.class)
|
||||||
|
public class MixinClientPlayerEntity extends AbstractClientPlayerEntity {
|
||||||
|
|
||||||
|
@Shadow private boolean lastOnGround;
|
||||||
|
|
||||||
|
public MixinClientPlayerEntity(ClientWorld world, GameProfile profile) {
|
||||||
|
super(world, profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "sendPosition", at = @At(value = "FIELD", target = "Lnet/minecraft/client/entity/player/ClientPlayerEntity;lastOnGround:Z", ordinal = 0))
|
||||||
|
public boolean emulateIdlePacket(ClientPlayerEntity instance) {
|
||||||
|
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||||
|
// <= 1.8 spams the idle packet instead of only sending it when the ground state changes
|
||||||
|
// So we invert the original logic:
|
||||||
|
// if (prevOnGround != onGround) sendPacket
|
||||||
|
// To be like:
|
||||||
|
// if (!onGround != onGround) sendPacket
|
||||||
|
// Which is the same as:
|
||||||
|
// if (true) sendPacket
|
||||||
|
return !onGround;
|
||||||
|
}
|
||||||
|
return lastOnGround;
|
||||||
|
}
|
||||||
|
}
|
@ -4,14 +4,17 @@
|
|||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"package": "de.florianmichael.viaforge.mixin",
|
"package": "de.florianmichael.viaforge.mixin",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"MixinNetworkManager",
|
|
||||||
"MixinNetworkManager_1",
|
|
||||||
"MixinMainMenuScreen",
|
"MixinMainMenuScreen",
|
||||||
"MixinMultiplayerScreen",
|
"MixinMultiplayerScreen",
|
||||||
|
"MixinNetworkManager",
|
||||||
|
"MixinNetworkManager_1",
|
||||||
"MixinServerListScreen"
|
"MixinServerListScreen"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
},
|
},
|
||||||
"refmap": "mixins.viaforge-mc114.refmap.json"
|
"refmap": "mixins.viaforge-mc114.refmap.json",
|
||||||
|
"client": [
|
||||||
|
"fixes.MixinClientPlayerEntity"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package de.florianmichael.viaforge.mixin.fixes;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
|
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
|
||||||
|
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||||
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
import net.raphimc.vialoader.util.VersionEnum;
|
||||||
|
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.Redirect;
|
||||||
|
|
||||||
|
@Mixin(ClientPlayerEntity.class)
|
||||||
|
public class MixinClientPlayerEntity extends AbstractClientPlayerEntity {
|
||||||
|
|
||||||
|
@Shadow private boolean lastOnGround;
|
||||||
|
|
||||||
|
public MixinClientPlayerEntity(ClientWorld world, GameProfile profile) {
|
||||||
|
super(world, profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "sendPosition", at = @At(value = "FIELD", target = "Lnet/minecraft/client/entity/player/ClientPlayerEntity;lastOnGround:Z", ordinal = 0))
|
||||||
|
public boolean emulateIdlePacket(ClientPlayerEntity instance) {
|
||||||
|
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||||
|
// <= 1.8 spams the idle packet instead of only sending it when the ground state changes
|
||||||
|
// So we invert the original logic:
|
||||||
|
// if (prevOnGround != onGround) sendPacket
|
||||||
|
// To be like:
|
||||||
|
// if (!onGround != onGround) sendPacket
|
||||||
|
// Which is the same as:
|
||||||
|
// if (true) sendPacket
|
||||||
|
return !onGround;
|
||||||
|
}
|
||||||
|
return lastOnGround;
|
||||||
|
}
|
||||||
|
}
|
@ -4,14 +4,17 @@
|
|||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"package": "de.florianmichael.viaforge.mixin",
|
"package": "de.florianmichael.viaforge.mixin",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"MixinNetworkManager",
|
|
||||||
"MixinNetworkManager_1",
|
|
||||||
"MixinMainMenuScreen",
|
"MixinMainMenuScreen",
|
||||||
"MixinMultiplayerScreen",
|
"MixinMultiplayerScreen",
|
||||||
|
"MixinNetworkManager",
|
||||||
|
"MixinNetworkManager_1",
|
||||||
"MixinServerListScreen"
|
"MixinServerListScreen"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
},
|
},
|
||||||
"refmap": "mixins.viaforge-mc115.refmap.json"
|
"refmap": "mixins.viaforge-mc115.refmap.json",
|
||||||
|
"client": [
|
||||||
|
"fixes.MixinClientPlayerEntity"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package de.florianmichael.viaforge.mixin.fixes;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
|
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
|
||||||
|
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||||
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
import net.raphimc.vialoader.util.VersionEnum;
|
||||||
|
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.Redirect;
|
||||||
|
|
||||||
|
@Mixin(ClientPlayerEntity.class)
|
||||||
|
public class MixinClientPlayerEntity extends AbstractClientPlayerEntity {
|
||||||
|
|
||||||
|
@Shadow private boolean lastOnGround;
|
||||||
|
|
||||||
|
public MixinClientPlayerEntity(ClientWorld world, GameProfile profile) {
|
||||||
|
super(world, profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "sendPosition", at = @At(value = "FIELD", target = "Lnet/minecraft/client/entity/player/ClientPlayerEntity;lastOnGround:Z", ordinal = 0))
|
||||||
|
public boolean emulateIdlePacket(ClientPlayerEntity instance) {
|
||||||
|
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||||
|
// <= 1.8 spams the idle packet instead of only sending it when the ground state changes
|
||||||
|
// So we invert the original logic:
|
||||||
|
// if (prevOnGround != onGround) sendPacket
|
||||||
|
// To be like:
|
||||||
|
// if (!onGround != onGround) sendPacket
|
||||||
|
// Which is the same as:
|
||||||
|
// if (true) sendPacket
|
||||||
|
return !onGround;
|
||||||
|
}
|
||||||
|
return lastOnGround;
|
||||||
|
}
|
||||||
|
}
|
@ -4,14 +4,17 @@
|
|||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"package": "de.florianmichael.viaforge.mixin",
|
"package": "de.florianmichael.viaforge.mixin",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"MixinNetworkManager",
|
|
||||||
"MixinNetworkManager_1",
|
|
||||||
"MixinMainMenuScreen",
|
"MixinMainMenuScreen",
|
||||||
"MixinMultiplayerScreen",
|
"MixinMultiplayerScreen",
|
||||||
|
"MixinNetworkManager",
|
||||||
|
"MixinNetworkManager_1",
|
||||||
"MixinServerListScreen"
|
"MixinServerListScreen"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
},
|
},
|
||||||
"refmap": "mixins.viaforge-mc116.refmap.json"
|
"refmap": "mixins.viaforge-mc116.refmap.json",
|
||||||
|
"client": [
|
||||||
|
"fixes.MixinClientPlayerEntity"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package de.florianmichael.viaforge.mixin.fixes;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
|
import net.minecraft.client.player.AbstractClientPlayer;
|
||||||
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
|
import net.raphimc.vialoader.util.VersionEnum;
|
||||||
|
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.Redirect;
|
||||||
|
|
||||||
|
@Mixin(LocalPlayer.class)
|
||||||
|
public class MixinLocalPlayer extends AbstractClientPlayer {
|
||||||
|
|
||||||
|
@Shadow private boolean lastOnGround;
|
||||||
|
|
||||||
|
public MixinLocalPlayer(ClientLevel level, GameProfile profile) {
|
||||||
|
super(level, profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "sendPosition", at = @At(value = "FIELD", target = "Lnet/minecraft/client/player/LocalPlayer;lastOnGround:Z", ordinal = 0))
|
||||||
|
public boolean emulateIdlePacket(LocalPlayer instance) {
|
||||||
|
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||||
|
// <= 1.8 spams the idle packet instead of only sending it when the ground state changes
|
||||||
|
// So we invert the original logic:
|
||||||
|
// if (prevOnGround != onGround) sendPacket
|
||||||
|
// To be like:
|
||||||
|
// if (!onGround != onGround) sendPacket
|
||||||
|
// Which is the same as:
|
||||||
|
// if (true) sendPacket
|
||||||
|
return !onGround;
|
||||||
|
}
|
||||||
|
return lastOnGround;
|
||||||
|
}
|
||||||
|
}
|
@ -6,9 +6,10 @@
|
|||||||
"mixins": [
|
"mixins": [
|
||||||
"MixinConnection",
|
"MixinConnection",
|
||||||
"MixinConnection_1",
|
"MixinConnection_1",
|
||||||
"MixinTitleScreen",
|
"MixinDirectJoinServerScreen",
|
||||||
"MixinJoinMultiplayerScreen",
|
"MixinJoinMultiplayerScreen",
|
||||||
"MixinDirectJoinServerScreen"
|
"MixinTitleScreen",
|
||||||
|
"fixes.MixinLocalPlayer"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package de.florianmichael.viaforge.mixin.fixes;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
|
import net.minecraft.client.player.AbstractClientPlayer;
|
||||||
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
|
import net.raphimc.vialoader.util.VersionEnum;
|
||||||
|
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.Redirect;
|
||||||
|
|
||||||
|
@Mixin(LocalPlayer.class)
|
||||||
|
public class MixinLocalPlayer extends AbstractClientPlayer {
|
||||||
|
|
||||||
|
@Shadow private boolean lastOnGround;
|
||||||
|
|
||||||
|
public MixinLocalPlayer(ClientLevel level, GameProfile profile) {
|
||||||
|
super(level, profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "sendPosition", at = @At(value = "FIELD", target = "Lnet/minecraft/client/player/LocalPlayer;lastOnGround:Z", ordinal = 0))
|
||||||
|
public boolean emulateIdlePacket(LocalPlayer instance) {
|
||||||
|
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||||
|
// <= 1.8 spams the idle packet instead of only sending it when the ground state changes
|
||||||
|
// So we invert the original logic:
|
||||||
|
// if (prevOnGround != onGround) sendPacket
|
||||||
|
// To be like:
|
||||||
|
// if (!onGround != onGround) sendPacket
|
||||||
|
// Which is the same as:
|
||||||
|
// if (true) sendPacket
|
||||||
|
return !onGround;
|
||||||
|
}
|
||||||
|
return lastOnGround;
|
||||||
|
}
|
||||||
|
}
|
@ -6,12 +6,15 @@
|
|||||||
"mixins": [
|
"mixins": [
|
||||||
"MixinConnection",
|
"MixinConnection",
|
||||||
"MixinConnection_1",
|
"MixinConnection_1",
|
||||||
"MixinTitleScreen",
|
"MixinDirectJoinServerScreen",
|
||||||
"MixinJoinMultiplayerScreen",
|
"MixinJoinMultiplayerScreen",
|
||||||
"MixinDirectJoinServerScreen"
|
"MixinTitleScreen"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
},
|
},
|
||||||
"refmap": "mixins.viaforge-mc118.refmap.json"
|
"refmap": "mixins.viaforge-mc118.refmap.json",
|
||||||
|
"client": [
|
||||||
|
"fixes.MixinLocalPlayer"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package de.florianmichael.viaforge.mixin.fixes;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
|
import net.minecraft.client.player.AbstractClientPlayer;
|
||||||
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
|
import net.raphimc.vialoader.util.VersionEnum;
|
||||||
|
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.Redirect;
|
||||||
|
|
||||||
|
@Mixin(LocalPlayer.class)
|
||||||
|
public class MixinLocalPlayer extends AbstractClientPlayer {
|
||||||
|
|
||||||
|
@Shadow private boolean lastOnGround;
|
||||||
|
|
||||||
|
public MixinLocalPlayer(ClientLevel level, GameProfile profile) {
|
||||||
|
super(level, profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "sendPosition", at = @At(value = "FIELD", target = "Lnet/minecraft/client/player/LocalPlayer;lastOnGround:Z", ordinal = 0))
|
||||||
|
public boolean emulateIdlePacket(LocalPlayer instance) {
|
||||||
|
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||||
|
// <= 1.8 spams the idle packet instead of only sending it when the ground state changes
|
||||||
|
// So we invert the original logic:
|
||||||
|
// if (prevOnGround != onGround) sendPacket
|
||||||
|
// To be like:
|
||||||
|
// if (!onGround != onGround) sendPacket
|
||||||
|
// Which is the same as:
|
||||||
|
// if (true) sendPacket
|
||||||
|
return !onGround;
|
||||||
|
}
|
||||||
|
return lastOnGround;
|
||||||
|
}
|
||||||
|
}
|
@ -6,12 +6,15 @@
|
|||||||
"mixins": [
|
"mixins": [
|
||||||
"MixinConnection",
|
"MixinConnection",
|
||||||
"MixinConnection_1",
|
"MixinConnection_1",
|
||||||
"MixinTitleScreen",
|
"MixinDirectJoinServerScreen",
|
||||||
"MixinJoinMultiplayerScreen",
|
"MixinJoinMultiplayerScreen",
|
||||||
"MixinDirectJoinServerScreen"
|
"MixinTitleScreen"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
},
|
},
|
||||||
"refmap": "mixins.viaforge-mc119.refmap.json"
|
"refmap": "mixins.viaforge-mc119.refmap.json",
|
||||||
|
"client": [
|
||||||
|
"fixes.MixinLocalPlayer"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package de.florianmichael.viaforge.mixin.fixes;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import de.florianmichael.viaforge.common.ViaForgeCommon;
|
||||||
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
|
import net.minecraft.client.player.AbstractClientPlayer;
|
||||||
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
|
import net.raphimc.vialoader.util.VersionEnum;
|
||||||
|
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.Redirect;
|
||||||
|
|
||||||
|
@Mixin(LocalPlayer.class)
|
||||||
|
public class MixinLocalPlayer extends AbstractClientPlayer {
|
||||||
|
|
||||||
|
@Shadow private boolean lastOnGround;
|
||||||
|
|
||||||
|
public MixinLocalPlayer(ClientLevel level, GameProfile profile) {
|
||||||
|
super(level, profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "sendPosition", at = @At(value = "FIELD", target = "Lnet/minecraft/client/player/LocalPlayer;lastOnGround:Z", ordinal = 0))
|
||||||
|
public boolean emulateIdlePacket(LocalPlayer instance) {
|
||||||
|
if (ViaForgeCommon.getManager().getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
|
||||||
|
// <= 1.8 spams the idle packet instead of only sending it when the ground state changes
|
||||||
|
// So we invert the original logic:
|
||||||
|
// if (prevOnGround != onGround) sendPacket
|
||||||
|
// To be like:
|
||||||
|
// if (!onGround != onGround) sendPacket
|
||||||
|
// Which is the same as:
|
||||||
|
// if (true) sendPacket
|
||||||
|
return !onGround();
|
||||||
|
}
|
||||||
|
return lastOnGround;
|
||||||
|
}
|
||||||
|
}
|
@ -6,12 +6,15 @@
|
|||||||
"mixins": [
|
"mixins": [
|
||||||
"MixinConnection",
|
"MixinConnection",
|
||||||
"MixinConnection_1",
|
"MixinConnection_1",
|
||||||
"MixinTitleScreen",
|
"MixinDirectJoinServerScreen",
|
||||||
"MixinJoinMultiplayerScreen",
|
"MixinJoinMultiplayerScreen",
|
||||||
"MixinDirectJoinServerScreen"
|
"MixinTitleScreen"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
},
|
},
|
||||||
"refmap": "mixins.viaforge-mc120.refmap.json"
|
"refmap": "mixins.viaforge-mc120.refmap.json",
|
||||||
|
"client": [
|
||||||
|
"fixes.MixinLocalPlayer"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user