diff --git a/build.gradle b/build.gradle index 0f80c16c7..659b15ea8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id "architectury-plugin" version "3.4-SNAPSHOT" - id "dev.architectury.loom" version "0.12.0-SNAPSHOT" apply false + id "dev.architectury.loom" version "1.1.+" apply false id "me.shedaniel.unified-publishing" version "0.1.+" id "maven-publish" } diff --git a/common/src/main/java/hunternif/mc/api/AtlasAPI.java b/common/src/main/java/hunternif/mc/api/AtlasAPI.java index a4a6de5d7..4a3c1e0ac 100644 --- a/common/src/main/java/hunternif/mc/api/AtlasAPI.java +++ b/common/src/main/java/hunternif/mc/api/AtlasAPI.java @@ -8,7 +8,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; +import net.minecraft.registry.Registries; 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/AntiqueAtlasMod.java b/common/src/main/java/hunternif/mc/impl/atlas/AntiqueAtlasMod.java index 31fc69fc9..c7b732118 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/AntiqueAtlasMod.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/AntiqueAtlasMod.java @@ -6,8 +6,7 @@ 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.core.scanning.WorldScanner; import hunternif.mc.impl.atlas.event.RecipeCraftedCallback; import hunternif.mc.impl.atlas.event.RecipeCraftedHandler; import hunternif.mc.impl.atlas.item.AntiqueAtlasItems; @@ -55,8 +54,6 @@ public static AtlasIdData getAtlasIdData(World world) { } public static void init() { - 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..630a2058e 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,15 +62,15 @@ 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()); } 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..bc6f9e3f8 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 @@ -13,7 +13,7 @@ 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.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..bd1ad71f3 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. @@ -148,7 +147,7 @@ private void drawPlayer(VertexConsumerProvider buffer, MatrixStack matrices, int matrices.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.multiply(new Quaternionf(RotationAxis.POSITIVE_Z.rotationDegrees(this.player.getHeadYaw() + 180))); matrices.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); 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..99bb28ce0 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", id -> id.toString().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..90337e1d9 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 @@ -13,6 +13,7 @@ import net.minecraft.util.Identifier; import net.minecraft.util.profiler.Profiler; +import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.*; @@ -40,14 +41,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", id -> id.toString().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).orElseThrow(IOException::new); 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..5c18e13f7 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 @@ -3,7 +3,7 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import hunternif.mc.impl.atlas.AntiqueAtlasMod; -import hunternif.mc.impl.atlas.core.scaning.TileHeightType; +import hunternif.mc.impl.atlas.core.scanning.TileHeightType; import hunternif.mc.impl.atlas.resource.ResourceReloadListener; import hunternif.mc.impl.atlas.util.Log; import net.fabricmc.api.EnvType; @@ -13,6 +13,7 @@ import net.minecraft.util.Identifier; import net.minecraft.util.profiler.Profiler; +import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Collection; @@ -45,11 +46,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", id -> id.toString().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).orElseThrow(IOException::new); 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..b7ee0cc2f 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 @@ -3,16 +3,17 @@ import dev.architectury.injectables.annotations.ExpectPlatform; import hunternif.mc.impl.atlas.AntiqueAtlasMod; import hunternif.mc.impl.atlas.client.texture.ITexture; -import hunternif.mc.impl.atlas.core.scaning.TileHeightType; +import hunternif.mc.impl.atlas.core.scanning.TileHeightType; 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.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.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; @@ -91,50 +92,257 @@ public void autoRegister(Identifier id, RegistryKey biome) { } } - @ExpectPlatform static private Optional guessFittingTextureSet(RegistryKey biome) { - throw new AssertionError("Not implemented"); - } - - static public Optional guessFittingTextureSetFallback(Biome biome) { - 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"); - case BEACH -> AntiqueAtlasMod.id("shore"); - case JUNGLE -> AntiqueAtlasMod.id("jungle"); - case SAVANNA -> AntiqueAtlasMod.id("savanna"); - case MESA -> AntiqueAtlasMod.id("plateau_mesa"); - case FOREST -> - biome.getPrecipitation() == Biome.Precipitation.SNOW ? AntiqueAtlasMod.id("snow_pines") : AntiqueAtlasMod.id("forest"); - case PLAINS -> - biome.getPrecipitation() == Biome.Precipitation.SNOW ? AntiqueAtlasMod.id("snow") : AntiqueAtlasMod.id("plains"); - case ICY -> AntiqueAtlasMod.id("ice_spikes"); - case DESERT -> AntiqueAtlasMod.id("desert"); - case TAIGA -> AntiqueAtlasMod.id("snow"); - case EXTREME_HILLS -> AntiqueAtlasMod.id("hills"); - case MOUNTAIN -> AntiqueAtlasMod.id("mountains"); - case THEEND -> { - List> features = biome.getGenerationSettings().getFeatures(); - PlacedFeature chorus_plant_feature = BuiltinRegistries.PLACED_FEATURE.get(new Identifier("chorus_plant")); - assert chorus_plant_feature != null; - boolean has_chorus_plant = features.stream().anyMatch(entries -> entries.stream().anyMatch(feature -> feature.value() == chorus_plant_feature)); - if (has_chorus_plant) { - yield AntiqueAtlasMod.id("end_island_plants"); + if (MinecraftClient.getInstance().world == null) + return Optional.empty(); + + RegistryEntry biomeTag = MinecraftClient.getInstance().world.getRegistryManager().get(RegistryKeys.BIOME).entryOf(biome); + + if (biomeIsVoid(biomeTag)) { + return Optional.of(AntiqueAtlasMod.id("end_void")); + } + + if (biomeTag.isIn(BiomeTags.IS_END) || biomeIsEnd(biomeTag)) { + if (biomeHasVegetation(biomeTag)) { + return Optional.of(AntiqueAtlasMod.id("end_island_plants")); + } else { + return Optional.of(AntiqueAtlasMod.id("end_island")); + } + } + + if (biomeTag.isIn(BiomeTags.IS_NETHER) || biomeIsNether(biomeTag)) { + return Optional.of(AntiqueAtlasMod.id("soul_sand_valley")); + } + + if (biomeIsSwamp(biomeTag)) { + 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) + || biomeIsWater(biomeTag)) { + if (biomeIsIcy(biomeTag)) + return Optional.of(AntiqueAtlasMod.id("ice")); + + return Optional.of(AntiqueAtlasMod.id("water")); + } + + if (biomeTag.isIn(BiomeTags.IS_BEACH) || biomeIsShore(biomeTag)) { + return Optional.of(AntiqueAtlasMod.id("shore")); + } + + if (biomeTag.isIn(BiomeTags.IS_JUNGLE) || biomeIsJungle(biomeTag)) { + if (biomeTag.isIn(BiomeTags.IS_HILL)) { + return Optional.of(AntiqueAtlasMod.id("jungle_hills")); + } else { + return Optional.of(AntiqueAtlasMod.id("jungle")); + } + } + + if (biomeTag.isIn(BiomeTags.IS_SAVANNA) || biomeIsSavanna(biomeTag)) { + return Optional.of(AntiqueAtlasMod.id("savana")); + } + + if (biomeTag.isIn(BiomeTags.IS_BADLANDS) || biomeIsBadlands(biomeTag)) { + if (biomeIsPlateau(biomeTag)) { // Is this still valid? Does height checking supersede this? + return Optional.of(AntiqueAtlasMod.id("plateau_mesa")); + } else { + return Optional.of(AntiqueAtlasMod.id("mesa")); + } + } + + if (biomeTag.isIn(BiomeTags.IS_FOREST) || biomeIsForest(biomeTag)) { + if (biomeIsIcy(biomeTag) || biomeIsSnowy(biomeTag)) { + 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 { - yield AntiqueAtlasMod.id("end_island"); + return Optional.of(AntiqueAtlasMod.id("forest")); } } - case MUSHROOM -> AntiqueAtlasMod.id("mushroom"); - case NETHER -> AntiqueAtlasMod.id("soul_sand_valley"); - case NONE -> AntiqueAtlasMod.id("end_void"); - case UNDERGROUND -> { - Log.warn("Underground biomes aren't supported yet."); - yield null; + } + + if (biomeIsPlains(biomeTag)) { + if (biomeIsIcy(biomeTag) || biomeIsSnowy(biomeTag)) { + 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 (biomeIsIcy(biomeTag)) { + if (biomeTag.isIn(BiomeTags.IS_HILL)) { + return Optional.of(AntiqueAtlasMod.id("mountains_snow_caps")); + } else { + return Optional.of(AntiqueAtlasMod.id("ice_spikes")); } - }; + } + + if (biomeIsDesert(biomeTag)) { + if (biomeTag.isIn(BiomeTags.IS_HILL)) { + return Optional.of(AntiqueAtlasMod.id("desert_hills")); + } else { + return Optional.of(AntiqueAtlasMod.id("desert")); + } + } + + if (biomeTag.isIn(BiomeTags.IS_TAIGA) || biomeIsTaiga(biomeTag)) { // should this be any snowy biome as a fallback? + return Optional.of(AntiqueAtlasMod.id("snow")); + } + + if (biomeIsExtremeHills(biomeTag)) { + return Optional.of(AntiqueAtlasMod.id("hills")); + } + + if (biomeIsPeak(biomeTag)) { + return Optional.of(AntiqueAtlasMod.id("mountains_snow_caps")); + } + + if (biomeTag.isIn(BiomeTags.IS_MOUNTAIN) || biomeIsMountain(biomeTag)) { + return Optional.of(AntiqueAtlasMod.id("mountains")); + } + + if (biomeIsMushroom(biomeTag)) { + return Optional.of(AntiqueAtlasMod.id("mushroom")); + } + + if (biomeTag.isIn(BiomeTags.IS_HILL)) { + return Optional.of(AntiqueAtlasMod.id("hills")); + } - return Optional.ofNullable(texture_set); + if (biomeIsUnderground(biomeTag)) { + AntiqueAtlasMod.LOG.warn("Underground biomes aren't supported yet."); + } + + return Optional.empty(); + } + + @ExpectPlatform + public static boolean biomeIsVoid(RegistryEntry biomeTag) { + return false; + } + + @ExpectPlatform + public static boolean biomeIsEnd(RegistryEntry biomeTag) { + return false; + } + + @ExpectPlatform + public static boolean biomeHasVegetation(RegistryEntry biomeTag) { + return false; + } + + @ExpectPlatform + public static boolean biomeIsNether(RegistryEntry biomeTag) { + return false; + } + + @ExpectPlatform + public static boolean biomeIsSwamp(RegistryEntry biomeTag) { + return false; + } + + @ExpectPlatform + public static boolean biomeIsWater(RegistryEntry biomeTag) { + return false; + } + + @ExpectPlatform + public static boolean biomeIsIcy(RegistryEntry biomeTag) { + return false; + } + + @ExpectPlatform + public static boolean biomeIsShore(RegistryEntry biomeTag) { + return false; + } + + @ExpectPlatform + public static boolean biomeIsJungle(RegistryEntry biomeTag) { + return false; + } + + @ExpectPlatform + public static boolean biomeIsSavanna(RegistryEntry biomeTag) { + return false; + } + + @ExpectPlatform + public static boolean biomeIsPlateau(RegistryEntry biomeTag) { + return false; + } + + @ExpectPlatform + public static boolean biomeIsBadlands(RegistryEntry biomeTag) { + return false; + } + + @ExpectPlatform + public static boolean biomeIsForest(RegistryEntry biomeTag) { + return false; + } + + @ExpectPlatform + public static boolean biomeIsSnowy(RegistryEntry biomeTag) { + return false; + } + + @ExpectPlatform + public static boolean biomeIsPlains(RegistryEntry biomeTag) { + return false; + } + + @ExpectPlatform + public static boolean biomeIsDesert(RegistryEntry biomeTag) { + return false; + } + + @ExpectPlatform + public static boolean biomeIsTaiga(RegistryEntry biomeTag) { + return false; + } + + @ExpectPlatform + public static boolean biomeIsExtremeHills(RegistryEntry biomeTag) { + return false; + } + + @ExpectPlatform + public static boolean biomeIsPeak(RegistryEntry biomeTag) { + return false; + } + + @ExpectPlatform + public static boolean biomeIsMountain(RegistryEntry biomeTag) { + return false; + } + + @ExpectPlatform + public static boolean biomeIsMushroom(RegistryEntry biomeTag) { + return false; + } + + @ExpectPlatform + public static boolean biomeIsUnderground(RegistryEntry biomeTag) { + return false; } 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..c74f0cc4a 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 context, 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); + context.drawText(font, l.header, (int) ((x) * s - headerWidth / 2F), (y) * s - 14, 0xffffff, false); int statusWidth = font.getWidth(l.status); - font.draw(matrices, l.status, (x) * s - statusWidth / 2F, (y) * s, 0xffffff); + context.drawText(font, l.status, (int) ((x) * s - statusWidth / 2F), (y) * s, 0xffffff, false); y += 7; @@ -42,8 +39,6 @@ public void draw(MatrixStack matrices, int scaledWidth, int scaledHeight) { if (l.maxProgress < 0) p = 0; - RenderSystem.disableTexture(); - Tessellator tessellator = Tessellator.getInstance(); BufferBuilder vb = tessellator.getBuffer(); @@ -60,7 +55,5 @@ public void draw(MatrixStack matrices, int scaledWidth, int scaledHeight) { vb.vertex(x + barWidth * p, y, 0).color(0.5f, 1, 0.5f, 1).next(); tessellator.draw(); - - 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..fc19f0c1f 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 context, int mouseX, int mouseY, float partialTick) { RenderSystem.enableBlend(); RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); @@ -81,7 +81,7 @@ 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); + Textures.BTN_ARROWS.draw(context, 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..70c291ae2 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 @@ -21,7 +21,7 @@ import hunternif.mc.impl.atlas.registry.MarkerType; import hunternif.mc.impl.atlas.util.*; 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; @@ -30,14 +30,11 @@ 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 +90,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 +337,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 +351,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 +385,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 +396,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 +481,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 +886,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 context, int mouseX, int mouseY, float par3) { long currentMillis = System.currentTimeMillis(); long deltaMillis = currentMillis - lastUpdateMillis; lastUpdateMillis = currentMillis; @@ -907,13 +903,13 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float par3) { } } - super.renderBackground(matrices); + super.renderBackground(context); 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(context, getGuiX(), getGuiY()); if ((stack == null && AntiqueAtlasMod.CONFIG.itemNeeded) || biomeData == null) return; @@ -942,8 +938,8 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float par3) { tiles.setScope(new Rect(mapStartX, mapStartZ, mapEndX, mapEndZ)); tiles.setStep(tile2ChunkScale); - matrices.push(); - matrices.translate(mapStartScreenX, mapStartScreenY, 0); + context.getMatrices().push(); + context.getMatrices().translate(mapStartScreenX, mapStartScreenY, 0); for (SubTileQuartet subtiles : tiles) { for (SubTile subtile : subtiles) { @@ -952,12 +948,12 @@ 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(context, subtile, tileHalfSize); } } } - matrices.pop(); + context.getMatrices().pop(); int markersStartX = MathUtil.roundToBase(mapStartX, MarkersData.CHUNK_STEP) / MarkersData.CHUNK_STEP - 1; int markersStartZ = MathUtil.roundToBase(mapStartZ, MarkersData.CHUNK_STEP) / MarkersData.CHUNK_STEP - 1; @@ -966,27 +962,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(context, getGuiX(), getGuiY()); double iconScale = getIconScale(); // Draw global markers: - renderMarkers(matrices, markersStartX, markersStartZ, markersEndX, markersEndZ, globalMarkersData); - renderMarkers(matrices, markersStartX, markersStartZ, markersEndX, markersEndZ, localMarkersData); + renderMarkers(context, markersStartX, markersStartZ, markersEndX, markersEndZ, globalMarkersData); + renderMarkers(context, markersStartX, markersStartZ, markersEndX, markersEndZ, localMarkersData); RenderSystem.disableScissor(); - Textures.BOOK_FRAME_NARROW.draw(matrices, getGuiX(), getGuiY()); + Textures.BOOK_FRAME_NARROW.draw(context, getGuiX(), getGuiY()); - renderScaleOverlay(matrices, deltaMillis); + renderScaleOverlay(context, deltaMillis); // Draw player icon: if (!state.is(HIDING_MARKERS)) { - renderPlayer(matrices, iconScale); + renderPlayer(context, iconScale); } // Draw buttons: - super.render(matrices, mouseX, mouseY, par3); + super.render(context, mouseX, mouseY, par3); // Draw the semi-transparent marker attached to the cursor when placing a new marker: RenderSystem.enableBlend(); @@ -996,7 +992,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(context, mouseX + renderInfo.x, mouseY + renderInfo.y); RenderSystem.setShaderColor(1, 1, 1, 1); } RenderSystem.disableBlend(); @@ -1012,26 +1008,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(context); + progressBar.draw(context, (width - 100) / 2, height / 2 - 34); } } - private void renderPlayer(MatrixStack matrices, double iconScale) { + private void renderPlayer(DrawContext context, double iconScale) { int playerOffsetX = worldXToScreenX(player.getBlockX()); int playerOffsetY = worldZToScreenY(player.getBlockZ()); @@ -1042,12 +1038,13 @@ 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(context, 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 context, long deltaMillis) { + MatrixStack matrices = context.getMatrices(); if (scaleAlpha > 3) { matrices.push(); matrices.translate(getGuiX() + WIDTH - 13, getGuiY() + 12, 0); @@ -1060,7 +1057,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); + context.drawText(this.textRenderer, text, -textWidth, 0, color, false); text = zoomNames[zoomLevel]; if (text.contains("/")) { @@ -1069,16 +1066,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); + context.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); + context.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); + context.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); + context.drawText(this.textRenderer, text, -textWidth - xWidth + 1, 2, color, false); } matrices.pop(); @@ -1097,7 +1094,7 @@ private void renderScaleOverlay(MatrixStack matrices, long deltaMillis) { } } - private void renderMarkers(MatrixStack matrices, int markersStartX, int markersStartZ, + private void renderMarkers(DrawContext context, int markersStartX, int markersStartZ, int markersEndX, int markersEndZ, DimensionMarkersData markersData) { if (markersData == null) return; @@ -1106,13 +1103,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(context, marker, getIconScale()); } } } } - private void renderMarker(MatrixStack matrices, Marker marker, double scale) { + private void renderMarker(DrawContext context, Marker marker, double scale) { MarkerType type = MarkerType.REGISTRY.get(marker.getType()); if (type.shouldHide(state.is(HIDING_MARKERS), scaleClipIndex)) { return; @@ -1167,11 +1164,11 @@ 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(context, markerX + info.x, markerY + info.y, info.width, info.height); RenderSystem.setShaderColor(1, 1, 1, 1); - if (isMouseOver && mouseIsOverMarker && marker.getLabel().getString().length() > 0) { + if (isMouseOver && mouseIsOverMarker && !marker.getLabel().getString().isEmpty()) { drawTooltip(Collections.singletonList(marker.getLabel()), textRenderer); } } @@ -1226,8 +1223,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..c28f5477b 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 context, 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(context, getGuiX(), getGuiY(), u, v, WIDTH, HEIGHT); // Render the icon: - iconTexture.draw(matrices, getGuiX() + (isMouseOver || isSelected() ? 3 : 2), getGuiY() + 1); + iconTexture.draw(context, 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..a90f1db63 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 context, 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(context, getGuiX(), getGuiY(), u, v, WIDTH, HEIGHT); // Render the icon: - iconTexture.draw(matrices, getGuiX() - (isMouseOver ? 3 : 2), getGuiY()-3, 24,24); + iconTexture.draw(context, 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..b89440ed0 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,13 +86,14 @@ 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.translatable("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.translatable("gui.antiqueatlas.marker.label")); textField.setEditable(true); - textField.setText(""); + textField.setFocusUnlocked(true); + textField.setFocused(true); scroller = new GuiScrollingContainer(); scroller.setWheelScrollsHorizontally(); @@ -133,7 +132,7 @@ public void init() { } public void setMarkerName(Text name) { - textField.setText(name.asString()); + textField.setText(name.getString()); } @Override @@ -160,18 +159,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 context, int mouseX, int mouseY, float partialTick) { + this.renderBackground(context); + drawCentered(context, Text.translatable("gui.antiqueatlas.marker.label"), this.height / 2 - 97, 0xffffff, true); + textField.render(context, mouseX, mouseY, partialTick); + drawCentered(context, 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, + context.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(context, 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..868927cdd 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 context, 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(context, getGuiX() + 1, getGuiY() + 1); ITexture texture = markerType.getTexture(); if (texture != null) { - texture.draw(matrices, getGuiX() + 1, getGuiY() + 1); + texture.draw(context, getGuiX() + 1, getGuiY() + 1); } - super.render(matrices, mouseX, mouseY, partialTick); + super.render(context, 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..02417b0fe 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 context, int mouseX, int mouseY, float partialTick) { if (isEnabled()) { RenderSystem.enableBlend(); RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); @@ -31,12 +31,12 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTi RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 0.5F); } - Textures.BTN_POSITION.draw(matrices, x, y, WIDTH, HEIGHT); + Textures.BTN_POSITION.draw(context, x, y, WIDTH, HEIGHT); 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..c8cc1730d 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 context, int mouseX, int mouseY, float partialTick) { ITexture texture = getTexture(); if (texture == null) return; - texture.draw(matrices, getGuiX(), getGuiY()); + texture.draw(context, 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..105bf47e8 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,19 @@ 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 context, 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); + context.drawText(this.textRenderer, l.header, (int) (x + (barWidth - headerWidth) / 2F), y - 14, 0xffffff, false); int statusWidth = this.textRenderer.getWidth(l.status); - this.textRenderer.draw(matrices, l.status, x + (barWidth - statusWidth) / 2F, y, 0xffffff); + context.drawText(this.textRenderer, l.status, (int) (x + (barWidth - statusWidth) / 2F), y, 0xffffff, false); y += 14; double p = l.currentProgress / l.maxProgress; if (l.maxProgress < 0) p = 0; - RenderSystem.disableTexture(); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder vb = tessellator.getBuffer(); @@ -66,8 +63,6 @@ public void draw(MatrixStack matrices, int x, int y) { vb.vertex(x + barWidth * p, y, 0).color(0.5f, 1, 0.5f, 1).next(); tessellator.draw(); - - 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..8179d64d0 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 context, int mouseX, int mouseY, float partialTick) { // Don't draw the anchor if there's nothing to scroll: if (!visible) { isDragged = false; @@ -193,12 +192,11 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTi / (float) (getScrollbarLength() - anchorSize)); } - 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(context); RenderSystem.disableBlend(); } @@ -232,7 +230,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 context); 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..5f39f12e2 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,13 +2,13 @@ import com.mojang.blaze3d.systems.RenderSystem; import hunternif.mc.impl.atlas.client.texture.ITexture; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import org.lwjgl.opengl.GL11; /** * Displays a texture that changes alpha at regular intervals. * By default the texture file is assumed to be full image, but that behavior - * can be altered by overriding the method {@link #drawImage(MatrixStack)}. + * can be altered by overriding the method {@link #drawImage(DrawContext)}. * * @author Hunternif */ @@ -51,7 +51,7 @@ public void setInvisibleAlpha(float invisibleAlpha) { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTick) { + public void render(DrawContext context, int mouseX, int mouseY, float partialTick) { long currentTime = System.currentTimeMillis(); if (lastTickTime + blinkTime < currentTime) { lastTickTime = currentTime; @@ -61,13 +61,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(context); RenderSystem.disableBlend(); RenderSystem.setShaderColor(1,1,1,1); } - private void drawImage(MatrixStack matrices) { - texture.draw(matrices, getGuiX(), getGuiY(), getWidth(), getHeight()); + private void drawImage(DrawContext context) { + texture.draw(context, 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..d49044475 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,8 @@ 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 +74,7 @@ interface UiCall { // TODO public GuiComponent() { - super(new LiteralText("component")); + super(Text.literal("component")); } /** @@ -411,16 +410,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 partialTick) { + super.render(context, mouseX, mouseY, partialTick); for (GuiComponent child : children) { if (!child.isClipped) { - child.render(matrices, mouseX, mouseY, partialTick); + child.render(context, mouseX, mouseY, partialTick); } } // 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,15 +553,10 @@ 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 context, 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; - + context.drawTooltip(font, lines, (int) x, (int) y); if (stencilEnabled) GL11.glEnable(GL11.GL_STENCIL_TEST); } @@ -581,7 +575,7 @@ private GuiComponent getTopLevelParent() { /** * Draws a text tooltip at mouse coordinates. *

- * Same as {@link #drawHoveringText2(MatrixStack, List, double, double, TextRenderer)}, but + * Same as {@link #drawHoveringText2(DrawContext, List, double, double, TextRenderer)}, but * the text is drawn on the top level parent component, after all its child * components have finished drawing. This allows the hovering text to be * unobscured by other components. @@ -638,13 +632,9 @@ 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 context, 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); - } else { - this.textRenderer.draw(matrices, text, (float) (this.width - length) / 2, y, color); - } + context.drawText(textRenderer, text, (this.width - length) / 2, y, color, dropShadow); } protected double getMouseX() { 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..79cce5641 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 context, int mouseX, int mouseY, float partialTick) { + texture.draw(context, 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..41df081f0 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 context) { // Draw left cap: - texture.draw(matrices, getGuiX() + anchorPos, getGuiY(), capLength, textureHeight, 0, 0, capLength, textureHeight); + texture.draw(context, 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(context, 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(context, 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..81bfe96a1 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 context) { // Draw top cap: - texture.draw(matrices, getGuiX(), getGuiY() + anchorPos, textureWidth, capLength, 0, 0, textureWidth, capLength); + texture.draw(context, 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(context, 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(context, 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..265bfca50 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,13 +52,13 @@ public void init() { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float par3) { + public void render(DrawContext context, 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)); // Draw the content (child GUIs): - super.render(matrices, mouseX, mouseY, par3); + super.render(context, mouseX, mouseY, par3); RenderSystem.disableScissor(); } 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..39cb71cf7 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 @@ -33,48 +33,57 @@ public ATexture(Identifier texture, boolean autobind) { this.LAYER = RenderLayer.getText(texture); } + @Override public Identifier getTexture() { return texture; } + @Override public void bind() { RenderSystem.setShaderTexture(0, texture); } - public void draw(MatrixStack matrices, int x, int y) { - draw(matrices, x, y, width(), height()); + @Override + public void draw(DrawContext context, int x, int y) { + draw(context, 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()); + @Override + public void draw(DrawContext context, int x, int y, int width, int height) { + draw(context, 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); + @Override + public void draw(DrawContext context, int x, int y, int u, int v, int regionWidth, int regionHeight) { + draw(context, 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) { + @Override + public void draw(DrawContext context, 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()); + context.drawTexture(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) { - matrices.push(); - matrices.translate(x, y, 0); - matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(180 + rotation)); - matrices.translate(-width / 2f, -height / 2f, 0f); + @Override + public void drawCenteredWithRotation(DrawContext context, int x, int y, int width, int height, float rotation) { + context.getMatrices().push(); + context.getMatrices().translate(x, y, 0); + context.getMatrices().multiply(RotationAxis.POSITIVE_Z.rotationDegrees(180 + rotation)); + context.getMatrices().translate(-width / 2f, -height / 2f, 0f); - draw(matrices, 0,0, width, height); + draw(context, 0,0, width, height); - matrices.pop(); + context.getMatrices().pop(); } + @Override 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); } + @Override 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) { if (autobind) { bind(); 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..ffb6ded54 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 context, int x, int y); - void draw(MatrixStack matrices, int x, int y, int width, int height); + void draw(DrawContext context, 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 context, 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 context, 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 context, 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..b35466042 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 context, SubTile subtile, int tileHalfSize) { + draw(context, 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..41f36783d 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,11 +6,11 @@ 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; @@ -66,7 +66,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); 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..f5b37c0ad 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.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.registry.RegistryKey; +import net.minecraft.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..c06ecc568 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 @@ -10,7 +10,7 @@ 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.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..c38faa363 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 @@ -12,7 +12,7 @@ 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.registry.RegistryKey; import net.minecraft.world.World; import java.util.Map; diff --git a/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/ITileDetector.java b/common/src/main/java/hunternif/mc/impl/atlas/core/scanning/ITileDetector.java similarity index 90% rename from common/src/main/java/hunternif/mc/impl/atlas/core/scaning/ITileDetector.java rename to common/src/main/java/hunternif/mc/impl/atlas/core/scanning/ITileDetector.java index ab78afb05..4d004082e 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/ITileDetector.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/core/scanning/ITileDetector.java @@ -1,4 +1,4 @@ -package hunternif.mc.impl.atlas.core.scaning; +package hunternif.mc.impl.atlas.core.scanning; import net.minecraft.util.Identifier; import net.minecraft.world.World; 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/scanning/TileDetectorBase.java similarity index 52% rename from common/src/main/java/hunternif/mc/impl/atlas/core/scaning/TileDetectorBase.java rename to common/src/main/java/hunternif/mc/impl/atlas/core/scanning/TileDetectorBase.java index 13e52ae2c..075222906 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/TileDetectorBase.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/core/scanning/TileDetectorBase.java @@ -1,21 +1,25 @@ -package hunternif.mc.impl.atlas.core.scaning; +package hunternif.mc.impl.atlas.core.scanning; +import com.google.common.collect.HashMultiset; +import com.google.common.collect.Multiset; +import com.google.common.collect.Ordering; +import dev.architectury.injectables.annotations.ExpectPlatform; import hunternif.mc.impl.atlas.AntiqueAtlasMod; import hunternif.mc.impl.atlas.core.TileIdMap; import net.minecraft.block.Block; import net.minecraft.block.Blocks; +import net.minecraft.registry.Registry; +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; import net.minecraft.world.biome.BiomeKeys; import net.minecraft.world.chunk.Chunk; -import java.util.*; - /** * Detects the 256 vanilla biomes, water pools and lava pools. * Water and beach biomes are given priority because shore line is the defining @@ -41,59 +45,21 @@ public class TileDetectorBase implements ITileDetector { */ private static final int ravineMinDepth = 7; - /** - * Set to true for biome IDs that return true for BiomeDictionary.isBiomeOfType(WATER) - */ - private static final Set waterBiomes = new HashSet<>(); - /** - * Set to true for biome IDs that return true for BiomeDictionary.isBiomeOfType(BEACH) - */ - private static final Set beachBiomes = new HashSet<>(); - - private static final Set swampBiomes = new HashSet<>(); - - /** - * 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) { - 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)); - } - } + @ExpectPlatform + static private boolean hasSwampWater(RegistryEntry biomeTag) { + throw new AssertionError("Not implemented"); } - int priorityForBiome(Identifier biome) { - if (waterBiomes.contains(biome)) { + static int priorityForBiome(RegistryEntry biomeTag) { + if (biomeTag.isIn(BiomeTags.IS_OCEAN) || biomeTag.isIn(BiomeTags.IS_RIVER) || biomeTag.isIn(BiomeTags.IS_DEEP_OCEAN)) { return 4; - } else if (beachBiomes.contains(biome)) { + } else if (biomeTag.isIn(BiomeTags.IS_BEACH)) { return 3; } else { return 1; } } - /* these are the values used by vanilla, but it just doesn't work for me. - protected static TileHeightType getHeightType(double weirdness) { - if (weirdness < (double) VanillaTerrainParameters.getNormalizedWeirdness(0.05f)) { - return TileHeightType.VALLEY; - } - if (weirdness < (double) VanillaTerrainParameters.getNormalizedWeirdness(0.26666668f)) { - return TileHeightType.LOW; - } - if (weirdness < (double) VanillaTerrainParameters.getNormalizedWeirdness(0.4f)) { - return TileHeightType.MID; - } - if (weirdness < (double) VanillaTerrainParameters.getNormalizedWeirdness(0.56666666f)) { - return TileHeightType.HIGH; - } - return TileHeightType.PEAK; - } */ - protected static TileHeightType getHeightTypeFromY(int y, int sealevel) { if (y < sealevel + 10) { return TileHeightType.VALLEY; @@ -112,20 +78,17 @@ 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) { - int occurrence = map.getOrDefault(biome, 0) + weight; - map.put(biome, occurrence); + protected static void updateOccurrencesMap(Multiset map, Identifier biome, int weight) { + map.add(biome, weight); } - protected static void updateOccurrencesMap(Map map, World world, Biome biome, TileHeightType type, int weight) { + protected static void updateOccurrencesMap(Multiset map, World world, Biome biome, TileHeightType type, int weight) { Identifier id = getBiomeIdentifier(world, biome); - id = Identifier.tryParse(id.toString() + "_" + type.getName()); - - int occurrence = map.getOrDefault(id, 0) + weight; - map.put(id, occurrence); + id = new Identifier(id.getNamespace(), id.getPath() + "_" + type.getName()); + map.add(id, weight); } @Override @@ -140,32 +103,25 @@ public int getScanRadius() { */ @Override public Identifier getBiomeID(World world, Chunk chunk) { - Map biomeOccurrences = new HashMap<>(BuiltinRegistries.BIOME.getIds().size()); + Multiset biomeOccurrences = HashMultiset.create(world.getRegistryManager().get(RegistryKeys.BIOME).size()); + Registry biomeRegistry = world.getRegistryManager().get(RegistryKeys.BIOME); for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; 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(); + RegistryEntry biomeTag = biomeRegistry.entryOf(biomeRegistry.getKey(biome).orElse(null)); // get top block int y = chunk.getHeightmap(Heightmap.Type.MOTION_BLOCKING).get(x, z); - - //this code runs on the server -// ServerChunkManager man = (ServerChunkManager) world.getChunkManager(); -// MultiNoiseUtil.MultiNoiseSampler sampler = man.getChunkGenerator().getMultiNoiseSampler(); -// ChunkPos pos = chunk.getPos(); -// MultiNoiseUtil.NoiseValuePoint sample = sampler.sample(pos.getStartX() + x, y + 10, pos.getStartZ() + z); - -// float m = MultiNoiseUtil.method_38666(sample.weirdnessNoise()); -// double weirdness = VanillaTerrainParameters.getNormalizedWeirdness(m); - if (AntiqueAtlasMod.CONFIG.doScanPonds) { if (y > 0) { Block topBlock = chunk.getBlockState(new BlockPos(x, y - 1, z)).getBlock(); // Check if there's surface of water at (x, z), but not swamp if (topBlock == Blocks.WATER) { - if (swampBiomes.contains(getBiomeIdentifier(world, biome))) { + + if (hasSwampWater(biomeTag)) { updateOccurrencesMap(biomeOccurrences, TileIdMap.SWAMP_WATER, priorityWaterPool); } else { updateOccurrencesMap(biomeOccurrences, waterPoolBiome, priorityWaterPool); @@ -182,14 +138,11 @@ 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(biomeTag)); } } if (biomeOccurrences.isEmpty()) return null; - - Map.Entry meanBiome = Collections.max(biomeOccurrences.entrySet(), Comparator.comparingInt(Map.Entry::getValue)); - return meanBiome.getKey(); + return biomeOccurrences.entrySet().stream().max(Ordering.natural().onResultOf(Multiset.Entry::getCount)).orElseThrow().getElement(); } } 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/scanning/TileDetectorEnd.java similarity index 76% rename from common/src/main/java/hunternif/mc/impl/atlas/core/scaning/TileDetectorEnd.java rename to common/src/main/java/hunternif/mc/impl/atlas/core/scanning/TileDetectorEnd.java index c3fd25731..468a03677 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/TileDetectorEnd.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/core/scanning/TileDetectorEnd.java @@ -1,21 +1,19 @@ -package hunternif.mc.impl.atlas.core.scaning; +package hunternif.mc.impl.atlas.core.scanning; +import com.google.common.collect.HashMultiset; +import com.google.common.collect.Multiset; +import com.google.common.collect.Ordering; 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; import net.minecraft.world.biome.BiomeKeys; import net.minecraft.world.chunk.Chunk; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Map; - /** * Detects seas of lava, cave ground and cave walls in the Nether. * @@ -25,7 +23,7 @@ public class TileDetectorEnd extends TileDetectorBase implements ITileDetector { @Override public Identifier getBiomeID(World world, Chunk chunk) { - Map biomeOccurrences = new HashMap<>(BuiltinRegistries.BIOME.getIds().size()); + Multiset biomeOccurrences = HashMultiset.create(world.getRegistryManager().get(RegistryKeys.BIOME).size()); for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { @@ -53,11 +51,7 @@ public Identifier getBiomeID(World world, Chunk chunk) { } } - if (biomeOccurrences.isEmpty()) - return null; - - Map.Entry meanBiome = Collections.max(biomeOccurrences.entrySet(), Comparator - .comparingInt(Map.Entry::getValue)); - return meanBiome.getKey(); + if (biomeOccurrences.isEmpty()) return null; + return biomeOccurrences.entrySet().stream().max(Ordering.natural().onResultOf(Multiset.Entry::getCount)).orElseThrow().getElement(); } } 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/scanning/TileDetectorNether.java similarity index 71% rename from common/src/main/java/hunternif/mc/impl/atlas/core/scaning/TileDetectorNether.java rename to common/src/main/java/hunternif/mc/impl/atlas/core/scanning/TileDetectorNether.java index bd4880e27..455626f2a 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/TileDetectorNether.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/core/scanning/TileDetectorNether.java @@ -1,21 +1,22 @@ -package hunternif.mc.impl.atlas.core.scaning; +package hunternif.mc.impl.atlas.core.scanning; +import com.google.common.collect.HashMultiset; +import com.google.common.collect.Multiset; +import com.google.common.collect.Ordering; import hunternif.mc.impl.atlas.core.TileIdMap; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.registry.Registry; +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; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Map; - /** * Detects seas of lava, cave ground and cave walls in the Nether. * @@ -39,12 +40,14 @@ public class TileDetectorNether extends TileDetectorBase implements ITileDetecto @Override public Identifier getBiomeID(World world, Chunk chunk) { - Map biomeOccurrences = new HashMap<>(BuiltinRegistries.BIOME.getIds().size()); + Multiset biomeOccurrences = HashMultiset.create(world.getRegistryManager().get(RegistryKeys.BIOME).size()); + Registry biomeRegistry = world.getRegistryManager().get(RegistryKeys.BIOME); 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 biomeTag = biomeRegistry.entryOf(biomeRegistry.getKey(biome).orElse(null)); + if (biomeTag.isIn(BiomeTags.IS_NETHER)) { // The Nether! Block seaLevelBlock = chunk.getBlockState(new BlockPos(x, lavaSeaLevel, z)).getBlock(); if (seaLevelBlock == Blocks.LAVA) { @@ -60,17 +63,13 @@ 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(biomeTag)); } } } if (biomeOccurrences.isEmpty()) return null; - - Map.Entry meanBiome = Collections.max(biomeOccurrences.entrySet(), Comparator - .comparingInt(Map.Entry::getValue)); - - return meanBiome.getKey(); + return biomeOccurrences.entrySet().stream().max(Ordering.natural().onResultOf(Multiset.Entry::getCount)).orElseThrow().getElement(); } @Override diff --git a/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/TileHeightType.java b/common/src/main/java/hunternif/mc/impl/atlas/core/scanning/TileHeightType.java similarity index 89% rename from common/src/main/java/hunternif/mc/impl/atlas/core/scaning/TileHeightType.java rename to common/src/main/java/hunternif/mc/impl/atlas/core/scanning/TileHeightType.java index 7f344f693..e192eabff 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/TileHeightType.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/core/scanning/TileHeightType.java @@ -1,4 +1,4 @@ -package hunternif.mc.impl.atlas.core.scaning; +package hunternif.mc.impl.atlas.core.scanning; /** * The enum represents the different height levels in biomes. 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/scanning/WorldScanner.java similarity index 98% rename from common/src/main/java/hunternif/mc/impl/atlas/core/scaning/WorldScanner.java rename to common/src/main/java/hunternif/mc/impl/atlas/core/scanning/WorldScanner.java index 7ec781047..37f4ad29a 100644 --- a/common/src/main/java/hunternif/mc/impl/atlas/core/scaning/WorldScanner.java +++ b/common/src/main/java/hunternif/mc/impl/atlas/core/scanning/WorldScanner.java @@ -1,4 +1,4 @@ -package hunternif.mc.impl.atlas.core.scaning; +package hunternif.mc.impl.atlas.core.scanning; import hunternif.mc.api.AtlasAPI; import hunternif.mc.impl.atlas.AntiqueAtlasMod; @@ -7,7 +7,7 @@ import hunternif.mc.impl.atlas.core.TileInfo; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.RegistryKey; +import net.minecraft.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..403415e6a 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,17 @@ 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..8445a7a18 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 @@ -16,9 +16,8 @@ import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; -import net.minecraft.tag.BlockTags; +import net.minecraft.registry.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..cda8f7e69 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,21 +1,25 @@ 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; public class RecipeAtlasCloning implements CraftingRecipe { public static final RecipeSerializer SERIALIZER = new SpecialRecipeSerializer<>(RecipeAtlasCloning::new); private final Identifier id; + private final CraftingRecipeCategory category; - public RecipeAtlasCloning(Identifier identifier) { + public RecipeAtlasCloning(Identifier identifier, CraftingRecipeCategory category) { this.id = identifier; + this.category = category; } @Override @@ -24,7 +28,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 +54,7 @@ public boolean matches(CraftingInventory inv, World world) { } @Override - public ItemStack craft(CraftingInventory inv) { + public ItemStack craft(RecipeInputInventory inv, DynamicRegistryManager registryManager) { int i = 0; // number of new copies ItemStack filledAtlas = ItemStack.EMPTY; @@ -92,7 +96,7 @@ public boolean fits(int width, int height) { } @Override - public ItemStack getOutput() { + public ItemStack getOutput(DynamicRegistryManager registryManager) { return ItemStack.EMPTY; } @@ -110,4 +114,9 @@ public RecipeSerializer getSerializer() { public RecipeType getType() { return RecipeType.CRAFTING; } + + @Override + public CraftingRecipeCategory getCategory() { + return category; + } } 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..dd98c6a0a 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; @@ -27,9 +29,11 @@ public class RecipeAtlasCombining implements CraftingRecipe { public static final RecipeSerializer SERIALIZER = new SpecialRecipeSerializer<>(RecipeAtlasCombining::new); private final Identifier id; + private final CraftingRecipeCategory category; - public RecipeAtlasCombining(Identifier id) { + public RecipeAtlasCombining(Identifier id, CraftingRecipeCategory category) { this.id = id; + this.category = category; } @Override @@ -38,11 +42,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 +60,7 @@ private boolean matches(CraftingInventory inv) { } @Override - public ItemStack craft(CraftingInventory inv) { + public ItemStack craft(RecipeInputInventory inv, DynamicRegistryManager registryManager) { ItemStack firstAtlas = ItemStack.EMPTY; List atlasIds = new ArrayList<>(9); for (int i = 0; i < inv.size(); ++i) { @@ -80,7 +84,7 @@ public boolean fits(int width, int height) { } @Override - public ItemStack getOutput() { + public ItemStack getOutput(DynamicRegistryManager registryManager) { return new ItemStack(AntiqueAtlasItems.ATLAS.get()); } @@ -99,6 +103,11 @@ public RecipeType getType() { return RecipeType.CRAFTING; } + @Override + public CraftingRecipeCategory getCategory() { + return category; + } + 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..a7c6f9a7e 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 @@ -2,7 +2,7 @@ import hunternif.mc.impl.atlas.util.ListMapValueIterator; import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.registry.RegistryKey; +import net.minecraft.registry.RegistryKey; import net.minecraft.world.World; import java.util.AbstractCollection; 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..99a6d0cce 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 @@ -4,7 +4,7 @@ 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.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..082b3f7da 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 @@ -5,7 +5,7 @@ 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.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..9a36802c8 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 @@ -12,6 +12,7 @@ import net.minecraft.util.Identifier; import net.minecraft.util.profiler.Profiler; +import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Collection; @@ -37,14 +38,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).orElseThrow(IOException::new); 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..b727426fa 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 @@ -3,7 +3,7 @@ import hunternif.mc.impl.atlas.item.AtlasItem; import net.minecraft.item.ItemStack; import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.registry.RegistryKey; +import net.minecraft.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..34c6d599b 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 @@ -8,7 +8,7 @@ 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; @@ -71,7 +71,7 @@ public void b(Entity entity) { PlayerEntity player = (PlayerEntity) entity; if (isEntityInPortal(entity)) { Log.info("Exiting"); - // player.worldObj.provider.dimensionId is the dimension of origin + // player.getWorld()Obj.provider.dimensionId is the dimension of origin DimensionType originDimension = player.getEntityWorld().getDimension().getType(); Log.info("Player %s left the %s", player.getCommandSource().getName(), Registry.DIMENSION_TYPE.getId(originDimension)); @@ -130,7 +130,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..148d0d5c4 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 @@ -13,10 +13,11 @@ 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; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -25,7 +26,7 @@ @Environment(EnvType.CLIENT) @Mixin(HeldItemRenderer.class) public abstract class HeldItemRendererMixin { - private OverlayRenderer atlasOverlayRenderer = new OverlayRenderer(); + @Unique private final OverlayRenderer atlasOverlayRenderer = new OverlayRenderer(); @Shadow private ItemStack offHand; @@ -68,18 +69,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 +92,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 +105,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 +121,9 @@ 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..32457b002 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 @@ -44,7 +44,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..abe23562a 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 partial, CallbackInfo info) { + 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..d37be3ca6 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 @@ -13,6 +13,7 @@ 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; @@ -26,12 +27,13 @@ @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 serverWorldAccess, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, net.minecraft.util.math.random.Random random, BlockBox boundingBox, ChunkPos chunkPos, BlockPos blockPos) { ServerWorld world; if (serverWorldAccess instanceof ServerWorld) { @@ -45,7 +47,7 @@ private void structurePieceGenerated(StructurePiece structurePiece, StructureWor } @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, net.minecraft.util.math.random.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..8f1432405 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.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.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..1fde89c5b 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(), + public static final SimpleDefaultedRegistry REGISTRY = new SimpleDefaultedRegistry<>(AntiqueAtlasMod.id("red_x_small").toString(), KEY, Lifecycle.experimental(), - null); + 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()); } @@ -203,11 +201,10 @@ public void initMips() { Log.warn("Marker %s -- Texture location is null at index %d!", MarkerType.REGISTRY.getId(this).toString(), i); } - Resource iresource = null; NativeImage bufferedimage = null; try { - iresource = MinecraftClient.getInstance().getResourceManager().getResource(icons[i]); + Resource iresource = MinecraftClient.getInstance().getResourceManager().getResource(icons[i]).orElseThrow(IOException::new); bufferedimage = NativeImage.read(iresource.getInputStream()); iconSizes[i] = Math.min(bufferedimage.getWidth(), bufferedimage.getHeight()); BitMatrix matrix = new BitMatrix(bufferedimage.getWidth(), bufferedimage.getHeight(), false); @@ -244,7 +241,6 @@ public void initMips() { if (bufferedimage != null) { bufferedimage.close(); } - 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..133315f31 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,13 @@ 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.StructureType; public class EndCity { public static void registerMarkers() { - StructureHandler.registerMarker(StructureFeature.ENDCITY, AntiqueAtlasMod.id("end_city"), new LiteralText("")); + StructureHandler.registerMarker(StructureType.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..f09d411ca 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).orElseThrow(IOException::new); try (InputStream stream = resource.getInputStream(); InputStreamReader reader = new InputStreamReader(stream)) { return JsonParser.parseReader(reader).getAsJsonObject(); } @@ -59,7 +59,7 @@ public CompletableFuture> load(ResourceManag try { - for (Identifier id : manager.findResources("atlas/structures", (s) -> s.endsWith(".json"))) { + for (Identifier id : manager.findResources("atlas/structures", id -> id.toString().endsWith(".json")).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..706854a93 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,11 @@ 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.Registry; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.registry.tag.TagKey; import net.minecraft.server.world.ServerWorld; import net.minecraft.structure.*; import net.minecraft.structure.pool.SinglePoolElement; @@ -13,9 +18,9 @@ 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 net.minecraft.world.gen.structure.Structure; +import net.minecraft.world.gen.structure.StructureType; import org.apache.commons.lang3.tuple.Triple; import java.util.*; @@ -25,6 +30,7 @@ public class StructureHandler { private static final HashMultimap> STRUCTURE_PIECE_TO_TILE_MAP = HashMultimap.create(); private static final Multimap> JIGSAW_TO_TILE_MAP = HashMultimap.create(); private static final Map> STRUCTURE_PIECE_TO_MARKER_MAP = new HashMap<>(); + private static final Map, Pair> STRUCTURE_TAG_TO_MARKER_MAP = new HashMap<>(); private static final Map STRUCTURE_PIECE_TILE_PRIORITY = new HashMap<>(); public static final Setter ALWAYS = (world, element, box, rotation) -> Collections.singleton(new ChunkPos(MathUtil.getCenter(box).getX() >> 4, MathUtil.getCenter(box).getZ() >> 4)); @@ -60,7 +66,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 +84,12 @@ 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(StructureType structureFeature, Identifier markerType, Text name) { + STRUCTURE_PIECE_TO_MARKER_MAP.put(Registries.STRUCTURE_TYPE.getId(structureFeature), new Pair<>(markerType, name)); + } + + public static void registerMarker(TagKey structureTag, Identifier markerType, Text name) { + STRUCTURE_TAG_TO_MARKER_MAP.put(structureTag, new Pair<>(markerType, name)); } private static int getPriority(Identifier structurePieceId) { @@ -120,7 +130,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,8 +148,25 @@ 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()); + + + Pair foundMarker = null; + if (STRUCTURE_PIECE_TO_MARKER_MAP.containsKey(structureId)) { + foundMarker = STRUCTURE_PIECE_TO_MARKER_MAP.get(structureId); + } else { + Registry structureRegistry = world.getRegistryManager().get(RegistryKeys.STRUCTURE); + RegistryEntry structureTag = structureRegistry.entryOf(structureRegistry.getKey(structureStart.getStructure()).orElse(null)); + for (Map.Entry, Pair> entry : STRUCTURE_TAG_TO_MARKER_MAP.entrySet()) { + if (structureTag.isIn(entry.getKey())) { + foundMarker = entry.getValue(); + break; + } + } + } + + if (foundMarker != null) { Triple key = Triple.of( structureStart.getBoundingBox().getCenter().getX(), structureStart.getBoundingBox().getCenter().getY(), @@ -151,8 +178,8 @@ public static void resolve(StructureStart structureStart, ServerWorld world) { AtlasAPI.getMarkerAPI().putGlobalMarker( world, false, - STRUCTURE_PIECE_TO_MARKER_MAP.get(structureId).getLeft(), - STRUCTURE_PIECE_TO_MARKER_MAP.get(structureId).getRight(), + foundMarker.getLeft(), + foundMarker.getRight(), structureStart.getBoundingBox().getCenter().getX(), structureStart.getBoundingBox().getCenter().getZ() ); 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..5f5c45ec3 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,13 @@ 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.registry.tag.StructureTags; +import net.minecraft.text.Text; 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(StructureTags.VILLAGE, 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..8843eb8bc 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).orElseThrow(IOException::new).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).orElseThrow(IOException::new).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).orElseThrow(IOException::new).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).orElseThrow(IOException::new).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..2715c1926 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 +accessible field net/minecraft/structure/pool/SinglePoolElement location Lcom/mojang/datafixers/util/Either; \ 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/build.gradle b/fabric/build.gradle index 4923582d7..3209401b7 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -89,7 +89,7 @@ publishing { unifiedPublishing { project { - gameVersions = ["1.18.2"] + gameVersions = ["1.20.1"] gameLoaders = ["fabric"] releaseType = "release" 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..d15f1ad2e 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 @@ -1,162 +1,99 @@ package hunternif.mc.impl.atlas.client.fabric; -import hunternif.mc.impl.atlas.AntiqueAtlasMod; -import hunternif.mc.impl.atlas.client.TileTextureMap; import net.fabricmc.api.EnvType; 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.util.Identifier; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryEntry; -import net.minecraft.util.registry.RegistryKey; +import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.world.biome.Biome; -import java.util.Optional; - @SuppressWarnings("unused") @Environment(EnvType.CLIENT) public class TileTextureMapImpl { + public static boolean biomeIsVoid(RegistryEntry biomeTag) { + return biomeTag.isIn(ConventionalBiomeTags.VOID); + } + + public static boolean biomeIsEnd(RegistryEntry biomeTag) { + return biomeTag.isIn(ConventionalBiomeTags.IN_THE_END) || biomeTag.isIn(ConventionalBiomeTags.END_ISLANDS); + } + + public static boolean biomeHasVegetation(RegistryEntry biomeTag) { + return biomeTag.isIn(ConventionalBiomeTags.VEGETATION_DENSE) || biomeTag.isIn(ConventionalBiomeTags.VEGETATION_SPARSE); + } + + public static boolean biomeIsNether(RegistryEntry biomeTag) { + return biomeTag.isIn(ConventionalBiomeTags.IN_NETHER); + } + + public static boolean biomeIsSwamp(RegistryEntry biomeTag) { + return biomeTag.isIn(ConventionalBiomeTags.SWAMP); + } + + public static boolean biomeIsWater(RegistryEntry biomeTag) { + return biomeTag.isIn(ConventionalBiomeTags.AQUATIC); + } + + public static boolean biomeIsIcy(RegistryEntry biomeTag) { + return biomeTag.isIn(ConventionalBiomeTags.ICY); + } + + public static boolean biomeIsShore(RegistryEntry biomeTag) { + return biomeTag.isIn(ConventionalBiomeTags.BEACH); + } + + public static boolean biomeIsJungle(RegistryEntry biomeTag) { + return biomeTag.isIn(ConventionalBiomeTags.JUNGLE) || biomeTag.isIn(ConventionalBiomeTags.TREE_JUNGLE); + } + + public static boolean biomeIsSavanna(RegistryEntry biomeTag) { + return biomeTag.isIn(ConventionalBiomeTags.SAVANNA) || biomeTag.isIn(ConventionalBiomeTags.TREE_SAVANNA); + } + + public static boolean biomeIsBadlands(RegistryEntry biomeTag) { + return biomeTag.isIn((ConventionalBiomeTags.BADLANDS)) || biomeTag.isIn((ConventionalBiomeTags.MESA)); + } + + public static boolean biomeIsPlateau(RegistryEntry biomeTag) { + return false; // None + } + + public static boolean biomeIsForest(RegistryEntry biomeTag) { + return biomeTag.isIn(ConventionalBiomeTags.TREE_DECIDUOUS); + } + + public static boolean biomeIsSnowy(RegistryEntry biomeTag) { + return biomeTag.isIn(ConventionalBiomeTags.SNOWY); + } + + public static boolean biomeIsPlains(RegistryEntry biomeTag) { + return biomeTag.isIn(ConventionalBiomeTags.PLAINS) || biomeTag.isIn(ConventionalBiomeTags.SNOWY_PLAINS); + } + + public static boolean biomeIsDesert(RegistryEntry biomeTag) { + return biomeTag.isIn(ConventionalBiomeTags.DESERT); + } + + public static boolean biomeIsTaiga(RegistryEntry biomeTag) { + return biomeTag.isIn(ConventionalBiomeTags.TAIGA); + } + + public static boolean biomeIsExtremeHills(RegistryEntry biomeTag) { + return biomeTag.isIn(ConventionalBiomeTags.EXTREME_HILLS); + } + + public static boolean biomeIsPeak(RegistryEntry biomeTag) { + return biomeTag.isIn(ConventionalBiomeTags.MOUNTAIN_PEAK); + } + + public static boolean biomeIsMountain(RegistryEntry biomeTag) { + return biomeTag.isIn(ConventionalBiomeTags.MOUNTAIN) || biomeTag.isIn(ConventionalBiomeTags.MOUNTAIN_SLOPE); + } + + public static boolean biomeIsMushroom(RegistryEntry biomeTag) { + return biomeTag.isIn(ConventionalBiomeTags.MUSHROOM); + } - 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(ConventionalBiomeTags.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(ConventionalBiomeTags.AQUATIC)) { - if (biomeTag.isIn(ConventionalBiomeTags.ICY)) - return Optional.of(AntiqueAtlasMod.id("ice")); - - return Optional.of(AntiqueAtlasMod.id("water")); - } - - if (biomeTag.isIn(BiomeTags.IS_BEACH) || biomeTag.isIn(ConventionalBiomeTags.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(ConventionalBiomeTags.SAVANNA) || biomeTag.isIn(ConventionalBiomeTags.TREE_SAVANNA)) { - return Optional.of(AntiqueAtlasMod.id("savana")); - } - - if (biomeTag.isIn((ConventionalBiomeTags.MESA))) { - return Optional.of(AntiqueAtlasMod.id("plateau_mesa")); - } - - if (biomeTag.isIn(BiomeTags.IS_FOREST) || biomeTag.isIn(ConventionalBiomeTags.TREE_DECIDUOUS)) { - if (biomeTag.isIn(ConventionalBiomeTags.ICY) || biomeTag.isIn(ConventionalBiomeTags.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(ConventionalBiomeTags.PLAINS) || biomeTag.isIn(ConventionalBiomeTags.SNOWY_PLAINS)) { - if (biomeTag.isIn(ConventionalBiomeTags.ICY) - || biomeTag.isIn(ConventionalBiomeTags.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(ConventionalBiomeTags.ICY)) { - 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(ConventionalBiomeTags.DESERT)) { - if (biomeTag.isIn(BiomeTags.IS_HILL)) { - return Optional.of(AntiqueAtlasMod.id("desert_hills")); - } else { - return Optional.of(AntiqueAtlasMod.id("desert")); - } - } - - if (biomeTag.isIn(ConventionalBiomeTags.TAIGA)) { - return Optional.of(AntiqueAtlasMod.id("snow")); - } - - if (biomeTag.isIn(ConventionalBiomeTags.EXTREME_HILLS)) { - return Optional.of(AntiqueAtlasMod.id("hills")); - } - - if (biomeTag.isIn(ConventionalBiomeTags.MOUNTAIN) || biomeTag.isIn(ConventionalBiomeTags.MOUNTAIN_SLOPE)) { - return Optional.of(AntiqueAtlasMod.id("mountains")); - } - - if (biomeTag.isIn(ConventionalBiomeTags.MOUNTAIN_PEAK)) { - return Optional.of(AntiqueAtlasMod.id("mountains_snow_caps")); - } - - if (biomeTag.isIn(ConventionalBiomeTags.IN_THE_END) || biomeTag.isIn(ConventionalBiomeTags.END_ISLANDS)) { - if (biomeTag.isIn(ConventionalBiomeTags.VEGETATION_DENSE) || biomeTag.isIn(ConventionalBiomeTags.VEGETATION_SPARSE)) { - return Optional.of(AntiqueAtlasMod.id("end_island_plants")); - } else { - return Optional.of(AntiqueAtlasMod.id("end_island")); - } - } - - if (biomeTag.isIn(ConventionalBiomeTags.MUSHROOM)) { - return Optional.of(AntiqueAtlasMod.id("mushroom")); - } - - if (biomeTag.isIn(ConventionalBiomeTags.IN_NETHER) || biomeTag.isIn(BiomeTags.IS_NETHER)) { - return Optional.of(AntiqueAtlasMod.id("soul_sand_valley")); - } - - if (biomeTag.isIn(ConventionalBiomeTags.VOID)) { - return Optional.of(AntiqueAtlasMod.id("end_void")); - } - - if (biomeTag.isIn(ConventionalBiomeTags.UNDERGROUND)) { - AntiqueAtlasMod.LOG.warn("Underground biomes aren't supported yet."); - } - - if (biomeTag.isIn(BiomeTags.IS_BADLANDS)) { - return Optional.of(AntiqueAtlasMod.id("mesa")); - } - - return TileTextureMap.guessFittingTextureSetFallback(biomeTag.value()); + public static boolean biomeIsUnderground(RegistryEntry biomeTag) { + return biomeTag.isIn(ConventionalBiomeTags.UNDERGROUND); } } diff --git a/fabric/src/main/java/hunternif/mc/impl/atlas/core/scanning/fabric/TileDetectorBaseImpl.java b/fabric/src/main/java/hunternif/mc/impl/atlas/core/scanning/fabric/TileDetectorBaseImpl.java new file mode 100644 index 000000000..5fc103193 --- /dev/null +++ b/fabric/src/main/java/hunternif/mc/impl/atlas/core/scanning/fabric/TileDetectorBaseImpl.java @@ -0,0 +1,11 @@ +package hunternif.mc.impl.atlas.core.scanning.fabric; + +import net.fabricmc.fabric.api.tag.convention.v1.ConventionalBiomeTags; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.world.biome.Biome; + +public class TileDetectorBaseImpl { + public static boolean hasSwampWater(RegistryEntry biomeTag) { + return biomeTag.isIn(ConventionalBiomeTags.SWAMP); + } +} diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 869ee8141..f02907a13 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -26,10 +26,10 @@ "icon": "antiqueatlas_icon.png", "depends": { "fabricloader": ">=0.10.8", - "fabric": ">=0.28.0", - "minecraft": ">=1.18.2", - "cloth-config2": [">=6.2.62", "<7.0.0"], - "architectury": ">=4.10.86" + "fabric": ">=0.87.0", + "minecraft": ">=1.20.1", + "cloth-config2": ">=11.1.106", + "architectury": ">=9.1.12" }, "mixins": [ "antiqueatlas.mixins.json", diff --git a/forge/build.gradle b/forge/build.gradle index 980e69799..73606723b 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -93,7 +93,7 @@ publishing { unifiedPublishing { project { - gameVersions = ["1.18.2"] + gameVersions = ["1.20.1"] gameLoaders = ["forge"] releaseType = "release" 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 index 45746be8b..f6edabb76 100644 --- 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 @@ -1,167 +1,99 @@ 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.registry.tag.BiomeTags; +import net.minecraft.registry.entry.RegistryEntry; 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()); + public static boolean biomeIsVoid(RegistryEntry biomeTag) { + return biomeTag.isIn(Tags.Biomes.IS_VOID); + } + + public static boolean biomeIsEnd(RegistryEntry biomeTag) { + return false; // Too Specific + } + + public static boolean biomeHasVegetation(RegistryEntry biomeTag) { + return biomeTag.isIn(Tags.Biomes.IS_SPARSE) || biomeTag.isIn(Tags.Biomes.IS_DENSE); // Not 100% sold here + } + + public static boolean biomeIsNether(RegistryEntry biomeTag) { + return false; // Too Specific + } + + public static boolean biomeIsSwamp(RegistryEntry biomeTag) { + return biomeTag.isIn(Tags.Biomes.IS_SWAMP); + } + + public static boolean biomeIsWater(RegistryEntry biomeTag) { + return biomeTag.isIn(Tags.Biomes.IS_WATER); + } + + public static boolean biomeIsIcy(RegistryEntry biomeTag) { + return biomeTag.isIn(Tags.Biomes.IS_COLD) || biomeTag.isIn(Tags.Biomes.IS_SNOWY); + } + + public static boolean biomeIsShore(RegistryEntry biomeTag) { + return biomeTag.isIn(BiomeTags.IS_BEACH); + } + + public static boolean biomeIsJungle(RegistryEntry biomeTag) { + return false; // None + } + + public static boolean biomeIsSavanna(RegistryEntry biomeTag) { + return false; // None + } + + public static boolean biomeIsBadlands(RegistryEntry biomeTag) { + return false; // None + } + + public static boolean biomeIsPlateau(RegistryEntry biomeTag) { + return biomeTag.isIn((Tags.Biomes.IS_PLATEAU)); + } + + public static boolean biomeIsForest(RegistryEntry biomeTag) { + return biomeTag.isIn(Tags.Biomes.IS_DENSE) || biomeTag.isIn(Tags.Biomes.IS_SPARSE); + } + + public static boolean biomeIsSnowy(RegistryEntry biomeTag) { + return biomeTag.isIn(Tags.Biomes.IS_SNOWY); + } + + public static boolean biomeIsPlains(RegistryEntry biomeTag) { + return biomeTag.isIn(Tags.Biomes.IS_PLAINS); + } + + public static boolean biomeIsDesert(RegistryEntry biomeTag) { + return biomeTag.isIn(Tags.Biomes.IS_HOT); + } + + public static boolean biomeIsTaiga(RegistryEntry biomeTag) { + return false; // None + } + + public static boolean biomeIsExtremeHills(RegistryEntry biomeTag) { + return false; // None + } + + public static boolean biomeIsPeak(RegistryEntry biomeTag) { + return biomeTag.isIn(Tags.Biomes.IS_PEAK); + } + + public static boolean biomeIsMountain(RegistryEntry biomeTag) { + return biomeTag.isIn(Tags.Biomes.IS_SLOPE); + } + + public static boolean biomeIsMushroom(RegistryEntry biomeTag) { + return biomeTag.isIn(Tags.Biomes.IS_MUSHROOM); + } + + public static boolean biomeIsUnderground(RegistryEntry biomeTag) { + return biomeTag.isIn(Tags.Biomes.IS_UNDERGROUND); } } 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 index 5433d7c14..4b6b5d0d0 100644 --- 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 @@ -4,14 +4,14 @@ 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.client.ConfigScreenHandler; 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()) + ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, + () -> new ConfigScreenHandler.ConfigScreenFactory((mc, parent) -> AutoConfig.getConfigScreen(AntiqueAtlasConfig.class, parent).get()) ); } } diff --git a/forge/src/main/java/hunternif/mc/impl/atlas/core/scanning/forge/TileDetectorBaseImpl.java b/forge/src/main/java/hunternif/mc/impl/atlas/core/scanning/forge/TileDetectorBaseImpl.java new file mode 100644 index 000000000..17e5b1c70 --- /dev/null +++ b/forge/src/main/java/hunternif/mc/impl/atlas/core/scanning/forge/TileDetectorBaseImpl.java @@ -0,0 +1,11 @@ +package hunternif.mc.impl.atlas.core.scanning.forge; + +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.world.biome.Biome; +import net.minecraftforge.common.Tags; + +public class TileDetectorBaseImpl { + public static boolean hasSwampWater(RegistryEntry biomeTag) { + return biomeTag.isIn(Tags.Biomes.IS_SWAMP); + } +} diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 14901023a..5b448afe5 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -18,27 +18,27 @@ Antique Atlas is a book that acts like a map featuring infinite scrolling, zoom [[dependencies.antiqueatlas]] modId="forge" mandatory=true -versionRange="[40,)" +versionRange="[47,)" ordering="NONE" side="BOTH" [[dependencies.antiqueatlas]] modId="minecraft" mandatory=true -versionRange="[1.18.2,)" +versionRange="[1.20.1,)" ordering="NONE" side="BOTH" [[dependencies.antiqueatlas]] modId="cloth_config" mandatory=true -versionRange="[6.2.62,)" +versionRange="[11.1.106,)" ordering="NONE" side="BOTH" [[dependencies.antiqueatlas]] modId = "architectury" mandatory = true -versionRange = "[4.10.86,)" +versionRange = "[9.1.12,)" ordering = "AFTER" side = "BOTH" diff --git a/forge/src/main/resources/pack.mcmeta b/forge/src/main/resources/pack.mcmeta index ee944f39b..36fe8a59b 100644 --- a/forge/src/main/resources/pack.mcmeta +++ b/forge/src/main/resources/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { "description": "AntiqueAtlas", - "pack_format": 8 + "pack_format": 15 } } diff --git a/gradle.properties b/gradle.properties index 47cbc2d67..cbcc046d8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,22 +2,22 @@ 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 +minecraft_version = 1.20.1 +yarn_mappings = 1.20.1+build.10 +fabric_loader_version = 0.14.22 +forge_version = 1.20.1-47.1.0 enabled_platforms = fabric,forge # Mod Properties -mod_version = 7.1.0 +mod_version = 9.0.0 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 +architectury_version = 9.1.12 +cloth_config_version = 11.1.106 +fabric_api_version = 0.87.0+1.20.1 +mod_menu_version = 7.2.2 # Publishing curseforge_id = 227795 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 29953ea14..41d9927a4 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 41dfb8790..774fae876 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index cccdd3d51..1b6c78733 100755 --- a/gradlew +++ b/gradlew @@ -1,78 +1,129 @@ -#!/usr/bin/env sh +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -81,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -89,84 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index f9553162f..107acd32c 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell