Skip to content

Commit 9dc5395

Browse files
committed
1.0.1
1 parent 2de5022 commit 9dc5395

File tree

3 files changed

+38
-21
lines changed

3 files changed

+38
-21
lines changed

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<groupId>cn.wode490390.nukkit</groupId>
88
<artifactId>singletspop</artifactId>
99
<packaging>jar</packaging>
10-
<version>1.0.0</version>
10+
<version>1.0.1</version>
1111
<name>Single Template Structure Populator</name>
1212
<description>Single-template structure populator plugin for Nukkit</description>
1313
<url>http://wode490390.cn/</url>
@@ -54,7 +54,7 @@
5454
<repositories>
5555
<repository>
5656
<id>nukkitx-repo</id>
57-
<url>http://repo.nukkitx.com/main/</url>
57+
<url>https://repo.nukkitx.com/main/</url>
5858
</repository>
5959
</repositories>
6060

src/main/java/cn/wode490390/nukkit/singletspop/populator/PopulatorFossil.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class PopulatorFossil extends Populator {
3636

3737
@Override
3838
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random, FullChunk chunk) {
39-
int biome = chunk.getBiomeId(0, 0);
39+
int biome = chunk.getBiomeId(3, 3);
4040
if ((biome == EnumBiome.DESERT.id || biome == EnumBiome.DESERT_HILLS.id || biome == EnumBiome.DESERT_M.id
4141
|| biome == EnumBiome.SWAMP.id || biome == EnumBiome.SWAMPLAND_M.id)
4242
&& random.nextBoundedInt(64) == (0x1211dfa1 & 63)) { //salted

src/main/java/cn/wode490390/nukkit/singletspop/populator/PopulatorShipwreck.java

+35-18
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,17 @@ public class PopulatorShipwreck extends Populator implements CallbackableTemplat
9494

9595
@Override
9696
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random, FullChunk chunk) {
97-
int biome = chunk.getBiomeId(0, 0);
97+
int biome = chunk.getBiomeId(5, 5);
9898
if ((biome == EnumBiome.OCEAN.id || biome == EnumBiome.DEEP_OCEAN.id || biome == EnumBiome.FROZEN_OCEAN.id
9999
|| biome == EnumBiome.BEACH.id || (biome >= 44 && biome <= 50))
100100
&& chunkX == (((chunkX < 0 ? (chunkX - SPACING + 1) : chunkX) / SPACING) * SPACING) + random.nextBoundedInt(SPACING - SEPARATION)
101101
&& chunkZ == (((chunkZ < 0 ? (chunkZ - SPACING + 1) : chunkZ) / SPACING) * SPACING) + random.nextBoundedInt(SPACING - SEPARATION)) {
102102
ReadableStructureTemplate template;
103-
boolean isBeached;
104103

105104
if (biome == EnumBiome.BEACH.id) {
106105
template = STRUCTURE_LOCATION_BEACHED[random.nextBoundedInt(STRUCTURE_LOCATION_BEACHED.length)];
107-
isBeached = true;
108106
} else {
109107
template = STRUCTURE_LOCATION_OCEAN[random.nextBoundedInt(STRUCTURE_LOCATION_OCEAN.length)];
110-
isBeached = false;
111108
}
112109

113110
BlockVector3 size = template.getSize();
@@ -118,13 +115,9 @@ public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom ra
118115
for (int z = 0; z < size.getZ() && z < 16; z++) {
119116
int y = chunk.getHighestBlockAt(x, z);
120117

121-
if (!isBeached) {
122-
y = Math.min(64, y);
123-
124-
int id = chunk.getBlockId(x, y, z);
125-
while ((id == WATER || id == STILL_WATER) && y > 0) {
126-
id = level.getBlockIdAt(x, --y, z);
127-
}
118+
int id = chunk.getBlockId(x, y, z);
119+
while (FILTER[id] && y > 0) {
120+
id = chunk.getBlockId(x, --y, z);
128121
}
129122

130123
sumY += y;
@@ -133,9 +126,6 @@ public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom ra
133126
}
134127

135128
int y = sumY / blockCount;
136-
if (!isBeached) {
137-
y = Math.min(64, y);
138-
}
139129

140130
int seed = random.nextInt();
141131
boolean isLarge = false;
@@ -163,13 +153,11 @@ public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom ra
163153
}
164154

165155
if (!chunks.isEmpty()) {
166-
int definiteY = y;
167-
168156
this.waitingChunks.put(Level.chunkHash(chunkX, chunkZ), indexes);
169157
for (BaseFullChunk ck : chunks) {
170158
Server.getInstance().getScheduler().scheduleAsyncTask(null, new CallbackableChunkGenerationTask(
171159
chunk.getProvider().getLevel(), ck, this,
172-
populator -> populator.generateChunkCallback(template, seed, level, chunkX, chunkZ, definiteY, ck.getX(), ck.getZ())));
160+
populator -> populator.generateChunkCallback(template, seed, level, chunkX, chunkZ, y, ck.getX(), ck.getZ())));
173161
}
174162
return;
175163
}
@@ -237,7 +225,36 @@ protected static Consumer<CompoundTag> getBlockActorProcessor(FullChunk chunk, N
237225
};
238226
}
239227

228+
public static final boolean[] FILTER = new boolean[256];
229+
240230
public static void init() {
241-
//NOOP
231+
FILTER[AIR] = true;
232+
FILTER[LOG] = true;
233+
FILTER[WATER] = true;
234+
FILTER[STILL_WATER] = true;
235+
FILTER[LAVA] = true;
236+
FILTER[STILL_LAVA] = true;
237+
FILTER[LEAVES] = true;
238+
FILTER[TALL_GRASS] = true;
239+
FILTER[DEAD_BUSH] = true;
240+
FILTER[DANDELION] = true;
241+
FILTER[RED_FLOWER] = true;
242+
FILTER[BROWN_MUSHROOM] = true;
243+
FILTER[RED_MUSHROOM] = true;
244+
FILTER[SNOW_LAYER] = true;
245+
FILTER[ICE] = true;
246+
FILTER[CACTUS] = true;
247+
FILTER[REEDS] = true;
248+
FILTER[PUMPKIN] = true;
249+
FILTER[BROWN_MUSHROOM_BLOCK] = true;
250+
FILTER[RED_MUSHROOM_BLOCK] = true;
251+
FILTER[MELON_BLOCK] = true;
252+
FILTER[VINE] = true;
253+
FILTER[WATER_LILY] = true;
254+
FILTER[COCOA] = true;
255+
FILTER[LEAVES2] = true;
256+
FILTER[LOG2] = true;
257+
FILTER[PACKED_ICE] = true;
258+
FILTER[DOUBLE_PLANT] = true;
242259
}
243260
}

0 commit comments

Comments
 (0)