Class RegistryCodecTest

java.lang.Object
net.neoforged.neoforge.oldtest.misc.RegistryCodecTest

public class RegistryCodecTest extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    private static final com.mojang.serialization.Codec<com.mojang.datafixers.util.Pair<Block,Item>>
    This Codec can serialize and deserialize a Pair<Item, Block>.
    private static final org.apache.logging.log4j.Logger
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    RegistryCodecTest(net.neoforged.bus.api.IEventBus modEventBus)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    commonSetup(net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent event)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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>> CODEC
      This Codec can serialize and deserialize a Pair<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)