From 72b298ea5fe97ede953fc711b422aa5e19cffff9 Mon Sep 17 00:00:00 2001 From: gnembon <41132274+gnembon@users.noreply.github.com> Date: Wed, 4 Sep 2024 20:23:21 +0200 Subject: [PATCH] 24w26a --- gradle.properties | 2 +- .../mixins/ChunkMap_scarpetChunkCreationMixin.java | 8 ++++---- .../carpet/mixins/Player_antiCheatDisabledMixin.java | 4 ++-- ...verGamePacketListenerImpl_scarpetEventsMixin.java | 11 +++++++---- src/main/java/carpet/patches/EntityPlayerMPFake.java | 5 +++-- .../carpet/patches/NetHandlerPlayServerFake.java | 7 ++++--- src/main/java/carpet/script/value/EntityValue.java | 12 +++++++----- src/main/java/carpet/utils/CommandHelper.java | 2 +- 8 files changed, 29 insertions(+), 22 deletions(-) diff --git a/gradle.properties b/gradle.properties index f14f3cc426..8aad738eb9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check https://fabricmc.net/develop/ - minecraft_version=24w35a + minecraft_version=24w36a loader_version=0.15.11 jsr305_version=3.0.2 fabric_version=0.102.0+1.21 diff --git a/src/main/java/carpet/mixins/ChunkMap_scarpetChunkCreationMixin.java b/src/main/java/carpet/mixins/ChunkMap_scarpetChunkCreationMixin.java index fc300dbbb5..c19738a8ba 100644 --- a/src/main/java/carpet/mixins/ChunkMap_scarpetChunkCreationMixin.java +++ b/src/main/java/carpet/mixins/ChunkMap_scarpetChunkCreationMixin.java @@ -23,7 +23,7 @@ import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ChunkMap.DistanceManager; import net.minecraft.server.level.ChunkResult; -import net.minecraft.server.level.ChunkTaskPriorityQueueSorter; +//import net.minecraft.server.level.ChunkTaskPriorityQueueSorter; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ThreadedLevelLightEngine; import net.minecraft.server.level.TicketType; @@ -76,9 +76,9 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi @Final private ThreadedLevelLightEngine lightEngine; - @Shadow - @Final - private ChunkTaskPriorityQueueSorter queueSorter; + //@Shadow + //@Final + //private ChunkTaskPriorityQueueSorter queueSorter; @Shadow @Final diff --git a/src/main/java/carpet/mixins/Player_antiCheatDisabledMixin.java b/src/main/java/carpet/mixins/Player_antiCheatDisabledMixin.java index 8a9625dc0a..9dc4676aab 100644 --- a/src/main/java/carpet/mixins/Player_antiCheatDisabledMixin.java +++ b/src/main/java/carpet/mixins/Player_antiCheatDisabledMixin.java @@ -4,7 +4,7 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ElytraItem; +//import net.minecraft.world.item.ElytraItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import org.spongepowered.asm.mixin.Mixin; @@ -26,7 +26,7 @@ private void allowDeploys(CallbackInfoReturnable cir) if (CarpetSettings.antiCheatDisabled && (Object)this instanceof ServerPlayer sp && sp.getServer().isDedicatedServer()) { ItemStack itemStack_1 = getItemBySlot(EquipmentSlot.CHEST); - if (itemStack_1.getItem() == Items.ELYTRA && ElytraItem.isFlyEnabled(itemStack_1)) { + if (itemStack_1.getItem() == Items.ELYTRA && !itemStack_1.nextDamageWillBreak()) { startFallFlying(); cir.setReturnValue(true); } diff --git a/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_scarpetEventsMixin.java b/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_scarpetEventsMixin.java index ed213d8100..9f75e4ec2b 100644 --- a/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_scarpetEventsMixin.java @@ -2,6 +2,7 @@ import carpet.fakes.EntityInterface; import net.minecraft.network.protocol.game.ServerboundChatCommandPacket; +import net.minecraft.world.entity.player.Input; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -57,12 +58,14 @@ private void checkMoves(ServerboundPlayerInputPacket p, CallbackInfo ci) { // todo this may not ride on the right thread moment, so needs to be checked - if (!((EntityInterface)player.getVehicle()).isPermanentVehicle()) // won't since that method makes sure its not null - player.setShiftKeyDown(p.isShiftKeyDown()); + Input input = p.input(); - if (PLAYER_RIDES.isNeeded() && (p.getXxa() != 0.0F || p.getZza() != 0.0F || p.isJumping() || p.isShiftKeyDown())) + if (player.getVehicle() != null && !((EntityInterface)player.getVehicle()).isPermanentVehicle()) // won't since that method makes sure its not null + player.setShiftKeyDown(p.input().shift()); + + if (PLAYER_RIDES.isNeeded() && (input.jump() || input.shift() || input.forward() || input.backward() || input.left() || input.right())) { - PLAYER_RIDES.onMountControls(player, p.getXxa(), p.getZza(), p.isJumping(), p.isShiftKeyDown()); + PLAYER_RIDES.onMountControls(player, input.left() == input.right() ? 0 : (input.left() ? -1 : 1 ), input.forward() == input.backward() ? 0 : (input.forward() ? 1 : -1), input.jump(), input.shift()); } } diff --git a/src/main/java/carpet/patches/EntityPlayerMPFake.java b/src/main/java/carpet/patches/EntityPlayerMPFake.java index b4911ab07c..ee1cd4dda2 100644 --- a/src/main/java/carpet/patches/EntityPlayerMPFake.java +++ b/src/main/java/carpet/patches/EntityPlayerMPFake.java @@ -37,6 +37,7 @@ import carpet.utils.Messenger; import java.util.Optional; +import java.util.Set; import java.util.concurrent.CompletableFuture; @SuppressWarnings("EntityConstructor") @@ -77,7 +78,7 @@ public static boolean createFake(String username, MinecraftServer server, Vec3 p EntityPlayerMPFake instance = new EntityPlayerMPFake(server, worldIn, current, ClientInformation.createDefault(), false); instance.fixStartingPosition = () -> instance.moveTo(pos.x, pos.y, pos.z, (float) yaw, (float) pitch); server.getPlayerList().placeNewPlayer(new FakeClientConnection(PacketFlow.SERVERBOUND), instance, new CommonListenerCookie(current, 0, instance.clientInformation(), false)); - instance.teleportTo(worldIn, pos.x, pos.y, pos.z, (float) yaw, (float) pitch, true); + instance.teleportTo(worldIn, pos.x, pos.y, pos.z, Set.of(), (float) yaw, (float) pitch, true); instance.setHealth(20.0F); instance.unsetRemoved(); instance.getAttribute(Attributes.STEP_HEIGHT).setBaseValue(0.6F); @@ -151,7 +152,7 @@ public void kill(Component reason) if (reason.getContents() instanceof TranslatableContents text && text.getKey().equals("multiplayer.disconnect.duplicate_login")) { this.connection.onDisconnect(new DisconnectionDetails(reason)); } else { - this.server.tell(new TickTask(this.server.getTickCount(), () -> { + this.server.schedule(new TickTask(this.server.getTickCount(), () -> { this.connection.onDisconnect(new DisconnectionDetails(reason)); })); } diff --git a/src/main/java/carpet/patches/NetHandlerPlayServerFake.java b/src/main/java/carpet/patches/NetHandlerPlayServerFake.java index bfdd7f45f5..7270ff5a34 100644 --- a/src/main/java/carpet/patches/NetHandlerPlayServerFake.java +++ b/src/main/java/carpet/patches/NetHandlerPlayServerFake.java @@ -8,7 +8,8 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.network.CommonListenerCookie; import net.minecraft.server.network.ServerGamePacketListenerImpl; -import net.minecraft.world.entity.RelativeMovement; +import net.minecraft.world.entity.PositionMoveRotation; +import net.minecraft.world.entity.Relative; import java.util.Set; public class NetHandlerPlayServerFake extends ServerGamePacketListenerImpl @@ -33,9 +34,9 @@ public void disconnect(Component message) } @Override - public void teleport(double d, double e, double f, float g, float h, Set set) + public void teleport(PositionMoveRotation positionMoveRotation, Set set) { - super.teleport(d, e, f, g, h, set); + super.teleport(positionMoveRotation, set); if (player.serverLevel().getPlayerByUUID(player.getUUID()) != null) { resetPosition(); player.serverLevel().getChunkSource().move(player); diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index e9dddb8e2c..86daa23a0b 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -49,7 +49,8 @@ import net.minecraft.world.entity.MobCategory; import net.minecraft.world.entity.PathfinderMob; import net.minecraft.world.entity.Pose; -import net.minecraft.world.entity.RelativeMovement; +import net.minecraft.world.entity.PositionMoveRotation; +import net.minecraft.world.entity.Relative; import net.minecraft.world.entity.ai.Brain; import net.minecraft.world.entity.ai.attributes.Attribute; import net.minecraft.world.entity.ai.attributes.AttributeMap; @@ -899,10 +900,11 @@ private static void updatePosition(Entity e, double x, double y, double z, float if (e instanceof ServerPlayer sp) { // this forces position but doesn't angles for some reason. Need both in the API in the future. - EnumSet set = EnumSet.noneOf(RelativeMovement.class); - set.add(RelativeMovement.X_ROT); - set.add(RelativeMovement.Y_ROT); - sp.connection.teleport(x, y, z, yaw, pitch, set); + EnumSet set = EnumSet.noneOf(Relative.class); + set.add(Relative.X_ROT); + set.add(Relative.Y_ROT); + + sp.connection.teleport(new PositionMoveRotation(new Vec3(x, y, z), Vec3.ZERO, yaw, pitch), set); } else { diff --git a/src/main/java/carpet/utils/CommandHelper.java b/src/main/java/carpet/utils/CommandHelper.java index d6825a914f..9b97f652ba 100644 --- a/src/main/java/carpet/utils/CommandHelper.java +++ b/src/main/java/carpet/utils/CommandHelper.java @@ -23,7 +23,7 @@ public static void notifyPlayersCommandsChanged(MinecraftServer server) { return; } - server.tell(new TickTask(server.getTickCount(), () -> + server.schedule(new TickTask(server.getTickCount(), () -> { try { for (ServerPlayer player : server.getPlayerList().getPlayers()) {