Skip to content

Commit 2517a8f

Browse files
committed
Update to 1.21.2-1.21.4
1 parent 93ead3b commit 2517a8f

File tree

4 files changed

+52
-16
lines changed

4 files changed

+52
-16
lines changed

gradle.properties

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

55
# Minecraft
6-
minecraftVersion=1.21
7-
minecraftRequired=>=1.20.5- <1.21.2
8-
minecraftCompatible=1.20.5,1.20.6,1.21,1.21.1
9-
yarnMappings=1.21+build.7
10-
loaderVersion=0.15.11
11-
fabricApiVersion=0.100.6+1.21
12-
polymerVersion=0.9.4+1.21
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
10+
loaderVersion=0.16.10
11+
fabricApiVersion=0.106.1+1.21.2
12+
polymerVersion=0.10.0+1.21.2
1313

1414
# Plugins
1515
systemProp.loomVersion=1.10.+

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@
2727
import net.minecraft.entity.SpawnGroup;
2828
import net.minecraft.registry.Registries;
2929
import net.minecraft.registry.Registry;
30+
import net.minecraft.registry.RegistryKey;
31+
import net.minecraft.registry.RegistryKeys;
3032
import net.minecraft.server.network.ServerPlayerEntity;
3133
import net.minecraft.text.Text;
3234
import net.minecraft.util.ActionResult;
3335
import net.minecraft.util.Hand;
36+
import net.minecraft.util.Identifier;
3437
import net.minecraft.util.math.BlockPos;
3538
import net.minecraft.util.math.Direction;
3639
import net.minecraft.util.math.MathHelper;
@@ -309,8 +312,9 @@ public static ActionResult sit(World world, Entity entity, double seatX, double
309312
}
310313

311314
public static <T extends Entity> EntityType<T> registerEntity(String id, EntityType.Builder<T> type) {
312-
var built = type.build(id);
313-
Registry.register(Registries.ENTITY_TYPE, id, built);
315+
final var identifier = Identifier.of(id);
316+
final var built = type.build(RegistryKey.of(RegistryKeys.ENTITY_TYPE, identifier));
317+
Registry.register(Registries.ENTITY_TYPE, identifier, built);
314318
PolymerEntityUtils.registerType(built);
315319
return built;
316320
}

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515
import net.minecraft.entity.data.DataTracker;
1616
import net.minecraft.nbt.NbtCompound;
1717
import net.minecraft.network.packet.s2c.play.EntityAttributesS2CPacket;
18-
import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket;
18+
import net.minecraft.registry.tag.DamageTypeTags;
1919
import net.minecraft.server.network.ServerPlayerEntity;
20+
import net.minecraft.server.world.ServerWorld;
2021
import net.minecraft.util.math.BlockPos;
2122
import net.minecraft.world.World;
23+
import org.jetbrains.annotations.Nullable;
24+
import xyz.nucleoid.packettweaker.PacketContext;
2225

2326
import java.util.Collection;
2427
import java.util.Collections;
@@ -45,7 +48,7 @@
4548
**/
4649
public class SeatEntity extends Entity implements PolymerEntity {
4750
private static final EntityAttributeInstance MAX_HEALTH_NULL = new EntityAttributeInstance(
48-
EntityAttributes.GENERIC_MAX_HEALTH, discard -> {
51+
EntityAttributes.MAX_HEALTH, discard -> {
4952
});
5053
private static final Collection<EntityAttributeInstance> MAX_HEALTH_NULL_SINGLE = Collections
5154
.singleton(MAX_HEALTH_NULL);
@@ -72,7 +75,7 @@ public SeatEntity(World world, double x, double y, double z) {
7275
* at a block.
7376
*/
7477
@Override
75-
public EntityType<?> getPolymerEntityType(ServerPlayerEntity player) {
78+
public EntityType<?> getPolymerEntityType(final PacketContext context) {
7679
return EntityType.ARMOR_STAND;
7780
}
7881

@@ -154,15 +157,21 @@ public void tick() {
154157
}
155158

156159
@Override
157-
public boolean damage(final DamageSource source, final float amount) {
158-
if (isInvulnerableTo(source)) {
160+
public boolean damage(final ServerWorld world, final DamageSource source, final float amount) {
161+
if (!source.isSourceCreativePlayer() && !source.isIn(DamageTypeTags.BYPASSES_INVULNERABILITY)) {
159162
return false;
160163
}
161164

162165
this.remove(RemovalReason.KILLED);
163166
return true;
164167
}
165168

169+
@Override
170+
public void onExplodedBy(@Nullable final Entity entity) {
171+
// Allows the seat to be destroyed by TNT.
172+
this.remove(RemovalReason.KILLED);
173+
}
174+
166175
protected boolean isDiscardable() {
167176
return this.getWorld().getBlockState(getAdjustedPos()).isAir();
168177
}

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,22 @@
77
package gay.ampflower.polysit.mixin;
88

99
import com.mojang.authlib.GameProfile;
10+
import net.minecraft.entity.Entity;
1011
import net.minecraft.entity.player.PlayerEntity;
12+
import net.minecraft.entity.player.PlayerPosition;
13+
import net.minecraft.network.packet.s2c.play.EntityPassengersSetS2CPacket;
14+
import net.minecraft.network.packet.s2c.play.PositionFlag;
15+
import net.minecraft.server.network.ServerPlayNetworkHandler;
1116
import net.minecraft.server.network.ServerPlayerEntity;
1217
import net.minecraft.util.math.BlockPos;
18+
import net.minecraft.util.math.Vec3d;
1319
import net.minecraft.world.World;
1420
import org.spongepowered.asm.mixin.Mixin;
1521
import org.spongepowered.asm.mixin.Shadow;
1622
import org.spongepowered.asm.mixin.injection.At;
1723
import org.spongepowered.asm.mixin.injection.Inject;
1824
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
25+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
1926

2027
/**
2128
* Forcefully teleports the player on dismount.
@@ -27,6 +34,9 @@
2734
**/
2835
@Mixin(ServerPlayerEntity.class)
2936
public abstract class MixinServerPlayerEntity extends PlayerEntity {
37+
@Shadow
38+
public ServerPlayNetworkHandler networkHandler;
39+
3040
@Shadow
3141
public abstract void requestTeleport(final double destX, final double destY, final double destZ);
3242

@@ -42,6 +52,19 @@ public MixinServerPlayerEntity(final World world, final BlockPos pos, final floa
4252
*/
4353
@Inject(method = "requestTeleportAndDismount", at = @At("RETURN"))
4454
private void onDismount(double x, double y, double z, CallbackInfo ci) {
45-
this.requestTeleport(x, y, z);
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.
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));
4669
}
4770
}

0 commit comments

Comments
 (0)