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