Skip to content

Commit 1fe8a33

Browse files
committed
v0.15.3.1 - Fix multiple radar bug
- Fixed a bug where 2+ radars would fight over terrain to show Took 17 minutes
1 parent 769d0aa commit 1fe8a33

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ parchment_mappings_version=2024.11.17
1717
mod_id=pmweatherapi
1818
mod_name=PMWeatherAPI
1919
mod_license=GNU GPL 3.0
20-
mod_version=0.15.3.0
20+
mod_version=0.15.3.1
2121
mod_group_id=net.nullved
2222
mod_authors=NullVed
2323
mod_description=An API for interfacing with ProtoManly's Weather Mod

src/main/java/net/nullved/pmweatherapi/client/data/PMWClientStorages.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.nullved.pmweatherapi.client.data;
22

33
import net.minecraft.client.Minecraft;
4+
import net.minecraft.core.BlockPos;
45
import net.minecraft.world.level.Level;
56
import net.neoforged.api.distmarker.Dist;
67
import net.neoforged.api.distmarker.OnlyIn;
@@ -22,7 +23,7 @@ public class PMWClientStorages {
2223
* A {@link Map} of {@link RadarMode}s to {@link Map}s of pixel ids and their {@link Color}
2324
* @since 0.14.15.6
2425
*/
25-
public static Map<RadarMode, Map<Integer, Color>> RADAR_MODE_COLORS = new HashMap<>();
26+
public static Map<BlockPos, Map<RadarMode, Map<Integer, Color>>> RADAR_MODE_COLORS = new HashMap<>();
2627

2728
private static Level lastLevel;
2829
private static RadarClientStorage radar;

src/main/java/net/nullved/pmweatherapi/mixin/RadarRendererMixin.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ private void render(BlockEntity blockEntity, float partialTicks, PoseStack poseS
139139

140140
RenderData renderData = new RenderData(blockEntity, sizeRenderDiameter, partialTicks, poseStack, multiBufferSource, combinedLightIn, combinedOverlayIn);
141141
RadarMode radarMode = blockEntity.getBlockState().getValue(PMWExtras.RADAR_MODE);
142-
if (!PMWClientStorages.RADAR_MODE_COLORS.containsKey(radarMode)) update = true;
142+
if (!PMWClientStorages.RADAR_MODE_COLORS.computeIfAbsent(radarBlockEntity.getBlockPos(), bp -> new HashMap<>()).containsKey(radarMode)) update = true;
143143

144144
for(int x = -resolution; x <= resolution; ++x) {
145145
for(int z = -resolution; z <= resolution; ++z) {
@@ -152,7 +152,7 @@ private void render(BlockEntity blockEntity, float partialTicks, PoseStack poseS
152152
float dbz = radarBlockEntity.reflectivityMap.getOrDefault(longID, 0.0F);
153153
float temp = radarBlockEntity.temperatureMap.getOrDefault(longID, 15.0F);
154154
float vel = radarBlockEntity.velocityMap.getOrDefault(longID, 0.0F);
155-
Color color = PMWClientStorages.RADAR_MODE_COLORS.computeIfAbsent(radarMode, rm -> new HashMap<>()).getOrDefault(id, new Color(1.0F, 0, 1.0F));
155+
Color color = PMWClientStorages.RADAR_MODE_COLORS.computeIfAbsent(radarBlockEntity.getBlockPos(), bp -> new HashMap<>()).computeIfAbsent(radarMode, rm -> new HashMap<>()).getOrDefault(id, new Color(1.0F, 0, 1.0F));
156156
Color dbg = radarBlockEntity.debugMap.getOrDefault(longID, new Color(0, 0, 0));
157157

158158
Vector3f pixelPos = (new Vector3f((float) x, 0.0F, (float) z)).mul(1.0F / (float) resolution).mul(sizeRenderDiameter / 2.0F);
@@ -430,7 +430,7 @@ private void render(BlockEntity blockEntity, float partialTicks, PoseStack poseS
430430
if (!PMWClientConfig.disableCustomRadarModeRendering) {
431431
PixelRenderData pixelRenderData = new PixelRenderData(canRender, dbz * 60.0F, vel, temp, x, z, resolution, worldPos, renderData);
432432
color = radarMode.getColorForPixel(pixelRenderData);
433-
PMWClientStorages.RADAR_MODE_COLORS.get(radarMode).put(id, color);
433+
PMWClientStorages.RADAR_MODE_COLORS.computeIfAbsent(radarBlockEntity.getBlockPos(), bp -> new HashMap<>()).get(radarMode).put(id, color);
434434
}
435435
}
436436

0 commit comments

Comments
 (0)