mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-10-21 15:57:19 +00:00
Look ma, no Bukkit API in the core package
This commit is contained in:
1 parent
7ee1d2c391
commit
5bf699cba9
345 files changed
+1352
-2642
No files matched your search
+13
-10
@@ -14,12 +14,19 @@ plugins {
|
||||
id("com.github.johnrengelman.shadow").version("6.1.0")
|
||||
}
|
||||
|
||||
val versionObj = Version("2", "2", "0", true)
|
||||
|
||||
allprojects {
|
||||
version = versionObj
|
||||
group = "com.dfsek.terra"
|
||||
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") }
|
||||
maven { url = uri("http://maven.enginehub.org/repo/") }
|
||||
maven { url = uri("https://repo.codemc.org/repository/maven-public") }
|
||||
maven { url = uri("https://papermc.io/repo/repository/maven-public/") }
|
||||
maven { url = uri("https://repo.aikar.co/content/groups/aikar/") }
|
||||
}
|
||||
|
||||
java {
|
||||
@@ -27,15 +34,10 @@ java {
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
val versionObj = Version("2", "2", "0", true)
|
||||
|
||||
version = versionObj
|
||||
|
||||
dependencies {
|
||||
implementation("org.apache.commons:commons-rng-core:1.3")
|
||||
implementation("net.jafama:jafama:2.3.2")
|
||||
|
||||
compileOnly("org.jetbrains:annotations:20.1.0")
|
||||
|
||||
implementation("commons-io:commons-io:2.4")
|
||||
implementation("org.apache.commons:commons-imaging:1.0-alpha2")
|
||||
@@ -47,19 +49,20 @@ dependencies {
|
||||
|
||||
implementation("com.scireum:parsii:1.2.1")
|
||||
|
||||
compileOnly("org.spigotmc:spigot-api:1.16.2-R0.1-SNAPSHOT")
|
||||
implementation("io.papermc:paperlib:1.0.5")
|
||||
|
||||
implementation("net.jafama:jafama:2.3.2")
|
||||
|
||||
implementation("com.dfsek:Tectonic:1.0.3")
|
||||
|
||||
|
||||
|
||||
|
||||
// JUnit.
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0")
|
||||
}
|
||||
|
||||
|
||||
|
||||
val compileJava: JavaCompile by tasks
|
||||
val mainSourceSet: SourceSet = sourceSets["main"]
|
||||
|
||||
@@ -168,7 +171,7 @@ val testWithPaper = task<JavaExec>(name = "testWithPaper") {
|
||||
// Copy Terra into dir
|
||||
doFirst {
|
||||
copy {
|
||||
from("${buildDir}/libs/Terra-${versionObj}.jar")
|
||||
from("${project("platforms:bukkit").buildDir}/libs/Terra-${versionObj}.jar")
|
||||
into("${testDir}/plugins/")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
plugins {
|
||||
java
|
||||
maven
|
||||
idea
|
||||
id("com.github.johnrengelman.shadow")
|
||||
}
|
||||
|
||||
group = "com.dfsek.terra.common"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") }
|
||||
maven { url = uri("http://maven.enginehub.org/repo/") }
|
||||
maven { url = uri("https://repo.codemc.org/repository/maven-public") }
|
||||
maven { url = uri("https://papermc.io/repo/repository/maven-public/") }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("org.jetbrains:annotations:20.1.0")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0")
|
||||
implementation("org.apache.commons:commons-rng-core:1.3")
|
||||
implementation("commons-io:commons-io:2.4")
|
||||
|
||||
implementation("com.scireum:parsii:1.2.1")
|
||||
implementation("com.dfsek:Tectonic:1.0.3")
|
||||
implementation("net.jafama:jafama:2.3.2")
|
||||
|
||||
compileOnly("com.googlecode.json-simple:json-simple:1.1")
|
||||
|
||||
implementation("com.google.guava:guava:30.0-jre")
|
||||
}
|
||||
|
||||
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
|
||||
|
||||
archiveClassifier.set("")
|
||||
archiveBaseName.set("Terra")
|
||||
setVersion(project.version)
|
||||
relocate("org.apache.commons", "com.dfsek.terra.lib.commons")
|
||||
relocate("org.bstats.bukkit", "com.dfsek.terra.lib.bstats")
|
||||
relocate("parsii", "com.dfsek.terra.lib.parsii")
|
||||
relocate("io.papermc.lib", "com.dfsek.terra.lib.paperlib")
|
||||
relocate("net.jafama", "com.dfsek.terra.lib.jafama")
|
||||
relocate("com.dfsek.tectonic", "com.dfsek.terra.lib.tectonic")
|
||||
relocate("net.jafama", "com.dfsek.terra.lib.jafama")
|
||||
minimize()
|
||||
}
|
||||
File renamed without changes.
+2
-2
@@ -3,7 +3,6 @@ package com.dfsek.terra;
|
||||
import com.dfsek.terra.api.gaea.biome.BiomeGrid;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.api.implementations.bukkit.generator.BukkitChunkGenerator;
|
||||
import com.dfsek.terra.biome.BiomeZone;
|
||||
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
|
||||
import com.dfsek.terra.biome.grid.master.TerraRadialBiomeGrid;
|
||||
@@ -12,6 +11,7 @@ import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.base.ConfigPackTemplate;
|
||||
import com.dfsek.terra.config.builder.biomegrid.BiomeGridBuilder;
|
||||
import com.dfsek.terra.debug.Debug;
|
||||
import com.dfsek.terra.generation.TerraChunkGenerator;
|
||||
|
||||
public class TerraWorld {
|
||||
private final TerraBiomeGrid grid;
|
||||
@@ -55,7 +55,7 @@ public class TerraWorld {
|
||||
}
|
||||
|
||||
public static boolean isTerraWorld(World w) {
|
||||
return w.getGenerator() instanceof BukkitChunkGenerator;
|
||||
return w.getGenerator() instanceof TerraChunkGenerator;
|
||||
}
|
||||
|
||||
public TerraBiomeGrid getGrid() {
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.dfsek.terra.api;
|
||||
|
||||
import com.dfsek.terra.api.generic.Handle;
|
||||
import com.dfsek.terra.api.generic.world.vector.Location;
|
||||
|
||||
public interface Entity extends Handle {
|
||||
Location getLocation();
|
||||
}
|
||||
-5
@@ -17,7 +17,6 @@ import com.dfsek.terra.config.loaders.config.GridSpawnLoader;
|
||||
import com.dfsek.terra.config.loaders.config.NoiseBuilderLoader;
|
||||
import com.dfsek.terra.config.loaders.config.OreConfigLoader;
|
||||
import com.dfsek.terra.config.loaders.config.OreHolderLoader;
|
||||
import com.dfsek.terra.config.loaders.config.StructureFeatureLoader;
|
||||
import com.dfsek.terra.config.loaders.config.TreeLayerLoader;
|
||||
import com.dfsek.terra.config.loaders.palette.CarverPaletteLoader;
|
||||
import com.dfsek.terra.config.loaders.palette.PaletteHolderLoader;
|
||||
@@ -31,9 +30,7 @@ import com.dfsek.terra.generation.items.ores.OreHolder;
|
||||
import com.dfsek.terra.generation.items.tree.TreeLayer;
|
||||
import com.dfsek.terra.image.ImageLoader;
|
||||
import com.dfsek.terra.procgen.GridSpawn;
|
||||
import com.dfsek.terra.structure.features.Feature;
|
||||
import com.dfsek.terra.util.MaterialSet;
|
||||
import com.dfsek.terra.util.StructureTypeEnum;
|
||||
|
||||
public class GenericLoaders implements LoaderRegistrar {
|
||||
private final TerraPlugin main;
|
||||
@@ -57,10 +54,8 @@ public class GenericLoaders implements LoaderRegistrar {
|
||||
.registerLoader(TreeLayer.class, new TreeLayerLoader(main))
|
||||
.registerLoader(MaterialSet.class, new MaterialSetLoader())
|
||||
.registerLoader(OreHolder.class, new OreHolderLoader())
|
||||
.registerLoader(Feature.class, new StructureFeatureLoader())
|
||||
.registerLoader(ImageLoader.class, new ImageLoaderLoader())
|
||||
.registerLoader(TerraBiomeGrid.Type.class, (t, o, l) -> TerraBiomeGrid.Type.valueOf((String) o))
|
||||
.registerLoader(StructureTypeEnum.class, (t, o, l) -> StructureTypeEnum.valueOf((String) o))
|
||||
.registerLoader(ImageLoader.Channel.class, (t, o, l) -> ImageLoader.Channel.valueOf((String) o))
|
||||
.registerLoader(ImageLoader.Align.class, (t, o, l) -> ImageLoader.Align.valueOf((String) o))
|
||||
.registerLoader(TerraFlora.Search.class, (t, o, l) -> TerraFlora.Search.valueOf((String) o));
|
||||
File renamed without changes.
@@ -0,0 +1,4 @@
|
||||
package com.dfsek.terra.api;
|
||||
|
||||
public interface Player extends Entity {
|
||||
}
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
package com.dfsek.terra.api.gaea;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
|
||||
public class Debug {
|
||||
public static JavaPlugin main;
|
||||
public static TerraPlugin main;
|
||||
|
||||
public static void setMain(JavaPlugin main) {
|
||||
public static void setMain(TerraPlugin main) {
|
||||
Debug.main = main;
|
||||
}
|
||||
|
||||
File renamed without changes.
+2
-1
@@ -1,6 +1,7 @@
|
||||
package com.dfsek.terra.api.gaea.biome;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
|
||||
/**
|
||||
* Interface to be implemented by a custom generator's Biome enum.<br>
|
||||
File renamed without changes.
-2
@@ -13,8 +13,6 @@ public abstract class Decorator {
|
||||
|
||||
public abstract boolean overrideStructureChance();
|
||||
|
||||
public abstract org.bukkit.block.Biome getVanillaBiome();
|
||||
|
||||
public abstract ProbabilityCollection<Flora> getFlora();
|
||||
|
||||
public abstract int getFloraChance();
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+6
-9
@@ -1,8 +1,7 @@
|
||||
package com.dfsek.terra.api.gaea.lang;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.dfsek.terra.api.generic.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
@@ -11,17 +10,15 @@ import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class Language extends YamlConfiguration {
|
||||
public Language(File file) throws IOException, InvalidConfigurationException {
|
||||
public class Language {
|
||||
public Language(File file) throws IOException {
|
||||
load(file);
|
||||
}
|
||||
@Override
|
||||
public void load(@NotNull File file) throws IOException, InvalidConfigurationException {
|
||||
super.load(file);
|
||||
public void load(@NotNull File file) throws IOException {
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public Message getMessage(String id) {
|
||||
Object m = get(id);
|
||||
Object m = null;
|
||||
Message temp;
|
||||
if(m instanceof List) {
|
||||
temp = new MultiLineMessage((List<String>) m);
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package com.dfsek.terra.api.gaea.lang;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.dfsek.terra.api.generic.CommandSender;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
+3
-4
@@ -1,7 +1,6 @@
|
||||
package com.dfsek.terra.api.gaea.lang;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.dfsek.terra.api.generic.CommandSender;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -16,14 +15,14 @@ public class MultiLineMessage implements Message {
|
||||
@Override
|
||||
public void log(Logger logger, Level level, String... args) {
|
||||
for(String line: message) {
|
||||
logger.log(level, ChatColor.translateAlternateColorCodes('&', String.format(line, Arrays.asList(args).toArray())));
|
||||
logger.log(level, String.format(line, Arrays.asList(args).toArray()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(CommandSender sender, String... args) {
|
||||
for(String line: message) {
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', String.format(line, Arrays.asList(args).toArray())));
|
||||
sender.sendMessage(String.format(line, Arrays.asList(args).toArray()));
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.api.gaea.lang;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.dfsek.terra.api.generic.CommandSender;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Level;
|
||||
@@ -14,12 +14,12 @@ public class SingleLineMessage implements Message {
|
||||
}
|
||||
@Override
|
||||
public void log(Logger logger, Level level, String... args) {
|
||||
logger.log(level, ChatColor.translateAlternateColorCodes('&', String.format(message, Arrays.asList(args).toArray())));
|
||||
logger.log(level, String.format(message, Arrays.asList(args).toArray()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(CommandSender sender, String... args) {
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', String.format(message, Arrays.asList(args).toArray())));
|
||||
sender.sendMessage(String.format(message, Arrays.asList(args).toArray()));
|
||||
}
|
||||
|
||||
@Override
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-10
@@ -1,8 +1,5 @@
|
||||
package com.dfsek.terra.api.gaea.profiler;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
/**
|
||||
* Class to hold a profiler data value. Contains formatting method to highlight value based on desired range.
|
||||
*/
|
||||
@@ -34,12 +31,6 @@ public class DataHolder {
|
||||
* @return String - The formatted data.
|
||||
*/
|
||||
public String getFormattedData(long data) {
|
||||
double range = desiredRangePercent * desired;
|
||||
ChatColor color = ChatColor.YELLOW;
|
||||
if(FastMath.abs(data - desired) > range) {
|
||||
if(data > desired) color = type.getDesire().getHighColor();
|
||||
else color = type.getDesire().getLowColor();
|
||||
}
|
||||
return color + type.getFormatted(data) + ChatColor.RESET;
|
||||
return type.getFormatted(data);
|
||||
}
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,10 @@
|
||||
package com.dfsek.terra.api.gaea.profiler;
|
||||
|
||||
|
||||
/**
|
||||
* Enum to represent the "goal" of a value, whether it is desirable for the value to be high (e.g. Frequency), or low (e.g. Period)
|
||||
*/
|
||||
public enum Desire {
|
||||
LOW, HIGH
|
||||
|
||||
}
|
||||
-2
@@ -3,7 +3,6 @@ package com.dfsek.terra.api.gaea.profiler;
|
||||
import com.dfsek.terra.api.gaea.math.MathUtil;
|
||||
import com.dfsek.terra.api.gaea.util.GlueList;
|
||||
import net.jafama.FastMath;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.List;
|
||||
@@ -33,7 +32,6 @@ public class Measurement {
|
||||
public void record(long value) {
|
||||
max = FastMath.max(value, max);
|
||||
min = FastMath.min(value, min);
|
||||
if(value / 1000000 > 5000) Bukkit.getLogger().warning("Measurement took " + type.getFormatted(value));
|
||||
measurements.add(value);
|
||||
}
|
||||
|
||||
File renamed without changes.
+5
-12
@@ -1,12 +1,9 @@
|
||||
package com.dfsek.terra.api.gaea.profiler;
|
||||
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.api.implementations.bukkit.generator.BukkitChunkGenerator;
|
||||
import com.dfsek.terra.api.implementations.bukkit.generator.BukkitChunkGeneratorWrapper;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import net.jafama.FastMath;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -16,7 +13,7 @@ public class WorldProfiler {
|
||||
private boolean isProfiling;
|
||||
|
||||
public WorldProfiler(World w) {
|
||||
if(!(w.getGenerator() instanceof BukkitChunkGenerator))
|
||||
if(w.getGenerator().getTerraGenerator() == null)
|
||||
throw new IllegalArgumentException("Attempted to instantiate profiler on non-Gaea managed world!");
|
||||
this.addMeasurement(new Measurement(2500000, DataType.PERIOD_MILLISECONDS), "TotalChunkGenTime")
|
||||
.addMeasurement(new Measurement(2500000, DataType.PERIOD_MILLISECONDS), "ChunkBaseGenTime")
|
||||
@@ -24,29 +21,25 @@ public class WorldProfiler {
|
||||
.addMeasurement(new Measurement(2000000, DataType.PERIOD_MILLISECONDS), "PopulationManagerTime");
|
||||
isProfiling = false;
|
||||
this.world = w;
|
||||
((BukkitChunkGeneratorWrapper) ((BukkitChunkGenerator) w.getGenerator()).getHandle()).getDelegate().attachProfiler(this);
|
||||
w.getGenerator().getTerraGenerator().attachProfiler(this);
|
||||
}
|
||||
|
||||
public String getResultsFormatted() {
|
||||
if(! isProfiling) return "Profiler is not currently running.";
|
||||
StringBuilder result = new StringBuilder(ChatColor.GOLD + "Gaea World Profiler Results (Min / Avg / Max / Std Dev): \n");
|
||||
StringBuilder result = new StringBuilder("Gaea World Profiler Results (Min / Avg / Max / Std Dev): \n");
|
||||
for(Map.Entry<String, Measurement> e : measures.entrySet()) {
|
||||
result.append(ChatColor.GOLD)
|
||||
result
|
||||
.append(e.getKey())
|
||||
.append(": ")
|
||||
.append(e.getValue().getDataHolder().getFormattedData(e.getValue().getMin()))
|
||||
.append(ChatColor.GOLD)
|
||||
.append(" / ")
|
||||
.append(e.getValue().getDataHolder().getFormattedData(e.getValue().average()))
|
||||
.append(ChatColor.GOLD)
|
||||
.append(" / ")
|
||||
.append(e.getValue().getDataHolder().getFormattedData(e.getValue().getMax()))
|
||||
.append(ChatColor.GOLD)
|
||||
.append(" / ")
|
||||
.append(ChatColor.GREEN)
|
||||
.append((double) FastMath.round((e.getValue().getStdDev() / 1000000) * 100D) / 100D)
|
||||
.append("ms")
|
||||
.append(ChatColor.GOLD).append(" (x").append(e.getValue().size()).append(")\n");
|
||||
.append(" (x").append(e.getValue().size()).append(")\n");
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
File renamed without changes.
+9
-17
@@ -2,12 +2,12 @@ package com.dfsek.terra.api.gaea.structures.loot;
|
||||
|
||||
import com.dfsek.terra.api.gaea.structures.loot.functions.AmountFunction;
|
||||
import com.dfsek.terra.api.gaea.structures.loot.functions.DamageFunction;
|
||||
import com.dfsek.terra.api.gaea.structures.loot.functions.EnchantWithLevelsFunction;
|
||||
import com.dfsek.terra.api.gaea.structures.loot.functions.Function;
|
||||
import com.dfsek.terra.api.gaea.util.GlueList;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.api.generic.inventory.ItemStack;
|
||||
import com.dfsek.terra.api.generic.world.block.MaterialData;
|
||||
import net.jafama.FastMath;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
@@ -18,19 +18,20 @@ import java.util.Random;
|
||||
* Representation of a single item entry within a Loot Table pool.
|
||||
*/
|
||||
public class Entry {
|
||||
private final Material item;
|
||||
private final MaterialData item;
|
||||
private final long weight;
|
||||
private final List<Function> functions = new GlueList<>();
|
||||
private final TerraPlugin main;
|
||||
|
||||
/**
|
||||
* Instantiates an Entry from a JSON representation.
|
||||
*
|
||||
* @param entry The JSON Object to instantiate from.
|
||||
*/
|
||||
public Entry(JSONObject entry) {
|
||||
|
||||
public Entry(JSONObject entry, TerraPlugin main) {
|
||||
this.main = main;
|
||||
String id = entry.get("name").toString();
|
||||
this.item = Material.matchMaterial(id);
|
||||
this.item = main.getWorldHandle().createMaterialData(id);
|
||||
|
||||
long weight1;
|
||||
try {
|
||||
@@ -62,15 +63,6 @@ public class Entry {
|
||||
long minDamage = (long) ((JSONObject) ((JSONObject) function).get("damage")).get("min");
|
||||
functions.add(new DamageFunction(FastMath.toIntExact(minDamage), FastMath.toIntExact(maxDamage)));
|
||||
break;
|
||||
case "minecraft:enchant_with_levels":
|
||||
case "enchant_with_levels":
|
||||
long maxEnchant = (long) ((JSONObject) ((JSONObject) function).get("levels")).get("max");
|
||||
long minEnchant = (long) ((JSONObject) ((JSONObject) function).get("levels")).get("min");
|
||||
JSONArray disabled = null;
|
||||
if(((JSONObject) function).containsKey("disabled_enchants"))
|
||||
disabled = (JSONArray) ((JSONObject) function).get("disabled_enchants");
|
||||
functions.add(new EnchantWithLevelsFunction(FastMath.toIntExact(minEnchant), FastMath.toIntExact(maxEnchant), disabled));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,7 +75,7 @@ public class Entry {
|
||||
* @return ItemStack - The ItemStack with all functions applied.
|
||||
*/
|
||||
public ItemStack getItem(Random r) {
|
||||
ItemStack item = new ItemStack(this.item, 1);
|
||||
ItemStack item = main.getItemHandle().newItemStack(this.item, 1);
|
||||
for(Function f : functions) {
|
||||
item = f.apply(item, r);
|
||||
}
|
||||
+6
-5
@@ -1,8 +1,9 @@
|
||||
package com.dfsek.terra.api.gaea.structures.loot;
|
||||
|
||||
import com.dfsek.terra.api.gaea.util.GlueList;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.api.generic.inventory.Inventory;
|
||||
import com.dfsek.terra.api.generic.inventory.ItemStack;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
@@ -23,12 +24,12 @@ public class LootTable {
|
||||
* @param json The JSON String representing the loot table.
|
||||
* @throws ParseException if malformed JSON is passed.
|
||||
*/
|
||||
public LootTable(String json) throws ParseException {
|
||||
public LootTable(String json, TerraPlugin main) throws ParseException {
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
Object tableJSON = jsonParser.parse(json);
|
||||
JSONArray poolArray = (JSONArray) ((JSONObject) tableJSON).get("pools");
|
||||
for(Object pool : poolArray) {
|
||||
pools.add(new Pool((JSONObject) pool));
|
||||
pools.add(new Pool((JSONObject) pool, main));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +65,7 @@ public class LootTable {
|
||||
if(slotItem == null) {
|
||||
i.setItem(slot, newStack);
|
||||
stack.setAmount(stack.getAmount() - 1);
|
||||
} else if(slotItem.getType() == newStack.getType()) {
|
||||
} else if(slotItem.getType().equals(newStack.getType())) {
|
||||
ItemStack dep = newStack.clone();
|
||||
dep.setAmount(newStack.getAmount() + slotItem.getAmount());
|
||||
i.setItem(slot, dep);
|
||||
+6
-4
@@ -2,8 +2,9 @@ package com.dfsek.terra.api.gaea.structures.loot;
|
||||
|
||||
import com.dfsek.terra.api.gaea.math.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.gaea.util.GlueList;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.api.generic.inventory.ItemStack;
|
||||
import net.jafama.FastMath;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
@@ -16,14 +17,15 @@ import java.util.Random;
|
||||
public class Pool {
|
||||
private final int max;
|
||||
private final int min;
|
||||
private final ProbabilityCollection<Entry> entries = new ProbabilityCollection<>();
|
||||
private final ProbabilityCollection<Entry> entries;
|
||||
|
||||
/**
|
||||
* Instantiates a Pool from a JSON representation.
|
||||
*
|
||||
* @param pool The JSON Object to instantiate from.
|
||||
*/
|
||||
public Pool(JSONObject pool) {
|
||||
public Pool(JSONObject pool, TerraPlugin main) {
|
||||
entries = new ProbabilityCollection<>();
|
||||
Object amount = pool.get("rolls");
|
||||
if(amount instanceof Long) {
|
||||
max = FastMath.toIntExact((Long) amount);
|
||||
@@ -34,7 +36,7 @@ public class Pool {
|
||||
}
|
||||
|
||||
for(Object entryJSON : (JSONArray) pool.get("entries")) {
|
||||
Entry entry = new Entry((JSONObject) entryJSON);
|
||||
Entry entry = new Entry((JSONObject) entryJSON, main);
|
||||
entries.add(entry, FastMath.toIntExact(entry.getWeight()));
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package com.dfsek.terra.api.gaea.structures.loot.functions;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.dfsek.terra.api.generic.inventory.ItemStack;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
package com.dfsek.terra.api.gaea.structures.loot.functions;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import com.dfsek.terra.api.generic.inventory.ItemStack;
|
||||
import com.dfsek.terra.api.generic.inventory.item.Damageable;
|
||||
import com.dfsek.terra.api.generic.inventory.item.ItemMeta;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package com.dfsek.terra.api.gaea.structures.loot.functions;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.dfsek.terra.api.generic.inventory.ItemStack;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
File renamed without changes.
+3
-2
@@ -1,8 +1,9 @@
|
||||
package com.dfsek.terra.api.gaea.tree.fractal;
|
||||
|
||||
import com.dfsek.terra.api.generic.Entity;
|
||||
import com.dfsek.terra.api.generic.world.vector.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.util.Consumer;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
||||
public class EntitySpawnHolder {
|
||||
+14
-14
@@ -1,20 +1,18 @@
|
||||
package com.dfsek.terra.api.gaea.tree.fractal;
|
||||
|
||||
import com.dfsek.terra.api.gaea.util.GlueList;
|
||||
import com.dfsek.terra.api.generic.Entity;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
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 com.dfsek.terra.api.implementations.bukkit.world.block.BukkitBlockData;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.util.Consumer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
||||
public abstract class FractalTree {
|
||||
@@ -22,9 +20,7 @@ public abstract class FractalTree {
|
||||
private final List<EntitySpawnHolder> entities = new GlueList<>();
|
||||
private final Location origin;
|
||||
private final Random random;
|
||||
private final List<Material> replaceable = Arrays.asList(Material.AIR, Material.GRASS_BLOCK, Material.DIRT, Material.STONE, Material.COARSE_DIRT, Material.GRAVEL, Material.PODZOL,
|
||||
Material.GRASS, Material.TALL_GRASS, Material.FERN, Material.POPPY, Material.LARGE_FERN, Material.BLUE_ORCHID, Material.AZURE_BLUET, Material.END_STONE, Material.SNOW, Material.SAND, Material.STONE_BUTTON, Material.DEAD_BUSH);
|
||||
|
||||
private final TerraPlugin main;
|
||||
|
||||
/**
|
||||
* Instantiates a TreeGrower at an origin location.
|
||||
@@ -32,9 +28,10 @@ public abstract class FractalTree {
|
||||
* @param origin - The origin location.
|
||||
* @param random - The random object to use whilst generating the tree.
|
||||
*/
|
||||
public FractalTree(Location origin, Random random) {
|
||||
public FractalTree(Location origin, Random random, TerraPlugin plugin) {
|
||||
this.origin = origin.add(0, 1, 0);
|
||||
this.random = random;
|
||||
this.main = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,8 +68,12 @@ public abstract class FractalTree {
|
||||
* @param l - The location to set.
|
||||
* @param m - The material to which it will be set.
|
||||
*/
|
||||
public void setBlock(Location l, Material m) {
|
||||
treeAssembler.put(l, new BukkitBlockData(m.createBlockData()));
|
||||
public void setBlock(Location l, BlockData m) {
|
||||
treeAssembler.put(l, m);
|
||||
}
|
||||
|
||||
public TerraPlugin getMain() {
|
||||
return main;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,8 +87,7 @@ public abstract class FractalTree {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void plant() {
|
||||
for(Map.Entry<Location, BlockData> entry : treeAssembler.entrySet()) {
|
||||
if(replaceable.contains(entry.getKey().getBlock().getType()))
|
||||
entry.getKey().getBlock().setBlockData(entry.getValue(), false);
|
||||
entry.getKey().getBlock().setBlockData(entry.getValue(), false);
|
||||
}
|
||||
for(EntitySpawnHolder e : entities) {
|
||||
Objects.requireNonNull(e.getLocation().getWorld()).spawn(e.getLocation(), e.getEntity(), e.getConsumer());
|
||||
@@ -107,7 +107,7 @@ public abstract class FractalTree {
|
||||
* @return Material - The material at the specified block.
|
||||
*/
|
||||
public MaterialData getMaterial(Location l) {
|
||||
return treeAssembler.getOrDefault(l, new BukkitBlockData(Material.AIR.createBlockData())).getMaterial();
|
||||
return treeAssembler.getOrDefault(l, main.getWorldHandle().createBlockData("minecraft:air")).getMaterial();
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -1,9 +1,9 @@
|
||||
package com.dfsek.terra.api.gaea.tree.fractal;
|
||||
|
||||
import com.dfsek.terra.api.gaea.math.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
import com.dfsek.terra.api.generic.world.vector.Location;
|
||||
import com.dfsek.terra.api.generic.world.vector.Vector3;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class TreeGeometry {
|
||||
private final FractalTree tree;
|
||||
@@ -20,15 +20,15 @@ public class TreeGeometry {
|
||||
return tree;
|
||||
}
|
||||
|
||||
public void generateSphere(Location l, Material m, int radius, boolean overwrite) {
|
||||
generateSphere(l, new ProbabilityCollection<Material>().add(m, 1), radius, overwrite);
|
||||
public void generateSphere(Location l, BlockData m, int radius, boolean overwrite) {
|
||||
generateSphere(l, new ProbabilityCollection<BlockData>().add(m, 1), radius, overwrite);
|
||||
}
|
||||
|
||||
public void generateCylinder(Location l, Material m, int radius, int height, boolean overwrite) {
|
||||
generateCylinder(l, new ProbabilityCollection<Material>().add(m, 1), radius, height, overwrite);
|
||||
public void generateCylinder(Location l, BlockData m, int radius, int height, boolean overwrite) {
|
||||
generateCylinder(l, new ProbabilityCollection<BlockData>().add(m, 1), radius, height, overwrite);
|
||||
}
|
||||
|
||||
public void generateSphere(Location l, ProbabilityCollection<Material> m, int radius, boolean overwrite) {
|
||||
public void generateSphere(Location l, ProbabilityCollection<BlockData> m, int radius, boolean overwrite) {
|
||||
for(int x = - radius; x <= radius; x++) {
|
||||
for(int y = - radius; y <= radius; y++) {
|
||||
for(int z = - radius; z <= radius; z++) {
|
||||
@@ -40,7 +40,7 @@ public class TreeGeometry {
|
||||
}
|
||||
}
|
||||
|
||||
public void generateSponge(Location l, ProbabilityCollection<Material> m, int radius, boolean overwrite, int sponginess) {
|
||||
public void generateSponge(Location l, ProbabilityCollection<BlockData> m, int radius, boolean overwrite, int sponginess) {
|
||||
for(int x = - radius; x <= radius; x++) {
|
||||
for(int y = - radius; y <= radius; y++) {
|
||||
for(int z = - radius; z <= radius; z++) {
|
||||
@@ -52,7 +52,7 @@ public class TreeGeometry {
|
||||
}
|
||||
}
|
||||
|
||||
public void generateCylinder(Location l, ProbabilityCollection<Material> m, int radius, int height, boolean overwrite) {
|
||||
public void generateCylinder(Location l, ProbabilityCollection<BlockData> m, int radius, int height, boolean overwrite) {
|
||||
for(int x = - radius; x <= radius; x++) {
|
||||
for(int y = 0; y <= height; y++) {
|
||||
for(int z = - radius; z <= radius; z++) {
|
||||
+6
-4
@@ -1,8 +1,9 @@
|
||||
package com.dfsek.terra.api.gaea.tree.fractal.trees;
|
||||
|
||||
import com.dfsek.terra.api.gaea.tree.fractal.FractalTree;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
import com.dfsek.terra.api.generic.world.vector.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -13,8 +14,8 @@ public class Cactus extends FractalTree {
|
||||
* @param origin - The origin location.
|
||||
* @param random - The random object to use whilst generating the tree.
|
||||
*/
|
||||
public Cactus(Location origin, Random random) {
|
||||
super(origin, random);
|
||||
public Cactus(Location origin, Random random, TerraPlugin main) {
|
||||
super(origin, random, main);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -22,7 +23,8 @@ public class Cactus extends FractalTree {
|
||||
*/
|
||||
@Override
|
||||
public void grow() {
|
||||
BlockData cactus = getMain().getWorldHandle().createBlockData("minecraft:cactus");
|
||||
int h = super.getRandom().nextInt(4) + 1;
|
||||
for(int i = 0; i < h; i++) setBlock(super.getOrigin().clone().add(0, i, 0), Material.CACTUS);
|
||||
for(int i = 0; i < h; i++) setBlock(super.getOrigin().clone().add(0, i, 0), cactus);
|
||||
}
|
||||
}
|
||||
+8
-4
@@ -3,16 +3,18 @@ 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.TerraPlugin;
|
||||
import com.dfsek.terra.api.generic.world.WorldHandle;
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
import com.dfsek.terra.api.generic.world.vector.Location;
|
||||
import com.dfsek.terra.api.generic.world.vector.Vector3;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
public class IceSpike extends FractalTree {
|
||||
private final TreeGeometry geo;
|
||||
private static final ProbabilityCollection<Material> ice = new ProbabilityCollection<Material>().add(Material.PACKED_ICE, 95).add(Material.BLUE_ICE, 5);
|
||||
private final ProbabilityCollection<BlockData> ice;
|
||||
|
||||
/**
|
||||
* Instantiates a TreeGrower at an origin location.
|
||||
@@ -20,9 +22,11 @@ public class IceSpike extends FractalTree {
|
||||
* @param origin - The origin location.
|
||||
* @param random - The random object to use whilst generating the tree.
|
||||
*/
|
||||
public IceSpike(Location origin, Random random) {
|
||||
super(origin, random);
|
||||
public IceSpike(Location origin, Random random, TerraPlugin main) {
|
||||
super(origin, random, main);
|
||||
geo = new TreeGeometry(this);
|
||||
WorldHandle handle = main.getWorldHandle();
|
||||
ice = new ProbabilityCollection<BlockData>().add(handle.createBlockData("minecraft:packed_ice"), 95).add(handle.createBlockData("minecraft:blue_ice"), 5);
|
||||
}
|
||||
|
||||
private double getOffset() {
|
||||
+8
-5
@@ -2,10 +2,11 @@ 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.TerraPlugin;
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
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.Material;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -19,8 +20,8 @@ public class OakTree extends FractalTree {
|
||||
* @param origin - The origin location.
|
||||
* @param random - The random object to use whilst generating the tree.
|
||||
*/
|
||||
public OakTree(Location origin, Random random) {
|
||||
super(origin, random);
|
||||
public OakTree(Location origin, Random random, TerraPlugin main) {
|
||||
super(origin, random, main);
|
||||
geo = new TreeGeometry(this);
|
||||
}
|
||||
|
||||
@@ -33,14 +34,16 @@ public class OakTree extends FractalTree {
|
||||
}
|
||||
|
||||
private void growBranch(Location l1, Vector3 diff, double d1, int recursions) {
|
||||
BlockData wood = getMain().getWorldHandle().createBlockData("minecraft:oak_wood");
|
||||
BlockData leaves = getMain().getWorldHandle().createBlockData("minecraft:oak_leave");
|
||||
if(recursions > 1) {
|
||||
geo.generateSphere(l1, Material.OAK_LEAVES, 1 + super.getRandom().nextInt(2) + (3 - recursions), false);
|
||||
geo.generateSphere(l1, leaves, 1 + super.getRandom().nextInt(2) + (3 - recursions), false);
|
||||
if(recursions > 2) return;
|
||||
}
|
||||
if(diff.getY() < 0) diff.rotateAroundAxis(TreeGeometry.getPerpendicular(diff.clone()).normalize(), FastMath.PI);
|
||||
int d = (int) diff.length();
|
||||
for(int i = 0; i < d; i++) {
|
||||
geo.generateSphere(l1.clone().add(diff.clone().multiply((double) i / d)), Material.OAK_WOOD, FastMath.max((int) d1, 0), true);
|
||||
geo.generateSphere(l1.clone().add(diff.clone().multiply((double) i / d)), wood, FastMath.max((int) d1, 0), true);
|
||||
}
|
||||
double runningAngle = (double) 45 / (recursions + 1);
|
||||
growBranch(l1.clone().add(diff), diff.clone().multiply(0.75).rotateAroundX(FastMath.toRadians(runningAngle + getNoise())).rotateAroundZ(FastMath.toRadians(getNoise())),
|
||||
+9
-11
@@ -1,9 +1,9 @@
|
||||
package com.dfsek.terra.api.gaea.tree.fractal.trees;
|
||||
|
||||
import com.dfsek.terra.api.gaea.tree.fractal.FractalTree;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
import com.dfsek.terra.api.generic.world.vector.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EnderCrystal;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -14,8 +14,8 @@ public class ShatteredPillar extends FractalTree {
|
||||
* @param origin - The origin location.
|
||||
* @param random - The random object to use whilst generating the tree.
|
||||
*/
|
||||
public ShatteredPillar(Location origin, Random random) {
|
||||
super(origin, random);
|
||||
public ShatteredPillar(Location origin, Random random, TerraPlugin main) {
|
||||
super(origin, random, main);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -23,30 +23,28 @@ public class ShatteredPillar extends FractalTree {
|
||||
*/
|
||||
@Override
|
||||
public void grow() {
|
||||
BlockData obsidian = getMain().getWorldHandle().createBlockData("minecraft:obsidian");
|
||||
int h = super.getRandom().nextInt(5) + 8;
|
||||
int max = h;
|
||||
for(int i = - h; i < h; i++) setBlock(super.getOrigin().clone().add(0, i, 0), Material.OBSIDIAN);
|
||||
for(int i = - h; i < h; i++) setBlock(super.getOrigin().clone().add(0, i, 0), obsidian);
|
||||
h = h + (getRandom().nextBoolean() ? getRandom().nextInt(3) + 1 : - (getRandom().nextInt(3) + 1));
|
||||
int[] crystalLoc = new int[] {0, 0};
|
||||
if(h > max) {
|
||||
max = h;
|
||||
crystalLoc = new int[] {1, 0};
|
||||
}
|
||||
for(int i = - h; i < h; i++) setBlock(super.getOrigin().clone().add(1, i, 0), Material.OBSIDIAN);
|
||||
for(int i = - h; i < h; i++) setBlock(super.getOrigin().clone().add(1, i, 0), obsidian);
|
||||
h = h + (getRandom().nextBoolean() ? getRandom().nextInt(3) + 1 : - (getRandom().nextInt(3) + 1));
|
||||
if(h > max) {
|
||||
max = h;
|
||||
crystalLoc = new int[] {0, 1};
|
||||
}
|
||||
for(int i = - h; i < h; i++) setBlock(super.getOrigin().clone().add(0, i, 1), Material.OBSIDIAN);
|
||||
for(int i = - h; i < h; i++) setBlock(super.getOrigin().clone().add(0, i, 1), obsidian);
|
||||
h = h + (getRandom().nextBoolean() ? getRandom().nextInt(3) + 1 : - (getRandom().nextInt(3) + 1));
|
||||
if(h > max) {
|
||||
max = h;
|
||||
crystalLoc = new int[] {1, 1};
|
||||
}
|
||||
for(int i = - h; i < h; i++) setBlock(super.getOrigin().clone().add(1, i, 1), Material.OBSIDIAN);
|
||||
if(getRandom().nextInt(100) < 25)
|
||||
spawnEntity(getOrigin().add(crystalLoc[0] + 0.5, max, crystalLoc[1] + 0.5), EnderCrystal.class,
|
||||
enderCrystal -> ((EnderCrystal) enderCrystal).setShowingBottom(false));
|
||||
for(int i = - h; i < h; i++) setBlock(super.getOrigin().clone().add(1, i, 1), obsidian);
|
||||
}
|
||||
}
|
||||
+15
-9
@@ -3,21 +3,19 @@ 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.TerraPlugin;
|
||||
import com.dfsek.terra.api.generic.world.WorldHandle;
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
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.Material;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class ShatteredTree extends FractalTree {
|
||||
private final TreeGeometry geo;
|
||||
private final ProbabilityCollection<Material> bark = new ProbabilityCollection<Material>()
|
||||
.add(Material.OBSIDIAN, 1)
|
||||
.add(Material.BLACK_CONCRETE, 1);
|
||||
private final ProbabilityCollection<Material> leaves = new ProbabilityCollection<Material>()
|
||||
.add(Material.PURPLE_STAINED_GLASS, 1)
|
||||
.add(Material.MAGENTA_STAINED_GLASS, 1);
|
||||
private final ProbabilityCollection<BlockData> bark;
|
||||
private final ProbabilityCollection<BlockData> leaves;
|
||||
|
||||
/**
|
||||
* Instantiates a TreeGrower at an origin location.
|
||||
@@ -25,9 +23,17 @@ public class ShatteredTree extends FractalTree {
|
||||
* @param origin - The origin location.
|
||||
* @param random - The random object to use whilst generating the tree.
|
||||
*/
|
||||
public ShatteredTree(Location origin, Random random) {
|
||||
super(origin, random);
|
||||
public ShatteredTree(Location origin, Random random, TerraPlugin main) {
|
||||
super(origin, random, main);
|
||||
geo = new TreeGeometry(this);
|
||||
WorldHandle handle = main.getWorldHandle();
|
||||
|
||||
bark = new ProbabilityCollection<BlockData>()
|
||||
.add(handle.createBlockData("minecraft:obsidian"), 1)
|
||||
.add(handle.createBlockData("minecraft:black_concrete"), 1);
|
||||
leaves = new ProbabilityCollection<BlockData>()
|
||||
.add(handle.createBlockData("minecraft:purple_stained_glass"), 1)
|
||||
.add(handle.createBlockData("minecraft:magenta_stained_glass"), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
+6
-4
@@ -1,8 +1,9 @@
|
||||
package com.dfsek.terra.api.gaea.tree.fractal.trees;
|
||||
|
||||
import com.dfsek.terra.api.gaea.tree.fractal.FractalTree;
|
||||
import com.dfsek.terra.api.generic.TerraPlugin;
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
import com.dfsek.terra.api.generic.world.vector.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -13,8 +14,8 @@ public class SmallShatteredPillar extends FractalTree {
|
||||
* @param origin - The origin location.
|
||||
* @param random - The random object to use whilst generating the tree.
|
||||
*/
|
||||
public SmallShatteredPillar(Location origin, Random random) {
|
||||
super(origin, random);
|
||||
public SmallShatteredPillar(Location origin, Random random, TerraPlugin main) {
|
||||
super(origin, random, main);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -23,6 +24,7 @@ public class SmallShatteredPillar extends FractalTree {
|
||||
@Override
|
||||
public void grow() {
|
||||
int h = super.getRandom().nextInt(5) + 5;
|
||||
for(int i = - h; i < h; i++) setBlock(super.getOrigin().clone().add(0, i, 0), Material.OBSIDIAN);
|
||||
BlockData obsidian = getMain().getWorldHandle().createBlockData("minecraft:obsidian");
|
||||
for(int i = - h; i < h; i++) setBlock(super.getOrigin().clone().add(0, i, 0), obsidian);
|
||||
}
|
||||
}
|
||||
+15
-9
@@ -3,21 +3,19 @@ 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.TerraPlugin;
|
||||
import com.dfsek.terra.api.generic.world.WorldHandle;
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
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.Material;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class SmallShatteredTree extends FractalTree {
|
||||
private final TreeGeometry geo;
|
||||
private final ProbabilityCollection<Material> bark = new ProbabilityCollection<Material>()
|
||||
.add(Material.OBSIDIAN, 1)
|
||||
.add(Material.BLACK_CONCRETE, 1);
|
||||
private final ProbabilityCollection<Material> leaves = new ProbabilityCollection<Material>()
|
||||
.add(Material.PURPLE_STAINED_GLASS, 1)
|
||||
.add(Material.MAGENTA_STAINED_GLASS, 1);
|
||||
private final ProbabilityCollection<BlockData> bark;
|
||||
private final ProbabilityCollection<BlockData> leaves;
|
||||
|
||||
/**
|
||||
* Instantiates a TreeGrower at an origin location.
|
||||
@@ -25,9 +23,17 @@ public class SmallShatteredTree extends FractalTree {
|
||||
* @param origin - The origin location.
|
||||
* @param random - The random object to use whilst generating the tree.
|
||||
*/
|
||||
public SmallShatteredTree(Location origin, Random random) {
|
||||
super(origin, random);
|
||||
public SmallShatteredTree(Location origin, Random random, TerraPlugin main) {
|
||||
super(origin, random, main);
|
||||
geo = new TreeGeometry(this);
|
||||
|
||||
WorldHandle handle = main.getWorldHandle();
|
||||
bark = new ProbabilityCollection<BlockData>()
|
||||
.add(handle.createBlockData("minecraft:obsidian"), 1)
|
||||
.add(handle.createBlockData("minecraft:black_concrete"), 1);
|
||||
leaves = new ProbabilityCollection<BlockData>()
|
||||
.add(handle.createBlockData("minecraft:purple_stained_glass"), 1)
|
||||
.add(handle.createBlockData("minecraft:magenta_stained_glass"), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
+10
-7
@@ -2,10 +2,11 @@ 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.TerraPlugin;
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
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.Material;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -18,8 +19,8 @@ public class SpruceTree extends FractalTree {
|
||||
* @param origin - The origin location.
|
||||
* @param random - The random object to use whilst generating the tree.
|
||||
*/
|
||||
public SpruceTree(Location origin, Random random) {
|
||||
super(origin, random);
|
||||
public SpruceTree(Location origin, Random random, TerraPlugin main) {
|
||||
super(origin, random, main);
|
||||
geo = new TreeGeometry(this);
|
||||
}
|
||||
|
||||
@@ -35,12 +36,14 @@ public class SpruceTree extends FractalTree {
|
||||
if(diff.getY() < 0) diff.rotateAroundAxis(TreeGeometry.getPerpendicular(diff.clone()).normalize(), FastMath.PI);
|
||||
int d = (int) diff.length();
|
||||
int rad = 7;
|
||||
BlockData wood = getMain().getWorldHandle().createBlockData("minecraft:spruce_wood");
|
||||
BlockData leaves = getMain().getWorldHandle().createBlockData("minecraft:spruce_leave");
|
||||
for(int i = 0; i < d; i++) {
|
||||
geo.generateSphere(l1.clone().add(diff.clone().multiply((double) i / d)), Material.SPRUCE_WOOD, (int) ((i > d * 0.65) ? 0.5 : 1.5), true);
|
||||
geo.generateSphere(l1.clone().add(diff.clone().multiply((double) i / d)), wood, (int) ((i > d * 0.65) ? 0.5 : 1.5), true);
|
||||
if(i > 3)
|
||||
geo.generateCylinder(l1.clone().add(diff.clone().multiply((double) i / d)), Material.SPRUCE_LEAVES, (int) (((6 - (i % 4))) * (1.25 - ((double) i / d))), 1, false);
|
||||
geo.generateCylinder(l1.clone().add(diff.clone().multiply((double) i / d)), leaves, (int) (((6 - (i % 4))) * (1.25 - ((double) i / d))), 1, false);
|
||||
}
|
||||
setBlock(l1.clone().add(diff), Material.SPRUCE_LEAVES);
|
||||
setBlock(l1.clone().add(diff).add(0, 1, 0), Material.SPRUCE_LEAVES);
|
||||
setBlock(l1.clone().add(diff), leaves);
|
||||
setBlock(l1.clone().add(diff).add(0, 1, 0), leaves);
|
||||
}
|
||||
}
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
package com.dfsek.terra.api.gaea.util;
|
||||
|
||||
|
||||
import org.apache.commons.rng.core.source64.XoRoShiRo128PlusPlus;
|
||||
|
||||
import java.util.Random;
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,5 @@
|
||||
package com.dfsek.terra.api.generic;
|
||||
|
||||
public interface CommandSender extends Handle {
|
||||
void sendMessage(String message);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.dfsek.terra.api.generic;
|
||||
|
||||
public interface Entity extends Handle {
|
||||
}
|
||||
File renamed without changes.
+17
-1
@@ -2,14 +2,18 @@ package com.dfsek.terra.api.generic;
|
||||
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.LoaderRegistrar;
|
||||
import com.dfsek.terra.api.gaea.lang.Language;
|
||||
import com.dfsek.terra.api.generic.inventory.ItemHandle;
|
||||
import com.dfsek.terra.api.generic.world.World;
|
||||
import com.dfsek.terra.api.generic.world.WorldHandle;
|
||||
import com.dfsek.terra.config.base.PluginConfig;
|
||||
import com.dfsek.terra.registry.ConfigRegistry;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public interface TerraPlugin extends LoaderRegistrar {
|
||||
WorldHandle getHandle();
|
||||
WorldHandle getWorldHandle();
|
||||
|
||||
boolean isEnabled();
|
||||
|
||||
@@ -18,4 +22,16 @@ public interface TerraPlugin extends LoaderRegistrar {
|
||||
Logger getLogger();
|
||||
|
||||
PluginConfig getTerraConfig();
|
||||
|
||||
File getDataFolder();
|
||||
|
||||
boolean isDebug();
|
||||
|
||||
Language getLanguage();
|
||||
|
||||
ConfigRegistry getRegistry();
|
||||
|
||||
void reload();
|
||||
|
||||
ItemHandle getItemHandle();
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.dfsek.terra.api.generic;
|
||||
|
||||
public interface Tree extends Handle {
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,11 @@
|
||||
package com.dfsek.terra.api.generic.inventory;
|
||||
|
||||
import com.dfsek.terra.api.generic.Handle;
|
||||
|
||||
public interface Inventory extends Handle {
|
||||
int getSize();
|
||||
|
||||
ItemStack getItem(int slot);
|
||||
|
||||
void setItem(int slot, ItemStack newStack);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.dfsek.terra.api.generic.inventory;
|
||||
|
||||
import com.dfsek.terra.api.generic.world.block.MaterialData;
|
||||
|
||||
public interface ItemHandle {
|
||||
ItemStack newItemStack(MaterialData material, int amount);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.dfsek.terra.api.generic.inventory;
|
||||
|
||||
import com.dfsek.terra.api.generic.Handle;
|
||||
import com.dfsek.terra.api.generic.inventory.item.ItemMeta;
|
||||
import com.dfsek.terra.api.generic.world.block.MaterialData;
|
||||
|
||||
public interface ItemStack extends Handle, Cloneable {
|
||||
int getAmount();
|
||||
|
||||
void setAmount(int i);
|
||||
|
||||
MaterialData getType();
|
||||
|
||||
ItemStack clone();
|
||||
|
||||
ItemMeta getItemMeta();
|
||||
|
||||
void setItemMeta(ItemMeta meta);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.dfsek.terra.api.generic.inventory.item;
|
||||
|
||||
import com.dfsek.terra.api.generic.Handle;
|
||||
|
||||
public interface Damageable extends Handle, Cloneable {
|
||||
Damageable clone();
|
||||
int getDamage();
|
||||
void setDamage(int damage);
|
||||
boolean hasDamage();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.dfsek.terra.api.generic.inventory.item;
|
||||
|
||||
import com.dfsek.terra.api.generic.Handle;
|
||||
|
||||
public interface ItemMeta extends Handle {
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+4
-4
@@ -1,15 +1,15 @@
|
||||
package com.dfsek.terra.api.generic.world;
|
||||
|
||||
import com.dfsek.terra.api.generic.Entity;
|
||||
import com.dfsek.terra.api.generic.Handle;
|
||||
import com.dfsek.terra.api.generic.Tree;
|
||||
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;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface World extends Handle {
|
||||
long getSeed();
|
||||
@@ -32,7 +32,7 @@ public interface World extends Handle {
|
||||
|
||||
Block getBlockAt(Location l);
|
||||
|
||||
boolean generateTree(Location l, TreeType vanillaTreeType); // TODO: Bukkit treetype is bad
|
||||
boolean generateTree(Location l, Tree vanillaTreeType); // TODO: Bukkit treetype is bad
|
||||
|
||||
void spawn(Location location, Class<Entity> entity, Consumer<Entity> consumer); // TODO: Bukkit Entity is bad
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,5 @@
|
||||
package com.dfsek.terra.api.generic.world.block;
|
||||
|
||||
public enum Axis {
|
||||
X, Y, Z
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
+21
-21
@@ -82,67 +82,67 @@ public enum BlockFace {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public org.bukkit.block.BlockFace getOppositeFace() {
|
||||
public BlockFace getOppositeFace() {
|
||||
switch(this) {
|
||||
case NORTH:
|
||||
return org.bukkit.block.BlockFace.SOUTH;
|
||||
return BlockFace.SOUTH;
|
||||
|
||||
case SOUTH:
|
||||
return org.bukkit.block.BlockFace.NORTH;
|
||||
return BlockFace.NORTH;
|
||||
|
||||
case EAST:
|
||||
return org.bukkit.block.BlockFace.WEST;
|
||||
return BlockFace.WEST;
|
||||
|
||||
case WEST:
|
||||
return org.bukkit.block.BlockFace.EAST;
|
||||
return BlockFace.EAST;
|
||||
|
||||
case UP:
|
||||
return org.bukkit.block.BlockFace.DOWN;
|
||||
return BlockFace.DOWN;
|
||||
|
||||
case DOWN:
|
||||
return org.bukkit.block.BlockFace.UP;
|
||||
return BlockFace.UP;
|
||||
|
||||
case NORTH_EAST:
|
||||
return org.bukkit.block.BlockFace.SOUTH_WEST;
|
||||
return BlockFace.SOUTH_WEST;
|
||||
|
||||
case NORTH_WEST:
|
||||
return org.bukkit.block.BlockFace.SOUTH_EAST;
|
||||
return BlockFace.SOUTH_EAST;
|
||||
|
||||
case SOUTH_EAST:
|
||||
return org.bukkit.block.BlockFace.NORTH_WEST;
|
||||
return BlockFace.NORTH_WEST;
|
||||
|
||||
case SOUTH_WEST:
|
||||
return org.bukkit.block.BlockFace.NORTH_EAST;
|
||||
return BlockFace.NORTH_EAST;
|
||||
|
||||
case WEST_NORTH_WEST:
|
||||
return org.bukkit.block.BlockFace.EAST_SOUTH_EAST;
|
||||
return BlockFace.EAST_SOUTH_EAST;
|
||||
|
||||
case NORTH_NORTH_WEST:
|
||||
return org.bukkit.block.BlockFace.SOUTH_SOUTH_EAST;
|
||||
return BlockFace.SOUTH_SOUTH_EAST;
|
||||
|
||||
case NORTH_NORTH_EAST:
|
||||
return org.bukkit.block.BlockFace.SOUTH_SOUTH_WEST;
|
||||
return BlockFace.SOUTH_SOUTH_WEST;
|
||||
|
||||
case EAST_NORTH_EAST:
|
||||
return org.bukkit.block.BlockFace.WEST_SOUTH_WEST;
|
||||
return BlockFace.WEST_SOUTH_WEST;
|
||||
|
||||
case EAST_SOUTH_EAST:
|
||||
return org.bukkit.block.BlockFace.WEST_NORTH_WEST;
|
||||
return BlockFace.WEST_NORTH_WEST;
|
||||
|
||||
case SOUTH_SOUTH_EAST:
|
||||
return org.bukkit.block.BlockFace.NORTH_NORTH_WEST;
|
||||
return BlockFace.NORTH_NORTH_WEST;
|
||||
|
||||
case SOUTH_SOUTH_WEST:
|
||||
return org.bukkit.block.BlockFace.NORTH_NORTH_EAST;
|
||||
return BlockFace.NORTH_NORTH_EAST;
|
||||
|
||||
case WEST_SOUTH_WEST:
|
||||
return org.bukkit.block.BlockFace.EAST_NORTH_EAST;
|
||||
return BlockFace.EAST_NORTH_EAST;
|
||||
|
||||
case SELF:
|
||||
return org.bukkit.block.BlockFace.SELF;
|
||||
return BlockFace.SELF;
|
||||
}
|
||||
|
||||
return org.bukkit.block.BlockFace.SELF;
|
||||
return BlockFace.SELF;
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -10,4 +10,6 @@ public interface MaterialData extends Handle {
|
||||
boolean isSolid();
|
||||
|
||||
boolean isAir();
|
||||
|
||||
double getMaxDurability();
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.dfsek.terra.api.generic.world.block.data;
|
||||
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
|
||||
public interface AnaloguePowerable extends BlockData {
|
||||
int getMaximumPower();
|
||||
int getPower();
|
||||
void setPower(int power);
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
+4
@@ -9,4 +9,8 @@ public interface MultipleFacing extends BlockData {
|
||||
Set<BlockFace> getFaces();
|
||||
|
||||
void setFace(BlockFace face, boolean facing);
|
||||
|
||||
Set<BlockFace> getAllowedFaces();
|
||||
|
||||
boolean hasFace(BlockFace f);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.dfsek.terra.api.generic.world.block.data;
|
||||
|
||||
import com.dfsek.terra.api.generic.world.block.Axis;
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface Orientable extends BlockData {
|
||||
Set<Axis> getAxes();
|
||||
void setAxis(Axis axis);
|
||||
Axis getAxis();
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.dfsek.terra.api.generic.world.block.data;
|
||||
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
|
||||
public interface Rail extends BlockData {
|
||||
Shape getShape();
|
||||
|
||||
void setShape(Shape newShape);
|
||||
|
||||
enum Shape {
|
||||
ASCENDING_EAST,
|
||||
ASCENDING_NORTH,
|
||||
ASCENDING_SOUTH,
|
||||
ASCENDING_WEST,
|
||||
EAST_WEST,
|
||||
NORTH_EAST,
|
||||
NORTH_SOUTH,
|
||||
NORTH_WEST,
|
||||
SOUTH_EAST,
|
||||
SOUTH_WEST
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.dfsek.terra.api.generic.world.block.data;
|
||||
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
import com.dfsek.terra.api.generic.world.block.BlockFace;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface RedstoneWire extends BlockData, AnaloguePowerable {
|
||||
Set<BlockFace> getAllowedFaces();
|
||||
Connection getFace(BlockFace face);
|
||||
void setFace(BlockFace face, Connection connection);
|
||||
enum Connection {
|
||||
NONE, SIDE, UP
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,15 @@
|
||||
package com.dfsek.terra.api.generic.world.block.data;
|
||||
|
||||
import com.dfsek.terra.api.generic.world.block.BlockData;
|
||||
import com.dfsek.terra.api.generic.world.block.BlockFace;
|
||||
|
||||
public interface Wall extends BlockData, Waterlogged {
|
||||
boolean isUp();
|
||||
void setHeight(BlockFace face, Height height);
|
||||
Height getHeight(BlockFace face);
|
||||
void setUp(boolean up);
|
||||
|
||||
enum Height {
|
||||
LOW, NONE, TALL
|
||||
}
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,4 @@
|
||||
package com.dfsek.terra.api.generic.world.block.state;
|
||||
|
||||
public interface BlockState {
|
||||
}
|
||||
Loaded 100 of 345 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user