1- package net .errorcraft .codecium .mixin .minecraft .registry . entry ;
1+ package net .errorcraft .codecium .mixin .minecraft .resources ;
22
33import com .llamalad7 .mixinextras .sugar .Local ;
44import com .mojang .datafixers .util .Pair ;
55import com .mojang .serialization .DataResult ;
66import com .mojang .serialization .DynamicOps ;
7- import net .minecraft .registry . Registry ;
8- import net .minecraft .registry . RegistryKey ;
9- import net .minecraft .registry . entry . RegistryEntry ;
10- import net .minecraft .registry . entry . RegistryEntryList ;
11- import net .minecraft .registry . entry . RegistryEntryListCodec ;
12- import net .minecraft .registry . tag .TagKey ;
7+ import net .minecraft .core . Holder ;
8+ import net .minecraft .core . HolderSet ;
9+ import net .minecraft .core . Registry ;
10+ import net .minecraft .resources . HolderSetCodec ;
11+ import net .minecraft .resources . ResourceKey ;
12+ import net .minecraft .tags .TagKey ;
1313import org .spongepowered .asm .mixin .Final ;
1414import org .spongepowered .asm .mixin .Mixin ;
1515import org .spongepowered .asm .mixin .Shadow ;
2121
2222import java .util .function .Supplier ;
2323
24- @ Mixin (RegistryEntryListCodec .class )
25- public class RegistryEntryListCodecExtender <E > {
24+ @ Mixin (HolderSetCodec .class )
25+ public class HolderSetCodecExtender <E > {
2626 @ Shadow
2727 @ Final
28- private RegistryKey <? extends Registry <E >> registry ;
28+ private ResourceKey <? extends Registry <E >> registryKey ;
2929
3030 @ Unique
31- private static RegistryKey <? extends Registry <?>> tempRegistryKey ;
31+ private static ResourceKey <? extends Registry <?>> tempRegistryKey ;
3232
3333 @ ModifyArg (
3434 method = "method_58027" ,
@@ -39,27 +39,27 @@ public class RegistryEntryListCodecExtender<E> {
3939 )
4040 )
4141 private static <E > Supplier <String > unknownRegistryTagUseBetterErrorMessage (Supplier <String > message , @ Local (argsOnly = true ) TagKey <E > tag ) {
42- return () -> "Cannot get a registry tag with id " + tag .id ();
42+ return () -> "Cannot get a registry tag with id " + tag .location ();
4343 }
4444
4545 @ ModifyArg (
46- method = "encode(Lnet/minecraft/registry/entry/RegistryEntryList ;Lcom/mojang/serialization/DynamicOps;Ljava/lang/Object;)Lcom/mojang/serialization/DataResult;" ,
46+ method = "encode(Lnet/minecraft/core/HolderSet ;Lcom/mojang/serialization/DynamicOps;Ljava/lang/Object;)Lcom/mojang/serialization/DataResult;" ,
4747 at = @ At (
4848 value = "INVOKE" ,
4949 target = "Lcom/mojang/serialization/DataResult;error(Ljava/util/function/Supplier;)Lcom/mojang/serialization/DataResult;" ,
5050 remap = false
5151 )
5252 )
53- private Supplier <String > invalidOwnerUseBetterErrorMessage (Supplier <String > message , @ Local (argsOnly = true ) RegistryEntryList <E > registryEntries ) {
54- return () -> "Registry tag " + registryEntries .getTagKey ().orElseThrow ().id () + " is not part of the current registry set" ;
53+ private Supplier <String > invalidOwnerUseBetterErrorMessage (Supplier <String > message , @ Local (argsOnly = true ) HolderSet <E > registryEntries ) {
54+ return () -> "Registry tag " + registryEntries .unwrapKey ().orElseThrow ().location () + " is not part of the current registry set" ;
5555 }
5656
5757 @ Inject (
58- method = "decodeDirect " ,
58+ method = "decodeWithoutRegistry " ,
5959 at = @ At ("HEAD" )
6060 )
61- private <T > void storeTemporaryRegistryKey (DynamicOps <T > ops , T input , CallbackInfoReturnable <DataResult <Pair <RegistryEntryList <E >, T >>> info ) {
62- RegistryEntryListCodecExtender .tempRegistryKey = this .registry ;
61+ private <T > void storeTemporaryRegistryKey (DynamicOps <T > ops , T input , CallbackInfoReturnable <DataResult <Pair <HolderSet <E >, T >>> info ) {
62+ HolderSetCodecExtender .tempRegistryKey = this .registryKey ;
6363 }
6464
6565 @ ModifyArg (
@@ -70,15 +70,15 @@ private <T> void storeTemporaryRegistryKey(DynamicOps<T> ops, T input, CallbackI
7070 remap = false
7171 )
7272 )
73- private static <R > Supplier <String > inaccessibleRegistryUseBetterErrorMessage (Supplier <String > message , @ Local RegistryEntry <R > entry ) {
74- return () -> "Registry " + RegistryEntryListCodecExtender .tempRegistryKey .getValue () + " is inaccessible for " + entry .getKey ().orElseThrow ();
73+ private static <R > Supplier <String > inaccessibleRegistryUseBetterErrorMessage (Supplier <String > message , @ Local Holder <R > entry ) {
74+ return () -> "Registry " + HolderSetCodecExtender .tempRegistryKey .location () + " is inaccessible for " + entry .unwrapKey ().orElseThrow ();
7575 }
7676
7777 @ Inject (
78- method = "decodeDirect " ,
78+ method = "decodeWithoutRegistry " ,
7979 at = @ At ("TAIL" )
8080 )
81- private <T > void removeTemporaryRegistryKey (DynamicOps <T > ops , T input , CallbackInfoReturnable <DataResult <Pair <RegistryEntryList <E >, T >>> info ) {
82- RegistryEntryListCodecExtender .tempRegistryKey = null ;
81+ private <T > void removeTemporaryRegistryKey (DynamicOps <T > ops , T input , CallbackInfoReturnable <DataResult <Pair <HolderSet <E >, T >>> info ) {
82+ HolderSetCodecExtender .tempRegistryKey = null ;
8383 }
8484}
0 commit comments