Skip to content

Commit f42efec

Browse files
committed
update: 1.21.8 initial commit
1 parent 541387d commit f42efec

18 files changed

+917
-918
lines changed

gradle.properties

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ org.gradle.jvmargs=-Xmx3G
44
org.gradle.daemon=false
55
org.gradle.debug=false
66

7-
parchment_minecraft=1.21.5
8-
parchment_version=2025.06.15
7+
parchment_minecraft=1.21.8
8+
parchment_version=2025.07.20
99

1010
# Mod
1111
mod_id=nitrogen_internals
@@ -19,16 +19,16 @@ mod_credits=The Aether Team
1919
mod_authors=AlphaMode, bconlon, Blodhgarm
2020
mod_description=A library used for the Aether series of mods.
2121

22-
minecraft_version=1.21.5
23-
minecraft_version_range=[1.21.5,1.21.6)
22+
minecraft_version=1.21.8
23+
minecraft_version_range=[1.21.8,1.21.9)
2424

25-
moddevgradle_version=2.0.61-beta
25+
moddevgradle_version=2.0.105
2626

27-
neo_version=21.5.89
28-
neo_version_range=[21.5.89,)
27+
neo_version=21.8.25
28+
neo_version_range=[21.8.25,)
2929

3030
# Dependencies
3131
#jei_version=19.21.0.246
32-
rei_version=19.0.809
33-
cloth_config_version=18.0.145
34-
architectury_version=16.1.4
32+
rei_version=20.0.811
33+
cloth_config_version=19.0.147
34+
architectury_version=17.0.8

src/main/java/com/aetherteam/nitrogen/Nitrogen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import java.util.UUID;
3535

