Skip to content

Commit 0b162cf

Browse files
committed
Update to 1.21.5
1 parent 2517a8f commit 0b162cf

File tree

7 files changed

+75
-60
lines changed

7 files changed

+75
-60
lines changed

gradle.properties

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Project Specifics
2-
projectVersion=0.8.4
2+
projectVersion=0.8.5
33
modrinthId=G9eJHDO2
44

55
# Minecraft
6-
minecraftVersion=1.21.2
7-
minecraftRequired=>=1.21.2- <1.21.5
8-
minecraftCompatible=1.21.2,1.21.3,1.21.4
9-
yarnMappings=1.21.2+build.1
6+
minecraftVersion=1.21.5
7+
minecraftRequired=>=1.21.5-
8+
minecraftCompatible=1.21.5
9+
yarnMappings=1.21.5+build.1
1010
loaderVersion=0.16.10
11-
fabricApiVersion=0.106.1+1.21.2
12-
polymerVersion=0.10.0+1.21.2
11+
fabricApiVersion=0.119.6+1.21.5
12+
polymerVersion=0.12.1+1.21.5-rc2
1313

1414
# Plugins
1515
systemProp.loomVersion=1.10.+

src/main/java/gay/ampflower/polysit/Main.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ public static ActionResult sit(@NotNull final World world, @NotNull final BlockS
273273

274274
// Set the spawn point for the player as one would expect.
275275
if (head != null) {
276-
player.setSpawnPoint(world.getRegistryKey(), head, player.getYaw(), false, true);
276+
player.setSpawnPoint(
277+
new ServerPlayerEntity.Respawn(world.getRegistryKey(), head, player.getYaw(), false), true);
277278
}
278279
}
279280

src/main/java/gay/ampflower/polysit/SeatEntity.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ protected void initDataTracker(final DataTracker.Builder builder) {
104104
@Override
105105
protected void readCustomDataFromNbt(NbtCompound nbt) {
106106
// Avoids setting position on entity init
107-
final var version = nbt.getInt(Main.VERSION_TAG_NAME);
107+
final var version = nbt.getInt(Main.VERSION_TAG_NAME, 0);
108108
if (version != Main.RUNTIME_VERSION) {
109109
this.setPos(this.getX(), this.getY() + Main.delta(version), this.getZ());
110110
// Required to suppress the packet
@@ -127,20 +127,6 @@ public boolean shouldSave() {
127127
return hasPassengers();
128128
}
129129

130-
/** Discard self when passengers are dismounted. */
131-
@Override
132-
public void removeAllPassengers() {
133-
super.removeAllPassengers();
134-
discard();
135-
}
136-
137-
/** Discard self when the passenger is dismounted. */
138-
@Override
139-
protected void removePassenger(Entity passenger) {
140-
super.removePassenger(passenger);
141-
discard();
142-
}
143-
144130
/**
145131
* Automatic cleanup and syncing yaw with the passenger.
146132
*/
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* Copyright 2025 Ampflower
2+
*
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6+
7+
package gay.ampflower.polysit.internal;
8+
9+
import net.minecraft.util.math.Vec3d;
10+
import org.jetbrains.annotations.ApiStatus;
11+
12+
/**
13+
* The code equivalent of a bodge wire.
14+
*
15+
* @author Ampflower
16+
* @since 0.8.5
17+
**/
18+
@ApiStatus.Internal
19+
public interface HackEntity {
20+
/** Delegates to player's handling. No-op */
21+
default void polysit$requestTeleportOnDismount(Vec3d position, Vec3d velocity) {
22+
}
23+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* Copyright 2025 Ampflower
2+
*
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6+
7+
package gay.ampflower.polysit.mixin;
8+
9+
import gay.ampflower.polysit.internal.HackEntity;
10+
import net.minecraft.entity.Entity;
11+
import net.minecraft.util.math.Vec3d;
12+
import org.spongepowered.asm.mixin.Mixin;
13+
import org.spongepowered.asm.mixin.Shadow;
14+
import org.spongepowered.asm.mixin.injection.At;
15+
import org.spongepowered.asm.mixin.injection.Inject;
16+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
17+
18+
/**
19+
* @author Ampflower
20+
* @since 0.8.5
21+
**/
22+
@Mixin(Entity.class)
23+
class MixinEntity implements HackEntity {
24+
@Shadow
25+
public native Vec3d getVelocity();
26+
27+
@Inject(method = "requestTeleportAndDismount", at = @At("RETURN"))
28+
private void onDismount(double x, double y, double z, CallbackInfo ci) {
29+
this.polysit$requestTeleportOnDismount(new Vec3d(x, y, z), this.getVelocity());
30+
}
31+
}

src/main/java/gay/ampflower/polysit/mixin/MixinServerPlayerEntity.java

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,15 @@
66

77
package gay.ampflower.polysit.mixin;
88

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;
1210
import net.minecraft.entity.player.PlayerPosition;
13-
import net.minecraft.network.packet.s2c.play.EntityPassengersSetS2CPacket;
1411
import net.minecraft.network.packet.s2c.play.PositionFlag;
1512
import net.minecraft.server.network.ServerPlayNetworkHandler;
1613
import net.minecraft.server.network.ServerPlayerEntity;
17-
import net.minecraft.util.math.BlockPos;
1814
import net.minecraft.util.math.Vec3d;
19-
import net.minecraft.world.World;
15+
import org.jetbrains.annotations.ApiStatus;
2016
import org.spongepowered.asm.mixin.Mixin;
2117
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;
2618

2719
/**
2820
* Forcefully teleports the player on dismount.
@@ -33,38 +25,19 @@
3325
* @since 0.3.1
3426
**/
3527
@Mixin(ServerPlayerEntity.class)
36-
public abstract class MixinServerPlayerEntity extends PlayerEntity {
28+
public abstract class MixinServerPlayerEntity implements HackEntity {
3729
@Shadow
3830
public ServerPlayNetworkHandler networkHandler;
3931

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-
4832
/**
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.
5035
*
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
6537
*/
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);
6942
}
7043
}

src/main/resources/polysit.mixin.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"mixins": [
66
"AccessorEntity",
77
"AccessorLivingEntity",
8+
"MixinEntity",
89
"MixinEntityTypeBootstrap",
910
"MixinLivingEntity",
1011
"MixinServerPlayerEntity"

0 commit comments

Comments
 (0)