mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-05 07:16:10 +00:00
update logging
This commit is contained in:
@@ -19,12 +19,17 @@ import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class BufferedLootApplication implements BufferedItem {
|
||||
private final LootTable table;
|
||||
private final Platform platform;
|
||||
private final StructureScript structure;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(BufferedLootApplication.class);
|
||||
|
||||
public BufferedLootApplication(LootTable table, Platform platform, StructureScript structure) {
|
||||
this.table = table;
|
||||
this.platform = platform;
|
||||
@@ -36,7 +41,7 @@ public class BufferedLootApplication implements BufferedItem {
|
||||
try {
|
||||
BlockEntity data = world.getBlockState(origin);
|
||||
if(!(data instanceof Container)) {
|
||||
platform.logger().severe("Failed to place loot at " + origin + "; block " + data + " is not container.");
|
||||
LOGGER.error("Failed to place loot at {}; block {} is not a container", origin, data);
|
||||
return;
|
||||
}
|
||||
Container container = (Container) data;
|
||||
@@ -48,7 +53,7 @@ public class BufferedLootApplication implements BufferedItem {
|
||||
event.getTable().fillInventory(container.getInventory(), new Random(origin.hashCode()));
|
||||
data.update(false);
|
||||
} catch(Exception e) {
|
||||
platform.logger().warning("Could not apply loot at " + origin + ": " + e.getMessage());
|
||||
LOGGER.error("Could not apply loot at {}", origin, e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,13 +13,16 @@ import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class BufferedStateManipulator implements BufferedItem {
|
||||
private final Platform platform;
|
||||
private final String data;
|
||||
|
||||
public BufferedStateManipulator(Platform platform, String state) {
|
||||
this.platform = platform;
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(BufferedStateManipulator.class);
|
||||
|
||||
public BufferedStateManipulator(String state) {
|
||||
this.data = state;
|
||||
}
|
||||
|
||||
@@ -30,7 +33,7 @@ public class BufferedStateManipulator implements BufferedItem {
|
||||
state.applyState(data);
|
||||
state.update(false);
|
||||
} catch(Exception e) {
|
||||
platform.logger().warning("Could not apply BlockState at " + origin + ": " + e.getMessage());
|
||||
LOGGER.warn("Could not apply BlockState at {}", origin, e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,9 @@ import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class StructureScript implements Structure {
|
||||
private final Block block;
|
||||
@@ -60,6 +63,8 @@ public class StructureScript implements Structure {
|
||||
private final Cache<Vector3, StructureBuffer> cache;
|
||||
private final Platform platform;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(StructureScript.class);
|
||||
|
||||
public StructureScript(InputStream inputStream, String id, Platform platform, Registry<Structure> registry,
|
||||
Registry<LootTable> lootRegistry,
|
||||
Registry<FunctionBuilder<?>> functionRegistry) {
|
||||
@@ -100,7 +105,7 @@ public class StructureScript implements Structure {
|
||||
.registerFunction("rotationDegrees", new ZeroArgFunctionBuilder<>(arguments -> arguments.getRotation().getDegrees(),
|
||||
Returnable.ReturnType.NUMBER))
|
||||
.registerFunction("print",
|
||||
new UnaryStringFunctionBuilder(string -> platform.getDebugLogger().info("[" + id + "] " + string)))
|
||||
new UnaryStringFunctionBuilder(string -> LOGGER.debug("[TerraScript:{}] {}", id, string)))
|
||||
.registerFunction("abs", new UnaryNumberFunctionBuilder(number -> FastMath.abs(number.doubleValue())))
|
||||
.registerFunction("pow", new BinaryNumberFunctionBuilder(
|
||||
(number, number2) -> FastMath.pow(number.doubleValue(), number2.doubleValue())))
|
||||
@@ -180,8 +185,7 @@ public class StructureScript implements Structure {
|
||||
try {
|
||||
return block.apply(arguments).getLevel() != Block.ReturnLevel.FAIL;
|
||||
} catch(RuntimeException e) {
|
||||
platform.logger().severe("Failed to generate structure at " + arguments.getBuffer().getOrigin() + ": " + e.getMessage());
|
||||
platform.getDebugLogger().stack(e);
|
||||
LOGGER.error("Failed to generate structure at {}", arguments.getBuffer().getOrigin(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@ import com.dfsek.terra.api.util.RotationUtil;
|
||||
import com.dfsek.terra.api.util.vector.Vector2;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class LootFunction implements Function<Void> {
|
||||
private final Registry<LootTable> registry;
|
||||
@@ -35,6 +38,8 @@ public class LootFunction implements Function<Void> {
|
||||
private final Platform platform;
|
||||
private final StructureScript script;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LootFunction.class);
|
||||
|
||||
public LootFunction(Registry<LootTable> registry, Returnable<Number> x, Returnable<Number> y, Returnable<Number> z,
|
||||
Returnable<String> data, Platform platform, Position position, StructureScript script) {
|
||||
this.registry = registry;
|
||||
@@ -59,7 +64,7 @@ public class LootFunction implements Function<Void> {
|
||||
LootTable table = registry.get(id);
|
||||
|
||||
if(table == null) {
|
||||
platform.logger().severe("No such loot table " + id);
|
||||
LOGGER.error("No such loot table {}", id);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class StateFunction implements Function<Void> {
|
||||
z.apply(implementationArguments, variableMap).doubleValue());
|
||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||
|
||||
arguments.getBuffer().addItem(new BufferedStateManipulator(platform, data.apply(implementationArguments, variableMap)),
|
||||
arguments.getBuffer().addItem(new BufferedStateManipulator(data.apply(implementationArguments, variableMap)),
|
||||
new Vector3(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).intValue(),
|
||||
FastMath.roundToInt(xz.getZ())));
|
||||
return null;
|
||||
|
||||
@@ -27,6 +27,9 @@ import com.dfsek.terra.api.util.RotationUtil;
|
||||
import com.dfsek.terra.api.util.vector.Vector2;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class StructureFunction implements Function<Boolean> {
|
||||
private final Registry<Structure> registry;
|
||||
@@ -36,6 +39,7 @@ public class StructureFunction implements Function<Boolean> {
|
||||
private final Platform platform;
|
||||
private final List<Returnable<String>> rotations;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(StructureFunction.class);
|
||||
public StructureFunction(Returnable<Number> x, Returnable<Number> y, Returnable<Number> z, Returnable<String> id,
|
||||
List<Returnable<String>> rotations, Registry<Structure> registry, Position position, Platform platform) {
|
||||
this.registry = registry;
|
||||
@@ -68,7 +72,7 @@ public class StructureFunction implements Function<Boolean> {
|
||||
String app = id.apply(implementationArguments, variableMap);
|
||||
Structure script = registry.get(app);
|
||||
if(script == null) {
|
||||
platform.logger().severe("No such structure " + app);
|
||||
LOGGER.warn("No such structure {}", app);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -77,7 +81,7 @@ public class StructureFunction implements Function<Boolean> {
|
||||
try {
|
||||
rotation1 = Rotation.valueOf(rotString);
|
||||
} catch(IllegalArgumentException e) {
|
||||
platform.logger().severe("Invalid rotation " + rotString);
|
||||
LOGGER.warn("Invalid rotation {}", rotString);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user