3636
@Mod(Nitrogen.MODID)
37-
@EventBusSubscriber(modid = Nitrogen.MODID, bus = EventBusSubscriber.Bus.GAME)
37+
@EventBusSubscriber(modid = Nitrogen.MODID)
3838
public class Nitrogen {
3939
public static final String MODID = "nitrogen_internals";
4040
public static final Logger LOGGER = LogUtils.getLogger();
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
package com.aetherteam.nitrogen.attachment;
22

3-
import com.aetherteam.nitrogen.network.packet.SyncLevelPacket;
4-
import net.minecraft.client.Minecraft;
5-
import net.minecraft.world.entity.player.Player;
6-
import net.minecraft.world.level.Level;
7-
8-
public class AttachmentUtil {
9-
/**
10-
* Used to sync data for level capabilities. This is in its own class to avoid classloading {@link Minecraft} from {@link SyncLevelPacket} on servers.
11-
*
12-
* @param syncLevelPacket The {@link SyncLevelPacket}.
13-
* @param playerEntity The {@link Player} that the level belongs to.
14-
* @param key The {@link String} key for the field to sync.
15-
* @param value The {@link Object} value to sync to the field.
16-
* @param isClientSide Whether the level is clientside, as a {@link Boolean}.
17-
* @see SyncLevelPacket
18-
*/
19-
public static void syncLevelCapability(SyncLevelPacket<?> syncLevelPacket, Player playerEntity, String key, Object value, boolean isClientSide) {
20-
Level level = isClientSide ? Minecraft.getInstance().level : playerEntity.level();
21-
level.getData(syncLevelPacket.getAttachment()).getSynchableFunctions().get(key).getMiddle().accept(value);
22-
}
23-
}
3+
//import com.aetherteam.nitrogen.network.packet.SyncLevelPacket;
4+
//import net.minecraft.client.Minecraft;
5+
//import net.minecraft.world.entity.player.Player;
6+
//import net.minecraft.world.level.Level;
7+
//
8+
//public class AttachmentUtil {
9+
// /**
10+
// * Used to sync data for level capabilities. This is in its own class to avoid classloading {@link Minecraft} from {@link SyncLevelPacket} on servers.
11+
// *
12+
// * @param syncLevelPacket The {@link SyncLevelPacket}.
13+
// * @param playerEntity The {@link Player} that the level belongs to.
14+
// * @param key The {@link String} key for the field to sync.
15+
// * @param value The {@link Object} value to sync to the field.
16+
// * @param isClientSide Whether the level is clientside, as a {@link Boolean}.
17+
// * @see SyncLevelPacket
18+
// */
19+
// public static void syncLevelCapability(SyncLevelPacket<?> syncLevelPacket, Player playerEntity, String key, Object value, boolean isClientSide) {
20+
// Level level = isClientSide ? Minecraft.getInstance().level : playerEntity.level();
21+
// level.getData(syncLevelPacket.getAttachment()).getSynchableFunctions().get(key).getMiddle().accept(value);
22+
// }
23+
//}
Lines changed: 130 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,132 @@
11
package com.aetherteam.nitrogen.attachment;
22

3-
import com.aetherteam.nitrogen.network.packet.SyncPacket;
4-
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
5-
import net.minecraft.resources.ResourceKey;
6-
import net.minecraft.server.level.ServerLevel;
7-
import net.minecraft.server.level.ServerPlayer;
8-
import net.minecraft.world.level.Level;
9-
import net.neoforged.neoforge.network.PacketDistributor;
10-
import org.apache.commons.lang3.tuple.Triple;
11-
import oshi.util.tuples.Quintet;
12-
13-
import javax.annotation.Nullable;
14-
import java.util.Map;
15-
import java.util.function.Consumer;
16-
import java.util.function.Supplier;
17-
18-
public interface INBTSynchable {
19-
/**
20-
* Sets a value to be synced to the given direction.
21-
*
22-
* @param direction The network {@link Direction} to send the packet.
23-
* @param key The {@link String} key for the field to sync.
24-
* @param value The {@link Object} value to sync to the field.
25-
*/
26-
default void setSynched(int entityID, Direction direction, String key, Object value) {
27-
this.setSynched(entityID, direction, key, value, null);
28-
}
29-
30-
/**
31-
* Sets a value to be synced to the given direction.<br><br>
32-
* Warning for "unchecked" is suppressed because casting from wildcards to classes inside type bounds is fine.
33-
*
34-
* @param direction The network {@link Direction} to send the packet.
35-
* @param key The {@link String} key for the field to sync.
36-
* @param value The {@link Object} value to sync to the field.
37-
* @param extra An extra value if necessary. The type of class that needs to be given depends on the direction.<br><br>
38-
* {@link Direction#SERVER} - None.<br><br>
39-
* {@link Direction#CLIENT} - None.<br><br>
40-
* {@link Direction#NEAR} - {@link Quintet}<{@link Double}, {@link Double}, {@link Double}, {@link Double}, {@link ServerLevel}>. This represents the 5 values needed for {@link PacketExecution#sendToNear(CustomPacketPayload, double, double, double, double, ResourceKey)}.<br><br>
41-
* {@link Direction#PLAYER} - {@link ServerPlayer}.<br><br>
42-
* {@link Direction#DIMENSION} - {@link ResourceKey}<{@link Level}>>. This represents the dimension to send the packet to.
43-
*/
44-
@SuppressWarnings("unchecked")
45-
default void setSynched(int entityID, Direction direction, String key, Object value, @Nullable Object extra) {
46-
switch (direction) {
47-
case SERVER ->
48-
PacketDistributor.sendToServer(this.getSyncPacket(entityID, key, this.getSynchableFunctions().get(key).getLeft(), value));
49-
case CLIENT ->
50-
PacketDistributor.sendToAllPlayers(this.getSyncPacket(entityID, key, this.getSynchableFunctions().get(key).getLeft(), value));
51-
case NEAR -> {
52-
if (extra instanceof Quintet<?, ?, ?, ?, ?> quintet) {
53-
Quintet<Double, Double, Double, Double, ServerLevel> nearValues = (Quintet<Double, Double, Double, Double, ServerLevel>) quintet;
54-
PacketDistributor.sendToPlayersNear(nearValues.getE(), null, nearValues.getA(), nearValues.getB(), nearValues.getC(), nearValues.getD(), this.getSyncPacket(entityID, key, this.getSynchableFunctions().get(key).getLeft(), value));
55-
}
56-
}
57-
case PLAYER -> {
58-
if (extra instanceof ServerPlayer serverPlayer) {
59-
PacketDistributor.sendToPlayer(serverPlayer, this.getSyncPacket(entityID, key, this.getSynchableFunctions().get(key).getLeft(), value));
60-
}
61-
}
62-
case DIMENSION -> {
63-
if (extra instanceof ServerLevel serverLevel) {
64-
PacketDistributor.sendToPlayersInDimension(serverLevel, this.getSyncPacket(entityID, key, this.getSynchableFunctions().get(key).getLeft(), value));
65-
}
66-
}
67-
}
68-
this.getSynchableFunctions().get(key).getMiddle().accept(value);
69-
}
70-
71-
/**
72-
* Forces all synchable capability values to sync to the given direction.
73-
*
74-
* @param direction The network {@link Direction} to send the packet.
75-
*/
76-
default void forceSync(int entityID, Direction direction) {
77-
this.forceSync(entityID, direction, null);
78-
}
79-
80-
/**
81-
* Forces all synchable capability values to sync to the given direction.
82-
*
83-
* @param direction The network {@link Direction} to send the packet.
84-
* @param extra An extra value if necessary. The type of class that needs to be given depends on the direction.<br><br>
85-
* {@link Direction#SERVER} - None.<br><br>
86-
* {@link Direction#CLIENT} - None.<br><br>
87-
* {@link Direction#NEAR} - {@link Quintet}<{@link Double}, {@link Double}, {@link Double}, {@link Double}, {@link ResourceKey}<{@link Level}>>. This represents the 5 values needed for {@link PacketExecution#sendToNear(CustomPacketPayload, double, double, double, double, ResourceKey)}.<br><br>
88-
* {@link Direction#PLAYER} - {@link ServerPlayer}.<br><br>
89-
* {@link Direction#DIMENSION} - {@link ResourceKey}<{@link Level}>>. This represents the dimension to send the packet to.
90-
*/
91-
default void forceSync(int entityID, Direction direction, @Nullable Object extra) {
92-
for (Map.Entry<String, Triple<Type, Consumer<Object>, Supplier<Object>>> entry : this.getSynchableFunctions().entrySet()) {
93-
this.setSynched(entityID, direction, entry.getKey(), entry.getValue().getRight().get(), extra);
94-
}
95-
}
96-
97-
/**
98-
* @return A {@link Map} of {@link String}s (representing the name of a field), and {@link Triple}s, containing
99-
* {@link Type}s (representing the data type),
100-
* {@link Consumer}<{@link Object}>s (representing setter methods), and
101-
* {@link Supplier}<{@link Object}>s (representing getter methods).
102-
*/
103-
Map<String, Triple<Type, Consumer<Object>, Supplier<Object>>> getSynchableFunctions();
104-
105-
/**
106-
* Creates the packet used for syncing.
107-
*
108-
* @param key The {@link String} key for the field to sync.
109-
* @param type The {@link Type} for the field's data type.
110-
* @param value The {@link Object} value to sync to the field.
111-
* @return The {@link SyncPacket} for syncing.
112-
*/
113-
SyncPacket getSyncPacket(int entityID, String key, INBTSynchable.Type type, Object value);
114-
115-
enum Direction {
116-
SERVER,
117-
CLIENT,
118-
NEAR,
119-
PLAYER,
120-
DIMENSION
121-
}
122-
123-
enum Type {
124-
INT,
125-
FLOAT,
126-
DOUBLE,
127-
BOOLEAN,
128-
UUID,
129-
ITEM_STACK,
130-
COMPOUND_TAG
131-
}
132-
}
3+
//import com.aetherteam.nitrogen.network.packet.SyncPacket;
4+
//import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
5+
//import net.minecraft.resources.ResourceKey;
6+
//import net.minecraft.server.level.ServerLevel;
7+
//import net.minecraft.server.level.ServerPlayer;
8+
//import net.minecraft.world.level.Level;
9+
//import net.neoforged.neoforge.network.PacketDistributor;
10+
//import org.apache.commons.lang3.tuple.Triple;
11+
//import oshi.util.tuples.Quintet;
12+
//
13+
//import javax.annotation.Nullable;
14+
//import java.util.Map;
15+
//import java.util.function.Consumer;
16+
//import java.util.function.Supplier;
17+
//
18+
//public interface INBTSynchable {
19+
// /**
20+
// * Sets a value to be synced to the given direction.
21+
// *
22+
// * @param direction The network {@link Direction} to send the packet.
23+
// * @param key The {@link String} key for the field to sync.
24+
// * @param value The {@link Object} value to sync to the field.
25+
// */
26+
// default void setSynched(int entityID, Direction direction, String key, Object value) {
27+
// this.setSynched(entityID, direction, key, value, null);
28+
// }
29+
//
30+
// /**
31+
// * Sets a value to be synced to the given direction.<br><br>
32+
// * Warning for "unchecked" is suppressed because casting from wildcards to classes inside type bounds is fine.
33+
// *
34+
// * @param direction The network {@link Direction} to send the packet.
35+
// * @param key The {@link String} key for the field to sync.
36+
// * @param value The {@link Object} value to sync to the field.
37+
// * @param extra An extra value if necessary. The type of class that needs to be given depends on the direction.<br><br>
38+
// * {@link Direction#SERVER} - None.<br><br>
39+
// * {@link Direction#CLIENT} - None.<br><br>
40+
// * {@link Direction#NEAR} - {@link Quintet}<{@link Double}, {@link Double}, {@link Double}, {@link Double}, {@link ServerLevel}>. This represents the 5 values needed for {@link PacketExecution#sendToNear(CustomPacketPayload, double, double, double, double, ResourceKey)}.<br><br>
41+
// * {@link Direction#PLAYER} - {@link ServerPlayer}.<br><br>
42+
// * {@link Direction#DIMENSION} - {@link ResourceKey}<{@link Level}>>. This represents the dimension to send the packet to.
43+
// */
44+
// @SuppressWarnings("unchecked")
45+
// default void setSynched(int entityID, Direction direction, String key, Object value, @Nullable Object extra) {
46+
// switch (direction) {
47+
// case SERVER ->
48+
// PacketDistributor.sendToServer(this.getSyncPacket(entityID, key, this.getSynchableFunctions().get(key).getLeft(), value));
49+
// case CLIENT ->
50+
// PacketDistributor.sendToAllPlayers(this.getSyncPacket(entityID, key, this.getSynchableFunctions().get(key).getLeft(), value));
51+
// case NEAR -> {
52+
// if (extra instanceof Quintet<?, ?, ?, ?, ?> quintet) {
53+
// Quintet<Double, Double, Double, Double, ServerLevel> nearValues = (Quintet<Double, Double, Double, Double, ServerLevel>) quintet;
54+
// PacketDistributor.sendToPlayersNear(nearValues.getE(), null, nearValues.getA(), nearValues.getB(), nearValues.getC(), nearValues.getD(), this.getSyncPacket(entityID, key, this.getSynchableFunctions().get(key).getLeft(), value));
55+
// }
56+
// }
57+
// case PLAYER -> {
58+
// if (extra instanceof ServerPlayer serverPlayer) {
59+
// PacketDistributor.sendToPlayer(serverPlayer, this.getSyncPacket(entityID, key, this.getSynchableFunctions().get(key).getLeft(), value));
60+
// }
61+
// }
62+
// case DIMENSION -> {
63+
// if (extra instanceof ServerLevel serverLevel) {
64+
// PacketDistributor.sendToPlayersInDimension(serverLevel, this.getSyncPacket(entityID, key, this.getSynchableFunctions().get(key).getLeft(), value));
65+
// }
66+
// }
67+
// }
68+
// this.getSynchableFunctions().get(key).getMiddle().accept(value);
69+
// }
70+
//
71+
// /**
72+
// * Forces all synchable capability values to sync to the given direction.
73+
// *
74+
// * @param direction The network {@link Direction} to send the packet.
75+
// */
76+
// default void forceSync(int entityID, Direction direction) {
77+
// this.forceSync(entityID, direction, null);
78+
// }
79+
//
80+
// /**
81+
// * Forces all synchable capability values to sync to the given direction.
82+
// *
83+
// * @param direction The network {@link Direction} to send the packet.
84+
// * @param extra An extra value if necessary. The type of class that needs to be given depends on the direction.<br><br>
85+
// * {@link Direction#SERVER} - None.<br><br>
86+
// * {@link Direction#CLIENT} - None.<br><br>
87+
// * {@link Direction#NEAR} - {@link Quintet}<{@link Double}, {@link Double}, {@link Double}, {@link Double}, {@link ResourceKey}<{@link Level}>>. This represents the 5 values needed for {@link PacketExecution#sendToNear(CustomPacketPayload, double, double, double, double, ResourceKey)}.<br><br>
88+
// * {@link Direction#PLAYER} - {@link ServerPlayer}.<br><br>
89+
// * {@link Direction#DIMENSION} - {@link ResourceKey}<{@link Level}>>. This represents the dimension to send the packet to.
90+
// */
91+
// default void forceSync(int entityID, Direction direction, @Nullable Object extra) {
92+
// for (Map.Entry<String, Triple<Type, Consumer<Object>, Supplier<Object>>> entry : this.getSynchableFunctions().entrySet()) {
93+
// this.setSynched(entityID, direction, entry.getKey(), entry.getValue().getRight().get(), extra);
94+
// }
95+
// }
96+
//
97+
// /**
98+
// * @return A {@link Map} of {@link String}s (representing the name of a field), and {@link Triple}s, containing
99+
// * {@link Type}s (representing the data type),
100+
// * {@link Consumer}<{@link Object}>s (representing setter methods), and
101+
// * {@link Supplier}<{@link Object}>s (representing getter methods).
102+
// */
103+
// Map<String, Triple<Type, Consumer<Object>, Supplier<Object>>> getSynchableFunctions();
104+
//
105+
// /**
106+
// * Creates the packet used for syncing.
107+
// *
108+
// * @param key The {@link String} key for the field to sync.
109+
// * @param type The {@link Type} for the field's data type.
110+
// * @param value The {@link Object} value to sync to the field.
111+
// * @return The {@link SyncPacket} for syncing.
112+
// */
113+
// SyncPacket getSyncPacket(int entityID, String key, INBTSynchable.Type type, Object value);
114+
//
115+
// enum Direction {
116+
// SERVER,
117+
// CLIENT,
118+
// NEAR,
119+
// PLAYER,
120+
// DIMENSION
121+
// }
122+
//
123+
// enum Type {
124+
// INT,
125+
// FLOAT,
126+
// DOUBLE,
127+
// BOOLEAN,
128+
// UUID,
129+
// ITEM_STACK,
130+
// COMPOUND_TAG
131+
// }
132+
//}

src/main/java/com/aetherteam/nitrogen/data/NitrogenDataGenerators.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static void onInitializeDataGenerator(GatherDataEvent.Client event) {
2424
// pack.mcmeta
2525
generator.addProvider(true, new PackMetadataGenerator(packOutput).add(PackMetadataSection.TYPE, new PackMetadataSection(
2626
Component.translatable("pack.nitrogen_internals.mod.description"),
27-
DetectedVersion.BUILT_IN.getPackVersion(PackType.SERVER_DATA),
27+
DetectedVersion.BUILT_IN.packVersion(PackType.SERVER_DATA),
2828
Optional.of(new InclusiveRange<>(0, Integer.MAX_VALUE)))));
2929
}
3030
}

