From a1a2103f471ef95a670a578cc87480c846c53594 Mon Sep 17 00:00:00 2001 From: Ap_Tx <3045929398@qq.com> Date: Fri, 2 Oct 2026 23:39:00 +0800 Subject: [PATCH] =?UTF-8?q?wip:=20=E8=BF=81=E7=A7=BB=E5=88=B0=2026.1.2?= =?UTF-8?q?=EF=BC=88=E7=AC=AC=E4=B8=80=E6=89=B9=EF=BC=9A=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E9=85=8D=E7=BD=AE+=E7=AE=80=E5=8D=95=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E7=B1=BB=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 已改:accessWidener/ fabric.mod.json/ HatCommand/ SitCommand/ util 接口/ 映射表文档。剩余源码待迁移。 --- MIGRATION_26.1.md | 111 ++++++++++++++++++ .../carpetslsaddition/command/HatCommand.java | 33 +++--- .../carpetslsaddition/command/SitCommand.java | 30 ++--- .../carpetslsaddition/util/SitEntity.java | 2 +- .../util/access/PlayerAccessor.java | 6 +- .../util/access/SLSBotAccessor.java | 2 +- src/main/resources/fabric.mod.json | 11 +- src/main/resources/slsa.accesswidener | 11 +- 8 files changed, 156 insertions(+), 50 deletions(-) create mode 100644 MIGRATION_26.1.md diff --git a/MIGRATION_26.1.md b/MIGRATION_26.1.md new file mode 100644 index 0000000..2071864 --- /dev/null +++ b/MIGRATION_26.1.md @@ -0,0 +1,111 @@ +# Yarn → Mojang official 映射表(1.21 → 26.1.2) + +> 26.1.2 起 Fabric 弃用 Yarn,改用 Mojang 官方映射(jar 未混淆)。 +> 本表记录本 mod 迁移用到的类名对照。⚠️ 表示结构/语义有变化,需人工核对。 + +## block +- block.BlockState → world.level.block.state.BlockState +- block.Blocks → world.level.block.Blocks +- block.MushroomPlantBlock → world.level.block.MushroomBlock +- block.RedstoneWireBlock → world.level.block.RedStoneWireBlock +- block.ShulkerBoxBlock → world.level.block.ShulkerBoxBlock +- block.entity.BlockEntity → world.level.block.entity.BlockEntity +- block.entity.EndGatewayBlockEntity → world.level.block.entity.TheEndGatewayBlockEntity +- block.entity.EndPortalBlockEntity → world.level.block.entity.TheEndPortalBlockEntity +- block.enums.TrialSpawnerState → world.level.block.entity.trialspawner.TrialSpawnerState +- block.pattern.BlockPattern → world.level.block.state.pattern.BlockPattern +- block.pattern.CachedBlockPosition → world.level.block.state.pattern.BlockPattern$BlockCacheLoader ⚠️ +- block.spawner.TrialSpawnerConfig → world.level.block.entity.trialspawner.TrialSpawnerConfig +- block.spawner.TrialSpawnerData → world.level.block.entity.trialspawner.TrialSpawnerStateData ⚠️ +- block.spawner.TrialSpawnerLogic → world.level.block.entity.trialspawner.TrialSpawner ⚠️ + +## command +- command.CommandRegistryAccess → commands.CommandBuildContext ⚠️ +- command.argument.* → commands.arguments.* +- server.command.ServerCommandSource → commands.CommandSourceStack +- server.command.CommandManager → commands.Commands +- command.CommandSource.suggestMatching → commands.SharedSuggestionProvider 方法 ⚠️ + +## component / nbt / text / util +- component.DataComponentTypes → core.component.DataComponentTypes +- nbt.NbtCompound → nbt.CompoundTag +- nbt.NbtElement → nbt.Tag +- text.Text → network.chat.Component +- text.Style → network.chat.Style +- util.Formatting → ChatFormatting +- util.math.BlockPos → core.BlockPos +- util.math.Direction → core.Direction +- util.math.MathHelper → util.Mth +- util.math.Vec2f → world.phys.Vec2 +- util.math.Vec3d → world.phys.Vec3 +- util.UserCache → server.players.GameProfileCache ⚠️ +- util.Uuids → core.UUIDUtil +- util.Nameable → world.Nameable +- registry.RegistryKey → resources.ResourceKey +- registry.tag.TagKey → tags.TagKey +- registry.tag.BlockTags → tags.BlockTags +- SharedConstants → SharedConstants + +## entity +- entity.Entity → world.entity.Entity +- entity.EntityType → world.entity.EntityType +- entity.EquipmentSlot → world.entity.EquipmentSlot +- entity.FallingBlockEntity → world.entity.item.FallingBlockEntity +- entity.ItemEntity → world.entity.item.ItemEntity +- entity.Leashable → world.entity.Leashable +- entity.LivingEntity → world.entity.LivingEntity +- entity.attribute.EntityAttributes → world.entity.ai.attributes.Attributes ⚠️ +- entity.boss.dragon.EnderDragonFight → world.level.dimension.end.EnderDragonFight +- entity.damage.DamageSource → world.damagesource.DamageSource +- entity.decoration.ArmorStandEntity → world.entity.decoration.ArmorStand +- entity.decoration.EndCrystalEntity → world.entity.EndCrystal ⚠️ +- entity.mob.EndermanEntity → world.entity.monster.EnderMan +- entity.mob.MobEntity → world.entity.Mob +- entity.passive.AnimalEntity → world.entity.animal.Animal +- entity.passive.ArmadilloEntity → world.entity.animal.Armadillo ⚠️ +- entity.player.PlayerAbilities → world.entity.player.Abilities +- entity.player.PlayerEntity → world.entity.player.Player +- entity.player.PlayerInventory → world.entity.player.Inventory +- entity.vehicle.BoatEntity → world.entity.vehicle.Boat ⚠️ + +## item / inventory / screen +- inventory.Inventory → world.entity.player.Inventory +- item.BlockItem → world.item.BlockItem +- item.ElytraItem → world.item.ElytraItem ⚠️ +- item.Equipment → world.item.Equipment ⚠️ +- item.Item → world.item.Item +- item.ItemStack → world.item.ItemStack +- item.Items → world.item.Items +- screen.AnvilScreenHandler → world.inventory.AnvilMenu +- screen.ScreenHandler → world.inventory.AbstractContainerMenu +- screen.slot.Slot → world.inventory.Slot + +## network +- network.NetworkSide → network.protocol.PacketFlow +- network.packet.c2s.common.SyncedClientOptions → server.level.ClientInformation +- network.packet.s2c.play.EntityPositionS2CPacket → network.protocol.game.ClientboundMoveEntityPacket +- network.packet.s2c.play.EntitySetHeadYawS2CPacket → network.protocol.game.ClientboundRotateHeadPacket +- network.packet.s2c.play.EntityTrackerUpdateS2CPacket → network.protocol.game.ClientboundSetEntityDataPacket +- network.packet.s2c.play.PlayerListS2CPacket → network.protocol.game.ClientboundPlayerInfoUpdatePacket +- server.network.ConnectedClientData → server.network.CommonListenerCookie ⚠️ +- server.network.ServerPlayNetworkHandler → server.network.ServerGamePacketListenerImpl +- server.network.ServerPlayerEntity → server.level.ServerPlayer + +## server / world +- server.MinecraftServer → server.MinecraftServer +- server.PlayerManager → server.players.PlayerList +- server.world.ServerWorld → server.level.ServerLevel +- server.world.SleepManager → server.players.SleepStatus ⚠️ +- world.World → world.level.Level +- world.WorldView → world.level.LevelReader +- world.GameMode → world.level.GameType +- world.SpawnHelper → world.level.NaturalSpawner +- world.chunk.WorldChunk → world.level.chunk.LevelChunk +- world.Heightmap → world.level.levelgen.Heightmap +- world.dimension.NetherPortal → world.level.block.NetherPortalBlock ⚠️ +- world.gen.feature.EndPortalFeature → world.level.levelgen.feature.EndPodiumFeature +- sound.SoundCategory → sounds.SoundSource +- sound.SoundEvents → sounds.SoundEvents +- resource.ResourcePackProfile → server.packs.* ⚠️ +- resource.ResourceType → server.packs.PackType +- resource.VanillaResourcePackProvider → server.packs.vanilla.VanillaPackResources ⚠️ \ No newline at end of file diff --git a/src/main/java/com/github/zly2006/carpetslsaddition/command/HatCommand.java b/src/main/java/com/github/zly2006/carpetslsaddition/command/HatCommand.java index 909ef1e..9eb0d03 100644 --- a/src/main/java/com/github/zly2006/carpetslsaddition/command/HatCommand.java +++ b/src/main/java/com/github/zly2006/carpetslsaddition/command/HatCommand.java @@ -2,29 +2,28 @@ package com.github.zly2006.carpetslsaddition.command; import com.github.zly2006.carpetslsaddition.SLSCarpetSettings; import com.mojang.brigadier.CommandDispatcher; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.item.ItemStack; -import net.minecraft.server.command.CommandManager; -import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ItemStack; public class HatCommand { - public static void register(CommandDispatcher dispatcher) { - dispatcher.register(CommandManager.literal("hat") - .requires(ServerCommandSource::isExecutedByPlayer) + public static void register(CommandDispatcher dispatcher) { + dispatcher.register(Commands.literal("hat") + .requires(CommandSourceStack::isPlayer) .requires((commandSource) -> SLSCarpetSettings.canUseHatCommand) .executes(context -> { - ServerPlayerEntity player = context.getSource().getPlayer(); + ServerPlayer player = context.getSource().getPlayer(); assert player != null; - ItemStack stack = player.getMainHandStack(); - ItemStack head = player.getEquippedStack(EquipmentSlot.HEAD); - player.equipStack(EquipmentSlot.HEAD, stack); - player.getInventory().setStack(player.getInventory().selectedSlot, head); - player.currentScreenHandler.syncState(); + ItemStack stack = player.getMainHandItem(); + ItemStack head = player.getItemBySlot(EquipmentSlot.HEAD); + player.setItemSlot(EquipmentSlot.HEAD, stack); + player.getInventory().setItem(player.getInventory().getSelectedSlot(), head); + player.containerMenu.sendAllDataToRemote(); return 1; - } - ) + }) ); } -} +} \ No newline at end of file diff --git a/src/main/java/com/github/zly2006/carpetslsaddition/command/SitCommand.java b/src/main/java/com/github/zly2006/carpetslsaddition/command/SitCommand.java index b003ddd..513576a 100644 --- a/src/main/java/com/github/zly2006/carpetslsaddition/command/SitCommand.java +++ b/src/main/java/com/github/zly2006/carpetslsaddition/command/SitCommand.java @@ -3,35 +3,35 @@ package com.github.zly2006.carpetslsaddition.command; import com.github.zly2006.carpetslsaddition.SLSCarpetSettings; import com.github.zly2006.carpetslsaddition.util.SitEntity; import com.mojang.brigadier.CommandDispatcher; -import net.minecraft.entity.decoration.ArmorStandEntity; -import net.minecraft.server.command.CommandManager; -import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.world.World; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.decoration.ArmorStand; public class SitCommand { - public static void register(CommandDispatcher dispatcher) { - dispatcher.register(CommandManager.literal("sit") - .requires(ServerCommandSource::isExecutedByPlayer) + public static void register(CommandDispatcher dispatcher) { + dispatcher.register(Commands.literal("sit") + .requires(CommandSourceStack::isPlayer) .requires((commandSource) -> SLSCarpetSettings.canUseSitCommand) .executes(context -> { - ServerPlayerEntity player = context.getSource().getPlayer(); + ServerPlayer player = context.getSource().getPlayer(); assert player != null; - if (player.getVehicle() != null || !player.isOnGround()) { // 防止错误的坐下行为 + if (player.getVehicle() != null || !player.onGround()) { // 防止错误的坐下行为 return 1; } - World world = player.getWorld(); + ServerLevel world = (ServerLevel) player.level(); - ArmorStandEntity armorStandEntity = new ArmorStandEntity(world, player.getX(), player.getY(), player.getZ()); + ArmorStand armorStandEntity = new ArmorStand(world, player.getX(), player.getY(), player.getZ()); ((SitEntity) armorStandEntity).setSitEntity(true); - world.spawnEntity(armorStandEntity); - player.setSneaking(false); + world.addFreshEntity(armorStandEntity); + player.setShiftKeyDown(false); player.startRiding(armorStandEntity); return 1; }) ); } -} +} \ No newline at end of file diff --git a/src/main/java/com/github/zly2006/carpetslsaddition/util/SitEntity.java b/src/main/java/com/github/zly2006/carpetslsaddition/util/SitEntity.java index 639bba2..f97690f 100644 --- a/src/main/java/com/github/zly2006/carpetslsaddition/util/SitEntity.java +++ b/src/main/java/com/github/zly2006/carpetslsaddition/util/SitEntity.java @@ -4,4 +4,4 @@ public interface SitEntity { boolean isSitEntity(); void setSitEntity(boolean sitEntity); -} +} \ No newline at end of file diff --git a/src/main/java/com/github/zly2006/carpetslsaddition/util/access/PlayerAccessor.java b/src/main/java/com/github/zly2006/carpetslsaddition/util/access/PlayerAccessor.java index 32d1d5d..c37d6c6 100644 --- a/src/main/java/com/github/zly2006/carpetslsaddition/util/access/PlayerAccessor.java +++ b/src/main/java/com/github/zly2006/carpetslsaddition/util/access/PlayerAccessor.java @@ -1,7 +1,7 @@ package com.github.zly2006.carpetslsaddition.util.access; -import net.minecraft.text.Text; +import net.minecraft.network.chat.Component; public interface PlayerAccessor { - void carpet_SLS_Addition$setDisplayName(Text name); -} + void carpet_SLS_Addition$setDisplayName(Component name); +} \ No newline at end of file diff --git a/src/main/java/com/github/zly2006/carpetslsaddition/util/access/SLSBotAccessor.java b/src/main/java/com/github/zly2006/carpetslsaddition/util/access/SLSBotAccessor.java index 9bbe95f..5261ba7 100644 --- a/src/main/java/com/github/zly2006/carpetslsaddition/util/access/SLSBotAccessor.java +++ b/src/main/java/com/github/zly2006/carpetslsaddition/util/access/SLSBotAccessor.java @@ -5,4 +5,4 @@ public interface SLSBotAccessor { void carpet_SLS_Addition$setBot(boolean isBot); long carpet_SLS_Addition$getSpawnTime(); void carpet_SLS_Addition$setSpawnTime(long spawnTime); -} +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 2d5b2fa..4101bd8 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -27,13 +27,10 @@ ], "depends": { - "fabricloader": ">=0.15.1", + "fabricloader": ">=0.19.3", "fabric-api": "*", - "minecraft": ">=1.21", - "java": ">=21", + "minecraft": ">=26.1", + "java": ">=25", "carpet": "*" - }, - "suggests": { - "another-mod": "*" } -} +} \ No newline at end of file diff --git a/src/main/resources/slsa.accesswidener b/src/main/resources/slsa.accesswidener index 36f153b..22fd16e 100644 --- a/src/main/resources/slsa.accesswidener +++ b/src/main/resources/slsa.accesswidener @@ -1,6 +1,5 @@ -accessWidener v1 named -accessible class net/minecraft/world/block/ChainRestrictedNeighborUpdater$Entry -accessible class net/minecraft/entity/mob/EndermanEntity$PickUpBlockGoal -accessible method net/minecraft/entity/Entity unsetRemoved ()V -accessible field net/minecraft/entity/player/PlayerEntity PLAYER_MODEL_PARTS Lnet/minecraft/entity/data/TrackedData; -accessible field net/minecraft/block/spawner/TrialSpawnerData spawnedMobsAlive Ljava/util/Set; +accessWidener v1 official + +accessible class net/minecraft/world/entity/monster/EnderMan$EndermanTakeBlockGoal +accessible field net/minecraft/world/entity/Entity entityData Lnet/minecraft/network/syncher/SynchedEntityData; +accessible field net/minecraft/server/level/ServerPlayer DATA_PLAYER_MODE_CUSTOMISATION Lnet/minecraft/network/syncher/EntityDataAccessor; \ No newline at end of file