12
12
import org .spongepowered .asm .mixin .injection .At ;
13
13
import org .spongepowered .asm .mixin .injection .Constant ;
14
14
import org .spongepowered .asm .mixin .injection .ModifyConstant ;
15
- import org .spongepowered .asm .mixin .injection .ModifyVariable ;
16
15
import org .spongepowered .asm .mixin .injection .Redirect ;
17
16
18
17
import com .gtnewhorizons .neid .Constants ;
19
18
import com .gtnewhorizons .neid .mixins .interfaces .IExtendedBlockStorageMixin ;
20
19
import com .llamalad7 .mixinextras .injector .WrapWithCondition ;
21
20
import com .llamalad7 .mixinextras .sugar .Local ;
21
+ import com .llamalad7 .mixinextras .sugar .ref .LocalIntRef ;
22
22
23
23
@ Mixin (Chunk .class )
24
24
public class MixinChunk {
25
25
26
+ private static final byte [] fakeByteArray = new byte [0 ];
27
+ private static final NibbleArray fakeNibbleArray = new NibbleArray (fakeByteArray , 0 );
28
+
26
29
@ Shadow
27
30
private ExtendedBlockStorage [] storageArrays ;
28
31
29
- // TODO: Can we make this not need to return a fake byte array?
30
32
@ Redirect (
31
33
method = "fillChunk" ,
32
34
at = @ At (
33
35
value = "INVOKE" ,
34
36
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockLSBArray()[B" ),
35
37
require = 1 )
36
38
private byte [] neid$injectNewDataCopy (ExtendedBlockStorage ebs , @ Local (ordinal = 0 ) byte [] thebytes ,
37
- @ Local (ordinal = 3 ) int forIndex , @ Local ( ordinal = 2 ) int offset ) {
39
+ @ Local (ordinal = 2 ) LocalIntRef offset ) {
38
40
IExtendedBlockStorageMixin ebsMixin = (IExtendedBlockStorageMixin ) ebs ;
39
41
ShortBuffer .wrap (ebsMixin .getBlock16BArray ())
40
- .put (ByteBuffer .wrap (thebytes , offset , Constants .BLOCKS_PER_EBS * 2 ).asShortBuffer ());
41
- return new byte [0 ];
42
+ .put (ByteBuffer .wrap (thebytes , offset .get (), Constants .BLOCKS_PER_EBS * 2 ).asShortBuffer ());
43
+ offset .set (offset .get () + (Constants .BLOCKS_PER_EBS * 2 ));
44
+ return fakeByteArray ;
42
45
}
43
46
44
- // TODO: Can we make this not need to return a fake NibbleArray?
45
47
@ Redirect (
46
48
method = "fillChunk" ,
47
49
at = @ At (
48
50
value = "INVOKE" ,
49
51
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getMetadataArray()Lnet/minecraft/world/chunk/NibbleArray;" ),
50
52
require = 1 )
51
53
private NibbleArray neid$injectNewMetadataCopy (ExtendedBlockStorage ebs , @ Local (ordinal = 0 ) byte [] thebytes ,
52
- @ Local (ordinal = 3 ) int forIndex , @ Local ( ordinal = 2 ) int offset ) {
54
+ @ Local (ordinal = 2 ) LocalIntRef offset ) {
53
55
IExtendedBlockStorageMixin ebsMixin = (IExtendedBlockStorageMixin ) ebs ;
54
56
ShortBuffer .wrap (ebsMixin .getBlock16BMetaArray ())
55
- .put (ByteBuffer .wrap (thebytes , offset , Constants .BLOCKS_PER_EBS * 2 ).asShortBuffer ());
56
- return new NibbleArray (0 , 0 );
57
+ .put (ByteBuffer .wrap (thebytes , offset .get (), Constants .BLOCKS_PER_EBS * 2 ).asShortBuffer ());
58
+ offset .set (offset .get () + (Constants .BLOCKS_PER_EBS * 2 ));
59
+ return fakeNibbleArray ;
57
60
}
58
61
59
62
@ WrapWithCondition (
@@ -78,16 +81,6 @@ public class MixinChunk {
78
81
return false ;
79
82
}
80
83
81
- @ ModifyVariable (method = "fillChunk" , at = @ At (value = "STORE" , ordinal = 1 ), ordinal = 2 , require = 1 )
82
- private int neid$cancelLSBOffsetIncrement (int i , @ Local (ordinal = 2 ) int old ) {
83
- return old + (Constants .BLOCKS_PER_EBS * 2 );
84
- }
85
-
86
- @ ModifyVariable (method = "fillChunk" , at = @ At (value = "STORE" , ordinal = 2 ), ordinal = 2 , require = 1 )
87
- private int neid$cancelMetaOffsetIncrement (int i , @ Local (ordinal = 2 ) int old ) {
88
- return old + (Constants .BLOCKS_PER_EBS * 2 );
89
- }
90
-
91
84
@ ModifyConstant (method = "fillChunk" , constant = @ Constant (intValue = 0 , ordinal = 10 ), require = 1 )
92
85
private int neid$NukeMSBForLoop (int i ) {
93
86
return this .storageArrays .length + 1 ;
0 commit comments