src/main/java/com/aetherteam/nitrogen/entity/BossMob.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import net.minecraft.core.HolderLookup;
44
import net.minecraft.nbt.CompoundTag;
55
import net.minecraft.network.chat.Component;
6+
import net.minecraft.network.chat.ComponentSerialization;
67
import net.minecraft.server.level.ServerPlayer;
78
import net.minecraft.world.entity.Mob;
89
import net.minecraft.world.entity.ai.targeting.TargetingConditions;
@@ -83,7 +84,7 @@ default void tearDownRoom() {
8384
BlockState convertBlock(BlockState state);
8485

8586
default void addBossSaveData(CompoundTag tag, HolderLookup.Provider provider) {
86-
tag.putString("BossName", Component.Serializer.toJson(this.getBossName(), provider));
87+
tag.storeNullable("BossName", ComponentSerialization.CODEC, this.getBossName());
8788
tag.putBoolean("BossFight", this.isBossFight());
8889
if (this.getDungeon() != null) {
8990
tag.put("Dungeon", this.getDungeon().addAdditionalSaveData());
@@ -95,10 +96,8 @@ default void readBossSaveData(CompoundTag tag, HolderLookup.Provider provider) {
9596
Optional<Boolean> bossFightOptional = tag.getBoolean("BossFight");
9697

9798
if (bossNameOptional.isPresent()) {
98-
Component name = Component.Serializer.fromJson(bossNameOptional.get(), provider);
99-
if (name != null) {
100-
this.setBossName(name);
101-
}
99+
Optional<Component> name = tag.read("BossName", ComponentSerialization.CODEC);
100+
name.ifPresent(this::setBossName);
102101
}
103102
bossFightOptional.ifPresent(this::setBossFight);
104103
if (tag.contains("Dungeon") && tag.get("Dungeon") instanceof CompoundTag dungeonTag) {

0 commit comments

Comments
 (0)