1
1
package mekanism .common .command ;
2
2
3
+ import com .mojang .brigadier .Command ;
3
4
import com .mojang .brigadier .arguments .DoubleArgumentType ;
4
5
import com .mojang .brigadier .builder .ArgumentBuilder ;
6
+ import mekanism .api .math .MathUtils ;
5
7
import mekanism .api .radiation .IRadiationManager ;
6
8
import mekanism .api .radiation .capability .IRadiationEntity ;
7
9
import mekanism .api .text .EnumColor ;
@@ -41,7 +43,7 @@ public class RadiationCommand {
41
43
.executes (ctx -> {
42
44
RadiationManager .get ().clearSources ();
43
45
ctx .getSource ().sendSuccess (() -> MekanismLang .COMMAND_RADIATION_REMOVE_ALL .translateColored (EnumColor .GRAY ), true );
44
- return 0 ;
46
+ return Command . SINGLE_SUCCESS ;
45
47
})
46
48
);
47
49
}
@@ -84,6 +86,7 @@ public class RadiationCommand {
84
86
cap .radiate (magnitude );
85
87
source .sendSuccess (() -> MekanismLang .COMMAND_RADIATION_ADD_ENTITY .translateColored (EnumColor .GRAY , RadiationScale .getSeverityColor (magnitude ),
86
88
UnitDisplayUtils .getDisplayShort (magnitude , RadiationUnit .SVH , 3 )), true );
89
+ return getReturnLevelFromRadiation (magnitude );
87
90
}
88
91
return 0 ;
89
92
})
@@ -144,7 +147,7 @@ public class RadiationCommand {
144
147
cap .set (RadiationManager .BASELINE );
145
148
source .sendSuccess (() -> MekanismLang .COMMAND_RADIATION_CLEAR .translateColored (EnumColor .GRAY ), true );
146
149
}
147
- return 0 ;
150
+ return Command . SINGLE_SUCCESS ;
148
151
}).then (Commands .argument ("targets" , EntityArgument .entities ())
149
152
.requires (MekanismPermissions .COMMAND_RADIATION_HEAL_OTHERS )
150
153
.executes (ctx -> {
@@ -181,6 +184,7 @@ public class RadiationCommand {
181
184
cap .set (newValue );
182
185
source .sendSuccess (() -> MekanismLang .COMMAND_RADIATION_REDUCE .translateColored (EnumColor .GRAY , RadiationScale .getSeverityColor (reduced ),
183
186
UnitDisplayUtils .getDisplayShort (reduced , RadiationUnit .SVH , 3 )), true );
187
+ return getReturnLevelFromRadiation (reduced );
184
188
}
185
189
return 0 ;
186
190
})
@@ -221,7 +225,7 @@ private static int addRadiation(CommandSourceStack source, Vec3 pos, Level world
221
225
IRadiationManager .INSTANCE .radiate (location , magnitude );
222
226
source .sendSuccess (() -> MekanismLang .COMMAND_RADIATION_ADD .translateColored (EnumColor .GRAY , RadiationScale .getSeverityColor (magnitude ),
223
227
UnitDisplayUtils .getDisplayShort (magnitude , RadiationUnit .SVH , 3 ), EnumColor .INDIGO , getPosition (location .pos ()), EnumColor .INDIGO , world ), true );
224
- return 0 ;
228
+ return getReturnLevelFromRadiation ( magnitude ) ;
225
229
}
226
230
227
231
private static int getRadiationLevel (CommandSourceStack source , Coordinates location , Level world ) {
@@ -234,10 +238,18 @@ private static int getRadiationLevel(CommandSourceStack source, Vec3 pos, Level
234
238
source .sendSuccess (() -> MekanismLang .COMMAND_RADIATION_GET .translateColored (EnumColor .GRAY , EnumColor .INDIGO , getPosition (location .pos ()), EnumColor .INDIGO ,
235
239
world , RadiationScale .getSeverityColor (magnitude ), UnitDisplayUtils .getDisplayShort (magnitude , RadiationUnit .SVH , 3 )),
236
240
true );
237
- return 0 ;
241
+ return getReturnLevelFromRadiation ( magnitude ) ;
238
242
}
239
243
240
244
private static Component getPosition (BlockPos pos ) {
241
245
return MekanismLang .GENERIC_BLOCK_POS .translate (pos .getX (), pos .getY (), pos .getZ ());
242
246
}
247
+
248
+ private static int getReturnLevelFromRadiation (double magnitude ) {
249
+ if (magnitude < RadiationManager .MIN_MAGNITUDE ) {
250
+ return 0 ;
251
+ }
252
+ //Multiply to make it so that we can differentiate various levels based on what the micro sievert rate would be
253
+ return MathUtils .clampToInt (magnitude * 1_000_000 );
254
+ }
243
255
}
0 commit comments