mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 10:51:55 -04:00
Merge branch 'master' of github.com:MightyPirates/OpenComputers into master-MC1.7.10
Conflicts: src/main/scala/li/cil/oc/server/component/DebugCard.scala
This commit is contained in:
commit
43f4ccb988
@ -992,5 +992,12 @@ opencomputers {
|
|||||||
# Pass along IDs of items and fluids when converting them to a table
|
# Pass along IDs of items and fluids when converting them to a table
|
||||||
# representation for Lua.
|
# representation for Lua.
|
||||||
insertIdsInConverters: false
|
insertIdsInConverters: false
|
||||||
|
|
||||||
|
# Enable debug card functionality. This may also be of use for custom
|
||||||
|
# maps, so it is enabled by default. If you run a server where people
|
||||||
|
# may cheat in items but should not have op/admin-like rights, you may
|
||||||
|
# want to set this to false. This will *not* remove the card, it will
|
||||||
|
# just make all functions it provides error out.
|
||||||
|
enableDebugCard: true
|
||||||
}
|
}
|
||||||
}
|
}
|
1
src/main/resources/assets/opencomputers/wcwidth.bin
Normal file
1
src/main/resources/assets/opencomputers/wcwidth.bin
Normal file
File diff suppressed because one or more lines are too long
@ -267,6 +267,7 @@ class Settings(config: Config) {
|
|||||||
val nativeInTmpDir = config.getBoolean("debug.nativeInTmpDir")
|
val nativeInTmpDir = config.getBoolean("debug.nativeInTmpDir")
|
||||||
val periodicallyForceLightUpdate = config.getBoolean("debug.periodicallyForceLightUpdate")
|
val periodicallyForceLightUpdate = config.getBoolean("debug.periodicallyForceLightUpdate")
|
||||||
val insertIdsInConverters = config.getBoolean("debug.insertIdsInConverters")
|
val insertIdsInConverters = config.getBoolean("debug.insertIdsInConverters")
|
||||||
|
val enableDebugCard = config.getBoolean("debug.enableDebugCard")
|
||||||
}
|
}
|
||||||
|
|
||||||
object Settings {
|
object Settings {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package li.cil.oc.server.component
|
package li.cil.oc.server.component
|
||||||
|
|
||||||
|
import li.cil.oc.Settings
|
||||||
import li.cil.oc.api.Network
|
import li.cil.oc.api.Network
|
||||||
import li.cil.oc.api.driver.Container
|
import li.cil.oc.api.driver.Container
|
||||||
import li.cil.oc.api.network.{Arguments, Callback, Context, Visibility}
|
import li.cil.oc.api.network.{Arguments, Callback, Context, Visibility}
|
||||||
@ -23,26 +24,47 @@ class DebugCard(owner: Container) extends component.ManagedComponent {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
|
import li.cil.oc.server.component.DebugCard.checkEnabled
|
||||||
|
|
||||||
@Callback(doc = """function(value:number):number -- Changes the component network's energy buffer by the specified delta.""")
|
@Callback(doc = """function(value:number):number -- Changes the component network's energy buffer by the specified delta.""")
|
||||||
def changeBuffer(context: Context, args: Arguments): Array[AnyRef] = result(node.changeBuffer(args.checkDouble(0)))
|
def changeBuffer(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
|
result(node.changeBuffer(args.checkDouble(0)))
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = """function():number -- Get the container's X position in the world.""")
|
@Callback(doc = """function():number -- Get the container's X position in the world.""")
|
||||||
def getX(context: Context, args: Arguments): Array[AnyRef] = result(owner.xPosition)
|
def getX(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
|
result(owner.xPosition)
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = """function():number -- Get the container's Y position in the world.""")
|
@Callback(doc = """function():number -- Get the container's Y position in the world.""")
|
||||||
def getY(context: Context, args: Arguments): Array[AnyRef] = result(owner.yPosition)
|
def getY(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
|
result(owner.yPosition)
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = """function():number -- Get the container's Z position in the world.""")
|
@Callback(doc = """function():number -- Get the container's Z position in the world.""")
|
||||||
def getZ(context: Context, args: Arguments): Array[AnyRef] = result(owner.zPosition)
|
def getZ(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
|
result(owner.zPosition)
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = """function():userdata -- Get the container's world object.""")
|
@Callback(doc = """function():userdata -- Get the container's world object.""")
|
||||||
def getWorld(context: Context, args: Arguments): Array[AnyRef] = result(new DebugCard.WorldValue(owner.world))
|
def getWorld(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
|
result(new DebugCard.WorldValue(owner.world))
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = """function(name:string):userdata -- Get the entity of a player.""")
|
@Callback(doc = """function(name:string):userdata -- Get the entity of a player.""")
|
||||||
def getPlayer(context: Context, args: Arguments): Array[AnyRef] = result(new DebugCard.PlayerValue(args.checkString(0)))
|
def getPlayer(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
|
result(new DebugCard.PlayerValue(args.checkString(0)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object DebugCard {
|
object DebugCard {
|
||||||
|
def checkEnabled() = if (!Settings.get.enableDebugCard) throw new Exception("debug card functionality is disabled")
|
||||||
|
|
||||||
final private def result(args: Any*): Array[AnyRef] = {
|
final private def result(args: Any*): Array[AnyRef] = {
|
||||||
def unwrap(arg: Any): AnyRef = arg match {
|
def unwrap(arg: Any): AnyRef = arg match {
|
||||||
@ -58,15 +80,21 @@ object DebugCard {
|
|||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
def withPlayer(f: (EntityPlayerMP) => Array[AnyRef]) = {
|
def withPlayer(f: (EntityPlayerMP) => Array[AnyRef]) = {
|
||||||
|
checkEnabled()
|
||||||
MinecraftServer.getServer.getConfigurationManager.func_152612_a(name) match {
|
MinecraftServer.getServer.getConfigurationManager.func_152612_a(name) match {
|
||||||
case player: EntityPlayerMP => f(player)
|
case player: EntityPlayerMP => f(player)
|
||||||
case _ => Array(Unit, "player is offline")
|
case _ => result(Unit, "player is offline")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Callback(doc = """function():userdata -- Get the container's world object.""")
|
||||||
|
def getWorld(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
withPlayer(player => result(new DebugCard.WorldValue(player.getEntityWorld)))
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = """function():string -- Get the player's game type.""")
|
@Callback(doc = """function():string -- Get the player's game type.""")
|
||||||
def getGameType(context: Context, args: Arguments): Array[AnyRef] =
|
def getGameType(context: Context, args: Arguments): Array[AnyRef] =
|
||||||
withPlayer(player => Array(player.theItemInWorldManager.getGameType.getName))
|
withPlayer(player => result(player.theItemInWorldManager.getGameType.getName))
|
||||||
|
|
||||||
@Callback(doc = """function(gametype:string) -- Set the player's game type (survival, creative, adventure).""")
|
@Callback(doc = """function(gametype:string) -- Set the player's game type (survival, creative, adventure).""")
|
||||||
def setGameType(context: Context, args: Arguments): Array[AnyRef] =
|
def setGameType(context: Context, args: Arguments): Array[AnyRef] =
|
||||||
@ -77,7 +105,7 @@ object DebugCard {
|
|||||||
|
|
||||||
@Callback(doc = """function():number, number, number -- Get the player's position.""")
|
@Callback(doc = """function():number, number, number -- Get the player's position.""")
|
||||||
def getPosition(context: Context, args: Arguments): Array[AnyRef] =
|
def getPosition(context: Context, args: Arguments): Array[AnyRef] =
|
||||||
withPlayer(player => Array(double2Double(player.posX), double2Double(player.posY), double2Double(player.posZ)))
|
withPlayer(player => result(player.posX, player.posY, player.posZ))
|
||||||
|
|
||||||
@Callback(doc = """function(x:number, y:number, z:number) -- Set the player's position.""")
|
@Callback(doc = """function(x:number, y:number, z:number) -- Set the player's position.""")
|
||||||
def setPosition(context: Context, args: Arguments): Array[AnyRef] =
|
def setPosition(context: Context, args: Arguments): Array[AnyRef] =
|
||||||
@ -88,11 +116,11 @@ object DebugCard {
|
|||||||
|
|
||||||
@Callback(doc = """function():number -- Get the player's health.""")
|
@Callback(doc = """function():number -- Get the player's health.""")
|
||||||
def getHealth(context: Context, args: Arguments): Array[AnyRef] =
|
def getHealth(context: Context, args: Arguments): Array[AnyRef] =
|
||||||
withPlayer(player => Array(float2Float(player.getHealth)))
|
withPlayer(player => result(player.getHealth))
|
||||||
|
|
||||||
@Callback(doc = """function():number -- Get the player's max health.""")
|
@Callback(doc = """function():number -- Get the player's max health.""")
|
||||||
def getMaxHealth(context: Context, args: Arguments): Array[AnyRef] =
|
def getMaxHealth(context: Context, args: Arguments): Array[AnyRef] =
|
||||||
withPlayer(player => Array(float2Float(player.getMaxHealth)))
|
withPlayer(player => result(player.getMaxHealth))
|
||||||
|
|
||||||
@Callback(doc = """function(health:number) -- Set the player's health.""")
|
@Callback(doc = """function(health:number) -- Set the player's health.""")
|
||||||
def setHealth(context: Context, args: Arguments): Array[AnyRef] =
|
def setHealth(context: Context, args: Arguments): Array[AnyRef] =
|
||||||
@ -120,53 +148,71 @@ object DebugCard {
|
|||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
@Callback(doc = """function():number -- Gets the numeric id of the current dimension.""")
|
@Callback(doc = """function():number -- Gets the numeric id of the current dimension.""")
|
||||||
def getDimensionId(context: Context, args: Arguments): Array[AnyRef] =
|
def getDimensionId(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
result(world.provider.dimensionId)
|
result(world.provider.dimensionId)
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = """function():string -- Gets the name of the current dimension.""")
|
@Callback(doc = """function():string -- Gets the name of the current dimension.""")
|
||||||
def getDimensionName(context: Context, args: Arguments): Array[AnyRef] =
|
def getDimensionName(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
result(world.provider.getDimensionName)
|
result(world.provider.getDimensionName)
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = """function():number -- Gets the seed of the world.""")
|
@Callback(doc = """function():number -- Gets the seed of the world.""")
|
||||||
def getSeed(context: Context, args: Arguments): Array[AnyRef] =
|
def getSeed(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
result(world.getSeed)
|
result(world.getSeed)
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = """function():boolean -- Returns whether it is currently raining.""")
|
@Callback(doc = """function():boolean -- Returns whether it is currently raining.""")
|
||||||
def isRaining(context: Context, args: Arguments): Array[AnyRef] =
|
def isRaining(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
result(world.isRaining)
|
result(world.isRaining)
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = """function(value:boolean) -- Sets whether it is currently raining.""")
|
@Callback(doc = """function(value:boolean) -- Sets whether it is currently raining.""")
|
||||||
def setRaining(context: Context, args: Arguments): Array[AnyRef] = {
|
def setRaining(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
world.getWorldInfo.setRaining(args.checkBoolean(0))
|
world.getWorldInfo.setRaining(args.checkBoolean(0))
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
@Callback(doc = """function():boolean -- Returns whether it is currently thundering.""")
|
@Callback(doc = """function():boolean -- Returns whether it is currently thundering.""")
|
||||||
def isThundering(context: Context, args: Arguments): Array[AnyRef] =
|
def isThundering(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
result(world.isThundering)
|
result(world.isThundering)
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = """function(value:boolean) -- Sets whether it is currently thundering.""")
|
@Callback(doc = """function(value:boolean) -- Sets whether it is currently thundering.""")
|
||||||
def setThundering(context: Context, args: Arguments): Array[AnyRef] = {
|
def setThundering(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
world.getWorldInfo.setThundering(args.checkBoolean(0))
|
world.getWorldInfo.setThundering(args.checkBoolean(0))
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
@Callback(doc = """function():number -- Get the current world time.""")
|
@Callback(doc = """function():number -- Get the current world time.""")
|
||||||
def getTime(context: Context, args: Arguments): Array[AnyRef] =
|
def getTime(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
result(world.getWorldTime)
|
result(world.getWorldTime)
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = """function(value:number) -- Set the current world time.""")
|
@Callback(doc = """function(value:number) -- Set the current world time.""")
|
||||||
def setTime(context: Context, args: Arguments): Array[AnyRef] = {
|
def setTime(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
world.setWorldTime(args.checkDouble(0).toLong)
|
world.setWorldTime(args.checkDouble(0).toLong)
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
@Callback(doc = """function():number, number, number -- Get the current spawn point coordinates.""")
|
@Callback(doc = """function():number, number, number -- Get the current spawn point coordinates.""")
|
||||||
def getSpawnPoint(context: Context, args: Arguments): Array[AnyRef] =
|
def getSpawnPoint(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
result(world.getWorldInfo.getSpawnX, world.getWorldInfo.getSpawnY, world.getWorldInfo.getSpawnZ)
|
result(world.getWorldInfo.getSpawnX, world.getWorldInfo.getSpawnY, world.getWorldInfo.getSpawnZ)
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = """function(x:number, y:number, z:number) -- Set the spawn point coordinates.""")
|
@Callback(doc = """function(x:number, y:number, z:number) -- Set the spawn point coordinates.""")
|
||||||
def setSpawnPoint(context: Context, args: Arguments): Array[AnyRef] = {
|
def setSpawnPoint(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
world.getWorldInfo.setSpawnPosition(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2))
|
world.getWorldInfo.setSpawnPosition(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2))
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
@ -174,42 +220,58 @@ object DebugCard {
|
|||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
@Callback(doc = """function(x:number, y:number, z:number):number -- Get the ID of the block at the specified coordinates.""")
|
@Callback(doc = """function(x:number, y:number, z:number):number -- Get the ID of the block at the specified coordinates.""")
|
||||||
def getBlockId(context: Context, args: Arguments): Array[AnyRef] =
|
def getBlockId(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
result(Block.getIdFromBlock(world.getBlock(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2))))
|
result(Block.getIdFromBlock(world.getBlock(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2))))
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = """function(x:number, y:number, z:number):number -- Get the metadata of the block at the specified coordinates.""")
|
@Callback(doc = """function(x:number, y:number, z:number):number -- Get the metadata of the block at the specified coordinates.""")
|
||||||
def getMetadata(context: Context, args: Arguments): Array[AnyRef] =
|
def getMetadata(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
result(world.getBlockMetadata(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2)))
|
result(world.getBlockMetadata(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2)))
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = """function(x:number, y:number, z:number):number -- Check whether the block at the specified coordinates is loaded.""")
|
@Callback(doc = """function(x:number, y:number, z:number):number -- Check whether the block at the specified coordinates is loaded.""")
|
||||||
def isLoaded(context: Context, args: Arguments): Array[AnyRef] =
|
def isLoaded(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
result(world.blockExists(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2)))
|
result(world.blockExists(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2)))
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = """function(x:number, y:number, z:number):number -- Check whether the block at the specified coordinates has a tile entity.""")
|
@Callback(doc = """function(x:number, y:number, z:number):number -- Check whether the block at the specified coordinates has a tile entity.""")
|
||||||
def hasTileEntity(context: Context, args: Arguments): Array[AnyRef] = {
|
def hasTileEntity(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
val (x, y, z) = (args.checkInteger(0), args.checkInteger(1), args.checkInteger(2))
|
val (x, y, z) = (args.checkInteger(0), args.checkInteger(1), args.checkInteger(2))
|
||||||
val block = world.getBlock(x, y, z)
|
val block = world.getBlock(x, y, z)
|
||||||
result(block != null && block.hasTileEntity(world.getBlockMetadata(x, y, z)))
|
result(block != null && block.hasTileEntity(world.getBlockMetadata(x, y, z)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Callback(doc = """function(x:number, y:number, z:number):number -- Get the light opacity of the block at the specified coordinates.""")
|
@Callback(doc = """function(x:number, y:number, z:number):number -- Get the light opacity of the block at the specified coordinates.""")
|
||||||
def getLightOpacity(context: Context, args: Arguments): Array[AnyRef] =
|
def getLightOpacity(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
result(world.getBlockLightOpacity(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2)))
|
result(world.getBlockLightOpacity(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2)))
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = """function(x:number, y:number, z:number):number -- Get the light value (emission) of the block at the specified coordinates.""")
|
@Callback(doc = """function(x:number, y:number, z:number):number -- Get the light value (emission) of the block at the specified coordinates.""")
|
||||||
def getLightValue(context: Context, args: Arguments): Array[AnyRef] =
|
def getLightValue(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
result(world.getBlockLightValue(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2)))
|
result(world.getBlockLightValue(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2)))
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = """function(x:number, y:number, z:number):number -- Get whether the block at the specified coordinates is directly under the sky.""")
|
@Callback(doc = """function(x:number, y:number, z:number):number -- Get whether the block at the specified coordinates is directly under the sky.""")
|
||||||
def canSeeSky(context: Context, args: Arguments): Array[AnyRef] =
|
def canSeeSky(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
result(world.canBlockSeeTheSky(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2)))
|
result(world.canBlockSeeTheSky(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2)))
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = """function(x:number, y:number, z:number, id:number, meta:number):number -- Set the block at the specified coordinates.""")
|
@Callback(doc = """function(x:number, y:number, z:number, id:number, meta:number):number -- Set the block at the specified coordinates.""")
|
||||||
def setBlock(context: Context, args: Arguments): Array[AnyRef] =
|
def setBlock(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
result(world.setBlock(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2), Block.getBlockById(args.checkInteger(3)), args.checkInteger(4), 3))
|
result(world.setBlock(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2), Block.getBlockById(args.checkInteger(3)), args.checkInteger(4), 3))
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = """function(x1:number, y1:number, z1:number, x2:number, y2:number, z2:number, id:number, meta:number):number -- Set all blocks in the area defined by the two corner points (x1, y1, z1) and (x2, y2, z2).""")
|
@Callback(doc = """function(x1:number, y1:number, z1:number, x2:number, y2:number, z2:number, id:number, meta:number):number -- Set all blocks in the area defined by the two corner points (x1, y1, z1) and (x2, y2, z2).""")
|
||||||
def setBlocks(context: Context, args: Arguments): Array[AnyRef] = {
|
def setBlocks(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
checkEnabled()
|
||||||
val (xMin, yMin, zMin) = (args.checkInteger(0), args.checkInteger(1), args.checkInteger(2))
|
val (xMin, yMin, zMin) = (args.checkInteger(0), args.checkInteger(1), args.checkInteger(2))
|
||||||
val (xMax, yMax, zMax) = (args.checkInteger(3), args.checkInteger(4), args.checkInteger(5))
|
val (xMax, yMax, zMax) = (args.checkInteger(3), args.checkInteger(4), args.checkInteger(5))
|
||||||
val (block, metadata) = (Block.getBlockById(args.checkInteger(6)), args.checkInteger(7))
|
val (block, metadata) = (Block.getBlockById(args.checkInteger(6)), args.checkInteger(7))
|
||||||
|
@ -1,153 +0,0 @@
|
|||||||
package li.cil.oc.util;
|
|
||||||
|
|
||||||
/* Original wcwidth code comes from the musl C library.
|
|
||||||
*
|
|
||||||
* Copyright © 2005-2014 Rich Felker, et al.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
||||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
public class FontUtil {
|
|
||||||
private static final short table[] = {
|
|
||||||
16,16,16,18,19,20,21,22,23,24,25,26,27,28,29,30,31,16,16,32,16,16,16,33,34,35,
|
|
||||||
36,37,38,39,16,16,40,16,16,16,16,16,16,16,16,16,16,16,41,42,16,16,43,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,44,16,45,46,47,48,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,49,16,16,50,51,16,52,16,16,
|
|
||||||
16,16,16,16,16,16,53,16,16,16,16,16,54,55,16,16,16,16,56,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,57,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,58,59,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,
|
|
||||||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
||||||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,248,3,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,255,255,255,255,191,
|
|
||||||
182,0,0,0,0,0,0,0,31,0,255,7,0,0,0,0,0,248,255,255,0,0,1,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,192,191,159,61,0,0,0,128,2,0,0,0,255,255,255,7,0,0,0,0,0,0,0,0,0,0,192,255,
|
|
||||||
1,0,0,0,0,0,0,248,15,0,0,0,192,251,239,62,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,240,255,255,127,7,0,0,0,0,0,0,20,254,33,254,0,12,0,0,0,2,0,0,0,0,0,
|
|
||||||
0,16,30,32,0,0,12,0,0,0,6,0,0,0,0,0,0,16,134,57,2,0,0,0,35,0,6,0,0,0,0,0,0,16,
|
|
||||||
190,33,0,0,12,0,0,0,2,0,0,0,0,0,0,144,30,32,64,0,12,0,0,0,4,0,0,0,0,0,0,0,1,
|
|
||||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,192,193,61,96,0,12,0,0,0,0,0,0,0,0,0,0,144,64,48,
|
|
||||||
0,0,12,0,0,0,0,0,0,0,0,0,0,0,30,32,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,4,92,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,242,7,128,127,0,0,0,0,0,0,0,0,0,0,0,0,242,27,0,63,0,0,0,0,0,0,
|
|
||||||
0,0,0,3,0,0,160,2,0,0,0,0,0,0,254,127,223,224,255,254,255,255,255,31,64,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,224,253,102,0,0,0,195,1,0,30,0,100,32,0,32,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,224,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
28,0,0,0,28,0,0,0,12,0,0,0,12,0,0,0,0,0,0,0,176,63,64,254,15,32,0,0,0,0,0,56,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,135,1,4,
|
|
||||||
14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,1,0,0,0,0,0,0,64,
|
|
||||||
127,229,31,248,159,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,15,0,0,0,0,0,208,23,4,0,0,
|
|
||||||
0,0,248,15,0,3,0,0,0,60,11,0,0,0,0,0,0,64,163,3,0,0,0,0,0,0,240,207,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,247,255,253,33,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,255,255,255,255,127,0,0,240,0,248,0,0,0,124,0,0,0,0,0,0,31,
|
|
||||||
252,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,0,60,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,247,63,0,0,0,128,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,3,0,68,8,0,0,96,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,255,
|
|
||||||
255,3,0,0,0,0,0,192,63,0,0,128,255,3,0,0,0,0,0,7,0,0,0,0,0,200,19,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,126,102,0,8,16,0,0,0,0,0,0,0,0,0,0,0,0,157,193,2,0,0,0,0,48,64,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,33,0,0,0,0,0,64,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,0,0,127,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,32,110,240,0,0,0,0,0,135,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,255,127,0,0,0,0,0,0,0,3,0,0,0,0,0,120,38,0,0,
|
|
||||||
0,0,0,0,0,0,7,0,0,0,128,239,31,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,192,127,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,40,191,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,128,3,248,255,231,15,0,0,0,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
};
|
|
||||||
private static final short wtable[] = {
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,18,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,19,16,16,16,16,16,16,16,16,16,16,20,21,22,23,24,17,
|
|
||||||
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,25,
|
|
||||||
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
|
|
||||||
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
|
|
||||||
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
|
|
||||||
17,17,17,17,17,17,17,17,26,16,16,16,16,27,16,16,17,17,17,17,17,17,17,17,17,17,
|
|
||||||
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
|
|
||||||
17,17,17,17,17,17,17,28,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,16,16,16,29,30,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,31,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
|
|
||||||
16,16,16,16,32,16,16,16,16,16,16,16,16,16,16,16,16,16,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,
|
|
||||||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
||||||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,
|
|
||||||
0,248,0,0,0,0,0,0,0,0,0,0,252,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,251,255,255,255,
|
|
||||||
255,255,255,255,255,255,255,15,0,255,255,255,255,255,255,255,255,255,255,255,
|
|
||||||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,63,0,0,0,255,15,
|
|
||||||
255,255,255,255,255,255,255,127,254,255,255,255,255,255,255,255,255,255,127,
|
|
||||||
254,255,255,255,255,255,255,255,255,255,255,255,255,224,255,255,255,255,63,
|
|
||||||
254,255,255,255,255,255,255,255,255,255,255,127,255,255,255,255,255,7,255,255,
|
|
||||||
255,255,15,0,255,255,255,255,255,127,255,255,255,255,255,0,255,255,255,255,
|
|
||||||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,127,255,
|
|
||||||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
|
|
||||||
255,255,255,255,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,
|
|
||||||
255,255,255,255,255,255,31,255,255,255,255,255,255,127,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,255,255,255,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,
|
|
||||||
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,15,0,255,
|
|
||||||
255,127,248,255,255,255,255,255,15,0,0,255,3,0,0,255,255,255,255,247,255,127,
|
|
||||||
15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,255,255,255,255,255,255,255,255,
|
|
||||||
255,255,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,255,255,255,255,255,7,255,1,3,0,0,
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
||||||
};
|
|
||||||
|
|
||||||
public static int wcwidth(int charCode) {
|
|
||||||
if (charCode < 0xFF) {
|
|
||||||
return ((charCode + 1) & 0x7F) >= 0x21 ? 1 : (charCode > 0) ? -1 : 0;
|
|
||||||
} else if ((charCode & 0xfffeffff) < 0xfffe) {
|
|
||||||
if (((table[table[charCode >> 8] * 32 + ((charCode & 0xFF) >> 3)] >> (charCode & 7)) & 1) == 1)
|
|
||||||
return 0;
|
|
||||||
else if (((wtable[wtable[charCode >> 8] * 32 + ((charCode & 0xFF) >> 3)] >> (charCode & 7)) & 1) == 1)
|
|
||||||
return 2;
|
|
||||||
else return 1;
|
|
||||||
} else if ((charCode & 0xfffe) == 0xfffe)
|
|
||||||
return -1;
|
|
||||||
else if ((charCode - 0x20000) < 0x20000)
|
|
||||||
return 2;
|
|
||||||
else if ((charCode == 0xe0001) || ((charCode - 0xe0020) < 0x5f) || ((charCode - 0xe0100) < 0xef))
|
|
||||||
return 0;
|
|
||||||
else return 1;
|
|
||||||
}
|
|
||||||
}
|
|
27
src/main/scala/li/cil/oc/util/FontUtil.scala
Normal file
27
src/main/scala/li/cil/oc/util/FontUtil.scala
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package li.cil.oc.util
|
||||||
|
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
|
import li.cil.oc.OpenComputers
|
||||||
|
|
||||||
|
object FontUtil {
|
||||||
|
// Note: we load the widths from a file (one byte per width) because the Scala
|
||||||
|
// compiler craps its pants when we try to have it as an array in the source
|
||||||
|
// file... seems having an array with 0x10000 entries leads to stack overflows,
|
||||||
|
// who would have known!
|
||||||
|
private val widths = {
|
||||||
|
val ba = Array.fill[Byte](0x10000)(-1)
|
||||||
|
val is = FontUtil.getClass.getResourceAsStream("/assets/opencomputers/wcwidth.bin")
|
||||||
|
if (is != null) {
|
||||||
|
try {
|
||||||
|
is.read(ba)
|
||||||
|
is.close()
|
||||||
|
} catch {
|
||||||
|
case e: IOException => OpenComputers.log.warn("Failed loading character widths. Font rendering will probably be derpy is all hell.", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ba
|
||||||
|
}
|
||||||
|
|
||||||
|
def wcwidth(ch: Int) = if (ch < 0 || ch >= widths.length) -1 else widths(ch)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user