mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2026-09-13 04:45:42 +00:00
Add commands.getDimension()
Debated "commands.getBlockDimension()" instead, to match getBlockPosition, but I think this is fine. Fixes #1866.
This commit is contained in:
+13
-1
@@ -157,6 +157,18 @@ public class CommandAPI implements ILuaAPI {
|
||||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the dimension the current command computer is in, such as {@code minecraft:overworld}.
|
||||
*
|
||||
* @return The dimension the computer is in.
|
||||
* @see #getBlockPosition()
|
||||
* @since 1.119.0
|
||||
*/
|
||||
@LuaFunction
|
||||
public final String getDimension() {
|
||||
return computer.getLevel().dimension().location().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the position of the current command computer.
|
||||
*
|
||||
@@ -165,10 +177,10 @@ public class CommandAPI implements ILuaAPI {
|
||||
* @cc.treturn number This computer's y position.
|
||||
* @cc.treturn number This computer's z position.
|
||||
* @cc.see gps.locate To get the position of a non-command computer.
|
||||
* @see #getDimension()
|
||||
*/
|
||||
@LuaFunction
|
||||
public final Object[] getBlockPosition() {
|
||||
// This is probably safe to do on the Lua thread. Probably.
|
||||
var pos = computer.getPosition();
|
||||
return new Object[]{ pos.getX(), pos.getY(), pos.getZ() };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user