it compiles now B)

This commit is contained in:
dfsek
2020-12-10 21:35:14 -07:00
parent dbf4b4dd3b
commit 3e04dc6b46
63 changed files with 293 additions and 262 deletions

View File

@@ -1,7 +1,8 @@
package com.dfsek.terra.api.bukkit;
import com.dfsek.terra.api.bukkit.world.BukkitBiome;
import com.dfsek.terra.api.generic.world.Biome;
import com.dfsek.terra.api.generic.world.BiomeGrid;
import org.bukkit.block.Biome;
import org.bukkit.generator.ChunkGenerator;
import org.jetbrains.annotations.NotNull;
@@ -19,21 +20,21 @@ public class BukkitBiomeGrid implements BiomeGrid {
@Override
public @NotNull Biome getBiome(int x, int z) {
return delegate.getBiome(x, z);
return new BukkitBiome(delegate.getBiome(x, z));
}
@Override
public @NotNull Biome getBiome(int x, int y, int z) {
return delegate.getBiome(x, y, z);
return new BukkitBiome(delegate.getBiome(x, y, z));
}
@Override
public void setBiome(int x, int z, @NotNull Biome bio) {
delegate.setBiome(x, z, bio);
delegate.setBiome(x, z, ((BukkitBiome) bio).getHandle());
}
@Override
public void setBiome(int x, int y, int z, @NotNull Biome bio) {
delegate.setBiome(x, y, z, bio);
delegate.setBiome(x, y, z, ((BukkitBiome) bio).getHandle());
}
}

View File

