From d64c89d1ee732debac2649bd2bf40053405c1daa Mon Sep 17 00:00:00 2001 From: Patbox <39821509+Patbox@users.noreply.github.com> Date: Thu, 13 Jun 2024 13:52:54 +0200 Subject: [PATCH] Update to 1.21 --- build.gradle | 2 +- gradle.properties | 14 +++++++------- .../space/essem/image2map/CardboardWarning.java | 2 +- src/main/java/space/essem/image2map/Image2Map.java | 9 +++------ .../java/space/essem/image2map/gui/MapGui.java | 3 ++- .../essem/image2map/renderer/MapRenderer.java | 7 ++++--- src/main/resources/fabric.mod.json | 2 +- src/main/resources/image2map.mixins.json | 2 +- 8 files changed, 20 insertions(+), 21 deletions(-) diff --git a/build.gradle b/build.gradle index 45bc1c5..971650f 100644 --- a/build.gradle +++ b/build.gradle @@ -49,7 +49,7 @@ tasks.withType(JavaCompile).configureEach { it.options.encoding = "UTF-8" // Minecraft 1.18 (1.18-pre2) upwards uses Java 17. - it.options.release = 17 + it.options.release = 21 } java { diff --git a/gradle.properties b/gradle.properties index 5a0ecdf..db1eb4a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,16 +3,16 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/versions.html - minecraft_version=1.20.6 - yarn_mappings=1.20.6+build.1 - loader_version=0.15.10 + minecraft_version=1.21-rc1 + yarn_mappings=1.21-rc1+build.1 + loader_version=0.15.11 # Mod Properties - mod_version = 0.6.0+1.20.6 + mod_version = 0.6.0+1.21 maven_group = space.essem archives_base_name = image2map # Dependencies - fabric_version=0.97.6+1.20.6 - mapcanvas_version=0.3.0+1.20.6 - sgui_version=1.5.1+1.20.5 \ No newline at end of file + fabric_version=0.100.1+1.21 + mapcanvas_version=0.4.0+1.21 + sgui_version=1.6.0+1.21 \ No newline at end of file diff --git a/src/main/java/space/essem/image2map/CardboardWarning.java b/src/main/java/space/essem/image2map/CardboardWarning.java index fd21774..76fee2f 100644 --- a/src/main/java/space/essem/image2map/CardboardWarning.java +++ b/src/main/java/space/essem/image2map/CardboardWarning.java @@ -8,7 +8,7 @@ import java.util.List; public class CardboardWarning implements PreLaunchEntrypoint { - public static final String MOD_NAME = "Brewery"; + public static final String MOD_NAME = "Image2Map"; public static final Logger LOGGER = LogUtils.getLogger(); // Overwrite heavy and generally problematic bukkit implementation diff --git a/src/main/java/space/essem/image2map/Image2Map.java b/src/main/java/space/essem/image2map/Image2Map.java index c1ac6bf..eea227c 100644 --- a/src/main/java/space/essem/image2map/Image2Map.java +++ b/src/main/java/space/essem/image2map/Image2Map.java @@ -23,10 +23,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtElement; -import net.minecraft.nbt.NbtList; -import net.minecraft.nbt.NbtString; +import net.minecraft.nbt.*; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -214,7 +211,7 @@ public static void giveToPlayer(PlayerEntity player, List items, Stri } else { var bundle = new ItemStack(Items.BUNDLE); bundle.set(DataComponentTypes.BUNDLE_CONTENTS, new BundleContentsComponent(items)); - bundle.set(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT.with(ImageData.CODEC, + bundle.set(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT.with(NbtOps.INSTANCE, ImageData.CODEC, ImageData.ofBundle(MathHelper.ceil(width / 128d), MathHelper.ceil(height / 128d))).getOrThrow()); bundle.set(DataComponentTypes.LORE, new LoreComponent(List.of(Text.literal(input)))); @@ -277,7 +274,7 @@ public static boolean clickItemFrame(PlayerEntity player, Hand hand, ItemFrameEn if (mapData.isSuccess() && mapData.getOrThrow().isReal()) { map = map.copy(); var newData = mapData.getOrThrow().withDirection(right, down, facing); - map.apply(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT, x -> x.with(ImageData.CODEC, newData).getOrThrow()); + map.apply(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT, x -> x.with(NbtOps.INSTANCE, ImageData.CODEC, newData).getOrThrow()); var frame = frames[mapData.getOrThrow().x() + mapData.getOrThrow().y() * width]; diff --git a/src/main/java/space/essem/image2map/gui/MapGui.java b/src/main/java/space/essem/image2map/gui/MapGui.java index 8be8745..2110836 100644 --- a/src/main/java/space/essem/image2map/gui/MapGui.java +++ b/src/main/java/space/essem/image2map/gui/MapGui.java @@ -69,7 +69,8 @@ public MapGui(ServerPlayerEntity player, int width, int height) { //this.cursorX = this.canvas.getWidth(); //this.cursorY = this.canvas.getHeight(); // MapDecoration.Type.TARGET_POINT //this.cursor = null;//this.canvas.createIcon(MapIcon.Type.TARGET_POINT, true, this.cursorX, this.cursorY, (byte) 14, null); - player.networkHandler.sendPacket(this.entity.createSpawnPacket()); + player.networkHandler.sendPacket(new EntitySpawnS2CPacket(this.entity.getId(), this.entity.getUuid(), + this.entity.getX(), this.entity.getY(), this.entity.getZ(), this.entity.getPitch(), entity.getYaw(), entity.getType(), 0, Vec3d.ZERO, entity.getHeadYaw())); player.networkHandler.sendPacket(new EntityTrackerUpdateS2CPacket(this.entity.getId(), this.entity.getDataTracker().getChangedEntries())); player.networkHandler.sendPacket(new SetCameraEntityS2CPacket(this.entity)); diff --git a/src/main/java/space/essem/image2map/renderer/MapRenderer.java b/src/main/java/space/essem/image2map/renderer/MapRenderer.java index 7d1866a..56dd940 100644 --- a/src/main/java/space/essem/image2map/renderer/MapRenderer.java +++ b/src/main/java/space/essem/image2map/renderer/MapRenderer.java @@ -18,6 +18,7 @@ import net.minecraft.item.Items; import net.minecraft.item.map.MapState; import net.minecraft.nbt.NbtList; +import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.NbtString; import net.minecraft.registry.Registries; import net.minecraft.registry.RegistryKey; @@ -75,8 +76,8 @@ public static List toVanillaItems(CanvasImage image, ServerWorld worl for (int ys = 0; ys < ySections; ys++) { for (int xs = 0; xs < xSections; xs++) { - var id = world.getNextMapId(); - var state = MapState.of(0, 0, (byte) 0, false, false, RegistryKey.of(RegistryKeys.WORLD, new Identifier("image2map", "generated"))); + var id = world.increaseAndGetMapId(); + var state = MapState.of(0, 0, (byte) 0, false, false, RegistryKey.of(RegistryKeys.WORLD, Identifier.of("image2map", "generated"))); for (int xl = 0; xl < 128; xl++) { for (int yl = 0; yl < 128; yl++) { @@ -94,7 +95,7 @@ public static List toVanillaItems(CanvasImage image, ServerWorld worl var stack = new ItemStack(Items.FILLED_MAP); stack.set(DataComponentTypes.MAP_ID, id); var data = ImageData.ofSimple(xs, ys, xSections, ySections); - stack.apply(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT, x -> x.with(ImageData.CODEC, data).getOrThrow()); + stack.apply(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT, x -> x.with(NbtOps.INSTANCE, ImageData.CODEC, data).getOrThrow()); stack.set(DataComponentTypes.LORE, new LoreComponent(List.of( Text.literal(xs + " / " + ys).formatted(Formatting.GRAY), Text.literal(url) diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index eec2359..7944e69 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -32,6 +32,6 @@ ], "depends": { "fabricloader": ">=0.14.0", - "fabric": "*" + "fabric-api": "*" } } diff --git a/src/main/resources/image2map.mixins.json b/src/main/resources/image2map.mixins.json index b0487e8..be9c17e 100644 --- a/src/main/resources/image2map.mixins.json +++ b/src/main/resources/image2map.mixins.json @@ -1,7 +1,7 @@ { "required": true, "package": "space.essem.image2map.mixin", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_21", "mixins": [ "BundleItemMixin", "EntityPassengersSetS2CPacketAccessor",