mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-18 10:32:30 +00:00
parent
7ce789d570
commit
3dd08f30a7
Binary file not shown.
@ -6,6 +6,7 @@ import com.dfsek.terra.config.base.ConfigUtil;
|
|||||||
import com.dfsek.terra.config.base.WorldConfig;
|
import com.dfsek.terra.config.base.WorldConfig;
|
||||||
import com.dfsek.terra.config.lang.LangUtil;
|
import com.dfsek.terra.config.lang.LangUtil;
|
||||||
import com.dfsek.terra.generation.TerraChunkGenerator;
|
import com.dfsek.terra.generation.TerraChunkGenerator;
|
||||||
|
import com.dfsek.terra.util.PaperUtil;
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
@ -15,7 +16,6 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.polydev.gaea.GaeaPlugin;
|
import org.polydev.gaea.GaeaPlugin;
|
||||||
import org.polydev.gaea.generation.GaeaChunkGenerator;
|
import org.polydev.gaea.generation.GaeaChunkGenerator;
|
||||||
import org.polydev.gaea.lang.Language;
|
import org.polydev.gaea.lang.Language;
|
||||||
import org.polydev.gaea.util.PaperUtil;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -44,7 +44,6 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ import org.polydev.gaea.world.Flora;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populates Flora and Trees
|
* Populates Flora and Trees
|
||||||
@ -63,22 +62,22 @@ public class FloraPopulator extends GaeaBlockPopulator {
|
|||||||
|
|
||||||
@SuppressWarnings("try")
|
@SuppressWarnings("try")
|
||||||
@Override
|
@Override
|
||||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull CompletableFuture<Chunk> futureChunk, int chunkX, int chunkZ) {
|
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||||
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("FloraTime")) {
|
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("FloraTime")) {
|
||||||
TerraWorld tw = TerraWorld.getWorld(world);
|
TerraWorld tw = TerraWorld.getWorld(world);
|
||||||
if(!tw.isSafe()) return;
|
if(!tw.isSafe()) return;
|
||||||
|
int originX = chunk.getX() << 4;
|
||||||
|
int originZ = chunk.getZ() << 4;
|
||||||
TerraBiomeGrid grid = tw.getGrid();
|
TerraBiomeGrid grid = tw.getGrid();
|
||||||
int originX = chunkX << 4;
|
|
||||||
int originZ = chunkZ << 4;
|
|
||||||
for(int x = 0; x < 16; x++) {
|
for(int x = 0; x < 16; x++) {
|
||||||
for(int z = 0; z < 16; z++) {
|
for(int z = 0; z < 16; z++) {
|
||||||
UserDefinedBiome biome = (UserDefinedBiome) grid.getBiome((chunkX << 4) + x, (chunkZ << 4) + z, GenerationPhase.POPULATE);
|
UserDefinedBiome biome = (UserDefinedBiome) grid.getBiome((chunk.getX() << 4) + x, (chunk.getZ() << 4) + z, GenerationPhase.POPULATE);
|
||||||
if((x & 1) == 0 && (z & 1) == 0) {
|
if((x & 1) == 0 && (z & 1) == 0) {
|
||||||
int treeChance = biome.getDecorator().getTreeDensity();
|
int treeChance = biome.getDecorator().getTreeDensity();
|
||||||
if(random.nextInt(1000) < treeChance) {
|
if(random.nextInt(1000) < treeChance) {
|
||||||
int xt = offset(random, x);
|
int xt = offset(random, x);
|
||||||
int zt = offset(random, z);
|
int zt = offset(random, z);
|
||||||
if(doTrees(biome, tw, random, futureChunk.join(), xt, zt)) continue;
|
if(doTrees(biome, tw, random, chunk, xt, zt)) continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(biome.getDecorator().getFloraChance() <= 0) continue;
|
if(biome.getDecorator().getFloraChance() <= 0) continue;
|
||||||
@ -90,7 +89,7 @@ public class FloraPopulator extends GaeaBlockPopulator {
|
|||||||
if(f.isFloraSimplex())
|
if(f.isFloraSimplex())
|
||||||
item = biome.getDecorator().getFlora().get(f.getFloraNoise(), originX + x, originZ + z);
|
item = biome.getDecorator().getFlora().get(f.getFloraNoise(), originX + x, originZ + z);
|
||||||
else item = biome.getDecorator().getFlora().get(random);
|
else item = biome.getDecorator().getFlora().get(random);
|
||||||
for(Block highest : item.getValidSpawnsAt(futureChunk.join(), x, z, c.getFloraHeights(item))) {
|
for(Block highest : item.getValidSpawnsAt(chunk, x, z, c.getFloraHeights(item))) {
|
||||||
if(random.nextInt(100) < biome.getDecorator().getFloraChance())
|
if(random.nextInt(100) < biome.getDecorator().getFloraChance())
|
||||||
item.plant(highest.getLocation());
|
item.plant(highest.getLocation());
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ import org.polydev.gaea.profiler.ProfileFuture;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
public class SnowPopulator extends GaeaBlockPopulator {
|
public class SnowPopulator extends GaeaBlockPopulator {
|
||||||
private static final Set<Material> blacklistSpawn = new HashSet<>();
|
private static final Set<Material> blacklistSpawn = new HashSet<>();
|
||||||
@ -47,10 +46,10 @@ public class SnowPopulator extends GaeaBlockPopulator {
|
|||||||
|
|
||||||
@SuppressWarnings("try")
|
@SuppressWarnings("try")
|
||||||
@Override
|
@Override
|
||||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull CompletableFuture<Chunk> futureChunk, int chunkX, int chunkZ) {
|
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||||
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("SnowTime")) {
|
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("SnowTime")) {
|
||||||
int origX = chunkX << 4;
|
int origX = chunk.getX() << 4;
|
||||||
int origZ = chunkZ << 4;
|
int origZ = chunk.getZ() << 4;
|
||||||
TerraWorld w = TerraWorld.getWorld(world);
|
TerraWorld w = TerraWorld.getWorld(world);
|
||||||
if(!w.isSafe()) return;
|
if(!w.isSafe()) return;
|
||||||
TerraBiomeGrid g = w.getGrid();
|
TerraBiomeGrid g = w.getGrid();
|
||||||
@ -61,13 +60,13 @@ public class SnowPopulator extends GaeaBlockPopulator {
|
|||||||
int y;
|
int y;
|
||||||
Block b = null;
|
Block b = null;
|
||||||
for(y = 254; y > 0; y--) {
|
for(y = 254; y > 0; y--) {
|
||||||
b = futureChunk.join().getBlock(x, y, z);
|
b = chunk.getBlock(x, y, z);
|
||||||
if(!b.getType().isAir()) break;
|
if(!b.getType().isAir()) break;
|
||||||
}
|
}
|
||||||
if(random.nextInt(100) >= biome.getSnow().getSnowChance(y))
|
if(random.nextInt(100) >= biome.getSnow().getSnowChance(y))
|
||||||
continue;
|
continue;
|
||||||
if(blacklistSpawn.contains(b.getType()) || b.isPassable()) continue;
|
if(blacklistSpawn.contains(b.getType()) || b.isPassable()) continue;
|
||||||
futureChunk.join().getBlock(x, ++y, z).setBlockData(DataUtil.SNOW, biome.getSnow().doPhysics());
|
chunk.getBlock(x, ++y, z).setBlockData(DataUtil.SNOW, biome.getSnow().doPhysics());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
17
src/main/java/com/dfsek/terra/util/PaperUtil.java
Normal file
17
src/main/java/com/dfsek/terra/util/PaperUtil.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package com.dfsek.terra.util;
|
||||||
|
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import static io.papermc.lib.PaperLib.suggestPaper;
|
||||||
|
|
||||||
|
public final class PaperUtil {
|
||||||
|
public static void checkPaper(JavaPlugin main) {
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(main, () -> {
|
||||||
|
if(!PaperLib.isPaper()) {
|
||||||
|
suggestPaper(main);
|
||||||
|
}
|
||||||
|
}, 100L);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user