Trees on Bukkit

This commit is contained in:
dfsek
2020-12-14 23:53:01 -07:00
parent 4d59c27a13
commit ee35c371ec
6 changed files with 45 additions and 6 deletions

View File

@@ -15,6 +15,7 @@ public class Cactus extends FractalTree {
main.getWorldHandle().createMaterialData("minecraft:red_sand"));
}
/**
* Instantiates a TreeGrower at an origin location.
*

View File

@@ -23,16 +23,16 @@ public class Transformer<F, T> {
* @return Result
*/
public T translate(F from) {
List<TransformException> exceptions = new ArrayList<>();
List<Exception> exceptions = new ArrayList<>();
for(Transform<F, T> transform : transformer) {
try {
return transform.transform(from);
} catch(TransformException exception) {
} catch(Exception exception) {
exceptions.add(exception);
}
}
StringBuilder exBuilder = new StringBuilder("Could not transform input; all attempts failed: ").append(from.toString()).append("\n");
for(TransformException exception : exceptions) exBuilder.append(exception.getMessage()).append("\n");
for(Exception exception : exceptions) exBuilder.append(exception.getMessage()).append("\n");
throw new AttemptsFailedException(exBuilder.toString());
}

View File

@@ -3,6 +3,7 @@ package com.dfsek.terra.registry;
import com.dfsek.terra.api.gaea.tree.Tree;
import com.dfsek.terra.api.gaea.tree.fractal.FractalTree;
import com.dfsek.terra.api.gaea.tree.fractal.trees.Cactus;
import com.dfsek.terra.api.gaea.tree.fractal.trees.IceSpike;
import com.dfsek.terra.api.gaea.tree.fractal.trees.OakTree;
import com.dfsek.terra.api.gaea.tree.fractal.trees.ShatteredPillar;
import com.dfsek.terra.api.gaea.tree.fractal.trees.ShatteredTree;
@@ -48,6 +49,7 @@ public class TreeRegistry extends TerraRegistry<Tree> {
addTree("SPRUCE");
addTree("SWAMP_OAK");
tryAdd("SMALL_SHATTERED_PILLAR", SmallShatteredPillar.class);
tryAdd("ICE_SPIKE", IceSpike.class);
addTree("TALL_BIRCH");
}
@@ -81,7 +83,6 @@ public class TreeRegistry extends TerraRegistry<Tree> {
public boolean plant(Location l, Random r) {
try {
FractalTree tree = constructor.newInstance(l, r, main);
if(!getSpawnable().contains(l.subtract(0, 1, 0).getBlock().getType())) return false;
tree.grow();
tree.plant();
return true;

View File

@@ -0,0 +1,14 @@
package com.dfsek.terra.util;
public final class StringUtils {
/**
* Strip Minecraft namespace from string
*
* @param in String to strip namespace of
* @return Stripped string/
*/
public static String stripMinecraftNamespace(String in) {
if(!in.startsWith("minecraft:")) return in;
return in.substring(10);
}
}