Skip to content

Commit a854691

Browse files
committed
added command /nc_radiation set xxx
1 parent 61b1f79 commit a854691

33 files changed

+619
-6
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ org.gradle.daemon=true
55
org.gradle.parallel=true
66
org.gradle.caching=true
77

8-
mod_version=1.2.6-rc.10
8+
mod_version=1.2.6
99

1010
mc_version=1.20.1
1111
mappings_version=2023.09.03

src/main/java/igentuman/nc/NuclearCraft.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ public NuclearCraft(FMLJavaModLoadingContext context) {
9494
modbus.addListener(ModSetup::init);
9595
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> modbus.addListener(ClientSetup::init));
9696
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> modbus.addListener(this::registerClientEventHandlers));
97-
isBetaBuild = ModList.get().getModFileById("nuclearcraft").getMods().get(0).getVersion().getQualifier().contains("beta");
97+
try {
98+
isBetaBuild = ModList.get().getModFileById("nuclearcraft").getMods().get(0).getVersion().getQualifier().contains("beta");
99+
} catch (Exception e) {
100+
isBetaBuild = false;
101+
}
98102
}
99103

100104
public static PacketHandler packetHandler() {

src/main/java/igentuman/nc/handler/command/RadiationCommand.java

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public static void register(CommandDispatcher<CommandSourceStack> command) {
2222
.then(Commands.argument("action", StringArgumentType.word())
2323
.suggests((context, builder) -> {
2424
builder.suggest("disable");
25+
builder.suggest("set");
2526
builder.suggest("enable");
2627
builder.suggest("clear_all");
2728
builder.suggest("clear_player");
@@ -33,6 +34,9 @@ public static void register(CommandDispatcher<CommandSourceStack> command) {
3334
.requires(cs -> cs.hasPermission(3))
3435
.executes(RadiationCommand::executeCommandWithPlayer)
3536
)
37+
.then(Commands.argument("value", new net.minecraft.commands.arguments.RangeArgument.Ints())
38+
.executes(RadiationCommand::executeSetRadiation)
39+
)
3640
)
3741
);
3842
}
@@ -43,19 +47,23 @@ private static int executeCommandWithPlayer(CommandContext<CommandSourceStack> c
4347
executor.sendSystemMessage(__("commands.nuclearcraft.no_permission"));
4448
return 1;
4549
}
46-
50+
4751
String action = StringArgumentType.getString(context, "action");
48-
52+
4953
if ("clear_player".equals(action)) {
5054
ServerPlayer targetPlayer = EntityArgument.getPlayer(context, "player");
5155
targetPlayer.getCapability(PLAYER_RADIATION).ifPresent(playerRadiation -> {
5256
playerRadiation.setRadiation(0);
5357
});
5458
executor.sendSystemMessage(Component.literal("Cleared player radiation " + targetPlayer.getName().getString()));
5559
return 1;
56-
} else {
57-
return executeCommand(context);
5860
}
61+
if ("set".equals(action)) {
62+
executeSetRadiation(context);
63+
return 1;
64+
}
65+
66+
return executeCommand(context);
5967
}
6068

6169
private static int executeCommand(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
@@ -86,4 +94,27 @@ private static int executeCommand(CommandContext<CommandSourceStack> context) th
8694

8795
return 1;
8896
}
97+
98+
private static int executeSetRadiation(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
99+
ServerPlayer player = context.getSource().getPlayerOrException();
100+
if (!player.hasPermissions(3)) {
101+
player.sendSystemMessage(__("commands.nuclearcraft.no_permission"));
102+
return 1;
103+
}
104+
String action = StringArgumentType.getString(context, "action");
105+
if (!"set".equals(action)) {
106+
context.getSource().sendFailure(Component.literal("Invalid action for value argument: " + action));
107+
return 0;
108+
}
109+
int value = 0;
110+
try {
111+
value = Math.max(0, Integer.parseInt(context.getInput().split(" ")[2]));
112+
} catch (Exception ex) {
113+
context.getSource().sendFailure(Component.literal("Invalid action for value argument: " + action));
114+
return 0;
115+
}
116+
RadiationManager.get(player.level()).setChunkRadiation(player.blockPosition(), value);
117+
player.sendSystemMessage(Component.literal("Set your radiation to " + value));
118+
return 1;
119+
}
89120
}

