39
39
import org .spongepowered .api .block .BlockState ;
40
40
import org .spongepowered .api .block .entity .BlockEntity ;
41
41
import org .spongepowered .api .entity .Entity ;
42
+ import org .spongepowered .api .util .Ticks ;
42
43
import org .spongepowered .api .world .biome .Biome ;
43
44
import org .spongepowered .api .world .chunk .Chunk ;
44
45
import org .spongepowered .api .world .volume .stream .StreamOptions ;
45
46
import org .spongepowered .api .world .volume .stream .VolumeStream ;
46
47
import org .spongepowered .asm .mixin .Final ;
48
+ import org .spongepowered .asm .mixin .Implements ;
49
+ import org .spongepowered .asm .mixin .Interface ;
47
50
import org .spongepowered .asm .mixin .Intrinsic ;
48
51
import org .spongepowered .asm .mixin .Mixin ;
49
52
import org .spongepowered .asm .mixin .Shadow ;
50
53
import org .spongepowered .common .accessor .world .level .chunk .ChunkBiomeContainerAccessor ;
54
+ import org .spongepowered .common .util .ChunkUtil ;
55
+ import org .spongepowered .common .util .SpongeTicks ;
51
56
import org .spongepowered .common .world .volume .VolumeStreamUtils ;
52
57
import org .spongepowered .common .world .volume .buffer .biome .ObjectArrayMutableBiomeBuffer ;
53
58
import org .spongepowered .common .world .volume .buffer .block .ArrayMutableBlockBuffer ;
61
66
import java .util .stream .Stream ;
62
67
63
68
@ Mixin (net .minecraft .world .level .chunk .LevelChunk .class )
69
+ @ Implements (@ Interface (iface = Chunk .class , prefix = "chunk$" ))
64
70
public abstract class LevelChunkMixin_API implements Chunk {
65
71
66
72
//@formatter:off
@@ -69,37 +75,22 @@ public abstract class LevelChunkMixin_API implements Chunk {
69
75
@ Shadow @ Final private ChunkPos chunkPos ;
70
76
@ Shadow @ Final private Level level ;
71
77
72
- @ Shadow public abstract void shadow$setInhabitedTime ( long p_177415_1_ );
78
+ @ Shadow public abstract boolean shadow$isEmpty ( );
73
79
//@formatter:on
74
80
75
81
@ Override
76
82
public boolean setBiome (final int x , final int y , final int z , final Biome biome ) {
77
- final net .minecraft .world .level .biome .Biome [] biomes = ((ChunkBiomeContainerAccessor ) this .biomes ).accessor$biomes ();
78
-
79
- int maskedX = x & ChunkBiomeContainer .HORIZONTAL_MASK ;
80
- int maskedY = Mth .clamp (y , 0 , ChunkBiomeContainer .VERTICAL_MASK );
81
- int maskedZ = z & ChunkBiomeContainer .HORIZONTAL_MASK ;
82
-
83
- final int WIDTH_BITS = ChunkBiomeContainerAccessor .accessor$WIDTH_BITS ();
84
- final int posKey = maskedY << WIDTH_BITS + WIDTH_BITS | maskedZ << WIDTH_BITS | maskedX ;
85
- biomes [posKey ] = (net .minecraft .world .level .biome .Biome ) (Object ) biome ;
86
-
87
- return true ;
88
- }
89
-
90
- @ Intrinsic
91
- public long impl$getInhabitedTime () {
92
- return this .inhabitedTime ;
83
+ return ChunkUtil .setBiome (this .biomes , x , y , z , biome );
93
84
}
94
85
95
- @ Intrinsic
96
- public void impl$setInhabitedTime ( long newInhabitedTime ) {
97
- this .shadow$setInhabitedTime ( newInhabitedTime );
86
+ @ Override
87
+ public Ticks inhabitedTime ( ) {
88
+ return new SpongeTicks ( this .inhabitedTime );
98
89
}
99
90
100
91
@ Override
101
- public long inhabitedTime ( ) {
102
- return this .inhabitedTime ;
92
+ public void setInhabitedTime ( final Ticks newInhabitedTime ) {
93
+ this .inhabitedTime = newInhabitedTime . ticks () ;
103
94
}
104
95
105
96
@ Override
@@ -110,23 +101,28 @@ public Vector3i chunkPosition() {
110
101
@ Override
111
102
public double regionalDifficultyFactor () {
112
103
return new DifficultyInstance (this .level .getDifficulty (), this .level .getDayTime (),
113
- this .inhabitedTime (), this .level .getMoonBrightness ()).getEffectiveDifficulty ();
104
+ this .inhabitedTime (). ticks () , this .level .getMoonBrightness ()).getEffectiveDifficulty ();
114
105
}
115
106
116
107
@ Override
117
108
public double regionalDifficultyPercentage () {
118
109
return new DifficultyInstance (this .level .getDifficulty (), this .level .getDayTime (),
119
- this .inhabitedTime (), this .level .getMoonBrightness ()).getSpecialMultiplier ();
110
+ this .inhabitedTime (). ticks () , this .level .getMoonBrightness ()).getSpecialMultiplier ();
120
111
}
121
112
122
113
@ Override
123
114
public org .spongepowered .api .world .World <?, ?> world () {
124
115
return ((org .spongepowered .api .world .World <?, ?>) this .level );
125
116
}
126
117
118
+ @ Intrinsic
119
+ public boolean chunk$isEmpty () {
120
+ return this .shadow$isEmpty ();
121
+ }
122
+
127
123
@ Override
128
124
public VolumeStream <Chunk , Entity > entityStream (
129
- Vector3i min , Vector3i max , StreamOptions options
125
+ final Vector3i min , final Vector3i max , final StreamOptions options
130
126
) {
131
127
VolumeStreamUtils .validateStreamArgs (
132
128
Objects .requireNonNull (min , "min" ), Objects .requireNonNull (max , "max" ),
@@ -165,7 +161,7 @@ public VolumeStream<Chunk, Entity> entityStream(
165
161
166
162
@ Override
167
163
public VolumeStream <Chunk , BlockState > blockStateStream (
168
- Vector3i min , Vector3i max , StreamOptions options
164
+ final Vector3i min , final Vector3i max , final StreamOptions options
169
165
) {
170
166
VolumeStreamUtils .validateStreamArgs (Objects .requireNonNull (min , "min" ), Objects .requireNonNull (max , "max" ),
171
167
Objects .requireNonNull (options , "options" ));
@@ -206,7 +202,7 @@ public VolumeStream<Chunk, BlockState> blockStateStream(
206
202
207
203
@ Override
208
204
public VolumeStream <Chunk , BlockEntity > blockEntityStream (
209
- Vector3i min , Vector3i max , StreamOptions options
205
+ final Vector3i min , final Vector3i max , final StreamOptions options
210
206
) {
211
207
VolumeStreamUtils .validateStreamArgs (Objects .requireNonNull (min , "min" ), Objects .requireNonNull (max , "max" ),
212
208
Objects .requireNonNull (options , "options" ));
@@ -242,13 +238,13 @@ public VolumeStream<Chunk, BlockEntity> blockEntityStream(
242
238
);
243
239
}
244
240
245
- private Stream <Map .Entry <BlockPos , net .minecraft .world .level .block .entity .BlockEntity >> impl$getBlockEntitiesStream (ChunkAccess chunk ) {
241
+ private Stream <Map .Entry <BlockPos , net .minecraft .world .level .block .entity .BlockEntity >> impl$getBlockEntitiesStream (final ChunkAccess chunk ) {
246
242
return chunk instanceof LevelChunk ? ((LevelChunk ) chunk ).getBlockEntities ().entrySet ().stream () : Stream .empty ();
247
243
}
248
244
249
245
@ Override
250
246
public VolumeStream <Chunk , Biome > biomeStream (
251
- Vector3i min , Vector3i max , StreamOptions options
247
+ final Vector3i min , final Vector3i max , final StreamOptions options
252
248
) {
253
249
VolumeStreamUtils .validateStreamArgs (Objects .requireNonNull (min , "min" ), Objects .requireNonNull (max , "max" ),
254
250
Objects .requireNonNull (options , "options" ));
0 commit comments