From 4ecbb3c7f754e87716fe602c557683adeabb8bf2 Mon Sep 17 00:00:00 2001 From: ishland Date: Sun, 27 Feb 2022 13:39:55 +0800 Subject: [PATCH] 1.18.2-rc1 --- build.gradle | 4 +- gradle.properties | 2 +- .../client/config/BoundingBoxTypeHelper.java | 43 ++-- .../bbor/client/config/ConfigManager.java | 201 +++++++++++------- .../bbor/client/gui/ControlList.java | 7 +- .../bbor/client/gui/ControlListSection.java | 6 +- .../bbor/client/gui/SettingsScreen.java | 31 ++- .../client/interop/BiomeBorderHelper.java | 2 +- .../client/interop/FlowerForestHelper.java | 7 +- .../client/interop/NBTStructureLoader.java | 5 +- .../client/interop/SpawnableBlocksHelper.java | 7 +- .../bbor/client/renderers/Renderer.java | 2 +- .../bbor/common/BoundingBoxType.java | 26 +-- .../bbor/common/StructureProcessor.java | 24 ++- .../bbor/common/events/StructuresLoaded.java | 6 +- .../bbor/common/interop/CommonInterop.java | 32 ++- .../irtimaled/bbor/mixin/access/IBiome.java | 13 ++ .../bbor/mixin/access/IPlacedFeature.java | 16 -- .../bbor/mixin/client/MixinGameSettings.java | 9 +- .../bbor/mixin/client/MixinMinecraft.java | 7 + .../resource/MixinResourcePackManager.java | 2 +- src/main/resources/bbor.accesswidener | 1 + src/main/resources/bbor.mixins.json | 2 +- src/main/resources/fabric.mod.json | 2 +- 24 files changed, 268 insertions(+), 189 deletions(-) create mode 100644 src/main/java/com/irtimaled/bbor/mixin/access/IBiome.java delete mode 100644 src/main/java/com/irtimaled/bbor/mixin/access/IPlacedFeature.java diff --git a/build.gradle b/build.gradle index b0e66d0..4f6e5c9 100644 --- a/build.gradle +++ b/build.gradle @@ -40,8 +40,8 @@ tasks.withType(JavaCompile).configureEach { dependencies { minecraft 'com.mojang:minecraft:' + project.mcVersion - mappings 'net.fabricmc:yarn:' + project.mcVersion + '+build.22:v2' - modImplementation 'net.fabricmc:fabric-loader:0.12.12' + mappings 'net.fabricmc:yarn:' + project.mcVersion + '+build.2:v2' + modImplementation 'net.fabricmc:fabric-loader:0.13.3' } loom { diff --git a/gradle.properties b/gradle.properties index 428708c..e0e30b1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,4 +3,4 @@ org.gradle.jvmargs=-Xmx4G name=bbor buildVersion=2.4 # leave a space to reduce merge conflicts on version change -mcVersion=1.18.1 +mcVersion=1.18.2-rc1 diff --git a/src/main/java/com/irtimaled/bbor/client/config/BoundingBoxTypeHelper.java b/src/main/java/com/irtimaled/bbor/client/config/BoundingBoxTypeHelper.java index d22d71b..4d6d5ed 100644 --- a/src/main/java/com/irtimaled/bbor/client/config/BoundingBoxTypeHelper.java +++ b/src/main/java/com/irtimaled/bbor/client/config/BoundingBoxTypeHelper.java @@ -1,15 +1,16 @@ package com.irtimaled.bbor.client.config; import com.irtimaled.bbor.common.BoundingBoxType; +import it.unimi.dsi.fastutil.objects.Object2ObjectMaps; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import java.awt.*; -import java.util.HashMap; import java.util.Map; public class BoundingBoxTypeHelper { - private static final Map structureTypeMap = new HashMap<>(); + private static final Map structureTypeMap = Object2ObjectMaps.synchronize(new Object2ObjectOpenHashMap<>()); - private static void registerType(BoundingBoxType type, Setting shouldRender, Setting color) { + public static void registerType(BoundingBoxType type, Setting shouldRender, Setting color) { structureTypeMap.put(type.getName(), new BoundingBoxTypeSettings(shouldRender, color)); } @@ -28,24 +29,24 @@ public class BoundingBoxTypeHelper { registerType(BoundingBoxType.FlowerForest, ConfigManager.drawFlowerForests, null); registerType(BoundingBoxType.BedrockCeiling, ConfigManager.drawBedrockCeilingBlocks, ConfigManager.colorBedrockCeilingBlocks); - registerType(BoundingBoxType.JungleTemple, ConfigManager.drawJungleTemples, ConfigManager.colorJungleTemples); - registerType(BoundingBoxType.DesertTemple, ConfigManager.drawDesertTemples, ConfigManager.colorDesertTemples); - registerType(BoundingBoxType.WitchHut, ConfigManager.drawWitchHuts, ConfigManager.colorWitchHuts); - registerType(BoundingBoxType.OceanMonument, ConfigManager.drawOceanMonuments, ConfigManager.colorOceanMonuments); - registerType(BoundingBoxType.Shipwreck, ConfigManager.drawShipwrecks, ConfigManager.colorShipwrecks); - registerType(BoundingBoxType.OceanRuin, ConfigManager.drawOceanRuins, ConfigManager.colorOceanRuins); - registerType(BoundingBoxType.BuriedTreasure, ConfigManager.drawBuriedTreasure, ConfigManager.colorBuriedTreasure); - registerType(BoundingBoxType.Stronghold, ConfigManager.drawStrongholds, ConfigManager.colorStrongholds); - registerType(BoundingBoxType.MineShaft, ConfigManager.drawMineShafts, ConfigManager.colorMineShafts); - registerType(BoundingBoxType.NetherFortress, ConfigManager.drawNetherFortresses, ConfigManager.colorNetherFortresses); - registerType(BoundingBoxType.EndCity, ConfigManager.drawEndCities, ConfigManager.colorEndCities); - registerType(BoundingBoxType.Mansion, ConfigManager.drawMansions, ConfigManager.colorMansions); - registerType(BoundingBoxType.Igloo, ConfigManager.drawIgloos, ConfigManager.colorIgloos); - registerType(BoundingBoxType.PillagerOutpost, ConfigManager.drawPillagerOutposts, ConfigManager.colorPillagerOutposts); - registerType(BoundingBoxType.Village, ConfigManager.drawVillages, ConfigManager.colorVillages); - registerType(BoundingBoxType.NetherFossil, ConfigManager.drawNetherFossils, ConfigManager.colorNetherFossils); - registerType(BoundingBoxType.BastionRemnant, ConfigManager.drawBastionRemnants, ConfigManager.colorBastionRemnants); - registerType(BoundingBoxType.RuinedPortal, ConfigManager.drawRuinedPortals, ConfigManager.colorRuinedPortals); +// registerType(BoundingBoxType.JungleTemple, ConfigManager.drawJungleTemples, ConfigManager.colorJungleTemples); +// registerType(BoundingBoxType.DesertTemple, ConfigManager.drawDesertTemples, ConfigManager.colorDesertTemples); +// registerType(BoundingBoxType.WitchHut, ConfigManager.drawWitchHuts, ConfigManager.colorWitchHuts); +// registerType(BoundingBoxType.OceanMonument, ConfigManager.drawOceanMonuments, ConfigManager.colorOceanMonuments); +// registerType(BoundingBoxType.Shipwreck, ConfigManager.drawShipwrecks, ConfigManager.colorShipwrecks); +// registerType(BoundingBoxType.OceanRuin, ConfigManager.drawOceanRuins, ConfigManager.colorOceanRuins); +// registerType(BoundingBoxType.BuriedTreasure, ConfigManager.drawBuriedTreasure, ConfigManager.colorBuriedTreasure); +// registerType(BoundingBoxType.Stronghold, ConfigManager.drawStrongholds, ConfigManager.colorStrongholds); +// registerType(BoundingBoxType.MineShaft, ConfigManager.drawMineShafts, ConfigManager.colorMineShafts); +// registerType(BoundingBoxType.NetherFortress, ConfigManager.drawNetherFortresses, ConfigManager.colorNetherFortresses); +// registerType(BoundingBoxType.EndCity, ConfigManager.drawEndCities, ConfigManager.colorEndCities); +// registerType(BoundingBoxType.Mansion, ConfigManager.drawMansions, ConfigManager.colorMansions); +// registerType(BoundingBoxType.Igloo, ConfigManager.drawIgloos, ConfigManager.colorIgloos); +// registerType(BoundingBoxType.PillagerOutpost, ConfigManager.drawPillagerOutposts, ConfigManager.colorPillagerOutposts); +// registerType(BoundingBoxType.Village, ConfigManager.drawVillages, ConfigManager.colorVillages); +// registerType(BoundingBoxType.NetherFossil, ConfigManager.drawNetherFossils, ConfigManager.colorNetherFossils); +// registerType(BoundingBoxType.BastionRemnant, ConfigManager.drawBastionRemnants, ConfigManager.colorBastionRemnants); +// registerType(BoundingBoxType.RuinedPortal, ConfigManager.drawRuinedPortals, ConfigManager.colorRuinedPortals); } public static Setting renderSetting(BoundingBoxType type) { diff --git a/src/main/java/com/irtimaled/bbor/client/config/ConfigManager.java b/src/main/java/com/irtimaled/bbor/client/config/ConfigManager.java index 7a53b9c..f69d12a 100644 --- a/src/main/java/com/irtimaled/bbor/client/config/ConfigManager.java +++ b/src/main/java/com/irtimaled/bbor/client/config/ConfigManager.java @@ -1,7 +1,12 @@ package com.irtimaled.bbor.client.config; +import it.unimi.dsi.fastutil.objects.Object2ObjectMaps; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; + import java.io.File; import java.util.HashSet; +import java.util.Map; +import java.util.Objects; import java.util.Set; public class ConfigManager { @@ -9,14 +14,14 @@ public class ConfigManager { private static File configDir; public static Setting fill; - public static Setting drawVillages; - public static Setting drawDesertTemples; - public static Setting drawJungleTemples; - public static Setting drawWitchHuts; - public static Setting drawStrongholds; - public static Setting drawMineShafts; - public static Setting drawNetherFortresses; - public static Setting drawOceanMonuments; + // public static Setting drawVillages; +// public static Setting drawDesertTemples; +// public static Setting drawJungleTemples; +// public static Setting drawWitchHuts; +// public static Setting drawStrongholds; +// public static Setting drawMineShafts; +// public static Setting drawNetherFortresses; +// public static Setting drawOceanMonuments; public static Setting alwaysVisible; public static Setting drawSlimeChunks; public static Setting slimeChunkMaxY; @@ -24,16 +29,16 @@ public class ConfigManager { public static Setting drawWorldSpawn; public static Setting worldSpawnMaxY; public static Setting drawLazySpawnChunks; - public static Setting drawEndCities; - public static Setting drawMansions; - public static Setting drawShipwrecks; - public static Setting drawOceanRuins; - public static Setting drawBuriedTreasure; - public static Setting drawIgloos; + // public static Setting drawEndCities; +// public static Setting drawMansions; +// public static Setting drawShipwrecks; +// public static Setting drawOceanRuins; +// public static Setting drawBuriedTreasure; +// public static Setting drawIgloos; public static Setting drawMobSpawners; public static Setting renderMobSpawnerSpawnArea; public static Setting renderMobSpawnerActivationLines; - public static Setting drawPillagerOutposts; + // public static Setting drawPillagerOutposts; public static Setting outerBoxesOnly; public static Setting drawAFKSpheres; public static Setting renderAFKSpawnableBlocks; @@ -43,9 +48,9 @@ public class ConfigManager { public static Setting renderOnlyCurrentBiome; public static Setting biomeBordersRenderDistance; public static Setting biomeBordersMaxY; - public static Setting drawNetherFossils; - public static Setting drawBastionRemnants; - public static Setting drawRuinedPortals; + // public static Setting drawNetherFossils; +// public static Setting drawBastionRemnants; +// public static Setting drawRuinedPortals; public static Setting drawConduits; public static Setting renderConduitMobHarmArea; public static Setting drawSpawnableBlocks; @@ -72,24 +77,24 @@ public class ConfigManager { public static Setting colorConduits; public static Setting colorConduitMobHarmArea; public static Setting colorSpawnableBlocks; - public static Setting colorJungleTemples; - public static Setting colorDesertTemples; - public static Setting colorWitchHuts; - public static Setting colorOceanMonuments; - public static Setting colorShipwrecks; - public static Setting colorOceanRuins; - public static Setting colorBuriedTreasure; - public static Setting colorStrongholds; - public static Setting colorMineShafts; - public static Setting colorNetherFortresses; - public static Setting colorEndCities; - public static Setting colorMansions; - public static Setting colorIgloos; - public static Setting colorPillagerOutposts; - public static Setting colorVillages; - public static Setting colorNetherFossils; - public static Setting colorBastionRemnants; - public static Setting colorRuinedPortals; +// public static Setting colorJungleTemples; +// public static Setting colorDesertTemples; +// public static Setting colorWitchHuts; +// public static Setting colorOceanMonuments; +// public static Setting colorShipwrecks; +// public static Setting colorOceanRuins; +// public static Setting colorBuriedTreasure; +// public static Setting colorStrongholds; +// public static Setting colorMineShafts; +// public static Setting colorNetherFortresses; +// public static Setting colorEndCities; +// public static Setting colorMansions; +// public static Setting colorIgloos; +// public static Setting colorPillagerOutposts; +// public static Setting colorVillages; +// public static Setting colorNetherFossils; +// public static Setting colorBastionRemnants; +// public static Setting colorRuinedPortals; public static Setting colorFlowerForestDandelion; public static Setting colorFlowerForestPoppy; public static Setting colorFlowerForestAllium; @@ -107,10 +112,48 @@ public class ConfigManager { public static Setting fastRender; + public static Map> structureRenderSettings = Object2ObjectMaps.synchronize(new Object2ObjectOpenHashMap<>()); + public static Map> structureColorSettings = Object2ObjectMaps.synchronize(new Object2ObjectOpenHashMap<>()); + private static final Map defaultStructureColors = new Object2ObjectOpenHashMap<>(); + + static { + defaultStructureColors.put("minecraft:fortress", Objects.requireNonNull(HexColor.from("#ff0000"))); + defaultStructureColors.put("minecraft:village_desert", Objects.requireNonNull(HexColor.from("#800080"))); + defaultStructureColors.put("minecraft:village_snowy", Objects.requireNonNull(HexColor.from("#800080"))); + defaultStructureColors.put("minecraft:village_plains", Objects.requireNonNull(HexColor.from("#800080"))); + defaultStructureColors.put("minecraft:village_savanna", Objects.requireNonNull(HexColor.from("#800080"))); + defaultStructureColors.put("minecraft:village_taiga", Objects.requireNonNull(HexColor.from("#800080"))); + defaultStructureColors.put("minecraft:desert_pyramid", Objects.requireNonNull(HexColor.from("#ffc800"))); + defaultStructureColors.put("minecraft:swamp_hut", Objects.requireNonNull(HexColor.from("#0000ff"))); + defaultStructureColors.put("minecraft:monument", Objects.requireNonNull(HexColor.from("#00ffff"))); + defaultStructureColors.put("minecraft:shipwreck", Objects.requireNonNull(HexColor.from("#00ffff"))); + defaultStructureColors.put("minecraft:shipwreck_beached", Objects.requireNonNull(HexColor.from("#00ffff"))); + defaultStructureColors.put("minecraft:ocean_ruin_cold", Objects.requireNonNull(HexColor.from("#00ffff"))); + defaultStructureColors.put("minecraft:ocean_ruin_warm", Objects.requireNonNull(HexColor.from("#00ffff"))); + defaultStructureColors.put("minecraft:buried_treasure", Objects.requireNonNull(HexColor.from("#00ffff"))); + defaultStructureColors.put("minecraft:stronghold", Objects.requireNonNull(HexColor.from("#ffff00"))); + defaultStructureColors.put("minecraft:mineshaft", Objects.requireNonNull(HexColor.from("#c0c0c0"))); + defaultStructureColors.put("minecraft:end_city", Objects.requireNonNull(HexColor.from("#ff00ff"))); + defaultStructureColors.put("minecraft:mansion", Objects.requireNonNull(HexColor.from("#8b4513"))); + defaultStructureColors.put("minecraft:igloo", Objects.requireNonNull(HexColor.from("#ffffff"))); + defaultStructureColors.put("minecraft:pillager_outpost", Objects.requireNonNull(HexColor.from("#404040"))); + defaultStructureColors.put("minecraft:nether_fossil", Objects.requireNonNull(HexColor.from("#ffffff"))); + defaultStructureColors.put("minecraft:bastion_remnant", Objects.requireNonNull(HexColor.from("#c0c0c0"))); + defaultStructureColors.put("minecraft:ruined_portal", Objects.requireNonNull(HexColor.from("#c800ff"))); + defaultStructureColors.put("minecraft:ruined_portal_desert", Objects.requireNonNull(HexColor.from("#c800ff"))); + defaultStructureColors.put("minecraft:ruined_portal_mountain", Objects.requireNonNull(HexColor.from("#c800ff"))); + defaultStructureColors.put("minecraft:ruined_portal_jungle", Objects.requireNonNull(HexColor.from("#c800ff"))); + defaultStructureColors.put("minecraft:ruined_portal_ocean", Objects.requireNonNull(HexColor.from("#c800ff"))); + defaultStructureColors.put("minecraft:ruined_portal_swamp", Objects.requireNonNull(HexColor.from("#c800ff"))); + defaultStructureColors.put("minecraft:ruined_portal_nether", Objects.requireNonNull(HexColor.from("#c800ff"))); + } + + private static Configuration config; + public static void loadConfig() { configDir = new File(".", "config"); configDir.mkdirs(); - Configuration config = loadConfiguration(); + config = loadConfiguration(); fill = setup(config, "general", "fill", true, "If set to true the bounding boxes are filled."); outerBoxesOnly = setup(config, "general", "outerBoxesOnly", false, "If set to true only the outer bounding boxes are rendered."); @@ -136,24 +179,24 @@ public class ConfigManager { drawBedrockCeilingBlocks = setup(config, "bedrockCeiling", "drawBedrockCeilingBlocks", true, "If set to true position with only one layer of bedrock will be drawn."); - drawVillages = setup(config, "structures", "drawVillages", false, "If set to true village bounding boxes will be drawn."); - drawDesertTemples = setup(config, "structures", "drawDesertTemples", true, "If set to true desert temple bounding boxes are drawn."); - drawJungleTemples = setup(config, "structures", "drawJungleTemples", true, "If set to true jungle temple bounding boxes are drawn."); - drawWitchHuts = setup(config, "structures", "drawWitchHuts", true, "If set to true witch hut bounding boxes are drawn."); - drawStrongholds = setup(config, "structures", "drawStrongholds", false, "If set to true stronghold bounding boxes are drawn."); - drawMineShafts = setup(config, "structures", "drawMineShafts", false, "If set to true mineshaft bounding boxes are drawn."); - drawNetherFortresses = setup(config, "structures", "drawNetherFortresses", true, "If set to true nether fortress bounding boxes are drawn."); - drawOceanMonuments = setup(config, "structures", "drawOceanMonuments", true, "If set to true ocean monument bounding boxes are drawn."); - drawEndCities = setup(config, "structures", "drawEndCities", true, "If set to true end city bounding boxes will be drawn."); - drawMansions = setup(config, "structures", "drawMansions", true, "If set to true woodland mansions will be drawn."); - drawIgloos = setup(config, "structures", "drawIgloos", true, "If set to true igloos will be drawn."); - drawShipwrecks = setup(config, "structures", "drawShipwrecks", true, "If set to true shipwrecks will be drawn."); - drawOceanRuins = setup(config, "structures", "drawOceanRuins", true, "If set to true ocean ruins will be drawn."); - drawBuriedTreasure = setup(config, "structures", "drawBuriedTreasures", true, "If set to true buried treasure will be drawn."); - drawPillagerOutposts = setup(config, "structures", "drawPillagerOutposts", true, "If set to true pillager outposts will be drawn."); - drawNetherFossils = setup(config, "structures", "drawNetherFossils", true, "If set to true nether fossils will be drawn."); - drawBastionRemnants = setup(config, "structures", "drawBastionRemnants", true, "If set to true bastion remnants will be drawn."); - drawRuinedPortals = setup(config, "structures", "drawRuinedPortals", true, "If set to true ruined portals will be drawn."); +// drawVillages = setup(config, "structures", "drawVillages", false, "If set to true village bounding boxes will be drawn."); +// drawDesertTemples = setup(config, "structures", "drawDesertTemples", true, "If set to true desert temple bounding boxes are drawn."); +// drawJungleTemples = setup(config, "structures", "drawJungleTemples", true, "If set to true jungle temple bounding boxes are drawn."); +// drawWitchHuts = setup(config, "structures", "drawWitchHuts", true, "If set to true witch hut bounding boxes are drawn."); +// drawStrongholds = setup(config, "structures", "drawStrongholds", false, "If set to true stronghold bounding boxes are drawn."); +// drawMineShafts = setup(config, "structures", "drawMineShafts", false, "If set to true mineshaft bounding boxes are drawn."); +// drawNetherFortresses = setup(config, "structures", "drawNetherFortresses", true, "If set to true nether fortress bounding boxes are drawn."); +// drawOceanMonuments = setup(config, "structures", "drawOceanMonuments", true, "If set to true ocean monument bounding boxes are drawn."); +// drawEndCities = setup(config, "structures", "drawEndCities", true, "If set to true end city bounding boxes will be drawn."); +// drawMansions = setup(config, "structures", "drawMansions", true, "If set to true woodland mansions will be drawn."); +// drawIgloos = setup(config, "structures", "drawIgloos", true, "If set to true igloos will be drawn."); +// drawShipwrecks = setup(config, "structures", "drawShipwrecks", true, "If set to true shipwrecks will be drawn."); +// drawOceanRuins = setup(config, "structures", "drawOceanRuins", true, "If set to true ocean ruins will be drawn."); +// drawBuriedTreasure = setup(config, "structures", "drawBuriedTreasures", true, "If set to true buried treasure will be drawn."); +// drawPillagerOutposts = setup(config, "structures", "drawPillagerOutposts", true, "If set to true pillager outposts will be drawn."); +// drawNetherFossils = setup(config, "structures", "drawNetherFossils", true, "If set to true nether fossils will be drawn."); +// drawBastionRemnants = setup(config, "structures", "drawBastionRemnants", true, "If set to true bastion remnants will be drawn."); +// drawRuinedPortals = setup(config, "structures", "drawRuinedPortals", true, "If set to true ruined portals will be drawn."); drawSlimeChunks = setup(config, "slimeChunks", "drawSlimeChunks", true, "If set to true slime chunks bounding boxes are drawn."); slimeChunkMaxY = setup(config, "slimeChunks", "slimeChunkMaxY", -1, "The maximum top of the slime chunk bounding box. If set to -1 it will use the value when activated, if set to 0 it will always track the player's feet."); @@ -189,24 +232,24 @@ public class ConfigManager { colorConduits = setup(config, "colors", "colorConduits", HexColor.from("#00ffff"), "Color of conduit bounding spheres."); colorConduitMobHarmArea = setup(config, "colors", "colorConduitMobHarmArea", HexColor.from("#ff7f00"), "Color of conduit mob harm bounding boxes."); colorSpawnableBlocks = setup(config, "colors", "colorSpawnableBlocks", HexColor.from("#ff0000"), "Color of spawnable blocks."); - colorJungleTemples = setup(config, "colors", "colorJungleTemples", HexColor.from("#006000"), "Color of jungle temple bounding boxes."); - colorDesertTemples = setup(config, "colors", "colorDesertTemples", HexColor.from("#ffc800"), "Color of desert temple bounding boxes."); - colorWitchHuts = setup(config, "colors", "colorWitchHuts", HexColor.from("#0000ff"), "Color of witch hut bounding boxes."); - colorOceanMonuments = setup(config, "colors", "colorOceanMonuments", HexColor.from("#00ffff"), "Color of ocean monument bounding boxes."); - colorShipwrecks = setup(config, "colors", "colorShipwrecks", HexColor.from("#00ffff"), "Color of ship wrecks."); - colorOceanRuins = setup(config, "colors", "colorOceanRuins", HexColor.from("#00ffff"), "Color of ocean ruins."); - colorBuriedTreasure = setup(config, "colors", "colorBuriedTreasure", HexColor.from("#00ffff"), "Color of buried treasure."); - colorStrongholds = setup(config, "colors", "colorStrongholds", HexColor.from("#ffff00"), "Color of stronghold bounding boxes."); - colorMineShafts = setup(config, "colors", "colorMineShafts", HexColor.from("#c0c0c0"), "Color of mineshaft bounding boxes."); - colorNetherFortresses = setup(config, "colors", "colorNetherFortresses", HexColor.from("#ff0000"), "Color of nether fortress bounding boxes."); - colorEndCities = setup(config, "colors", "colorEndCities", HexColor.from("#ff00ff"), "Color of end cities."); - colorMansions = setup(config, "colors", "colorMansions", HexColor.from("#8b4513"), "Color of woodland mansions."); - colorIgloos = setup(config, "colors", "colorIgloos", HexColor.from("#ffffff"), "Color of igloos."); - colorPillagerOutposts = setup(config, "colors", "colorPillagerOutposts", HexColor.from("#404040"), "Color of pillager outposts."); - colorVillages = setup(config, "colors", "colorVillages", HexColor.from("#800080"), "Color of village bounding boxes."); - colorNetherFossils = setup(config, "colors", "colorNetherFossils", HexColor.from("#ffffff"), "Color of nether fossils."); - colorBastionRemnants = setup(config, "colors", "colorBastionRemnants", HexColor.from("#c0c0c0"), "Color of bastion remnants."); - colorRuinedPortals = setup(config, "colors", "colorRuinedPortals", HexColor.from("#c800ff"), "Color of ruined portals."); +// colorJungleTemples = setup(config, "colors", "colorJungleTemples", HexColor.from("#006000"), "Color of jungle temple bounding boxes."); +// colorDesertTemples = setup(config, "colors", "colorDesertTemples", HexColor.from("#ffc800"), "Color of desert temple bounding boxes."); +// colorWitchHuts = setup(config, "colors", "colorWitchHuts", HexColor.from("#0000ff"), "Color of witch hut bounding boxes."); +// colorOceanMonuments = setup(config, "colors", "colorOceanMonuments", HexColor.from("#00ffff"), "Color of ocean monument bounding boxes."); +// colorShipwrecks = setup(config, "colors", "colorShipwrecks", HexColor.from("#00ffff"), "Color of ship wrecks."); +// colorOceanRuins = setup(config, "colors", "colorOceanRuins", HexColor.from("#00ffff"), "Color of ocean ruins."); +// colorBuriedTreasure = setup(config, "colors", "colorBuriedTreasure", HexColor.from("#00ffff"), "Color of buried treasure."); +// colorStrongholds = setup(config, "colors", "colorStrongholds", HexColor.from("#ffff00"), "Color of stronghold bounding boxes."); +// colorMineShafts = setup(config, "colors", "colorMineShafts", HexColor.from("#c0c0c0"), "Color of mineshaft bounding boxes."); +// colorNetherFortresses = setup(config, "colors", "colorNetherFortresses", HexColor.from("#ff0000"), "Color of nether fortress bounding boxes."); +// colorEndCities = setup(config, "colors", "colorEndCities", HexColor.from("#ff00ff"), "Color of end cities."); +// colorMansions = setup(config, "colors", "colorMansions", HexColor.from("#8b4513"), "Color of woodland mansions."); +// colorIgloos = setup(config, "colors", "colorIgloos", HexColor.from("#ffffff"), "Color of igloos."); +// colorPillagerOutposts = setup(config, "colors", "colorPillagerOutposts", HexColor.from("#404040"), "Color of pillager outposts."); +// colorVillages = setup(config, "colors", "colorVillages", HexColor.from("#800080"), "Color of village bounding boxes."); +// colorNetherFossils = setup(config, "colors", "colorNetherFossils", HexColor.from("#ffffff"), "Color of nether fossils."); +// colorBastionRemnants = setup(config, "colors", "colorBastionRemnants", HexColor.from("#c0c0c0"), "Color of bastion remnants."); +// colorRuinedPortals = setup(config, "colors", "colorRuinedPortals", HexColor.from("#c800ff"), "Color of ruined portals."); colorFlowerForestDandelion = setup(config, "colors", "colorFlowerForestDandelion", HexColor.from("#ffff00"), "Color of Flower Forest Dandelion"); colorFlowerForestPoppy = setup(config, "colors", "colorFlowerForestPoppy", HexColor.from("#ff0000"), "Color of Flower Forest Poppy"); colorFlowerForestAllium = setup(config, "colors", "colorFlowerForestAllium", HexColor.from("#ff00ff"), "Color of Flower Forest Allium"); @@ -236,6 +279,18 @@ public class ConfigManager { config.save(); } + public static Setting structureShouldRender(String key) { + final Setting setting = structureRenderSettings.put(key, setup(config, "structures", "drawStructure_" + key.replace(':', '_'), true, "If set to true structure %s bounding boxes will be drawn.".formatted(key))); + saveConfig(); + return setting; + } + + public static Setting structureColor(String key) { + final Setting setting = structureColorSettings.put(key, setup(config, "colors", "colorStructure_" + key.replace(':', '_'), defaultStructureColors.getOrDefault(key, HexColor.from("#ffffff")), "Color if structure %s bounding boxes.".formatted(key))); + saveConfig(); + return setting; + } + private static Setting setup(Configuration config, String category, String settingName, T defaultValue, String comment) { Setting setting = config.get(category, settingName, defaultValue); setting.category = category; diff --git a/src/main/java/com/irtimaled/bbor/client/gui/ControlList.java b/src/main/java/com/irtimaled/bbor/client/gui/ControlList.java index f27e394..ac4f23c 100644 --- a/src/main/java/com/irtimaled/bbor/client/gui/ControlList.java +++ b/src/main/java/com/irtimaled/bbor/client/gui/ControlList.java @@ -311,7 +311,12 @@ public class ControlList extends DrawableHelper implements IControlSet { } ControlList section(String title, CreateControl... createControls) { - this.add(new ControlListSection(title, createControls)); + this.add(new ControlListSection(title, -1, createControls)); + return this; + } + + ControlList section(String title, int columnCount, CreateControl... createControls) { + this.add(new ControlListSection(title, columnCount, createControls)); return this; } diff --git a/src/main/java/com/irtimaled/bbor/client/gui/ControlListSection.java b/src/main/java/com/irtimaled/bbor/client/gui/ControlListSection.java index 9cab24f..ca32696 100644 --- a/src/main/java/com/irtimaled/bbor/client/gui/ControlListSection.java +++ b/src/main/java/com/irtimaled/bbor/client/gui/ControlListSection.java @@ -16,12 +16,12 @@ public class ControlListSection extends ControlListEntry implements IControlSet private IControl focused; private boolean dragging; - ControlListSection(String title, CreateControl... createControls) { + ControlListSection(String title, int columnCount, CreateControl... createControls) { this.title = title; this.titleHeight = title != null ? TITLE_HEIGHT : 0; this.height = titleHeight; - int columnCount = columnCount(); + if (columnCount == -1) columnCount = defaultColumnCount(); int controlWidth = (ControlList.CONTROLS_WIDTH - ((columnCount - 1) * 4)) / columnCount; int column = 0; @@ -37,7 +37,7 @@ public class ControlListSection extends ControlListEntry implements IControlSet } } - private int columnCount() { + private int defaultColumnCount() { switch (minecraft.getLanguageManager().getLanguage().getCode()) { case "en_au": case "en_us": diff --git a/src/main/java/com/irtimaled/bbor/client/gui/SettingsScreen.java b/src/main/java/com/irtimaled/bbor/client/gui/SettingsScreen.java index f4f3dc1..f85c543 100644 --- a/src/main/java/com/irtimaled/bbor/client/gui/SettingsScreen.java +++ b/src/main/java/com/irtimaled/bbor/client/gui/SettingsScreen.java @@ -4,6 +4,7 @@ import com.irtimaled.bbor.client.ClientRenderer; import com.irtimaled.bbor.client.config.ConfigManager; import com.irtimaled.bbor.client.interop.ClientInterop; import com.irtimaled.bbor.common.BoundingBoxType; +import com.irtimaled.bbor.common.StructureProcessor; import net.minecraft.SharedConstants; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; @@ -107,25 +108,17 @@ public class SettingsScreen extends ListScreen { .section(I18n.translate("bbor.features.spawningSpheres"), width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.features.spawningSpheres"), BoundingBoxType.AFKSphere), width -> new BoolSettingButton(width, I18n.translate("bbor.features.spawnableBlocks"), ConfigManager.renderAFKSpawnableBlocks)) - .section(I18n.translate("bbor.tabs.structures"), - width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.desertTemples"), BoundingBoxType.DesertTemple), - width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.jungleTemples"), BoundingBoxType.JungleTemple), - width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.witchHuts"), BoundingBoxType.WitchHut), - width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.mansions"), BoundingBoxType.Mansion), - width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.monuments"), BoundingBoxType.OceanMonument), - width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.igloos"), BoundingBoxType.Igloo), - width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.oceanRuins"), BoundingBoxType.OceanRuin), - width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.buriedTreasure"), BoundingBoxType.BuriedTreasure), - width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.shipwrecks"), BoundingBoxType.Shipwreck), - width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.strongholds"), BoundingBoxType.Stronghold), - width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.mineshafts"), BoundingBoxType.MineShaft), - width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.villages"), BoundingBoxType.Village), - width -> version.matches(pillagerOutpostVersionPattern) ? new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.pillagerOutposts"), BoundingBoxType.PillagerOutpost) : null, - width -> version.matches(bastionRemnantVersionPattern) ? new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.ruinedPortal"), BoundingBoxType.RuinedPortal) : null, - width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.fortresses"), BoundingBoxType.NetherFortress), - width -> version.matches(netherFossilVersionPattern) ? new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.netherFossils"), BoundingBoxType.NetherFossil) : null, - width -> version.matches(bastionRemnantVersionPattern) ? new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.bastionRemnants"), BoundingBoxType.BastionRemnant) : null, - width -> new BoundingBoxTypeButton(width, I18n.translate("bbor.structures.endCities"), BoundingBoxType.EndCity)); + .section(I18n.translate("bbor.tabs.structures"), 2, + generateStructureControls()); return controlList; } + + private CreateControl[] generateStructureControls() { + return StructureProcessor.supportedStructureIds + .stream() + .map(key -> (CreateControl) (width -> new BoundingBoxTypeButton(width, key, BoundingBoxType.getByNameHash(("structure:" + key).hashCode())))) + .distinct() + .toArray(CreateControl[]::new); + } + } diff --git a/src/main/java/com/irtimaled/bbor/client/interop/BiomeBorderHelper.java b/src/main/java/com/irtimaled/bbor/client/interop/BiomeBorderHelper.java index 5dd29e0..1434f3a 100644 --- a/src/main/java/com/irtimaled/bbor/client/interop/BiomeBorderHelper.java +++ b/src/main/java/com/irtimaled/bbor/client/interop/BiomeBorderHelper.java @@ -35,7 +35,7 @@ public class BiomeBorderHelper { final ClientWorld world = MinecraftClient.getInstance().world; return biomeArray.computeIfAbsent(pos.asLong(), key -> { assert world != null; - return world.getRegistryManager().get(Registry.BIOME_KEY).getRawId(world.getBiome(pos)); + return world.getRegistryManager().get(Registry.BIOME_KEY).getRawId(world.getBiome(pos).value()); }); } diff --git a/src/main/java/com/irtimaled/bbor/client/interop/FlowerForestHelper.java b/src/main/java/com/irtimaled/bbor/client/interop/FlowerForestHelper.java index ed1d486..f15f4f9 100644 --- a/src/main/java/com/irtimaled/bbor/client/interop/FlowerForestHelper.java +++ b/src/main/java/com/irtimaled/bbor/client/interop/FlowerForestHelper.java @@ -4,7 +4,6 @@ import com.irtimaled.bbor.client.config.ConfigManager; import com.irtimaled.bbor.client.config.HexColor; import com.irtimaled.bbor.client.config.Setting; import com.irtimaled.bbor.common.models.Coords; -import com.irtimaled.bbor.mixin.access.IPlacedFeature; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.client.MinecraftClient; @@ -44,9 +43,9 @@ public class FlowerForestHelper { flowerColorMap.put(Blocks.OXEYE_DAISY.getDefaultState(), ConfigManager.colorFlowerForestOxeyeDaisy); flowerColorMap.put(Blocks.CORNFLOWER.getDefaultState(), ConfigManager.colorFlowerForestCornflower); flowerColorMap.put(Blocks.LILY_OF_THE_VALLEY.getDefaultState(), ConfigManager.colorFlowerForestLilyOfTheValley); - final PlacedFeature placedFeature = VegetationConfiguredFeatures.FLOWER_FLOWER_FOREST.config.feature().get(); - final ConfiguredFeature configuredFeature = (ConfiguredFeature) ((IPlacedFeature) placedFeature).getFeature().get(); - blockStateProvider = configuredFeature.getConfig().toPlace(); + final PlacedFeature placedFeature = VegetationConfiguredFeatures.FLOWER_FLOWER_FOREST.value().config().feature().value(); + final var configuredFeature = (ConfiguredFeature) placedFeature.feature().value(); + blockStateProvider = configuredFeature.config().toPlace(); } public static Setting getFlowerColorAtPos(Coords coords) { diff --git a/src/main/java/com/irtimaled/bbor/client/interop/NBTStructureLoader.java b/src/main/java/com/irtimaled/bbor/client/interop/NBTStructureLoader.java index c6ab45c..d8c8143 100644 --- a/src/main/java/com/irtimaled/bbor/client/interop/NBTStructureLoader.java +++ b/src/main/java/com/irtimaled/bbor/client/interop/NBTStructureLoader.java @@ -21,7 +21,6 @@ import net.minecraft.world.World; import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.gen.StructureAccessor; import net.minecraft.world.gen.chunk.ChunkGenerator; -import net.minecraft.world.gen.feature.FeatureConfig; import net.minecraft.world.level.storage.LevelStorage; import net.minecraft.world.storage.RegionBasedStorage; @@ -110,7 +109,7 @@ class NBTStructureLoader { NbtCompound structureStarts = loadStructureStarts(chunkX, chunkZ); if (structureStarts == null || structureStarts.getSize() == 0) return; - Map> structureStartMap = new HashMap<>(); + Map structureStartMap = new HashMap<>(); for (String key : structureStarts.getKeys()) { NbtCompound compound = structureStarts.getCompound(key); if (compound.contains("BB")) { @@ -121,7 +120,7 @@ class NBTStructureLoader { EventBus.publish(new StructuresLoaded(structureStartMap, dimensionId)); } - private static class SimpleStructureStart extends StructureStart { + private static class SimpleStructureStart extends StructureStart { private final BlockBox parsedBoundingBox; SimpleStructureStart(NbtCompound compound) { diff --git a/src/main/java/com/irtimaled/bbor/client/interop/SpawnableBlocksHelper.java b/src/main/java/com/irtimaled/bbor/client/interop/SpawnableBlocksHelper.java index 99d3371..6d44fcd 100644 --- a/src/main/java/com/irtimaled/bbor/client/interop/SpawnableBlocksHelper.java +++ b/src/main/java/com/irtimaled/bbor/client/interop/SpawnableBlocksHelper.java @@ -1,6 +1,7 @@ package com.irtimaled.bbor.client.interop; import com.irtimaled.bbor.common.models.Coords; +import com.irtimaled.bbor.mixin.access.IBiome; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.client.MinecraftClient; @@ -49,9 +50,9 @@ public class SpawnableBlocksHelper { static boolean isSpawnable(World world, BlockPos pos, BlockState spawnBlockState, BlockState upperBlockState) { VoxelShape collisionShape = upperBlockState.getCollisionShape(world, pos); - Biome biome = world.getBiome(pos); - boolean isNether = biome.getCategory() == Biome.Category.NETHER; - return biome.getCategory() != Biome.Category.MUSHROOM && + Biome biome = world.getBiome(pos).value(); + boolean isNether = ((IBiome) biome).bbor$getCategory() == Biome.Category.NETHER; + return ((IBiome) biome).bbor$getCategory() != Biome.Category.MUSHROOM && spawnBlockState.allowsSpawning(world, pos.down(), isNether ? EntityType.ZOMBIFIED_PIGLIN : entityType) && !Block.isFaceFullSquare(collisionShape, Direction.UP) && !upperBlockState.emitsRedstonePower() && diff --git a/src/main/java/com/irtimaled/bbor/client/renderers/Renderer.java b/src/main/java/com/irtimaled/bbor/client/renderers/Renderer.java index aea5916..102c755 100644 --- a/src/main/java/com/irtimaled/bbor/client/renderers/Renderer.java +++ b/src/main/java/com/irtimaled/bbor/client/renderers/Renderer.java @@ -97,7 +97,7 @@ public class Renderer { public void render() { if (glMode == VertexFormat.DrawMode.QUADS) { - bufferBuilder.setCameraPosition((float) Camera.getX(), (float) Camera.getY(), (float) Camera.getZ()); + bufferBuilder.sortFrom((float) Camera.getX(), (float) Camera.getY(), (float) Camera.getZ()); } tessellator.draw(); matrixStack.pop(); diff --git a/src/main/java/com/irtimaled/bbor/common/BoundingBoxType.java b/src/main/java/com/irtimaled/bbor/common/BoundingBoxType.java index 38850f8..c273d74 100644 --- a/src/main/java/com/irtimaled/bbor/common/BoundingBoxType.java +++ b/src/main/java/com/irtimaled/bbor/common/BoundingBoxType.java @@ -1,10 +1,13 @@ package com.irtimaled.bbor.common; +import it.unimi.dsi.fastutil.objects.Object2ObjectMaps; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; + import java.util.HashMap; import java.util.Map; public class BoundingBoxType { - private static final Map structureTypeMap = new HashMap<>(); + private static final Map structureTypeMap = Object2ObjectMaps.synchronize(new Object2ObjectOpenHashMap<>()); public static final BoundingBoxType WorldSpawn = register("World_Spawn"); public static final BoundingBoxType SpawnChunks = register("Spawn_Chunks"); @@ -20,26 +23,9 @@ public class BoundingBoxType { public static final BoundingBoxType FlowerForest = register("Flower Forest"); public static final BoundingBoxType BedrockCeiling = register("Bedrock Ceiling"); - public static final BoundingBoxType JungleTemple = register("jungle_pyramid"); - public static final BoundingBoxType DesertTemple = register("desert_pyramid"); - public static final BoundingBoxType WitchHut = register("swamp_hut"); - public static final BoundingBoxType OceanMonument = register("monument"); - public static final BoundingBoxType Shipwreck = register("shipwreck"); - public static final BoundingBoxType OceanRuin = register("ocean_ruin"); - public static final BoundingBoxType BuriedTreasure = register("buried_treasure"); - public static final BoundingBoxType Stronghold = register("stronghold"); - public static final BoundingBoxType MineShaft = register("mineshaft"); - public static final BoundingBoxType NetherFortress = register("fortress"); - public static final BoundingBoxType EndCity = register("endcity"); - public static final BoundingBoxType Mansion = register("mansion"); - public static final BoundingBoxType Igloo = register("igloo"); - public static final BoundingBoxType PillagerOutpost = register("pillager_outpost"); - public static final BoundingBoxType Village = register("village"); - public static final BoundingBoxType NetherFossil = register("nether_fossil"); - public static final BoundingBoxType BastionRemnant = register("bastion_remnant"); - public static final BoundingBoxType RuinedPortal = register("ruined_portal"); + public static final Map structures = new HashMap<>(); - private static BoundingBoxType register(String name) { + public static BoundingBoxType register(String name) { return structureTypeMap.computeIfAbsent(name.hashCode(), k -> new BoundingBoxType(name)); } diff --git a/src/main/java/com/irtimaled/bbor/common/StructureProcessor.java b/src/main/java/com/irtimaled/bbor/common/StructureProcessor.java index f1681ce..de83f67 100644 --- a/src/main/java/com/irtimaled/bbor/common/StructureProcessor.java +++ b/src/main/java/com/irtimaled/bbor/common/StructureProcessor.java @@ -4,6 +4,10 @@ import com.irtimaled.bbor.common.models.AbstractBoundingBox; import com.irtimaled.bbor.common.models.BoundingBoxCuboid; import com.irtimaled.bbor.common.models.Coords; import com.irtimaled.bbor.mixin.access.IStructureStart; +import it.unimi.dsi.fastutil.objects.Object2ObjectMaps; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; +import it.unimi.dsi.fastutil.objects.ObjectSets; import net.minecraft.structure.StructurePiece; import net.minecraft.structure.StructureStart; import net.minecraft.util.math.BlockBox; @@ -12,11 +16,12 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -class StructureProcessor { - private static final Set supportedStructures = new HashSet<>(); +public class StructureProcessor { + private static final Map supportedStructures = Object2ObjectMaps.synchronize(new Object2ObjectOpenHashMap<>()); + public static final Set supportedStructureIds = ObjectSets.synchronize(new ObjectOpenHashSet<>()); - static void registerSupportedStructure(BoundingBoxType type) { - supportedStructures.add(type); + public static void registerSupportedStructure(BoundingBoxType type) { + supportedStructures.put(type.getName(), type); } StructureProcessor(BoundingBoxCache boundingBoxCache) { @@ -25,7 +30,7 @@ class StructureProcessor { private final BoundingBoxCache boundingBoxCache; - private void addStructures(BoundingBoxType type, StructureStart structureStart) { + private void addStructures(BoundingBoxType type, StructureStart structureStart) { if (structureStart == null) return; try { @@ -52,9 +57,12 @@ class StructureProcessor { return BoundingBoxCuboid.from(min, max, type); } - void process(Map> structures) { - if (structures.size() > 0) { - supportedStructures.forEach(type -> addStructures(type, structures.get(type.getName()))); + void process(Map structures) { + for (Map.Entry entry : structures.entrySet()) { + final BoundingBoxType type = supportedStructures.get("structure:" + entry.getKey()); + if (type != null) { + addStructures(type, entry.getValue()); + } } } } diff --git a/src/main/java/com/irtimaled/bbor/common/events/StructuresLoaded.java b/src/main/java/com/irtimaled/bbor/common/events/StructuresLoaded.java index 32b5016..1d03c50 100644 --- a/src/main/java/com/irtimaled/bbor/common/events/StructuresLoaded.java +++ b/src/main/java/com/irtimaled/bbor/common/events/StructuresLoaded.java @@ -6,15 +6,15 @@ import net.minecraft.structure.StructureStart; import java.util.Map; public class StructuresLoaded { - private final Map> structures; + private final Map structures; private final DimensionId dimensionId; - public StructuresLoaded(Map> structures, DimensionId dimensionId) { + public StructuresLoaded(Map structures, DimensionId dimensionId) { this.structures = structures; this.dimensionId = dimensionId; } - public Map> getStructures() { + public Map getStructures() { return structures; } diff --git a/src/main/java/com/irtimaled/bbor/common/interop/CommonInterop.java b/src/main/java/com/irtimaled/bbor/common/interop/CommonInterop.java index 321c4c7..b2daee1 100644 --- a/src/main/java/com/irtimaled/bbor/common/interop/CommonInterop.java +++ b/src/main/java/com/irtimaled/bbor/common/interop/CommonInterop.java @@ -1,8 +1,12 @@ package com.irtimaled.bbor.common.interop; import com.irtimaled.bbor.client.ClientRenderer; +import com.irtimaled.bbor.client.config.BoundingBoxTypeHelper; +import com.irtimaled.bbor.client.config.ConfigManager; import com.irtimaled.bbor.client.renderers.AbstractRenderer; +import com.irtimaled.bbor.common.BoundingBoxType; import com.irtimaled.bbor.common.EventBus; +import com.irtimaled.bbor.common.StructureProcessor; import com.irtimaled.bbor.common.events.PlayerLoggedIn; import com.irtimaled.bbor.common.events.PlayerLoggedOut; import com.irtimaled.bbor.common.events.PlayerSubscribed; @@ -19,24 +23,48 @@ import net.minecraft.server.network.ServerPlayNetworkHandler; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.structure.StructureStart; +import net.minecraft.util.Identifier; +import net.minecraft.util.registry.Registry; +import net.minecraft.util.registry.RegistryKey; +import net.minecraft.world.World; import net.minecraft.world.chunk.WorldChunk; +import net.minecraft.world.gen.feature.ConfiguredStructureFeature; +import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.Map; +import java.util.Optional; import java.util.function.Supplier; public class CommonInterop { public static void chunkLoaded(WorldChunk chunk) { DimensionId dimensionId = DimensionId.from(chunk.getWorld().getRegistryKey()); - Map> structures = new HashMap<>(); - chunk.getStructureStarts().entrySet().forEach(es -> structures.put(es.getKey().getName(), es.getValue())); + Map structures = new HashMap<>(); + final Registry> structureFeatureRegistry = chunk.getWorld().getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY); + for (Map.Entry, StructureStart> es : chunk.getStructureStarts().entrySet()) { + final Optional>> optional = structureFeatureRegistry.getKey(es.getKey()); + optional.ifPresent(key -> structures.put(key.getValue().toString(), es.getValue())); + } if (structures.size() > 0) EventBus.publish(new StructuresLoaded(structures, dimensionId)); } public static void loadWorlds(Collection worlds) { for (ServerWorld world : worlds) { loadWorld(world); + loadWorldStructures(world); + } + } + + public static void loadWorldStructures(World world) { + final Registry> structureFeatureRegistry = world.getRegistryManager().get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY); + System.out.println("Registring structures: " + Arrays.toString(structureFeatureRegistry.getEntrySet().stream().map(entry -> entry.getKey().getValue().toString()).distinct().toArray(String[]::new))); + for (var entry : structureFeatureRegistry.getEntrySet()) { + final Identifier value = entry.getKey().getValue(); + final BoundingBoxType boundingBoxType = BoundingBoxType.register("structure:" + value); + StructureProcessor.registerSupportedStructure(boundingBoxType); + StructureProcessor.supportedStructureIds.add(value.toString()); + BoundingBoxTypeHelper.registerType(boundingBoxType, ConfigManager.structureShouldRender(value.toString()), ConfigManager.structureColor(value.toString())); } } diff --git a/src/main/java/com/irtimaled/bbor/mixin/access/IBiome.java b/src/main/java/com/irtimaled/bbor/mixin/access/IBiome.java new file mode 100644 index 0000000..9493c63 --- /dev/null +++ b/src/main/java/com/irtimaled/bbor/mixin/access/IBiome.java @@ -0,0 +1,13 @@ +package com.irtimaled.bbor.mixin.access; + +import net.minecraft.world.biome.Biome; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(Biome.class) +public interface IBiome { + + @Accessor("category") + Biome.Category bbor$getCategory(); + +} diff --git a/src/main/java/com/irtimaled/bbor/mixin/access/IPlacedFeature.java b/src/main/java/com/irtimaled/bbor/mixin/access/IPlacedFeature.java deleted file mode 100644 index 1fca3d9..0000000 --- a/src/main/java/com/irtimaled/bbor/mixin/access/IPlacedFeature.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.irtimaled.bbor.mixin.access; - -import net.minecraft.world.gen.feature.ConfiguredFeature; -import net.minecraft.world.gen.feature.PlacedFeature; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.util.function.Supplier; - -@Mixin(PlacedFeature.class) -public interface IPlacedFeature { - - @Accessor - Supplier> getFeature(); - -} diff --git a/src/main/java/com/irtimaled/bbor/mixin/client/MixinGameSettings.java b/src/main/java/com/irtimaled/bbor/mixin/client/MixinGameSettings.java index fc3691a..5333d6e 100644 --- a/src/main/java/com/irtimaled/bbor/mixin/client/MixinGameSettings.java +++ b/src/main/java/com/irtimaled/bbor/mixin/client/MixinGameSettings.java @@ -15,18 +15,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(GameOptions.class) public abstract class MixinGameSettings { - @Mutable - @Final - @Shadow - public KeyBinding[] keysAll; @Shadow public abstract void load(); + @Mutable + @Shadow @Final public KeyBinding[] allKeys; + @Inject(method = "", at = @At("RETURN")) private void init(CallbackInfo ci) { ClientProxy.registerKeyBindings(); - keysAll = ArrayUtils.addAll(keysAll, KeyListener.keyBindings()); + allKeys = ArrayUtils.addAll(allKeys, KeyListener.keyBindings()); this.load(); } } diff --git a/src/main/java/com/irtimaled/bbor/mixin/client/MixinMinecraft.java b/src/main/java/com/irtimaled/bbor/mixin/client/MixinMinecraft.java index 5e30839..dfa2f41 100644 --- a/src/main/java/com/irtimaled/bbor/mixin/client/MixinMinecraft.java +++ b/src/main/java/com/irtimaled/bbor/mixin/client/MixinMinecraft.java @@ -1,8 +1,10 @@ package com.irtimaled.bbor.mixin.client; import com.irtimaled.bbor.client.ClientProxy; +import com.irtimaled.bbor.common.interop.CommonInterop; import net.minecraft.client.MinecraftClient; import net.minecraft.client.RunArgs; +import net.minecraft.client.world.ClientWorld; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -15,4 +17,9 @@ public abstract class MixinMinecraft { new ClientProxy().init(); } + @Inject(method = "joinWorld", at = @At("RETURN")) + private void onJoinWorld(ClientWorld world, CallbackInfo ci) { + CommonInterop.loadWorldStructures(world); + } + } diff --git a/src/main/java/com/irtimaled/bbor/mixin/resource/MixinResourcePackManager.java b/src/main/java/com/irtimaled/bbor/mixin/resource/MixinResourcePackManager.java index 5003bff..94f5e69 100644 --- a/src/main/java/com/irtimaled/bbor/mixin/resource/MixinResourcePackManager.java +++ b/src/main/java/com/irtimaled/bbor/mixin/resource/MixinResourcePackManager.java @@ -35,7 +35,7 @@ public class MixinResourcePackManager { ResourcePackSource.PACK_SOURCE_BUILTIN); } - @Redirect(method = "providePackProfiles", at = @At(value = "INVOKE", target = "Lcom/google/common/collect/ImmutableMap;copyOf(Ljava/util/Map;)Lcom/google/common/collect/ImmutableMap;")) + @Redirect(method = "providePackProfiles", at = @At(value = "INVOKE", target = "Lcom/google/common/collect/ImmutableMap;copyOf(Ljava/util/Map;)Lcom/google/common/collect/ImmutableMap;", remap = false)) private ImmutableMap beforeReturn(Map map) { map.put(BBOR, resourcePackProfile); return ImmutableMap.copyOf(map); diff --git a/src/main/resources/bbor.accesswidener b/src/main/resources/bbor.accesswidener index 2074ef3..b836b81 100644 --- a/src/main/resources/bbor.accesswidener +++ b/src/main/resources/bbor.accesswidener @@ -3,3 +3,4 @@ accessWidener v1 named accessible class net/minecraft/client/world/ClientChunkManager$ClientChunkMap extendable class net/minecraft/structure/StructureStart +extendable class net/minecraft/world/biome/Biome diff --git a/src/main/resources/bbor.mixins.json b/src/main/resources/bbor.mixins.json index b0684b6..8aee692 100644 --- a/src/main/resources/bbor.mixins.json +++ b/src/main/resources/bbor.mixins.json @@ -6,7 +6,7 @@ "package": "com.irtimaled.bbor.mixin", "mixins": [ "access.IBeaconBlockEntity", - "access.IPlacedFeature", + "access.IBiome", "access.IStructureStart", "client.renderer.MixinDebugHud", "client.renderer.MixinWorldRenderer", diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 1c6cd51..97257b6 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -12,6 +12,6 @@ "bbor.mixins.json" ], "depends": { - "minecraft": ">=1.18.1" + "minecraft": ">=1.18.2-rc.1" } } -- 2.44.0