29
29
import lombok .val ;
30
30
import org .apache .logging .log4j .Level ;
31
31
import org .spongepowered .asm .mixin .Mixin ;
32
- import org .spongepowered .asm .mixin .Overwrite ;
32
+ import org .spongepowered .asm .mixin .injection .At ;
33
+ import org .spongepowered .asm .mixin .injection .Inject ;
34
+ import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
35
+ import org .spongepowered .asm .mixin .injection .callback .CallbackInfoReturnable ;
33
36
34
37
import net .minecraft .block .Block ;
35
38
import net .minecraft .entity .Entity ;
@@ -53,9 +56,13 @@ public abstract class AnvilChunkLoaderMixin {
53
56
*
54
57
* @author FalsePattern
55
58
* @reason Replace functionality
59
+ * @implNote Inject-cancel instead of overwrite for compat with Metaworlds-Mixins
56
60
*/
57
- @ Overwrite
58
- private void writeChunkToNBT (Chunk chunk , World world , NBTTagCompound nbt ) {
61
+ @ Inject (method = "writeChunkToNBT" ,
62
+ at = @ At ("HEAD" ),
63
+ cancellable = true ,
64
+ require = 1 )
65
+ private void writeChunkToNBT (Chunk chunk , World world , NBTTagCompound nbt , CallbackInfo ci ) {
59
66
nbt .setByte ("V" , (byte ) 1 );
60
67
nbt .setInteger ("xPos" , chunk .xPosition );
61
68
nbt .setInteger ("zPos" , chunk .zPosition );
@@ -65,6 +72,7 @@ private void writeChunkToNBT(Chunk chunk, World world, NBTTagCompound nbt) {
65
72
writeSubChunks (chunk , nbt );
66
73
writeCustomData (chunk , nbt );
67
74
writeEntities (chunk , world , nbt );
75
+ ci .cancel ();
68
76
}
69
77
70
78
/**
@@ -73,9 +81,13 @@ private void writeChunkToNBT(Chunk chunk, World world, NBTTagCompound nbt) {
73
81
*
74
82
* @author FalsePattern
75
83
* @reason Replace functionality
84
+ * @implNote Inject-cancel instead of overwrite for compat with Metaworlds-Mixins
76
85
*/
77
- @ Overwrite
78
- private Chunk readChunkFromNBT (World world , NBTTagCompound nbt ) {
86
+ @ Inject (method = "readChunkFromNBT" ,
87
+ at = @ At ("HEAD" ),
88
+ cancellable = true ,
89
+ require = 1 )
90
+ private void readChunkFromNBT (World world , NBTTagCompound nbt , CallbackInfoReturnable <Chunk > cir ) {
79
91
int x = nbt .getInteger ("xPos" );
80
92
int z = nbt .getInteger ("zPos" );
81
93
Chunk chunk = new Chunk (world , x , z );
@@ -85,7 +97,7 @@ private Chunk readChunkFromNBT(World world, NBTTagCompound nbt) {
85
97
readCustomData (chunk , nbt );
86
98
87
99
// End this method here and split off entity loading to another method
88
- return chunk ;
100
+ cir . setReturnValue ( chunk ) ;
89
101
}
90
102
91
103
private void readCustomData (Chunk chunk , NBTTagCompound nbt ) {
0 commit comments