From 263695053d997e75ec4a10f0de3ea0cb8a0de80c Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Fri, 6 Sep 2024 23:02:34 -0400 Subject: 1.21 ... maybe (still testing) Special thanks to Xenapte for the 1.20.6 patch. --- .../org/chrisoft/trashyaddon/commands/MapDumpCommand.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/main/java/org/chrisoft/trashyaddon/commands/MapDumpCommand.java') diff --git a/src/main/java/org/chrisoft/trashyaddon/commands/MapDumpCommand.java b/src/main/java/org/chrisoft/trashyaddon/commands/MapDumpCommand.java index 2bc7096..b09c9be 100644 --- a/src/main/java/org/chrisoft/trashyaddon/commands/MapDumpCommand.java +++ b/src/main/java/org/chrisoft/trashyaddon/commands/MapDumpCommand.java @@ -4,6 +4,8 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder; import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.commands.Command; import net.minecraft.command.CommandSource; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.component.type.MapIdComponent; import net.minecraft.entity.EntityType; import net.minecraft.entity.decoration.ItemFrameEntity; import net.minecraft.client.MinecraftClient; @@ -19,7 +21,6 @@ import java.util.zip.GZIPOutputStream; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.Vector; -import java.util.OptionalInt; import static com.mojang.brigadier.Command.SINGLE_SUCCESS; @@ -38,14 +39,14 @@ public class MapDumpCommand extends Command { if (e.getType() != EntityType.ITEM_FRAME && e.getType() != EntityType.GLOW_ITEM_FRAME) continue; ItemFrameEntity ife = (ItemFrameEntity) e; - OptionalInt oid = ife.getMapId(); - if (oid.isEmpty()) + MapIdComponent idc = ife.getMapId(ife.getHeldItemStack()); + if (idc == null) continue; - int id = oid.getAsInt(); - MapState mapState = FilledMapItem.getMapState(id, mc.world); + int id = idc.id(); + MapState mapState = FilledMapItem.getMapState(idc, mc.world); if (mapState == null) continue; - String name = ife.getHeldItemStack().hasCustomName() ? ife.getHeldItemStack().getName().getString() : ""; + String name = ife.getHeldItemStack().contains(DataComponentTypes.CUSTOM_NAME) ? ife.getHeldItemStack().getName().getString() : ""; byte[] u8name = name.getBytes(StandardCharsets.UTF_8); int bsz = 4 + 4 + u8name.length + 16384; ByteBuffer buf = ByteBuffer.allocate(bsz); -- cgit v1.2.3