mirror of
https://github.com/BentoBoxWorld/Boxed.git
synced 2025-01-06 18:47:52 +01:00
Code cleanup. Remove debug.
This commit is contained in:
parent
1a8c97b38b
commit
52b1ae4056
@ -3,6 +3,7 @@ package world.bentobox.boxed;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
@ -149,17 +150,11 @@ public class Boxed extends GameModeAddon {
|
||||
.generateStructures(false)
|
||||
.seed(getSettings().getSeed())
|
||||
.createWorld();
|
||||
seedWorld.setDifficulty(Difficulty.PEACEFUL); // No damage wanted in this world.
|
||||
saveChunks(seedWorld);
|
||||
|
||||
|
||||
String worldName = settings.getWorldName().toLowerCase();
|
||||
/*
|
||||
if (getServer().getWorld(worldName) == null) {
|
||||
log("Creating Boxed Seed world ...");
|
||||
}
|
||||
seedWorld = WorldCreator.name(worldName + "_bak").seed(settings.getSeed()).createWorld();
|
||||
seedWorld.setDifficulty(Difficulty.PEACEFUL); // No damage wanted in this world.
|
||||
*/
|
||||
|
||||
if (getServer().getWorld(worldName) == null) {
|
||||
log("Creating Boxed world ...");
|
||||
}
|
||||
|
@ -1,12 +1,7 @@
|
||||
package world.bentobox.boxed;
|
||||
|
||||
import org.bukkit.generator.BiomeProvider;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
import world.bentobox.bentobox.api.addons.Addon;
|
||||
import world.bentobox.bentobox.api.addons.Pladdon;
|
||||
import world.bentobox.boxed.generators.SimpleBiomeProvider;
|
||||
|
||||
public class BoxedPladdon extends Pladdon {
|
||||
|
||||
@ -15,8 +10,4 @@ public class BoxedPladdon extends Pladdon {
|
||||
return new Boxed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeProvider getDefaultBiomeProvider(@NonNull String worldName, @Nullable String id) {
|
||||
return new SimpleBiomeProvider();
|
||||
}
|
||||
}
|
||||
|
@ -1,40 +0,0 @@
|
||||
package world.bentobox.boxed;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
|
||||
/**
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class DebugListener implements Listener {
|
||||
|
||||
private final Boxed addon;
|
||||
private int size;
|
||||
|
||||
/**
|
||||
* @param addon
|
||||
*/
|
||||
public DebugListener(Boxed addon) {
|
||||
this.addon = addon;
|
||||
this.size = addon.getSettings().getIslandDistance();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onMove(PlayerMoveEvent e) {
|
||||
if (e.getTo().getBlockX() != e.getFrom().getBlockX() || e.getTo().getBlockZ() != e.getFrom().getBlockZ()) {
|
||||
int chunkX = e.getTo().getChunk().getX();
|
||||
int chunkZ = e.getTo().getChunk().getZ();
|
||||
int xx = Math.floorMod(chunkX, size);
|
||||
int zz = Math.floorMod(chunkZ, size);
|
||||
BentoBox.getInstance().logDebug("x = " + e.getTo().getBlockX() + " z = " + e.getTo().getBlockZ());
|
||||
BentoBox.getInstance().logDebug("ChunkX = " + chunkX + " ChunkZ = " + chunkZ);
|
||||
BentoBox.getInstance().logDebug("CalcChunk X = " + xx + " Calc ChunkZ = " + zz + " should loop");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
package world.bentobox.boxed.generators;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BiomeProvider;
|
||||
import org.bukkit.generator.WorldInfo;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.boxed.Boxed;
|
||||
|
||||
/**
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class BoxedBiomeProvider extends BiomeProvider {
|
||||
|
||||
private final Boxed addon;
|
||||
|
||||
public BoxedBiomeProvider(Boxed boxed) {
|
||||
addon = boxed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiome(WorldInfo worldInfo, int x, int y, int z) {
|
||||
if (!worldInfo.getName().equals(addon.getSettings().getWorldName())) {
|
||||
BentoBox.getInstance().logDebug("Wrong world biome ask.");
|
||||
return Biome.OLD_GROWTH_SPRUCE_TAIGA;
|
||||
}
|
||||
int chunkX = (int)((double)x/16);
|
||||
int chunkZ = (int)((double)z/16);
|
||||
ChunkSnapshot c = addon.getChunkGenerator().getChunk(chunkX, chunkZ);
|
||||
if (c == null) {
|
||||
//BentoBox.getInstance().logDebug("No chunk snapshot for " + (int)((double)x/16) + "," + (int)((double)z/16));
|
||||
return Biome.OLD_GROWTH_SPRUCE_TAIGA;
|
||||
}
|
||||
int xx = Math.floorMod(x, 16);
|
||||
int zz = Math.floorMod(z, 16);
|
||||
int yy = Math.max(Math.min(y * 4, worldInfo.getMaxHeight()), worldInfo.getMinHeight()); // To handle bug in Spigot
|
||||
Biome b = c.getBiome(xx, yy, zz);
|
||||
if (b != Biome.CUSTOM) {
|
||||
/*
|
||||
if (chunkX == 0 && chunkZ == 0) {
|
||||
BentoBox.getInstance().logDebug("Chunk thinks its coords are x=" + c.getX() + " z=" + c.getZ());
|
||||
BentoBox.getInstance().logDebug("World min = " + worldInfo.getMinHeight() + " world max = " + worldInfo.getMaxHeight());
|
||||
BentoBox.getInstance().logDebug("Biome found and coord = " + b + " " + x + "," + y + "," + z);
|
||||
BentoBox.getInstance().logDebug("Chunk = " + chunkX + "," + chunkZ);
|
||||
BentoBox.getInstance().logDebug("Pos in chunk " + xx + "," + yy + "," + zz);
|
||||
}
|
||||
*/
|
||||
return b;
|
||||
} else {
|
||||
return Biome.OLD_GROWTH_BIRCH_FOREST;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Biome> getBiomes(WorldInfo worldInfo) {
|
||||
// Return all of them for now!
|
||||
return Arrays.stream(Biome.values()).filter(b -> !b.equals(Biome.CUSTOM)).toList();
|
||||
//return overWorld.getBiomeProvider().getBiomes(overWorld);
|
||||
}
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package world.bentobox.boxed.generators;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BiomeProvider;
|
||||
import org.bukkit.generator.WorldInfo;
|
||||
import org.bukkit.util.noise.SimplexOctaveGenerator;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class SimpleBiomeProvider extends BiomeProvider {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Biome getBiome(@NonNull WorldInfo worldInfo, int x, int y, int z) {
|
||||
SimplexOctaveGenerator generator = new SimplexOctaveGenerator(new Random(worldInfo.getSeed()), 6);
|
||||
generator.setScale(0.01);
|
||||
|
||||
|
||||
if (generator.noise(x, z, 1, 1, true) < 0) {
|
||||
return Biome.OCEAN;
|
||||
} else {
|
||||
return Biome.DESERT;
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public List<Biome> getBiomes(@NonNull WorldInfo worldInfo) {
|
||||
return Lists.newArrayList(Biome.OCEAN, Biome.DESERT);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user