Skip to content

Commit a2332a8

Browse files
committed
Update to 1.21.5
1 parent 65f00ca commit a2332a8

6 files changed

Lines changed: 49 additions & 57 deletions

File tree

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.9.4
2+
projectVersion=0.9.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
@@ -289,7 +289,8 @@ public static ActionResult sit(@NotNull final World world, @NotNull final BlockS
289289

290290
// Set the spawn point for the player as one would expect.
291291
if (head != null && EntitySleepEvents.ALLOW_SETTING_SPAWN.invoker().allowSettingSpawn(player, head)) {
292-
player.setSpawnPoint(world.getRegistryKey(), head, player.getYaw(), false, true);
292+
player.setSpawnPoint(
293+
new ServerPlayerEntity.Respawn(world.getRegistryKey(), head, player.getYaw(), false), true);
293294
}
294295
}
295296

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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 net.minecraft.entity.Entity;
10+
import net.minecraft.util.math.Vec3d;
11+
import org.spongepowered.asm.mixin.Mixin;
12+
import org.spongepowered.asm.mixin.Shadow;
13+
import org.spongepowered.asm.mixin.injection.At;
14+
import org.spongepowered.asm.mixin.injection.Inject;
15+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
16+
17+
/**
18+
* @author Ampflower
19+
* @since 0.8.5
20+
**/
21+
@Mixin(Entity.class)
22+
abstract class MixinEntity {
23+
@Shadow
24+
public abstract Vec3d getVelocity();
25+
26+
@Inject(method = "requestTeleportAndDismount", at = @At("RETURN"))
27+
protected void onDismount(double x, double y, double z, CallbackInfo ci) {
28+
}
29+
}

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

Lines changed: 9 additions & 34 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;
129
import net.minecraft.entity.player.PlayerPosition;
13-
import net.minecraft.network.packet.s2c.play.EntityPassengersSetS2CPacket;
1410
import net.minecraft.network.packet.s2c.play.PositionFlag;
1511
import net.minecraft.server.network.ServerPlayNetworkHandler;
1612
import net.minecraft.server.network.ServerPlayerEntity;
17-
import net.minecraft.util.math.BlockPos;
1813
import net.minecraft.util.math.Vec3d;
19-
import net.minecraft.world.World;
14+
import org.spongepowered.asm.mixin.Debug;
2015
import org.spongepowered.asm.mixin.Mixin;
2116
import org.spongepowered.asm.mixin.Shadow;
22-
import org.spongepowered.asm.mixin.injection.At;
23-
import org.spongepowered.asm.mixin.injection.Inject;
2417
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,21 @@
3325
* @since 0.3.1
3426
**/
3527
@Mixin(ServerPlayerEntity.class)
36-
public abstract class MixinServerPlayerEntity extends PlayerEntity {
28+
@Debug(export = true)
29+
public abstract class MixinServerPlayerEntity extends MixinEntity {
3730
@Shadow
3831
public ServerPlayNetworkHandler networkHandler;
3932

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-
4833
/**
49-
* Forces a teleport packet, which for some reason is not sent.
34+
* Modified requestTeleport for also sending the current velocity. Enforces that
35+
* the client can't just shove the player because there's a block edge to go to.
5036
*
51-
* Blame Mojang for this one's existence.
37+
* @since 0.9.5
5238
*/
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.
39+
@Override
40+
protected void onDismount(final double x, final double y, final double z, final CallbackInfo ci) {
41+
System.out.printf("%f, %f, %f, %s\n", x, y, z, ci);
5842
this.networkHandler.requestTeleport(new PlayerPosition(new Vec3d(x, y, z), this.getVelocity(), 0.F, 0.F),
5943
PositionFlag.ROT);
6044
}
61-
62-
/**
63-
* Forces a passenger update packet to the player, removing the chance for the
64-
* client to assert movement.
65-
*/
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));
69-
}
7045
}

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)