|
6 | 6 |
|
7 | 7 | package gay.ampflower.polysit.mixin; |
8 | 8 |
|
9 | | -import com.mojang.authlib.GameProfile; |
10 | | -import net.minecraft.entity.Entity; |
11 | | -import net.minecraft.entity.player.PlayerEntity; |
| 9 | +import gay.ampflower.polysit.internal.HackEntity; |
12 | 10 | import net.minecraft.entity.player.PlayerPosition; |
13 | | -import net.minecraft.network.packet.s2c.play.EntityPassengersSetS2CPacket; |
14 | 11 | import net.minecraft.network.packet.s2c.play.PositionFlag; |
15 | 12 | import net.minecraft.server.network.ServerPlayNetworkHandler; |
16 | 13 | import net.minecraft.server.network.ServerPlayerEntity; |
17 | | -import net.minecraft.util.math.BlockPos; |
18 | 14 | import net.minecraft.util.math.Vec3d; |
19 | | -import net.minecraft.world.World; |
| 15 | +import org.jetbrains.annotations.ApiStatus; |
20 | 16 | import org.spongepowered.asm.mixin.Mixin; |
21 | 17 | import org.spongepowered.asm.mixin.Shadow; |
22 | | -import org.spongepowered.asm.mixin.injection.At; |
23 | | -import org.spongepowered.asm.mixin.injection.Inject; |
24 | | -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
25 | | -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
26 | 18 |
|
27 | 19 | /** |
28 | 20 | * Forcefully teleports the player on dismount. |
|
33 | 25 | * @since 0.3.1 |
34 | 26 | **/ |
35 | 27 | @Mixin(ServerPlayerEntity.class) |
36 | | -public abstract class MixinServerPlayerEntity extends PlayerEntity { |
| 28 | +public abstract class MixinServerPlayerEntity implements HackEntity { |
37 | 29 | @Shadow |
38 | 30 | public ServerPlayNetworkHandler networkHandler; |
39 | 31 |
|
40 | | - @Shadow |
41 | | - public abstract void requestTeleport(final double destX, final double destY, final double destZ); |
42 | | - |
43 | | - public MixinServerPlayerEntity(final World world, final BlockPos pos, final float yaw, |
44 | | - final GameProfile gameProfile) { |
45 | | - super(world, pos, yaw, gameProfile); |
46 | | - } |
47 | | - |
48 | 32 | /** |
49 | | - * Forces a teleport packet, which for some reason is not sent. |
| 33 | + * Modified requestTeleport for also sending the current velocity. Enforces that |
| 34 | + * the client can't just shove the player because there's a block edge to go to. |
50 | 35 | * |
51 | | - * Blame Mojang for this one's existence. |
52 | | - */ |
53 | | - @Inject(method = "requestTeleportAndDismount", at = @At("RETURN")) |
54 | | - private void onDismount(double x, double y, double z, CallbackInfo ci) { |
55 | | - // Modified requestTeleport for also sending the current velocity. |
56 | | - // Enforces that the client can't just shove the player because there's a block |
57 | | - // edge to go to. |
58 | | - this.networkHandler.requestTeleport(new PlayerPosition(new Vec3d(x, y, z), this.getVelocity(), 0.F, 0.F), |
59 | | - PositionFlag.ROT); |
60 | | - } |
61 | | - |
62 | | - /** |
63 | | - * Forces a passenger update packet to the player, removing the chance for the |
64 | | - * client to assert movement. |
| 36 | + * @since 0.8.5 |
65 | 37 | */ |
66 | | - @Inject(method = "startRiding", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayNetworkHandler;requestTeleport(Lnet/minecraft/entity/player/PlayerPosition;Ljava/util/Set;)V")) |
67 | | - private void onMount(Entity vehicle, boolean force, CallbackInfoReturnable<Boolean> ci) { |
68 | | - this.networkHandler.sendPacket(new EntityPassengersSetS2CPacket(vehicle)); |
| 38 | + @Override |
| 39 | + @ApiStatus.Internal |
| 40 | + public void polysit$requestTeleportOnDismount(final Vec3d position, final Vec3d velocity) { |
| 41 | + this.networkHandler.requestTeleport(new PlayerPosition(position, velocity, 0.F, 0.F), PositionFlag.ROT); |
69 | 42 | } |
70 | 43 | } |
0 commit comments