src/main/java/igentuman/nc/radiation/data/RadiationManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,9 @@ public void clearChunk(int x, int z) {
129129
public void addRadiation(Level level, double v, BlockPos worldPosition) {
130130
addRadiation(level, v, worldPosition.getX(), worldPosition.getY(), worldPosition.getZ());
131131
}
132+
133+
public void setChunkRadiation(BlockPos blockPos, int value) {
134+
worldRadiation.setChunkRadiation(blockPos, value);
135+
setDirty();
136+
}
132137
}

src/main/java/igentuman/nc/radiation/data/WorldRadiation.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,12 @@ public int naturalRadiation(int chunkX, int chunkZ) {
183183
radiation += RADIATION_CONFIG.dimensionRadiation(level.dimension().location().toString());
184184
return radiation;
185185
}
186+
187+
public void setChunkRadiation(BlockPos blockPos, int value) {
188+
long id = pack(blockPos.getX() >> 4, blockPos.getZ() >> 4);
189+
int curTimestamp = (int) (getServerTime() / 20);
190+
int newRadiation = Math.min(value*1000, Integer.MAX_VALUE);
191+
chunkRadiation.put(id, pack(newRadiation, curTimestamp));
192+
updatedChunks.put(id, pack(newRadiation, curTimestamp));
193+
}
186194
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "Accelerators",
3+
"description": "Accelerating particles",
4+
"icon": "nuclearcraft:linear_accelerator_controller",
5+
"parent": "nuclearcraft:multiblocks",
6+
"sortnum": 0
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "Particle Chambers",
3+
"description": "Smashing particles",
4+
"icon": "nuclearcraft:target_chamber_controller",
5+
"parent": "nuclearcraft:multiblocks",
6+
"sortnum": 0
7+
}
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
{
2+
"name": "Accelerators",
3+
"icon": "nuclearcraft:accelerator_casing",
4+
"category": "nuclearcraft:accelerators",
5+
"sortnum": 0,
6+
"pages": [
7+
{
8+
"anchor": "cooling",
9+
"type": "text",
10+
"title": "Cooling",
11+
"text": "Accelerators need to be cooled as they and the environment produce heat. If they overheat while operating, some of the overheating components will $(l)explode$().$(br2)To cool an accelerator you need to pipe in a cold coolant and pipe out a hot coolant. Each coolant has a different temperature, this determines the minimum temperature your accelerator can reach."
12+
},
13+
{
14+
"type": "text",
15+
"text": "For example, Liquid Helium is 4 Kelvin (K), Liquid Nitrogen is 70 K. The valid coolants and their temperatures can be seen in JEI. $(br2)To pipe coolant in and out of an accelerator you need at least 2 Accelerator Coolant Vents, one in input mode and one in output mode. The mode can be switched using the Nuclearcraft multitool."
16+
},
17+
{
18+
"anchor": "construction",
19+
"type": "text",
20+
"title": "Construction",
21+
"text": "The outside (casing) of all accelerators are made out of Accelerator Casing or Accelerator Glass. In the casing you need: $(li)The accelerator's controller$(li)at least one port."
22+
},
23+
{
24+
"anchor": "structure",
25+
"type": "text",
26+
"text": "Inside each accelerator, is a connected line of Beam Blocks that the particles will travel through. Around this beam can be 3 different types of $(l)component structures$(): $(l)Radio Frequency (RF) Amplifiers$(), $(l)Dipole Magnets$() and $(l)Quadrupole Magnets$(). Around these component structures coolers are placed to cool the whole accelerator."
27+
},
28+
{
29+
"type": "text",
30+
"text": "Each structure contributes to a different stat of the accelerator: RF Amplifiers add voltage, Dipole Magnets add dipole strength and Quadrupole Magnets add quadrupole strength. The amount each structure adds can be seen on the tooltip of the block that makes it."
31+
},
32+
{
33+
"type": "text",
34+
"text": ""
35+
},
36+
{
37+
"anchor": "rf_amplifier",
38+
"type": "diagram",
39+
"header": "RF Amplifiers",
40+
"text": "RF amplifiers are constructed from 8 RF Amplifier blocks of the same type in a ring around the accelerator beam as shown above. RF amplifiers cannot be directly next to each other, requiring at least a block of space between them."
41+
},
42+
{
43+
"type": "text",
44+
"text": "RF amplifiers increase the accelerating voltage of the accelerator and thus the $(l:particles/introduction#energy)energy$(/l) of the resulting particle out the end. The accelerating voltage of each RF Amplifier is determined by the material of the amplifier's blocks. Shown to the left is a RF amplifier made of niobium titanium."
45+
},
46+
{
47+
"anchor": "quadrupole",
48+
"type": "diagram",
49+
"header": "Quadrupole Magnets",
50+
"image": "nuclearcraft:textures/gui/book_images/quadrupole.png",
51+
"text": "Quadrupole Magnets are constructed from 4 Accelerator Electromagnets of the same type around an Accelerator Beam as shown above."
52+
},
53+
{
54+
"type": "text",
55+
"text": "Quadrupoles increase the $(l:particles/introduction#focus)focus$(/l) (basically the confinement) of the particle beam. The focus is used to tell how far a beam can travel. If the beam travels too far in an accelerator it will not output. So more quadrupoles are needed to be added to compensate for the $(l:particles/introduction#focus_loss)loss in focus$(/l). The strength of a quadrupole is determined by the type of electromagnet used to create it. Shown to the left is a quadrupole made of copper."
56+
},
57+
{
58+
"anchor": "dipole",
59+
"type": "diagram",
60+
"header": "Dipole Magnets",
61+
"image": "nuclearcraft:textures/gui/book_images/ring_yokes.png",
62+
"text": "Dipole Magnets are created by placing an Accelerator Electromagnet of the same type above and below a beam and the filling the rest of the 3x3x3 space around that beam with Accelerator yokes. Shown above is a Synchrotron accelerator with 5 Dipoles."
63+
},
64+
{
65+
"type": "diagram_low",
66+
"image": "nuclearcraft:textures/gui/book_images/ring_empty.png",
67+
"text": "Dipoles can have multiple beam blocks coming in and out of them replacing the yokes. Shown below is the same Synchrotron with the yokes removed to show where the beams blocks are."
68+
},
69+
{
70+
"anchor": "coolers",
71+
"type": "text",
72+
"title": "Coolers",
73+
"text": "Each RF amplifier block and electromagnet produce heat while operating. To get rid of this heat coolers are placed inside the accelerator. They only work if their required rules are met. These rules are shown on the tool tips of each cooler. You can check if coolers are in valid positions by sneak right clicking the controller of a formed accelerator with the $(l:multiblocks/multitool)multitool$(/l)."
74+
},
75+
{
76+
"type": "nuclearcraft:diagram_high",
77+
"image": "nuclearcraft:textures/gui/book_images/linac_cooler.png",
78+
"text": "Shown above is a $(l:multiblocks/accelerators/linear_accelerator)Linear Accelerator$(/l) with a quadrupole and RF amplifier with coolers placed around them."
79+
},
80+
{
81+
"anchor": "operation",
82+
"type": "text",
83+
"title": "Operation",
84+
"text": "There are a few things one should know about how to operate accelerators before building or turning them on. They are Power, Heating, Coolant, Focus and Control"
85+
},
86+
87+
{
88+
"anchor": "power",
89+
"type": "text",
90+
"title": "Power",
91+
"text": "Hovering over the Power bar (left) of the gui will show you the power stored in the accelerator and the power used by the accelerator when on. The power used can be calculated as $(l)P=p/ε$() where $(l)p$() is sum of all the components base power and $(l)ε$() is the average component efficiency. The percentage in brackets is $(l)1/ε$() which is how much of the base power is used."
92+
},
93+
{
94+
"anchor": "heat",
95+
"type": "text",
96+
"title": "Heating",
97+
"text": "There are 2 sources of heating in an accelerator. External heating from the warm environment, which depends on where the accelerator is and is always present, and internal heating. This heat comes from the components in the accelerator and is only present when the accelerator is turned on."
98+
},
99+
{
100+
"type": "text",
101+
"text": "Hovering over the heat bar (middle) of the gui will show you the heat stored in the accelerator, the Cooling: the amount of cooling the coolers provide, the Current Heating: the amount of heat currently generated, the Maximum Heating: the max amount of heat the accelerator can possibly generated (if your cooling is greater than this and the accelerator has a constant supply of coolant then it will never overheat), -"
102+
},
103+
{
104+
"type": "text",
105+
"text": "- the Maximum External Heating: the max amount of external heat from the environment (this is already included in Maximum Heating)."
106+
},
107+
{
108+
"type": "text",
109+
"text": "To calculate the maximum heating it is the sum of the internal and external heating. The external heating is $(br)$(l)Hₑ=κA(Tₑ-Tₐ)$() where $(l)Tₑ$() is the environment temperature usually around 300 K, $(l)Tₐ$() is the accelerators temperature, $(l)κ$() is thermal conductivity (default config is 0.0025) and A is the surface area of the accelerator. The maximum External heating is therefore when $(l)Tₐ$() = 0 K. The Internal Heating is the sum of all the component blocks' heat generation values."
110+
},
111+
{
112+
"anchor": "coolant",
113+
"type": "text",
114+
"title": "Coolant",
115+
"text": "Hovering over the coolant bar (right) of the gui will show you the amount of coolant stored, the maximum rate coolant can be used and the maximum amount of hot coolant that can be produced. The Accelerators coolant tanks (both input and output) can be cleared by holding shift in the gui and pressing the button that appears. The type of components you use in the accelerator determines its maximum operating temperature."
116+
},
117+
{
118+
"type": "text",
119+
"text": "The temperature of the coolant used must be below this for the accelerator to cool down below its maximum operating temperature. If the accelerator temperature rises above its maximum operating temperate while running then some of the $(l)$(c)overheating components will explode$()."
120+
},
121+
{
122+
"anchor": "focus",
123+
"type": "text",
124+
"title": "Focus",
125+
"text": "The output focus can be calculated using $(br)$(l)f = f₀-(α(1+|q|$(o)sqrt$()$(l)(I/Iᵢ)))L + |q|B₄$()$(br)where $(l)f₀$() is the input beam's focus. For a new beam created from an ion source the starting focus is determined by the ion source and is seen on its tool tip. $(l)α$() is the beam attenuation rate (this can be seen on Beamline's tool tip, by default 0.02). "
126+
},
127+
{
128+
"type": "text",
129+
"text": "$(l)I$() is the pu/t of the beam, $(l)Iᵢ$() is the beam scaling factor (10000 with default configs).$(l)L$() is the length of the accelerator, $(l)q$() is the particle's charge and $(l)B₄$() is the Quadrupole strength in Tesla of the accelerator which is the sum of the strength of each quadrupole.$(br2)The length and quadrupole strength can be seen in the accelerator's gui."
130+
},
131+
{
132+
"anchor": "control",
133+
"type": "text",
134+
"title": "Control",
135+
"text": "You can control accelerators in 2 ways either with redstone signals or if mod for Computers is installed with a computer. For redstone control: a redstone signal to the controller or a Port will try to turn the accelerator on if it can. If it can't there will be an error message in the gui."
136+
},
137+
{
138+
"type": "text",
139+
"text": "You can find out more details about specific accelerator control in their sections. You can also see more about computer control in the open computers section."
140+
},
141+
{
142+
"type": "text",
143+
"text": "In output mode redstone ports output a redstone signal strength proportional to the fraction the current temperature is to the maximum operating temperature of the accelerator. So at the maximum operating temperature and above the redstone signal strength is 15, at half the maximum operating temperature the signal strength is 7."
144+
}
145+
146+
]
147+
}

0 commit comments

Comments
 (0)