mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-23 21:14:26 +00:00
start working on error handling stuff
This commit is contained in:
+1
-1
@@ -15,7 +15,7 @@ public class ApiAddon implements BaseAddon {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getVersion() {
|
||||
public Version version() {
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ public class ApiAddonLoader implements BootstrapBaseAddon<BaseAddon> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getVersion() {
|
||||
public Version version() {
|
||||
return VERSION;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -39,7 +39,7 @@ public class AddonsCommandAddon implements AddonInitializer {
|
||||
.append(" - ")
|
||||
.append(addon.getID())
|
||||
.append('@')
|
||||
.append(addon.getVersion().getFormatted())
|
||||
.append(addon.version().getFormatted())
|
||||
.append('\n'));
|
||||
context.sender().sendMessage(addons.toString());
|
||||
})
|
||||
@@ -52,10 +52,10 @@ public class AddonsCommandAddon implements AddonInitializer {
|
||||
BaseAddon addon = context.get("addon");
|
||||
StringBuilder addonInfo = new StringBuilder("Addon ").append(addon.getID()).append('\n');
|
||||
|
||||
addonInfo.append("Version: ").append(addon.getVersion().getFormatted()).append('\n');
|
||||
addonInfo.append("Version: ").append(addon.version().getFormatted()).append('\n');
|
||||
|
||||
addonInfo.append("Dependencies:\n");
|
||||
addon.getDependencies().forEach((id, versions) -> addonInfo
|
||||
addon.dependencies().forEach((id, versions) -> addonInfo
|
||||
.append(" - ")
|
||||
.append(id)
|
||||
.append('@')
|
||||
|
||||
+2
-5
@@ -4,7 +4,6 @@ package com.dfsek.terra.addons.commands.locate;
|
||||
import com.dfsek.seismic.type.vector.Vector2Int;
|
||||
import com.dfsek.seismic.type.vector.Vector3Int;
|
||||
|
||||
import com.dfsek.terra.api.util.function.FunctionUtils;
|
||||
import com.dfsek.terra.api.util.generic.data.types.Maybe;
|
||||
|
||||
import org.incendo.cloud.CommandManager;
|
||||
@@ -13,8 +12,6 @@ import org.incendo.cloud.context.CommandContext;
|
||||
import org.incendo.cloud.description.Description;
|
||||
import org.incendo.cloud.parser.standard.IntegerParser;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
@@ -41,7 +38,7 @@ public class LocateCommandAddon implements AddonInitializer {
|
||||
private BaseAddon addon;
|
||||
|
||||
private static Registry<Biome> getBiomeRegistry(CommandContext<CommandSender> sender) {
|
||||
return sender.sender().getEntity().orThrow().world().getPack().getRegistry(Biome.class);
|
||||
return sender.sender().entity().orThrow().world().getPack().getRegistry(Biome.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,7 +66,7 @@ public class LocateCommandAddon implements AddonInitializer {
|
||||
.handler(context -> {
|
||||
// 1. Gather Context & Arguments
|
||||
Biome targetBiome = context.get("biome");
|
||||
Entity sender = context.sender().getEntity().orThrow(
|
||||
Entity sender = context.sender().entity().orThrow(
|
||||
() -> new Error("Only entities can run this command."));
|
||||
World world = sender.world();
|
||||
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@ public class StructureCommandAddon implements AddonInitializer {
|
||||
private BaseAddon addon;
|
||||
|
||||
private static Registry<Structure> getStructureRegistry(CommandContext<CommandSender> sender) {
|
||||
return sender.sender().getEntity().orThrow().world().getPack().getRegistry(Structure.class);
|
||||
return sender.sender().entity().orThrow().world().getPack().getRegistry(Structure.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,7 +55,7 @@ public class StructureCommandAddon implements AddonInitializer {
|
||||
.optional("rotation", EnumParser.enumParser(Rotation.class), DefaultValue.constant(Rotation.NONE))
|
||||
.handler(context -> {
|
||||
Structure structure = context.get("structure");
|
||||
Entity sender = context.sender().getEntity().orThrow();
|
||||
Entity sender = context.sender().entity().orThrow();
|
||||
structure.generate(
|
||||
sender.position().toInt(),
|
||||
sender.world(),
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public class TerraFlora implements Structure {
|
||||
|
||||
private void test(EnumSet<Direction> faces, Direction f, Vector3Int b, WritableWorld world) {
|
||||
if(testRotation.contains(
|
||||
world.getBlockState(b.getX() + f.getModX(), b.getY() + f.getModY(), b.getZ() + f.getModZ()).getBlockType()))
|
||||
world.getBlockState(b.getX() + f.getModX(), b.getY() + f.getModY(), b.getZ() + f.getModZ()).blockType()))
|
||||
faces.add(f);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -24,6 +24,6 @@ public class AirMatchPatternTemplate implements ObjectTemplate<Pattern> {
|
||||
|
||||
@Override
|
||||
public Pattern get() {
|
||||
return new MatchPattern(offset, BlockState::isAir);
|
||||
return new MatchPattern(offset, BlockState::air);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -26,6 +26,6 @@ public class BlockSetMatchPatternTemplate implements ObjectTemplate<Pattern> {
|
||||
|
||||
@Override
|
||||
public Pattern get() {
|
||||
return new MatchPattern(offset, blockState -> blocks.contains(blockState.getBlockType()));
|
||||
return new MatchPattern(offset, blockState -> blocks.contains(blockState.blockType()));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -21,6 +21,6 @@ public class SolidMatchPatternTemplate implements ObjectTemplate<Pattern> {
|
||||
|
||||
@Override
|
||||
public Pattern get() {
|
||||
return new MatchPattern(offset, blockState -> blockState.getBlockType().isSolid());
|
||||
return new MatchPattern(offset, blockState -> blockState.blockType().solid());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ public class SurfaceLocator implements Locator {
|
||||
int min = Math.max(search.getMin(), column.getMinY());
|
||||
if(min >= max) return builder.build();
|
||||
for(int y = min; y < max; y++) {
|
||||
if(column.getBlock(y).isAir() && !column.getBlock(y - 1).isAir()) {
|
||||
if(column.getBlock(y).air() && !column.getBlock(y - 1).air()) {
|
||||
builder.set(y);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ public class TopLocator implements Locator {
|
||||
@Override
|
||||
public BinaryColumn getSuitableCoordinates(Column<?> column) {
|
||||
for(int y = search.getMax(); y >= search.getMin(); y--) {
|
||||
if(column.getBlock(y).isAir() && !column.getBlock(y - 1).isAir()) {
|
||||
if(column.getBlock(y).air() && !column.getBlock(y - 1).air()) {
|
||||
return new BinaryColumn(y, y + 1, yi -> true);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -149,7 +149,7 @@ public class VanillaOre implements Structure {
|
||||
if(!visited.get(index)) { // Skip blocks that have already been visited
|
||||
|
||||
visited.set(index);
|
||||
BlockType block = world.getBlockState(xi, yi, zi).getBlockType();
|
||||
BlockType block = world.getBlockState(xi, yi, zi).blockType();
|
||||
if(shouldPlace(getReplaceable(), block, exposed, random, world, xi, yi, zi)) {
|
||||
world.setBlockState(xi, yi, zi, getMaterial(block), isApplyGravity());
|
||||
++blockCount;
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ public class VanillaScatteredOre extends VanillaOre {
|
||||
|
||||
for(int j = 0; j < i; ++j) {
|
||||
this.setPos(mutable, random, location, Math.min(j, spread));
|
||||
BlockType block = world.getBlockState(mutable).getBlockType();
|
||||
BlockType block = world.getBlockState(mutable).blockType();
|
||||
if(shouldPlace(getReplaceable(), block, exposed, random, world, mutable.getX(), mutable.getY(), mutable.getZ())) {
|
||||
world.setBlockState(mutable, getMaterial(block), isApplyGravity());
|
||||
}
|
||||
|
||||
+6
-6
@@ -21,12 +21,12 @@ public class VanillaOreUtils {
|
||||
if(!replaceable.contains(type)) return false;
|
||||
if(shouldExpose(random, exposedChance)) return true; // Exposed blocks can be placed regardless of adjacency to air
|
||||
// Adjacency is checked after determining not exposed rather than vice-versa, assuming block checks are more expensive
|
||||
boolean adjacentAir = world.getBlockState(x, y, z - 1).isAir() ||
|
||||
world.getBlockState(x, y, z + 1).isAir() ||
|
||||
world.getBlockState(x, y - 1, z).isAir() ||
|
||||
world.getBlockState(x, y + 1, z).isAir() ||
|
||||
world.getBlockState(x - 1, y, z).isAir() ||
|
||||
world.getBlockState(x + 1, y, z).isAir();
|
||||
boolean adjacentAir = world.getBlockState(x, y, z - 1).air() ||
|
||||
world.getBlockState(x, y, z + 1).air() ||
|
||||
world.getBlockState(x, y - 1, z).air() ||
|
||||
world.getBlockState(x, y + 1, z).air() ||
|
||||
world.getBlockState(x - 1, y, z).air() ||
|
||||
world.getBlockState(x + 1, y, z).air();
|
||||
return !adjacentAir; // Exposed check did not pass earlier so only blocks not adjacent air should place
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -66,12 +66,12 @@ public class ManifestAddon implements BaseAddon {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, VersionRange> getDependencies() {
|
||||
public Map<String, VersionRange> dependencies() {
|
||||
return manifest.getDependencies();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getVersion() {
|
||||
public Version version() {
|
||||
return manifest.getVersion();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -132,7 +132,7 @@ public class ManifestAddonLoader implements BootstrapBaseAddon<ManifestAddon> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getVersion() {
|
||||
public Version version() {
|
||||
return VERSION;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ contributors:
|
||||
id: shortcut-blockstate-fallback
|
||||
version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.shortcut.blockstate.ShortcutBlockstateFallbackAddon"
|
||||
- "com.dfsek.terra.addons.shortcut.blockstate.ShortcutBlockStateFallbackAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ public class BlockFunction implements Function<Void> {
|
||||
y.apply(implementationArguments, scope).doubleValue(),
|
||||
FloatingPointFunctions.round(xz.getZ())).mutable().add(arguments.getOrigin().toFloat());
|
||||
BlockState current = arguments.getWorld().getBlockState(set);
|
||||
if(overwrite.apply(implementationArguments, scope) || current.isAir()) {
|
||||
if(overwrite.apply(implementationArguments, scope) || current.air()) {
|
||||
arguments.getWorld().setBlockState(set, rot, physics.apply(implementationArguments, scope));
|
||||
}
|
||||
} catch(RuntimeException e) {
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ public class CheckBlockFunction implements Function<String> {
|
||||
.add(Vector3.of(FloatingPointFunctions.round(xz.getX()),
|
||||
y.apply(implementationArguments, scope)
|
||||
.doubleValue(), FloatingPointFunctions.round(xz.getZ()))))
|
||||
.getAsString();
|
||||
.asString();
|
||||
if(data.contains("[")) return data.substring(0, data.indexOf('[')); // Strip properties
|
||||
else return data;
|
||||
}
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ public class PullFunction implements Function<Void> {
|
||||
Vector3.Mutable mutable = Vector3.of(FloatingPointFunctions.round(xz.getX()), y.apply(implementationArguments, scope).intValue(),
|
||||
FloatingPointFunctions.round(xz.getZ())).mutable().add(arguments.getOrigin().toFloat());
|
||||
while(mutable.getY() > arguments.getWorld().getMinHeight()) {
|
||||
if(!arguments.getWorld().getBlockState(mutable).isAir()) {
|
||||
if(!arguments.getWorld().getBlockState(mutable).air()) {
|
||||
arguments.getWorld().setBlockState(mutable, data);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user