Skip to content

Commit b3428b8

Browse files
authored
v0.15.3.3-rc2 - Storage #for functions, Radar Overlays off when debugging
2 parents 4067d4b + a930963 commit b3428b8

10 files changed

Lines changed: 103 additions & 10 deletions

File tree

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ 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.3-rc1
20+
mod_version=0.15.3.3-rc2
2121
mod_group_id=net.nullved
2222
mod_authors=nullved
2323
mod_description=An API for interfacing with ProtoManly's Weather Mod
2424

2525
# Dependencies
2626
pmweather_version=0.15.3
27-
pmweather_version_range=[0.15.0-1.21.1-alpha,0.15.999-1.21.1-alpha)
27+
pmweather_version_range=[0.15.3-1.21.1-alpha,0.15.999-1.21.1-alpha)

src/main/java/net/nullved/pmweatherapi/client/render/IDOverlay.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,21 @@ public void render(boolean canRender, RenderData renderData, BufferBuilder buffe
3737
poseStack.pushPose();
3838
poseStack.translate((side.x * scale) - 0.5F * (scale - 1), 1.055f, (side.z * scale) - 0.5F * (scale - 1));
3939
poseStack.mulPose(Axis.YN.rotationDegrees(side.rotation));
40+
poseStack.mulPose(Axis.XP.rotationDegrees(90));
4041
poseStack.scale(0.01f, 0.01f, 0.01f);
4142

4243
renderText(Component.literal(mode.getId().toString()), renderData, poseStack);
4344

45+
poseStack.mulPose(Axis.XP.rotationDegrees(-90));
46+
47+
4448
float lineHeight = 8.0f;
4549
float offset = lineHeight;
4650
for (Supplier<? extends IRadarOverlay> overlay: RadarOverlays.getOverlays()) {
4751
poseStack.pushPose();
4852
poseStack.translate(0, 0, offset);
4953
poseStack.scale(0.6f, 0.6f, 0.6f);
54+
poseStack.mulPose(Axis.XP.rotationDegrees(90));
5055

5156
renderText(Component.literal(overlay.get().getID().toString()).withColor(0x888888), renderData, poseStack);
5257

src/main/java/net/nullved/pmweatherapi/config/PMWClientConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public class PMWClientConfig {
1414

1515
private static final ModConfigSpec.BooleanValue DISABLE_CUSTOM_RADAR_MODE_RENDERING;
1616
public static boolean disableCustomRadarModeRendering;
17+
private static final ModConfigSpec.BooleanValue DISABLE_OVERLAYS_WHEN_DEBUGGING;
18+
public static boolean disableOverlaysWhenDebugging;
1719
private static final ModConfigSpec.BooleanValue SHOW_RADAR_MODE_ID;
1820
public static boolean showRadarModeId;
1921
private static final ModConfigSpec.EnumValue<RadarModeIDSide> RADAR_MODE_ID_SIDE;
@@ -25,13 +27,15 @@ private static void onLoad(ModConfigEvent event) {
2527
if (event.getConfig().getSpec() == SPEC && !(event instanceof ModConfigEvent.Unloading)) {
2628
PMWeatherAPI.LOGGER.info("Loading Client PMWeatherAPI Configs");
2729
disableCustomRadarModeRendering = DISABLE_CUSTOM_RADAR_MODE_RENDERING.getAsBoolean();
30+
disableOverlaysWhenDebugging = DISABLE_OVERLAYS_WHEN_DEBUGGING.getAsBoolean();
2831
showRadarModeId = SHOW_RADAR_MODE_ID.getAsBoolean();
2932
radarModeIDSide = RADAR_MODE_ID_SIDE.get();
3033
}
3134
}
3235

3336
static {
3437
DISABLE_CUSTOM_RADAR_MODE_RENDERING = BUILDER.comment("Disables custom radar mode rendering").define("disable_custom_radar_mode_rendering", false);
38+
DISABLE_OVERLAYS_WHEN_DEBUGGING = BUILDER.comment("Disables all overlays when client radar debugging is on").define("disable_overlays_when_debugging", true);
3539
SHOW_RADAR_MODE_ID = BUILDER.comment("Shows the radar mode ID").define("show_radar_mode_id", false);
3640
RADAR_MODE_ID_SIDE = BUILDER.comment("The side to render the radar mode ID on").defineEnum("radar_mode_id_side", RadarModeIDSide.NORTH);
3741
SPEC = BUILDER.build();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class BlockBehaviourMixin {
3333
private static void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston, CallbackInfo ci) {
3434
if (state.getBlock() instanceof RadarBlock) {
3535
RadarServerStorage radarStorage = PMWStorages.radars().get(level.dimension());
36-
radarStorage.addAndSync(new RadarStorageData(pos, state.getValue(PMWExtras.RADAR_MODE)));
36+
radarStorage.addAndSync(new RadarStorageData(pos, state.getValue(PMWExtras.RADAR_MODE), state.getValue(RadarBlock.ON)));
3737
} else if (state.getBlock() instanceof MetarBlock) {
3838
// Get Metar data
3939
WeatherHandler weatherHandler = GameBusEvents.MANAGERS.get(level.dimension());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private InteractionResult useWithoutItem(BlockState state, Level level, BlockPos
5151
if (!level.isClientSide()) {
5252
RadarMode currentMode = state.getValue(PMWExtras.RADAR_MODE);
5353
RadarMode newMode = currentMode.cycle();
54-
PMWStorages.radars().get(level.dimension()).addAndSync(new RadarStorageData(pos, newMode));
54+
PMWStorages.radars().get(level.dimension()).addAndSync(new RadarStorageData(pos, newMode, state.getValue(RadarBlock.ON)));
5555
level.setBlockAndUpdate(pos, state.setValue(PMWExtras.RADAR_MODE, newMode));
5656
}
5757

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ private void render(BlockEntity blockEntity, float partialTicks, PoseStack poseS
592592
bufferBuilder.addVertex(topLeft).setColor(color).addVertex(bottomLeft).setColor(color).addVertex(bottomRight).setColor(color).addVertex(topRight).setColor(color);
593593

594594
// PMWeatherAPI: RadarOverlays callback
595-
RadarOverlays.renderOverlays(renderData, bufferBuilder, canRender);
595+
if (!ClientConfig.radarDebugging || !PMWClientConfig.disableOverlaysWhenDebugging) RadarOverlays.renderOverlays(renderData, bufferBuilder, canRender);
596596

597597
matrix4fStack.mul(poseStack.last().pose().invert());
598598
matrix4fStack.translate(-0.5F, -1.05F, -0.5F);

src/main/java/net/nullved/pmweatherapi/radar/storage/RadarStorageData.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,21 @@
1818
*/
1919
public class RadarStorageData extends StorageData {
2020
public static final ResourceLocation ID = PMWeatherAPI.rl("radar");
21-
private RadarMode radarMode;
21+
private final RadarMode radarMode;
22+
private final boolean on;
2223

23-
public RadarStorageData(BlockPos pos, RadarMode radarMode) {
24+
public RadarStorageData(BlockPos pos, RadarMode radarMode, boolean on) {
2425
super(pos);
2526
this.radarMode = radarMode;
27+
this.on = on;
28+
}
29+
30+
public RadarMode getRadarMode() {
31+
return radarMode;
32+
}
33+
34+
public boolean isOn() {
35+
return on;
2636
}
2737

2838
@Override
@@ -34,6 +44,7 @@ public ResourceLocation getId() {
3444
public CompoundTag serializeToNBT() {
3545
CompoundTag tag = super.serializeToNBT();
3646
tag.putString("radar_mode", radarMode.getSerializedName());
47+
tag.putBoolean("on", on);
3748
return tag;
3849
}
3950

@@ -42,9 +53,10 @@ public static RadarStorageData deserializeFromNBT(CompoundTag tag, int version)
4253

4354
if (bp != null) {
4455
RadarMode mode = RadarMode.get(tag.getString("radar_mode"));
45-
return new RadarStorageData(bp, mode);
56+
boolean on = tag.getBoolean("on");
57+
return new RadarStorageData(bp, mode, on);
4658
} else {
47-
return new RadarStorageData(NbtUtils.readBlockPos(tag, "").orElseThrow(() -> new IllegalArgumentException("Could not read BlockPos in RadarStorageData!")), RadarMode.get(tag.getString("radar_mode")));
59+
return new RadarStorageData(NbtUtils.readBlockPos(tag, "").orElseThrow(() -> new IllegalArgumentException("Could not read BlockPos in RadarStorageData!")), RadarMode.get(tag.getString("radar_mode")), !tag.contains("on") || tag.getBoolean("on"));
4860
}
4961
}
5062
}

src/main/java/net/nullved/pmweatherapi/storage/IStorage.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import java.util.Collection;
1414
import java.util.Set;
15+
import java.util.function.Consumer;
1516

1617
/**
1718
* The interface defining a Storage such as {@link RadarStorage}
@@ -41,6 +42,11 @@ public interface IStorage<D extends IStorageData> {
4142
Set<D> getInChunk(ChunkPos pos);
4243
Set<D> getInAdjacentChunks(ChunkPos pos);
4344

45+
void forAll(Consumer<D> consumer);
46+
void forAllWithinRange(BlockPos base, double radius, Consumer<D> consumer);
47+
void forInChunk(ChunkPos pos, Consumer<D> consumer);
48+
void forInAdjacentChunks(ChunkPos pos, Consumer<D> consumer);
49+
4450
boolean shouldRecalculate(ChunkPos pos);
4551

4652
void add(D data);

src/main/java/net/nullved/pmweatherapi/storage/PMWStorage.java

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import net.minecraft.server.level.ServerLevel;
1212
import net.minecraft.world.level.ChunkPos;
1313
import net.minecraft.world.level.Level;
14-
import net.minecraft.world.level.block.Block;
1514
import net.neoforged.neoforge.event.level.ChunkWatchEvent;
1615
import net.nullved.pmweatherapi.PMWeatherAPI;
1716
import net.nullved.pmweatherapi.client.data.IClientStorage;
@@ -26,6 +25,7 @@
2625
import net.nullved.pmweatherapi.storage.data.StorageData;
2726

2827
import java.util.*;
28+
import java.util.function.Consumer;
2929
import java.util.function.Function;
3030
import java.util.stream.Collectors;
3131

@@ -127,6 +127,14 @@ public Set<D> getAll() {
127127
return data.values().stream().flatMap(Collection::stream).collect(Collectors.toSet());
128128
}
129129

130+
/**
131+
* Gets a {@link Set} of every {@link IStorageData} within a given radius of the base {@link BlockPos}
132+
*
133+
* @param base The base {@link BlockPos}
134+
* @param radius The radius of the search range
135+
* @return All {@link IStorageData} within {@code radius} blocks of the base {@link BlockPos}
136+
* @since 0.15.3.3
137+
*/
130138
@Override
131139
public Set<D> getAllWithinRange(BlockPos base, double radius) {
132140
int chunks = (int) Math.ceil(radius / 16.0F) + 1;
@@ -155,6 +163,13 @@ public Set<D> getInChunk(ChunkPos pos) {
155163
return data.getOrDefault(pos, Set.of());
156164
}
157165

166+
/**
167+
* Gets the {@link Set} of {@link IStorageData} within this and adjacent {@link ChunkPos}'
168+
*
169+
* @param pos The middle {@link ChunkPos}
170+
* @return A {@link Set} of the {@link IStorageData} in this and adjacent chunks
171+
* @since 0.15.3.3
172+
*/
158173
@Override
159174
public Set<D> getInAdjacentChunks(ChunkPos pos) {
160175
Set<D> set = new HashSet<>();
@@ -166,6 +181,55 @@ public Set<D> getInAdjacentChunks(ChunkPos pos) {
166181
return set;
167182
}
168183

184+
185+
/**
186+
* Executes a {@link Consumer} for every {@link IStorageData} saved in this {@link IStorage}, regardless of {@link ChunkPos}
187+
*
188+
* @param consumer The function to run for each {@link IStorageData}
189+
* @since 0.15.3.3-rc2
190+
*/
191+
@Override
192+
public void forAll(Consumer<D> consumer) {
193+
getAll().forEach(consumer);
194+
}
195+
196+
/**
197+
* Executes a {@link Consumer} for every {@link IStorageData} within a given radius of the base {@link BlockPos}
198+
*
199+
* @param base The base {@link BlockPos}
200+
* @param radius The radius of the search range
201+
* @param consumer The function to run for each {@link IStorageData}
202+
* @since 0.15.3.3-rc2
203+
*/
204+
@Override
205+
public void forAllWithinRange(BlockPos base, double radius, Consumer<D> consumer) {
206+
getAllWithinRange(base, radius).forEach(consumer);
207+
}
208+
209+
/**
210+
* Executes a {@link Consumer} for each {@link IStorageData} in this {@link ChunkPos}
211+
*
212+
* @param pos The {@link ChunkPos} to search
213+
* @param consumer The function to run for each {@link IStorageData}
214+
* @since 0.15.3.3-rc2
215+
*/
216+
@Override
217+
public void forInChunk(ChunkPos pos, Consumer<D> consumer) {
218+
getInChunk(pos).forEach(consumer);
219+
}
220+
221+
/**
222+
* Executes a {@link Consumer} for each {@link IStorageData} within this and adjacent {@link ChunkPos}'
223+
*
224+
* @param pos The middle {@link ChunkPos}
225+
* @param consumer The function to run for each {@link IStorageData}
226+
* @since 0.15.3.3-rc2
227+
*/
228+
@Override
229+
public void forInAdjacentChunks(ChunkPos pos, Consumer<D> consumer) {
230+
getInAdjacentChunks(pos).forEach(consumer);
231+
}
232+
169233
/**
170234
* Determines if the data for the given {@link ChunkPos} is older than 30 seconds or does not exist.
171235
* Intended to be used while listening to a {@link ChunkWatchEvent.Sent} event (See {@link PMWEvents})

src/main/resources/assets/pmweatherapi/lang/en_us.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"pmweatherapi.configuration.disable_custom_radar_mode_rendering": "Disable Custom Radar Mode Rendering",
33
"pmweatherapi.configuration.disable_custom_radar_mode_rendering.tooltip": "Disables all custom radar modes from rendering. Falls back to PMWeather for Reflectivity and Velocity. Any custom radar modes will not appear, but still be cycled through",
4+
"pmweatherapi.configuration.disable_overlays_when_debugging": "Disable Overlays when Debugging",
5+
"pmweatherapi.configuration.disable_overlays_when_debugging.tooltip": "Disables all overlays from rendering when client radar debugging is on",
46
"pmweatherapi.configuration.show_radar_mode_id": "Show Radar Mode ID",
57
"pmweatherapi.configuration.show_radar_mode_id.tooltip": "Enables an overlay to show the current radar mode's ID",
68
"pmweatherapi.configuration.radar_mode_id_side": "Radar Mode ID Side",

0 commit comments

Comments
 (0)