diff options
author | Chris Xiong <chirs241097@gmail.com> | 2024-09-06 23:02:34 -0400 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2024-09-06 23:02:34 -0400 |
commit | 263695053d997e75ec4a10f0de3ea0cb8a0de80c (patch) | |
tree | a3d331738b56e0661731511cb46297d51e6ae9cd /src/main/java/org/chrisoft/trashyaddon/commands/MapDumpCommand.java | |
parent | 04b4941e65693f8d6b55f924781d7dd7cd26b1d5 (diff) | |
download | meteor-trashy-addon-dev.tar.xz |
Special thanks to Xenapte for the 1.20.6 patch.
Diffstat (limited to 'src/main/java/org/chrisoft/trashyaddon/commands/MapDumpCommand.java')
-rw-r--r-- | src/main/java/org/chrisoft/trashyaddon/commands/MapDumpCommand.java | 13 |
1 files changed, 7 insertions, 6 deletions
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); |