From 289a972c0429a60af7de7e44e490d91fd4822b80 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Thu, 19 Dec 2024 12:07:20 +0200 Subject: [PATCH 01/45] add ftb chunks to build config --- dependencies.gradle | 7 +++++++ settings.gradle | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/dependencies.gradle b/dependencies.gradle index 13e072da63..22de67e18f 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -60,6 +60,9 @@ dependencies { // FTB Teams modCompileOnly(forge.ftbteams) modCompileOnly(forge.ftblibrary) + + // FTB Chunks + modCompileOnly(forge.ftbchunks) // Argonauts modCompileOnly(forge.argonauts) @@ -101,6 +104,10 @@ dependencies { modExtraRuntimeOnly(forge.xaerosminimap) modExtraRuntimeOnly(forge.xaerosworldmap) modExtraRuntimeOnly(forge.journeymap.forge) + + modExtraRuntimeOnly(forge.ftblibrary) + modExtraRuntimeOnly(forge.ftbteams) + modExtraRuntimeOnly(forge.ftbchunks) modExtraRuntimeOnly("top.theillusivec4.curios:curios-forge:${forge.versions.curios.get()}") modExtraRuntimeOnly("curse.maven:spark-361579:4738952") diff --git a/settings.gradle b/settings.gradle index fd8df091af..5c65533a4d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -41,6 +41,7 @@ dependencyResolutionManagement { def journeyMapApiVersion = "2.0.0" def ftbteamsForgeFile = "5267190" def ftblibraryForgeFile = "5567591" + def ftbchunksForgeFile = "5956390" def argonautsForgeFile = "5263580" def resourcefulForgeFile = "5659871" def kffVersion = "4.11.0" @@ -134,6 +135,9 @@ dependencyResolutionManagement { def ftblibrary = version("ftblibrary", ftblibraryForgeFile) library("ftblibrary", "curse.maven", "ftb-library-forge-404465").versionRef(ftblibrary) + + def ftbchunks = version("ftbchunks", ftbchunksForgeFile) + library("ftbchunks", "curse.maven", "ftb-chunks-forge-314906").versionRef(ftbchunks) def argonautslib = version("argonauts", argonautsForgeFile) library("argonauts", "curse.maven", "argonauts-845833").versionRef(argonautslib) From e9ac4ba8dc1e601a9826c1ab11be4f7409b49bb7 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Fri, 20 Dec 2024 12:26:27 +0200 Subject: [PATCH 02/45] temporary --- .../resources/assets/gtceu/lang/en_ud.json | 3 + .../resources/assets/gtceu/lang/en_us.json | 3 + .../gregtechceu/gtceu/common/CommonProxy.java | 5 ++ .../gtceu/data/lang/IntegrationLang.java | 4 + .../integration/map/GroupingMapRenderer.java | 3 +- .../integration/map/WaypointManager.java | 6 ++ .../map/ftbchunks/FTBChunksIntegration.java | 83 +++++++++++++++++++ .../map/ftbchunks/FTBChunksOptions.java | 33 ++++++++ .../map/ftbchunks/FTBChunksRenderer.java | 67 +++++++++++++++ .../ftbchunks/FTBChunksWaypointHandler.java | 30 +++++++ .../veins/fluid/FluidChunkHighlighter.java | 44 ++++++++++ 11 files changed, 280 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksIntegration.java create mode 100644 src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java create mode 100644 src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksRenderer.java create mode 100644 src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksWaypointHandler.java create mode 100644 src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkHighlighter.java diff --git a/src/generated/resources/assets/gtceu/lang/en_ud.json b/src/generated/resources/assets/gtceu/lang/en_ud.json index 18580338c0..aacf2c8d42 100644 --- a/src/generated/resources/assets/gtceu/lang/en_ud.json +++ b/src/generated/resources/assets/gtceu/lang/en_ud.json @@ -2122,6 +2122,9 @@ "fluid.tile.lava": "ɐʌɐꞀ", "fluid.tile.water": "ɹǝʇɐM", "fluid_cell.empty": "ʎʇdɯƎ", + "ftbchunks.gtceu_prospecting": "buıʇɔǝdsoɹԀ nƎƆ⟘⅁", + "ftbchunks.gtceu_prospecting.bedrock_fluids": "suıǝΛ pınןℲ ʞɔoɹpǝᗺ ʍoɥS", + "ftbchunks.gtceu_prospecting.ore_veins": "suıǝΛ ǝɹO ʍoɥS", "gtceu.air_scrubber": "ɹǝqqnɹɔS ɹıⱯ", "gtceu.alloy_blast_smelter": "ɹǝʇןǝɯS ʇsɐןᗺ ʎoןןⱯ", "gtceu.alloy_smelter": "ɹǝʇןǝɯS ʎoןןⱯ", diff --git a/src/generated/resources/assets/gtceu/lang/en_us.json b/src/generated/resources/assets/gtceu/lang/en_us.json index b3fdb619c0..6f858670a8 100644 --- a/src/generated/resources/assets/gtceu/lang/en_us.json +++ b/src/generated/resources/assets/gtceu/lang/en_us.json @@ -2122,6 +2122,9 @@ "fluid.tile.lava": "Lava", "fluid.tile.water": "Water", "fluid_cell.empty": "Empty", + "ftbchunks.gtceu_prospecting": "GTCEu Prospecting", + "ftbchunks.gtceu_prospecting.bedrock_fluids": "Show Bedrock Fluid Veins", + "ftbchunks.gtceu_prospecting.ore_veins": "Show Ore Veins", "gtceu.air_scrubber": "Air Scrubber", "gtceu.alloy_blast_smelter": "Alloy Blast Smelter", "gtceu.alloy_smelter": "Alloy Smelter", diff --git a/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java b/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java index 985142e0de..bd2cbcca68 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java +++ b/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java @@ -47,6 +47,7 @@ import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; import com.gregtechceu.gtceu.integration.kjs.events.MaterialModificationEventJS; import com.gregtechceu.gtceu.integration.map.WaypointManager; +import com.gregtechceu.gtceu.integration.map.ftbchunks.FTBChunksIntegration; import com.gregtechceu.gtceu.integration.top.forge.TheOneProbePluginImpl; import com.gregtechceu.gtceu.utils.input.KeyBind; @@ -247,6 +248,10 @@ public void loadComplete(FMLLoadCompleteEvent e) { GTCEu.LOGGER.info("TheOneProbe found. Enabling integration..."); TheOneProbePluginImpl.init(); } + if (GTCEu.isFTBChunksLoaded()) { + GTCEu.LOGGER.info("FTB Chunks found. Enabling integration..."); + FTBChunksIntegration.init(); + } }); } diff --git a/src/main/java/com/gregtechceu/gtceu/data/lang/IntegrationLang.java b/src/main/java/com/gregtechceu/gtceu/data/lang/IntegrationLang.java index 7835f13b8a..1a8a19e163 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/lang/IntegrationLang.java +++ b/src/main/java/com/gregtechceu/gtceu/data/lang/IntegrationLang.java @@ -112,5 +112,9 @@ private static void initMinimapLang(RegistrateLangProvider provider) { provider.add("gtceu.journeymap.options.layers", "Prospection layers"); provider.add("gtceu.journeymap.options.layers.ore_veins", "Show Ore Veins"); provider.add("gtceu.journeymap.options.layers.bedrock_fluids", "Show Bedrock Fluid Veins"); + + provider.add("ftbchunks.gtceu_prospecting", "GTCEu Prospecting"); + provider.add("ftbchunks.gtceu_prospecting.ore_veins", "Show Ore Veins"); + provider.add("ftbchunks.gtceu_prospecting.bedrock_fluids", "Show Bedrock Fluid Veins"); } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/GroupingMapRenderer.java b/src/main/java/com/gregtechceu/gtceu/integration/map/GroupingMapRenderer.java index fee59b0cff..2e3602c0d1 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/GroupingMapRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/GroupingMapRenderer.java @@ -3,6 +3,7 @@ import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.data.worldgen.ores.GeneratedVeinMetadata; import com.gregtechceu.gtceu.api.gui.misc.ProspectorMode; +import com.gregtechceu.gtceu.integration.map.ftbchunks.FTBChunksRenderer; import com.gregtechceu.gtceu.integration.map.journeymap.JourneymapRenderer; import com.gregtechceu.gtceu.integration.map.xaeros.XaerosRenderer; @@ -34,7 +35,7 @@ public class GroupingMapRenderer extends GenericMapRenderer { renderers.put(GTValues.MODID_XAEROS_MINIMAP, new XaerosRenderer()); } if (Platform.isModLoaded(GTValues.MODID_FTB_CHUNKS)) { - // TODO FTB chunks support + renderers.put(GTValues.MODID_FTB_CHUNKS, new FTBChunksRenderer()); } instance = new GroupingMapRenderer(renderers); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/WaypointManager.java b/src/main/java/com/gregtechceu/gtceu/integration/map/WaypointManager.java index 20bbc5a6ae..bb00a71cb1 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/WaypointManager.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/WaypointManager.java @@ -1,6 +1,8 @@ package com.gregtechceu.gtceu.integration.map; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; +import com.gregtechceu.gtceu.integration.map.ftbchunks.FTBChunksWaypointHandler; import com.gregtechceu.gtceu.integration.map.journeymap.JourneymapWaypointHandler; import com.gregtechceu.gtceu.integration.map.xaeros.XaeroWaypointHandler; @@ -35,6 +37,10 @@ public static void init() { WaypointManager.registerWaypointHandler(new JourneymapWaypointHandler()); active = true; } + if (GTCEu.isFTBChunksLoaded()) { + WaypointManager.registerWaypointHandler(new FTBChunksWaypointHandler()); + active = true; + } } private static final Set handlers = new HashSet<>(); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksIntegration.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksIntegration.java new file mode 100644 index 0000000000..93deced17a --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksIntegration.java @@ -0,0 +1,83 @@ +package com.gregtechceu.gtceu.integration.map.ftbchunks; + +import dev.ftb.mods.ftbchunks.api.FTBChunksAPI; +import dev.ftb.mods.ftbchunks.api.client.FTBChunksClientAPI; +import dev.ftb.mods.ftbchunks.api.client.event.MapIconEvent; +import dev.ftb.mods.ftbchunks.api.client.icon.MapType; +import dev.ftb.mods.ftbchunks.api.client.waypoint.Waypoint; +import dev.ftb.mods.ftbchunks.api.client.waypoint.WaypointManager; +import dev.ftb.mods.ftbchunks.client.map.MapDimension; +import dev.ftb.mods.ftbchunks.client.map.MapManager; +import lombok.Getter; +import net.minecraft.core.BlockPos; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; + +public class FTBChunksIntegration { + + @Getter + private static FTBChunksClientAPI clientAPI; + + @Getter + private static WaypointManager waypointManager; + + @Getter + private static FTBChunksOptions options; + + public static void init() { + options = new FTBChunksOptions(); + clientAPI = FTBChunksAPI.clientApi(); + if (clientAPI.getWaypointManager().isPresent()) { + waypointManager = clientAPI.getWaypointManager().get(); + } else { + waypointManager = new WaypointManager() { + @Override + public Waypoint addWaypointAt(BlockPos blockPos, String s) { + return null; + } + + @Override + public boolean removeWaypointAt(BlockPos blockPos) { + return false; + } + + @Override + public boolean removeWaypoint(Waypoint waypoint) { + return false; + } + + @Override + public Collection getAllWaypoints() { + return List.of(); + } + + @Override + public Optional getNearestDeathpoint(Player player) { + return Optional.empty(); + } + }; + } + MapIconEvent.MINIMAP.register(FTBChunksIntegration::onMapIconEvent); + MapIconEvent.LARGE_MAP.register(FTBChunksIntegration::onMapIconEvent); + } + + private static void onMapIconEvent(MapIconEvent event) { + if (event.getMapType() == MapType.MINIMAP) { + // todo: check if point is within render distance before adding + } + + } + + public static Optional getMapManager() { + return MapManager.getInstance(); + } + + public static Optional getMapDimension(ResourceKey dimension) { + return getMapManager().map(manager -> manager.getDimension(dimension)); + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java new file mode 100644 index 0000000000..a37678ea56 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java @@ -0,0 +1,33 @@ +package com.gregtechceu.gtceu.integration.map.ftbchunks; + +import dev.ftb.mods.ftblibrary.snbt.config.BooleanValue; + +import java.util.HashMap; +import java.util.Map; + +import static dev.ftb.mods.ftbchunks.client.FTBChunksClientConfig.CONFIG; + +public class FTBChunksOptions { + private final Map layerOptions = new HashMap<>(); + + public FTBChunksOptions() { + var group = CONFIG.addGroup("gtceu_prospecting"); + final var oreLayer = group.addBoolean("ore_veins", false); + layerOptions.put(oreLayer.key, oreLayer); + final var fluidLayer = group.addBoolean("bedrock_fluids", false); + layerOptions.put(fluidLayer.key, fluidLayer); + } + + public boolean showLayer(String name) { + return layerOptions.get(name).get(); + } + + public void toggleLayer(String name, boolean active) { + layerOptions.get(name).set(active); + FTBChunksIntegration.getWaypointManager().getAllWaypoints().forEach(waypoint -> { + if (waypoint.getName().equals(name)) { + waypoint.setHidden(!active); + } + }); + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksRenderer.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksRenderer.java new file mode 100644 index 0000000000..31595abb49 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksRenderer.java @@ -0,0 +1,67 @@ +package com.gregtechceu.gtceu.integration.map.ftbchunks; + +import com.google.common.collect.HashBasedTable; +import com.google.common.collect.Table; +import com.gregtechceu.gtceu.api.data.chemical.material.Material; +import com.gregtechceu.gtceu.api.data.worldgen.ores.GeneratedVeinMetadata; +import com.gregtechceu.gtceu.api.gui.misc.ProspectorMode; +import com.gregtechceu.gtceu.integration.map.GenericMapRenderer; +import com.gregtechceu.gtceu.integration.map.ftbchunks.veins.fluid.FluidChunkHighlighter; +import com.gregtechceu.gtceu.integration.map.xaeros.minimap.ore.OreVeinElement; +import com.mojang.blaze3d.platform.NativeImage; +import dev.ftb.mods.ftbchunks.api.FTBChunksAPI; +import dev.ftb.mods.ftbchunks.client.map.MapManager; +import dev.ftb.mods.ftblibrary.ui.Widget; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import journeymap.client.api.display.Overlay; +import lombok.Getter; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.Level; + +import java.util.HashMap; +import java.util.Map; + +public class FTBChunksRenderer extends GenericMapRenderer { + public static final Table, String, OreVeinElement> oreElements = HashBasedTable.create(); + public static final Table, ChunkPos, ProspectorMode.FluidInfo> fluidElements = HashBasedTable + .create(); + + @Getter + private static final Map markers = new Object2ObjectOpenHashMap<>(); + + @Override + public boolean addMarker(String name, String id, ResourceKey dim, ChunkPos pos, ProspectorMode.FluidInfo fluid) { + fluidElements.put(dim, pos, fluid); + if (MapManager.getInstance().isPresent()) { + var mapManager = MapManager.getInstance().get(); + var mapDimension = mapManager.getDimension(dim); + mapDimension.get + new FluidChunkHighlighter() + } + return true; + } + + @Override + public boolean addMarker(String name, ResourceKey dim, GeneratedVeinMetadata vein, String id) { + oreElements.put(dim, id, new OreVeinElement(vein, name)); + return true; + } + + @Override + public boolean removeMarker(ResourceKey dim, String id) { + OreVeinElement marker = oreElements.remove(dim, id); + return marker != null; + } + + @Override + public boolean doShowLayer(String name) { + return FTBChunksIntegration.getOptions().showLayer(name); + } + + @Override + public void setLayerActive(String name, boolean active) { + FTBChunksIntegration.getOptions().toggleLayer(name, active); + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksWaypointHandler.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksWaypointHandler.java new file mode 100644 index 0000000000..7aba355ce5 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksWaypointHandler.java @@ -0,0 +1,30 @@ +package com.gregtechceu.gtceu.integration.map.ftbchunks; + +import com.gregtechceu.gtceu.integration.map.IWaypointHandler; +import dev.ftb.mods.ftbchunks.api.client.waypoint.Waypoint; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import net.minecraft.core.BlockPos; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.Level; + +import java.util.Map; + +public class FTBChunksWaypointHandler implements IWaypointHandler { + private static final Map waypoints = new Object2ObjectOpenHashMap<>(); + + @Override + public void setWaypoint(String key, String name, int color, ResourceKey dim, int x, int y, int z) { + var waypoint = FTBChunksIntegration.getWaypointManager().addWaypointAt(new BlockPos(x, y, z), name) + .setColor(color) + .setHidden(false); + waypoints.put(key, waypoint); + } + + @Override + public void removeWaypoint(String key) { + var removed = waypoints.remove(key); + if (removed != null) { + FTBChunksIntegration.getWaypointManager().removeWaypoint(removed); + } + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkHighlighter.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkHighlighter.java new file mode 100644 index 0000000000..fbebb2391d --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkHighlighter.java @@ -0,0 +1,44 @@ +package com.gregtechceu.gtceu.integration.map.ftbchunks.veins.fluid; + +import com.gregtechceu.gtceu.integration.map.GroupingMapRenderer; +import dev.ftb.mods.ftbchunks.client.gui.MapIconWidget; +import dev.ftb.mods.ftbchunks.client.map.MapChunk; +import dev.ftb.mods.ftbchunks.client.map.MapDimension; +import dev.ftb.mods.ftblibrary.math.XZ; +import dev.ftb.mods.ftblibrary.ui.Panel; +import dev.ftb.mods.ftblibrary.util.TooltipList; +import lombok.Getter; +import net.minecraft.world.level.ChunkPos; + +@Getter +public class FluidChunkHighlighter extends MapIconWidget { + protected MapDimension dimension; + protected int chunkX; + protected int chunkZ; + protected MapChunk mapChunk; + + public FluidChunkHighlighter(Panel p, MapDimension dimension, ChunkPos chunkPos) { + super(p); + this.dimension = dimension; + this.chunkX = chunkPos.x; + this.chunkZ = chunkPos.z; + var pos = XZ.regionFromChunk(chunkPos); + this.mapChunk = this.dimension.getRegion(pos).getDataBlocking().getChunk(pos); + } + + @Override + public boolean isEnabled() { + return GroupingMapRenderer.getInstance().doShowLayer("bedrock_fluids"); + } + + @Override + public boolean shouldDraw() { + return isEnabled(); + } + + @Override + public void addMouseOverText(TooltipList list) { + super.addMouseOverText(list); + // todo: append tooltips + } +} From d49451acca1e71d27a125cc2132aa1d051632d16 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Wed, 25 Dec 2024 09:53:35 +0200 Subject: [PATCH 03/45] got the ore veins working --- .../gregtechceu/gtceu/client/ClientProxy.java | 6 ++ .../gregtechceu/gtceu/common/CommonProxy.java | 5 - .../map/ftbchunks/FTBChunksIntegration.java | 83 ---------------- .../map/ftbchunks/FTBChunksOptions.java | 17 ++-- .../map/ftbchunks/FTBChunksPlugin.java | 36 +++++++ .../map/ftbchunks/FTBChunksRenderer.java | 44 ++++----- .../ftbchunks/FTBChunksWaypointHandler.java | 23 +++-- .../veins/fluid/FluidChunkHighlighter.java | 17 ++-- .../map/ftbchunks/veins/ore/OreVeinIcon.java | 99 +++++++++++++++++++ 9 files changed, 188 insertions(+), 142 deletions(-) delete mode 100644 src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksIntegration.java create mode 100644 src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksPlugin.java create mode 100644 src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java diff --git a/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java b/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java index b23b52183e..903a5030b1 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java +++ b/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.client; +import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition; import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; import com.gregtechceu.gtceu.api.data.worldgen.bedrockore.BedrockOreDefinition; @@ -13,11 +14,13 @@ import com.gregtechceu.gtceu.common.entity.GTBoat; import com.gregtechceu.gtceu.integration.map.ClientCacheManager; import com.gregtechceu.gtceu.integration.map.cache.client.GTClientCache; +import com.gregtechceu.gtceu.integration.map.ftbchunks.FTBChunksPlugin; import com.gregtechceu.gtceu.integration.map.layer.Layers; import com.gregtechceu.gtceu.integration.map.layer.builtin.FluidRenderLayer; import com.gregtechceu.gtceu.integration.map.layer.builtin.OreRenderLayer; import com.gregtechceu.gtceu.utils.input.KeyBind; +import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.Platform; import net.minecraft.client.model.BoatModel; @@ -57,6 +60,9 @@ public static void init() { ClientCacheManager.registerClientCache(GTClientCache.instance, "gtceu"); Layers.registerLayer(OreRenderLayer::new, "ore_veins"); Layers.registerLayer(FluidRenderLayer::new, "bedrock_fluids"); + if (LDLib.isModLoaded(GTValues.MODID_FTB_CHUNKS)) { + FTBChunksPlugin.getInstance().initialize(); + } } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java b/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java index bd2cbcca68..985142e0de 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java +++ b/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java @@ -47,7 +47,6 @@ import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; import com.gregtechceu.gtceu.integration.kjs.events.MaterialModificationEventJS; import com.gregtechceu.gtceu.integration.map.WaypointManager; -import com.gregtechceu.gtceu.integration.map.ftbchunks.FTBChunksIntegration; import com.gregtechceu.gtceu.integration.top.forge.TheOneProbePluginImpl; import com.gregtechceu.gtceu.utils.input.KeyBind; @@ -248,10 +247,6 @@ public void loadComplete(FMLLoadCompleteEvent e) { GTCEu.LOGGER.info("TheOneProbe found. Enabling integration..."); TheOneProbePluginImpl.init(); } - if (GTCEu.isFTBChunksLoaded()) { - GTCEu.LOGGER.info("FTB Chunks found. Enabling integration..."); - FTBChunksIntegration.init(); - } }); } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksIntegration.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksIntegration.java deleted file mode 100644 index 93deced17a..0000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksIntegration.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.gregtechceu.gtceu.integration.map.ftbchunks; - -import dev.ftb.mods.ftbchunks.api.FTBChunksAPI; -import dev.ftb.mods.ftbchunks.api.client.FTBChunksClientAPI; -import dev.ftb.mods.ftbchunks.api.client.event.MapIconEvent; -import dev.ftb.mods.ftbchunks.api.client.icon.MapType; -import dev.ftb.mods.ftbchunks.api.client.waypoint.Waypoint; -import dev.ftb.mods.ftbchunks.api.client.waypoint.WaypointManager; -import dev.ftb.mods.ftbchunks.client.map.MapDimension; -import dev.ftb.mods.ftbchunks.client.map.MapManager; -import lombok.Getter; -import net.minecraft.core.BlockPos; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; - -import java.util.Collection; -import java.util.List; -import java.util.Optional; - -public class FTBChunksIntegration { - - @Getter - private static FTBChunksClientAPI clientAPI; - - @Getter - private static WaypointManager waypointManager; - - @Getter - private static FTBChunksOptions options; - - public static void init() { - options = new FTBChunksOptions(); - clientAPI = FTBChunksAPI.clientApi(); - if (clientAPI.getWaypointManager().isPresent()) { - waypointManager = clientAPI.getWaypointManager().get(); - } else { - waypointManager = new WaypointManager() { - @Override - public Waypoint addWaypointAt(BlockPos blockPos, String s) { - return null; - } - - @Override - public boolean removeWaypointAt(BlockPos blockPos) { - return false; - } - - @Override - public boolean removeWaypoint(Waypoint waypoint) { - return false; - } - - @Override - public Collection getAllWaypoints() { - return List.of(); - } - - @Override - public Optional getNearestDeathpoint(Player player) { - return Optional.empty(); - } - }; - } - MapIconEvent.MINIMAP.register(FTBChunksIntegration::onMapIconEvent); - MapIconEvent.LARGE_MAP.register(FTBChunksIntegration::onMapIconEvent); - } - - private static void onMapIconEvent(MapIconEvent event) { - if (event.getMapType() == MapType.MINIMAP) { - // todo: check if point is within render distance before adding - } - - } - - public static Optional getMapManager() { - return MapManager.getInstance(); - } - - public static Optional getMapDimension(ResourceKey dimension) { - return getMapManager().map(manager -> manager.getDimension(dimension)); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java index a37678ea56..f2c4e1c2a0 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java @@ -8,8 +8,9 @@ import static dev.ftb.mods.ftbchunks.client.FTBChunksClientConfig.CONFIG; public class FTBChunksOptions { + private final Map layerOptions = new HashMap<>(); - + public FTBChunksOptions() { var group = CONFIG.addGroup("gtceu_prospecting"); final var oreLayer = group.addBoolean("ore_veins", false); @@ -17,17 +18,19 @@ public FTBChunksOptions() { final var fluidLayer = group.addBoolean("bedrock_fluids", false); layerOptions.put(fluidLayer.key, fluidLayer); } - + public boolean showLayer(String name) { return layerOptions.get(name).get(); } - + public void toggleLayer(String name, boolean active) { layerOptions.get(name).set(active); - FTBChunksIntegration.getWaypointManager().getAllWaypoints().forEach(waypoint -> { - if (waypoint.getName().equals(name)) { - waypoint.setHidden(!active); - } + FTBChunksPlugin.getInstance().clientAPI.getWaypointManager().ifPresent(manager -> { + manager.getAllWaypoints().forEach(waypoint -> { + if (waypoint.getName().equals(name)) { + waypoint.setHidden(!active); + } + }); }); } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksPlugin.java new file mode 100644 index 0000000000..f727d5bca3 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksPlugin.java @@ -0,0 +1,36 @@ +package com.gregtechceu.gtceu.integration.map.ftbchunks; + +import com.gregtechceu.gtceu.integration.map.GroupingMapRenderer; + +import dev.ftb.mods.ftbchunks.api.FTBChunksAPI; +import dev.ftb.mods.ftbchunks.api.client.FTBChunksClientAPI; +import dev.ftb.mods.ftbchunks.api.client.event.MapIconEvent; +import dev.ftb.mods.ftbchunks.client.map.MapDimension; + +public class FTBChunksPlugin { + + private static FTBChunksPlugin instance; + + protected FTBChunksClientAPI clientAPI; + protected FTBChunksOptions options; + + protected FTBChunksPlugin() {} + + public static FTBChunksPlugin getInstance() { + return instance == null ? instance = new FTBChunksPlugin() : instance; + } + + public void initialize() { + options = new FTBChunksOptions(); + clientAPI = FTBChunksAPI.clientApi(); + + MapIconEvent.MINIMAP.register(this::mapIconEventHandler); + MapIconEvent.LARGE_MAP.register(this::mapIconEventHandler); + } + + private void mapIconEventHandler(MapIconEvent event) { + if (!GroupingMapRenderer.getInstance().doShowLayer("ore_veins")) return; + MapDimension.getCurrent().ifPresent( + mapDimension -> FTBChunksRenderer.oreElements.row(mapDimension.dimension).values().forEach(event::add)); + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksRenderer.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksRenderer.java index 31595abb49..731d1b5173 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksRenderer.java @@ -1,67 +1,57 @@ package com.gregtechceu.gtceu.integration.map.ftbchunks; -import com.google.common.collect.HashBasedTable; -import com.google.common.collect.Table; -import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.worldgen.ores.GeneratedVeinMetadata; import com.gregtechceu.gtceu.api.gui.misc.ProspectorMode; import com.gregtechceu.gtceu.integration.map.GenericMapRenderer; -import com.gregtechceu.gtceu.integration.map.ftbchunks.veins.fluid.FluidChunkHighlighter; -import com.gregtechceu.gtceu.integration.map.xaeros.minimap.ore.OreVeinElement; -import com.mojang.blaze3d.platform.NativeImage; -import dev.ftb.mods.ftbchunks.api.FTBChunksAPI; -import dev.ftb.mods.ftbchunks.client.map.MapManager; -import dev.ftb.mods.ftblibrary.ui.Widget; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; -import journeymap.client.api.display.Overlay; -import lombok.Getter; +import com.gregtechceu.gtceu.integration.map.ftbchunks.veins.ore.OreVeinIcon; + import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; -import java.util.HashMap; +import com.google.common.collect.HashBasedTable; +import com.google.common.collect.Table; +import dev.ftb.mods.ftblibrary.ui.Widget; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import lombok.Getter; + import java.util.Map; public class FTBChunksRenderer extends GenericMapRenderer { - public static final Table, String, OreVeinElement> oreElements = HashBasedTable.create(); + + public static final Table, String, OreVeinIcon> oreElements = HashBasedTable.create(); public static final Table, ChunkPos, ProspectorMode.FluidInfo> fluidElements = HashBasedTable .create(); @Getter private static final Map markers = new Object2ObjectOpenHashMap<>(); - + @Override - public boolean addMarker(String name, String id, ResourceKey dim, ChunkPos pos, ProspectorMode.FluidInfo fluid) { + public boolean addMarker(String name, String id, ResourceKey dim, ChunkPos pos, + ProspectorMode.FluidInfo fluid) { fluidElements.put(dim, pos, fluid); - if (MapManager.getInstance().isPresent()) { - var mapManager = MapManager.getInstance().get(); - var mapDimension = mapManager.getDimension(dim); - mapDimension.get - new FluidChunkHighlighter() - } return true; } @Override public boolean addMarker(String name, ResourceKey dim, GeneratedVeinMetadata vein, String id) { - oreElements.put(dim, id, new OreVeinElement(vein, name)); + oreElements.put(dim, id, new OreVeinIcon(vein)); return true; } @Override public boolean removeMarker(ResourceKey dim, String id) { - OreVeinElement marker = oreElements.remove(dim, id); + var marker = oreElements.remove(dim, id); return marker != null; } @Override public boolean doShowLayer(String name) { - return FTBChunksIntegration.getOptions().showLayer(name); + return FTBChunksPlugin.getInstance().options.showLayer(name); } @Override public void setLayerActive(String name, boolean active) { - FTBChunksIntegration.getOptions().toggleLayer(name, active); + FTBChunksPlugin.getInstance().options.toggleLayer(name, active); } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksWaypointHandler.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksWaypointHandler.java index 7aba355ce5..88bbe2446c 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksWaypointHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksWaypointHandler.java @@ -1,30 +1,33 @@ package com.gregtechceu.gtceu.integration.map.ftbchunks; import com.gregtechceu.gtceu.integration.map.IWaypointHandler; -import dev.ftb.mods.ftbchunks.api.client.waypoint.Waypoint; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; + import net.minecraft.core.BlockPos; import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.Level; +import dev.ftb.mods.ftbchunks.api.client.waypoint.Waypoint; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; + import java.util.Map; public class FTBChunksWaypointHandler implements IWaypointHandler { + private static final Map waypoints = new Object2ObjectOpenHashMap<>(); - + @Override public void setWaypoint(String key, String name, int color, ResourceKey dim, int x, int y, int z) { - var waypoint = FTBChunksIntegration.getWaypointManager().addWaypointAt(new BlockPos(x, y, z), name) - .setColor(color) - .setHidden(false); - waypoints.put(key, waypoint); + FTBChunksPlugin.getInstance().clientAPI.getWaypointManager() + .map(manager -> manager.addWaypointAt( + new BlockPos(x, y, z), name).setColor(color).setHidden(false)) + .map(waypoint -> waypoints.put(key, waypoint)); } @Override public void removeWaypoint(String key) { var removed = waypoints.remove(key); - if (removed != null) { - FTBChunksIntegration.getWaypointManager().removeWaypoint(removed); - } + if (removed != null) + FTBChunksPlugin.getInstance().clientAPI.getWaypointManager() + .ifPresent(manager -> manager.removeWaypoint(removed)); } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkHighlighter.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkHighlighter.java index fbebb2391d..e4a921e56a 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkHighlighter.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkHighlighter.java @@ -1,44 +1,41 @@ package com.gregtechceu.gtceu.integration.map.ftbchunks.veins.fluid; import com.gregtechceu.gtceu.integration.map.GroupingMapRenderer; -import dev.ftb.mods.ftbchunks.client.gui.MapIconWidget; + +import net.minecraft.world.level.ChunkPos; + import dev.ftb.mods.ftbchunks.client.map.MapChunk; import dev.ftb.mods.ftbchunks.client.map.MapDimension; import dev.ftb.mods.ftblibrary.math.XZ; import dev.ftb.mods.ftblibrary.ui.Panel; import dev.ftb.mods.ftblibrary.util.TooltipList; import lombok.Getter; -import net.minecraft.world.level.ChunkPos; @Getter -public class FluidChunkHighlighter extends MapIconWidget { +public class FluidChunkHighlighter { + protected MapDimension dimension; protected int chunkX; protected int chunkZ; protected MapChunk mapChunk; - + public FluidChunkHighlighter(Panel p, MapDimension dimension, ChunkPos chunkPos) { - super(p); this.dimension = dimension; this.chunkX = chunkPos.x; this.chunkZ = chunkPos.z; var pos = XZ.regionFromChunk(chunkPos); - this.mapChunk = this.dimension.getRegion(pos).getDataBlocking().getChunk(pos); + this.mapChunk = this.dimension.getRegion(pos).getDataBlocking().getChunk(pos); } - @Override public boolean isEnabled() { return GroupingMapRenderer.getInstance().doShowLayer("bedrock_fluids"); } - @Override public boolean shouldDraw() { return isEnabled(); } - @Override public void addMouseOverText(TooltipList list) { - super.addMouseOverText(list); // todo: append tooltips } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java new file mode 100644 index 0000000000..ded0b0e777 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java @@ -0,0 +1,99 @@ +package com.gregtechceu.gtceu.integration.map.ftbchunks.veins.ore; + +import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconType; +import com.gregtechceu.gtceu.api.data.worldgen.ores.GeneratedVeinMetadata; +import com.gregtechceu.gtceu.client.util.DrawUtil; +import com.gregtechceu.gtceu.config.ConfigHolder; +import com.gregtechceu.gtceu.integration.map.layer.builtin.OreRenderLayer; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.inventory.InventoryMenu; +import net.minecraft.world.phys.Vec3; + +import com.mojang.blaze3d.platform.InputConstants; +import com.mojang.blaze3d.systems.RenderSystem; +import dev.ftb.mods.ftbchunks.api.client.icon.MapIcon; +import dev.ftb.mods.ftbchunks.api.client.icon.MapType; +import dev.ftb.mods.ftblibrary.ui.BaseScreen; +import dev.ftb.mods.ftblibrary.ui.input.Key; +import dev.ftb.mods.ftblibrary.ui.input.MouseButton; +import dev.ftb.mods.ftblibrary.util.TooltipList; + +import java.util.List; + +public class OreVeinIcon implements MapIcon { + + protected final GeneratedVeinMetadata veinMetadata; + protected String name = null; + protected List tooltip = null; + + public OreVeinIcon(GeneratedVeinMetadata veinMetadata) { + this.veinMetadata = veinMetadata; + } + + @Override + public Vec3 getPos(float v) { + return veinMetadata.center().getCenter(); + } + + @Override + public boolean onMousePressed(BaseScreen baseScreen, MouseButton mouseButton) { + return false; + } + + @Override + public boolean onKeyPressed(BaseScreen baseScreen, Key key) { + if (key.is(InputConstants.KEY_DELETE)) { + veinMetadata.depleted(!veinMetadata.depleted()); + } + return false; + } + + @Override + public void addTooltip(TooltipList list) { + if (name == null) name = OreRenderLayer.getName(veinMetadata).getString(); + OreRenderLayer.getTooltip(name, veinMetadata).forEach(list::add); + } + + @Override + public void draw(MapType mapType, GuiGraphics graphics, int x, int y, int w, int h, boolean outsideVisibleArea, + int iconAlpha) { + var iconSize = ConfigHolder.INSTANCE.compat.minimap.oreIconSize; + + var firstMaterial = veinMetadata.definition().veinGenerator().getAllMaterials().get(0); + int materialARGB = firstMaterial.getMaterialARGB(); + var colors = DrawUtil.floats(materialARGB); + RenderSystem.setShaderColor(1, 1, 1, 1); + + ResourceLocation oreTexture = MaterialIconType.rawOre.getItemTexturePath(firstMaterial.getMaterialIconSet(), + true); + if (oreTexture != null) { + var oreSprite = Minecraft.getInstance() + .getTextureAtlas(InventoryMenu.BLOCK_ATLAS) + .apply(oreTexture); + graphics.blit(x, y, 0, w, h, oreSprite, colors[0], colors[1], colors[2], 1); + } + oreTexture = MaterialIconType.rawOre.getItemTexturePath(firstMaterial.getMaterialIconSet(), "secondary", true); + if (oreTexture != null) { + var materialSecondaryARGB = firstMaterial.getMaterialSecondaryARGB(); + colors = DrawUtil.floats(materialSecondaryARGB); + var oreSprite = Minecraft.getInstance() + .getTextureAtlas(InventoryMenu.BLOCK_ATLAS) + .apply(oreTexture); + graphics.blit(x, y, 0, w, h, oreSprite, colors[0], colors[1], colors[2], 1); + } + + RenderSystem.setShaderColor(1, 1, 1, 1); + var borderColor = ConfigHolder.INSTANCE.compat.minimap.getBorderColor(materialARGB | 0xFF000000); + if ((borderColor & 0xFF000000) != 0) { + var thickness = iconSize / 16; + graphics.fill(x, y, x + w, y + h + thickness, borderColor); + graphics.fill(x, y - (h / 16), x + w, y + h + thickness, borderColor); + graphics.fill(x, y, x + w + (w / 16), y + h, borderColor); + graphics.fill(x - thickness, y, x + w + thickness, y + h, borderColor); + } + } +} From ece8cc3a7e54dbf8e8381780772152b3fd609452 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Wed, 25 Dec 2024 14:45:49 +0200 Subject: [PATCH 04/45] lang --- src/generated/resources/assets/gtceu/lang/en_ud.json | 1 - src/generated/resources/assets/gtceu/lang/en_us.json | 1 - .../java/com/gregtechceu/gtceu/data/lang/IntegrationLang.java | 2 +- .../com/gregtechceu/gtceu/integration/map/WaypointManager.java | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/generated/resources/assets/gtceu/lang/en_ud.json b/src/generated/resources/assets/gtceu/lang/en_ud.json index aacf2c8d42..523c70757f 100644 --- a/src/generated/resources/assets/gtceu/lang/en_ud.json +++ b/src/generated/resources/assets/gtceu/lang/en_ud.json @@ -1742,7 +1742,6 @@ "config.gtceu.option.enableCleanroom": "ɯooɹuɐǝןƆǝןqɐuǝ", "config.gtceu.option.enableFEConverters": "sɹǝʇɹǝʌuoƆƎℲǝןqɐuǝ", "config.gtceu.option.enableMaintenance": "ǝɔuɐuǝʇuıɐWǝןqɐuǝ", - "config.gtceu.option.enableMoreDualHatchAbility": "ʎʇıןıqⱯɥɔʇɐHןɐnᗡǝɹoWǝןqɐuǝ", "config.gtceu.option.enableResearch": "ɥɔɹɐǝsǝᴚǝןqɐuǝ", "config.gtceu.option.enableTieredCasings": "sbuısɐƆpǝɹǝı⟘ǝןqɐuǝ", "config.gtceu.option.enableWorldAccelerators": "sɹoʇɐɹǝןǝɔɔⱯpןɹoMǝןqɐuǝ", diff --git a/src/generated/resources/assets/gtceu/lang/en_us.json b/src/generated/resources/assets/gtceu/lang/en_us.json index 6f858670a8..acb12541a0 100644 --- a/src/generated/resources/assets/gtceu/lang/en_us.json +++ b/src/generated/resources/assets/gtceu/lang/en_us.json @@ -1742,7 +1742,6 @@ "config.gtceu.option.enableCleanroom": "enableCleanroom", "config.gtceu.option.enableFEConverters": "enableFEConverters", "config.gtceu.option.enableMaintenance": "enableMaintenance", - "config.gtceu.option.enableMoreDualHatchAbility": "enableMoreDualHatchAbility", "config.gtceu.option.enableResearch": "enableResearch", "config.gtceu.option.enableTieredCasings": "enableTieredCasings", "config.gtceu.option.enableWorldAccelerators": "enableWorldAccelerators", diff --git a/src/main/java/com/gregtechceu/gtceu/data/lang/IntegrationLang.java b/src/main/java/com/gregtechceu/gtceu/data/lang/IntegrationLang.java index 1a8a19e163..e4ba6bab7e 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/lang/IntegrationLang.java +++ b/src/main/java/com/gregtechceu/gtceu/data/lang/IntegrationLang.java @@ -112,7 +112,7 @@ private static void initMinimapLang(RegistrateLangProvider provider) { provider.add("gtceu.journeymap.options.layers", "Prospection layers"); provider.add("gtceu.journeymap.options.layers.ore_veins", "Show Ore Veins"); provider.add("gtceu.journeymap.options.layers.bedrock_fluids", "Show Bedrock Fluid Veins"); - + provider.add("ftbchunks.gtceu_prospecting", "GTCEu Prospecting"); provider.add("ftbchunks.gtceu_prospecting.ore_veins", "Show Ore Veins"); provider.add("ftbchunks.gtceu_prospecting.bedrock_fluids", "Show Bedrock Fluid Veins"); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/WaypointManager.java b/src/main/java/com/gregtechceu/gtceu/integration/map/WaypointManager.java index bb00a71cb1..b6fe6c6e48 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/WaypointManager.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/WaypointManager.java @@ -37,7 +37,7 @@ public static void init() { WaypointManager.registerWaypointHandler(new JourneymapWaypointHandler()); active = true; } - if (GTCEu.isFTBChunksLoaded()) { + if (Platform.isModLoaded(GTValues.MODID_FTB_CHUNKS)) { WaypointManager.registerWaypointHandler(new FTBChunksWaypointHandler()); active = true; } From 8bf0106867948da31b689ba6921da1b08ba4c7f1 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Wed, 25 Dec 2024 14:56:57 +0200 Subject: [PATCH 05/45] spotless --- .../com/gregtechceu/gtceu/integration/map/WaypointManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/WaypointManager.java b/src/main/java/com/gregtechceu/gtceu/integration/map/WaypointManager.java index b6fe6c6e48..9594f06b60 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/WaypointManager.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/WaypointManager.java @@ -1,6 +1,5 @@ package com.gregtechceu.gtceu.integration.map; -import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.integration.map.ftbchunks.FTBChunksWaypointHandler; import com.gregtechceu.gtceu.integration.map.journeymap.JourneymapWaypointHandler; From c89b97a417b3431d407ec2cdc45f82e078c298f7 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Wed, 25 Dec 2024 15:29:40 +0200 Subject: [PATCH 06/45] added ability to add waypoint when clicking on ore vein marker --- .../map/ftbchunks/FTBChunksPlugin.java | 3 ++ .../map/ftbchunks/veins/ore/OreVeinIcon.java | 39 +++++++++++++++---- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksPlugin.java index f727d5bca3..4464a3a02b 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksPlugin.java @@ -6,12 +6,15 @@ import dev.ftb.mods.ftbchunks.api.client.FTBChunksClientAPI; import dev.ftb.mods.ftbchunks.api.client.event.MapIconEvent; import dev.ftb.mods.ftbchunks.client.map.MapDimension; +import lombok.Getter; public class FTBChunksPlugin { private static FTBChunksPlugin instance; + @Getter protected FTBChunksClientAPI clientAPI; + @Getter protected FTBChunksOptions options; protected FTBChunksPlugin() {} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java index ded0b0e777..a045857966 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java @@ -4,6 +4,7 @@ import com.gregtechceu.gtceu.api.data.worldgen.ores.GeneratedVeinMetadata; import com.gregtechceu.gtceu.client.util.DrawUtil; import com.gregtechceu.gtceu.config.ConfigHolder; +import com.gregtechceu.gtceu.integration.map.ftbchunks.FTBChunksPlugin; import com.gregtechceu.gtceu.integration.map.layer.builtin.OreRenderLayer; import net.minecraft.client.Minecraft; @@ -17,6 +18,9 @@ import com.mojang.blaze3d.systems.RenderSystem; import dev.ftb.mods.ftbchunks.api.client.icon.MapIcon; import dev.ftb.mods.ftbchunks.api.client.icon.MapType; +import dev.ftb.mods.ftbchunks.client.map.MapDimension; +import dev.ftb.mods.ftbchunks.client.map.WaypointImpl; +import dev.ftb.mods.ftbchunks.client.map.WaypointType; import dev.ftb.mods.ftblibrary.ui.BaseScreen; import dev.ftb.mods.ftblibrary.ui.input.Key; import dev.ftb.mods.ftblibrary.ui.input.MouseButton; @@ -28,12 +32,24 @@ public class OreVeinIcon implements MapIcon { protected final GeneratedVeinMetadata veinMetadata; protected String name = null; + protected Integer color = null; protected List tooltip = null; public OreVeinIcon(GeneratedVeinMetadata veinMetadata) { this.veinMetadata = veinMetadata; } + public String getName() { + return name == null ? name = OreRenderLayer.getName(veinMetadata).getString() : name; + } + + public Integer getColor() { + if (color == null) { + color = veinMetadata.definition().veinGenerator().getAllMaterials().get(0).getMaterialARGB(); + } + return color; + } + @Override public Vec3 getPos(float v) { return veinMetadata.center().getCenter(); @@ -41,7 +57,18 @@ public Vec3 getPos(float v) { @Override public boolean onMousePressed(BaseScreen baseScreen, MouseButton mouseButton) { - return false; + MapDimension.getCurrent() + .ifPresent(mapDimension -> FTBChunksPlugin.getInstance().getClientAPI() + .getWaypointManager(mapDimension.dimension) + .ifPresent(waypointManager -> { + var waypoint = new WaypointImpl(WaypointType.DEFAULT, mapDimension, veinMetadata.center()); + if (!waypointManager.getAllWaypoints().contains(waypoint)) { + waypointManager.addWaypointAt(veinMetadata.center(), getName()) + .setColor(getColor()) + .setHidden(false); + } + })); + return true; } @Override @@ -49,13 +76,12 @@ public boolean onKeyPressed(BaseScreen baseScreen, Key key) { if (key.is(InputConstants.KEY_DELETE)) { veinMetadata.depleted(!veinMetadata.depleted()); } - return false; + return true; } @Override public void addTooltip(TooltipList list) { - if (name == null) name = OreRenderLayer.getName(veinMetadata).getString(); - OreRenderLayer.getTooltip(name, veinMetadata).forEach(list::add); + OreRenderLayer.getTooltip(getName(), veinMetadata).forEach(list::add); } @Override @@ -64,8 +90,7 @@ public void draw(MapType mapType, GuiGraphics graphics, int x, int y, int w, int var iconSize = ConfigHolder.INSTANCE.compat.minimap.oreIconSize; var firstMaterial = veinMetadata.definition().veinGenerator().getAllMaterials().get(0); - int materialARGB = firstMaterial.getMaterialARGB(); - var colors = DrawUtil.floats(materialARGB); + var colors = DrawUtil.floats(getColor()); RenderSystem.setShaderColor(1, 1, 1, 1); ResourceLocation oreTexture = MaterialIconType.rawOre.getItemTexturePath(firstMaterial.getMaterialIconSet(), @@ -87,7 +112,7 @@ public void draw(MapType mapType, GuiGraphics graphics, int x, int y, int w, int } RenderSystem.setShaderColor(1, 1, 1, 1); - var borderColor = ConfigHolder.INSTANCE.compat.minimap.getBorderColor(materialARGB | 0xFF000000); + var borderColor = ConfigHolder.INSTANCE.compat.minimap.getBorderColor(getColor() | 0xFF000000); if ((borderColor & 0xFF000000) != 0) { var thickness = iconSize / 16; graphics.fill(x, y, x + w, y + h + thickness, borderColor); From 61b766940f489efeae2f82878ce6f24c4f3f3c90 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Thu, 26 Dec 2024 14:59:59 +0200 Subject: [PATCH 07/45] fluid overlay is working still buggy when zoomed in --- .../mixins/ftbchunks/RegionMapPanelMixin.java | 66 ++++++++++ .../map/ftbchunks/FTBChunksPlugin.java | 9 +- .../veins/fluid/FluidChunkHighlighter.java | 41 ------ .../ftbchunks/veins/fluid/FluidChunkIcon.java | 117 ++++++++++++++++++ .../veins/fluid/FluidChunkWidget.java | 111 +++++++++++++++++ src/main/resources/gtceu.mixins.json | 1 + 6 files changed, 301 insertions(+), 44 deletions(-) create mode 100644 src/main/java/com/gregtechceu/gtceu/core/mixins/ftbchunks/RegionMapPanelMixin.java delete mode 100644 src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkHighlighter.java create mode 100644 src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkIcon.java create mode 100644 src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java diff --git a/src/main/java/com/gregtechceu/gtceu/core/mixins/ftbchunks/RegionMapPanelMixin.java b/src/main/java/com/gregtechceu/gtceu/core/mixins/ftbchunks/RegionMapPanelMixin.java new file mode 100644 index 0000000000..790e77390f --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/core/mixins/ftbchunks/RegionMapPanelMixin.java @@ -0,0 +1,66 @@ +package com.gregtechceu.gtceu.core.mixins.ftbchunks; + +import com.gregtechceu.gtceu.integration.map.ftbchunks.FTBChunksPlugin; +import com.gregtechceu.gtceu.integration.map.ftbchunks.FTBChunksRenderer; +import com.gregtechceu.gtceu.integration.map.ftbchunks.veins.fluid.FluidChunkWidget; + +import dev.ftb.mods.ftbchunks.client.gui.LargeMapScreen; +import dev.ftb.mods.ftbchunks.client.gui.RegionMapPanel; +import dev.ftb.mods.ftbchunks.client.map.MapManager; +import dev.ftb.mods.ftblibrary.math.XZ; +import dev.ftb.mods.ftblibrary.ui.Panel; +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; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(value = RegionMapPanel.class, remap = false) +public abstract class RegionMapPanelMixin extends Panel { + + @Shadow + @Final + LargeMapScreen largeMap; + + @Shadow + int regionMinX; + + @Shadow + int regionMinZ; + + public RegionMapPanelMixin(Panel panel) { + super(panel); + } + + @Inject(method = "addWidgets", + at = @At(value = "INVOKE", target = "Ldev/ftb/mods/ftbchunks/client/gui/RegionMapPanel;alignWidgets()V")) + private void gtceu$injectAddWidgets(CallbackInfo ci) { + if (!FTBChunksPlugin.getInstance().getOptions().showLayer("bedrock_fluids") || + MapManager.getInstance().isEmpty()) { + return; + } + + FTBChunksRenderer.fluidElements.row(largeMap.currentDimension()).forEach((pos, info) -> { + var widget = new FluidChunkWidget((RegionMapPanel) (Object) this, XZ.of(pos), info); + add(widget); + }); + } + + @Inject(method = "alignWidgets", + at = @At(value = "INVOKE", + target = "Ldev/ftb/mods/ftblibrary/ui/Widget;setPosAndSize(IIII)Ldev/ftb/mods/ftblibrary/ui/Widget;")) + private void gtceu$injectAlignWidgets(CallbackInfo ci) { + for (var widget : widgets) { + if (!(widget instanceof FluidChunkWidget w)) continue; + + int regionSize = largeMap.getRegionTileSize(); + int chunkSize = largeMap.getRegionTileSize() / 32; + var chunkPos = w.getChunkPos(); + + var x = (chunkPos.getRegionX() - regionMinX) * regionSize + chunkPos.getRegionLocalX() * chunkSize; + var y = (chunkPos.getRegionZ() - regionMinZ) * regionSize + chunkPos.getRegionLocalZ() * chunkSize; + w.setPosAndSize(x, y, chunkSize, chunkSize); + } + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksPlugin.java index 4464a3a02b..e91b74fa37 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksPlugin.java @@ -32,8 +32,11 @@ public void initialize() { } private void mapIconEventHandler(MapIconEvent event) { - if (!GroupingMapRenderer.getInstance().doShowLayer("ore_veins")) return; - MapDimension.getCurrent().ifPresent( - mapDimension -> FTBChunksRenderer.oreElements.row(mapDimension.dimension).values().forEach(event::add)); + if (GroupingMapRenderer.getInstance().doShowLayer("ore_veins")) { + MapDimension.getCurrent() + .ifPresent(mapDimension -> FTBChunksRenderer.oreElements.row(mapDimension.dimension) + .values() + .forEach(event::add)); + } } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkHighlighter.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkHighlighter.java deleted file mode 100644 index e4a921e56a..0000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkHighlighter.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.gregtechceu.gtceu.integration.map.ftbchunks.veins.fluid; - -import com.gregtechceu.gtceu.integration.map.GroupingMapRenderer; - -import net.minecraft.world.level.ChunkPos; - -import dev.ftb.mods.ftbchunks.client.map.MapChunk; -import dev.ftb.mods.ftbchunks.client.map.MapDimension; -import dev.ftb.mods.ftblibrary.math.XZ; -import dev.ftb.mods.ftblibrary.ui.Panel; -import dev.ftb.mods.ftblibrary.util.TooltipList; -import lombok.Getter; - -@Getter -public class FluidChunkHighlighter { - - protected MapDimension dimension; - protected int chunkX; - protected int chunkZ; - protected MapChunk mapChunk; - - public FluidChunkHighlighter(Panel p, MapDimension dimension, ChunkPos chunkPos) { - this.dimension = dimension; - this.chunkX = chunkPos.x; - this.chunkZ = chunkPos.z; - var pos = XZ.regionFromChunk(chunkPos); - this.mapChunk = this.dimension.getRegion(pos).getDataBlocking().getChunk(pos); - } - - public boolean isEnabled() { - return GroupingMapRenderer.getInstance().doShowLayer("bedrock_fluids"); - } - - public boolean shouldDraw() { - return isEnabled(); - } - - public void addMouseOverText(TooltipList list) { - // todo: append tooltips - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkIcon.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkIcon.java new file mode 100644 index 0000000000..eb2e2de198 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkIcon.java @@ -0,0 +1,117 @@ +package com.gregtechceu.gtceu.integration.map.ftbchunks.veins.fluid; + +import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; +import com.gregtechceu.gtceu.api.gui.misc.ProspectorMode; +import com.gregtechceu.gtceu.integration.map.GroupingMapRenderer; +import com.gregtechceu.gtceu.integration.map.ftbchunks.FTBChunksPlugin; +import com.gregtechceu.gtceu.integration.map.layer.builtin.FluidRenderLayer; + +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.phys.Vec3; +import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions; + +import dev.ftb.mods.ftbchunks.FTBChunks; +import dev.ftb.mods.ftbchunks.api.client.icon.MapIcon; +import dev.ftb.mods.ftbchunks.api.client.icon.MapType; +import dev.ftb.mods.ftbchunks.client.map.MapDimension; +import dev.ftb.mods.ftbchunks.client.map.WaypointImpl; +import dev.ftb.mods.ftbchunks.client.map.WaypointType; +import dev.ftb.mods.ftblibrary.icon.Color4I; +import dev.ftb.mods.ftblibrary.icon.Icon; +import dev.ftb.mods.ftblibrary.ui.BaseScreen; +import dev.ftb.mods.ftblibrary.ui.input.Key; +import dev.ftb.mods.ftblibrary.ui.input.MouseButton; +import dev.ftb.mods.ftblibrary.util.TooltipList; +import lombok.Getter; + +import java.util.List; + +@Getter +public class FluidChunkIcon implements MapIcon { + + protected ChunkPos chunkPos; + protected ProspectorMode.FluidInfo fluidVein; + + protected String name = null; + protected List tooltip = null; + + public FluidChunkIcon(ProspectorMode.FluidInfo fluidVein, ChunkPos chunkPos) { + this.chunkPos = chunkPos; + this.fluidVein = fluidVein; + } + + public String getName() { + return name == null ? name = FluidRenderLayer.getName(fluidVein).getString() : name; + } + + public int getColor() { + var color = IClientFluidTypeExtensions.of(fluidVein.fluid()).getTintColor(); + var material = ChemicalHelper.getMaterial(fluidVein.fluid()); + if (material != null) { + color = material.getMaterialARGB(); + } + return (color & 0xFF) << 24 | (color >> 8 & 0xFF) << 16 | (color >> 16 & 0xFF) << 8; + } + + public List getTooltip() { + return tooltip == null ? tooltip = FluidRenderLayer.getTooltip(fluidVein) : tooltip; + } + + @Override + public void addTooltip(TooltipList list) { + getTooltip().forEach(list::add); + } + + @Override + public boolean isVisible(MapType mapType, double distanceToPlayer, boolean outsideVisibleArea) { + return GroupingMapRenderer.getInstance().doShowLayer("bedrock_fluids") && + MapIcon.super.isVisible(mapType, distanceToPlayer, outsideVisibleArea); + } + + @Override + public Vec3 getPos(float v) { + return chunkPos.getWorldPosition().getCenter(); + } + + @Override + public boolean onMousePressed(BaseScreen baseScreen, MouseButton mouseButton) { + MapDimension.getCurrent() + .ifPresent(mapDimension -> FTBChunksPlugin.getInstance().getClientAPI() + .getWaypointManager(mapDimension.dimension) + .ifPresent(waypointManager -> { + var pos = BlockPos.containing(getPos(0)); + var waypoint = new WaypointImpl(WaypointType.DEFAULT, mapDimension, pos); + if (!waypointManager.getAllWaypoints().contains(waypoint)) { + waypointManager.addWaypointAt(pos, getName()) + .setColor(getColor()) + .setHidden(false); + } + })); + return true; + } + + @Override + public boolean onKeyPressed(BaseScreen baseScreen, Key key) { + return false; + } + + @Override + public void draw(MapType mapType, GuiGraphics graphics, int x, int y, int w, int h, boolean outsideVisibleArea, + int iconAlpha) { + if (!FTBChunksPlugin.getInstance().getOptions().showLayer("bedrock_fluids") || + MapDimension.getCurrent().isEmpty()) { + return; + } + + var color = getColor(); + + var fillOpacity = 25; + var centerColor = color | 255 * fillOpacity / 100; + Icon.getIcon(IClientFluidTypeExtensions.of(fluidVein.fluid()).getStillTexture()) + .withColor(Color4I.rgba(centerColor)) + .draw(graphics, x, y, FTBChunks.TILE_SIZE, FTBChunks.TILE_SIZE); + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java new file mode 100644 index 0000000000..83ce72fca9 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java @@ -0,0 +1,111 @@ +package com.gregtechceu.gtceu.integration.map.ftbchunks.veins.fluid; + +import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; +import com.gregtechceu.gtceu.api.gui.misc.ProspectorMode; +import com.gregtechceu.gtceu.integration.map.ftbchunks.FTBChunksPlugin; +import com.gregtechceu.gtceu.integration.map.layer.builtin.FluidRenderLayer; + +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.phys.Vec3; +import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions; + +import dev.ftb.mods.ftbchunks.FTBChunks; +import dev.ftb.mods.ftbchunks.client.gui.RegionMapPanel; +import dev.ftb.mods.ftbchunks.client.map.MapDimension; +import dev.ftb.mods.ftbchunks.client.map.WaypointImpl; +import dev.ftb.mods.ftbchunks.client.map.WaypointType; +import dev.ftb.mods.ftblibrary.icon.Color4I; +import dev.ftb.mods.ftblibrary.icon.Icon; +import dev.ftb.mods.ftblibrary.math.XZ; +import dev.ftb.mods.ftblibrary.ui.Theme; +import dev.ftb.mods.ftblibrary.ui.Widget; +import dev.ftb.mods.ftblibrary.ui.input.MouseButton; +import dev.ftb.mods.ftblibrary.util.TooltipList; + +import java.util.List; + +public class FluidChunkWidget extends Widget { + + private final XZ chunkPos; + private final ProspectorMode.FluidInfo fluidInfo; + + private List tooltip; + private String name; + + public FluidChunkWidget(RegionMapPanel panel, XZ chunkPos, + ProspectorMode.FluidInfo fluidInfo) { + super(panel); + setSize(FTBChunks.TILE_SIZE, FTBChunks.TILE_SIZE); + this.chunkPos = chunkPos; + this.fluidInfo = fluidInfo; + } + + public List getTooltip() { + return tooltip == null ? tooltip = FluidRenderLayer.getTooltip(fluidInfo) : tooltip; + } + + public ChunkPos getChunkPos() { + return new ChunkPos(chunkPos.x(), chunkPos.z()); + } + + public Vec3 getPos() { + return getChunkPos().getMiddleBlockPosition(70).getCenter(); + } + + public String getName() { + return name == null ? name = FluidRenderLayer.getName(fluidInfo).getString() : name; + } + + public int getColor() { + var color = IClientFluidTypeExtensions.of(fluidInfo.fluid()).getTintColor(); + var material = ChemicalHelper.getMaterial(fluidInfo.fluid()); + if (material != null) { + color = material.getMaterialARGB(); + } + return (color & 0xFF) << 24 | (color >> 8 & 0xFF) << 16 | (color >> 16 & 0xFF) << 8; + } + + @Override + public boolean mouseDoubleClicked(MouseButton button) { + MapDimension.getCurrent() + .ifPresent(mapDimension -> FTBChunksPlugin.getInstance().getClientAPI() + .getWaypointManager(mapDimension.dimension) + .ifPresent(waypointManager -> { + var pos = BlockPos.containing(getPos()); + var waypoint = new WaypointImpl(WaypointType.DEFAULT, mapDimension, pos); + if (!waypointManager.getAllWaypoints().contains(waypoint)) { + waypointManager.addWaypointAt(pos, getName()) + .setColor(getColor()) + .setHidden(false); + } + })); + return true; + } + + @Override + public boolean isEnabled() { + return FTBChunksPlugin.getInstance().getOptions().showLayer("bedrock_fluids"); + } + + @Override + public void addMouseOverText(TooltipList list) { + getTooltip().forEach(list::add); + } + + @Override + public void draw(GuiGraphics graphics, Theme theme, int x, int y, int w, int h) { + if (!shouldDraw()) { + return; + } + + var color = Color4I.rgba(getColor()); + var hsb = Color4I.RGBtoHSB(color.redi(), color.greeni(), color.bluei(), null); + hsb[0] = (hsb[0] + 0.5f) % 1f; + Icon.getIcon(IClientFluidTypeExtensions.of(fluidInfo.fluid()).getStillTexture()) + .withColor(Color4I.hsb(hsb[0], hsb[1], hsb[2])) + .draw(graphics, x, y, FTBChunks.TILE_SIZE, FTBChunks.TILE_SIZE); + } +} diff --git a/src/main/resources/gtceu.mixins.json b/src/main/resources/gtceu.mixins.json index 808773400e..f1c9c97e78 100644 --- a/src/main/resources/gtceu.mixins.json +++ b/src/main/resources/gtceu.mixins.json @@ -17,6 +17,7 @@ "MultiPlayerGameModeMixin", "journeymap.FullscreenMixin", "rei.FluidEntryRendererMixin", + "ftbchunks.RegionMapPanelMixin", "xaeroworldmap.GuiMapMixin", "xaeroworldmap.MapElementRenderHandlerBuilderMixin", "xaerominimap.HighlighterRegistryMixin", From c89fb4aae217ea2315fb39d9e7b94873d1abfaf1 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Thu, 26 Dec 2024 15:01:50 +0200 Subject: [PATCH 08/45] removed old icon for fluid chunks that didn't work --- .../ftbchunks/veins/fluid/FluidChunkIcon.java | 117 ------------------ 1 file changed, 117 deletions(-) delete mode 100644 src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkIcon.java diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkIcon.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkIcon.java deleted file mode 100644 index eb2e2de198..0000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkIcon.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.gregtechceu.gtceu.integration.map.ftbchunks.veins.fluid; - -import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; -import com.gregtechceu.gtceu.api.gui.misc.ProspectorMode; -import com.gregtechceu.gtceu.integration.map.GroupingMapRenderer; -import com.gregtechceu.gtceu.integration.map.ftbchunks.FTBChunksPlugin; -import com.gregtechceu.gtceu.integration.map.layer.builtin.FluidRenderLayer; - -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.core.BlockPos; -import net.minecraft.network.chat.Component; -import net.minecraft.world.level.ChunkPos; -import net.minecraft.world.phys.Vec3; -import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions; - -import dev.ftb.mods.ftbchunks.FTBChunks; -import dev.ftb.mods.ftbchunks.api.client.icon.MapIcon; -import dev.ftb.mods.ftbchunks.api.client.icon.MapType; -import dev.ftb.mods.ftbchunks.client.map.MapDimension; -import dev.ftb.mods.ftbchunks.client.map.WaypointImpl; -import dev.ftb.mods.ftbchunks.client.map.WaypointType; -import dev.ftb.mods.ftblibrary.icon.Color4I; -import dev.ftb.mods.ftblibrary.icon.Icon; -import dev.ftb.mods.ftblibrary.ui.BaseScreen; -import dev.ftb.mods.ftblibrary.ui.input.Key; -import dev.ftb.mods.ftblibrary.ui.input.MouseButton; -import dev.ftb.mods.ftblibrary.util.TooltipList; -import lombok.Getter; - -import java.util.List; - -@Getter -public class FluidChunkIcon implements MapIcon { - - protected ChunkPos chunkPos; - protected ProspectorMode.FluidInfo fluidVein; - - protected String name = null; - protected List tooltip = null; - - public FluidChunkIcon(ProspectorMode.FluidInfo fluidVein, ChunkPos chunkPos) { - this.chunkPos = chunkPos; - this.fluidVein = fluidVein; - } - - public String getName() { - return name == null ? name = FluidRenderLayer.getName(fluidVein).getString() : name; - } - - public int getColor() { - var color = IClientFluidTypeExtensions.of(fluidVein.fluid()).getTintColor(); - var material = ChemicalHelper.getMaterial(fluidVein.fluid()); - if (material != null) { - color = material.getMaterialARGB(); - } - return (color & 0xFF) << 24 | (color >> 8 & 0xFF) << 16 | (color >> 16 & 0xFF) << 8; - } - - public List getTooltip() { - return tooltip == null ? tooltip = FluidRenderLayer.getTooltip(fluidVein) : tooltip; - } - - @Override - public void addTooltip(TooltipList list) { - getTooltip().forEach(list::add); - } - - @Override - public boolean isVisible(MapType mapType, double distanceToPlayer, boolean outsideVisibleArea) { - return GroupingMapRenderer.getInstance().doShowLayer("bedrock_fluids") && - MapIcon.super.isVisible(mapType, distanceToPlayer, outsideVisibleArea); - } - - @Override - public Vec3 getPos(float v) { - return chunkPos.getWorldPosition().getCenter(); - } - - @Override - public boolean onMousePressed(BaseScreen baseScreen, MouseButton mouseButton) { - MapDimension.getCurrent() - .ifPresent(mapDimension -> FTBChunksPlugin.getInstance().getClientAPI() - .getWaypointManager(mapDimension.dimension) - .ifPresent(waypointManager -> { - var pos = BlockPos.containing(getPos(0)); - var waypoint = new WaypointImpl(WaypointType.DEFAULT, mapDimension, pos); - if (!waypointManager.getAllWaypoints().contains(waypoint)) { - waypointManager.addWaypointAt(pos, getName()) - .setColor(getColor()) - .setHidden(false); - } - })); - return true; - } - - @Override - public boolean onKeyPressed(BaseScreen baseScreen, Key key) { - return false; - } - - @Override - public void draw(MapType mapType, GuiGraphics graphics, int x, int y, int w, int h, boolean outsideVisibleArea, - int iconAlpha) { - if (!FTBChunksPlugin.getInstance().getOptions().showLayer("bedrock_fluids") || - MapDimension.getCurrent().isEmpty()) { - return; - } - - var color = getColor(); - - var fillOpacity = 25; - var centerColor = color | 255 * fillOpacity / 100; - Icon.getIcon(IClientFluidTypeExtensions.of(fluidVein.fluid()).getStillTexture()) - .withColor(Color4I.rgba(centerColor)) - .draw(graphics, x, y, FTBChunks.TILE_SIZE, FTBChunks.TILE_SIZE); - } -} From 73be5fd067e0e7e469bf6524f9ec7dd3d94ba57f Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Thu, 26 Dec 2024 15:15:44 +0200 Subject: [PATCH 09/45] fixed color values --- .../map/ftbchunks/veins/fluid/FluidChunkWidget.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java index 83ce72fca9..810703ac56 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java @@ -65,7 +65,7 @@ public int getColor() { if (material != null) { color = material.getMaterialARGB(); } - return (color & 0xFF) << 24 | (color >> 8 & 0xFF) << 16 | (color >> 16 & 0xFF) << 8; + return color; } @Override @@ -101,11 +101,8 @@ public void draw(GuiGraphics graphics, Theme theme, int x, int y, int w, int h) return; } - var color = Color4I.rgba(getColor()); - var hsb = Color4I.RGBtoHSB(color.redi(), color.greeni(), color.bluei(), null); - hsb[0] = (hsb[0] + 0.5f) % 1f; Icon.getIcon(IClientFluidTypeExtensions.of(fluidInfo.fluid()).getStillTexture()) - .withColor(Color4I.hsb(hsb[0], hsb[1], hsb[2])) + .withColor(Color4I.rgba(getColor())) .draw(graphics, x, y, FTBChunks.TILE_SIZE, FTBChunks.TILE_SIZE); } } From cd871a07c1bdbf2241a86e13d98d1d1a69c3c215 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Thu, 26 Dec 2024 16:33:53 +0200 Subject: [PATCH 10/45] fluid info parameters were reversed --- .../gregtechceu/gtceu/api/gui/misc/ProspectorMode.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/misc/ProspectorMode.java b/src/main/java/com/gregtechceu/gtceu/api/gui/misc/ProspectorMode.java index ab4f3a5079..53d7b8d990 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/misc/ProspectorMode.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/misc/ProspectorMode.java @@ -176,7 +176,7 @@ public static FluidInfo fromNbt(CompoundTag tag) { Fluid fluid = BuiltInRegistries.FLUID.get(new ResourceLocation(tag.getString("fluid"))); int left = tag.getInt("left"); int yield = tag.getInt("yield"); - return new FluidInfo(fluid, left, yield); + return new FluidInfo(fluid, yield, left); } public CompoundTag toNbt() { @@ -199,8 +199,8 @@ public void scan(FluidInfo[][][] storage, LevelChunk chunk) { var left = 100 * fluidVein.getOperationsRemaining() / BedrockFluidVeinSavedData.MAXIMUM_VEIN_OPERATIONS; storage[0][0] = new FluidInfo[] { - new FluidInfo(fluidVein.getDefinition().getStoredFluid().get(), left, - fluidVein.getFluidYield()), + new FluidInfo(fluidVein.getDefinition().getStoredFluid().get(), fluidVein.getFluidYield(), + left), }; } } @@ -233,8 +233,8 @@ public String getUniqueID(FluidInfo item) { @Override public void serialize(FluidInfo item, FriendlyByteBuf buf) { buf.writeUtf(BuiltInRegistries.FLUID.getKey(item.fluid).toString()); - buf.writeVarInt(item.left); buf.writeVarInt(item.yield); + buf.writeVarInt(item.left); } @Override From e6fbc11c9c29a318d933e7fd44948196301674c1 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Thu, 26 Dec 2024 16:34:25 +0200 Subject: [PATCH 11/45] removed caching of tooltip --- .../map/ftbchunks/veins/fluid/FluidChunkWidget.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java index 810703ac56..37c1b4aac4 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java @@ -32,7 +32,6 @@ public class FluidChunkWidget extends Widget { private final XZ chunkPos; private final ProspectorMode.FluidInfo fluidInfo; - private List tooltip; private String name; public FluidChunkWidget(RegionMapPanel panel, XZ chunkPos, @@ -43,10 +42,6 @@ public FluidChunkWidget(RegionMapPanel panel, XZ chunkPos, this.fluidInfo = fluidInfo; } - public List getTooltip() { - return tooltip == null ? tooltip = FluidRenderLayer.getTooltip(fluidInfo) : tooltip; - } - public ChunkPos getChunkPos() { return new ChunkPos(chunkPos.x(), chunkPos.z()); } @@ -92,7 +87,7 @@ public boolean isEnabled() { @Override public void addMouseOverText(TooltipList list) { - getTooltip().forEach(list::add); + FluidRenderLayer.getTooltip(fluidInfo).forEach(list::add); } @Override From 943bb17bfefa502246b188ed3ad036e018b98568 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Thu, 26 Dec 2024 16:34:46 +0200 Subject: [PATCH 12/45] fixed colors and overlay display --- .../map/ftbchunks/veins/fluid/FluidChunkWidget.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java index 37c1b4aac4..8f6e18ffaa 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java @@ -96,8 +96,11 @@ public void draw(GuiGraphics graphics, Theme theme, int x, int y, int w, int h) return; } - Icon.getIcon(IClientFluidTypeExtensions.of(fluidInfo.fluid()).getStillTexture()) - .withColor(Color4I.rgba(getColor())) - .draw(graphics, x, y, FTBChunks.TILE_SIZE, FTBChunks.TILE_SIZE); + var fluidIcon = Icon.getIcon(IClientFluidTypeExtensions.of(fluidInfo.fluid()).getStillTexture()) + .withColor(Color4I.rgba(getColor()).withAlphaf(isMouseOver() ? 0.9f : 0.8f)); + if (isMouseOver()) { + fluidIcon = fluidIcon.withBorder(Color4I.rgba(getColor()), false); + } + fluidIcon.draw(graphics, x, y, w, h); } } From 52b77201eae144812df00167145d9a8ae577d628 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Thu, 26 Dec 2024 16:42:46 +0200 Subject: [PATCH 13/45] spotless --- .../map/ftbchunks/veins/fluid/FluidChunkWidget.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java index 8f6e18ffaa..7e1ca80cd0 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java @@ -7,7 +7,6 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; -import net.minecraft.network.chat.Component; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.phys.Vec3; import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions; @@ -25,8 +24,6 @@ import dev.ftb.mods.ftblibrary.ui.input.MouseButton; import dev.ftb.mods.ftblibrary.util.TooltipList; -import java.util.List; - public class FluidChunkWidget extends Widget { private final XZ chunkPos; From 05dd93045c796e522c0ebf24ef6f93401d10f52a Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Thu, 26 Dec 2024 17:08:02 +0200 Subject: [PATCH 14/45] replaced `XZ` with `ChunkPos` --- .../core/mixins/ftbchunks/RegionMapPanelMixin.java | 3 +-- .../map/ftbchunks/veins/fluid/FluidChunkWidget.java | 11 ++++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/core/mixins/ftbchunks/RegionMapPanelMixin.java b/src/main/java/com/gregtechceu/gtceu/core/mixins/ftbchunks/RegionMapPanelMixin.java index 790e77390f..c74c418625 100644 --- a/src/main/java/com/gregtechceu/gtceu/core/mixins/ftbchunks/RegionMapPanelMixin.java +++ b/src/main/java/com/gregtechceu/gtceu/core/mixins/ftbchunks/RegionMapPanelMixin.java @@ -7,7 +7,6 @@ import dev.ftb.mods.ftbchunks.client.gui.LargeMapScreen; import dev.ftb.mods.ftbchunks.client.gui.RegionMapPanel; import dev.ftb.mods.ftbchunks.client.map.MapManager; -import dev.ftb.mods.ftblibrary.math.XZ; import dev.ftb.mods.ftblibrary.ui.Panel; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -42,7 +41,7 @@ public RegionMapPanelMixin(Panel panel) { } FTBChunksRenderer.fluidElements.row(largeMap.currentDimension()).forEach((pos, info) -> { - var widget = new FluidChunkWidget((RegionMapPanel) (Object) this, XZ.of(pos), info); + var widget = new FluidChunkWidget((RegionMapPanel) (Object) this, pos, info); add(widget); }); } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java index 7e1ca80cd0..72aacf3fe6 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java @@ -18,20 +18,21 @@ import dev.ftb.mods.ftbchunks.client.map.WaypointType; import dev.ftb.mods.ftblibrary.icon.Color4I; import dev.ftb.mods.ftblibrary.icon.Icon; -import dev.ftb.mods.ftblibrary.math.XZ; import dev.ftb.mods.ftblibrary.ui.Theme; import dev.ftb.mods.ftblibrary.ui.Widget; import dev.ftb.mods.ftblibrary.ui.input.MouseButton; import dev.ftb.mods.ftblibrary.util.TooltipList; +import lombok.Getter; public class FluidChunkWidget extends Widget { - private final XZ chunkPos; + @Getter + private final ChunkPos chunkPos; private final ProspectorMode.FluidInfo fluidInfo; private String name; - public FluidChunkWidget(RegionMapPanel panel, XZ chunkPos, + public FluidChunkWidget(RegionMapPanel panel, ChunkPos chunkPos, ProspectorMode.FluidInfo fluidInfo) { super(panel); setSize(FTBChunks.TILE_SIZE, FTBChunks.TILE_SIZE); @@ -39,10 +40,6 @@ public FluidChunkWidget(RegionMapPanel panel, XZ chunkPos, this.fluidInfo = fluidInfo; } - public ChunkPos getChunkPos() { - return new ChunkPos(chunkPos.x(), chunkPos.z()); - } - public Vec3 getPos() { return getChunkPos().getMiddleBlockPosition(70).getCenter(); } From dd31e62a19d10c6aadeeddfd6a30d4c5c97848c8 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Thu, 26 Dec 2024 17:42:07 +0200 Subject: [PATCH 15/45] better ore and color picking --- .../map/ftbchunks/veins/ore/OreVeinIcon.java | 43 +++++++++++++------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java index a045857966..107cf71a30 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java @@ -1,5 +1,7 @@ package com.gregtechceu.gtceu.integration.map.ftbchunks.veins.ore; +import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; +import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconType; import com.gregtechceu.gtceu.api.data.worldgen.ores.GeneratedVeinMetadata; import com.gregtechceu.gtceu.client.util.DrawUtil; @@ -10,7 +12,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.phys.Vec3; @@ -27,12 +28,12 @@ import dev.ftb.mods.ftblibrary.util.TooltipList; import java.util.List; +import java.util.function.Function; public class OreVeinIcon implements MapIcon { protected final GeneratedVeinMetadata veinMetadata; protected String name = null; - protected Integer color = null; protected List tooltip = null; public OreVeinIcon(GeneratedVeinMetadata veinMetadata) { @@ -43,11 +44,21 @@ public String getName() { return name == null ? name = OreRenderLayer.getName(veinMetadata).getString() : name; } - public Integer getColor() { - if (color == null) { - color = veinMetadata.definition().veinGenerator().getAllMaterials().get(0).getMaterialARGB(); + public Material getMaterial() { + Material firstMaterial = null; + if (!veinMetadata.definition().indicatorGenerators().isEmpty()) { + var blockOrMaterial = veinMetadata.definition().indicatorGenerators().get(0).block(); + firstMaterial = blockOrMaterial == null ? null : blockOrMaterial.map( + state -> { + var matStack = ChemicalHelper.getMaterial(state.getBlock()); + return matStack == null ? null : matStack.material(); + }, + Function.identity()); } - return color; + if (firstMaterial == null) { + firstMaterial = veinMetadata.definition().veinGenerator().getAllMaterials().get(0); + } + return firstMaterial; } @Override @@ -64,7 +75,7 @@ public boolean onMousePressed(BaseScreen baseScreen, MouseButton mouseButton) { var waypoint = new WaypointImpl(WaypointType.DEFAULT, mapDimension, veinMetadata.center()); if (!waypointManager.getAllWaypoints().contains(waypoint)) { waypointManager.addWaypointAt(veinMetadata.center(), getName()) - .setColor(getColor()) + .setColor(getMaterial().getMaterialARGB()) .setHidden(false); } })); @@ -87,13 +98,16 @@ public void addTooltip(TooltipList list) { @Override public void draw(MapType mapType, GuiGraphics graphics, int x, int y, int w, int h, boolean outsideVisibleArea, int iconAlpha) { - var iconSize = ConfigHolder.INSTANCE.compat.minimap.oreIconSize; + if (outsideVisibleArea) { + return; + } - var firstMaterial = veinMetadata.definition().veinGenerator().getAllMaterials().get(0); - var colors = DrawUtil.floats(getColor()); + var iconSize = ConfigHolder.INSTANCE.compat.minimap.oreIconSize; + var firstMaterial = getMaterial(); + var colors = DrawUtil.floats(firstMaterial.getMaterialARGB()); RenderSystem.setShaderColor(1, 1, 1, 1); - ResourceLocation oreTexture = MaterialIconType.rawOre.getItemTexturePath(firstMaterial.getMaterialIconSet(), + var oreTexture = MaterialIconType.rawOre.getItemTexturePath(firstMaterial.getMaterialIconSet(), true); if (oreTexture != null) { var oreSprite = Minecraft.getInstance() @@ -112,12 +126,13 @@ public void draw(MapType mapType, GuiGraphics graphics, int x, int y, int w, int } RenderSystem.setShaderColor(1, 1, 1, 1); - var borderColor = ConfigHolder.INSTANCE.compat.minimap.getBorderColor(getColor() | 0xFF000000); + var borderColor = ConfigHolder.INSTANCE.compat.minimap + .getBorderColor(firstMaterial.getMaterialARGB() | 0xFF000000); if ((borderColor & 0xFF000000) != 0) { var thickness = iconSize / 16; graphics.fill(x, y, x + w, y + h + thickness, borderColor); - graphics.fill(x, y - (h / 16), x + w, y + h + thickness, borderColor); - graphics.fill(x, y, x + w + (w / 16), y + h, borderColor); + graphics.fill(x, y - thickness, x + w, y + h + thickness, borderColor); + graphics.fill(x, y, x + w + thickness, y + h, borderColor); graphics.fill(x - thickness, y, x + w + thickness, y + h, borderColor); } } From d0a1640cd2d9fb429ec0e23f0ce537b16595a2a8 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Thu, 26 Dec 2024 17:50:46 +0200 Subject: [PATCH 16/45] removed unused var --- .../gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java index 107cf71a30..f63d1af7cc 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java @@ -11,7 +11,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.network.chat.Component; import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.phys.Vec3; @@ -27,14 +26,12 @@ import dev.ftb.mods.ftblibrary.ui.input.MouseButton; import dev.ftb.mods.ftblibrary.util.TooltipList; -import java.util.List; import java.util.function.Function; public class OreVeinIcon implements MapIcon { protected final GeneratedVeinMetadata veinMetadata; protected String name = null; - protected List tooltip = null; public OreVeinIcon(GeneratedVeinMetadata veinMetadata) { this.veinMetadata = veinMetadata; From a52e74d1119564c79266d41a26b9de1ed97be08d Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Thu, 26 Dec 2024 17:59:42 +0200 Subject: [PATCH 17/45] depleted state changes vein title --- .../gtceu/integration/map/layer/builtin/OreRenderLayer.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/layer/builtin/OreRenderLayer.java b/src/main/java/com/gregtechceu/gtceu/integration/map/layer/builtin/OreRenderLayer.java index 3a8937c9d9..aa153ff4bd 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/layer/builtin/OreRenderLayer.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/layer/builtin/OreRenderLayer.java @@ -37,7 +37,11 @@ public static Component getName(GeneratedVeinMetadata vein) { public static List getTooltip(String name, GeneratedVeinMetadata vein) { final List tooltip = new ArrayList<>(); - tooltip.add(Component.literal(name)); + var title = Component.literal(name); + if (vein.depleted()) { + title.append(" (").append(Component.translatable("gtceu.minimap.ore_vein.depleted")).append(")"); + } + tooltip.add(title); for (var filler : vein.definition().veinGenerator().getAllEntries()) { filler.getKey().ifLeft(state -> { From d28229e191ece3eb46126cf790a5e7cc5aa24341 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Thu, 26 Dec 2024 18:40:46 +0200 Subject: [PATCH 18/45] option to hide depleted veins --- .../gtceu/integration/map/ftbchunks/FTBChunksOptions.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java index f2c4e1c2a0..12e37803c5 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java @@ -11,12 +11,15 @@ public class FTBChunksOptions { private final Map layerOptions = new HashMap<>(); + private final BooleanValue hideDepleted; + public FTBChunksOptions() { var group = CONFIG.addGroup("gtceu_prospecting"); final var oreLayer = group.addBoolean("ore_veins", false); layerOptions.put(oreLayer.key, oreLayer); final var fluidLayer = group.addBoolean("bedrock_fluids", false); layerOptions.put(fluidLayer.key, fluidLayer); + hideDepleted = group.addBoolean("hide_depleted", false); } public boolean showLayer(String name) { @@ -33,4 +36,8 @@ public void toggleLayer(String name, boolean active) { }); }); } + + public boolean hideDepleted() { + return hideDepleted.get(); + } } From 941299a599c41fd479da8068792831cac1902539 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Thu, 26 Dec 2024 18:40:51 +0200 Subject: [PATCH 19/45] data gen --- src/generated/resources/assets/gtceu/lang/en_ud.json | 1 + src/generated/resources/assets/gtceu/lang/en_us.json | 1 + .../java/com/gregtechceu/gtceu/data/lang/IntegrationLang.java | 1 + 3 files changed, 3 insertions(+) diff --git a/src/generated/resources/assets/gtceu/lang/en_ud.json b/src/generated/resources/assets/gtceu/lang/en_ud.json index 523c70757f..1bc44efa77 100644 --- a/src/generated/resources/assets/gtceu/lang/en_ud.json +++ b/src/generated/resources/assets/gtceu/lang/en_ud.json @@ -2123,6 +2123,7 @@ "fluid_cell.empty": "ʎʇdɯƎ", "ftbchunks.gtceu_prospecting": "buıʇɔǝdsoɹԀ nƎƆ⟘⅁", "ftbchunks.gtceu_prospecting.bedrock_fluids": "suıǝΛ pınןℲ ʞɔoɹpǝᗺ ʍoɥS", + "ftbchunks.gtceu_prospecting.hide_depleted": "suıǝΛ pǝʇǝןdǝᗡ ǝpıH", "ftbchunks.gtceu_prospecting.ore_veins": "suıǝΛ ǝɹO ʍoɥS", "gtceu.air_scrubber": "ɹǝqqnɹɔS ɹıⱯ", "gtceu.alloy_blast_smelter": "ɹǝʇןǝɯS ʇsɐןᗺ ʎoןןⱯ", diff --git a/src/generated/resources/assets/gtceu/lang/en_us.json b/src/generated/resources/assets/gtceu/lang/en_us.json index acb12541a0..0160116dff 100644 --- a/src/generated/resources/assets/gtceu/lang/en_us.json +++ b/src/generated/resources/assets/gtceu/lang/en_us.json @@ -2123,6 +2123,7 @@ "fluid_cell.empty": "Empty", "ftbchunks.gtceu_prospecting": "GTCEu Prospecting", "ftbchunks.gtceu_prospecting.bedrock_fluids": "Show Bedrock Fluid Veins", + "ftbchunks.gtceu_prospecting.hide_depleted": "Hide Depleted Veins", "ftbchunks.gtceu_prospecting.ore_veins": "Show Ore Veins", "gtceu.air_scrubber": "Air Scrubber", "gtceu.alloy_blast_smelter": "Alloy Blast Smelter", diff --git a/src/main/java/com/gregtechceu/gtceu/data/lang/IntegrationLang.java b/src/main/java/com/gregtechceu/gtceu/data/lang/IntegrationLang.java index e4ba6bab7e..da4b56860e 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/lang/IntegrationLang.java +++ b/src/main/java/com/gregtechceu/gtceu/data/lang/IntegrationLang.java @@ -116,5 +116,6 @@ private static void initMinimapLang(RegistrateLangProvider provider) { provider.add("ftbchunks.gtceu_prospecting", "GTCEu Prospecting"); provider.add("ftbchunks.gtceu_prospecting.ore_veins", "Show Ore Veins"); provider.add("ftbchunks.gtceu_prospecting.bedrock_fluids", "Show Bedrock Fluid Veins"); + provider.add("ftbchunks.gtceu_prospecting.hide_depleted", "Hide Depleted Veins"); } } From 143ef6fd87cb9b17b44c8ca8aa679a9861744358 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Thu, 26 Dec 2024 18:40:59 +0200 Subject: [PATCH 20/45] hide veins if depleted --- .../veins/fluid/FluidChunkWidget.java | 13 +++++++++++++ .../map/ftbchunks/veins/ore/OreVeinIcon.java | 18 +++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java index 72aacf3fe6..be9d3cc4af 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java @@ -59,6 +59,10 @@ public int getColor() { @Override public boolean mouseDoubleClicked(MouseButton button) { + if (!shouldDraw()) { + return false; + } + MapDimension.getCurrent() .ifPresent(mapDimension -> FTBChunksPlugin.getInstance().getClientAPI() .getWaypointManager(mapDimension.dimension) @@ -81,9 +85,18 @@ public boolean isEnabled() { @Override public void addMouseOverText(TooltipList list) { + if (!shouldDraw()) { + return; + } + FluidRenderLayer.getTooltip(fluidInfo).forEach(list::add); } + @Override + public boolean shouldDraw() { + return fluidInfo.left() > 0 || !FTBChunksPlugin.getInstance().getOptions().hideDepleted(); + } + @Override public void draw(GuiGraphics graphics, Theme theme, int x, int y, int w, int h) { if (!shouldDraw()) { diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java index f63d1af7cc..eeb62e7e88 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java @@ -37,6 +37,11 @@ public OreVeinIcon(GeneratedVeinMetadata veinMetadata) { this.veinMetadata = veinMetadata; } + public boolean isEnabled() { + return FTBChunksPlugin.getInstance().getOptions().showLayer("ore_veins") && + !(veinMetadata.depleted() && FTBChunksPlugin.getInstance().getOptions().hideDepleted()); + } + public String getName() { return name == null ? name = OreRenderLayer.getName(veinMetadata).getString() : name; } @@ -65,6 +70,9 @@ public Vec3 getPos(float v) { @Override public boolean onMousePressed(BaseScreen baseScreen, MouseButton mouseButton) { + if (!isEnabled()) { + return false; + } MapDimension.getCurrent() .ifPresent(mapDimension -> FTBChunksPlugin.getInstance().getClientAPI() .getWaypointManager(mapDimension.dimension) @@ -81,6 +89,10 @@ public boolean onMousePressed(BaseScreen baseScreen, MouseButton mouseButton) { @Override public boolean onKeyPressed(BaseScreen baseScreen, Key key) { + if (!isEnabled()) { + return false; + } + if (key.is(InputConstants.KEY_DELETE)) { veinMetadata.depleted(!veinMetadata.depleted()); } @@ -89,13 +101,17 @@ public boolean onKeyPressed(BaseScreen baseScreen, Key key) { @Override public void addTooltip(TooltipList list) { + if (!isEnabled()) { + return; + } + OreRenderLayer.getTooltip(getName(), veinMetadata).forEach(list::add); } @Override public void draw(MapType mapType, GuiGraphics graphics, int x, int y, int w, int h, boolean outsideVisibleArea, int iconAlpha) { - if (outsideVisibleArea) { + if (outsideVisibleArea || !isEnabled()) { return; } From 5aadbbb96fb1058527f16ef94e4ac3174f8a3ec3 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Thu, 26 Dec 2024 18:41:10 +0200 Subject: [PATCH 21/45] spotless --- .../map/ftbchunks/veins/fluid/FluidChunkWidget.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java index be9d3cc4af..c2c8a5f2e8 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java @@ -62,7 +62,7 @@ public boolean mouseDoubleClicked(MouseButton button) { if (!shouldDraw()) { return false; } - + MapDimension.getCurrent() .ifPresent(mapDimension -> FTBChunksPlugin.getInstance().getClientAPI() .getWaypointManager(mapDimension.dimension) @@ -88,7 +88,7 @@ public void addMouseOverText(TooltipList list) { if (!shouldDraw()) { return; } - + FluidRenderLayer.getTooltip(fluidInfo).forEach(list::add); } From 815485ac268360f88ade0d13943617151cd43da6 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Thu, 26 Dec 2024 20:50:02 +0200 Subject: [PATCH 22/45] move plugin init to client setup event --- .../com/gregtechceu/gtceu/client/ClientProxy.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java b/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java index 903a5030b1..e0d6fb96e6 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java +++ b/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java @@ -35,6 +35,7 @@ import net.minecraftforge.client.event.RegisterKeyMappingsEvent; import net.minecraftforge.client.event.RegisterParticleProvidersEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; @@ -60,9 +61,6 @@ public static void init() { ClientCacheManager.registerClientCache(GTClientCache.instance, "gtceu"); Layers.registerLayer(OreRenderLayer::new, "ore_veins"); Layers.registerLayer(FluidRenderLayer::new, "bedrock_fluids"); - if (LDLib.isModLoaded(GTValues.MODID_FTB_CHUNKS)) { - FTBChunksPlugin.getInstance().initialize(); - } } } @@ -99,4 +97,11 @@ public void onRegisterGuiOverlays(RegisterGuiOverlaysEvent event) { public void onRegisterParticleProviders(RegisterParticleProvidersEvent event) { event.registerSpriteSet(GTParticleTypes.HAZARD_PARTICLE.get(), HazardParticle.Provider::new); } + + @SubscribeEvent + public void onClientSetup(FMLClientSetupEvent event) { + if (LDLib.isModLoaded(GTValues.MODID_FTB_CHUNKS)) { + FTBChunksPlugin.getInstance().initialize(); + } + } } From e02c390dd769a3fa12191ea8a709f4542b57696e Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Thu, 26 Dec 2024 20:56:17 +0200 Subject: [PATCH 23/45] refresh the map after adding a waypoint --- .../integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java | 1 + .../gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java index c2c8a5f2e8..29de6f0c18 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java @@ -73,6 +73,7 @@ public boolean mouseDoubleClicked(MouseButton button) { waypointManager.addWaypointAt(pos, getName()) .setColor(getColor()) .setHidden(false); + parent.openGui(); } })); return true; diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java index eeb62e7e88..d3ecc727bd 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java @@ -82,6 +82,7 @@ public boolean onMousePressed(BaseScreen baseScreen, MouseButton mouseButton) { waypointManager.addWaypointAt(veinMetadata.center(), getName()) .setColor(getMaterial().getMaterialARGB()) .setHidden(false); + baseScreen.openGui(); } })); return true; From 173d8299717ca602059f413a261ffed54acb97bf Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Thu, 26 Dec 2024 21:52:43 +0200 Subject: [PATCH 24/45] made some of the code less deranged --- .../gregtechceu/gtceu/client/ClientProxy.java | 2 +- .../mixins/ftbchunks/RegionMapPanelMixin.java | 4 +-- .../map/ftbchunks/FTBChunksOptions.java | 23 +++++++++------- .../map/ftbchunks/FTBChunksPlugin.java | 27 ++++--------------- .../map/ftbchunks/FTBChunksRenderer.java | 4 +-- .../ftbchunks/FTBChunksWaypointHandler.java | 5 ++-- .../veins/fluid/FluidChunkWidget.java | 9 ++++--- .../map/ftbchunks/veins/ore/OreVeinIcon.java | 9 ++++--- 8 files changed, 37 insertions(+), 46 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java b/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java index e0d6fb96e6..f3e02af11d 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java +++ b/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java @@ -101,7 +101,7 @@ public void onRegisterParticleProviders(RegisterParticleProvidersEvent event) { @SubscribeEvent public void onClientSetup(FMLClientSetupEvent event) { if (LDLib.isModLoaded(GTValues.MODID_FTB_CHUNKS)) { - FTBChunksPlugin.getInstance().initialize(); + FTBChunksPlugin.addEventListeners(); } } } diff --git a/src/main/java/com/gregtechceu/gtceu/core/mixins/ftbchunks/RegionMapPanelMixin.java b/src/main/java/com/gregtechceu/gtceu/core/mixins/ftbchunks/RegionMapPanelMixin.java index c74c418625..c396898fc7 100644 --- a/src/main/java/com/gregtechceu/gtceu/core/mixins/ftbchunks/RegionMapPanelMixin.java +++ b/src/main/java/com/gregtechceu/gtceu/core/mixins/ftbchunks/RegionMapPanelMixin.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.core.mixins.ftbchunks; -import com.gregtechceu.gtceu.integration.map.ftbchunks.FTBChunksPlugin; +import com.gregtechceu.gtceu.integration.map.ftbchunks.FTBChunksOptions; import com.gregtechceu.gtceu.integration.map.ftbchunks.FTBChunksRenderer; import com.gregtechceu.gtceu.integration.map.ftbchunks.veins.fluid.FluidChunkWidget; @@ -35,7 +35,7 @@ public RegionMapPanelMixin(Panel panel) { @Inject(method = "addWidgets", at = @At(value = "INVOKE", target = "Ldev/ftb/mods/ftbchunks/client/gui/RegionMapPanel;alignWidgets()V")) private void gtceu$injectAddWidgets(CallbackInfo ci) { - if (!FTBChunksPlugin.getInstance().getOptions().showLayer("bedrock_fluids") || + if (!FTBChunksOptions.showLayer("bedrock_fluids") || MapManager.getInstance().isEmpty()) { return; } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java index 12e37803c5..f5af43a486 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java @@ -1,5 +1,7 @@ package com.gregtechceu.gtceu.integration.map.ftbchunks; +import dev.ftb.mods.ftbchunks.api.FTBChunksAPI; +import dev.ftb.mods.ftbchunks.client.FTBChunksClientConfig; import dev.ftb.mods.ftblibrary.snbt.config.BooleanValue; import java.util.HashMap; @@ -9,26 +11,29 @@ public class FTBChunksOptions { - private final Map layerOptions = new HashMap<>(); + private static final Map layerOptions = new HashMap<>(); - private final BooleanValue hideDepleted; + private static BooleanValue hideDepleted; - public FTBChunksOptions() { + private FTBChunksOptions() {} + + public static void initialize() { var group = CONFIG.addGroup("gtceu_prospecting"); - final var oreLayer = group.addBoolean("ore_veins", false); + var oreLayer = group.addBoolean("ore_veins", false); layerOptions.put(oreLayer.key, oreLayer); - final var fluidLayer = group.addBoolean("bedrock_fluids", false); + var fluidLayer = group.addBoolean("bedrock_fluids", false); layerOptions.put(fluidLayer.key, fluidLayer); hideDepleted = group.addBoolean("hide_depleted", false); } - public boolean showLayer(String name) { + public static boolean showLayer(String name) { return layerOptions.get(name).get(); } - public void toggleLayer(String name, boolean active) { + public static void toggleLayer(String name, boolean active) { layerOptions.get(name).set(active); - FTBChunksPlugin.getInstance().clientAPI.getWaypointManager().ifPresent(manager -> { + FTBChunksClientConfig.saveConfig(); + FTBChunksAPI.clientApi().getWaypointManager().ifPresent(manager -> { manager.getAllWaypoints().forEach(waypoint -> { if (waypoint.getName().equals(name)) { waypoint.setHidden(!active); @@ -37,7 +42,7 @@ public void toggleLayer(String name, boolean active) { }); } - public boolean hideDepleted() { + public static boolean hideDepleted() { return hideDepleted.get(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksPlugin.java index e91b74fa37..73680d5b41 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksPlugin.java @@ -2,36 +2,19 @@ import com.gregtechceu.gtceu.integration.map.GroupingMapRenderer; -import dev.ftb.mods.ftbchunks.api.FTBChunksAPI; -import dev.ftb.mods.ftbchunks.api.client.FTBChunksClientAPI; import dev.ftb.mods.ftbchunks.api.client.event.MapIconEvent; import dev.ftb.mods.ftbchunks.client.map.MapDimension; -import lombok.Getter; public class FTBChunksPlugin { - private static FTBChunksPlugin instance; + private FTBChunksPlugin() {} - @Getter - protected FTBChunksClientAPI clientAPI; - @Getter - protected FTBChunksOptions options; - - protected FTBChunksPlugin() {} - - public static FTBChunksPlugin getInstance() { - return instance == null ? instance = new FTBChunksPlugin() : instance; - } - - public void initialize() { - options = new FTBChunksOptions(); - clientAPI = FTBChunksAPI.clientApi(); - - MapIconEvent.MINIMAP.register(this::mapIconEventHandler); - MapIconEvent.LARGE_MAP.register(this::mapIconEventHandler); + public static void addEventListeners() { + MapIconEvent.MINIMAP.register(FTBChunksPlugin::mapIconEventHandler); + MapIconEvent.LARGE_MAP.register(FTBChunksPlugin::mapIconEventHandler); } - private void mapIconEventHandler(MapIconEvent event) { + private static void mapIconEventHandler(MapIconEvent event) { if (GroupingMapRenderer.getInstance().doShowLayer("ore_veins")) { MapDimension.getCurrent() .ifPresent(mapDimension -> FTBChunksRenderer.oreElements.row(mapDimension.dimension) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksRenderer.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksRenderer.java index 731d1b5173..f51552e79b 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksRenderer.java @@ -47,11 +47,11 @@ public boolean removeMarker(ResourceKey dim, String id) { @Override public boolean doShowLayer(String name) { - return FTBChunksPlugin.getInstance().options.showLayer(name); + return FTBChunksOptions.showLayer(name); } @Override public void setLayerActive(String name, boolean active) { - FTBChunksPlugin.getInstance().options.toggleLayer(name, active); + FTBChunksOptions.toggleLayer(name, active); } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksWaypointHandler.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksWaypointHandler.java index 88bbe2446c..946a45bab7 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksWaypointHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksWaypointHandler.java @@ -6,6 +6,7 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.Level; +import dev.ftb.mods.ftbchunks.api.FTBChunksAPI; import dev.ftb.mods.ftbchunks.api.client.waypoint.Waypoint; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; @@ -17,7 +18,7 @@ public class FTBChunksWaypointHandler implements IWaypointHandler { @Override public void setWaypoint(String key, String name, int color, ResourceKey dim, int x, int y, int z) { - FTBChunksPlugin.getInstance().clientAPI.getWaypointManager() + FTBChunksAPI.clientApi().getWaypointManager() .map(manager -> manager.addWaypointAt( new BlockPos(x, y, z), name).setColor(color).setHidden(false)) .map(waypoint -> waypoints.put(key, waypoint)); @@ -27,7 +28,7 @@ public void setWaypoint(String key, String name, int color, ResourceKey d public void removeWaypoint(String key) { var removed = waypoints.remove(key); if (removed != null) - FTBChunksPlugin.getInstance().clientAPI.getWaypointManager() + FTBChunksAPI.clientApi().getWaypointManager() .ifPresent(manager -> manager.removeWaypoint(removed)); } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java index 29de6f0c18..cbf2171cd3 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/fluid/FluidChunkWidget.java @@ -2,7 +2,7 @@ import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; import com.gregtechceu.gtceu.api.gui.misc.ProspectorMode; -import com.gregtechceu.gtceu.integration.map.ftbchunks.FTBChunksPlugin; +import com.gregtechceu.gtceu.integration.map.ftbchunks.FTBChunksOptions; import com.gregtechceu.gtceu.integration.map.layer.builtin.FluidRenderLayer; import net.minecraft.client.gui.GuiGraphics; @@ -12,6 +12,7 @@ import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions; import dev.ftb.mods.ftbchunks.FTBChunks; +import dev.ftb.mods.ftbchunks.api.FTBChunksAPI; import dev.ftb.mods.ftbchunks.client.gui.RegionMapPanel; import dev.ftb.mods.ftbchunks.client.map.MapDimension; import dev.ftb.mods.ftbchunks.client.map.WaypointImpl; @@ -64,7 +65,7 @@ public boolean mouseDoubleClicked(MouseButton button) { } MapDimension.getCurrent() - .ifPresent(mapDimension -> FTBChunksPlugin.getInstance().getClientAPI() + .ifPresent(mapDimension -> FTBChunksAPI.clientApi() .getWaypointManager(mapDimension.dimension) .ifPresent(waypointManager -> { var pos = BlockPos.containing(getPos()); @@ -81,7 +82,7 @@ public boolean mouseDoubleClicked(MouseButton button) { @Override public boolean isEnabled() { - return FTBChunksPlugin.getInstance().getOptions().showLayer("bedrock_fluids"); + return FTBChunksOptions.showLayer("bedrock_fluids"); } @Override @@ -95,7 +96,7 @@ public void addMouseOverText(TooltipList list) { @Override public boolean shouldDraw() { - return fluidInfo.left() > 0 || !FTBChunksPlugin.getInstance().getOptions().hideDepleted(); + return fluidInfo.left() > 0 || !FTBChunksOptions.hideDepleted(); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java index d3ecc727bd..1f243584ef 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/veins/ore/OreVeinIcon.java @@ -6,7 +6,7 @@ import com.gregtechceu.gtceu.api.data.worldgen.ores.GeneratedVeinMetadata; import com.gregtechceu.gtceu.client.util.DrawUtil; import com.gregtechceu.gtceu.config.ConfigHolder; -import com.gregtechceu.gtceu.integration.map.ftbchunks.FTBChunksPlugin; +import com.gregtechceu.gtceu.integration.map.ftbchunks.FTBChunksOptions; import com.gregtechceu.gtceu.integration.map.layer.builtin.OreRenderLayer; import net.minecraft.client.Minecraft; @@ -16,6 +16,7 @@ import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.systems.RenderSystem; +import dev.ftb.mods.ftbchunks.api.FTBChunksAPI; import dev.ftb.mods.ftbchunks.api.client.icon.MapIcon; import dev.ftb.mods.ftbchunks.api.client.icon.MapType; import dev.ftb.mods.ftbchunks.client.map.MapDimension; @@ -38,8 +39,8 @@ public OreVeinIcon(GeneratedVeinMetadata veinMetadata) { } public boolean isEnabled() { - return FTBChunksPlugin.getInstance().getOptions().showLayer("ore_veins") && - !(veinMetadata.depleted() && FTBChunksPlugin.getInstance().getOptions().hideDepleted()); + return FTBChunksOptions.showLayer("ore_veins") && + !(veinMetadata.depleted() && FTBChunksOptions.hideDepleted()); } public String getName() { @@ -74,7 +75,7 @@ public boolean onMousePressed(BaseScreen baseScreen, MouseButton mouseButton) { return false; } MapDimension.getCurrent() - .ifPresent(mapDimension -> FTBChunksPlugin.getInstance().getClientAPI() + .ifPresent(mapDimension -> FTBChunksAPI.clientApi() .getWaypointManager(mapDimension.dimension) .ifPresent(waypointManager -> { var waypoint = new WaypointImpl(WaypointType.DEFAULT, mapDimension, veinMetadata.center()); From c50d18b1b9dbdd1344ce628488e2d47dfb7891df Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Fri, 27 Dec 2024 09:21:20 +0200 Subject: [PATCH 25/45] replaced current player dimension with event dimension --- .../integration/map/ftbchunks/FTBChunksPlugin.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksPlugin.java index 73680d5b41..514fc0bb56 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksPlugin.java @@ -3,23 +3,24 @@ import com.gregtechceu.gtceu.integration.map.GroupingMapRenderer; import dev.ftb.mods.ftbchunks.api.client.event.MapIconEvent; -import dev.ftb.mods.ftbchunks.client.map.MapDimension; +import dev.ftb.mods.ftbchunks.client.map.MapManager; public class FTBChunksPlugin { private FTBChunksPlugin() {} public static void addEventListeners() { + FTBChunksOptions.initialize(); MapIconEvent.MINIMAP.register(FTBChunksPlugin::mapIconEventHandler); MapIconEvent.LARGE_MAP.register(FTBChunksPlugin::mapIconEventHandler); } private static void mapIconEventHandler(MapIconEvent event) { if (GroupingMapRenderer.getInstance().doShowLayer("ore_veins")) { - MapDimension.getCurrent() - .ifPresent(mapDimension -> FTBChunksRenderer.oreElements.row(mapDimension.dimension) - .values() - .forEach(event::add)); + MapManager.getInstance().ifPresent(manager -> FTBChunksRenderer.oreElements + .row(event.getDimension()) + .values() + .forEach(event::add)); } } } From 7c635b4af00d3a6a396fe61e7f76662049b62c49 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Fri, 27 Dec 2024 09:44:32 +0200 Subject: [PATCH 26/45] make sure options are initialized at most once --- .../gtceu/integration/map/ftbchunks/FTBChunksOptions.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java index f5af43a486..5a69120758 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java @@ -3,6 +3,7 @@ import dev.ftb.mods.ftbchunks.api.FTBChunksAPI; import dev.ftb.mods.ftbchunks.client.FTBChunksClientConfig; import dev.ftb.mods.ftblibrary.snbt.config.BooleanValue; +import lombok.Getter; import java.util.HashMap; import java.util.Map; @@ -14,10 +15,16 @@ public class FTBChunksOptions { private static final Map layerOptions = new HashMap<>(); private static BooleanValue hideDepleted; + + private static boolean initialized = false; private FTBChunksOptions() {} public static void initialize() { + if (initialized) { + return; + } + initialized = true; var group = CONFIG.addGroup("gtceu_prospecting"); var oreLayer = group.addBoolean("ore_veins", false); layerOptions.put(oreLayer.key, oreLayer); From 291b6bffe007d708cd7cb0c12e13cc3421128e47 Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Fri, 27 Dec 2024 10:16:24 +0200 Subject: [PATCH 27/45] getting intellij to shut up about it --- .../map/ftbchunks/FTBChunksOptions.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java index 5a69120758..0e846b3e08 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/map/ftbchunks/FTBChunksOptions.java @@ -3,7 +3,6 @@ import dev.ftb.mods.ftbchunks.api.FTBChunksAPI; import dev.ftb.mods.ftbchunks.client.FTBChunksClientConfig; import dev.ftb.mods.ftblibrary.snbt.config.BooleanValue; -import lombok.Getter; import java.util.HashMap; import java.util.Map; @@ -15,7 +14,7 @@ public class FTBChunksOptions { private static final Map layerOptions = new HashMap<>(); private static BooleanValue hideDepleted; - + private static boolean initialized = false; private FTBChunksOptions() {} @@ -40,13 +39,12 @@ public static boolean showLayer(String name) { public static void toggleLayer(String name, boolean active) { layerOptions.get(name).set(active); FTBChunksClientConfig.saveConfig(); - FTBChunksAPI.clientApi().getWaypointManager().ifPresent(manager -> { - manager.getAllWaypoints().forEach(waypoint -> { - if (waypoint.getName().equals(name)) { - waypoint.setHidden(!active); - } - }); - }); + FTBChunksAPI.clientApi().getWaypointManager() + .ifPresent(manager -> manager.getAllWaypoints().forEach(waypoint -> { + if (waypoint.getName().equals(name)) { + waypoint.setHidden(!active); + } + })); } public static boolean hideDepleted() { From 20e921e7c16ed14d302eaa3104232d098c64202e Mon Sep 17 00:00:00 2001 From: omergunr100 Date: Fri, 27 Dec 2024 10:22:14 +0200 Subject: [PATCH 28/45] initialize options right after the config is initialized --- .../ftbchunks/FTBChunksClientConfigMixin.java | 21 +++++++++++++++++++ src/main/resources/gtceu.mixins.json | 1 + 2 files changed, 22 insertions(+) create mode 100644 src/main/java/com/gregtechceu/gtceu/core/mixins/ftbchunks/FTBChunksClientConfigMixin.java diff --git a/src/main/java/com/gregtechceu/gtceu/core/mixins/ftbchunks/FTBChunksClientConfigMixin.java b/src/main/java/com/gregtechceu/gtceu/core/mixins/ftbchunks/FTBChunksClientConfigMixin.java new file mode 100644 index 0000000000..c6afa7477c --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/core/mixins/ftbchunks/FTBChunksClientConfigMixin.java @@ -0,0 +1,21 @@ +package com.gregtechceu.gtceu.core.mixins.ftbchunks; + +import com.gregtechceu.gtceu.integration.map.ftbchunks.FTBChunksOptions; + +import dev.ftb.mods.ftbchunks.client.FTBChunksClientConfig; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(value = FTBChunksClientConfig.class, remap = false) +public interface FTBChunksClientConfigMixin { + + @Inject(method = "", + at = @At(value = "INVOKE", + shift = At.Shift.AFTER, + target = "Ldev/ftb/mods/ftblibrary/snbt/config/SNBTConfig;create(Ljava/lang/String;)Ldev/ftb/mods/ftblibrary/snbt/config/SNBTConfig;")) + private static void gtceu$injectSaveConfig(CallbackInfo ci) { + FTBChunksOptions.initialize(); + } +} diff --git a/src/main/resources/gtceu.mixins.json b/src/main/resources/gtceu.mixins.json index f1c9c97e78..7e3e8c10ea 100644 --- a/src/main/resources/gtceu.mixins.json +++ b/src/main/resources/gtceu.mixins.json @@ -18,6 +18,7 @@ "journeymap.FullscreenMixin", "rei.FluidEntryRendererMixin", "ftbchunks.RegionMapPanelMixin", + "ftbchunks.FTBChunksClientConfigMixin", "xaeroworldmap.GuiMapMixin", "xaeroworldmap.MapElementRenderHandlerBuilderMixin", "xaerominimap.HighlighterRegistryMixin", From e3c1b42223005946de708583774e88b8827eb1d3 Mon Sep 17 00:00:00 2001 From: jtuc <6748724+jtuc@users.noreply.github.com> Date: Fri, 27 Dec 2024 00:06:59 +0200 Subject: [PATCH 29/45] Add LargeMapScreenMixin for toggle icons --- .../mixins/ftbchunks/LargeMapScreenMixin.java | 59 +++++++++++++++++++ src/main/resources/gtceu.mixins.json | 1 + 2 files changed, 60 insertions(+) create mode 100644 src/main/java/com/gregtechceu/gtceu/core/mixins/ftbchunks/LargeMapScreenMixin.java diff --git a/src/main/java/com/gregtechceu/gtceu/core/mixins/ftbchunks/LargeMapScreenMixin.java b/src/main/java/com/gregtechceu/gtceu/core/mixins/ftbchunks/LargeMapScreenMixin.java new file mode 100644 index 0000000000..3c11df9984 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/core/mixins/ftbchunks/LargeMapScreenMixin.java @@ -0,0 +1,59 @@ +package com.gregtechceu.gtceu.core.mixins.ftbchunks; + +import com.gregtechceu.gtceu.integration.map.ButtonState; + +import net.minecraft.network.chat.Component; +import net.minecraft.world.item.Items; + +import dev.ftb.mods.ftbchunks.client.gui.LargeMapScreen; +import dev.ftb.mods.ftblibrary.icon.Icon; +import dev.ftb.mods.ftblibrary.icon.Icons; +import dev.ftb.mods.ftblibrary.icon.ItemIcon; +import dev.ftb.mods.ftblibrary.ui.BaseScreen; +import dev.ftb.mods.ftblibrary.ui.Button; +import dev.ftb.mods.ftblibrary.ui.SimpleButton; +import org.spongepowered.asm.mixin.Mixin; +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; + +import java.util.ArrayList; +import java.util.List; + +@Mixin(value = LargeMapScreen.class, remap = false) +public abstract class LargeMapScreenMixin extends BaseScreen { + + @Unique + private final List