mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 06:11:24 +00:00
Merge remote-tracking branch 'origin/ver/6.0.0' into architecture/slf4j-logging
# Conflicts: # common/addons/chunk-generator-noise-3d/src/main/java/com/dfsek/terra/addons/chunkgenerator/generation/generators/NoiseChunkGenerator3D.java # common/addons/config-structure/src/main/java/com/dfsek/terra/addons/structure/command/structure/StructureExportCommand.java # common/addons/config-structure/src/main/java/com/dfsek/terra/addons/structure/structures/loot/functions/EnchantFunction.java # common/addons/language-yaml/src/main/java/com/dfsek/terra/addons/yaml/YamlAddon.java # common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/buffer/items/BufferedBlock.java # common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/buffer/items/BufferedLootApplication.java # common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/buffer/items/BufferedStateManipulator.java # common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/script/StructureScript.java # common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/script/functions/LootFunction.java # common/addons/structure-terrascript-loader/src/main/java/com/dfsek/terra/addons/terrascript/script/functions/StructureFunction.java # common/api/core/src/main/java/com/dfsek/terra/api/Platform.java # common/implementation/src/main/java/com/dfsek/terra/AbstractPlatform.java # common/implementation/src/main/java/com/dfsek/terra/InternalAddon.java # common/implementation/src/main/java/com/dfsek/terra/commands/AddonsCommand.java # common/implementation/src/main/java/com/dfsek/terra/commands/ReloadCommand.java # common/implementation/src/main/java/com/dfsek/terra/commands/profiler/ProfileQueryCommand.java # common/implementation/src/main/java/com/dfsek/terra/config/PluginConfigImpl.java # common/implementation/src/main/java/com/dfsek/terra/config/lang/LangUtil.java # common/implementation/src/main/java/com/dfsek/terra/config/pack/ConfigPackImpl.java # common/implementation/src/main/java/com/dfsek/terra/event/FunctionalEventHandlerImpl.java # common/implementation/src/main/java/com/dfsek/terra/registry/config/ConfigTypeRegistry.java # common/implementation/src/main/java/com/dfsek/terra/registry/master/AddonRegistry.java # common/implementation/src/main/java/com/dfsek/terra/registry/master/ConfigRegistry.java # platforms/bukkit/src/main/java/com/dfsek/terra/bukkit/BukkitAddon.java # platforms/bukkit/src/main/java/com/dfsek/terra/bukkit/PlatformImpl.java # platforms/bukkit/src/main/java/com/dfsek/terra/bukkit/listeners/SpigotListener.java # platforms/fabric/src/main/java/com/dfsek/terra/fabric/FabricAddon.java # platforms/fabric/src/main/java/com/dfsek/terra/fabric/FabricEntryPoint.java # platforms/fabric/src/main/java/com/dfsek/terra/fabric/PlatformImpl.java # platforms/fabric/src/main/java/com/dfsek/terra/fabric/generation/FabricChunkGeneratorWrapper.java # platforms/sponge/src/main/java/com/dfsek/terra/sponge/PlatformImpl.java
This commit is contained in:
+7
-7
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.addons.structure;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
@@ -16,14 +16,14 @@ import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
@Author("Terra")
|
||||
public class StructureAddon extends TerraAddon {
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
main.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> event.getPack().applyLoader(ConfiguredStructure.class, (t, o, l) -> null))
|
||||
.failThrough();
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> event.getPack().applyLoader(ConfiguredStructure.class, (t, o, l) -> null))
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,13 +1,13 @@
|
||||
package com.dfsek.terra.addons.structure;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.ConfigFactory;
|
||||
import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
|
||||
|
||||
public class StructureFactory implements ConfigFactory<StructureTemplate, ConfiguredStructure> {
|
||||
@Override
|
||||
public ConfiguredStructure build(StructureTemplate config, TerraPlugin main) {
|
||||
public ConfiguredStructure build(StructureTemplate config, Platform platform) {
|
||||
return new TerraStructure(config.getStructures(), config.getY(), config.getSpawn());
|
||||
}
|
||||
}
|
||||
|
||||
+6
-5
@@ -1,11 +1,12 @@
|
||||
package com.dfsek.terra.addons.structure;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.config.WorldConfig;
|
||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||
import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
@@ -20,16 +21,16 @@ import com.dfsek.terra.api.world.generator.GenerationStage;
|
||||
|
||||
|
||||
public class StructurePopulator implements GenerationStage, Chunkified {
|
||||
private final TerraPlugin main;
|
||||
private final Platform platform;
|
||||
|
||||
public StructurePopulator(TerraPlugin main) {
|
||||
this.main = main;
|
||||
public StructurePopulator(Platform platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@SuppressWarnings("try")
|
||||
@Override
|
||||
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("structure")) {
|
||||
try(ProfileFrame ignore = platform.getProfiler().profile("structure")) {
|
||||
if(world.getConfig().disableStructures()) return;
|
||||
|
||||
int cx = (chunk.getX() << 4);
|
||||
|
||||
+5
-4
@@ -1,10 +1,11 @@
|
||||
package com.dfsek.terra.addons.structure.command;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
@@ -19,16 +20,16 @@ public class AsyncStructureFinder implements Runnable {
|
||||
protected final int centerX;
|
||||
protected final int centerZ;
|
||||
protected final World world;
|
||||
protected final TerraPlugin main;
|
||||
protected final Platform platform;
|
||||
private final Consumer<Vector3> callback;
|
||||
protected int searchSize = 1;
|
||||
|
||||
public AsyncStructureFinder(BiomeProvider provider, ConfiguredStructure target, @NotNull Vector3 origin, World world, int startRadius,
|
||||
int maxRadius, Consumer<Vector3> callback, TerraPlugin main) {
|
||||
int maxRadius, Consumer<Vector3> callback, Platform platform) {
|
||||
//setSearchSize(target.getSpawn().getWidth() + 2 * target.getSpawn().getSeparation());
|
||||
this.provider = provider;
|
||||
this.target = target;
|
||||
this.main = main;
|
||||
this.platform = platform;
|
||||
this.startRadius = startRadius;
|
||||
this.maxRadius = maxRadius;
|
||||
this.centerX = origin.getBlockX();
|
||||
|
||||
+5
-5
@@ -8,7 +8,7 @@ import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.block.entity.Sign;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
@@ -34,7 +34,7 @@ public class StructureExportCommand implements CommandTemplate {
|
||||
private static final Logger logger = LoggerFactory.getLogger(StructureExportCommand.class);
|
||||
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
private Platform platform;
|
||||
|
||||
@ArgumentTarget("id")
|
||||
private String id;
|
||||
@@ -43,7 +43,7 @@ public class StructureExportCommand implements CommandTemplate {
|
||||
public void execute(CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
Pair<Vector3, Vector3> area = main.getWorldHandle().getSelectedLocation(player);
|
||||
Pair<Vector3, Vector3> area = platform.getWorldHandle().getSelectedLocation(player);
|
||||
|
||||
Vector3 firstCorner = area.getLeft();
|
||||
Vector3 secondCorner = area.getRight();
|
||||
@@ -78,7 +78,7 @@ public class StructureExportCommand implements CommandTemplate {
|
||||
BlockEntity state = player.world().getBlockState(x, y, z);
|
||||
if(state instanceof Sign sign) {
|
||||
if("[TERRA]".equals(sign.getLine(0))) {
|
||||
data = main.getWorldHandle().createBlockData(sign.getLine(2) + sign.getLine(3));
|
||||
data = platform.getWorldHandle().createBlockData(sign.getLine(2) + sign.getLine(3));
|
||||
}
|
||||
}
|
||||
if(!data.isStructureVoid()) {
|
||||
@@ -91,7 +91,7 @@ public class StructureExportCommand implements CommandTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
File file = new File(main.getDataFolder() + File.separator + "export" + File.separator + "structures", id + ".tesf");
|
||||
File file = new File(platform.getDataFolder() + File.separator + "export" + File.separator + "structures", id + ".tesf");
|
||||
try {
|
||||
file.getParentFile().mkdirs();
|
||||
file.createNewFile();
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ import java.util.concurrent.ThreadLocalRandom;
|
||||
import com.dfsek.terra.addons.structure.command.structure.argument.ScriptArgumentParser;
|
||||
import com.dfsek.terra.addons.structure.command.structure.completer.RotationCompleter;
|
||||
import com.dfsek.terra.addons.structure.command.structure.completer.ScriptCompleter;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.command.CommandTemplate;
|
||||
import com.dfsek.terra.api.command.annotation.Argument;
|
||||
import com.dfsek.terra.api.command.annotation.Command;
|
||||
@@ -54,7 +54,7 @@ public class StructureLoadCommand implements CommandTemplate {
|
||||
private Structure script;
|
||||
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender) {
|
||||
|
||||
+5
-5
@@ -5,7 +5,7 @@ import java.util.Locale;
|
||||
import com.dfsek.terra.addons.structure.command.AsyncStructureFinder;
|
||||
import com.dfsek.terra.addons.structure.command.structure.argument.StructureArgumentParser;
|
||||
import com.dfsek.terra.addons.structure.command.structure.completer.StructureCompleter;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.command.CommandTemplate;
|
||||
import com.dfsek.terra.api.command.annotation.Argument;
|
||||
import com.dfsek.terra.api.command.annotation.Command;
|
||||
@@ -42,7 +42,7 @@ import com.dfsek.terra.api.util.vector.Vector3;
|
||||
))
|
||||
public class StructureLocateCommand implements CommandTemplate {
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
private Platform platform;
|
||||
|
||||
@ArgumentTarget("structure")
|
||||
private ConfiguredStructure structure;
|
||||
@@ -58,7 +58,7 @@ public class StructureLocateCommand implements CommandTemplate {
|
||||
Player player = (Player) sender;
|
||||
|
||||
new Thread(new AsyncStructureFinder(player.world().getBiomeProvider(), structure,
|
||||
player.position().clone().multiply((1D / main.getTerraConfig().getBiomeSearchResolution())),
|
||||
player.position().clone().multiply((1D / platform.getTerraConfig().getBiomeSearchResolution())),
|
||||
player.world(), 0, radius, location -> {
|
||||
if(location != null) {
|
||||
sender.sendMessage(
|
||||
@@ -66,10 +66,10 @@ public class StructureLocateCommand implements CommandTemplate {
|
||||
location.getBlockX(), location.getBlockZ(),
|
||||
location.add(new Vector3(0, player.position().getY(), 0)).distance(player.position())));
|
||||
if(teleport) {
|
||||
main.runPossiblyUnsafeTask(
|
||||
platform.runPossiblyUnsafeTask(
|
||||
() -> player.position(new Vector3(location.getX(), player.position().getY(), location.getZ())));
|
||||
}
|
||||
} //else LangUtil.send("command.biome.unable-to-locate", sender);
|
||||
}, main), "Biome Location Thread").start();
|
||||
}, platform), "Biome Location Thread").start();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.addons.structure.command.structure.argument;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.command.arg.ArgumentParser;
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
@@ -10,7 +10,7 @@ import com.dfsek.terra.api.structure.Structure;
|
||||
|
||||
public class ScriptArgumentParser implements ArgumentParser<Structure> {
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public Structure parse(CommandSender sender, String arg) {
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.addons.structure.command.structure.argument;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.command.arg.ArgumentParser;
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
@@ -10,7 +10,7 @@ import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
|
||||
public class StructureArgumentParser implements ArgumentParser<ConfiguredStructure> {
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public ConfiguredStructure parse(CommandSender sender, String arg) {
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ package com.dfsek.terra.addons.structure.command.structure.completer;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.command.tab.TabCompleter;
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
@@ -13,7 +13,7 @@ import com.dfsek.terra.api.structure.Structure;
|
||||
|
||||
public class ScriptCompleter implements TabCompleter {
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public List<String> complete(CommandSender sender) {
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ package com.dfsek.terra.addons.structure.command.structure.completer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.command.tab.TabCompleter;
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
@@ -13,7 +13,7 @@ import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
|
||||
public class StructureCompleter implements TabCompleter {
|
||||
@Inject
|
||||
private TerraPlugin main;
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public List<String> complete(CommandSender sender) {
|
||||
|
||||
+11
-13
@@ -1,5 +1,7 @@
|
||||
package com.dfsek.terra.addons.structure.structures.loot;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
@@ -12,7 +14,6 @@ import com.dfsek.terra.addons.structure.structures.loot.functions.AmountFunction
|
||||
import com.dfsek.terra.addons.structure.structures.loot.functions.DamageFunction;
|
||||
import com.dfsek.terra.addons.structure.structures.loot.functions.EnchantFunction;
|
||||
import com.dfsek.terra.addons.structure.structures.loot.functions.LootFunction;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.inventory.Item;
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
|
||||
@@ -30,9 +31,9 @@ public class Entry {
|
||||
*
|
||||
* @param entry The JSON Object to instantiate from.
|
||||
*/
|
||||
public Entry(JSONObject entry, TerraPlugin main) {
|
||||
public Entry(JSONObject entry, Platform platform) {
|
||||
String id = entry.get("name").toString();
|
||||
this.item = main.getItemHandle().createItem(id);
|
||||
this.item = platform.getItemHandle().createItem(id);
|
||||
|
||||
long weight1;
|
||||
try {
|
||||
@@ -45,8 +46,7 @@ public class Entry {
|
||||
if(entry.containsKey("functions")) {
|
||||
for(Object function : (JSONArray) entry.get("functions")) {
|
||||
switch(((String) ((JSONObject) function).get("function"))) {
|
||||
case "minecraft:set_count":
|
||||
case "set_count":
|
||||
case "minecraft:set_count", "set_count" -> {
|
||||
Object loot = ((JSONObject) function).get("count");
|
||||
long max, min;
|
||||
if(loot instanceof Long) {
|
||||
@@ -57,23 +57,21 @@ public class Entry {
|
||||
min = (long) ((JSONObject) loot).get("min");
|
||||
}
|
||||
functions.add(new AmountFunction(FastMath.toIntExact(min), FastMath.toIntExact(max)));
|
||||
break;
|
||||
case "minecraft:set_damage":
|
||||
case "set_damage":
|
||||
}
|
||||
case "minecraft:set_damage", "set_damage" -> {
|
||||
long maxDamage = (long) ((JSONObject) ((JSONObject) function).get("damage")).get("max");
|
||||
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":
|
||||
}
|
||||
case "minecraft:enchant_with_levels", "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 EnchantFunction(FastMath.toIntExact(minEnchant), FastMath.toIntExact(maxEnchant), disabled, main));
|
||||
break;
|
||||
new EnchantFunction(FastMath.toIntExact(minEnchant), FastMath.toIntExact(maxEnchant), disabled, platform));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -9,7 +9,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.inventory.Inventory;
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
|
||||
@@ -27,12 +27,12 @@ public class LootTableImpl implements com.dfsek.terra.api.structure.LootTable {
|
||||
*
|
||||
* @throws ParseException if malformed JSON is passed.
|
||||
*/
|
||||
public LootTableImpl(String json, TerraPlugin main) throws ParseException {
|
||||
public LootTableImpl(String json, Platform platform) 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, main));
|
||||
pools.add(new Pool((JSONObject) pool, platform));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -1,5 +1,7 @@
|
||||
package com.dfsek.terra.addons.structure.structures.loot;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
@@ -8,7 +10,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
|
||||
@@ -26,7 +27,7 @@ public class Pool {
|
||||
*
|
||||
* @param pool The JSON Object to instantiate from.
|
||||
*/
|
||||
public Pool(JSONObject pool, TerraPlugin main) {
|
||||
public Pool(JSONObject pool, Platform platform) {
|
||||
entries = new ProbabilityCollection<>();
|
||||
Object amount = pool.get("rolls");
|
||||
if(amount instanceof Long) {
|
||||
@@ -38,7 +39,7 @@ public class Pool {
|
||||
}
|
||||
|
||||
for(Object entryJSON : (JSONArray) pool.get("entries")) {
|
||||
Entry entry = new Entry((JSONObject) entryJSON, main);
|
||||
Entry entry = new Entry((JSONObject) entryJSON, platform);
|
||||
entries.add(entry, FastMath.toIntExact(entry.getWeight()));
|
||||
}
|
||||
}
|
||||
|
||||
+6
-5
@@ -1,5 +1,7 @@
|
||||
package com.dfsek.terra.addons.structure.structures.loot.functions;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.slf4j.Logger;
|
||||
@@ -10,7 +12,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
import com.dfsek.terra.api.inventory.item.Enchantment;
|
||||
import com.dfsek.terra.api.inventory.item.ItemMeta;
|
||||
@@ -22,14 +23,14 @@ public class EnchantFunction implements LootFunction {
|
||||
private final int min;
|
||||
private final int max;
|
||||
private final JSONArray disabled;
|
||||
private final TerraPlugin main;
|
||||
private final Platform platform;
|
||||
|
||||
|
||||
public EnchantFunction(int min, int max, JSONArray disabled, TerraPlugin main) {
|
||||
public EnchantFunction(int min, int max, JSONArray disabled, Platform platform) {
|
||||
this.max = max;
|
||||
this.min = min;
|
||||
this.disabled = disabled;
|
||||
this.main = main;
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,7 +47,7 @@ public class EnchantFunction implements LootFunction {
|
||||
|
||||
double enchant = (r.nextDouble() * (max - min)) + min;
|
||||
List<Enchantment> possible = new ArrayList<>();
|
||||
for(Enchantment ench : main.getItemHandle().getEnchantments()) {
|
||||
for(Enchantment ench : platform.getItemHandle().getEnchantments()) {
|
||||
if(ench.canEnchantItem(original) && (disabled == null || !this.disabled.contains(ench.getID()))) {
|
||||
possible.add(ench);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user