From 2cf25942d39560d9e835e5651922942cb4ea5b9c Mon Sep 17 00:00:00 2001 From: D1p4k <82884007+D1p4k@users.noreply.github.com> Date: Mon, 18 Sep 2023 18:48:18 +0200 Subject: [PATCH] Update to 1.20.1 I guess --- common/build.gradle | 2 +- .../main/java/hunternif/mc/api/AtlasAPI.java | 4 +- .../mc/impl/atlas/AntiqueAtlasConfig.java | 2 +- .../mc/impl/atlas/AntiqueAtlasMod.java | 4 +- .../hunternif/mc/impl/atlas/ClientProxy.java | 15 +- .../mc/impl/atlas/api/impl/TileApiImpl.java | 6 +- .../mc/impl/atlas/client/OverlayRenderer.java | 71 ++++---- .../mc/impl/atlas/client/SetTileRenderer.java | 8 +- .../mc/impl/atlas/client/TextureConfig.java | 2 +- .../impl/atlas/client/TextureSetConfig.java | 4 +- .../impl/atlas/client/TileTextureConfig.java | 4 +- .../mc/impl/atlas/client/TileTextureMap.java | 16 +- .../client/gui/ExportProgressOverlay.java | 15 +- .../impl/atlas/client/gui/GuiArrowButton.java | 7 +- .../mc/impl/atlas/client/gui/GuiAtlas.java | 93 +++++----- .../atlas/client/gui/GuiBookmarkButton.java | 8 +- .../atlas/client/gui/GuiMarkerBookmark.java | 8 +- .../atlas/client/gui/GuiMarkerFinalizer.java | 34 ++-- .../atlas/client/gui/GuiMarkerInList.java | 10 +- .../atlas/client/gui/GuiPositionButton.java | 8 +- .../mc/impl/atlas/client/gui/GuiScaleBar.java | 8 +- .../atlas/client/gui/ProgressBarOverlay.java | 14 +- .../atlas/client/gui/core/AGuiScrollbar.java | 11 +- .../client/gui/core/GuiBlinkingImage.java | 9 +- .../atlas/client/gui/core/GuiComponent.java | 25 ++- .../client/gui/core/GuiComponentButton.java | 2 +- .../impl/atlas/client/gui/core/GuiCursor.java | 6 +- .../atlas/client/gui/core/GuiHScrollbar.java | 10 +- .../atlas/client/gui/core/GuiVScrollbar.java | 10 +- .../atlas/client/gui/core/GuiViewport.java | 4 +- .../impl/atlas/client/texture/ATexture.java | 38 ++-- .../impl/atlas/client/texture/ITexture.java | 11 +- .../atlas/client/texture/TileTexture.java | 6 +- .../mc/impl/atlas/core/AtlasData.java | 9 +- .../atlas/core/GlobalTileDataHandler.java | 3 +- .../impl/atlas/core/PlayerEventHandler.java | 4 +- .../mc/impl/atlas/core/TileDataStorage.java | 2 +- .../mc/impl/atlas/core/WorldData.java | 2 +- .../atlas/core/scaning/TileDetectorBase.java | 34 ++-- .../atlas/core/scaning/TileDetectorEnd.java | 5 +- .../core/scaning/TileDetectorNether.java | 14 +- .../impl/atlas/core/scaning/WorldScanner.java | 2 +- .../impl/atlas/core/watcher/DeathWatcher.java | 4 +- .../mc/impl/atlas/item/AntiqueAtlasItems.java | 12 +- .../mc/impl/atlas/item/AtlasItem.java | 5 +- .../impl/atlas/item/RecipeAtlasCloning.java | 17 +- .../impl/atlas/item/RecipeAtlasCombining.java | 21 ++- .../atlas/marker/DimensionMarkersData.java | 8 +- .../impl/atlas/marker/GlobalMarkersData.java | 2 +- .../mc/impl/atlas/marker/Marker.java | 2 +- .../atlas/marker/MarkerTextureConfig.java | 6 +- .../mc/impl/atlas/marker/MarkersData.java | 8 +- .../impl/atlas/marker/MarkersDataHandler.java | 2 +- .../atlas/marker/NetherPortalWatcher.java | 7 +- .../atlas/mixin/HeldItemRendererMixin.java | 24 +-- .../MixinCartographyTableScreenHandler.java | 5 +- .../atlas/mixin/MixinCraftingResultSlot.java | 6 +- .../mc/impl/atlas/mixin/MixinInGameHud.java | 6 +- .../mixin/structure/StructureStartMixin.java | 21 +-- .../mixinhooks/CartographyTableHooks.java | 7 +- .../play/PutBrowsingPositionC2SPacket.java | 8 +- .../s2c/play/DeleteGlobalTileS2CPacket.java | 6 +- .../s2c/play/DimensionUpdateS2CPacket.java | 6 +- .../s2c/play/PutGlobalTileS2CPacket.java | 6 +- .../packet/s2c/play/PutMarkersS2CPacket.java | 6 +- .../packet/s2c/play/PutTileS2CPacket.java | 6 +- .../packet/s2c/play/TileGroupsS2CPacket.java | 6 +- .../mc/impl/atlas/registry/MarkerType.java | 27 ++- .../mc/impl/atlas/structure/EndCity.java | 8 +- .../mc/impl/atlas/structure/JigsawConfig.java | 7 +- .../atlas/structure/StructureHandler.java | 16 +- .../mc/impl/atlas/structure/Village.java | 15 +- .../mc/impl/atlas/util/ExportImageUtil.java | 8 +- .../main/resources/antiqueatlas.accesswidener | 2 - .../models/item/antique_atlas.json | 2 +- .../models/item/empty_antique_atlas.json | 2 +- .../{items => item}/antique_atlas.png | Bin .../{items => item}/empty_antique_atlas.png | Bin .../client/fabric/TileTextureMapImpl.java | 13 +- forge/build.gradle | 130 -------------- forge/gradle.properties | 1 - .../client/forge/TileTextureMapImpl.java | 167 ------------------ .../gui/forge/AntiqueAtlasConfigMenu.java | 17 -- .../atlas/forge/AntiqueAtlasModForge.java | 29 --- .../mixin/forge/VolatileMixinPluginImpl.java | 10 -- forge/src/main/resources/META-INF/mods.toml | 44 ----- .../main/resources/antiqueatlas.mixins.json | 13 -- forge/src/main/resources/pack.mcmeta | 6 - gradle.properties | 23 +-- settings.gradle | 1 - 90 files changed, 449 insertions(+), 849 deletions(-) rename common/src/main/resources/assets/antiqueatlas/textures/{items => item}/antique_atlas.png (100%) rename common/src/main/resources/assets/antiqueatlas/textures/{items => item}/empty_antique_atlas.png (100%) delete mode 100644 forge/build.gradle delete mode 100644 forge/gradle.properties delete mode 100644 forge/src/main/java/hunternif/mc/impl/atlas/client/forge/TileTextureMapImpl.java delete mode 100644 forge/src/main/java/hunternif/mc/impl/atlas/client/gui/forge/AntiqueAtlasConfigMenu.java delete mode 100644 forge/src/main/java/hunternif/mc/impl/atlas/forge/AntiqueAtlasModForge.java delete mode 100644 forge/src/main/java/hunternif/mc/impl/atlas/mixin/forge/VolatileMixinPluginImpl.java delete mode 100644 forge/src/main/resources/META-INF/mods.toml delete mode 100644 forge/src/main/resources/antiqueatlas.mixins.json delete mode 100644 forge/src/main/resources/pack.mcmeta diff --git a/common/build.gradle b/common/build.gradle index 53f60a904..847ce7918 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,5 +1,5 @@ architectury { - common(rootProject.enabled_platforms.split(",")) + common(rootProject.enabled_platforms) } loom { diff --git a/common/src/main/java/hunternif/mc/api/AtlasAPI.java b/common/src/main/java/hunternif/mc/api/AtlasAPI.java index a4a6de5d7..3b4cfb466 100644 --- a/common/src/main/java/hunternif/mc/api/AtlasAPI.java +++ b/common/src/main/java/hunternif/mc/api/AtlasAPI.java @@ -7,8 +7,8 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import java.util.ArrayList; import java.util.Collections; @@ -33,7 +33,7 @@ public static int getVersion() { } public static Item getAtlasItem() { - return Registry.ITEM.get(new Identifier("antiqueatlas:antique_atlas")); + return Registries.ITEM.get(new Identifier("antiqueatlas:antique_atlas")); } /** diff --git a/common/src/main/java/hunternif/mc/impl/atlas/AntiqueAtlasConfig.java b/common/src/main/java/hunternif/mc/impl/atlas/AntiqueAtlasConfig.java index ac77754dc..21dfcafa7 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/AntiqueAtlasConfig.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/AntiqueAtlasConfig.java @@ -93,7 +93,7 @@ public class AntiqueAtlasConfig implements ConfigData { @ConfigEntry.Category("performance") @Comment("If true, all resource pack loading information will be logged during start and reload.") - public boolean resourcePackLogging = true; + public boolean resourcePackLogging = false; @ConfigEntry.Category("appearance") @Comment("The size (in GUI pixels) of a map's tile.\nNote that this will change with Minecraft's GUI scale configuration.\nWhen using a small gui scale, the map may look better with a TILE_SIZE of 16 or more.") diff --git a/common/src/main/java/hunternif/mc/impl/atlas/AntiqueAtlasMod.java b/common/src/main/java/hunternif/mc/impl/atlas/AntiqueAtlasMod.java index 31fc69fc9..08fba1dfc 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/AntiqueAtlasMod.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/AntiqueAtlasMod.java @@ -6,7 +6,6 @@ import hunternif.mc.impl.atlas.core.GlobalTileDataHandler; import hunternif.mc.impl.atlas.core.PlayerEventHandler; import hunternif.mc.impl.atlas.core.TileDataHandler; -import hunternif.mc.impl.atlas.core.scaning.TileDetectorBase; import hunternif.mc.impl.atlas.core.scaning.WorldScanner; import hunternif.mc.impl.atlas.event.RecipeCraftedCallback; import hunternif.mc.impl.atlas.event.RecipeCraftedHandler; @@ -55,7 +54,8 @@ public static AtlasIdData getAtlasIdData(World world) { } public static void init() { - TileDetectorBase.scanBiomeTypes(); + //We just check for tags now + //TileDetectorBase.scanBiomeTypes(); AutoConfig.register(AntiqueAtlasConfig.class, JanksonConfigSerializer::new); CONFIG = AutoConfig.getConfigHolder(AntiqueAtlasConfig.class).getConfig(); diff --git a/common/src/main/java/hunternif/mc/impl/atlas/ClientProxy.java b/common/src/main/java/hunternif/mc/impl/atlas/ClientProxy.java index f06030121..696049efd 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/ClientProxy.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/ClientProxy.java @@ -8,14 +8,13 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.world.ClientWorld; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.resource.ResourceManager; import net.minecraft.resource.ResourceReloader; import net.minecraft.resource.ResourceType; import net.minecraft.util.Identifier; import net.minecraft.util.profiler.Profiler; -import net.minecraft.util.registry.BuiltinRegistries; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.biome.Biome; import java.util.Map; @@ -63,19 +62,19 @@ public void initClient() { * we need the ClientWorld loaded here. */ public static void assignCustomBiomeTextures(ClientWorld world) { - for (Map.Entry, Biome> biome : BuiltinRegistries.BIOME.getEntrySet()) { - Identifier id = BuiltinRegistries.BIOME.getId(biome.getValue()); + for (Map.Entry, Biome> biome : world.getRegistryManager().get(RegistryKeys.BIOME).getEntrySet()) { + Identifier id = world.getRegistryManager().get(RegistryKeys.BIOME).getId(biome.getValue()); if (!TileTextureMap.instance().isRegistered(id)) { TileTextureMap.instance().autoRegister(id, biome.getKey()); } } - for (Map.Entry, Biome> entry : world.getRegistryManager().get(Registry.BIOME_KEY).getEntrySet()) { - Identifier id = world.getRegistryManager().get(Registry.BIOME_KEY).getId(entry.getValue()); + /*for (Map.Entry, Biome> entry : world.getRegistryManager().get(RegistryKeys.BIOME).getEntrySet()) { + Identifier id = world.getRegistryManager().get(RegistryKeys.BIOME).getId(entry.getValue()); if (!TileTextureMap.instance().isRegistered(id)) { TileTextureMap.instance().autoRegister(id, entry.getKey()); } - } + }*/ } @Override diff --git a/common/src/main/java/hunternif/mc/impl/atlas/api/impl/TileApiImpl.java b/common/src/main/java/hunternif/mc/impl/atlas/api/impl/TileApiImpl.java index adcd5dd4c..db43c98e4 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/api/impl/TileApiImpl.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/api/impl/TileApiImpl.java @@ -1,19 +1,19 @@ package hunternif.mc.impl.atlas.api.impl; -import hunternif.mc.impl.atlas.AntiqueAtlasMod; import hunternif.mc.api.TileAPI; +import hunternif.mc.impl.atlas.AntiqueAtlasMod; import hunternif.mc.impl.atlas.core.AtlasData; import hunternif.mc.impl.atlas.core.TileDataStorage; import hunternif.mc.impl.atlas.network.packet.c2s.play.PutTileC2SPacket; -import hunternif.mc.impl.atlas.network.packet.s2c.play.PutGlobalTileS2CPacket; import hunternif.mc.impl.atlas.network.packet.s2c.play.DeleteGlobalTileS2CPacket; +import hunternif.mc.impl.atlas.network.packet.s2c.play.PutGlobalTileS2CPacket; import hunternif.mc.impl.atlas.network.packet.s2c.play.PutTileS2CPacket; import hunternif.mc.impl.atlas.util.Log; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.registry.RegistryKey; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.World; diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/OverlayRenderer.java b/common/src/main/java/hunternif/mc/impl/atlas/client/OverlayRenderer.java index 9b1b04981..43d41c4fa 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/OverlayRenderer.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/OverlayRenderer.java @@ -3,9 +3,9 @@ import com.mojang.blaze3d.systems.RenderSystem; import hunternif.mc.api.client.AtlasClientAPI; import hunternif.mc.impl.atlas.AntiqueAtlasMod; -import hunternif.mc.impl.atlas.item.AntiqueAtlasItems; import hunternif.mc.impl.atlas.client.gui.GuiAtlas; import hunternif.mc.impl.atlas.core.WorldData; +import hunternif.mc.impl.atlas.item.AntiqueAtlasItems; import hunternif.mc.impl.atlas.item.AtlasItem; import hunternif.mc.impl.atlas.marker.DimensionMarkersData; import hunternif.mc.impl.atlas.marker.Marker; @@ -16,21 +16,20 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.util.math.Quaternion; +import net.minecraft.util.math.RotationAxis; import net.minecraft.util.math.Vec3d; -import net.minecraft.util.math.Vec3f; import net.minecraft.world.World; +import org.joml.Quaternionf; import org.lwjgl.opengl.GL11; import java.util.List; @Environment(EnvType.CLIENT) -public class OverlayRenderer extends DrawableHelper { +public class OverlayRenderer { /** * Number of blocks per chunk in minecraft. This is certianly stored * somewhere else, but I couldn't be bothered to find it. @@ -40,7 +39,7 @@ public class OverlayRenderer extends DrawableHelper { private PlayerEntity player; private World world; - public void drawOverlay(MatrixStack matrices, VertexConsumerProvider vertexConsumer, int light, ItemStack atlas) { + public void drawOverlay(MatrixStack matrixStack, VertexConsumerProvider vertexConsumer, int light, ItemStack atlas) { // Overlay must close if Atlas GUI is opened if (MinecraftClient.getInstance().currentScreen instanceof GuiAtlas) { return; @@ -55,48 +54,48 @@ public void drawOverlay(MatrixStack matrices, VertexConsumerProvider vertexConsu if (!atlas.isEmpty() && atlas.getItem() == AntiqueAtlasItems.ATLAS.getOrNull()) { int atlasID = AtlasItem.getAtlasID(atlas); - drawMinimap(matrices, atlasID, vertexConsumer, light); + drawMinimap(matrixStack, atlasID, vertexConsumer, light); } } - private void drawMinimap(MatrixStack matrices, int atlasID, VertexConsumerProvider buffer, int light) { + private void drawMinimap(MatrixStack matrixStack, int atlasID, VertexConsumerProvider buffer, int light) { RenderSystem.enableBlend(); RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - matrices.push(); - matrices.translate(0, 0, 0.01); - Textures.BOOK.drawWithLight(buffer, matrices, 0, 0, (int) (GuiAtlas.WIDTH * 1.5), (int) (GuiAtlas.HEIGHT * 1.5), light); - matrices.pop(); + matrixStack.push(); + matrixStack.translate(0, 0, 0.01); + Textures.BOOK.drawWithLight(buffer, matrixStack, 0, 0, (int) (GuiAtlas.WIDTH * 1.5), (int) (GuiAtlas.HEIGHT * 1.5), light); + matrixStack.pop(); - matrices.push(); - matrices.scale(INNER_ELEMENTS_SCALE_FACTOR, INNER_ELEMENTS_SCALE_FACTOR, 1F); + matrixStack.push(); + matrixStack.scale(INNER_ELEMENTS_SCALE_FACTOR, INNER_ELEMENTS_SCALE_FACTOR, 1F); - drawTiles(buffer, matrices, atlasID, light); - matrices.translate(0, 0, -0.01); + drawTiles(buffer, matrixStack, atlasID, light); + matrixStack.translate(0, 0, -0.01); if (AntiqueAtlasMod.CONFIG.markerSize > 0) { - drawMarkers(buffer, matrices, atlasID, light); + drawMarkers(buffer, matrixStack, atlasID, light); } - matrices.pop(); + matrixStack.pop(); - matrices.translate(0, 0, -0.02); - drawPlayer(buffer, matrices, light); + matrixStack.translate(0, 0, -0.02); + drawPlayer(buffer, matrixStack, light); // Overlay the frame so that edges of the map are smooth: - matrices.translate(0, 0, -0.01); - Textures.BOOK_FRAME.drawWithLight(buffer, matrices, 0, 0, (int) (GuiAtlas.WIDTH * 1.5), (int) (GuiAtlas.HEIGHT * 1.5), light); + matrixStack.translate(0, 0, -0.01); + Textures.BOOK_FRAME.drawWithLight(buffer, matrixStack, 0, 0, (int) (GuiAtlas.WIDTH * 1.5), (int) (GuiAtlas.HEIGHT * 1.5), light); RenderSystem.disableBlend(); } - private void drawTiles(VertexConsumerProvider buffer, MatrixStack matrices, int atlasID, int light) { + private void drawTiles(VertexConsumerProvider buffer, MatrixStack matrixStack, int atlasID, int light) { Rect iteratorScope = getChunkCoverage(player.getPos()); TileRenderIterator iter = AtlasClientAPI.getTileAPI().getTiles(world, atlasID, iteratorScope, 1); Vec3d chunkPosition = player.getPos().multiply(1D / CHUNK_SIZE, 1D / CHUNK_SIZE, 1D / CHUNK_SIZE); int shapeMiddleX = (int) ((GuiAtlas.WIDTH * 1.5F) / (INNER_ELEMENTS_SCALE_FACTOR * 2)); int shapeMiddleY = (int) ((GuiAtlas.HEIGHT * 1.5F) / (INNER_ELEMENTS_SCALE_FACTOR * 2)); - SetTileRenderer renderer = new SetTileRenderer(buffer, matrices, AntiqueAtlasMod.CONFIG.tileSize / 2, light); + SetTileRenderer renderer = new SetTileRenderer(buffer, matrixStack, AntiqueAtlasMod.CONFIG.tileSize / 2, light); while (iter.hasNext()) { SubTileQuartet subtiles = iter.next(); @@ -123,7 +122,7 @@ private void drawTiles(VertexConsumerProvider buffer, MatrixStack matrices, int renderer.draw(); } - private void drawMarkers(VertexConsumerProvider buffer, MatrixStack matrices, int atlasID, int light) { + private void drawMarkers(VertexConsumerProvider buffer, MatrixStack matrixStack, int atlasID, int light) { // biomeData needed to prevent undiscovered markers from appearing WorldData biomeData = AntiqueAtlasMod.tileData.getData( atlasID, this.world).getWorldData( @@ -132,7 +131,7 @@ private void drawMarkers(VertexConsumerProvider buffer, MatrixStack matrices, in .getData().getMarkersDataInWorld(this.world.getRegistryKey()); // Draw global markers: - drawMarkersData(buffer, matrices, globalMarkersData, biomeData, light); + drawMarkersData(buffer, matrixStack, globalMarkersData, biomeData, light); MarkersData markersData = AntiqueAtlasMod.markersData.getMarkersData( atlasID, MinecraftClient.getInstance().world); @@ -140,19 +139,19 @@ private void drawMarkers(VertexConsumerProvider buffer, MatrixStack matrices, in DimensionMarkersData localMarkersData = markersData.getMarkersDataInWorld(world.getRegistryKey()); // Draw local markers: - drawMarkersData(buffer, matrices, localMarkersData, biomeData, light); + drawMarkersData(buffer, matrixStack, localMarkersData, biomeData, light); } } - private void drawPlayer(VertexConsumerProvider buffer, MatrixStack matrices, int light) { - matrices.push(); + private void drawPlayer(VertexConsumerProvider buffer, MatrixStack matrixStack, int light) { + matrixStack.push(); - matrices.translate((int) ((GuiAtlas.WIDTH * 1.5F) / 2F), (int) ((GuiAtlas.HEIGHT * 1.5F) / 2F), 0); - matrices.multiply(new Quaternion(Vec3f.POSITIVE_Z, this.player.getHeadYaw() + 180, true)); - matrices.translate(-AntiqueAtlasMod.CONFIG.playerIconWidth / 2.0, -AntiqueAtlasMod.CONFIG.playerIconHeight / 2.0, 0); + matrixStack.translate((int) ((GuiAtlas.WIDTH * 1.5F) / 2F), (int) ((GuiAtlas.HEIGHT * 1.5F) / 2F), 0); + matrixStack.multiply(new Quaternionf(RotationAxis.POSITIVE_Z.rotationDegrees(this.player.getHeadYaw() + 180))); + matrixStack.translate(-AntiqueAtlasMod.CONFIG.playerIconWidth / 2.0, -AntiqueAtlasMod.CONFIG.playerIconHeight / 2.0, 0); - Textures.PLAYER.drawWithLight(buffer, matrices, 0, 0, AntiqueAtlasMod.CONFIG.playerIconWidth, AntiqueAtlasMod.CONFIG.playerIconHeight, light); - matrices.pop(); + Textures.PLAYER.drawWithLight(buffer, matrixStack, 0, 0, AntiqueAtlasMod.CONFIG.playerIconWidth, AntiqueAtlasMod.CONFIG.playerIconHeight, light); + matrixStack.pop(); } private void drawMarkersData(VertexConsumerProvider buffer, MatrixStack matrices, DimensionMarkersData markersData, WorldData biomeData, int light) { @@ -189,7 +188,7 @@ private void drawMarkersData(VertexConsumerProvider buffer, MatrixStack matrices } } - private void renderMarker(VertexConsumerProvider buffer, MatrixStack matrices, Marker marker, int x, int y, WorldData biomeData, int light) { + private void renderMarker(VertexConsumerProvider buffer, MatrixStack matrixStack, Marker marker, int x, int y, WorldData biomeData, int light) { int tileHalfSize = GuiAtlas.MARKER_SIZE / 16; if (!((x + tileHalfSize) <= 240 && (x - tileHalfSize >= 3) && (y + tileHalfSize) < 166 && (y - tileHalfSize) >= 0)) return; @@ -201,7 +200,7 @@ private void renderMarker(VertexConsumerProvider buffer, MatrixStack matrices, M MarkerType type = MarkerType.REGISTRY.get(marker.getType()); // TODO Fabric - Scale factor? MarkerRenderInfo info = type.getRenderInfo(1, AntiqueAtlasMod.CONFIG.tileSize, 1); - info.tex.drawWithLight(buffer, matrices, x - GuiAtlas.MARKER_SIZE / 4 + 4, y - GuiAtlas.MARKER_SIZE / 4 + 4, GuiAtlas.MARKER_SIZE / 2, GuiAtlas.MARKER_SIZE / 2, light); + info.tex.drawWithLight(buffer, matrixStack, x - GuiAtlas.MARKER_SIZE / 4 + 4, y - GuiAtlas.MARKER_SIZE / 4 + 4, GuiAtlas.MARKER_SIZE / 2, GuiAtlas.MARKER_SIZE / 2, light); } private Rect getChunkCoverage(Vec3d position) { diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/SetTileRenderer.java b/common/src/main/java/hunternif/mc/impl/atlas/client/SetTileRenderer.java index 2f6730d9a..dff4f8663 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/SetTileRenderer.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/SetTileRenderer.java @@ -21,13 +21,13 @@ class SetTileRenderer { private final HashMap> subjects = new HashMap<>(); - private final MatrixStack matrices; + private final MatrixStack matrixStack; private final int tileHalfSize; private final int light; private final VertexConsumerProvider buffer; - public SetTileRenderer(VertexConsumerProvider buffer, MatrixStack matrices, int tileHalfSize, int light) { - this.matrices = matrices; + public SetTileRenderer(VertexConsumerProvider buffer, MatrixStack matrixStack, int tileHalfSize, int light) { + this.matrixStack = matrixStack; this.tileHalfSize = tileHalfSize; this.light = light; this.buffer = buffer; @@ -53,7 +53,7 @@ public void draw() { private void drawInlineAutotileCorner(ITexture texture, int x, int y, int u, int v) { // This is dumb. But because there are drawn four at a time, these chunks prevent rendering outside of our map if ((x + tileHalfSize) <= 240 && (x - tileHalfSize >= 0) && (y + tileHalfSize) < 166 && (y - tileHalfSize) >= 0) { - texture.drawWithLight(this.buffer, this.matrices, x, y, tileHalfSize, tileHalfSize, u, v, 1, 1, this.light); + texture.drawWithLight(this.buffer, matrixStack, x, y, tileHalfSize, tileHalfSize, u, v, 1, 1, this.light); } } diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/TextureConfig.java b/common/src/main/java/hunternif/mc/impl/atlas/client/TextureConfig.java index 2121cc45a..215f2312b 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/TextureConfig.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/TextureConfig.java @@ -41,7 +41,7 @@ public CompletableFuture> load(ResourceManager manager return CompletableFuture.supplyAsync(() -> { Map textures = new HashMap<>(); - for (Identifier id : manager.findResources("textures/gui/tiles", (s) -> s.endsWith(".png"))) { + for (Identifier id : manager.findResources("textures/gui/tiles", (s) -> s.getPath().endsWith(".png")).keySet()) { // id now contains the physical file path of the texture try { diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/TextureSetConfig.java b/common/src/main/java/hunternif/mc/impl/atlas/client/TextureSetConfig.java index 334e8dc82..6fa16e8e0 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/TextureSetConfig.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/TextureSetConfig.java @@ -40,14 +40,14 @@ public CompletableFuture> load(ResourceManager manager, P Map sets = new HashMap<>(); try { - for (Identifier id : manager.findResources("atlas/texture_sets", (s) -> s.endsWith(".json"))) { + for (Identifier id : manager.findResources("atlas/texture_sets", (s) -> s.getPath().endsWith(".json")).keySet()) { Identifier texture_id = new Identifier( id.getNamespace(), id.getPath().replace("atlas/texture_sets/", "").replace(".json", "") ); try { - Resource resource = manager.getResource(id); + Resource resource = manager.getResource(id).get(); try ( InputStream stream = resource.getInputStream(); InputStreamReader reader = new InputStreamReader(stream) diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/TileTextureConfig.java b/common/src/main/java/hunternif/mc/impl/atlas/client/TileTextureConfig.java index 248d55f73..c7d005b9a 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/TileTextureConfig.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/TileTextureConfig.java @@ -45,11 +45,11 @@ public CompletableFuture> load(ResourceManager manag Map map = new HashMap<>(); try { - for (Identifier id : manager.findResources("atlas/tiles", (s) -> s.endsWith(".json"))) { + for (Identifier id : manager.findResources("atlas/tiles", (s) -> s.getPath().endsWith(".json")).keySet()) { Identifier tile_id = new Identifier(id.getNamespace(), id.getPath().replace("atlas/tiles/", "").replace(".json", "")); try { - Resource resource = manager.getResource(id); + Resource resource = manager.getResource(id).get(); try (InputStream stream = resource.getInputStream(); InputStreamReader reader = new InputStreamReader(stream)) { JsonObject object = JsonParser.parseReader(reader).getAsJsonObject(); diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/TileTextureMap.java b/common/src/main/java/hunternif/mc/impl/atlas/client/TileTextureMap.java index 514ff5770..62c66e7b8 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/TileTextureMap.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/TileTextureMap.java @@ -7,12 +7,10 @@ import hunternif.mc.impl.atlas.util.Log; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.BuiltinRegistries; -import net.minecraft.util.registry.RegistryEntryList; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.feature.PlacedFeature; import java.util.*; import java.util.Map.Entry; @@ -96,8 +94,10 @@ static private Optional guessFittingTextureSet(RegistryKey bi throw new AssertionError("Not implemented"); } - static public Optional guessFittingTextureSetFallback(Biome biome) { - Identifier texture_set = switch (biome.getCategory()) { + //TODO: This is not implemented, because I do not want to do this. + static public Optional guessFittingTextureSetFallback(RegistryEntry.Reference biome) { + AntiqueAtlasMod.LOG.error("FALLBACK WAS CALLED"); + /**Identifier texture_set = switch (biome.getCategory()) { case SWAMP -> AntiqueAtlasMod.id("swamp"); case OCEAN, RIVER -> biome.getPrecipitation() == Biome.Precipitation.SNOW ? AntiqueAtlasMod.id("ice") : AntiqueAtlasMod.id("water"); @@ -132,9 +132,9 @@ static public Optional guessFittingTextureSetFallback(Biome biome) { Log.warn("Underground biomes aren't supported yet."); yield null; } - }; + };**/ - return Optional.ofNullable(texture_set); + return Optional.ofNullable(null); } public boolean isRegistered(Identifier id) { diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/ExportProgressOverlay.java b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/ExportProgressOverlay.java index bf6790ace..3877ce034 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/ExportProgressOverlay.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/ExportProgressOverlay.java @@ -1,24 +1,21 @@ package hunternif.mc.impl.atlas.client.gui; -import com.mojang.blaze3d.platform.GlStateManager; -import com.mojang.blaze3d.systems.RenderSystem; import hunternif.mc.impl.atlas.util.ExportImageUtil; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.Tessellator; import net.minecraft.client.render.VertexFormat; import net.minecraft.client.render.VertexFormats; -import net.minecraft.client.util.math.MatrixStack; -import org.lwjgl.opengl.GL11; public enum ExportProgressOverlay { INSTANCE; @Environment(EnvType.CLIENT) - public void draw(MatrixStack matrices, int scaledWidth, int scaledHeight) { + public void draw(DrawContext drawContext, int scaledWidth, int scaledHeight) { int x = scaledWidth - 40, y = scaledHeight - 20, barWidth = 50, barHeight = 2; ExportUpdateListener l = ExportUpdateListener.INSTANCE; @@ -31,9 +28,9 @@ public void draw(MatrixStack matrices, int scaledWidth, int scaledHeight) { int s = 2; int headerWidth = font.getWidth(l.header); - font.draw(matrices, l.header, (x) * s - headerWidth / 2F, (y) * s - 14, 0xffffff); + drawContext.drawText(font, l.header, (x) * s - headerWidth / 2, (y) * s - 14, 0xffffff, false); int statusWidth = font.getWidth(l.status); - font.draw(matrices, l.status, (x) * s - statusWidth / 2F, (y) * s, 0xffffff); + drawContext.drawText(font, l.header, (x) * s - statusWidth / 2, (y) * s, 0xffffff, false); y += 7; @@ -42,7 +39,7 @@ public void draw(MatrixStack matrices, int scaledWidth, int scaledHeight) { if (l.maxProgress < 0) p = 0; - RenderSystem.disableTexture(); + //RenderSystem.disableTexture(); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder vb = tessellator.getBuffer(); @@ -61,6 +58,6 @@ public void draw(MatrixStack matrices, int scaledWidth, int scaledHeight) { tessellator.draw(); - RenderSystem.enableTexture(); + //RenderSystem.enableTexture(); } } diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiArrowButton.java b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiArrowButton.java index e32c026a1..3e1d00f3b 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiArrowButton.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiArrowButton.java @@ -3,7 +3,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import hunternif.mc.impl.atlas.client.Textures; import hunternif.mc.impl.atlas.client.gui.core.GuiComponentButton; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import org.lwjgl.opengl.GL11; public class GuiArrowButton extends GuiComponentButton { @@ -44,7 +44,7 @@ static GuiArrowButton right() { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTick) { + public void render(DrawContext drawContext, int mouseX, int mouseY, float partialTick) { RenderSystem.enableBlend(); RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); @@ -81,7 +81,8 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTi v = 12; break; } - Textures.BTN_ARROWS.draw(matrices, x, y, u, v, WIDTH, HEIGHT); + drawContext.drawTexture(Textures.BTN_ARROWS.getTexture(), x, y, u, v, WIDTH, HEIGHT); + //Textures.BTN_ARROWS.draw(matrices, x, y, u, v, WIDTH, HEIGHT); RenderSystem.disableBlend(); } diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiAtlas.java b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiAtlas.java index 0511dcfb2..712a8fb80 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiAtlas.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiAtlas.java @@ -19,25 +19,24 @@ import hunternif.mc.impl.atlas.network.packet.c2s.play.PutBrowsingPositionC2SPacket; import hunternif.mc.impl.atlas.registry.MarkerRenderInfo; import hunternif.mc.impl.atlas.registry.MarkerType; -import hunternif.mc.impl.atlas.util.*; +import hunternif.mc.impl.atlas.util.ExportImageUtil; +import hunternif.mc.impl.atlas.util.Log; +import hunternif.mc.impl.atlas.util.MathUtil; +import hunternif.mc.impl.atlas.util.Rect; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.option.KeyBinding; import net.minecraft.client.resource.language.I18n; import net.minecraft.client.sound.PositionedSoundInstance; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; -import net.minecraft.text.LiteralText; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3f; import org.lwjgl.glfw.GLFW; import org.lwjgl.opengl.GL11; @@ -93,14 +92,14 @@ public class GuiAtlas extends GuiComponent { public void onEnterState() { // Set the button as not selected so that it can be clicked again: btnShowMarkers.setSelected(false); - btnShowMarkers.setTitle(new TranslatableText("gui.antiqueatlas.showMarkers")); + btnShowMarkers.setTitle(Text.translatable("gui.antiqueatlas.showMarkers")); btnShowMarkers.setIconTexture(Textures.ICON_SHOW_MARKERS); } @Override public void onExitState() { btnShowMarkers.setSelected(false); - btnShowMarkers.setTitle(new TranslatableText("gui.antiqueatlas.hideMarkers")); + btnShowMarkers.setTitle(Text.translatable("gui.antiqueatlas.hideMarkers")); btnShowMarkers.setIconTexture(Textures.ICON_HIDE_MARKERS); } }; @@ -340,7 +339,7 @@ public GuiAtlas() { btnRight.addListener(positionListener); btnPosition.addListener(positionListener); - btnExportPng = new GuiBookmarkButton(1, Textures.ICON_EXPORT, new TranslatableText("gui.antiqueatlas.exportImage")) { + btnExportPng = new GuiBookmarkButton(1, Textures.ICON_EXPORT, Text.translatable("gui.antiqueatlas.exportImage")) { @Override public boolean isEnabled() { return !ExportImageUtil.isExporting; @@ -354,7 +353,7 @@ public boolean isEnabled() { } }); - btnMarker = new GuiBookmarkButton(0, Textures.ICON_ADD_MARKER, new TranslatableText("gui.antiqueatlas.addMarker")); + btnMarker = new GuiBookmarkButton(0, Textures.ICON_ADD_MARKER, Text.translatable("gui.antiqueatlas.addMarker")); addChild(btnMarker).offsetGuiCoords(300, 14); btnMarker.addListener(button -> { if (state.is(PLACING_MARKER)) { @@ -388,7 +387,7 @@ public boolean isEnabled() { } } }); - btnDelMarker = new GuiBookmarkButton(2, Textures.ICON_DELETE_MARKER, new TranslatableText("gui.antiqueatlas.delMarker")); + btnDelMarker = new GuiBookmarkButton(2, Textures.ICON_DELETE_MARKER, Text.translatable("gui.antiqueatlas.delMarker")); addChild(btnDelMarker).offsetGuiCoords(300, 33); btnDelMarker.addListener(button -> { if (state.is(DELETING_MARKER)) { @@ -399,7 +398,7 @@ public boolean isEnabled() { state.switchTo(DELETING_MARKER); } }); - btnShowMarkers = new GuiBookmarkButton(3, Textures.ICON_HIDE_MARKERS, new TranslatableText("gui.antiqueatlas.hideMarkers")); + btnShowMarkers = new GuiBookmarkButton(3, Textures.ICON_HIDE_MARKERS, Text.translatable("gui.antiqueatlas.hideMarkers")); addChild(btnShowMarkers).offsetGuiCoords(300, 52); btnShowMarkers.addListener(button -> { selectedButton = null; @@ -484,7 +483,6 @@ public void init() { state.switchTo(NORMAL); //TODO: his causes the Export PNG progress bar to disappear when resizing game window } - MinecraftClient.getInstance().keyboard.setRepeatEvents(true); screenScale = MinecraftClient.getInstance().getWindow().getScaleFactor(); setCentered(); @@ -890,7 +888,7 @@ private void setMapScale(double scale, int addOffsetX, int addOffsetY) { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float par3) { + public void render(DrawContext drawContext, int mouseX, int mouseY, float par3) { long currentMillis = System.currentTimeMillis(); long deltaMillis = currentMillis - lastUpdateMillis; lastUpdateMillis = currentMillis; @@ -907,13 +905,13 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float par3) { } } - super.renderBackground(matrices); + super.renderBackground(drawContext); RenderSystem.setShaderColor(1, 1, 1, 1); // TODO fix me for 1.17 // RenderSystem.enableAlphaTest(); // RenderSystem.alphaFunc(GL11.GL_GREATER, 0); // So light detail on tiles is visible - Textures.BOOK.draw(matrices, getGuiX(), getGuiY()); + Textures.BOOK.draw(drawContext, getGuiX(), getGuiY()); if ((stack == null && AntiqueAtlasMod.CONFIG.itemNeeded) || biomeData == null) return; @@ -942,6 +940,8 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float par3) { tiles.setScope(new Rect(mapStartX, mapStartZ, mapEndX, mapEndZ)); tiles.setStep(tile2ChunkScale); + + var matrices = drawContext.getMatrices(); matrices.push(); matrices.translate(mapStartScreenX, mapStartScreenY, 0); @@ -952,7 +952,7 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float par3) { if (texture instanceof TileTexture) { TileTexture tileTexture = (TileTexture) texture; tileTexture.bind(); - tileTexture.drawSubTile(matrices, subtile, tileHalfSize); + tileTexture.drawSubTile(drawContext, subtile, tileHalfSize); } } } @@ -966,27 +966,27 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float par3) { // Overlay the frame so that edges of the map are smooth: RenderSystem.setShaderColor(1, 1, 1, 1); - Textures.BOOK_FRAME.draw(matrices, getGuiX(), getGuiY()); + Textures.BOOK_FRAME.draw(drawContext, getGuiX(), getGuiY()); double iconScale = getIconScale(); // Draw global markers: - renderMarkers(matrices, markersStartX, markersStartZ, markersEndX, markersEndZ, globalMarkersData); - renderMarkers(matrices, markersStartX, markersStartZ, markersEndX, markersEndZ, localMarkersData); + renderMarkers(drawContext, markersStartX, markersStartZ, markersEndX, markersEndZ, globalMarkersData); + renderMarkers(drawContext, markersStartX, markersStartZ, markersEndX, markersEndZ, localMarkersData); RenderSystem.disableScissor(); - Textures.BOOK_FRAME_NARROW.draw(matrices, getGuiX(), getGuiY()); + Textures.BOOK_FRAME_NARROW.draw(drawContext, getGuiX(), getGuiY()); - renderScaleOverlay(matrices, deltaMillis); + renderScaleOverlay(drawContext, deltaMillis); // Draw player icon: if (!state.is(HIDING_MARKERS)) { - renderPlayer(matrices, iconScale); + renderPlayer(drawContext, iconScale); } // Draw buttons: - super.render(matrices, mouseX, mouseY, par3); + super.render(drawContext, mouseX, mouseY, par3); // Draw the semi-transparent marker attached to the cursor when placing a new marker: RenderSystem.enableBlend(); @@ -996,7 +996,7 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float par3) { markerFinalizer.selectedType.calculateMip(iconScale, mapScale, screenScale); MarkerRenderInfo renderInfo = markerFinalizer.selectedType.getRenderInfo(iconScale, mapScale, screenScale); markerFinalizer.selectedType.resetMip(); - renderInfo.tex.draw(matrices, mouseX + renderInfo.x, mouseY + renderInfo.y); + renderInfo.tex.draw(drawContext, mouseX + renderInfo.x, mouseY + renderInfo.y); RenderSystem.setShaderColor(1, 1, 1, 1); } RenderSystem.disableBlend(); @@ -1012,26 +1012,26 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float par3) { Identifier tile = biomeData.getTile(pos.x, pos.z); if (tile == null) { - drawTooltip(Arrays.asList(new LiteralText(coords), new LiteralText(chunks)), textRenderer); + drawTooltip(Arrays.asList(Text.literal(coords), Text.literal(chunks)), textRenderer); } else { String texture_set = TileTextureMap.instance().getTextureSet(tile).name.toString(); drawTooltip(Arrays.asList( - new LiteralText(coords), - new LiteralText(chunks), - new LiteralText("Tile: " + tile), - new LiteralText("TSet: " + texture_set)), + Text.literal(coords), + Text.literal(chunks), + Text.literal("Tile: " + tile), + Text.literal("TSet: " + texture_set)), textRenderer); } } // Draw progress overlay: if (state.is(EXPORTING_IMAGE)) { - renderBackground(matrices); - progressBar.draw(matrices, (width - 100) / 2, height / 2 - 34); + renderBackground(drawContext); + progressBar.draw(drawContext, (width - 100) / 2, height / 2 - 34); } } - private void renderPlayer(MatrixStack matrices, double iconScale) { + private void renderPlayer(DrawContext drawContext, double iconScale) { int playerOffsetX = worldXToScreenX(player.getBlockX()); int playerOffsetY = worldZToScreenY(player.getBlockZ()); @@ -1042,13 +1042,14 @@ private void renderPlayer(MatrixStack matrices, double iconScale) { RenderSystem.setShaderColor(1, 1, 1, state.is(PLACING_MARKER) ? 0.5f : 1); float playerRotation = (float) Math.round(player.getYaw() / 360f * PLAYER_ROTATION_STEPS) / PLAYER_ROTATION_STEPS * 360f; - Textures.PLAYER.drawCenteredWithRotation(matrices, playerOffsetX, playerOffsetY, (int) Math.round(PLAYER_ICON_WIDTH * iconScale), (int) Math.round(PLAYER_ICON_HEIGHT * iconScale), playerRotation); + Textures.PLAYER.drawCenteredWithRotation(drawContext, playerOffsetX, playerOffsetY, (int) Math.round(PLAYER_ICON_WIDTH * iconScale), (int) Math.round(PLAYER_ICON_HEIGHT * iconScale), playerRotation); RenderSystem.setShaderColor(1, 1, 1, 1); } - private void renderScaleOverlay(MatrixStack matrices, long deltaMillis) { + private void renderScaleOverlay(DrawContext drawContext, long deltaMillis) { if (scaleAlpha > 3) { + var matrices = drawContext.getMatrices(); matrices.push(); matrices.translate(getGuiX() + WIDTH - 13, getGuiY() + 12, 0); @@ -1060,7 +1061,7 @@ private void renderScaleOverlay(MatrixStack matrices, long deltaMillis) { text = "x"; xWidth = textWidth = this.textRenderer.getWidth(text); xWidth++; - this.textRenderer.draw(matrices, text, -textWidth, 0, color); + drawContext.drawText(this.textRenderer, text, -textWidth, 0, color, false); text = zoomNames[zoomLevel]; if (text.contains("/")) { @@ -1069,16 +1070,16 @@ private void renderScaleOverlay(MatrixStack matrices, long deltaMillis) { int centerXtranslate = Math.max(this.textRenderer.getWidth(parts[0]), this.textRenderer.getWidth(parts[1])) / 2; matrices.translate(-xWidth - centerXtranslate, (float) -this.textRenderer.fontHeight / 2, 0); - DrawableHelper.fill(matrices, -centerXtranslate - 1, this.textRenderer.fontHeight - 1, centerXtranslate, this.textRenderer.fontHeight, color); + drawContext.fill(-centerXtranslate - 1, this.textRenderer.fontHeight - 1, centerXtranslate, this.textRenderer.fontHeight, color); textWidth = this.textRenderer.getWidth(parts[0]); - this.textRenderer.draw(matrices, parts[0], (float) -textWidth / 2, 0, color); + drawContext.drawText(this.textRenderer, parts[0], -textWidth / 2, 0, color, false); textWidth = this.textRenderer.getWidth(parts[1]); - this.textRenderer.draw(matrices, parts[1], (float) -textWidth / 2, 10, color); + drawContext.drawText(this.textRenderer, parts[1], -textWidth / 2, 10, color, false); } else { textWidth = this.textRenderer.getWidth(text); - this.textRenderer.draw(matrices, text, -textWidth - xWidth + 1, 2, color); + drawContext.drawText(this.textRenderer, text, -textWidth - xWidth + 1, 2, color, false); } matrices.pop(); @@ -1097,7 +1098,7 @@ private void renderScaleOverlay(MatrixStack matrices, long deltaMillis) { } } - private void renderMarkers(MatrixStack matrices, int markersStartX, int markersStartZ, + private void renderMarkers(DrawContext drawContext, int markersStartX, int markersStartZ, int markersEndX, int markersEndZ, DimensionMarkersData markersData) { if (markersData == null) return; @@ -1106,13 +1107,13 @@ private void renderMarkers(MatrixStack matrices, int markersStartX, int markersS List markers = markersData.getMarkersAtChunk(x, z); if (markers == null) continue; for (Marker marker : markers) { - renderMarker(matrices, marker, getIconScale()); + renderMarker(drawContext, marker, getIconScale()); } } } } - private void renderMarker(MatrixStack matrices, Marker marker, double scale) { + private void renderMarker(DrawContext drawContext, Marker marker, double scale) { MarkerType type = MarkerType.REGISTRY.get(marker.getType()); if (type.shouldHide(state.is(HIDING_MARKERS), scaleClipIndex)) { return; @@ -1167,7 +1168,7 @@ private void renderMarker(MatrixStack matrices, Marker marker, double scale) { markerY = MathHelper.clamp(markerY, getGuiY() + MAP_BORDER_HEIGHT, getGuiY() + MAP_HEIGHT + MAP_BORDER_HEIGHT); } - info.tex.draw(matrices, markerX + info.x, markerY + info.y, info.width, info.height); + info.tex.draw(drawContext, markerX + info.x, markerY + info.y, info.width, info.height); RenderSystem.setShaderColor(1, 1, 1, 1); @@ -1226,8 +1227,8 @@ protected void onChildClosed(GuiComponent child) { * Update all text labels to current localization. */ public void updateL18n() { - btnExportPng.setTitle(new TranslatableText("gui.antiqueatlas.exportImage")); - btnMarker.setTitle(new TranslatableText("gui.antiqueatlas.addMarker")); + btnExportPng.setTitle(Text.translatable("gui.antiqueatlas.exportImage")); + btnMarker.setTitle(Text.translatable("gui.antiqueatlas.addMarker")); } /** diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiBookmarkButton.java b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiBookmarkButton.java index 5fdd885b6..c01cece71 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiBookmarkButton.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiBookmarkButton.java @@ -5,7 +5,7 @@ import hunternif.mc.impl.atlas.client.gui.core.GuiToggleButton; import hunternif.mc.impl.atlas.client.texture.ITexture; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import net.minecraft.text.Text; import java.util.Collections; @@ -48,16 +48,16 @@ void setTitle(Text title) { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTick) { + public void render(DrawContext drawContext, int mouseX, int mouseY, float partialTick) { RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); // Render background: int u = colorIndex * WIDTH; int v = isMouseOver || isSelected() ? 0 : HEIGHT; - Textures.BOOKMARKS.draw(matrices, getGuiX(), getGuiY(), u, v, WIDTH, HEIGHT); + Textures.BOOKMARKS.draw(drawContext, getGuiX(), getGuiY(), u, v, WIDTH, HEIGHT); // Render the icon: - iconTexture.draw(matrices, getGuiX() + (isMouseOver || isSelected() ? 3 : 2), getGuiY() + 1); + iconTexture.draw(drawContext, getGuiX() + (isMouseOver || isSelected() ? 3 : 2), getGuiY() + 1); if (isMouseOver) { drawTooltip(Collections.singletonList(title), MinecraftClient.getInstance().textRenderer); diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiMarkerBookmark.java b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiMarkerBookmark.java index 6a65f5da4..539746d56 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiMarkerBookmark.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiMarkerBookmark.java @@ -7,7 +7,7 @@ import hunternif.mc.impl.atlas.marker.Marker; import hunternif.mc.impl.atlas.registry.MarkerType; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import net.minecraft.text.Text; import java.util.Collections; @@ -45,16 +45,16 @@ public Text getTitle() { @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTick) { + public void render(DrawContext drawContext, int mouseX, int mouseY, float partialTick) { RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); // Render background: int u = colorIndex * WIDTH; int v = isMouseOver ? 0 : HEIGHT; - Textures.BOOKMARKS_LEFT.draw(matrices, getGuiX(), getGuiY(), u, v, WIDTH, HEIGHT); + Textures.BOOKMARKS_LEFT.draw(drawContext, getGuiX(), getGuiY(), u, v, WIDTH, HEIGHT); // Render the icon: - iconTexture.draw(matrices, getGuiX() - (isMouseOver ? 3 : 2), getGuiY()-3, 24,24); + iconTexture.draw(drawContext, getGuiX() - (isMouseOver ? 3 : 2), getGuiY()-3, 24,24); if (isMouseOver && !getTitle().getString().isEmpty()) { drawTooltip(Collections.singletonList(getTitle()), MinecraftClient.getInstance().textRenderer); diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiMarkerFinalizer.java b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiMarkerFinalizer.java index e78ce68c3..743c79e3c 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiMarkerFinalizer.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiMarkerFinalizer.java @@ -4,20 +4,18 @@ import hunternif.mc.impl.atlas.client.gui.core.GuiComponent; import hunternif.mc.impl.atlas.client.gui.core.GuiScrollingContainer; import hunternif.mc.impl.atlas.client.gui.core.ToggleGroup; - import hunternif.mc.impl.atlas.registry.MarkerType; +import hunternif.mc.impl.atlas.registry.MarkerType; import hunternif.mc.impl.atlas.util.Log; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; -import net.minecraft.text.LiteralText; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.world.World; import java.util.ArrayList; @@ -79,8 +77,8 @@ void removeAllMarkerListeners() { public void init() { super.init(); - addDrawableChild(btnDone = new ButtonWidget(this.width / 2 - BUTTON_WIDTH - BUTTON_SPACING / 2, this.height / 2 + 40, BUTTON_WIDTH, 20, new TranslatableText("gui.done"), (button) -> { - AtlasClientAPI.getMarkerAPI().putMarker(world, true, atlasID, MarkerType.REGISTRY.getId(selectedType), new LiteralText(textField.getText()), markerX, markerZ); + addDrawableChild(btnDone = ButtonWidget.builder(Text.translatable("gui.done"), (button) -> { + AtlasClientAPI.getMarkerAPI().putMarker(world, true, atlasID, MarkerType.REGISTRY.getId(selectedType), Text.literal(textField.getText()), markerX, markerZ); Log.info("Put marker in Atlas #%d \"%s\" at (%d, %d)", atlasID, textField.getText(), markerX, markerZ); ClientPlayerEntity player = MinecraftClient.getInstance().player; @@ -88,11 +86,11 @@ public void init() { SoundEvents.ENTITY_VILLAGER_WORK_CARTOGRAPHER, SoundCategory.AMBIENT, 1F, 1F); closeChild(); - })); - addDrawableChild(btnCancel = new ButtonWidget(this.width / 2 + BUTTON_SPACING / 2, this.height / 2 + 40, BUTTON_WIDTH, 20, new TranslatableText("gui.cancel"), (button) -> { + }).dimensions(this.width / 2 - BUTTON_WIDTH - BUTTON_SPACING / 2, this.height / 2 + 40, BUTTON_WIDTH, 20).build()); + addDrawableChild(btnCancel = ButtonWidget.builder(Text.literal("gui.cancel"), (button) -> { closeChild(); - })); - textField = new TextFieldWidget(MinecraftClient.getInstance().textRenderer, (this.width - 200) / 2, this.height / 2 - 81, 200, 20, new TranslatableText("gui.antiqueatlas.marker.label")); + }).dimensions(this.width / 2 + BUTTON_SPACING / 2, this.height / 2 + 40, BUTTON_WIDTH, 20).build()); + textField = new TextFieldWidget(MinecraftClient.getInstance().textRenderer, (this.width - 200) / 2, this.height / 2 - 81, 200, 20, Text.literal("gui.antiqueatlas.marker.label")); textField.setEditable(true); textField.setText(""); @@ -133,7 +131,7 @@ public void init() { } public void setMarkerName(Text name) { - textField.setText(name.asString()); + textField.setText(name.getString()); } @Override @@ -160,18 +158,18 @@ public boolean charTyped(char aa, int bb) { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTick) { - this.renderBackground(matrices); - drawCentered(matrices, new TranslatableText("gui.antiqueatlas.marker.label"), this.height / 2 - 97, 0xffffff, true); - textField.render(matrices, mouseX, mouseY, partialTick); - drawCentered(matrices, new TranslatableText("gui.antiqueatlas.marker.type"), this.height / 2 - 44, 0xffffff, true); + public void render(DrawContext drawContext, int mouseX, int mouseY, float partialTick) { + this.renderBackground(drawContext); + drawCentered(drawContext, Text.translatable("gui.antiqueatlas.marker.label"), this.height / 2 - 97, 0xffffff, true); + textField.render(drawContext, mouseX, mouseY, partialTick); + drawCentered(drawContext, Text.translatable("gui.antiqueatlas.marker.type"), this.height / 2 - 44, 0xffffff, true); // Darker background for marker type selector - fillGradient(matrices, scroller.getGuiX() - TYPE_BG_FRAME, scroller.getGuiY() - TYPE_BG_FRAME, + drawContext.fillGradient(scroller.getGuiX() - TYPE_BG_FRAME, scroller.getGuiY() - TYPE_BG_FRAME, scroller.getGuiX() + scroller.getWidth() + TYPE_BG_FRAME, scroller.getGuiY() + scroller.getHeight() + TYPE_BG_FRAME, 0x88101010, 0x99101010); - super.render(matrices, mouseX, mouseY, partialTick); + super.render(drawContext, mouseX, mouseY, partialTick); } interface IMarkerTypeSelectListener { diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiMarkerInList.java b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiMarkerInList.java index 96aa17470..7cbff349f 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiMarkerInList.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiMarkerInList.java @@ -4,7 +4,7 @@ import hunternif.mc.impl.atlas.client.gui.core.GuiToggleButton; import hunternif.mc.impl.atlas.client.texture.ITexture; import hunternif.mc.impl.atlas.registry.MarkerType; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; public class GuiMarkerInList extends GuiToggleButton { @@ -22,15 +22,15 @@ public MarkerType getMarkerType() { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTick) { + public void render(DrawContext drawContext, int mouseX, int mouseY, float partialTick) { ITexture frame_texture = isSelected() ? Textures.MARKER_FRAME_ON : Textures.MARKER_FRAME_OFF; - frame_texture.draw(matrices, getGuiX() + 1, getGuiY() + 1); + frame_texture.draw(drawContext, getGuiX() + 1, getGuiY() + 1); ITexture texture = markerType.getTexture(); if (texture != null) { - texture.draw(matrices, getGuiX() + 1, getGuiY() + 1); + texture.draw(drawContext, getGuiX() + 1, getGuiY() + 1); } - super.render(matrices, mouseX, mouseY, partialTick); + super.render(drawContext, mouseX, mouseY, partialTick); } } diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiPositionButton.java b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiPositionButton.java index 9d0da7571..1c2855411 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiPositionButton.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiPositionButton.java @@ -4,8 +4,8 @@ import hunternif.mc.impl.atlas.client.Textures; import hunternif.mc.impl.atlas.client.gui.core.GuiComponentButton; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.TranslatableText; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.text.Text; import org.lwjgl.opengl.GL11; import java.util.Collections; @@ -19,7 +19,7 @@ public GuiPositionButton() { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTick) { + public void render(DrawContext matrices, int mouseX, int mouseY, float partialTick) { if (isEnabled()) { RenderSystem.enableBlend(); RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); @@ -36,7 +36,7 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTi RenderSystem.disableBlend(); if (isMouseOver) { - drawTooltip(Collections.singletonList(new TranslatableText("gui.antiqueatlas.followPlayer")), MinecraftClient.getInstance().textRenderer); + drawTooltip(Collections.singletonList(Text.translatable("gui.antiqueatlas.followPlayer")), MinecraftClient.getInstance().textRenderer); } } } diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiScaleBar.java b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiScaleBar.java index 92d495255..77e5101a4 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiScaleBar.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/GuiScaleBar.java @@ -6,8 +6,8 @@ import hunternif.mc.impl.atlas.client.gui.core.GuiComponent; import hunternif.mc.impl.atlas.client.texture.ITexture; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.TranslatableText; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.text.Text; import java.util.Collections; import java.util.Map; @@ -57,14 +57,14 @@ private ITexture getTexture() { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTick) { + public void render(DrawContext matrices, int mouseX, int mouseY, float partialTick) { ITexture texture = getTexture(); if (texture == null) return; texture.draw(matrices, getGuiX(), getGuiY()); if (isMouseOver) { - drawTooltip(Collections.singletonList(new TranslatableText("gui.antiqueatlas.scalebar")), MinecraftClient.getInstance().textRenderer); + drawTooltip(Collections.singletonList(Text.translatable("gui.antiqueatlas.scalebar")), MinecraftClient.getInstance().textRenderer); } } } diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/ProgressBarOverlay.java b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/ProgressBarOverlay.java index b97d5d916..bc9f93f14 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/ProgressBarOverlay.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/ProgressBarOverlay.java @@ -1,16 +1,14 @@ package hunternif.mc.impl.atlas.client.gui; -import com.mojang.blaze3d.systems.RenderSystem; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.Tessellator; import net.minecraft.client.render.VertexFormat; import net.minecraft.client.render.VertexFormats; -import net.minecraft.client.util.math.MatrixStack; -import org.lwjgl.opengl.GL11; class ProgressBarOverlay { /** @@ -36,20 +34,20 @@ public ProgressBarOverlay(int barWidth, int barHeight) { * Render progress bar on the screen. */ @Environment(EnvType.CLIENT) - public void draw(MatrixStack matrices, int x, int y) { + public void draw(DrawContext drawContext, int x, int y) { ExportUpdateListener l = ExportUpdateListener.INSTANCE; int headerWidth = this.textRenderer.getWidth(l.header); - this.textRenderer.draw(matrices, l.header, x + (barWidth - headerWidth) / 2F, y - 14, 0xffffff); + drawContext.drawText(this.textRenderer, l.header, x + (barWidth - headerWidth) / 2, y - 14, 0xffffff, false); int statusWidth = this.textRenderer.getWidth(l.status); - this.textRenderer.draw(matrices, l.status, x + (barWidth - statusWidth) / 2F, y, 0xffffff); + drawContext.drawText(this.textRenderer, l.header, x + (barWidth - statusWidth) / 2, y, 0xffffff, false); y += 14; double p = l.currentProgress / l.maxProgress; if (l.maxProgress < 0) p = 0; - RenderSystem.disableTexture(); + //RenderSystem.disableTexture(); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder vb = tessellator.getBuffer(); @@ -67,7 +65,7 @@ public void draw(MatrixStack matrices, int x, int y) { tessellator.draw(); - RenderSystem.enableTexture(); + //RenderSystem.enableTexture(); } } diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/AGuiScrollbar.java b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/AGuiScrollbar.java index 0cfe40e1f..f6d73b555 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/AGuiScrollbar.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/AGuiScrollbar.java @@ -2,8 +2,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import hunternif.mc.impl.atlas.client.texture.ITexture; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Identifier; +import net.minecraft.client.gui.DrawContext; import org.lwjgl.opengl.GL11; @@ -181,7 +180,7 @@ public boolean mouseReleased(double mouseX, double mouseY, int button) { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTick) { + public void render(DrawContext drawContext, int mouseX, int mouseY, float partialTick) { // Don't draw the anchor if there's nothing to scroll: if (!visible) { isDragged = false; @@ -193,12 +192,12 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTi / (float) (getScrollbarLength() - anchorSize)); } - RenderSystem.enableTexture(); + //RenderSystem.enableTexture(); RenderSystem.enableBlend(); RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); RenderSystem.setShaderColor(1, 1, 1, 1); - drawAnchor(matrices); + drawAnchor(drawContext); RenderSystem.disableBlend(); } @@ -232,7 +231,7 @@ private void updateAnchorPos() { protected abstract int getMousePos(int mouseX, int mouseY); // Modifying axis-related data - protected abstract void drawAnchor(MatrixStack matrices); + protected abstract void drawAnchor(DrawContext matrices); protected abstract void updateContentPos(); diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiBlinkingImage.java b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiBlinkingImage.java index 6823cbd90..1ace06260 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiBlinkingImage.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiBlinkingImage.java @@ -2,6 +2,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import hunternif.mc.impl.atlas.client.texture.ITexture; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.util.math.MatrixStack; import org.lwjgl.opengl.GL11; @@ -51,7 +52,7 @@ public void setInvisibleAlpha(float invisibleAlpha) { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTick) { + public void render(DrawContext drawContext, int mouseX, int mouseY, float partialTick) { long currentTime = System.currentTimeMillis(); if (lastTickTime + blinkTime < currentTime) { lastTickTime = currentTime; @@ -61,13 +62,13 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTi RenderSystem.enableBlend(); RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - drawImage(matrices); + drawImage(drawContext); RenderSystem.disableBlend(); RenderSystem.setShaderColor(1,1,1,1); } - private void drawImage(MatrixStack matrices) { - texture.draw(matrices, getGuiX(), getGuiY(), getWidth(), getHeight()); + private void drawImage(DrawContext drawContext) { + texture.draw(drawContext, getGuiX(), getGuiY(), getWidth(), getHeight()); } } diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiComponent.java b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiComponent.java index 775919e05..f1368a901 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiComponent.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiComponent.java @@ -4,9 +4,9 @@ import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.LiteralText; import net.minecraft.text.Text; import org.lwjgl.opengl.GL11; @@ -75,7 +75,7 @@ interface UiCall { // TODO public GuiComponent() { - super(new LiteralText("component")); + super(Text.literal("component")); } /** @@ -411,16 +411,16 @@ public boolean keyReleased(int a, int b, int c) { * Render this GUI and its children. */ @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTick) { - super.render(matrices, mouseX, mouseY, partialTick); + public void render(DrawContext context, int mouseX, int mouseY, float delta) { + super.render(context, mouseX, mouseY, delta); for (GuiComponent child : children) { if (!child.isClipped) { - child.render(matrices, mouseX, mouseY, partialTick); + child.render(context, mouseX, mouseY, delta); } } // Draw any hovering text requested by child components: if (hoveringTextInfo.shouldDraw) { - drawHoveringText2(matrices, hoveringTextInfo.lines, hoveringTextInfo.x, hoveringTextInfo.y, hoveringTextInfo.font); + drawHoveringText2(context, hoveringTextInfo.lines, hoveringTextInfo.x, hoveringTextInfo.y, hoveringTextInfo.font); hoveringTextInfo.shouldDraw = false; } } @@ -554,14 +554,11 @@ protected boolean isMouseInRadius(int x, int y, int radius) { * component's dimensions (i.e. if it won't fit in when drawn to the left * of the cursor, it will be drawn to the right instead). */ - private void drawHoveringText2(MatrixStack matrices, List lines, double x, double y, TextRenderer font) { + private void drawHoveringText2(DrawContext drawContext, List lines, double x, double y, TextRenderer font) { boolean stencilEnabled = GL11.glIsEnabled(GL11.GL_STENCIL_TEST); if (stencilEnabled) GL11.glDisable(GL11.GL_STENCIL_TEST); - TextRenderer old = this.textRenderer; - this.textRenderer = font; - renderTooltip(matrices, lines, (int) x, (int) y); - this.textRenderer = old; + drawContext.drawTooltip(font, lines, (int) x, (int) y); if (stencilEnabled) GL11.glEnable(GL11.GL_STENCIL_TEST); } @@ -638,12 +635,12 @@ protected void onChildClosed(GuiComponent child) { /** * Draw a text string centered horizontally, using this GUI's font. */ - protected void drawCentered(MatrixStack matrices, Text text, int y, int color, boolean dropShadow) { + protected void drawCentered(DrawContext drawContext, Text text, int y, int color, boolean dropShadow) { int length = this.textRenderer.getWidth(text); if (dropShadow) { - this.textRenderer.drawWithShadow(matrices, text, (float) (this.width - length) / 2, y, color); + drawContext.drawTextWithShadow(this.textRenderer, text, (this.width - length) / 2, y, color); } else { - this.textRenderer.draw(matrices, text, (float) (this.width - length) / 2, y, color); + drawContext.drawText(this.textRenderer, text, (this.width - length) / 2, y, color, false); } } diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiComponentButton.java b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiComponentButton.java index 6e2691446..c55dcdda6 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiComponentButton.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiComponentButton.java @@ -15,7 +15,7 @@ public class GuiComponentButton extends GuiComponent { private final List listeners = new ArrayList<>(); private boolean enabled = true; - private SoundEvent clickSound = SoundEvents.UI_BUTTON_CLICK; + private SoundEvent clickSound = SoundEvents.UI_BUTTON_CLICK.value(); public void setEnabled(boolean value) { enabled = value; diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiCursor.java b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiCursor.java index a3a0965d2..e7525095a 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiCursor.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiCursor.java @@ -1,7 +1,7 @@ package hunternif.mc.impl.atlas.client.gui.core; import hunternif.mc.impl.atlas.client.texture.ITexture; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; /** @@ -44,7 +44,7 @@ public int getHeight() { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTick) { - texture.draw(matrices, mouseX - pointX, mouseY - pointY, textureWidth, textureHeight); + public void render(DrawContext drawContext, int mouseX, int mouseY, float partialTick) { + texture.draw(drawContext, mouseX - pointX, mouseY - pointY, textureWidth, textureHeight); } } diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiHScrollbar.java b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiHScrollbar.java index 47db2fc18..324980398 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiHScrollbar.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiHScrollbar.java @@ -1,6 +1,6 @@ package hunternif.mc.impl.atlas.client.gui.core; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; public class GuiHScrollbar extends AGuiScrollbar { @@ -9,15 +9,15 @@ public GuiHScrollbar(GuiViewport viewport) { } @Override - protected void drawAnchor(MatrixStack matrices) { + protected void drawAnchor(DrawContext drawContext) { // Draw left cap: - texture.draw(matrices, getGuiX() + anchorPos, getGuiY(), capLength, textureHeight, 0, 0, capLength, textureHeight); + texture.draw(drawContext, getGuiX() + anchorPos, getGuiY(), capLength, textureHeight, 0, 0, capLength, textureHeight); // Draw body: - texture.draw(matrices, getGuiX() + anchorPos + capLength, getGuiY(), anchorSize, textureHeight, capLength, 0, textureBodyLength, textureHeight); + texture.draw(drawContext, getGuiX() + anchorPos + capLength, getGuiY(), anchorSize, textureHeight, capLength, 0, textureBodyLength, textureHeight); // Draw right cap: - texture.draw(matrices, getGuiX() + anchorPos + capLength + anchorSize, getGuiY(), textureWidth - capLength, 0, capLength, textureHeight); + texture.draw(drawContext, getGuiX() + anchorPos + capLength + anchorSize, getGuiY(), textureWidth - capLength, 0, capLength, textureHeight); } @Override diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiVScrollbar.java b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiVScrollbar.java index 2b64ff766..00f20b2b9 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiVScrollbar.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiVScrollbar.java @@ -1,6 +1,6 @@ package hunternif.mc.impl.atlas.client.gui.core; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; public class GuiVScrollbar extends AGuiScrollbar { @@ -9,15 +9,15 @@ public GuiVScrollbar(GuiViewport viewport) { } @Override - protected void drawAnchor(MatrixStack matrices) { + protected void drawAnchor(DrawContext drawContext) { // Draw top cap: - texture.draw(matrices, getGuiX(), getGuiY() + anchorPos, textureWidth, capLength, 0, 0, textureWidth, capLength); + texture.draw(drawContext, getGuiX(), getGuiY() + anchorPos, textureWidth, capLength, 0, 0, textureWidth, capLength); // Draw body: - texture.draw(matrices, getGuiX(), getGuiY() + anchorPos + capLength, textureWidth, anchorSize, 0, capLength, textureWidth, textureBodyLength); + texture.draw(drawContext, getGuiX(), getGuiY() + anchorPos + capLength, textureWidth, anchorSize, 0, capLength, textureWidth, textureBodyLength); // Draw bottom cap: - texture.draw(matrices, getGuiX(),getGuiY() + anchorPos + capLength + anchorSize, 0, textureHeight - capLength, textureWidth, capLength); + texture.draw(drawContext, getGuiX(),getGuiY() + anchorPos + capLength + anchorSize, 0, textureHeight - capLength, textureWidth, capLength); } @Override diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiViewport.java b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiViewport.java index d38cd5699..75a8cca33 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiViewport.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/gui/core/GuiViewport.java @@ -2,7 +2,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; /** * The children of this component are rendered and process input only inside @@ -52,7 +52,7 @@ public void init() { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float par3) { + public void render(DrawContext matrices, int mouseX, int mouseY, float par3) { RenderSystem.enableScissor((int) (getGuiX() * screenScale), (int) (MinecraftClient.getInstance().getWindow().getFramebufferHeight() - (getGuiY() + properHeight) * screenScale), (int) (properWidth * screenScale), (int) (properHeight * screenScale)); diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/texture/ATexture.java b/common/src/main/java/hunternif/mc/impl/atlas/client/texture/ATexture.java index dbb04e4c8..b7f127fc8 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/texture/ATexture.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/texture/ATexture.java @@ -3,14 +3,14 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; -import net.minecraft.util.math.Matrix4f; -import net.minecraft.util.math.Vec3f; +import net.minecraft.util.math.RotationAxis; +import org.joml.Matrix4f; /** * An abstract base class, which implements the ITexture interface using @@ -41,49 +41,51 @@ public void bind() { RenderSystem.setShaderTexture(0, texture); } - public void draw(MatrixStack matrices, int x, int y) { + public void draw(DrawContext matrices, int x, int y) { draw(matrices, x, y, width(), height()); } - public void draw(MatrixStack matrices, int x, int y, int width, int height) { - draw(matrices, x, y, width, height, 0, 0, this.width(), this.height()); + public void draw(DrawContext drawContext, int x, int y, int width, int height) { + draw(drawContext, x, y, width, height, 0, 0, this.width(), this.height()); } - public void draw(MatrixStack matrices, int x, int y, int u, int v, int regionWidth, int regionHeight) { - draw(matrices, x, y, regionWidth, regionHeight, u, v, regionWidth, regionHeight); + public void draw(DrawContext drawContext, int x, int y, int u, int v, int regionWidth, int regionHeight) { + draw(drawContext, x, y, regionWidth, regionHeight, u, v, regionWidth, regionHeight); } - public void draw(MatrixStack matrices, int x, int y, int width, int height, int u, int v, int regionWidth, int regionHeight) { + public void draw(DrawContext drawContext, int x, int y, int width, int height, int u, int v, int regionWidth, int regionHeight) { if (autobind) { bind(); } - DrawableHelper.drawTexture(matrices, x, y, width, height, u, v, regionWidth, regionHeight, this.width(), this.height()); + drawContext.drawTexture(this.getTexture(), x, y, width, height, u, v, regionWidth, regionHeight, this.width(), this.height()); } - public void drawCenteredWithRotation(MatrixStack matrices, int x, int y, int width, int height, float rotation) { + public void drawCenteredWithRotation(DrawContext drawContext, int x, int y, int width, int height, float rotation) { + MatrixStack matrices = drawContext.getMatrices(); matrices.push(); matrices.translate(x, y, 0); - matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(180 + rotation)); + matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(180 + rotation)); matrices.translate(-width / 2f, -height / 2f, 0f); - draw(matrices, 0,0, width, height); + draw(drawContext, 0,0, width, height); matrices.pop(); } - public void drawWithLight(VertexConsumerProvider consumer, MatrixStack matrices, int x, int y, int width, int height, int light) { - drawWithLight(consumer, matrices, x, y, width, height, 0, 0, this.width(), this.height(), light); + public void drawWithLight(VertexConsumerProvider consumer, MatrixStack matrixStack, int x, int y, int width, int height, int light) { + drawWithLight(consumer, matrixStack, x, y, width, height, 0, 0, this.width(), this.height(), light); } - public void drawWithLight(VertexConsumerProvider consumer, MatrixStack matrices, int x, int y, int width, int height, int u, int v, int regionWidth, int regionHeight, int light) { + public void drawWithLight(VertexConsumerProvider consumer, MatrixStack matrixStack, int x, int y, int width, int height, int u, int v, int regionWidth, int regionHeight, int light) { if (autobind) { bind(); } - drawTexturedQuadWithLight(consumer, matrices.peek().getPositionMatrix(), x, x + width, y, y + height, (u + 0.0F) / (float) this.width(), (u + (float) regionWidth) / (float) this.width(), (v + 0.0F) / (float) this.height(), (v + (float) regionHeight) / (float) this.height(), light); + drawTexturedQuadWithLight(consumer, matrixStack, x, x + width, y, y + height, (u + 0.0F) / (float) this.width(), (u + (float) regionWidth) / (float) this.width(), (v + 0.0F) / (float) this.height(), (v + (float) regionHeight) / (float) this.height(), light); } - private void drawTexturedQuadWithLight(VertexConsumerProvider vertexConsumer, Matrix4f matrices, int x0, int x1, int y0, int y1, float u0, float u1, float v0, float v1, int light) { + private void drawTexturedQuadWithLight(VertexConsumerProvider vertexConsumer, MatrixStack matrixStack, int x0, int x1, int y0, int y1, float u0, float u1, float v0, float v1, int light) { VertexConsumer consumer = vertexConsumer.getBuffer(this.LAYER); + Matrix4f matrices = matrixStack.peek().getPositionMatrix(); consumer.vertex(matrices, (float) x0, (float) y1, 0f).color(255, 255, 255, 255).texture(u0, v1).light(light).next(); consumer.vertex(matrices, (float) x1, (float) y1, 0f).color(255, 255, 255, 255).texture(u1, v1).light(light).next(); consumer.vertex(matrices, (float) x1, (float) y0, 0f).color(255, 255, 255, 255).texture(u1, v0).light(light).next(); diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/texture/ITexture.java b/common/src/main/java/hunternif/mc/impl/atlas/client/texture/ITexture.java index 615e11420..f849cf6f0 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/texture/ITexture.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/texture/ITexture.java @@ -2,6 +2,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; @@ -26,15 +27,15 @@ public interface ITexture { void bind(); - void draw(MatrixStack matrices, int x, int y); + void draw(DrawContext matrices, int x, int y); - void draw(MatrixStack matrices, int x, int y, int width, int height); + void draw(DrawContext matrices, int x, int y, int width, int height); - void drawCenteredWithRotation(MatrixStack matrices, int x, int y, int width, int height, float rotation); + void drawCenteredWithRotation(DrawContext matrices, int x, int y, int width, int height, float rotation); - void draw(MatrixStack matrices, int x, int y, int width, int height, int u, int v, int regionWidth, int regionHeight); + void draw(DrawContext matrices, int x, int y, int width, int height, int u, int v, int regionWidth, int regionHeight); - void draw(MatrixStack matrices, int x, int y, int u, int v, int regionWidth, int regionHeight); + void draw(DrawContext matrices, int x, int y, int u, int v, int regionWidth, int regionHeight); void drawWithLight(VertexConsumerProvider consumer, MatrixStack matrices, int x, int y, int width, int height, int light); diff --git a/common/src/main/java/hunternif/mc/impl/atlas/client/texture/TileTexture.java b/common/src/main/java/hunternif/mc/impl/atlas/client/texture/TileTexture.java index 3ab11ebe7..1c3090ac2 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/client/texture/TileTexture.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/client/texture/TileTexture.java @@ -3,7 +3,7 @@ import hunternif.mc.impl.atlas.client.SubTile; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import net.minecraft.util.Identifier; /** @@ -28,7 +28,7 @@ public int height() { return 48; } - public void drawSubTile(MatrixStack matrices, SubTile subtile, int tileHalfSize) { - draw(matrices, subtile.x * tileHalfSize, subtile.y * tileHalfSize, tileHalfSize, tileHalfSize, subtile.getTextureU() * 8, subtile.getTextureV() * 8, 8, 8); + public void drawSubTile(DrawContext drawContext, SubTile subtile, int tileHalfSize) { + draw(drawContext, subtile.x * tileHalfSize, subtile.y * tileHalfSize, tileHalfSize, tileHalfSize, subtile.getTextureU() * 8, subtile.getTextureV() * 8, 8, 8); } } diff --git a/common/src/main/java/hunternif/mc/impl/atlas/core/AtlasData.java b/common/src/main/java/hunternif/mc/impl/atlas/core/AtlasData.java index 1fef75818..237cc5ee9 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/core/AtlasData.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/core/AtlasData.java @@ -6,16 +6,15 @@ import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; import net.minecraft.nbt.NbtList; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.Identifier; import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.PersistentState; import net.minecraft.world.World; import java.util.*; -import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; /** @@ -66,7 +65,7 @@ public void updateFromNbt(NbtCompound compound) { for (int d = 0; d < worldMapList.size(); d++) { NbtCompound worldTag = worldMapList.getCompound(d); RegistryKey worldID; - worldID = RegistryKey.of(Registry.WORLD_KEY, new Identifier(worldTag.getString(TAG_WORLD_ID))); + worldID = RegistryKey.of(RegistryKeys.WORLD, new Identifier(worldTag.getString(TAG_WORLD_ID))); NbtList dimensionTag = (NbtList) worldTag.get(TAG_VISITED_CHUNKS); WorldData dimData = this.getWorldData(worldID); dimData.readFromNBT(dimensionTag); @@ -85,7 +84,7 @@ public NbtCompound writeNbt(NbtCompound compound) { public NbtCompound writeToNBT(NbtCompound compound, boolean includeTileData) { NbtList dimensionMapList = new NbtList(); compound.putInt(TAG_VERSION, VERSION); - for (Entry, WorldData> dimensionEntry : worldMap.entrySet()) { + for (Map.Entry, WorldData> dimensionEntry : worldMap.entrySet()) { NbtCompound dimTag = new NbtCompound(); dimTag.putString(TAG_WORLD_ID, dimensionEntry.getKey().getValue().toString()); WorldData dimData = dimensionEntry.getValue(); diff --git a/common/src/main/java/hunternif/mc/impl/atlas/core/GlobalTileDataHandler.java b/common/src/main/java/hunternif/mc/impl/atlas/core/GlobalTileDataHandler.java index 753d75015..329a99a11 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/core/GlobalTileDataHandler.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/core/GlobalTileDataHandler.java @@ -1,9 +1,8 @@ package hunternif.mc.impl.atlas.core; -import net.minecraft.server.MinecraftServer; +import net.minecraft.registry.RegistryKey; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.World; import java.util.Map; diff --git a/common/src/main/java/hunternif/mc/impl/atlas/core/PlayerEventHandler.java b/common/src/main/java/hunternif/mc/impl/atlas/core/PlayerEventHandler.java index 7fc0f3663..b32ad95cf 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/core/PlayerEventHandler.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/core/PlayerEventHandler.java @@ -8,7 +8,7 @@ public class PlayerEventHandler { public static void onPlayerLogin(ServerPlayerEntity player) { - World world = player.world; + World world = player.getWorld(); int atlasID = player.getUuid().hashCode(); AtlasData data = AntiqueAtlasMod.tileData.getData(atlasID, world); @@ -28,7 +28,7 @@ public static void onPlayerTick(PlayerEntity player) { if (!AntiqueAtlasMod.CONFIG.itemNeeded) { // TODO Can we move world scanning to the server in this case as well? AtlasData data = AntiqueAtlasMod.tileData.getData( - player.getUuid().hashCode(), player.world); + player.getUuid().hashCode(), player.getWorld()); AntiqueAtlasMod.worldScanner.updateAtlasAroundPlayer(data, player); } diff --git a/common/src/main/java/hunternif/mc/impl/atlas/core/TileDataStorage.java b/common/src/main/java/hunternif/mc/impl/atlas/core/TileDataStorage.java index e02802957..e567d8e15 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/core/TileDataStorage.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/core/TileDataStorage.java @@ -7,10 +7,10 @@ import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; import net.minecraft.nbt.NbtList; +import net.minecraft.registry.RegistryKey; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.Identifier; import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.PersistentState; import net.minecraft.world.World; diff --git a/common/src/main/java/hunternif/mc/impl/atlas/core/WorldData.java b/common/src/main/java/hunternif/mc/impl/atlas/core/WorldData.java index 69db7f6b3..cbbf86c22 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/core/WorldData.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/core/WorldData.java @@ -9,10 +9,10 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtList; +import net.minecraft.registry.RegistryKey; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.Identifier; import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.World; import java.util.Map; diff --git a/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/TileDetectorBase.java b/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/TileDetectorBase.java index 13e52ae2c..c41d27874 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/TileDetectorBase.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/TileDetectorBase.java @@ -4,10 +4,11 @@ import hunternif.mc.impl.atlas.core.TileIdMap; import net.minecraft.block.Block; import net.minecraft.block.Blocks; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.registry.tag.BiomeTags; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.registry.BuiltinRegistries; -import net.minecraft.util.registry.Registry; import net.minecraft.world.Heightmap; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; @@ -52,25 +53,26 @@ public class TileDetectorBase implements ITileDetector { private static final Set swampBiomes = new HashSet<>(); - /** + /* + We check the tags now! + * Scan all registered biomes to mark biomes of certain types that will be * given higher priority when identifying mean biome ID for a chunk. * (Currently WATER, BEACH and SWAMP) - */ - public static void scanBiomeTypes() { - for (Biome biome : BuiltinRegistries.BIOME) { + public static void scanBiomeTypes(World world) { + for (Biome biome : Registries.BIOME_SOURCE) { switch (biome.getCategory()) { case BEACH -> beachBiomes.add(BuiltinRegistries.BIOME.getId(biome)); case RIVER, OCEAN -> waterBiomes.add(BuiltinRegistries.BIOME.getId(biome)); case SWAMP -> swampBiomes.add(BuiltinRegistries.BIOME.getId(biome)); } } - } + }*/ - int priorityForBiome(Identifier biome) { - if (waterBiomes.contains(biome)) { + int priorityForBiome(RegistryEntry biomeRegistryKey) { + if (biomeRegistryKey.isIn(BiomeTags.IS_RIVER) || biomeRegistryKey.isIn(BiomeTags.IS_OCEAN)) { return 4; - } else if (beachBiomes.contains(biome)) { + } else if (biomeRegistryKey.isIn(BiomeTags.IS_BEACH)) { return 3; } else { return 1; @@ -112,7 +114,7 @@ protected static TileHeightType getHeightTypeFromY(int y, int sealevel) { protected static Identifier getBiomeIdentifier(World world, Biome biome) { - return world.getRegistryManager().get(Registry.BIOME_KEY).getId(biome); + return world.getRegistryManager().get(RegistryKeys.BIOME).getId(biome); } protected static void updateOccurrencesMap(Map map, Identifier biome, int weight) { @@ -140,12 +142,16 @@ public int getScanRadius() { */ @Override public Identifier getBiomeID(World world, Chunk chunk) { - Map biomeOccurrences = new HashMap<>(BuiltinRegistries.BIOME.getIds().size()); + var BIOME_REGISTRY = world.getRegistryManager().get(RegistryKeys.BIOME); + Map biomeOccurrences = new HashMap<>(BIOME_REGISTRY.getIds().size()); for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { + + RegistryEntry registryEntryBiome = chunk.getBiomeForNoiseGen(x, world.getSeaLevel(), z); // biomes seems to be changing with height as well. Let's scan at sea level. - Biome biome = chunk.getBiomeForNoiseGen(x, world.getSeaLevel(), z).value(); + Biome biome = registryEntryBiome.value(); + // get top block int y = chunk.getHeightmap(Heightmap.Type.MOTION_BLOCKING).get(x, z); @@ -183,7 +189,7 @@ public Identifier getBiomeID(World world, Chunk chunk) { } // updateOccurrencesMap(biomeOccurrences, world, biome, getHeightType(weirdness), priorityForBiome(getBiomeIdentifier(world, biome))); - updateOccurrencesMap(biomeOccurrences, world, biome, getHeightTypeFromY(y, world.getSeaLevel()), priorityForBiome(getBiomeIdentifier(world, biome))); + updateOccurrencesMap(biomeOccurrences, world, biome, getHeightTypeFromY(y, world.getSeaLevel()), priorityForBiome(registryEntryBiome)); } } diff --git a/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/TileDetectorEnd.java b/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/TileDetectorEnd.java index c3fd25731..6978faadc 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/TileDetectorEnd.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/TileDetectorEnd.java @@ -2,9 +2,9 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.registry.RegistryKeys; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.world.Heightmap; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; @@ -25,7 +25,8 @@ public class TileDetectorEnd extends TileDetectorBase implements ITileDetector { @Override public Identifier getBiomeID(World world, Chunk chunk) { - Map biomeOccurrences = new HashMap<>(BuiltinRegistries.BIOME.getIds().size()); + var BIOME_REGISTRY = world.getRegistryManager().get(RegistryKeys.BIOME); + Map biomeOccurrences = new HashMap<>(BIOME_REGISTRY.getIds().size()); for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { diff --git a/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/TileDetectorNether.java b/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/TileDetectorNether.java index bd4880e27..9f1b7d6a8 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/TileDetectorNether.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/TileDetectorNether.java @@ -4,9 +4,11 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.registry.tag.BiomeTags; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.Chunk; @@ -39,12 +41,14 @@ public class TileDetectorNether extends TileDetectorBase implements ITileDetecto @Override public Identifier getBiomeID(World world, Chunk chunk) { - Map biomeOccurrences = new HashMap<>(BuiltinRegistries.BIOME.getIds().size()); + var BIOME_REGISTRY = world.getRegistryManager().get(RegistryKeys.BIOME); + Map biomeOccurrences = new HashMap<>(BIOME_REGISTRY.getIds().size()); for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { - Biome biome = chunk.getBiomeForNoiseGen(x, lavaSeaLevel, z).value(); - if (biome.getCategory() == Biome.Category.NETHER) { + RegistryEntry registryEntryBiome = chunk.getBiomeForNoiseGen(x, lavaSeaLevel, z); + Biome biome = registryEntryBiome.value(); + if (registryEntryBiome.isIn(BiomeTags.IS_NETHER)) { // The Nether! Block seaLevelBlock = chunk.getBlockState(new BlockPos(x, lavaSeaLevel, z)).getBlock(); if (seaLevelBlock == Blocks.LAVA) { @@ -60,7 +64,7 @@ public Identifier getBiomeID(World world, Chunk chunk) { } } else { // In case there are custom biomes "modded in": - updateOccurrencesMap(biomeOccurrences, getBiomeIdentifier(world,biome), priorityForBiome(getBiomeIdentifier(world,biome))); + updateOccurrencesMap(biomeOccurrences, getBiomeIdentifier(world,biome), priorityForBiome(registryEntryBiome)); } } } diff --git a/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/WorldScanner.java b/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/WorldScanner.java index 7ec781047..2fc549459 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/WorldScanner.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/WorldScanner.java @@ -6,8 +6,8 @@ import hunternif.mc.impl.atlas.core.ITileStorage; import hunternif.mc.impl.atlas.core.TileInfo; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.registry.RegistryKey; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.ChunkStatus; diff --git a/common/src/main/java/hunternif/mc/impl/atlas/core/watcher/DeathWatcher.java b/common/src/main/java/hunternif/mc/impl/atlas/core/watcher/DeathWatcher.java index 731bd3796..beb215efd 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/core/watcher/DeathWatcher.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/core/watcher/DeathWatcher.java @@ -3,7 +3,7 @@ import hunternif.mc.api.AtlasAPI; import hunternif.mc.impl.atlas.AntiqueAtlasMod; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.text.TranslatableText; +import net.minecraft.text.Text; import net.minecraft.util.Identifier; /** @@ -16,7 +16,7 @@ public static void onPlayerDeath(PlayerEntity player) { if (AntiqueAtlasMod.CONFIG.autoDeathMarker) { for (int atlasID : AtlasAPI.getPlayerAtlases(player)) { AtlasAPI.getMarkerAPI().putMarker(player.getEntityWorld(), true, atlasID, new Identifier("antiqueatlas:tomb"), - new TranslatableText("gui.antiqueatlas.marker.tomb", player.getName()), + Text.translatable("gui.antiqueatlas.marker.tomb", player.getName()), (int) player.getX(), (int) player.getZ()); } } diff --git a/common/src/main/java/hunternif/mc/impl/atlas/item/AntiqueAtlasItems.java b/common/src/main/java/hunternif/mc/impl/atlas/item/AntiqueAtlasItems.java index 22bb14e73..0988b2181 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/item/AntiqueAtlasItems.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/item/AntiqueAtlasItems.java @@ -4,20 +4,18 @@ import dev.architectury.registry.registries.RegistrySupplier; import hunternif.mc.impl.atlas.AntiqueAtlasMod; import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; - import net.minecraft.item.ItemStack; import net.minecraft.recipe.RecipeSerializer; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.RegistryKeys; + public class AntiqueAtlasItems { public static final DeferredRegister - ITEMS = DeferredRegister.create(AntiqueAtlasMod.ID, Registry.ITEM_KEY); + ITEMS = DeferredRegister.create(AntiqueAtlasMod.ID, RegistryKeys.ITEM); public static final DeferredRegister> - RECIPES = DeferredRegister.create(AntiqueAtlasMod.ID, Registry.RECIPE_SERIALIZER_KEY); + RECIPES = DeferredRegister.create(AntiqueAtlasMod.ID, RegistryKeys.RECIPE_SERIALIZER); - public static final RegistrySupplier EMPTY_ATLAS = ITEMS.register("empty_antique_atlas", () -> new EmptyAtlasItem(new Item.Settings().group(ItemGroup.MISC))); + public static final RegistrySupplier EMPTY_ATLAS = ITEMS.register("empty_antique_atlas", () -> new EmptyAtlasItem(new Item.Settings())); public static final RegistrySupplier ATLAS = ITEMS.register("antique_atlas", () -> new AtlasItem(new Item.Settings().maxCount(1))); public static ItemStack getAtlasFromId(int atlasID) { diff --git a/common/src/main/java/hunternif/mc/impl/atlas/item/AtlasItem.java b/common/src/main/java/hunternif/mc/impl/atlas/item/AtlasItem.java index a88ccde27..c182eeee7 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/item/AtlasItem.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/item/AtlasItem.java @@ -13,12 +13,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUsageContext; import net.minecraft.item.map.MapBannerMarker; +import net.minecraft.registry.tag.BlockTags; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; -import net.minecraft.tag.BlockTags; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; @@ -39,7 +38,7 @@ public static int getAtlasID(ItemStack stack) { @Override public Text getName(ItemStack stack) { - return new TranslatableText(this.getTranslationKey(), getAtlasID(stack)); + return Text.translatable(this.getTranslationKey(), getAtlasID(stack)); } @Override diff --git a/common/src/main/java/hunternif/mc/impl/atlas/item/RecipeAtlasCloning.java b/common/src/main/java/hunternif/mc/impl/atlas/item/RecipeAtlasCloning.java index 796f3b26d..f48000fa0 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/item/RecipeAtlasCloning.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/item/RecipeAtlasCloning.java @@ -1,12 +1,14 @@ package hunternif.mc.impl.atlas.item; import hunternif.mc.impl.atlas.AntiqueAtlasMod; -import net.minecraft.inventory.CraftingInventory; +import net.minecraft.inventory.RecipeInputInventory; import net.minecraft.item.ItemStack; import net.minecraft.recipe.CraftingRecipe; import net.minecraft.recipe.RecipeSerializer; import net.minecraft.recipe.RecipeType; import net.minecraft.recipe.SpecialRecipeSerializer; +import net.minecraft.recipe.book.CraftingRecipeCategory; +import net.minecraft.registry.DynamicRegistryManager; import net.minecraft.util.Identifier; import net.minecraft.world.World; @@ -14,7 +16,7 @@ public class RecipeAtlasCloning implements CraftingRecipe { public static final RecipeSerializer SERIALIZER = new SpecialRecipeSerializer<>(RecipeAtlasCloning::new); private final Identifier id; - public RecipeAtlasCloning(Identifier identifier) { + public RecipeAtlasCloning(Identifier identifier, CraftingRecipeCategory craftingRecipeCategory) { this.id = identifier; } @@ -24,7 +26,7 @@ public String getGroup() { } @Override - public boolean matches(CraftingInventory inv, World world) { + public boolean matches(RecipeInputInventory inv, World world) { int i = 0; // number of empty atlases ItemStack filledAtlas = ItemStack.EMPTY; @@ -50,7 +52,7 @@ public boolean matches(CraftingInventory inv, World world) { } @Override - public ItemStack craft(CraftingInventory inv) { + public ItemStack craft(RecipeInputInventory inv, DynamicRegistryManager dynamicRegistryManager) { int i = 0; // number of new copies ItemStack filledAtlas = ItemStack.EMPTY; @@ -92,7 +94,7 @@ public boolean fits(int width, int height) { } @Override - public ItemStack getOutput() { + public ItemStack getOutput(DynamicRegistryManager dynamicRegistryManager) { return ItemStack.EMPTY; } @@ -110,4 +112,9 @@ public RecipeSerializer getSerializer() { public RecipeType getType() { return RecipeType.CRAFTING; } + + @Override + public CraftingRecipeCategory getCategory() { + return CraftingRecipeCategory.MISC; + } } diff --git a/common/src/main/java/hunternif/mc/impl/atlas/item/RecipeAtlasCombining.java b/common/src/main/java/hunternif/mc/impl/atlas/item/RecipeAtlasCombining.java index 42288fb3b..1f201e64e 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/item/RecipeAtlasCombining.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/item/RecipeAtlasCombining.java @@ -4,15 +4,17 @@ import hunternif.mc.impl.atlas.core.AtlasData; import hunternif.mc.impl.atlas.marker.Marker; import hunternif.mc.impl.atlas.marker.MarkersData; -import net.minecraft.inventory.CraftingInventory; import net.minecraft.inventory.Inventory; +import net.minecraft.inventory.RecipeInputInventory; import net.minecraft.item.ItemStack; import net.minecraft.recipe.CraftingRecipe; import net.minecraft.recipe.RecipeSerializer; import net.minecraft.recipe.RecipeType; import net.minecraft.recipe.SpecialRecipeSerializer; +import net.minecraft.recipe.book.CraftingRecipeCategory; +import net.minecraft.registry.DynamicRegistryManager; +import net.minecraft.registry.RegistryKey; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.World; import java.util.ArrayList; @@ -28,7 +30,7 @@ public class RecipeAtlasCombining implements CraftingRecipe { public static final RecipeSerializer SERIALIZER = new SpecialRecipeSerializer<>(RecipeAtlasCombining::new); private final Identifier id; - public RecipeAtlasCombining(Identifier id) { + public RecipeAtlasCombining(Identifier id, CraftingRecipeCategory craftingRecipeCategory) { this.id = id; } @@ -38,11 +40,11 @@ public String getGroup() { } @Override - public boolean matches(CraftingInventory inv, World world) { + public boolean matches(RecipeInputInventory inv, World world) { return matches(inv); } - private boolean matches(CraftingInventory inv) { + private boolean matches(RecipeInputInventory inv) { int atlasesFound = 0; for (int i = 0; i < inv.size(); ++i) { ItemStack stack = inv.getStack(i); @@ -56,7 +58,7 @@ private boolean matches(CraftingInventory inv) { } @Override - public ItemStack craft(CraftingInventory inv) { + public ItemStack craft(RecipeInputInventory inv, DynamicRegistryManager dynamicRegistryManager) { ItemStack firstAtlas = ItemStack.EMPTY; List atlasIds = new ArrayList<>(9); for (int i = 0; i < inv.size(); ++i) { @@ -80,7 +82,7 @@ public boolean fits(int width, int height) { } @Override - public ItemStack getOutput() { + public ItemStack getOutput(DynamicRegistryManager dynamicRegistryManager) { return new ItemStack(AntiqueAtlasItems.ATLAS.get()); } @@ -99,6 +101,11 @@ public RecipeType getType() { return RecipeType.CRAFTING; } + @Override + public CraftingRecipeCategory getCategory() { + return CraftingRecipeCategory.MISC; + } + public ItemStack onCrafted(World world, Inventory inventory, ItemStack result) { if (world.isClient) return result; // Until the first update, on the client the returned atlas ID is the same as the first Atlas on the crafting grid. diff --git a/common/src/main/java/hunternif/mc/impl/atlas/marker/DimensionMarkersData.java b/common/src/main/java/hunternif/mc/impl/atlas/marker/DimensionMarkersData.java index 07e7b318b..d2f1ca22c 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/marker/DimensionMarkersData.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/marker/DimensionMarkersData.java @@ -1,15 +1,11 @@ package hunternif.mc.impl.atlas.marker; import hunternif.mc.impl.atlas.util.ListMapValueIterator; +import net.minecraft.registry.RegistryKey; import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.World; -import java.util.AbstractCollection; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; diff --git a/common/src/main/java/hunternif/mc/impl/atlas/marker/GlobalMarkersData.java b/common/src/main/java/hunternif/mc/impl/atlas/marker/GlobalMarkersData.java index 39d139e9a..38191c79a 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/marker/GlobalMarkersData.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/marker/GlobalMarkersData.java @@ -1,10 +1,10 @@ package hunternif.mc.impl.atlas.marker; import net.minecraft.nbt.NbtCompound; +import net.minecraft.registry.RegistryKey; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.World; /** Holds global markers, i.e. ones that appear in all atlases. */ diff --git a/common/src/main/java/hunternif/mc/impl/atlas/marker/Marker.java b/common/src/main/java/hunternif/mc/impl/atlas/marker/Marker.java index 60ecea1dd..04824e1de 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/marker/Marker.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/marker/Marker.java @@ -1,11 +1,11 @@ package hunternif.mc.impl.atlas.marker; import net.minecraft.network.PacketByteBuf; +import net.minecraft.registry.RegistryKey; import net.minecraft.text.Text; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.World; /** diff --git a/common/src/main/java/hunternif/mc/impl/atlas/marker/MarkerTextureConfig.java b/common/src/main/java/hunternif/mc/impl/atlas/marker/MarkerTextureConfig.java index 587962ae1..15d1302bf 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/marker/MarkerTextureConfig.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/marker/MarkerTextureConfig.java @@ -3,8 +3,8 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import hunternif.mc.impl.atlas.AntiqueAtlasMod; -import hunternif.mc.impl.atlas.resource.ResourceReloadListener; import hunternif.mc.impl.atlas.registry.MarkerType; +import hunternif.mc.impl.atlas.resource.ResourceReloadListener; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.resource.Resource; @@ -37,14 +37,14 @@ public CompletableFuture> load(ResourceManager manag return CompletableFuture.supplyAsync(() -> { Map typeMap = new HashMap<>(); - for (Identifier id : manager.findResources("atlas/markers", (s) -> s.endsWith(".json"))) { + for (Identifier id : manager.findResources("atlas/markers", (id) -> id.toString().endsWith(".json")).keySet()) { Identifier markerId = new Identifier( id.getNamespace(), id.getPath().replace("atlas/markers/", "").replace(".json", "") ); try { - Resource resource = manager.getResource(id); + Resource resource = manager.getResource(id).get(); try ( InputStream stream = resource.getInputStream(); InputStreamReader reader = new InputStreamReader(stream) diff --git a/common/src/main/java/hunternif/mc/impl/atlas/marker/MarkersData.java b/common/src/main/java/hunternif/mc/impl/atlas/marker/MarkersData.java index c84185390..974b88445 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/marker/MarkersData.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/marker/MarkersData.java @@ -1,18 +1,18 @@ package hunternif.mc.impl.atlas.marker; -import hunternif.mc.impl.atlas.AntiqueAtlasMod; import hunternif.mc.api.MarkerAPI; +import hunternif.mc.impl.atlas.AntiqueAtlasMod; import hunternif.mc.impl.atlas.network.packet.s2c.play.PutMarkersS2CPacket; import hunternif.mc.impl.atlas.util.Log; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; import net.minecraft.nbt.NbtList; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.PersistentState; import net.minecraft.world.World; @@ -90,7 +90,7 @@ protected static void doReadNbt(NbtCompound compound, MarkersData data) { NbtList dimensionMapList = compound.getList(TAG_WORLD_MAP_LIST, NbtElement.COMPOUND_TYPE); for (int d = 0; d < dimensionMapList.size(); d++) { NbtCompound tag = dimensionMapList.getCompound(d); - RegistryKey world = RegistryKey.of(Registry.WORLD_KEY, new Identifier(tag.getString(TAG_WORLD_ID))); + RegistryKey world = RegistryKey.of(RegistryKeys.WORLD, new Identifier(tag.getString(TAG_WORLD_ID))); NbtList tagList = tag.getList(TAG_MARKERS, NbtElement.COMPOUND_TYPE); for (int i = 0; i < tagList.size(); i++) { diff --git a/common/src/main/java/hunternif/mc/impl/atlas/marker/MarkersDataHandler.java b/common/src/main/java/hunternif/mc/impl/atlas/marker/MarkersDataHandler.java index effbc8c36..0092320e8 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/marker/MarkersDataHandler.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/marker/MarkersDataHandler.java @@ -2,8 +2,8 @@ import hunternif.mc.impl.atlas.item.AtlasItem; import net.minecraft.item.ItemStack; +import net.minecraft.registry.RegistryKey; import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.PersistentStateManager; import net.minecraft.world.World; diff --git a/common/src/main/java/hunternif/mc/impl/atlas/marker/NetherPortalWatcher.java b/common/src/main/java/hunternif/mc/impl/atlas/marker/NetherPortalWatcher.java index 9b0050e4e..4817443ca 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/marker/NetherPortalWatcher.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/marker/NetherPortalWatcher.java @@ -1,16 +1,17 @@ package hunternif.mc.impl.atlas.marker; -import hunternif.mc.impl.atlas.AntiqueAtlasMod; import hunternif.mc.api.AtlasAPI; +import hunternif.mc.impl.atlas.AntiqueAtlasMod; import hunternif.mc.impl.atlas.item.AtlasItem; import hunternif.mc.impl.atlas.mixinhooks.EntityHooksAA; import hunternif.mc.impl.atlas.registry.MarkerType; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.text.TranslatableText; +import net.minecraft.text.Text; import net.minecraft.world.World; import net.minecraft.world.dimension.DimensionType; + import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -130,7 +131,7 @@ private void addPortalMarkerIfNone(PlayerEntity player, World world, int atlasID } // Marker not found, place new one: - AtlasAPI.getMarkerAPI().putMarker(world, false, atlasID, MarkerType.REGISTRY.getId(netherPortalType), new TranslatableText("gui.antiqueatlas.marker.netherPortal"), x, z); + AtlasAPI.getMarkerAPI().putMarker(world, false, atlasID, MarkerType.REGISTRY.getId(netherPortalType), Text.translatable("gui.antiqueatlas.marker.netherPortal"), x, z); } private static boolean isEntityInPortal(Entity entity) { diff --git a/common/src/main/java/hunternif/mc/impl/atlas/mixin/HeldItemRendererMixin.java b/common/src/main/java/hunternif/mc/impl/atlas/mixin/HeldItemRendererMixin.java index c2f10ee9b..0f44012d5 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/mixin/HeldItemRendererMixin.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/mixin/HeldItemRendererMixin.java @@ -1,7 +1,7 @@ package hunternif.mc.impl.atlas.mixin; -import hunternif.mc.impl.atlas.item.AntiqueAtlasItems; import hunternif.mc.impl.atlas.client.OverlayRenderer; +import hunternif.mc.impl.atlas.item.AntiqueAtlasItems; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; @@ -13,7 +13,7 @@ import net.minecraft.util.Arm; import net.minecraft.util.Hand; import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3f; +import net.minecraft.util.math.RotationAxis; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -68,18 +68,18 @@ private void renderAtlasInBothHands(MatrixStack matrices, VertexConsumerProvider matrices.translate(0.0D, -g / 2.0F, h); float i = getMapAngle(pitch); matrices.translate(0.0D, 0.04F + equipProgress * -1.2F + i * -0.5F, -0.7200000286102295D); - matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(i * -85.0F)); + matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(i * -85.0F)); if (!this.client.player.isInvisible()) { matrices.push(); - matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90.0F)); + matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(90.0F)); this.renderArm(matrices, vertexConsumers, light, Arm.RIGHT); this.renderArm(matrices, vertexConsumers, light, Arm.LEFT); matrices.pop(); } float j = MathHelper.sin(f * 3.1415927F); - matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(j * 20.0F)); + matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(j * 20.0F)); matrices.scale(0.5F, 0.5F, 1.0F); this.renderFirstPersonAtlas(matrices, vertexConsumers, light, this.mainHand); @@ -91,7 +91,7 @@ private void renderAtlasInOneHand(MatrixStack matrices, VertexConsumerProvider v matrices.translate(f * 0.125F, -0.125D, 0.0D); if (!this.client.player.isInvisible()) { matrices.push(); - matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(f * 10.0F)); + matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(f * 10.0F)); this.renderArmHoldingItem(matrices, vertexConsumers, light, equipProgress, swingProgress, arm); matrices.pop(); } @@ -104,11 +104,11 @@ private void renderAtlasInOneHand(MatrixStack matrices, VertexConsumerProvider v float j = 0.4F * MathHelper.sin(g * 6.2831855F); float k = -0.3F * MathHelper.sin(swingProgress * 3.1415927F); matrices.translate(f * i, j - 0.3F * h, k); - matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(h * -45.0F)); - matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(f * h * -30.0F)); + matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(h * -45.0F)); + matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(f * h * -30.0F)); - matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(180.0F)); - matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(180.0F)); + matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180.0F)); + matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(180.0F)); matrices.scale(0.38F, 0.38F, 0.38F); matrices.translate(-0.75D, -0.5D, 0.0D); matrices.scale(0.0078125F, 0.0078125F, 0.0078125F); @@ -120,8 +120,8 @@ private void renderAtlasInOneHand(MatrixStack matrices, VertexConsumerProvider v } private void renderFirstPersonAtlas(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, ItemStack item) { - matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(180.0F)); - matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(180.0F)); + matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180.0F)); + matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(180.0F)); matrices.scale(0.38F, 0.38F, 0.38F); matrices.translate(-1.85D, -0.5D, 0.0D); diff --git a/common/src/main/java/hunternif/mc/impl/atlas/mixin/MixinCartographyTableScreenHandler.java b/common/src/main/java/hunternif/mc/impl/atlas/mixin/MixinCartographyTableScreenHandler.java index adb93b1bc..a11220563 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/mixin/MixinCartographyTableScreenHandler.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/mixin/MixinCartographyTableScreenHandler.java @@ -33,7 +33,8 @@ protected MixinCartographyTableScreenHandler(@Nullable ScreenHandlerType type } // inject into lambda inside CartographyTableScreenHandler::updateResult - @Inject(method = {"lambda$setupResultSlot$0", "method_17382", "m_39166_"}, at = @At("HEAD"), cancellable = true) + // @Inject(method = {"lambda$setupResultSlot$0", "method_17382", "m_39166_"}, at = @At("HEAD"), cancellable = true) + @Inject(method = "method_17382", at = @At("HEAD"), cancellable = true) void antiqueatlas_call(ItemStack map, ItemStack atlas, ItemStack result, World world, BlockPos pos, CallbackInfo info) { if (atlas.getItem() == AtlasAPI.getAtlasItem() && map.getItem() == Items.FILLED_MAP) { this.resultInventory.setStack(CartographyTableScreenHandler.RESULT_SLOT_INDEX, atlas.copy()); @@ -44,7 +45,7 @@ void antiqueatlas_call(ItemStack map, ItemStack atlas, ItemStack result, World w } } - @Inject(method = "transferSlot", at = @At("HEAD"), cancellable = true) + @Inject(method = "quickMove", at = @At("HEAD"), cancellable = true) void antiqueatlas_transferSlot(PlayerEntity player, int index, CallbackInfoReturnable info) { if (index >= 0 && index <= 2) return; diff --git a/common/src/main/java/hunternif/mc/impl/atlas/mixin/MixinCraftingResultSlot.java b/common/src/main/java/hunternif/mc/impl/atlas/mixin/MixinCraftingResultSlot.java index 9b1b10760..80fff459a 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/mixin/MixinCraftingResultSlot.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/mixin/MixinCraftingResultSlot.java @@ -2,8 +2,8 @@ import hunternif.mc.impl.atlas.event.RecipeCraftedCallback; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.CraftingInventory; import net.minecraft.inventory.Inventory; +import net.minecraft.inventory.RecipeInputInventory; import net.minecraft.item.ItemStack; import net.minecraft.recipe.RecipeUnlocker; import net.minecraft.screen.slot.CraftingResultSlot; @@ -20,7 +20,7 @@ public class MixinCraftingResultSlot extends Slot { @Final @Shadow - private CraftingInventory input; + private RecipeInputInventory input; @Final @Shadow private PlayerEntity player; @@ -32,7 +32,7 @@ public MixinCraftingResultSlot(Inventory inventory_1, int int_1, int int_2, int @Inject(at = @At("HEAD"), method = "onCrafted(Lnet/minecraft/item/ItemStack;)V") protected void onCrafted(ItemStack stack, final CallbackInfo info) { if (inventory instanceof RecipeUnlocker) { - RecipeCraftedCallback.EVENT.invoker().onCrafted(this.player, this.player.world, ((RecipeUnlocker) (inventory)).getLastRecipe(), stack, input); + RecipeCraftedCallback.EVENT.invoker().onCrafted(this.player, this.player.getWorld(), ((RecipeUnlocker) (inventory)).getLastRecipe(), stack, input); } } } diff --git a/common/src/main/java/hunternif/mc/impl/atlas/mixin/MixinInGameHud.java b/common/src/main/java/hunternif/mc/impl/atlas/mixin/MixinInGameHud.java index 3fc82d266..e3c2ebab9 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/mixin/MixinInGameHud.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/mixin/MixinInGameHud.java @@ -3,8 +3,8 @@ import hunternif.mc.impl.atlas.client.gui.ExportProgressOverlay; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.InGameHud; -import net.minecraft.client.util.math.MatrixStack; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -20,7 +20,7 @@ public class MixinInGameHud { private int scaledHeight; @Inject(at = @At("TAIL"), method = "render") - public void draw(MatrixStack matrix, float partial, CallbackInfo info) { - ExportProgressOverlay.INSTANCE.draw(matrix, scaledWidth, scaledHeight); + public void draw(DrawContext context, float tickDelta, CallbackInfo ci) { + ExportProgressOverlay.INSTANCE.draw(context, scaledWidth, scaledHeight); } } diff --git a/common/src/main/java/hunternif/mc/impl/atlas/mixin/structure/StructureStartMixin.java b/common/src/main/java/hunternif/mc/impl/atlas/mixin/structure/StructureStartMixin.java index 8923a8fd3..2e2777d0b 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/mixin/structure/StructureStartMixin.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/mixin/structure/StructureStartMixin.java @@ -9,10 +9,12 @@ import net.minecraft.util.math.BlockBox; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; +import net.minecraft.util.math.random.Random; import net.minecraft.world.ChunkRegion; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.StructureAccessor; import net.minecraft.world.gen.chunk.ChunkGenerator; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -20,32 +22,31 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.List; -import java.util.Random; @Mixin(StructureStart.class) public class StructureStartMixin { + @Final @Shadow - protected StructurePiecesList children; + private StructurePiecesList children; - @Redirect(method = "place", at = @At(value = "INVOKE", target = "Lnet/minecraft/structure/StructurePiece;generate(Lnet/minecraft/world/StructureWorldAccess;Lnet/minecraft/world/gen/StructureAccessor;Lnet/minecraft/world/gen/chunk/ChunkGenerator;Ljava/util/Random;Lnet/minecraft/util/math/BlockBox;Lnet/minecraft/util/math/ChunkPos;Lnet/minecraft/util/math/BlockPos;)V")) - private void structurePieceGenerated(StructurePiece structurePiece, StructureWorldAccess serverWorldAccess, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, Random random, BlockBox boundingBox, ChunkPos chunkPos, BlockPos blockPos) { + @Redirect(method = "place", at = @At(value = "INVOKE", target = "Lnet/minecraft/structure/StructurePiece;generate(Lnet/minecraft/world/StructureWorldAccess;Lnet/minecraft/world/gen/StructureAccessor;Lnet/minecraft/world/gen/chunk/ChunkGenerator;Lnet/minecraft/util/math/random/Random;Lnet/minecraft/util/math/BlockBox;Lnet/minecraft/util/math/ChunkPos;Lnet/minecraft/util/math/BlockPos;)V")) + private void structurePieceGenerated(StructurePiece structurePiece, StructureWorldAccess structureWorldAccess, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, Random random, BlockBox boundingBox, ChunkPos chunkPos, BlockPos blockPos) { ServerWorld world; - if (serverWorldAccess instanceof ServerWorld) { - world = (ServerWorld) serverWorldAccess; + if (structureWorldAccess instanceof ServerWorld) { + world = (ServerWorld) structureWorldAccess; } else { - world = ((ChunkRegion) serverWorldAccess).world; + world = ((ChunkRegion) structureWorldAccess).world; } StructurePieceAddedCallback.EVENT.invoker().onStructurePieceAdded(structurePiece, world); - structurePiece.generate(serverWorldAccess, structureAccessor, chunkGenerator, random, boundingBox, chunkPos, blockPos); + structurePiece.generate(structureWorldAccess, structureAccessor, chunkGenerator, random, boundingBox, chunkPos, blockPos); } @Inject(method = "place", at = @At("RETURN")) - private void structureGenerated(StructureWorldAccess serverWorldAccess, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, Random random, BlockBox blockBox, ChunkPos chunkPos, CallbackInfo ci) { + private void structureGenerated(StructureWorldAccess serverWorldAccess, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, Random random, BlockBox chunkBox, ChunkPos chunkPos, CallbackInfo ci) { ServerWorld world; if (serverWorldAccess instanceof ServerWorld) { diff --git a/common/src/main/java/hunternif/mc/impl/atlas/mixinhooks/CartographyTableHooks.java b/common/src/main/java/hunternif/mc/impl/atlas/mixinhooks/CartographyTableHooks.java index bf9c29dbb..0471d64a4 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/mixinhooks/CartographyTableHooks.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/mixinhooks/CartographyTableHooks.java @@ -10,7 +10,6 @@ import net.minecraft.item.map.MapIcon; import net.minecraft.item.map.MapState; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; public class CartographyTableHooks { @@ -33,13 +32,13 @@ public static void onTakeItem(PlayerEntity player, ItemStack map, ItemStack atla if (icon.getType() == MapIcon.Type.RED_X) { type = AntiqueAtlasMod.id("red_x_small"); - label = new TranslatableText("gui.antiqueatlas.marker.treasure"); + label = Text.translatable("gui.antiqueatlas.marker.treasure"); } else if (icon.getType() == MapIcon.Type.MONUMENT) { type = AntiqueAtlasMod.id("monument"); - label = new TranslatableText("gui.antiqueatlas.marker.monument"); + label = Text.translatable("gui.antiqueatlas.marker.monument"); } else if (icon.getType() == MapIcon.Type.MANSION) { type = AntiqueAtlasMod.id("mansion"); - label = new TranslatableText("gui.antiqueatlas.marker.mansion"); + label = Text.translatable("gui.antiqueatlas.marker.mansion"); } if (type != null) { diff --git a/common/src/main/java/hunternif/mc/impl/atlas/network/packet/c2s/play/PutBrowsingPositionC2SPacket.java b/common/src/main/java/hunternif/mc/impl/atlas/network/packet/c2s/play/PutBrowsingPositionC2SPacket.java index ea4a8afef..61b5315e6 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/network/packet/c2s/play/PutBrowsingPositionC2SPacket.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/network/packet/c2s/play/PutBrowsingPositionC2SPacket.java @@ -1,14 +1,14 @@ package hunternif.mc.impl.atlas.network.packet.c2s.play; import dev.architectury.networking.NetworkManager; -import hunternif.mc.impl.atlas.AntiqueAtlasMod; import hunternif.mc.api.AtlasAPI; +import hunternif.mc.impl.atlas.AntiqueAtlasMod; import hunternif.mc.impl.atlas.network.packet.c2s.C2SPacket; import hunternif.mc.impl.atlas.util.Log; import net.minecraft.network.PacketByteBuf; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.World; /** @@ -34,7 +34,7 @@ public Identifier getId() { public static void apply(PacketByteBuf buf, NetworkManager.PacketContext context) { int atlasID = buf.readVarInt(); - RegistryKey world = RegistryKey.of(Registry.WORLD_KEY, buf.readIdentifier()); + RegistryKey world = RegistryKey.of(RegistryKeys.WORLD, buf.readIdentifier()); int x = buf.readVarInt(); int y = buf.readVarInt(); double zoom = buf.readDouble(); diff --git a/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/DeleteGlobalTileS2CPacket.java b/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/DeleteGlobalTileS2CPacket.java index 4be6c8c7b..11b1e39ea 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/DeleteGlobalTileS2CPacket.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/DeleteGlobalTileS2CPacket.java @@ -7,9 +7,9 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.network.PacketByteBuf; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.World; /** @@ -33,7 +33,7 @@ public Identifier getId() { @Environment(EnvType.CLIENT) public static void apply(PacketByteBuf buf, NetworkManager.PacketContext context) { - RegistryKey world = RegistryKey.of(Registry.WORLD_KEY, buf.readIdentifier()); + RegistryKey world = RegistryKey.of(RegistryKeys.WORLD, buf.readIdentifier()); int chunkX = buf.readVarInt(); int chunkZ = buf.readVarInt(); diff --git a/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/DimensionUpdateS2CPacket.java b/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/DimensionUpdateS2CPacket.java index 9b1670135..6f167a79d 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/DimensionUpdateS2CPacket.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/DimensionUpdateS2CPacket.java @@ -8,9 +8,9 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.network.PacketByteBuf; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.World; import java.util.ArrayList; @@ -40,7 +40,7 @@ public Identifier getId() { @Environment(EnvType.CLIENT) public static void apply(PacketByteBuf buf, NetworkManager.PacketContext context) { int atlasID = buf.readVarInt(); - RegistryKey world = RegistryKey.of(Registry.WORLD_KEY, buf.readIdentifier()); + RegistryKey world = RegistryKey.of(RegistryKeys.WORLD, buf.readIdentifier()); int tileCount = buf.readVarInt(); if (world == null) { diff --git a/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/PutGlobalTileS2CPacket.java b/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/PutGlobalTileS2CPacket.java index 1807123dc..aba70afc1 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/PutGlobalTileS2CPacket.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/PutGlobalTileS2CPacket.java @@ -7,10 +7,10 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.network.PacketByteBuf; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.util.Identifier; import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.World; import java.util.List; @@ -50,7 +50,7 @@ public Identifier getId() { @Environment(EnvType.CLIENT) public static void apply(PacketByteBuf buf, NetworkManager.PacketContext context) { - RegistryKey world = RegistryKey.of(Registry.WORLD_KEY, buf.readIdentifier()); + RegistryKey world = RegistryKey.of(RegistryKeys.WORLD, buf.readIdentifier()); int tileCount = buf.readVarInt(); TileDataStorage data = AntiqueAtlasMod.globalTileData.getData(world); diff --git a/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/PutMarkersS2CPacket.java b/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/PutMarkersS2CPacket.java index acb6799a2..2dd4e818d 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/PutMarkersS2CPacket.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/PutMarkersS2CPacket.java @@ -12,9 +12,9 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.network.PacketByteBuf; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.World; import java.util.Collection; @@ -61,7 +61,7 @@ public Identifier getId() { @Environment(EnvType.CLIENT) public static void apply(PacketByteBuf buf, NetworkManager.PacketContext context) { int atlasID = buf.readVarInt(); - RegistryKey world = RegistryKey.of(Registry.WORLD_KEY, buf.readIdentifier()); + RegistryKey world = RegistryKey.of(RegistryKeys.WORLD, buf.readIdentifier()); int typesLength = buf.readVarInt(); ListMultimap markersByType = ArrayListMultimap.create(); diff --git a/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/PutTileS2CPacket.java b/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/PutTileS2CPacket.java index 2b0294407..bf004a82b 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/PutTileS2CPacket.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/PutTileS2CPacket.java @@ -7,9 +7,9 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.network.PacketByteBuf; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.World; /** @@ -36,7 +36,7 @@ public Identifier getId() { @Environment(EnvType.CLIENT) public static void apply(PacketByteBuf buf, NetworkManager.PacketContext context) { int atlasID = buf.readVarInt(); - RegistryKey world = RegistryKey.of(Registry.WORLD_KEY, buf.readIdentifier()); + RegistryKey world = RegistryKey.of(RegistryKeys.WORLD, buf.readIdentifier()); int x = buf.readVarInt(); int z = buf.readVarInt(); Identifier tile = buf.readIdentifier(); diff --git a/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/TileGroupsS2CPacket.java b/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/TileGroupsS2CPacket.java index dfdf54b03..5519ec340 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/TileGroupsS2CPacket.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/network/packet/s2c/play/TileGroupsS2CPacket.java @@ -10,9 +10,9 @@ import net.fabricmc.api.Environment; import net.minecraft.nbt.NbtCompound; import net.minecraft.network.PacketByteBuf; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.World; import java.util.ArrayList; @@ -47,7 +47,7 @@ public Identifier getId() { @Environment(EnvType.CLIENT) public static void apply(PacketByteBuf buf, NetworkManager.PacketContext context) { int atlasID = buf.readVarInt(); - RegistryKey world = RegistryKey.of(Registry.WORLD_KEY, buf.readIdentifier()); + RegistryKey world = RegistryKey.of(RegistryKeys.WORLD, buf.readIdentifier()); int length = buf.readVarInt(); List tileGroups = new ArrayList<>(length); diff --git a/common/src/main/java/hunternif/mc/impl/atlas/registry/MarkerType.java b/common/src/main/java/hunternif/mc/impl/atlas/registry/MarkerType.java index 1cbbf568b..ce7653d03 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/registry/MarkerType.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/registry/MarkerType.java @@ -12,27 +12,25 @@ import hunternif.mc.impl.atlas.util.Log; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.client.MinecraftClient; import net.minecraft.client.texture.NativeImage; import net.minecraft.client.texture.TextureManager; +import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.SimpleDefaultedRegistry; +import net.minecraft.resource.Resource; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.*; -import org.apache.commons.io.IOUtils; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import java.util.Map; -import java.util.OptionalInt; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.resource.Resource; public class MarkerType { public static final RegistryKey> KEY = RegistryKey.ofRegistry(AntiqueAtlasMod.id("marker")); - public static final DefaultedRegistry REGISTRY = new DefaultedRegistry<>(AntiqueAtlasMod.id("red_x_small").toString(), - KEY, - Lifecycle.experimental(), - null); + public static final SimpleDefaultedRegistry REGISTRY = new SimpleDefaultedRegistry<>(AntiqueAtlasMod.id("red_x_small").toString(), + KEY, + Lifecycle.experimental(), + false); private Identifier[] icons; private BitMatrix[] iconPixels; @@ -61,7 +59,7 @@ public static void register(Identifier location, MarkerType type) { type.initMips(); if (REGISTRY.containsId(location)) { int id = REGISTRY.getRawId(REGISTRY.get(location)); - REGISTRY.replace(OptionalInt.of(id), RegistryKey.of(KEY, location), type, Lifecycle.stable()); + REGISTRY.set(id, RegistryKey.of(KEY, location), type, Lifecycle.stable()); } else { REGISTRY.add(RegistryKey.of(KEY, location), type, Lifecycle.stable()); } @@ -207,7 +205,7 @@ public void initMips() { NativeImage bufferedimage = null; try { - iresource = MinecraftClient.getInstance().getResourceManager().getResource(icons[i]); + iresource = MinecraftClient.getInstance().getResourceManager().getResource(icons[i]).get(); bufferedimage = NativeImage.read(iresource.getInputStream()); iconSizes[i] = Math.min(bufferedimage.getWidth(), bufferedimage.getHeight()); BitMatrix matrix = new BitMatrix(bufferedimage.getWidth(), bufferedimage.getHeight(), false); @@ -244,7 +242,8 @@ public void initMips() { if (bufferedimage != null) { bufferedimage.close(); } - IOUtils.closeQuietly(iresource); + //It think we do not need this anymore, hopefully + //IOUtils.closeQuietly(iresource); } } } diff --git a/common/src/main/java/hunternif/mc/impl/atlas/structure/EndCity.java b/common/src/main/java/hunternif/mc/impl/atlas/structure/EndCity.java index dc3ccceb7..d141b9b36 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/structure/EndCity.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/structure/EndCity.java @@ -1,13 +1,15 @@ package hunternif.mc.impl.atlas.structure; import hunternif.mc.impl.atlas.AntiqueAtlasMod; -import net.minecraft.text.LiteralText; -import net.minecraft.world.gen.feature.StructureFeature; +import net.minecraft.text.Text; +import net.minecraft.world.gen.structure.StructureKeys; + +import java.util.List; public class EndCity { public static void registerMarkers() { - StructureHandler.registerMarker(StructureFeature.ENDCITY, AntiqueAtlasMod.id("end_city"), new LiteralText("")); + StructureHandler.registerMarker(List.of(StructureKeys.END_CITY), AntiqueAtlasMod.id("end_city"), Text.literal("")); } } diff --git a/common/src/main/java/hunternif/mc/impl/atlas/structure/JigsawConfig.java b/common/src/main/java/hunternif/mc/impl/atlas/structure/JigsawConfig.java index 09187cb38..22d193d97 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/structure/JigsawConfig.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/structure/JigsawConfig.java @@ -26,7 +26,7 @@ public class JigsawConfig implements ResourceReloadListener PIECES = new ConcurrentHashMap<>(); private static JsonObject readResource(ResourceManager manager, Identifier id) throws IOException { - Resource resource = manager.getResource(id); + Resource resource = manager.getResource(id).get(); try (InputStream stream = resource.getInputStream(); InputStreamReader reader = new InputStreamReader(stream)) { return JsonParser.parseReader(reader).getAsJsonObject(); } @@ -59,7 +59,10 @@ public CompletableFuture> load(ResourceManag try { - for (Identifier id : manager.findResources("atlas/structures", (s) -> s.endsWith(".json"))) { + + Map map = manager.findResources("atlas/structures", (identifier -> identifier.toString().endsWith(".json"))); + + for (Identifier id : map.keySet()) { // id now contains the physical file path of the structure piece AntiqueAtlasMod.LOG.info("Found structure piece config: " + id); diff --git a/common/src/main/java/hunternif/mc/impl/atlas/structure/StructureHandler.java b/common/src/main/java/hunternif/mc/impl/atlas/structure/StructureHandler.java index 8a7b09a93..84eff4cf4 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/structure/StructureHandler.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/structure/StructureHandler.java @@ -4,6 +4,8 @@ import com.google.common.collect.Multimap; import hunternif.mc.api.AtlasAPI; import hunternif.mc.impl.atlas.util.MathUtil; +import net.minecraft.registry.Registries; +import net.minecraft.registry.RegistryKey; import net.minecraft.server.world.ServerWorld; import net.minecraft.structure.*; import net.minecraft.structure.pool.SinglePoolElement; @@ -13,9 +15,7 @@ import net.minecraft.util.Pair; import net.minecraft.util.math.BlockBox; import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.registry.Registry; import net.minecraft.world.World; -import net.minecraft.world.gen.feature.StructureFeature; import org.apache.commons.lang3.tuple.Triple; import java.util.*; @@ -60,7 +60,7 @@ public static Collection IF_Z_DIRECTION(World ignoredWorld, StructureP private static final Set> VISITED_STRUCTURES = Collections.newSetFromMap(new ConcurrentHashMap<>()); public static void registerTile(StructurePieceType structurePieceType, int priority, Identifier textureId, Setter setter) { - Identifier id = Registry.STRUCTURE_PIECE.getId(structurePieceType); + Identifier id = Registries.STRUCTURE_PIECE.getId(structurePieceType); STRUCTURE_PIECE_TO_TILE_MAP.put(id, new Pair<>(textureId, setter)); STRUCTURE_PIECE_TILE_PRIORITY.put(textureId, priority); } @@ -78,8 +78,10 @@ public static void registerJigsawTile(Identifier jigsawPattern, int priority, Id registerJigsawTile(jigsawPattern, priority, tileID, ALWAYS); } - public static void registerMarker(StructureFeature structureFeature, Identifier markerType, Text name) { - STRUCTURE_PIECE_TO_MARKER_MAP.put(Registry.STRUCTURE_FEATURE.getId(structureFeature), new Pair<>(markerType, name)); + public static void registerMarker(Iterable> structureFeatures, Identifier markerType, Text name) { + structureFeatures.forEach(structureFeature -> { + STRUCTURE_PIECE_TO_MARKER_MAP.put(structureFeature.getValue(), new Pair<>(markerType, name)); + }); } private static int getPriority(Identifier structurePieceId) { @@ -120,7 +122,7 @@ public static void resolve(StructurePiece structurePiece, ServerWorld world) { return; } - Identifier structurePieceId = Registry.STRUCTURE_PIECE.getId(structurePiece.getType()); + Identifier structurePieceId = Registries.STRUCTURE_PIECE.getId(structurePiece.getType()); if (STRUCTURE_PIECE_TO_TILE_MAP.containsKey(structurePieceId)) { for (Pair entry : STRUCTURE_PIECE_TO_TILE_MAP.get(structurePieceId)) { Collection matches; @@ -138,7 +140,7 @@ public static void resolve(StructurePiece structurePiece, ServerWorld world) { } public static void resolve(StructureStart structureStart, ServerWorld world) { - Identifier structureId = Registry.STRUCTURE_FEATURE.getId(structureStart.getFeature().feature); + Identifier structureId = Registries.STRUCTURE_TYPE.getId(structureStart.getStructure().getType()); if (STRUCTURE_PIECE_TO_MARKER_MAP.containsKey(structureId)) { Triple key = Triple.of( structureStart.getBoundingBox().getCenter().getX(), diff --git a/common/src/main/java/hunternif/mc/impl/atlas/structure/Village.java b/common/src/main/java/hunternif/mc/impl/atlas/structure/Village.java index 8dc51d131..f94297be6 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/structure/Village.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/structure/Village.java @@ -1,13 +1,22 @@ package hunternif.mc.impl.atlas.structure; import hunternif.mc.impl.atlas.AntiqueAtlasMod; -import net.minecraft.text.TranslatableText; -import net.minecraft.world.gen.feature.StructureFeature; +import net.minecraft.text.Text; +import net.minecraft.world.gen.structure.StructureKeys; + +import java.util.List; public class Village { public static void registerMarkers() { if (AntiqueAtlasMod.CONFIG.autoVillageMarkers) { - StructureHandler.registerMarker(StructureFeature.VILLAGE, AntiqueAtlasMod.id("village"), new TranslatableText("gui.antiqueatlas.marker.village")); + StructureHandler.registerMarker( + List.of( + StructureKeys.VILLAGE_DESERT, + StructureKeys.VILLAGE_PLAINS, + StructureKeys.VILLAGE_SAVANNA, + StructureKeys.VILLAGE_SNOWY, + StructureKeys.VILLAGE_TAIGA + ), AntiqueAtlasMod.id("village"), Text.translatable("gui.antiqueatlas.marker.village")); } } } diff --git a/common/src/main/java/hunternif/mc/impl/atlas/util/ExportImageUtil.java b/common/src/main/java/hunternif/mc/impl/atlas/util/ExportImageUtil.java index af22c5116..27adc2779 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/util/ExportImageUtil.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/util/ExportImageUtil.java @@ -121,7 +121,7 @@ public static void exportPngImage(WorldData biomeData, DimensionMarkersData glob BufferedImage bg = null; Map textureImageMap = new HashMap<>(); try { - InputStream is = MinecraftClient.getInstance().getResourceManager().getResource(Textures.EXPORTED_BG).getInputStream(); + InputStream is = MinecraftClient.getInstance().getResourceManager().getResource(Textures.EXPORTED_BG).get().getInputStream(); bg = ImageIO.read(is); is.close(); @@ -136,7 +136,7 @@ public static void exportPngImage(WorldData biomeData, DimensionMarkersData glob } for (Identifier texture : allTextures) { try { - is = MinecraftClient.getInstance().getResourceManager().getResource(texture).getInputStream(); + is = MinecraftClient.getInstance().getResourceManager().getResource(texture).get().getInputStream(); BufferedImage tileImage = ImageIO.read(is); is.close(); textureImageMap.put(texture, tileImage); @@ -193,7 +193,7 @@ public static void exportPngImageTooLarge(final WorldData biomeData, final Dimen BufferedImage bg = null; final Map textureImageMap = new HashMap<>(); try { - InputStream is = MinecraftClient.getInstance().getResourceManager().getResource(Textures.EXPORTED_BG).getInputStream(); + InputStream is = MinecraftClient.getInstance().getResourceManager().getResource(Textures.EXPORTED_BG).get().getInputStream(); bg = ImageIO.read(is); is.close(); @@ -208,7 +208,7 @@ public static void exportPngImageTooLarge(final WorldData biomeData, final Dimen } for (Identifier texture : allTextures) { try { - is = MinecraftClient.getInstance().getResourceManager().getResource(texture).getInputStream(); + is = MinecraftClient.getInstance().getResourceManager().getResource(texture).get().getInputStream(); BufferedImage tileImage = ImageIO.read(is); is.close(); textureImageMap.put(texture, tileImage); diff --git a/common/src/main/resources/antiqueatlas.accesswidener b/common/src/main/resources/antiqueatlas.accesswidener index 6a01429bb..ad099f681 100644 --- a/common/src/main/resources/antiqueatlas.accesswidener +++ b/common/src/main/resources/antiqueatlas.accesswidener @@ -1,5 +1,3 @@ accessWidener v1 named accessible field net/minecraft/world/ChunkRegion world Lnet/minecraft/server/world/ServerWorld; accessible field net/minecraft/structure/pool/SinglePoolElement location Lcom/mojang/datafixers/util/Either; -accessible method net/minecraft/world/biome/Biome getCategory (Lnet/minecraft/util/registry/RegistryEntry;)Lnet/minecraft/world/biome/Biome$Category; -accessible method net/minecraft/world/biome/Biome getCategory ()Lnet/minecraft/world/biome/Biome$Category; \ No newline at end of file diff --git a/common/src/main/resources/assets/antiqueatlas/models/item/antique_atlas.json b/common/src/main/resources/assets/antiqueatlas/models/item/antique_atlas.json index 34b83c3ea..e8ba905f8 100644 --- a/common/src/main/resources/assets/antiqueatlas/models/item/antique_atlas.json +++ b/common/src/main/resources/assets/antiqueatlas/models/item/antique_atlas.json @@ -1,7 +1,7 @@ { "parent": "item/generated", "textures": { - "layer0": "antiqueatlas:items/antique_atlas" + "layer0": "antiqueatlas:item/antique_atlas" }, "display": { "thirdperson": { diff --git a/common/src/main/resources/assets/antiqueatlas/models/item/empty_antique_atlas.json b/common/src/main/resources/assets/antiqueatlas/models/item/empty_antique_atlas.json index e635638a3..e91196b08 100644 --- a/common/src/main/resources/assets/antiqueatlas/models/item/empty_antique_atlas.json +++ b/common/src/main/resources/assets/antiqueatlas/models/item/empty_antique_atlas.json @@ -1,7 +1,7 @@ { "parent": "item/generated", "textures": { - "layer0": "antiqueatlas:items/empty_antique_atlas" + "layer0": "antiqueatlas:item/empty_antique_atlas" }, "display": { "thirdperson": { diff --git a/common/src/main/resources/assets/antiqueatlas/textures/items/antique_atlas.png b/common/src/main/resources/assets/antiqueatlas/textures/item/antique_atlas.png similarity index 100% rename from common/src/main/resources/assets/antiqueatlas/textures/items/antique_atlas.png rename to common/src/main/resources/assets/antiqueatlas/textures/item/antique_atlas.png diff --git a/common/src/main/resources/assets/antiqueatlas/textures/items/empty_antique_atlas.png b/common/src/main/resources/assets/antiqueatlas/textures/item/empty_antique_atlas.png similarity index 100% rename from common/src/main/resources/assets/antiqueatlas/textures/items/empty_antique_atlas.png rename to common/src/main/resources/assets/antiqueatlas/textures/item/empty_antique_atlas.png diff --git a/fabric/src/main/java/hunternif/mc/impl/atlas/client/fabric/TileTextureMapImpl.java b/fabric/src/main/java/hunternif/mc/impl/atlas/client/fabric/TileTextureMapImpl.java index f44df09f1..87afcf605 100644 --- a/fabric/src/main/java/hunternif/mc/impl/atlas/client/fabric/TileTextureMapImpl.java +++ b/fabric/src/main/java/hunternif/mc/impl/atlas/client/fabric/TileTextureMapImpl.java @@ -6,11 +6,11 @@ import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.tag.convention.v1.ConventionalBiomeTags; import net.minecraft.client.MinecraftClient; -import net.minecraft.tag.BiomeTags; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.registry.tag.BiomeTags; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryEntry; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.biome.Biome; import java.util.Optional; @@ -23,8 +23,7 @@ static public Optional guessFittingTextureSet(RegistryKey bio if (MinecraftClient.getInstance().world == null) return Optional.empty(); - RegistryEntry biomeTag = MinecraftClient.getInstance().world.getRegistryManager().get(Registry.BIOME_KEY).entryOf(biome); - + RegistryEntry.Reference biomeTag = MinecraftClient.getInstance().world.getRegistryManager().get(RegistryKeys.BIOME).entryOf(biome); if (biomeTag.isIn(ConventionalBiomeTags.SWAMP)) { if (biomeTag.isIn(BiomeTags.IS_HILL)) { return Optional.of(AntiqueAtlasMod.id("swamp_hills")); @@ -157,6 +156,6 @@ static public Optional guessFittingTextureSet(RegistryKey bio return Optional.of(AntiqueAtlasMod.id("mesa")); } - return TileTextureMap.guessFittingTextureSetFallback(biomeTag.value()); + return TileTextureMap.guessFittingTextureSetFallback(biomeTag); } } diff --git a/forge/build.gradle b/forge/build.gradle deleted file mode 100644 index 980e69799..000000000 --- a/forge/build.gradle +++ /dev/null @@ -1,130 +0,0 @@ -plugins { - id "com.github.johnrengelman.shadow" version "7.1.2" - id "me.shedaniel.unified-publishing" -} - -architectury { - platformSetupLoomIde() - forge() -} - -loom { - accessWidenerPath = project(":common").loom.accessWidenerPath - - forge { - convertAccessWideners = true - extraAccessWideners.add loom.accessWidenerPath.get().asFile.name - - mixinConfig "antiqueatlas-common.mixins.json" - mixinConfig "antiqueatlas.mixins.json" - } -} - - -configurations { - common - shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentForge.extendsFrom common -} - -dependencies { - forge "net.minecraftforge:forge:${rootProject.forge_version}" - - modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}" - modApi "me.shedaniel.cloth:cloth-config-forge:${rootProject.cloth_config_version}" - - common(project(path: ":common", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } -} - -processResources { - inputs.property "version", project.version - - filesMatching("META-INF/mods.toml") { - expand "version": project.version - } -} - -shadowJar { - exclude "fabric.mod.json" - exclude "architectury.common.json" - - configurations = [project.configurations.shadowCommon] - classifier "dev-shadow" -} - -remapJar { - input.set shadowJar.archiveFile - dependsOn shadowJar - classifier null -} - -jar { - classifier "dev" -} - -sourcesJar { - def commonSources = project(":common").sourcesJar - dependsOn commonSources - from commonSources.archiveFile.map { zipTree(it) } -} - -components.java { - withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { - skip() - } -} - -publishing { - publications { - mavenForge(MavenPublication) { - artifactId = rootProject.archives_base_name + "-" + project.name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - } -} - -unifiedPublishing { - project { - gameVersions = ["1.18.2"] - gameLoaders = ["forge"] - releaseType = "release" - - mainPublication tasks.remapJar - - relations { - depends { - curseforge = "cloth-config" - modrinth = "cloth-config" - } - depends { - curseforge = "architectury-api" - modrinth = "architectury-api" - } - } - - var cfToken = System.getenv("CF_TOKEN") - if (cfToken != null) { - curseforge { - token = cfToken - id = rootProject.curseforge_id - gameVersions.addAll "Java 17" - } - } - - var mrToken = System.getenv("MODRINTH_TOKEN") - if (mrToken != null) { - modrinth { - token = mrToken - id = rootProject.modrinth_id - } - } - } -} \ No newline at end of file diff --git a/forge/gradle.properties b/forge/gradle.properties deleted file mode 100644 index 32f842a63..000000000 --- a/forge/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -loom.platform=forge \ No newline at end of file diff --git a/forge/src/main/java/hunternif/mc/impl/atlas/client/forge/TileTextureMapImpl.java b/forge/src/main/java/hunternif/mc/impl/atlas/client/forge/TileTextureMapImpl.java deleted file mode 100644 index 45746be8b..000000000 --- a/forge/src/main/java/hunternif/mc/impl/atlas/client/forge/TileTextureMapImpl.java +++ /dev/null @@ -1,167 +0,0 @@ -package hunternif.mc.impl.atlas.client.forge; - -import hunternif.mc.impl.atlas.AntiqueAtlasMod; -import hunternif.mc.impl.atlas.client.TileTextureMap; -import net.minecraft.client.MinecraftClient; -import net.minecraft.tag.BiomeTags; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryEntry; -import net.minecraft.util.registry.RegistryKey; -import net.minecraft.world.biome.Biome; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.common.Tags; - -import java.util.Optional; - -@OnlyIn(Dist.CLIENT) -public class TileTextureMapImpl { - static public Optional guessFittingTextureSet(RegistryKey biome) { - if (MinecraftClient.getInstance().world == null) - return Optional.empty(); - - RegistryEntry biomeTag = MinecraftClient.getInstance().world.getRegistryManager().get(Registry.BIOME_KEY).entryOf(biome); - - if (biomeTag.isIn(Tags.Biomes.IS_END)) { -// if (biomeTag.isIn(Tags.Biomes.END) || biomeTag.isIn(ConventionalBiomeTags.VEGETATION_SPARSE)) { -// return Optional.of(AntiqueAtlasMod.id("end_island_plants")); -// } else { - return Optional.of(AntiqueAtlasMod.id("end_island")); -// } - } - - if (biomeTag.isIn(BiomeTags.IS_NETHER)) { - return Optional.of(AntiqueAtlasMod.id("soul_sand_valley")); - } - - if (biomeTag.isIn(Tags.Biomes.IS_VOID)) { - return Optional.of(AntiqueAtlasMod.id("end_void")); - } - - if (biomeTag.isIn(Tags.Biomes.IS_SWAMP)) { - if (biomeTag.isIn(BiomeTags.IS_HILL)) { - return Optional.of(AntiqueAtlasMod.id("swamp_hills")); - } else { - return Optional.of(AntiqueAtlasMod.id("swamp")); - } - } - - if (biomeTag.isIn(BiomeTags.IS_OCEAN) - || biomeTag.isIn(BiomeTags.IS_DEEP_OCEAN) - || biomeTag.isIn(BiomeTags.IS_RIVER) - || biomeTag.isIn(Tags.Biomes.IS_WATER)) { - if (biomeTag.isIn(Tags.Biomes.IS_COLD) || biomeTag.isIn(Tags.Biomes.IS_SNOWY)) - return Optional.of(AntiqueAtlasMod.id("ice")); - - return Optional.of(AntiqueAtlasMod.id("water")); - } - - if (biomeTag.isIn(BiomeTags.IS_BEACH) || biomeTag.isIn(Tags.Biomes.IS_BEACH)) { - return Optional.of(AntiqueAtlasMod.id("shore")); - } - - if (biomeTag.isIn(BiomeTags.IS_JUNGLE)) { - if (biomeTag.isIn(BiomeTags.IS_HILL)) { - return Optional.of(AntiqueAtlasMod.id("jungle_hills")); - } else { - return Optional.of(AntiqueAtlasMod.id("jungle")); - } - } - - if (biomeTag.isIn(Tags.Biomes.IS_SAVANNA)) { - return Optional.of(AntiqueAtlasMod.id("savana")); - } - - if (biomeTag.isIn((Tags.Biomes.IS_PLATEAU))) { - return Optional.of(AntiqueAtlasMod.id("plateau_mesa")); - } - - if (biomeTag.isIn(BiomeTags.IS_FOREST) - || biomeTag.isIn(Tags.Biomes.IS_DENSE) - || biomeTag.isIn(Tags.Biomes.IS_SPARSE) - ) { - if (biomeTag.isIn(Tags.Biomes.IS_COLD) || biomeTag.isIn(Tags.Biomes.IS_SNOWY)) { - if (biomeTag.isIn(BiomeTags.IS_HILL)) { - return Optional.of(AntiqueAtlasMod.id("snow_pines_hills")); - } else { - return Optional.of(AntiqueAtlasMod.id("snow_pines")); - } - } else { - if (biomeTag.isIn(BiomeTags.IS_HILL)) { - return Optional.of(AntiqueAtlasMod.id("forest_hills")); - } else { - return Optional.of(AntiqueAtlasMod.id("forest")); - } - } - } - - if (biomeTag.isIn(Tags.Biomes.IS_PLAINS)) { - if (biomeTag.isIn(Tags.Biomes.IS_COLD) - || biomeTag.isIn(Tags.Biomes.IS_SNOWY) - ) { - if (biomeTag.isIn(BiomeTags.IS_HILL)) { - return Optional.of(AntiqueAtlasMod.id("snow_hills")); - } else { - return Optional.of(AntiqueAtlasMod.id("snow")); - } - } else { - if (biomeTag.isIn(BiomeTags.IS_HILL)) { - return Optional.of(AntiqueAtlasMod.id("hills")); - } else { - return Optional.of(AntiqueAtlasMod.id("plains")); - } - } - } - - if (biomeTag.isIn(Tags.Biomes.IS_COLD)) { - if (biomeTag.isIn(BiomeTags.IS_HILL)) { - return Optional.of(AntiqueAtlasMod.id("mountains_snow_caps")); - } else { - return Optional.of(AntiqueAtlasMod.id("ice_spikes")); - } - } - - if (biomeTag.isIn(Tags.Biomes.IS_HOT)) { - if (biomeTag.isIn(BiomeTags.IS_HILL)) { - return Optional.of(AntiqueAtlasMod.id("desert_hills")); - } else { - return Optional.of(AntiqueAtlasMod.id("desert")); - } - } - -// if (biomeTag.isIn(Tags.Biomes.TAIGA)) { -// return Optional.of(AntiqueAtlasMod.id("snow")); -// } - -// if (biomeTag.isIn(Tags.Biomes.EXTREME_HILLS)) { -// return Optional.of(AntiqueAtlasMod.id("hills")); -// } - - if (biomeTag.isIn(Tags.Biomes.IS_SLOPE)) { - return Optional.of(AntiqueAtlasMod.id("mountains")); - } - - if (biomeTag.isIn(Tags.Biomes.IS_PEAK)) { - return Optional.of(AntiqueAtlasMod.id("mountains_snow_caps")); - } - - if (biomeTag.isIn(Tags.Biomes.IS_MUSHROOM)) { - return Optional.of(AntiqueAtlasMod.id("mushroom")); - } - - if (biomeTag.isIn(BiomeTags.IS_BADLANDS)) { - return Optional.of(AntiqueAtlasMod.id("mesa")); - } - - if (biomeTag.isIn(BiomeTags.IS_HILL)) { - return Optional.of(AntiqueAtlasMod.id("hills")); - } - - if (biomeTag.isIn(Tags.Biomes.IS_UNDERGROUND)) { - AntiqueAtlasMod.LOG.warn("Underground biomes aren't supported yet."); - } - - return TileTextureMap.guessFittingTextureSetFallback(biomeTag.value()); - } -} diff --git a/forge/src/main/java/hunternif/mc/impl/atlas/client/gui/forge/AntiqueAtlasConfigMenu.java b/forge/src/main/java/hunternif/mc/impl/atlas/client/gui/forge/AntiqueAtlasConfigMenu.java deleted file mode 100644 index 5433d7c14..000000000 --- a/forge/src/main/java/hunternif/mc/impl/atlas/client/gui/forge/AntiqueAtlasConfigMenu.java +++ /dev/null @@ -1,17 +0,0 @@ -package hunternif.mc.impl.atlas.client.gui.forge; - -import hunternif.mc.impl.atlas.AntiqueAtlasConfig; -import me.shedaniel.autoconfig.AutoConfig; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.ConfigGuiHandler; -import net.minecraftforge.fml.ModLoadingContext; - -@OnlyIn(Dist.CLIENT) -public class AntiqueAtlasConfigMenu { - public static void init() { - ModLoadingContext.get().registerExtensionPoint(ConfigGuiHandler.ConfigGuiFactory.class, - () -> new ConfigGuiHandler.ConfigGuiFactory((mc, parent) -> AutoConfig.getConfigScreen(AntiqueAtlasConfig.class, parent).get()) - ); - } -} diff --git a/forge/src/main/java/hunternif/mc/impl/atlas/forge/AntiqueAtlasModForge.java b/forge/src/main/java/hunternif/mc/impl/atlas/forge/AntiqueAtlasModForge.java deleted file mode 100644 index 8850084ba..000000000 --- a/forge/src/main/java/hunternif/mc/impl/atlas/forge/AntiqueAtlasModForge.java +++ /dev/null @@ -1,29 +0,0 @@ -package hunternif.mc.impl.atlas.forge; - -import dev.architectury.platform.Platform; -import dev.architectury.platform.forge.EventBuses; -import dev.architectury.utils.Env; -import hunternif.mc.impl.atlas.AntiqueAtlasMod; -import hunternif.mc.impl.atlas.AntiqueAtlasModClient; -import hunternif.mc.impl.atlas.client.gui.forge.AntiqueAtlasConfigMenu; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; - -@Mod(AntiqueAtlasMod.ID) -public class AntiqueAtlasModForge -{ - public AntiqueAtlasModForge() - { - // Submit our event bus to let architectury register our content on the right time - EventBuses.registerModEventBus(AntiqueAtlasMod.ID, - FMLJavaModLoadingContext.get().getModEventBus()); - - AntiqueAtlasMod.init(); - - if (Platform.getEnvironment() == Env.CLIENT) - { - AntiqueAtlasModClient.init(); - AntiqueAtlasConfigMenu.init(); - } - } -} diff --git a/forge/src/main/java/hunternif/mc/impl/atlas/mixin/forge/VolatileMixinPluginImpl.java b/forge/src/main/java/hunternif/mc/impl/atlas/mixin/forge/VolatileMixinPluginImpl.java deleted file mode 100644 index 7e5d0e257..000000000 --- a/forge/src/main/java/hunternif/mc/impl/atlas/mixin/forge/VolatileMixinPluginImpl.java +++ /dev/null @@ -1,10 +0,0 @@ -package hunternif.mc.impl.atlas.mixin.forge; - -import net.minecraftforge.fml.loading.FMLEnvironment; - -public class VolatileMixinPluginImpl -{ - public static boolean isDevelopmentEnvironment() { - return !FMLEnvironment.production; - } -} \ No newline at end of file diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml deleted file mode 100644 index 14901023a..000000000 --- a/forge/src/main/resources/META-INF/mods.toml +++ /dev/null @@ -1,44 +0,0 @@ -modLoader="javafml" -loaderVersion="[40,)" -license="GNU GENERAL PUBLIC LICENSE" -issueTrackerURL="https://github.com/AntiqueAtlasTeam/AntiqueAtlas/issues" - -[[mods]] -modId="antiqueatlas" -version="${version}" -logoFile="antiqueatlas_icon.png" -displayName="Antique Atlas" -displayURL="https://www.curseforge.com/minecraft/mc-mods/antique-atlas" -credits="Hunternif, Kenkron, osipxd, thecodewarrior, TehNut, crafteverywhere, coolAlias, Ruukas97, Mazdallier, chesterccj305, asiekierka, sam-kirby, esotericist, dadodollabela, Yulife, Waterrail, The-Fireplace, TBM13, Rikshy, GirafiStudios, DrCopernicus, DBotThePony, AugiteSoul, Stereowalker" -authors="Hunternif, tyra314" -description=''' -Antique Atlas is a book that acts like a map featuring infinite scrolling, zoom and custom labeled markers. The map is generated around the player by calculating the average biome in each 16x16 chunk. -''' - -[[dependencies.antiqueatlas]] -modId="forge" -mandatory=true -versionRange="[40,)" -ordering="NONE" -side="BOTH" - -[[dependencies.antiqueatlas]] -modId="minecraft" -mandatory=true -versionRange="[1.18.2,)" -ordering="NONE" -side="BOTH" - -[[dependencies.antiqueatlas]] -modId="cloth_config" -mandatory=true -versionRange="[6.2.62,)" -ordering="NONE" -side="BOTH" - -[[dependencies.antiqueatlas]] -modId = "architectury" -mandatory = true -versionRange = "[4.10.86,)" -ordering = "AFTER" -side = "BOTH" diff --git a/forge/src/main/resources/antiqueatlas.mixins.json b/forge/src/main/resources/antiqueatlas.mixins.json deleted file mode 100644 index dc4307faf..000000000 --- a/forge/src/main/resources/antiqueatlas.mixins.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "required": true, - "package": "hunternif.mc.impl.atlas.mixin.forge", - "compatibilityLevel": "JAVA_17", - "mixins": [ - ], - "client": [ - ], - "injectors": { - "defaultRequire": 1 - }, - "minVersion": "0.1" -} diff --git a/forge/src/main/resources/pack.mcmeta b/forge/src/main/resources/pack.mcmeta deleted file mode 100644 index ee944f39b..000000000 --- a/forge/src/main/resources/pack.mcmeta +++ /dev/null @@ -1,6 +0,0 @@ -{ - "pack": { - "description": "AntiqueAtlas", - "pack_format": 8 - } -} diff --git a/gradle.properties b/gradle.properties index 47cbc2d67..7760c6da4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,23 +2,18 @@ org.gradle.jvmargs=-Xmx2G # Fabric Properties -minecraft_version = 1.18.2 -yarn_mappings = 1.18.2+build.4 -fabric_loader_version = 0.14.17 -forge_version = 1.18.2-40.2.0 -enabled_platforms = fabric,forge +minecraft_version = 1.20.1 +yarn_mappings = 1.20.1+build.10 +fabric_loader_version = 0.14.22 +enabled_platforms = fabric # Mod Properties -mod_version = 7.1.0 +mod_version = 7.1.1 maven_group = hunternif.mc.atlas archives_base_name = antiqueatlas # Dependencies -architectury_version = 4.11.89 -cloth_config_version = 6.4.90 -fabric_api_version = 0.76.0+1.18.2 -mod_menu_version = 3.2.3 - -# Publishing -curseforge_id = 227795 -modrinth_id = wHODup9j \ No newline at end of file +architectury_version = 9.1.12 +cloth_config_version = 11.1.106 +fabric_api_version = 0.88.1+1.20.1 +mod_menu_version = 7.2.2 \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 7a04630a0..8ff3af5a0 100644 --- a/settings.gradle +++ b/settings.gradle @@ -13,6 +13,5 @@ if (JavaVersion.current().ordinal() + 1 < 17) { include("common") include("fabric") -include("forge") rootProject.name = "antiqueatlas"