Class RegistryCodecTest
java.lang.Object
net.neoforged.neoforge.oldtest.misc.RegistryCodecTest
This test mod show a few example usages of
Registry.byNameCodec()
to serialize and deserialize registry entries to JSON or NBT.
There are 4 tested cases :
1. json -> Pair
2. Pair -> nbt
3. Pair -> compressed json
4. compressed json -> Pair
For each test the result will be logged.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
commonSetup
(net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent event)
-
Field Details
-
LOGGER
private static final org.apache.logging.log4j.Logger LOGGER -
CODEC
private static final com.mojang.serialization.Codec<com.mojang.datafixers.util.Pair<Block,Item>> CODECThis Codec can serialize and deserialize aPair<Item, Block>
. The resulting JSON (or NBT equivalent) will have this structure:{ "block": "block_registry_name", "item": "item_registry_name" }
-
-
Constructor Details
-
RegistryCodecTest
public RegistryCodecTest(net.neoforged.bus.api.IEventBus modEventBus)
-
-
Method Details
-
commonSetup
public void commonSetup(net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent event)
-