Skip to content

Commit 322efa0

Browse files
committed
v0.14.15.6 - Custom Radar Modes + ColorMaps
- Added Custom Radar Modes - Added PixelRenderData for CRMs - Added ColorMaps, a ColorTables equivalent - Added StringProperty for storing string values in BlockStates - Added logo - Updated neoforge.mods.toml Took 6 hours 37 minutes
1 parent b6a90ed commit 322efa0

File tree

17 files changed

+1151
-22
lines changed

17 files changed

+1151
-22
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.14.15.5
20+
mod_version=0.14.15.6
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/PMWeatherAPI.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,13 @@ public PMWeatherAPI(IEventBus modEventBus, ModContainer modContainer) {
2525
modEventBus.addListener(this::commonSetup);
2626
modEventBus.addListener(this::registerPayloads);
2727

28-
// modEventBus.addListener(this::clientSetup);
29-
3028
LOGGER.info("Initialized PMWAPI");
3129
}
3230

3331
private void commonSetup(FMLCommonSetupEvent event) {
34-
if (!ModList.get().isLoaded("pmweather")) {
35-
throw new RuntimeException("ProtoManly's Weather not detected!");
36-
}
32+
// if (!ModList.get().isLoaded("pmweather")) {
33+
// throw new RuntimeException("ProtoManly's Weather not detected!");
34+
// }
3735
}
3836

3937
private void registerPayloads(RegisterPayloadHandlersEvent event) {

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,24 @@
66
import net.neoforged.api.distmarker.OnlyIn;
77
import net.nullved.pmweatherapi.PMWeatherAPI;
88
import net.nullved.pmweatherapi.client.radar.RadarClientStorage;
9+
import net.nullved.pmweatherapi.radar.RadarMode;
10+
11+
import java.awt.*;
12+
import java.util.HashMap;
13+
import java.util.Map;
914

1015
/**
1116
* A class holding the specific storage instances for the client
1217
* @since 0.14.15.3
1318
*/
1419
@OnlyIn(Dist.CLIENT)
1520
public class PMWClientStorages {
21+
/**
22+
* A {@link Map} of {@link RadarMode}s to {@link Map}s of pixel ids and their {@link Color}
23+
* @since 0.14.15.6
24+
*/
25+
public static Map<RadarMode, Map<Integer, Color>> RADAR_MODE_COLORS = new HashMap<>();
26+
1627
private static Level lastLevel;
1728
private static RadarClientStorage radar;
1829

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package net.nullved.pmweatherapi.client.render;
2+
3+
/**
4+
* Specific rendering data for a pixel on the radar
5+
* @param canRender {@code true} if either the server doesn't require WSR-88D or a WSR-88D is complete within 4 chunks of the radar
6+
* @param rdbz The relative reflectivity
7+
* @param velocity The velocity
8+
* @param temp The temperature
9+
* @param x The x-position of the pixel (from {@code -resolution} to {@code resolution})
10+
* @param z The z-position of the pixel (from {@code -resolution} to {@code resolution})
11+
* @param resolution The resolution of the radar
12+
* @param renderData The associated {@link RenderData}
13+
* @since 0.14.15.6
14+
*/
15+
public record PixelRenderData(boolean canRender, float rdbz, float velocity, float temp, int x, int z, int resolution, RenderData renderData) {
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package net.nullved.pmweatherapi.data;
2+
3+
import net.minecraft.core.BlockPos;
4+
import net.nullved.pmweatherapi.radar.RadarMode;
5+
import net.nullved.pmweatherapi.util.StringProperty;
6+
7+
import java.util.HashMap;
8+
import java.util.Map;
9+
10+
/**
11+
* A class storing extra things used by varying parts of the API
12+
* @since 0.14.15.6
13+
*/
14+
public class PMWExtras {
15+
public static StringProperty RADAR_MODE = new StringProperty("radarmode", RadarMode.values());
16+
public static final Map<BlockPos, BlockPos> RADAR_WSR_88D_LOOKUP = new HashMap<>();
17+
}

src/main/java/net/nullved/pmweatherapi/data/PMWStorages.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
import net.minecraft.resources.ResourceKey;
44
import net.minecraft.world.level.Level;
5+
import net.nullved.pmweatherapi.radar.RadarMode;
56
import net.nullved.pmweatherapi.radar.RadarServerStorage;
67
import net.nullved.pmweatherapi.radar.RadarStorage;
8+
import net.nullved.pmweatherapi.util.StringProperty;
79

810
import java.util.HashMap;
911
import java.util.Map;
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package net.nullved.pmweatherapi.mixin;
2+
3+
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
4+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
5+
import dev.protomanly.pmweather.block.RadarBlock;
6+
import net.minecraft.core.BlockPos;
7+
import net.minecraft.world.InteractionResult;
8+
import net.minecraft.world.entity.player.Player;
9+
import net.minecraft.world.level.Level;
10+
import net.minecraft.world.level.block.Block;
11+
import net.minecraft.world.level.block.state.BlockState;
12+
import net.minecraft.world.level.block.state.StateDefinition;
13+
import net.minecraft.world.level.block.state.properties.EnumProperty;
14+
import net.minecraft.world.phys.BlockHitResult;
15+
import net.nullved.pmweatherapi.data.PMWExtras;
16+
import net.nullved.pmweatherapi.radar.RadarMode;
17+
import org.spongepowered.asm.mixin.Mixin;
18+
import org.spongepowered.asm.mixin.Shadow;
19+
import org.spongepowered.asm.mixin.injection.At;
20+
import org.spongepowered.asm.mixin.injection.Inject;
21+
import org.spongepowered.asm.mixin.injection.Redirect;
22+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
23+
24+
@Mixin(RadarBlock.class)
25+
public class RadarBlockMixin {
26+
@Shadow public static EnumProperty<RadarBlock.Mode> RADAR_MODE;
27+
28+
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Ldev/protomanly/pmweather/block/RadarBlock;registerDefaultState(Lnet/minecraft/world/level/block/state/BlockState;)V"))
29+
private void init(RadarBlock instance, BlockState state) {
30+
instance.registerDefaultState(instance.defaultBlockState().setValue(PMWExtras.RADAR_MODE, RadarMode.REFLECTIVITY.stringValue()).setValue(RADAR_MODE, RadarBlock.Mode.REFLECTIVITY));
31+
}
32+
33+
@Inject(method = "createBlockStateDefinition", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/StateDefinition$Builder;add([Lnet/minecraft/world/level/block/state/properties/Property;)Lnet/minecraft/world/level/block/state/StateDefinition$Builder;"))
34+
private void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder, CallbackInfo ci) {
35+
builder.add(PMWExtras.RADAR_MODE);
36+
}
37+
38+
@WrapMethod(method = "useWithoutItem")
39+
private InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult, Operation<InteractionResult> original) {
40+
original.call(state, level, pos, player, hitResult);
41+
42+
if (!level.isClientSide()) {
43+
RadarMode currentMode = RadarMode.get(state.getValue(PMWExtras.RADAR_MODE).value());
44+
RadarMode newMode = currentMode.cycle();
45+
level.setBlockAndUpdate(pos, state.setValue(PMWExtras.RADAR_MODE, newMode.stringValue()));
46+
}
47+
48+
return InteractionResult.SUCCESS_NO_ITEM_USED;
49+
}
50+
}

0 commit comments

Comments
 (0)