@@ -1,7 +1,9 @@
package com.dfsek.terra.api.bukkit;
import com.dfsek.terra.api.bukkit.world.block.BukkitBlock;
import com.dfsek.terra.api.generic.world.Chunk;
import com.dfsek.terra.api.generic.world.World;
import com.dfsek.terra.api.generic.world.block.Block;
public class BukkitChunk implements Chunk {
private final org.bukkit.Chunk delegate;
@@ -25,6 +27,11 @@ public class BukkitChunk implements Chunk {
return new BukkitWorld(delegate.getWorld());
}
@Override
public Block getBlock(int x, int y, int z) {
return new BukkitBlock(delegate.getBlock(x, y, z));
}
@Override
public org.bukkit.Chunk getHandle() {
return delegate;

View File

@@ -7,6 +7,9 @@ import com.dfsek.terra.api.generic.world.Chunk;
import com.dfsek.terra.api.generic.world.World;
import com.dfsek.terra.api.generic.world.block.Block;
import com.dfsek.terra.api.generic.world.vector.Location;
import org.bukkit.TreeType;
import org.bukkit.entity.Entity;
import org.bukkit.util.Consumer;
import java.io.File;
import java.util.UUID;
@@ -68,6 +71,16 @@ public class BukkitWorld implements World {
return new BukkitBlock(delegate.getBlockAt(l.getBlockX(), l.getBlockY(), l.getBlockZ()));
}
@Override
public boolean generateTree(Location l, TreeType vanillaTreeType) {
return delegate.generateTree(new org.bukkit.Location(((BukkitWorld) l.getWorld()).getHandle(), l.getX(), l.getY(), l.getZ()), vanillaTreeType);
}
@Override
public void spawn(Location l, Class<Entity> entity, Consumer<Entity> consumer) {
delegate.spawn(new org.bukkit.Location(((BukkitWorld) l.getWorld()).getHandle(), l.getX(), l.getY(), l.getZ()), entity, consumer);
}
@Override
public org.bukkit.World getHandle() {
return delegate;

View File

@@ -5,28 +5,28 @@ import com.dfsek.terra.api.bukkit.world.block.BukkitMaterialData;
import com.dfsek.terra.api.bukkit.world.block.data.BukkitStairs;
import com.dfsek.terra.api.bukkit.world.block.data.BukkitWaterlogged;
import com.dfsek.terra.api.generic.world.WorldHandle;
import com.dfsek.terra.api.generic.world.block.Block;
import com.dfsek.terra.api.generic.world.block.BlockData;
import com.dfsek.terra.api.generic.world.block.MaterialData;
import com.dfsek.terra.api.generic.world.block.data.Waterlogged;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.type.Stairs;
public class BukkitWorldHandle implements WorldHandle {
@Override
public void setBlockData(Block block, org.bukkit.block.data.BlockData data, boolean physics) {
public void setBlockData(Block block, BlockData data, boolean physics) {
block.setBlockData(data, physics);
}
@Override
public org.bukkit.block.data.BlockData getBlockData(Block block) {
public BlockData getBlockData(Block block) {
return block.getBlockData();
}
@Override
public Material getType(Block block) {
public MaterialData getType(Block block) {
return block.getType();
}

View File

@@ -1,7 +1,12 @@
package com.dfsek.terra.api.bukkit.world.block;
import com.dfsek.terra.api.bukkit.BukkitWorld;
import com.dfsek.terra.api.bukkit.world.block.data.BukkitEnumAdapter;
import com.dfsek.terra.api.generic.world.block.Block;
import com.dfsek.terra.api.generic.world.block.BlockData;
import com.dfsek.terra.api.generic.world.block.BlockFace;
import com.dfsek.terra.api.generic.world.block.MaterialData;
import com.dfsek.terra.api.generic.world.vector.Location;
public class BukkitBlock implements Block {
private final org.bukkit.block.Block delegate;
@@ -20,6 +25,51 @@ public class BukkitBlock implements Block {
return new BukkitBlockData(delegate.getBlockData());
}
@Override
public Block getRelative(BlockFace face) {
return new BukkitBlock(delegate.getRelative(BukkitEnumAdapter.fromTerraBlockFace(face)));
}
@Override
public Block getRelative(BlockFace face, int len) {
return new BukkitBlock(delegate.getRelative(BukkitEnumAdapter.fromTerraBlockFace(face), len));
}
@Override
public boolean isEmpty() {
return delegate.isEmpty();
}
@Override
public Location getLocation() {
return new Location(new BukkitWorld(delegate.getWorld()), delegate.getX(), delegate.getY(), delegate.getZ());
}
@Override
public MaterialData getType() {
return new BukkitMaterialData(delegate.getType());
}
@Override
public int getX() {
return delegate.getX();
}
@Override
public int getZ() {
return delegate.getZ();
}
@Override
public int getY() {
return delegate.getY();
}
@Override
public boolean isPassable() {
return delegate.isPassable();
}
@Override
public Object getHandle() {
return delegate;

View File

@@ -21,6 +21,16 @@ public class BukkitMaterialData implements MaterialData {
return ((BukkitMaterialData) other.getMaterial()).getHandle().equals(delegate);
}
@Override
public boolean isSolid() {
return delegate.isSolid();
}
@Override
public boolean isAir() {
return delegate.isAir();
}
@Override
public Material getHandle() {
return delegate;

View File

@@ -13,7 +13,7 @@ public interface Biome {
*
* @return Biome - The Vanilla biome.
*/
org.bukkit.block.Biome getVanillaBiome();
com.dfsek.terra.api.generic.world.Biome getVanillaBiome();
/**
* Gets the BiomeTerrain instance used to generate the biome.

View File

@@ -10,7 +10,7 @@ import com.dfsek.terra.api.gaea.tree.fractal.trees.ShatteredTree;
import com.dfsek.terra.api.gaea.tree.fractal.trees.SmallShatteredPillar;
import com.dfsek.terra.api.gaea.tree.fractal.trees.SmallShatteredTree;
import com.dfsek.terra.api.gaea.tree.fractal.trees.SpruceTree;
import org.bukkit.Location;
import com.dfsek.terra.api.generic.world.vector.Location;
import java.util.Random;

View File

@@ -1,14 +1,16 @@
package com.dfsek.terra.api.gaea.tree;
import com.dfsek.terra.api.bukkit.world.block.BukkitMaterialData;
import com.dfsek.terra.api.gaea.tree.fractal.FractalTree;
import com.dfsek.terra.api.generic.world.block.MaterialData;
import com.dfsek.terra.api.generic.world.vector.Location;
import com.google.common.collect.Sets;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.Collections;
import java.util.Random;
import java.util.Set;
import java.util.stream.Collectors;
public enum TreeType implements Tree {
SHATTERED_SMALL(null, Collections.singleton(Material.END_STONE)),
@@ -85,7 +87,7 @@ public enum TreeType implements Tree {
return CustomTreeType.valueOf(this.toString());
}
public boolean plant(Location l, Random r, JavaPlugin main) {
public boolean plant(Location l, Random r) {
if(this.getVanillaTreeType() == null) {
if(!spawnable.contains(l.subtract(0, 1, 0).getBlock().getType())) return false;
FractalTree tree = getCustomTreeType().getTree(l, r);
@@ -97,7 +99,7 @@ public enum TreeType implements Tree {
}
@Override
public Set<Material> getSpawnable() {
return spawnable;
public Set<MaterialData> getSpawnable() {
return spawnable.stream().map(BukkitMaterialData::new).collect(Collectors.toSet());
}
}

View File

@@ -1,6 +1,6 @@
package com.dfsek.terra.api.gaea.tree.fractal;
import org.bukkit.Location;
import com.dfsek.terra.api.generic.world.vector.Location;
import org.bukkit.entity.Entity;
import org.bukkit.util.Consumer;

View File

@@ -1,9 +1,11 @@
package com.dfsek.terra.api.gaea.tree.fractal;
import com.dfsek.terra.api.bukkit.world.block.BukkitBlockData;
import com.dfsek.terra.api.gaea.util.GlueList;
import org.bukkit.Location;
import com.dfsek.terra.api.generic.world.block.BlockData;
import com.dfsek.terra.api.generic.world.block.MaterialData;
import com.dfsek.terra.api.generic.world.vector.Location;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Entity;
import org.bukkit.util.Consumer;
@@ -70,7 +72,7 @@ public abstract class FractalTree {
* @param m - The material to which it will be set.
*/
public void setBlock(Location l, Material m) {
treeAssembler.put(l, m.createBlockData());
treeAssembler.put(l, new BukkitBlockData(m.createBlockData()));
}
/**
@@ -104,8 +106,8 @@ public abstract class FractalTree {
* @param l - The location at which to check.
* @return Material - The material at the specified block.
*/
public Material getMaterial(Location l) {
return treeAssembler.getOrDefault(l, Material.AIR.createBlockData()).getMaterial();
public MaterialData getMaterial(Location l) {
return treeAssembler.getOrDefault(l, new BukkitBlockData(Material.AIR.createBlockData())).getMaterial();
}

View File

@@ -1,9 +1,9 @@
package com.dfsek.terra.api.gaea.tree.fractal;
import com.dfsek.terra.api.gaea.math.ProbabilityCollection;
import org.bukkit.Location;
import com.dfsek.terra.api.generic.world.vector.Location;
import com.dfsek.terra.api.generic.world.vector.Vector3;
import org.bukkit.Material;
import org.bukkit.util.Vector;
public class TreeGeometry {
private final FractalTree tree;
@@ -12,8 +12,8 @@ public class TreeGeometry {
this.tree = tree;
}
public static Vector getPerpendicular(Vector v) {
return v.getZ() < v.getX() ? new Vector(v.getY(), - v.getX(), 0) : new Vector(0, - v.getZ(), v.getY());
public static Vector3 getPerpendicular(Vector3 v) {
return v.getZ() < v.getX() ? new Vector3(v.getY(), - v.getX(), 0) : new Vector3(0, - v.getZ(), v.getY());
}
public FractalTree getTree() {
@@ -32,7 +32,7 @@ public class TreeGeometry {
for(int x = - radius; x <= radius; x++) {
for(int y = - radius; y <= radius; y++) {
for(int z = - radius; z <= radius; z++) {
Vector position = l.toVector().clone().add(new Vector(x, y, z));
Vector3 position = l.toVector().clone().add(new Vector3(x, y, z));
if(l.toVector().distance(position) <= radius + 0.5 && (overwrite || tree.getMaterial(position.toLocation(l.getWorld())).isAir()))
tree.setBlock(position.toLocation(l.getWorld()), m.get());
}
@@ -44,7 +44,7 @@ public class TreeGeometry {
for(int x = - radius; x <= radius; x++) {
for(int y = - radius; y <= radius; y++) {
for(int z = - radius; z <= radius; z++) {
Vector position = l.toVector().clone().add(new Vector(x, y, z));
Vector3 position = l.toVector().clone().add(new Vector3(x, y, z));
if(tree.getRandom().nextInt(100) < sponginess && l.toVector().distance(position) <= radius + 0.5 && (overwrite || tree.getMaterial(position.toLocation(l.getWorld())).isAir()))
tree.setBlock(position.toLocation(l.getWorld()), m.get());
}
@@ -56,7 +56,7 @@ public class TreeGeometry {
for(int x = - radius; x <= radius; x++) {
for(int y = 0; y <= height; y++) {
for(int z = - radius; z <= radius; z++) {
Vector position = l.toVector().clone().add(new Vector(x, 0, z));
Vector3 position = l.toVector().clone().add(new Vector3(x, 0, z));
if(l.toVector().distance(position) <= radius + 0.5 && (overwrite || tree.getMaterial(position.toLocation(l.getWorld())).isAir()))
tree.setBlock(position.toLocation(l.getWorld()), m.get());
}

View File

@@ -1,6 +1,6 @@
package com.dfsek.terra.api.gaea.tree.fractal;
import org.bukkit.Location;
import com.dfsek.terra.api.generic.world.vector.Location;
import java.util.Random;

View File

@@ -1,7 +1,7 @@
package com.dfsek.terra.api.gaea.tree.fractal.trees;
import com.dfsek.terra.api.gaea.tree.fractal.FractalTree;
import org.bukkit.Location;
import com.dfsek.terra.api.generic.world.vector.Location;
import org.bukkit.Material;
import java.util.Random;

View File

@@ -3,9 +3,9 @@ package com.dfsek.terra.api.gaea.tree.fractal.trees;
import com.dfsek.terra.api.gaea.math.ProbabilityCollection;
import com.dfsek.terra.api.gaea.tree.fractal.FractalTree;
import com.dfsek.terra.api.gaea.tree.fractal.TreeGeometry;
import org.bukkit.Location;
import com.dfsek.terra.api.generic.world.vector.Location;
import com.dfsek.terra.api.generic.world.vector.Vector3;
import org.bukkit.Material;
import org.bukkit.util.Vector;
import java.util.Random;
@@ -34,7 +34,7 @@ public class IceSpike extends FractalTree {
*/
@Override
public void grow() {
Vector direction = new Vector(getOffset(), 0, getOffset());
Vector3 direction = new Vector3(getOffset(), 0, getOffset());
Location l1 = super.getOrigin().clone();
int h = super.getRandom().nextInt(16) + 8;
for(int i = 0; i < h; i++) {

View File

@@ -2,10 +2,10 @@ package com.dfsek.terra.api.gaea.tree.fractal.trees;
import com.dfsek.terra.api.gaea.tree.fractal.FractalTree;
import com.dfsek.terra.api.gaea.tree.fractal.TreeGeometry;
import com.dfsek.terra.api.generic.world.vector.Location;
import com.dfsek.terra.api.generic.world.vector.Vector3;
import net.jafama.FastMath;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.util.Vector;
import java.util.Random;
@@ -29,10 +29,10 @@ public class OakTree extends FractalTree {
*/
@Override
public void grow() {
growBranch(super.getOrigin().clone(), new Vector(super.getRandom().nextInt(5) - 2, super.getRandom().nextInt(4) + 6, super.getRandom().nextInt(5) - 2), 2, 0);
growBranch(super.getOrigin().clone(), new Vector3(super.getRandom().nextInt(5) - 2, super.getRandom().nextInt(4) + 6, super.getRandom().nextInt(5) - 2), 2, 0);
}
private void growBranch(Location l1, Vector diff, double d1, int recursions) {
private void growBranch(Location l1, Vector3 diff, double d1, int recursions) {
if(recursions > 1) {
geo.generateSphere(l1, Material.OAK_LEAVES, 1 + super.getRandom().nextInt(2) + (3 - recursions), false);
if(recursions > 2) return;

View File

@@ -1,47 +0,0 @@
package com.dfsek.terra.api.gaea.tree.fractal.trees;
import com.dfsek.terra.api.gaea.math.FastNoiseLite;
import com.dfsek.terra.api.gaea.math.ProbabilityCollection;
import com.dfsek.terra.api.gaea.tree.fractal.FractalTree;
import com.dfsek.terra.api.gaea.tree.fractal.TreeGeometry;
import org.bukkit.Location;
import org.bukkit.Material;
import java.util.Random;
public class Rock extends FractalTree {
private final TreeGeometry geo;
private final FastNoiseLite noise;
private final FastNoiseLite rock;
private static final ProbabilityCollection<Material> ice = new ProbabilityCollection<Material>().add(Material.PACKED_ICE, 95).add(Material.BLUE_ICE, 5);
/**
* Instantiates a TreeGrower at an origin location.
*
* @param origin - The origin location.
* @param random - The random object to use whilst generating the tree.
*/
public Rock(Location origin, Random random) {
super(origin, random);
int seed = origin.hashCode();
this.noise = new FastNoiseLite(seed);
this.rock = new FastNoiseLite(++seed);
geo = new TreeGeometry(this);
}
/**
* Grows the tree in memory. Intended to be invoked from an async thread.
*/
@Override
public void grow() {
Location l1 = super.getOrigin().clone();
int h = super.getRandom().nextInt(16) + 8;
for(int i = 0; i < h; i++) {
geo.generateSponge(l1.clone().add(0, i, 0), ice, (int) ((1-((double) i / h))*2+1), true, 70);
}
for(int i = 0; i < h/3; i++) {
setBlock(l1.clone().add(0, h+i, 0), ice.get(super.getRandom()));
}
}
}

View File

@@ -1,7 +1,7 @@
package com.dfsek.terra.api.gaea.tree.fractal.trees;
import com.dfsek.terra.api.gaea.tree.fractal.FractalTree;
import org.bukkit.Location;
import com.dfsek.terra.api.generic.world.vector.Location;
import org.bukkit.Material;
import org.bukkit.entity.EnderCrystal;

View File

@@ -3,10 +3,10 @@ package com.dfsek.terra.api.gaea.tree.fractal.trees;
import com.dfsek.terra.api.gaea.math.ProbabilityCollection;
import com.dfsek.terra.api.gaea.tree.fractal.FractalTree;
import com.dfsek.terra.api.gaea.tree.fractal.TreeGeometry;
import com.dfsek.terra.api.generic.world.vector.Location;
import com.dfsek.terra.api.generic.world.vector.Vector3;
import net.jafama.FastMath;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.util.Vector;
import java.util.Random;
@@ -35,11 +35,11 @@ public class ShatteredTree extends FractalTree {
*/
@Override
public void grow() {
growBranch(super.getOrigin().clone(), new Vector(super.getRandom().nextInt(5) - 2, super.getRandom().nextInt(4) + 6, super.getRandom().nextInt(5) - 2), 1, 0);
growBranch(super.getOrigin().clone(), new Vector3(super.getRandom().nextInt(5) - 2, super.getRandom().nextInt(4) + 6, super.getRandom().nextInt(5) - 2), 1, 0);
}
private void growBranch(Location l1, Vector diff, double d1, int recursions) {
private void growBranch(Location l1, Vector3 diff, double d1, int recursions) {
if(recursions > 2) {
geo.generateSphere(l1, leaves, 1 + super.getRandom().nextInt(2), false);
return;

View File

@@ -1,7 +1,7 @@
package com.dfsek.terra.api.gaea.tree.fractal.trees;
import com.dfsek.terra.api.gaea.tree.fractal.FractalTree;
import org.bukkit.Location;
import com.dfsek.terra.api.generic.world.vector.Location;
import org.bukkit.Material;
import java.util.Random;

View File

@@ -3,10 +3,10 @@ package com.dfsek.terra.api.gaea.tree.fractal.trees;
import com.dfsek.terra.api.gaea.math.ProbabilityCollection;
import com.dfsek.terra.api.gaea.tree.fractal.FractalTree;
import com.dfsek.terra.api.gaea.tree.fractal.TreeGeometry;
import com.dfsek.terra.api.generic.world.vector.Location;
import com.dfsek.terra.api.generic.world.vector.Vector3;
import net.jafama.FastMath;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.util.Vector;
import java.util.Random;
@@ -35,11 +35,11 @@ public class SmallShatteredTree extends FractalTree {
*/
@Override
public void grow() {
growBranch(super.getOrigin().clone(), new Vector(super.getRandom().nextInt(5) - 2, super.getRandom().nextInt(3) + 4, super.getRandom().nextInt(5) - 2), 1.5, 0);
growBranch(super.getOrigin().clone(), new Vector3(super.getRandom().nextInt(5) - 2, super.getRandom().nextInt(3) + 4, super.getRandom().nextInt(5) - 2), 1.5, 0);
}
private void growBranch(Location l1, Vector diff, double d1, int recursions) {
private void growBranch(Location l1, Vector3 diff, double d1, int recursions) {
if(recursions > 2) {
geo.generateSphere(l1, leaves, 1 + super.getRandom().nextInt(2) + (3 - recursions), false);
return;

View File

@@ -2,10 +2,10 @@ package com.dfsek.terra.api.gaea.tree.fractal.trees;
import com.dfsek.terra.api.gaea.tree.fractal.FractalTree;
import com.dfsek.terra.api.gaea.tree.fractal.TreeGeometry;
import com.dfsek.terra.api.generic.world.vector.Location;
import com.dfsek.terra.api.generic.world.vector.Vector3;
import net.jafama.FastMath;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.util.Vector;
import java.util.Random;
@@ -28,10 +28,10 @@ public class SpruceTree extends FractalTree {
*/
@Override
public void grow() {
growTrunk(super.getOrigin().clone(), new Vector(0, 16 + super.getRandom().nextInt(5), 0));
growTrunk(super.getOrigin().clone(), new Vector3(0, 16 + super.getRandom().nextInt(5), 0));
}
private void growTrunk(Location l1, Vector diff) {
private void growTrunk(Location l1, Vector3 diff) {
if(diff.getY() < 0) diff.rotateAroundAxis(TreeGeometry.getPerpendicular(diff.clone()).normalize(), FastMath.PI);
int d = (int) diff.length();
int rad = 7;

View File

@@ -1,19 +1,21 @@
package com.dfsek.terra.api.gaea.world;
import com.dfsek.terra.api.bukkit.world.block.BukkitBlockData;
import com.dfsek.terra.api.gaea.math.Range;
import com.dfsek.terra.api.gaea.util.GlueList;
import com.dfsek.terra.api.generic.world.Chunk;
import com.dfsek.terra.api.generic.world.block.Block;
import com.dfsek.terra.api.generic.world.block.BlockData;
import com.dfsek.terra.api.generic.world.block.BlockFace;
import com.dfsek.terra.api.generic.world.vector.Location;
import com.google.common.collect.Sets;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public enum FloraType implements Flora {
TALL_GRASS(Sets.newHashSet(Material.GRASS_BLOCK, Material.PODZOL), Bukkit.createBlockData("minecraft:tall_grass[half=lower]"), Bukkit.createBlockData("minecraft:tall_grass[half=upper]")),
@@ -51,8 +53,8 @@ public enum FloraType implements Flora {
private final Set<Material> spawns;
FloraType(Set<Material> validSpawns, BlockData... type) {
data.addAll(Arrays.asList(type));
FloraType(Set<Material> validSpawns, org.bukkit.block.data.BlockData... type) {
data.addAll(Arrays.stream(type).map(BukkitBlockData::new).collect(Collectors.toList()));
this.spawns = validSpawns;
}

View File

@@ -1,7 +1,6 @@
package com.dfsek.terra.api.generic.world;
import com.dfsek.terra.api.generic.Handle;
import org.bukkit.block.Biome;
import org.jetbrains.annotations.NotNull;
public interface BiomeGrid extends Handle {

View File

@@ -4,6 +4,9 @@ import com.dfsek.terra.api.generic.Handle;
import com.dfsek.terra.api.generic.generator.ChunkGenerator;
import com.dfsek.terra.api.generic.world.block.Block;
import com.dfsek.terra.api.generic.world.vector.Location;
import org.bukkit.TreeType;
import org.bukkit.entity.Entity;
import org.bukkit.util.Consumer;
import java.io.File;
import java.util.UUID;
@@ -28,4 +31,8 @@ public interface World extends Handle {
Block getBlockAt(int x, int y, int z);
Block getBlockAt(Location l);
boolean generateTree(Location l, TreeType vanillaTreeType); // TODO: Bukkit treetype is bad
void spawn(Location location, Class<Entity> entity, Consumer<Entity> consumer); // TODO: Bukkit Entity is bad
}

View File

@@ -23,4 +23,6 @@ public interface Block extends Handle {
int getZ();
int getY();
boolean isPassable();
}

View File

@@ -8,4 +8,6 @@ public interface MaterialData extends Handle {
boolean matches(BlockData other);
boolean isSolid();
boolean isAir();
}

View File

@@ -77,4 +77,18 @@ public class Location implements Cloneable {
public Block getBlock() {
return world.getBlockAt(this);
}
public Location subtract(int x, int y, int z) {
vector.subtract(x, y, z);
return this;
}
public Location add(Vector3 add) {
vector.add(add);
return this;
}
public Vector3 toVector() {
return vector.clone();
}
}

View File

@@ -23,6 +23,15 @@ public class Vector3 implements Cloneable {
this.z = z;
}
/**
* Get the threshold used for equals().
*
* @return The epsilon.
*/
public static double getEpsilon() {
return epsilon;
}
public double getZ() {
return z;
}
@@ -89,15 +98,6 @@ public class Vector3 implements Cloneable {
return this;
}
/**
* Get the threshold used for equals().
*
* @return The epsilon.
*/
public static double getEpsilon() {
return epsilon;
}
public double lengthSquared() {
return x * x + y * y + z * z;
}
@@ -300,4 +300,11 @@ public class Vector3 implements Cloneable {
public Vector3 normalize() {
return this.multiply(1D / this.length());
}
public Vector3 subtract(int x, int y, int z) {
this.x -= x;
this.y -= y;
this.z = -z;
return this;
}
}

View File

@@ -3,9 +3,9 @@ package com.dfsek.terra.async;
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.api.gaea.biome.Biome;
import com.dfsek.terra.api.gaea.generation.GenerationPhase;
import com.dfsek.terra.api.generic.world.vector.Vector3;
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
import org.bukkit.Location;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer;
@@ -15,7 +15,7 @@ import java.util.function.Consumer;
*/
public class AsyncBiomeFinder extends AsyncFeatureFinder<Biome> {
public AsyncBiomeFinder(TerraBiomeGrid grid, Biome target, @NotNull Location origin, int startRadius, int maxRadius, Consumer<Vector> callback, TerraBukkitPlugin main) {
public AsyncBiomeFinder(TerraBiomeGrid grid, Biome target, @NotNull Location origin, int startRadius, int maxRadius, Consumer<Vector3> callback, TerraBukkitPlugin main) {
super(grid, target, origin, startRadius, maxRadius, callback, main);
}
@@ -33,7 +33,7 @@ public class AsyncBiomeFinder extends AsyncFeatureFinder<Biome> {
}
@Override
public Vector finalizeVector(Vector orig) {
public Vector3 finalizeVector(Vector3 orig) {
return orig.multiply(main.getTerraConfig().getBiomeSearchResolution());
}
}

View File

@@ -1,11 +1,11 @@
package com.dfsek.terra.async;
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.api.generic.world.vector.Vector3;
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer;
@@ -18,11 +18,11 @@ public abstract class AsyncFeatureFinder<T> implements Runnable {
protected final int centerX;
protected final int centerZ;
protected final World world;
private final Consumer<Vector> callback;
private final Consumer<Vector3> callback;
protected int searchSize = 1;
protected final TerraBukkitPlugin main;
public AsyncFeatureFinder(TerraBiomeGrid grid, T target, @NotNull Location origin, int startRadius, int maxRadius, Consumer<Vector> callback, TerraBukkitPlugin main) {
public AsyncFeatureFinder(TerraBiomeGrid grid, T target, @NotNull Location origin, int startRadius, int maxRadius, Consumer<Vector3> callback, TerraBukkitPlugin main) {
this.grid = grid;
this.target = target;
this.main = main;
@@ -67,12 +67,12 @@ public abstract class AsyncFeatureFinder<T> implements Runnable {
run++;
toggle = !toggle;
}
Vector finalSpawn = found ? finalizeVector(new Vector(x, 0, z)) : null;
Vector3 finalSpawn = found ? finalizeVector(new Vector3(x, 0, z)) : null;
Bukkit.getScheduler().runTask(main, () -> callback.accept(finalSpawn));
}
public abstract Vector finalizeVector(Vector orig);
public abstract Vector3 finalizeVector(Vector3 orig);
public abstract boolean isValid(int x, int z, T target);

View File

@@ -1,7 +1,9 @@
package com.dfsek.terra.async;
import com.dfsek.terra.api.bukkit.BukkitWorld;
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.api.gaea.util.FastRandom;
import com.dfsek.terra.api.generic.world.vector.Vector3;
import com.dfsek.terra.biome.UserDefinedBiome;
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
import com.dfsek.terra.generation.items.TerraStructure;
@@ -10,7 +12,6 @@ import com.dfsek.terra.structure.Rotation;
import com.dfsek.terra.structure.Structure;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import java.util.Random;
@@ -20,7 +21,7 @@ import java.util.function.Consumer;
* Runnable to locate structures asynchronously
*/
public class AsyncStructureFinder extends AsyncFeatureFinder<TerraStructure> {
public AsyncStructureFinder(TerraBiomeGrid grid, TerraStructure target, @NotNull Location origin, int startRadius, int maxRadius, Consumer<Vector> callback, TerraBukkitPlugin main) {
public AsyncStructureFinder(TerraBiomeGrid grid, TerraStructure target, @NotNull Location origin, int startRadius, int maxRadius, Consumer<Vector3> callback, TerraBukkitPlugin main) {
super(grid, target, origin, startRadius, maxRadius, callback, main);
setSearchSize(target.getSpawn().getWidth() + 2 * target.getSpawn().getSeparation());
}
@@ -34,7 +35,7 @@ public class AsyncStructureFinder extends AsyncFeatureFinder<TerraStructure> {
*/
public boolean isValid(int x, int z, TerraStructure target) {
World world = getWorld();
Location spawn = target.getSpawn().getChunkSpawn(x, z, world.getSeed()).toLocation(world);
com.dfsek.terra.api.generic.world.vector.Location spawn = target.getSpawn().getChunkSpawn(x, z, world.getSeed()).toLocation(new BukkitWorld(world));
if(!((UserDefinedBiome) grid.getBiome(spawn)).getConfig().getStructures().contains(target)) return false;
Random r2 = new FastRandom(spawn.hashCode());
Structure struc = target.getStructures().get(r2);
@@ -49,7 +50,7 @@ public class AsyncStructureFinder extends AsyncFeatureFinder<TerraStructure> {
}
@Override
public Vector finalizeVector(Vector orig) {
public Vector3 finalizeVector(Vector3 orig) {
GridSpawn spawn = target.getSpawn();
return spawn.getChunkSpawn(orig.getBlockX(), orig.getBlockZ(), world.getSeed());
}

View File

@@ -15,14 +15,14 @@ import org.bukkit.World;
public class UserDefinedBiome implements Biome {
private final GeneratorBuilder gen;
private final UserDefinedDecorator decorator;
private final org.bukkit.block.Biome vanilla;
private final com.dfsek.terra.api.generic.world.Biome vanilla;
private final String id;
private final BiomeTemplate config;
private final ConfigPack pack;
private UserDefinedBiome erode;
public UserDefinedBiome(org.bukkit.block.Biome vanilla, UserDefinedDecorator dec, GeneratorBuilder gen, BiomeTemplate config, ConfigPack pack) {
public UserDefinedBiome(com.dfsek.terra.api.generic.world.Biome vanilla, UserDefinedDecorator dec, GeneratorBuilder gen, BiomeTemplate config, ConfigPack pack) {
this.vanilla = vanilla;
this.decorator = dec;
this.gen = gen;
@@ -37,7 +37,7 @@ public class UserDefinedBiome implements Biome {
* @return Biome - The Vanilla biome.
*/
@Override
public org.bukkit.block.Biome getVanillaBiome() {
public com.dfsek.terra.api.generic.world.Biome getVanillaBiome() {
return vanilla;
}

View File

@@ -1,7 +1,7 @@
package com.dfsek.terra.biome.palette;
import com.dfsek.terra.api.gaea.math.ProbabilityCollection;
import org.bukkit.block.data.BlockData;
import com.dfsek.terra.api.generic.world.block.BlockData;
import org.jetbrains.annotations.NotNull;
public class PaletteLayer {

View File

@@ -17,7 +17,7 @@ public class FixChunkCommand extends WorldCommand {
@Override
public boolean execute(@NotNull Player player, @NotNull Command command, @NotNull String s, @NotNull String[] strings, World world) {
TerraChunkGenerator.fixChunk(player.getLocation().getChunk());
//TerraChunkGenerator.fixChunk(player.getLocation().getChunk());
return true;
}

View File

@@ -38,7 +38,7 @@ public class SaveDataCommand extends WorldCommand {
@Override
public boolean execute(@NotNull Player sender, org.bukkit.command.@NotNull Command command, @NotNull String label, @NotNull String[] args, World w) {
TerraChunkGenerator.saveAll();
//TerraChunkGenerator.saveAll();
LangUtil.send("debug.data-save", sender, w.getName());
return true;
}

View File

@@ -1,11 +1,6 @@
package com.dfsek.terra.command.biome;
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.api.gaea.command.WorldCommand;
import com.dfsek.terra.api.gaea.generation.GenerationPhase;
import com.dfsek.terra.biome.UserDefinedBiome;
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
import com.dfsek.terra.config.lang.LangUtil;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -23,9 +18,12 @@ public class BiomeCommand extends WorldCommand {
@Override
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World w) {
/*
TerraBiomeGrid grid = ((TerraBukkitPlugin) getMain()).getWorld(sender.getWorld()).getGrid();
UserDefinedBiome biome = (UserDefinedBiome) grid.getBiome(sender.getLocation(), GenerationPhase.POPULATE);
LangUtil.send("command.biome.in", sender, biome.getID());
*/
return true;
}

View File

@@ -1,5 +1,6 @@
package com.dfsek.terra.command.biome;
import com.dfsek.terra.api.bukkit.BukkitWorld;
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.api.gaea.command.WorldCommand;
import com.dfsek.terra.biome.UserDefinedBiome;
@@ -17,7 +18,6 @@ import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class BiomeInfoCommand extends WorldCommand {
public BiomeInfoCommand(com.dfsek.terra.api.gaea.command.Command parent) {
@@ -27,7 +27,7 @@ public class BiomeInfoCommand extends WorldCommand {
@Override
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
String id = args[0];
ConfigPack cfg = ((TerraBukkitPlugin) getMain()).getWorld(world).getConfig();
ConfigPack cfg = ((TerraBukkitPlugin) getMain()).getWorld(new BukkitWorld(world)).getConfig();
UserDefinedBiome b;
try {
b = cfg.getBiome(id);
@@ -84,11 +84,14 @@ public class BiomeInfoCommand extends WorldCommand {
@Override
public List<String> getTabCompletions(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) {
/*
if(!(sender instanceof Player) || !(((Player) sender).getWorld().getGenerator() instanceof TerraChunkGenerator))
return Collections.emptyList();
List<String> ids = ((TerraBukkitPlugin) getMain()).getWorld(((Player) sender).getWorld()).getConfig().getBiomeIDs();
if(args.length == 1)
return ids.stream().filter(string -> string.toUpperCase().startsWith(args[0].toUpperCase())).collect(Collectors.toList());
*/
return Collections.emptyList();
}
}

View File

@@ -1,28 +1,14 @@
package com.dfsek.terra.command.biome;
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.api.gaea.command.WorldCommand;
import com.dfsek.terra.async.AsyncBiomeFinder;
import com.dfsek.terra.biome.UserDefinedBiome;
import com.dfsek.terra.config.lang.LangUtil;
import com.dfsek.terra.generation.TerraChunkGenerator;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
public class BiomeLocateCommand extends WorldCommand {
private final boolean tp;
@@ -35,6 +21,7 @@ public class BiomeLocateCommand extends WorldCommand {
@SuppressWarnings("DuplicatedCode")
@Override
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
/*
String id = args[0];
int maxRadius;
try {
@@ -62,6 +49,8 @@ public class BiomeLocateCommand extends WorldCommand {
// LangUtil.send("command.biome.biome-found", sender, String.valueOf(location.getBlockX()), String.valueOf(location.getBlockZ()));
} else LangUtil.send("command.biome.unable-to-locate", sender);
}, (TerraBukkitPlugin) getMain()));
*/
return true;
}
@@ -82,11 +71,14 @@ public class BiomeLocateCommand extends WorldCommand {
@Override
public List<String> getTabCompletions(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) {
/*
if(!(sender instanceof Player) || !(((Player) sender).getWorld().getGenerator() instanceof TerraChunkGenerator))
return Collections.emptyList();
List<String> ids = ((TerraBukkitPlugin) getMain()).getWorld(((Player) sender).getWorld()).getConfig().getBiomeIDs();
if(args.length == 1)
return ids.stream().filter(string -> string.toUpperCase().startsWith(args[0].toUpperCase())).collect(Collectors.toList());
*/
return Collections.emptyList();
}
}

View File

@@ -1,16 +1,12 @@
package com.dfsek.terra.command.image;
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.api.gaea.command.WorldCommand;
import com.dfsek.terra.config.lang.LangUtil;
import com.dfsek.terra.image.WorldImageGenerator;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.Collections;
import java.util.List;
@@ -21,6 +17,7 @@ public class RenderCommand extends WorldCommand {
@Override
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
/*
try {
WorldImageGenerator g = new WorldImageGenerator(world, Integer.parseInt(args[0]), Integer.parseInt(args[1]), (TerraBukkitPlugin) getMain());
g.drawWorld(sender.getLocation().getBlockX(), sender.getLocation().getBlockZ());
@@ -37,6 +34,9 @@ public class RenderCommand extends WorldCommand {
LangUtil.send("command.image.render.error", sender);
return true;
}
*/
return true;
}
@Override

View File

@@ -1,9 +1,6 @@
package com.dfsek.terra.command.image.gui;
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.api.gaea.command.WorldCommand;
import com.dfsek.terra.config.lang.LangUtil;
import com.dfsek.terra.image.ImageLoader;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -20,6 +17,7 @@ public class RawGUICommand extends WorldCommand {
@Override
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
/*
if(!getMain().isDebug()) {
LangUtil.send("command.image.gui.debug", sender);
return true;
@@ -27,6 +25,8 @@ public class RawGUICommand extends WorldCommand {
ImageLoader loader = ((TerraBukkitPlugin) getMain()).getWorld(world).getConfig().getTemplate().getImageLoader();
if(loader != null) loader.debug(false, sender.getWorld(), (TerraBukkitPlugin) getMain());
else ImageLoader.debugWorld(false, world, (TerraBukkitPlugin) getMain());
*/
return true;
}

View File

@@ -1,9 +1,6 @@
package com.dfsek.terra.command.image.gui;
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.api.gaea.command.WorldCommand;
import com.dfsek.terra.config.lang.LangUtil;
import com.dfsek.terra.image.ImageLoader;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -20,6 +17,7 @@ public class StepGUICommand extends WorldCommand {
@Override
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
/*
if(!getMain().isDebug()) {
LangUtil.send("command.image.gui.debug", sender);
return true;
@@ -27,6 +25,8 @@ public class StepGUICommand extends WorldCommand {
ImageLoader loader = ((TerraBukkitPlugin) getMain()).getWorld(world).getConfig().getTemplate().getImageLoader();
if(loader != null) loader.debug(true, sender.getWorld(), (TerraBukkitPlugin) getMain());
else ImageLoader.debugWorld(true, world, (TerraBukkitPlugin) getMain());
*/
return true;
}

View File

@@ -1,5 +1,6 @@
package com.dfsek.terra.command.profile;
import com.dfsek.terra.api.bukkit.BukkitWorld;
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.api.gaea.command.WorldCommand;
import com.dfsek.terra.api.gaea.profiler.WorldProfiler;
@@ -19,7 +20,7 @@ public class QueryCommand extends WorldCommand {
@Override
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
WorldProfiler profile = ((TerraBukkitPlugin) getMain()).getWorld(world).getProfiler();
WorldProfiler profile = ((TerraBukkitPlugin) getMain()).getWorld(new BukkitWorld(world)).getProfiler();
sender.sendMessage(profile.getResultsFormatted());
return true;
}

View File

@@ -1,5 +1,6 @@
package com.dfsek.terra.command.profile;
import com.dfsek.terra.api.bukkit.BukkitWorld;
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.api.gaea.command.WorldCommand;
import com.dfsek.terra.api.gaea.profiler.WorldProfiler;
@@ -20,7 +21,7 @@ public class ResetCommand extends WorldCommand {
@Override
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
WorldProfiler profile = ((TerraBukkitPlugin) getMain()).getWorld(world).getProfiler();
WorldProfiler profile = ((TerraBukkitPlugin) getMain()).getWorld(new BukkitWorld(world)).getProfiler();
profile.reset();
LangUtil.send("command.profile.reset", sender);
return true;

View File

@@ -1,5 +1,6 @@
package com.dfsek.terra.command.profile;
import com.dfsek.terra.api.bukkit.BukkitWorld;
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.api.gaea.command.WorldCommand;
import com.dfsek.terra.api.gaea.profiler.WorldProfiler;
@@ -20,7 +21,7 @@ public class StartCommand extends WorldCommand {
@Override
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
WorldProfiler profile = ((TerraBukkitPlugin) getMain()).getWorld(world).getProfiler();
WorldProfiler profile = ((TerraBukkitPlugin) getMain()).getWorld(new BukkitWorld(world)).getProfiler();
profile.setProfiling(true);
LangUtil.send("command.profile.start", sender);
return true;

View File

@@ -1,5 +1,6 @@
package com.dfsek.terra.command.profile;
import com.dfsek.terra.api.bukkit.BukkitWorld;
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.api.gaea.command.WorldCommand;
import com.dfsek.terra.api.gaea.profiler.WorldProfiler;
@@ -20,7 +21,7 @@ public class StopCommand extends WorldCommand {
@Override
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
WorldProfiler profile = ((TerraBukkitPlugin) getMain()).getWorld(world).getProfiler();
WorldProfiler profile = ((TerraBukkitPlugin) getMain()).getWorld(new BukkitWorld(world)).getProfiler();
profile.setProfiling(false);
LangUtil.send("command.profile.stop", sender);
return true;

View File

@@ -1,9 +1,6 @@
package com.dfsek.terra.command.structure;
import com.dfsek.terra.api.gaea.command.PlayerCommand;
import com.dfsek.terra.config.lang.LangUtil;
import com.dfsek.terra.structure.InitializationException;
import com.dfsek.terra.structure.Structure;
import com.dfsek.terra.util.structure.WorldEditUtil;
import org.bukkit.Location;
import org.bukkit.command.Command;
@@ -11,8 +8,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
@@ -24,7 +19,8 @@ public class ExportCommand extends PlayerCommand {
@Override
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
Location[] l = WorldEditUtil.getSelectionLocations(sender);
if(l == null) return true;
/*if(l == null) return true;
Location l1 = l[0];
Location l2 = l[1];
Structure structure;
@@ -45,6 +41,8 @@ public class ExportCommand extends PlayerCommand {
} catch(IOException e) {
e.printStackTrace();
}
*/
return true;
}

View File

@@ -1,28 +1,15 @@
package com.dfsek.terra.command.structure;
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.api.gaea.command.WorldCommand;
import com.dfsek.terra.async.AsyncStructureFinder;
import com.dfsek.terra.config.lang.LangUtil;
import com.dfsek.terra.generation.items.TerraStructure;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
public class LocateCommand extends WorldCommand {
private final boolean tp;
@@ -44,6 +31,7 @@ public class LocateCommand extends WorldCommand {
LangUtil.send("command.structure.invalid-radius", sender, args[1]);
return true;
}
/*
TerraStructure s;
try {
s = Objects.requireNonNull(((TerraBukkitPlugin) getMain()).getWorld(world).getConfig().getStructure(id));
@@ -65,6 +53,8 @@ public class LocateCommand extends WorldCommand {
sender.sendMessage("Unable to locate structure. ");
}
}, (TerraBukkitPlugin) getMain()));
*/
return true;
}
@@ -85,11 +75,15 @@ public class LocateCommand extends WorldCommand {
@Override
public List<String> getTabCompletions(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) {
/*
if(!(sender instanceof Player) || !(((Player) sender).getWorld().getGenerator() instanceof TerraChunkGenerator))
return Collections.emptyList();
List<String> ids = ((TerraBukkitPlugin) getMain()).getWorld(((Player) sender).getWorld()).getConfig().getStructureIDs();
if(args.length == 1)
return ids.stream().filter(string -> string.toUpperCase().startsWith(args[0].toUpperCase())).collect(Collectors.toList());
*/
return Collections.emptyList();
}
}

View File

@@ -1,9 +1,7 @@
package com.dfsek.terra.command.structure;
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.api.gaea.command.DebugCommand;
import com.dfsek.terra.api.gaea.command.WorldCommand;
import com.dfsek.terra.structure.StructureSpawnRequirement;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
@@ -25,11 +23,14 @@ public class SpawnCommand extends WorldCommand implements DebugCommand {
int x = p.getBlockX();
int y = p.getBlockY();
int z = p.getBlockZ();
/*
boolean air = StructureSpawnRequirement.AIR.getInstance(world, (TerraBukkitPlugin) getMain()).matches(x, y, z);
boolean ground = StructureSpawnRequirement.LAND.getInstance(world, (TerraBukkitPlugin) getMain()).matches(x, y, z);
boolean sea = StructureSpawnRequirement.OCEAN.getInstance(world, (TerraBukkitPlugin) getMain()).matches(x, y, z);
sender.sendMessage("AIR: " + air + "\nLAND: " + ground + "\nOCEAN: " + sea);
*/
return true;
}

View File

@@ -1,17 +1,11 @@
package com.dfsek.terra.command.structure.load;
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.api.gaea.command.DebugCommand;
import com.dfsek.terra.config.lang.LangUtil;
import com.dfsek.terra.structure.Rotation;
import com.dfsek.terra.structure.Structure;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -27,6 +21,7 @@ public class LoadFullCommand extends LoadCommand implements DebugCommand {
@Override
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
/*
try {
Rotation r;
try {
@@ -43,6 +38,8 @@ public class LoadFullCommand extends LoadCommand implements DebugCommand {
e.printStackTrace();
LangUtil.send("command.structure.invalid", sender, args[0]);
}
*/
return true;
}

View File

@@ -1,23 +1,12 @@
package com.dfsek.terra.command.structure.load;
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.api.gaea.command.DebugCommand;
import com.dfsek.terra.api.generic.world.WorldHandle;
import com.dfsek.terra.config.lang.LangUtil;
import com.dfsek.terra.structure.Structure;
import com.dfsek.terra.structure.StructureContainedBlock;
import com.dfsek.terra.structure.StructureInfo;
import com.dfsek.terra.structure.StructureSpawnRequirement;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -37,6 +26,7 @@ public class LoadRawCommand extends LoadCommand implements DebugCommand {
@Override
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
/*
try {
WorldHandle handle = ((TerraBukkitPlugin) getMain()).getHandle();
Structure struc = Structure.load(new File(getMain().getDataFolder() + File.separator + "export" + File.separator + "structures", args[0] + ".tstructure"));
@@ -88,6 +78,8 @@ public class LoadRawCommand extends LoadCommand implements DebugCommand {
e.printStackTrace();
LangUtil.send("command.structure.invalid", sender, args[0]);
}
*/
return true;
}

View File

@@ -5,10 +5,10 @@ import com.dfsek.terra.api.gaea.world.Flora;
import com.dfsek.terra.api.gaea.world.palette.Palette;
import com.dfsek.terra.api.gaea.world.palette.RandomPalette;
import com.dfsek.terra.api.generic.TerraPlugin;
import com.dfsek.terra.api.generic.world.block.BlockData;
import com.dfsek.terra.biome.palette.PaletteLayer;
import com.dfsek.terra.config.templates.FloraTemplate;
import com.dfsek.terra.generation.items.flora.TerraFlora;
import org.bukkit.block.data.BlockData;
public class FloraFactory implements TerraFactory<FloraTemplate, Flora> {
@Override

View File

@@ -6,9 +6,9 @@ import com.dfsek.terra.api.gaea.world.palette.Palette;
import com.dfsek.terra.api.gaea.world.palette.RandomPalette;
import com.dfsek.terra.api.gaea.world.palette.SimplexPalette;
import com.dfsek.terra.api.generic.TerraPlugin;
import com.dfsek.terra.api.generic.world.block.BlockData;
import com.dfsek.terra.biome.palette.PaletteLayer;
import com.dfsek.terra.config.templates.PaletteTemplate;
import org.bukkit.block.data.BlockData;
public class PaletteFactory implements TerraFactory<PaletteTemplate, Palette<BlockData>> {
@Override

View File

@@ -4,9 +4,9 @@ import com.dfsek.tectonic.exception.LoadException;
import com.dfsek.tectonic.loading.ConfigLoader;
import com.dfsek.tectonic.loading.TypeLoader;
import com.dfsek.terra.api.gaea.math.ProbabilityCollection;
import com.dfsek.terra.api.generic.world.block.BlockData;
import com.dfsek.terra.biome.palette.PaletteLayer;
import com.dfsek.terra.config.loaders.Types;
import org.bukkit.block.data.BlockData;
import java.lang.reflect.Type;
import java.util.Map;

View File

@@ -3,6 +3,7 @@ package com.dfsek.terra.config.templates;
import com.dfsek.tectonic.annotations.Abstractable;
import com.dfsek.tectonic.annotations.Default;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.bukkit.world.block.BukkitMaterialData;
import com.dfsek.terra.biome.palette.PaletteLayer;
import com.dfsek.terra.generation.items.flora.TerraFlora;
import com.dfsek.terra.util.MaterialSet;
@@ -28,7 +29,7 @@ public class FloraTemplate extends AbstractableTemplate {
@Value("replaceable")
@Abstractable
@Default
private MaterialSet replaceable = MaterialSet.singleton(Material.AIR);
private MaterialSet replaceable = MaterialSet.singleton(new BukkitMaterialData(Material.AIR));
@Value("irrigable")
@Abstractable

View File

@@ -1,12 +1,6 @@
package com.dfsek.terra.debug.gui;
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.api.gaea.generation.GenerationPhase;
import com.dfsek.terra.biome.UserDefinedBiome;
import com.dfsek.terra.image.ImageLoader;
import net.jafama.FastMath;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import javax.swing.*;
import java.awt.*;
@@ -33,8 +27,8 @@ public class DebugFrame extends JFrame implements ActionListener {
@Override
public void paint(Graphics g) {
super.paintComponents(g);
/*
for(Player p : Bukkit.getOnlinePlayers()) {
if(!(p.getWorld().getGenerator() instanceof TerraChunkGenerator)) break;
int xp = (int) (((double) FastMath.floorMod(p.getLocation().getBlockX() - (img.getWidth() / 2), x) / x) * getWidth());
int zp = (int) (((double) FastMath.floorMod(p.getLocation().getBlockZ() - (img.getHeight() / 2), z) / z) * getHeight());
ImageLoader loader = main.getWorld(p.getWorld()).getConfig().getTemplate().getImageLoader();
@@ -52,6 +46,8 @@ public class DebugFrame extends JFrame implements ActionListener {
g.setColor(Color.RED);
g.fillOval(xp + 3, zp + 3, 5, 5);
}
*/
}
@Override

View File

@@ -3,6 +3,7 @@ package com.dfsek.terra.generation.items.tree;
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.api.gaea.math.ProbabilityCollection;
import com.dfsek.terra.api.gaea.tree.Tree;
import com.dfsek.terra.api.generic.world.vector.Location;
import com.dfsek.terra.api.generic.world.vector.Vector2;
import com.dfsek.terra.structure.Rotation;
import com.dfsek.terra.structure.Structure;
@@ -10,8 +11,6 @@ import com.dfsek.terra.structure.StructureContainedBlock;
import com.dfsek.terra.structure.StructureInfo;
import com.dfsek.terra.util.MaterialSet;
import com.dfsek.terra.util.structure.RotationUtil;
import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.Random;
@@ -27,13 +26,13 @@ public class TerraTree implements Tree {
}
@Override
public boolean plant(Location location, Random random, JavaPlugin main) {
public boolean plant(Location location, Random random) {
Location mut = location.clone().subtract(0, yOffset, 0);
if(!spawnable.contains(location.getBlock().getType())) return false;
Structure struc = structure.get(random);
Rotation rotation = Rotation.fromDegrees(random.nextInt(4) * 90);
if(!struc.checkSpawns(mut, rotation, (TerraBukkitPlugin) main)) return false;
struc.paste(mut, rotation, (TerraBukkitPlugin) main);
if(!struc.checkSpawns(mut, rotation, null)) return false;
struc.paste(mut, rotation, null);
return true;
}

View File

@@ -1,17 +1,6 @@
package com.dfsek.terra.listeners;
import com.dfsek.terra.TerraWorld;
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.api.gaea.tree.Tree;
import com.dfsek.terra.api.gaea.tree.TreeType;
import com.dfsek.terra.api.gaea.util.FastRandom;
import com.dfsek.terra.config.base.ConfigPack;
import com.dfsek.terra.debug.Debug;
import com.dfsek.terra.generation.items.tree.TerraTree;
import com.dfsek.terra.registry.TreeRegistry;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.world.StructureGrowEvent;
@@ -28,8 +17,10 @@ public class EventListener implements Listener {
@EventHandler
public void onSaplingGrow(StructureGrowEvent e) {
if(!TerraWorld.isTerraWorld(e.getWorld())) return;
TerraWorld tw = main.getWorld(e.getWorld());
/*
World bukkit = new BukkitWorld(e.getWorld());
if(!TerraWorld.isTerraWorld(bukkit)) return;
TerraWorld tw = main.getWorld(bukkit);
ConfigPack c = tw.getConfig();
if(c.getTemplate().isDisableSaplings()) return;
e.setCancelled(true);
@@ -44,5 +35,7 @@ public class EventListener implements Listener {
block.setBlockData(data);
}
} else if(!tree.plant(e.getLocation().subtract(0, 1, 0), new FastRandom(), main)) block.setBlockData(data);
*/
}
}

View File

@@ -1,21 +1,7 @@
package com.dfsek.terra.listeners;
import com.dfsek.terra.TerraWorld;
import com.dfsek.terra.api.bukkit.TerraBukkitPlugin;
import com.dfsek.terra.async.AsyncStructureFinder;
import com.dfsek.terra.debug.Debug;
import com.dfsek.terra.generation.items.TerraStructure;
import com.dfsek.terra.util.StructureTypeEnum;
import org.bukkit.entity.EnderSignal;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Villager;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.entity.VillagerAcquireTradeEvent;
import org.bukkit.event.entity.VillagerCareerChangeEvent;
/**
* Listener to load on Spigot servers, contains Villager crash prevention and hacky ender eye redirection.
@@ -29,6 +15,7 @@ public class SpigotListener implements Listener {
public SpigotListener(TerraBukkitPlugin main) {
this.main = main;
}
/*
@EventHandler(priority = EventPriority.NORMAL)
public void onEnderEye(EntitySpawnEvent e) {
@@ -67,4 +54,6 @@ public class SpigotListener implements Listener {
e.setCancelled(true);
}
}
*/
}

View File

@@ -2,8 +2,6 @@ package com.dfsek.terra.registry;
import com.dfsek.terra.api.gaea.world.Flora;
import com.dfsek.terra.api.gaea.world.FloraType;
import com.dfsek.terra.generation.items.flora.BlockFlora;
import org.bukkit.Bukkit;
public class FloraRegistry extends TerraRegistry<Flora> {
public FloraRegistry() {
@@ -12,8 +10,6 @@ public class FloraRegistry extends TerraRegistry<Flora> {
@Override
public Flora get(String id) {
if(id.startsWith("BLOCK:"))
return new BlockFlora(Bukkit.createBlockData(id.substring(6))); // Return single flora for BLOCK: shortcut.
return super.get(id);
}
}

View File

@@ -1,15 +1,16 @@
package com.dfsek.terra.registry;
import com.dfsek.terra.api.bukkit.world.block.BukkitBlockData;
import com.dfsek.terra.api.gaea.world.palette.Palette;
import com.dfsek.terra.api.generic.world.block.BlockData;
import com.dfsek.terra.biome.palette.SinglePalette;
import org.bukkit.Bukkit;
import org.bukkit.block.data.BlockData;
public class PaletteRegistry extends TerraRegistry<Palette<BlockData>> {
@Override
public Palette<BlockData> get(String id) {
if(id.startsWith("BLOCK:"))
return new SinglePalette<>(Bukkit.createBlockData(id.substring(6))); // Return single palette for BLOCK: shortcut.
return new SinglePalette<>(new BukkitBlockData(Bukkit.createBlockData(id.substring(6)))); // Return single palette for BLOCK: shortcut.
return super.get(id);
}
}

View File

@@ -4,19 +4,16 @@ import com.dfsek.terra.api.gaea.world.palette.Palette;
import com.dfsek.terra.api.generic.generator.ChunkGenerator;
import com.dfsek.terra.api.generic.world.block.BlockData;
import com.dfsek.terra.api.generic.world.block.MaterialData;
import com.dfsek.terra.api.generic.world.block.data.Bisected;
import com.dfsek.terra.api.generic.world.block.data.Stairs;
import com.dfsek.terra.api.generic.world.block.data.Waterlogged;
import com.dfsek.terra.api.generic.world.vector.Vector3;
import com.dfsek.terra.generation.Sampler;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.type.Slab;
import java.util.Map;
public final class SlabUtil {
public static void prepareBlockPartFloor(BlockData down, BlockData orig, ChunkGenerator.ChunkData chunk, Vector3 block, Map<MaterialData, Palette<BlockData>> slabs,
Map<MaterialData, Palette<BlockData>> stairs, double thresh, Sampler sampler) {
/*
if(sampler.sample(block.getBlockX(), block.getBlockY() - 0.4, block.getBlockZ()) > thresh) {
if(stairs != null) {
Palette<BlockData> stairPalette = stairs.get(down.getMaterial());
@@ -32,10 +29,12 @@ public final class SlabUtil {
} else if(orig.matches(PaletteUtil.WATER)) return;
chunk.setBlock(block.getBlockX(), block.getBlockY(), block.getBlockZ(), slab);
}
*/
}
public static void prepareBlockPartCeiling(BlockData up, BlockData orig, ChunkGenerator.ChunkData chunk, Vector3 block, Map<MaterialData, Palette<BlockData>> slabs,
Map<MaterialData, Palette<BlockData>> stairs, double thresh, Sampler sampler) {
/*
if(sampler.sample(block.getBlockX(), block.getBlockY() + 0.4, block.getBlockZ()) > thresh) {
if(stairs != null) {
Palette<BlockData> stairPalette = stairs.get(up.getMaterial());
@@ -54,10 +53,14 @@ public final class SlabUtil {
} else if(orig.matches(PaletteUtil.WATER)) return; // Only replace water if waterlogged.
chunk.setBlock(block.getBlockX(), block.getBlockY(), block.getBlockZ(), slab);
}
*/
}
private static boolean placeStair(BlockData orig, ChunkGenerator.ChunkData chunk, Vector3 block, double thresh, Sampler sampler, Stairs stairNew) {
if(sampler.sample(block.getBlockX() - 0.55, block.getBlockY(), block.getBlockZ()) > thresh) {
/*
if(sampler.sample(block.getBlockX() - 0.55, block.getBlockY(), block.getBlockZ()) > thresh) {
stairNew.setFacing(BlockFace.WEST);
} else if(sampler.sample(block.getBlockX(), block.getBlockY(), block.getBlockZ() - 0.55) > thresh) {
stairNew.setFacing(BlockFace.NORTH);
@@ -71,6 +74,8 @@ public final class SlabUtil {
chunk.setBlock(block.getBlockX(), block.getBlockY(), block.getBlockZ(), stairNew);
return true;
}
*/
return false;
}
}

View File

@@ -1,5 +1,5 @@
name: "Terra"
main: "com.dfsek.terra.api.bukkit.Terra"
main: "com.dfsek.terra.api.bukkit.TerraBukkitPlugin"
version: "@VERSION@"
load: "STARTUP"
api-version: "1.16"