Add WIP mixins for locking view and doing the handshake
This commit is contained in:
parent
512328f710
commit
a4bd44b2b9
@ -0,0 +1,20 @@
|
||||
package org.muellerssoftware.openproximitychatfabric.mixins;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArgs;
|
||||
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
|
||||
|
||||
@Mixin(PlayerMoveC2SPacket.class)
|
||||
public class PlayerMoveMixin {
|
||||
@ModifyArgs(method = "<init>(DDDFFZZZ)V", at = @At("HEAD"))
|
||||
private static void doHandshake(Args args) {
|
||||
if (ViewLock.isLocked()) {
|
||||
if (MinecraftClient.getInstance().player == null) return;
|
||||
args.set(3, ViewLock.yaw);
|
||||
args.set(4, ViewLock.pitch);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package org.muellerssoftware.openproximitychatfabric.mixins;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
|
||||
import org.muellerssoftware.openproximitychatfabric.connect.Stage1HandshakeBuilder;
|
||||
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(PlayerEntity.class)
|
||||
public class TickMixin {
|
||||
private static Stage1HandshakeBuilder.Movement[] movements = {
|
||||
new Stage1HandshakeBuilder.Movement(0.031, 0.041),
|
||||
new Stage1HandshakeBuilder.Movement(-0.059, -0.026),
|
||||
new Stage1HandshakeBuilder.Movement(0.053, 0.058),
|
||||
new Stage1HandshakeBuilder.Movement(-0.097, -0.093),
|
||||
new Stage1HandshakeBuilder.Movement(0.023, 0.084),
|
||||
new Stage1HandshakeBuilder.Movement(0.049, -0.064),
|
||||
new Stage1HandshakeBuilder.Movement(0.033, 0.083),
|
||||
new Stage1HandshakeBuilder.Movement(-0.033, -0.083),
|
||||
new Stage1HandshakeBuilder.Movement(0.027, 0.095),
|
||||
new Stage1HandshakeBuilder.Movement(-0.027, -0.095),
|
||||
new Stage1HandshakeBuilder.Movement(0.032, 0),
|
||||
new Stage1HandshakeBuilder.Movement(-0.032, -0)
|
||||
};
|
||||
|
||||
@Inject(method = "tick()V", at = @At("TAIL"))
|
||||
private void sendMovePacket(CallbackInfo ci) {
|
||||
Entity entity = (Entity)(Object)this;
|
||||
ViewLock.setLocked(false);
|
||||
MinecraftClient.getInstance().player.networkHandler.sendPacket(new PlayerMoveC2SPacket.Full(entity.getX(), entity.getY(), entity.getZ(), entity.getYaw(), entity.getPitch(), entity.isOnGround()));
|
||||
ViewLock.setLocked(true);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package org.muellerssoftware.openproximitychatfabric.mixins;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
|
||||
public class ViewLock {
|
||||
private static boolean locked;
|
||||
public static float yaw;
|
||||
public static float pitch;
|
||||
|
||||
public static boolean isLocked() {
|
||||
return locked;
|
||||
}
|
||||
|
||||
public static void setLocked(boolean locked) {
|
||||
ClientPlayerEntity player = MinecraftClient.getInstance().player;
|
||||
if (player != null) {
|
||||
yaw = player.getYaw();
|
||||
pitch = player.getPitch();
|
||||
ViewLock.locked = locked;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,7 +6,9 @@
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
"ClientPlayNetworkHandlerMixin"
|
||||
"ClientPlayNetworkHandlerMixin",
|
||||
"PlayerMoveMixin",
|
||||
"TickMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
Loading…
Reference in New Issue
Block a user