mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 11:48:02 -04:00
Merge branch 'master-MC1.8' of github.com:MightyPirates/OpenComputers into OC1.5-MC1.8
Conflicts: build.properties
This commit is contained in:
commit
ea0f13e24f
@ -263,6 +263,7 @@ sourceSets {
|
||||
exclude 'li/cil/oc/integration/projectred/**'
|
||||
exclude 'li/cil/oc/integration/railcraft/**'
|
||||
exclude 'li/cil/oc/integration/redlogic/**'
|
||||
exclude 'li/cil/oc/integration/rotarycraft/**'
|
||||
exclude 'li/cil/oc/integration/stargatetech2/**'
|
||||
exclude 'li/cil/oc/integration/tcon/**'
|
||||
exclude 'li/cil/oc/integration/thermalexpansion/**'
|
||||
|
@ -1,7 +1,7 @@
|
||||
minecraft.version=1.8
|
||||
forge.version=11.14.3.1450
|
||||
|
||||
oc.version=1.5.18
|
||||
oc.version=1.5.19
|
||||
oc.subversion=
|
||||
|
||||
ae2.version=rv2-beta-26
|
||||
|
@ -1368,6 +1368,11 @@ opencomputers {
|
||||
# The recommended method is to use the database component instead.
|
||||
allowItemStackNBTTags: false
|
||||
}
|
||||
|
||||
buildcraft {
|
||||
# Cost to convert a loot disk to another in the BuildCraft programming table.
|
||||
programmingTableCost: 5000
|
||||
}
|
||||
}
|
||||
|
||||
# Settings that are intended for debugging issues, not for normal use.
|
||||
|
@ -0,0 +1,12 @@
|
||||
[{
|
||||
"includes": [
|
||||
"traits/environment.json",
|
||||
"traits/inventory.json",
|
||||
"traits/powerAcceptor.json"
|
||||
],
|
||||
"nbt": {
|
||||
"blacklist": [
|
||||
"oc:adapter.blocks"
|
||||
]
|
||||
}
|
||||
}]
|
@ -0,0 +1,12 @@
|
||||
[{
|
||||
"includes": [
|
||||
"traits/environment.json",
|
||||
"traits/inventory.json",
|
||||
"traits/powerAcceptor.json"
|
||||
],
|
||||
"nbt": {
|
||||
"blacklist": [
|
||||
"oc:remaining"
|
||||
]
|
||||
}
|
||||
}]
|
@ -0,0 +1,3 @@
|
||||
[{
|
||||
"includes": ["traits/environment.json"]
|
||||
}]
|
@ -0,0 +1,3 @@
|
||||
[{
|
||||
"includes": ["traits/environment.json"]
|
||||
}]
|
@ -0,0 +1,9 @@
|
||||
[{
|
||||
"includes": [
|
||||
"traits/computer.json",
|
||||
"traits/inventory.json",
|
||||
"traits/powerAcceptor.json",
|
||||
"traits/redstone.json",
|
||||
"traits/rotatable.json"
|
||||
]
|
||||
}]
|
@ -0,0 +1,3 @@
|
||||
[{
|
||||
"includes": ["case.json"]
|
||||
}]
|
@ -0,0 +1,3 @@
|
||||
[{
|
||||
"includes": ["case.json"]
|
||||
}]
|
@ -0,0 +1,3 @@
|
||||
[{
|
||||
"includes": ["case.json"]
|
||||
}]
|
@ -0,0 +1,3 @@
|
||||
[{
|
||||
"includes": ["case.json"]
|
||||
}]
|
@ -0,0 +1,16 @@
|
||||
[{
|
||||
"includes": [
|
||||
"traits/environment.json",
|
||||
"traits/inventory.json",
|
||||
"traits/powerAcceptor.json",
|
||||
"traits/redstone.json",
|
||||
"traits/rotatable.json"
|
||||
],
|
||||
"nbt": {
|
||||
"blacklist": [
|
||||
"chargeSpeed",
|
||||
"hasPower",
|
||||
"invertSignal"
|
||||
]
|
||||
}
|
||||
}]
|
@ -0,0 +1,14 @@
|
||||
[{
|
||||
"includes": [
|
||||
"traits/environment.json",
|
||||
"traits/inventory.json",
|
||||
"traits/powerAcceptor.json"
|
||||
],
|
||||
"nbt": {
|
||||
"blacklist": [
|
||||
"oc:buffer",
|
||||
"oc:queue",
|
||||
"oc:total"
|
||||
]
|
||||
}
|
||||
}]
|
@ -0,0 +1,7 @@
|
||||
[{
|
||||
"includes": [
|
||||
"traits/environment.json",
|
||||
"traits/inventory.json",
|
||||
"traits/rotatable.json"
|
||||
]
|
||||
}]
|
@ -0,0 +1,3 @@
|
||||
[{
|
||||
"includes": ["traits/environment.json"]
|
||||
}]
|
@ -0,0 +1,7 @@
|
||||
[{
|
||||
"includes": [
|
||||
"traits/environment.json",
|
||||
"traits/externalData.json",
|
||||
"traits/rotatable.json"
|
||||
]
|
||||
}]
|
@ -0,0 +1,3 @@
|
||||
[{
|
||||
"includes": ["hologram.json"]
|
||||
}]
|
@ -0,0 +1,3 @@
|
||||
[{
|
||||
"includes": ["hologram.json"]
|
||||
}]
|
@ -0,0 +1,8 @@
|
||||
[{
|
||||
"includes": ["traits/rotatable.json"],
|
||||
"nbt": {
|
||||
"blacklist": [
|
||||
"oc:keyboard"
|
||||
]
|
||||
}
|
||||
}]
|
@ -0,0 +1,18 @@
|
||||
[{
|
||||
"includes": [
|
||||
"traits/computer.json",
|
||||
"traits/hub.json",
|
||||
"traits/inventory.json",
|
||||
"traits/powerAcceptor.json",
|
||||
"traits/redstone.json",
|
||||
"traits/rotatable.json"
|
||||
],
|
||||
"nbt": {
|
||||
"blacklist": [
|
||||
"oc:info",
|
||||
"oc:snooper",
|
||||
"oc:componentNodes",
|
||||
"oc:outputs"
|
||||
]
|
||||
}
|
||||
}]
|
@ -0,0 +1,3 @@
|
||||
[{
|
||||
"includes": ["traits/environment.json"]
|
||||
}]
|
@ -0,0 +1,6 @@
|
||||
[{
|
||||
"includes": [
|
||||
"traits/environment.json",
|
||||
"traits/redstone.json"
|
||||
]
|
||||
}]
|
@ -0,0 +1,6 @@
|
||||
[{
|
||||
"includes": [
|
||||
"traits/environment.json",
|
||||
"traits/powerAcceptor.json"
|
||||
]
|
||||
}]
|
@ -0,0 +1,7 @@
|
||||
[{
|
||||
"nbt": {
|
||||
"blacklist": [
|
||||
"oc:connector"
|
||||
]
|
||||
}
|
||||
}]
|
@ -0,0 +1,16 @@
|
||||
[{
|
||||
"includes": [
|
||||
"traits/environment.json",
|
||||
"traits/inventory.json"
|
||||
],
|
||||
"nbt": {
|
||||
"blacklist": [
|
||||
"oc:active",
|
||||
"oc:amountInk",
|
||||
"oc:amountMaterial",
|
||||
"oc:limit",
|
||||
"oc:remaining",
|
||||
"oc:total"
|
||||
]
|
||||
}
|
||||
}]
|
@ -0,0 +1,7 @@
|
||||
[{
|
||||
"includes": [
|
||||
"traits/environment.json",
|
||||
"traits/inventory.json",
|
||||
"traits/rotatable.json"
|
||||
]
|
||||
}]
|
@ -0,0 +1,8 @@
|
||||
[{
|
||||
"includes": ["traits/redstone.json"],
|
||||
"nbt": {
|
||||
"blacklist": [
|
||||
"oc:redstone/node"
|
||||
]
|
||||
}
|
||||
}]
|
@ -0,0 +1,12 @@
|
||||
[{
|
||||
"includes": [
|
||||
"traits/hub.json",
|
||||
"traits/inventory.json",
|
||||
"traits/powerAcceptor.json"
|
||||
],
|
||||
"nbt": {
|
||||
"blacklist": [
|
||||
"oc:componentNodes"
|
||||
]
|
||||
}
|
||||
}]
|
@ -0,0 +1,24 @@
|
||||
[{
|
||||
"includes": [
|
||||
"traits/computer.json",
|
||||
"traits/environment.json",
|
||||
"traits/inventory.json",
|
||||
"traits/redstone.json",
|
||||
"traits/rotatable.json"
|
||||
],
|
||||
"nbt": {
|
||||
"blacklist": [
|
||||
"display",
|
||||
"oc:components",
|
||||
"oc:containers",
|
||||
"oc:lightColor",
|
||||
"oc:owner",
|
||||
"oc:ownerUuid",
|
||||
"oc:robot",
|
||||
"oc:robotEnergy",
|
||||
"oc:selectedSlot",
|
||||
"oc:selectedTank",
|
||||
"oc:storedEnergy"
|
||||
]
|
||||
}
|
||||
}]
|
@ -0,0 +1,14 @@
|
||||
[{
|
||||
"includes": [
|
||||
"traits/environment.json",
|
||||
"traits/externalData.json",
|
||||
"traits/redstone.json",
|
||||
"traits/rotatable.json"
|
||||
],
|
||||
"nbt": {
|
||||
"blacklist": [
|
||||
"oc:hasPower",
|
||||
"oc:hadRedstoneInput"
|
||||
]
|
||||
}
|
||||
}]
|
@ -0,0 +1,3 @@
|
||||
[{
|
||||
"includes": ["screen.json"]
|
||||
}]
|
@ -0,0 +1,3 @@
|
||||
[{
|
||||
"includes": ["screen.json"]
|
||||
}]
|
@ -0,0 +1,3 @@
|
||||
[{
|
||||
"includes": ["screen.json"]
|
||||
}]
|
@ -0,0 +1,15 @@
|
||||
[{
|
||||
"includes": [
|
||||
"traits/hub.json",
|
||||
"traits/inventory.json",
|
||||
"traits/powerAcceptor.json",
|
||||
"traits/redstone.json",
|
||||
"traits/rotatable.json"
|
||||
],
|
||||
"nbt": {
|
||||
"blacklist": [
|
||||
"oc:servers",
|
||||
"oc:terminals"
|
||||
]
|
||||
}
|
||||
}]
|
@ -0,0 +1,7 @@
|
||||
[{
|
||||
"nbt": {
|
||||
"blacklist": [
|
||||
"oc:computer"
|
||||
]
|
||||
}
|
||||
}]
|
@ -0,0 +1,8 @@
|
||||
[{
|
||||
"nbt": {
|
||||
"blacklist": [
|
||||
"node",
|
||||
"oc:node"
|
||||
]
|
||||
}
|
||||
}]
|
@ -0,0 +1,9 @@
|
||||
[{
|
||||
"nbt": {
|
||||
"blacklist": [
|
||||
"chunkX",
|
||||
"chunkZ",
|
||||
"dimension"
|
||||
]
|
||||
}
|
||||
}]
|
@ -0,0 +1,8 @@
|
||||
[{
|
||||
"nbt": {
|
||||
"blacklist": [
|
||||
"oc:plugs",
|
||||
"oc:queue"
|
||||
]
|
||||
}
|
||||
}]
|
@ -0,0 +1,8 @@
|
||||
[{
|
||||
"ignoreInventoryContents": true,
|
||||
"nbt": {
|
||||
"blacklist": [
|
||||
"oc:items"
|
||||
]
|
||||
}
|
||||
}]
|
@ -0,0 +1,9 @@
|
||||
[{
|
||||
"nbt": {
|
||||
"blacklist": [
|
||||
"oc:ae2power",
|
||||
"oc:ic2power",
|
||||
"oc:ic2cpower"
|
||||
]
|
||||
}
|
||||
}]
|
@ -0,0 +1,11 @@
|
||||
[{
|
||||
"nbt": {
|
||||
"blacklist": [
|
||||
"oc:rs.input",
|
||||
"oc:rs.output",
|
||||
"oc:rs.bundledInput",
|
||||
"oc:rs.bundledOutput",
|
||||
"oc:rs.rednetInput"
|
||||
]
|
||||
}
|
||||
}]
|
@ -0,0 +1,7 @@
|
||||
[{
|
||||
"rotation": {
|
||||
"type": "nbtField",
|
||||
"tag": "oc:yaw",
|
||||
"format": "ForgeDirection"
|
||||
}
|
||||
}]
|
@ -0,0 +1,3 @@
|
||||
[{
|
||||
"includes": ["traits/environment.json"]
|
||||
}]
|
@ -0,0 +1,7 @@
|
||||
[{
|
||||
"includes": [
|
||||
"traits/environment.json",
|
||||
"traits/redstone.json",
|
||||
"traits/rotatable.json"
|
||||
]
|
||||
}]
|
@ -1,19 +1,57 @@
|
||||
local shell = require("shell")
|
||||
|
||||
local fs = require("filesystem")
|
||||
local args = shell.parse(...)
|
||||
|
||||
if #args == 0 then
|
||||
for name, value in shell.aliases() do
|
||||
io.write(name .. " " .. value .. "\n")
|
||||
local shell_name = '-' .. fs.name(os.getenv("SHELL"))
|
||||
local cmd_name = "alias"
|
||||
local error_prefix = shell_name .. ": " .. cmd_name .. ": "
|
||||
|
||||
local function validAliasName(k)
|
||||
return k:match("[/%$`=|&;%(%)<> \t]") == nil
|
||||
end
|
||||
elseif #args == 1 then
|
||||
local value = shell.getAlias(args[1])
|
||||
if value then
|
||||
io.write(value)
|
||||
|
||||
local function setAlias(k, v)
|
||||
if not validAliasName(k) then
|
||||
io.stderr:write(string.format("%s `%s': invalid alias name\n", error_prefix, k))
|
||||
else
|
||||
io.stderr:write("no such alias")
|
||||
shell.setAlias(k, v)
|
||||
end
|
||||
end
|
||||
|
||||
local function printAlias(k)
|
||||
local v = shell.getAlias(k)
|
||||
if not v then
|
||||
io.stderr:write(string.format("%s %s: not found\n", error_prefix, k))
|
||||
else
|
||||
io.write(string.format("alias %s='%s'\n", k, v))
|
||||
end
|
||||
end
|
||||
|
||||
local function splitPair(arg)
|
||||
local matchBegin, matchEnd = arg:find("=")
|
||||
if matchBegin == nil or matchBegin == 1 then
|
||||
return arg
|
||||
else
|
||||
return arg:sub(1, matchBegin - 1), arg:sub(matchEnd + 1)
|
||||
end
|
||||
end
|
||||
|
||||
local function handlePair(k, v)
|
||||
if v then
|
||||
return setAlias(k, v)
|
||||
else
|
||||
return printAlias(k)
|
||||
end
|
||||
end
|
||||
|
||||
if not next(args) then -- no args
|
||||
-- print all aliases
|
||||
for k,v in shell.aliases() do
|
||||
print(string.format("alias %s='%s'", k, v))
|
||||
end
|
||||
else
|
||||
shell.setAlias(args[1], args[2])
|
||||
io.write("alias created: " .. args[1] .. " -> " .. args[2])
|
||||
for k,v in pairs(args) do
|
||||
checkArg(1,v,"string")
|
||||
handlePair(splitPair(v))
|
||||
end
|
||||
end
|
@ -1,11 +1,105 @@
|
||||
local shell = require("shell")
|
||||
local fs = require("filesystem")
|
||||
|
||||
local args = shell.parse(...)
|
||||
local shell_name = '-' .. fs.name(os.getenv("SHELL"))
|
||||
local cmd_name = "cd"
|
||||
local error_prefix = shell_name .. ": " .. cmd_name .. ": "
|
||||
|
||||
local args, ops = shell.parse(...)
|
||||
local path = nil
|
||||
local verbose = false
|
||||
|
||||
-- order of if blocks following POSIX specification on cd
|
||||
-- this is not a complete support of the POSIX spec - I am
|
||||
-- not supporting -L and -P options for differentiating between
|
||||
-- logically and physically following symlink paths
|
||||
-- but, we do support CDPATH
|
||||
if #args == 0 then
|
||||
io.write("Usage: cd <dirname>")
|
||||
local home = os.getenv("HOME")
|
||||
if not home then
|
||||
io.stderr:write(error_prefix .. "HOME not set\n")
|
||||
return 1
|
||||
end
|
||||
path = home
|
||||
elseif args[1]:len() > 0 and args[1]:sub(1,1) == '/' then
|
||||
path = args[1]
|
||||
elseif args[1]:len() > 0 and args[1]:sub(1,1) == "." then
|
||||
path = args[1]
|
||||
elseif args[1] == '-' then
|
||||
verbose = true
|
||||
local oldpwd = os.getenv("OLDPWD");
|
||||
if not oldpwd then
|
||||
io.stderr:write(error_prefix .. "OLDPWD not set\n")
|
||||
return 1
|
||||
end
|
||||
path = oldpwd
|
||||
else
|
||||
local result, reason = shell.setWorkingDirectory(shell.resolve(args[1]))
|
||||
local CDPATH = os.getenv("CDPATH")
|
||||
if CDPATH then
|
||||
for cd_path in CDPATH:gmatch("[^:]*:?") do
|
||||
-- [^:]+ would be simpler but CDPATH can define
|
||||
-- empty paths if the user wants to check . before
|
||||
-- the end of the cdpath list
|
||||
|
||||
if cd_path and cd_path:len() > 0 then
|
||||
-- remove trailing : now if it was matched
|
||||
if cd_path:sub(-1) == ':' then
|
||||
cd_path = cd_path:sub(1, -2)
|
||||
end
|
||||
|
||||
-- if cd_path is empty (POSIX says null) then check ./
|
||||
-- there is a case where we don't hit this if block for
|
||||
-- an empty cd_path, i.e. CDPATH="" which SHOULD be considered
|
||||
-- null for this purpose - but, that scenario would also act the
|
||||
-- same as no CDPATH and test ./ independently - so we get the
|
||||
-- same results. I've tested this on gentoo linux and confirmed
|
||||
-- curiously, empty checks are not verbose
|
||||
local empty_check = false
|
||||
if cd_path == "" then
|
||||
cd_path = "."
|
||||
empty_check = true
|
||||
end
|
||||
|
||||
-- concat / on cd_path if it doesn't have one
|
||||
if cd_path:sub(-1) ~= '/' then
|
||||
cd_path = cd_path .. '/'
|
||||
end
|
||||
|
||||
local test_path = cd_path .. args[1]
|
||||
|
||||
-- resolve here because fs.exists doesn't
|
||||
-- understand . and ..
|
||||
test_path = shell.resolve(test_path)
|
||||
if fs.exists(test_path) then
|
||||
path = test_path
|
||||
verbose = not empty_check
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if not path then
|
||||
path = args[1]
|
||||
end
|
||||
end
|
||||
|
||||
local resolved = shell.resolve(path)
|
||||
if not fs.exists(resolved) then
|
||||
io.stderr:write(error_prefix .. path .. ": No such file or directory\n")
|
||||
return 1
|
||||
end
|
||||
|
||||
path = resolved
|
||||
|
||||
local oldpwd = shell.getWorkingDirectory()
|
||||
local result, reason = shell.setWorkingDirectory(path);
|
||||
if not result then
|
||||
io.stderr:write(reason)
|
||||
io.stderr:write(error_prefix .. reason)
|
||||
return 1
|
||||
else
|
||||
os.setenv("OLDPWD", oldpwd)
|
||||
end
|
||||
|
||||
if verbose then
|
||||
os.execute("pwd")
|
||||
end
|
||||
|
133
src/main/resources/assets/opencomputers/loot/OpenOS/bin/du.lua
Normal file
133
src/main/resources/assets/opencomputers/loot/OpenOS/bin/du.lua
Normal file
@ -0,0 +1,133 @@
|
||||
local shell = require("shell")
|
||||
local fs = require("filesystem")
|
||||
|
||||
local args, options, reason = shell.parse(...)
|
||||
if #args == 0 then
|
||||
args[1] = '.'
|
||||
end
|
||||
|
||||
local TRY=[[
|
||||
Try 'du --help' for more information.]]
|
||||
|
||||
local VERSION=[[
|
||||
du (OpenOS bin) 1.0
|
||||
Written by payonel, patterned after GNU coreutils du]]
|
||||
|
||||
local HELP=[[
|
||||
Usage: du [OPTION]... [FILE]...
|
||||
Summarize disk usage of each FILE, recursively for directories.
|
||||
|
||||
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)
|
||||
-s, --summarize display only a total for each argument
|
||||
--help display this help and exit
|
||||
--version output version information and exit]]
|
||||
|
||||
local function writeline(value, pipe)
|
||||
pipe = pipe or io.stdout
|
||||
pipe:write(value)
|
||||
pipe:write('\n')
|
||||
end
|
||||
|
||||
if options.help then
|
||||
writeline(HELP)
|
||||
return true
|
||||
end
|
||||
|
||||
if options.version then
|
||||
writeline(VERSION)
|
||||
return true
|
||||
end
|
||||
|
||||
local function addTrailingSlash(path)
|
||||
if path:sub(-1) ~= '/' then
|
||||
return path .. '/'
|
||||
else
|
||||
return path
|
||||
end
|
||||
end
|
||||
|
||||
local function opCheck(shortName, longName)
|
||||
local enabled = options[shortName] or options[longName]
|
||||
options[shortName] = nil
|
||||
options[longName] = nil
|
||||
return enabled
|
||||
end
|
||||
|
||||
local bHuman = opCheck('h', 'human-readable')
|
||||
local bSummary = opCheck('s', 'summarize')
|
||||
|
||||
if (next(options)) then
|
||||
for op,v in pairs(options) do
|
||||
io.stderr:write(string.format("du: invalid option -- '%s'\n", op))
|
||||
end
|
||||
writeline(TRY, io.stderr)
|
||||
return false
|
||||
end
|
||||
|
||||
local function formatSize(size)
|
||||
if not bHuman then
|
||||
return tostring(size)
|
||||
end
|
||||
local sizes = {"", "K", "M", "G"}
|
||||
local unit = 1
|
||||
local power = options.si and 1000 or 1024
|
||||
while size > power and unit < #sizes do
|
||||
unit = unit + 1
|
||||
size = size / power
|
||||
end
|
||||
|
||||
return math.floor(size * 10) / 10 .. sizes[unit]
|
||||
end
|
||||
|
||||
local function printSize(size, rpath)
|
||||
local displaySize = formatSize(size)
|
||||
writeline(string.format("%s%s", string.format("%-12s", displaySize), rpath))
|
||||
end
|
||||
|
||||
local function visitor(rpath)
|
||||
local subtotal = 0
|
||||
local dirs = 0
|
||||
local spath = shell.resolve(rpath)
|
||||
|
||||
if (fs.isDirectory(spath)) then
|
||||
local list_result = fs.list(spath)
|
||||
for list_item in list_result do
|
||||
local vtotal, vdirs = visitor(addTrailingSlash(rpath) .. list_item)
|
||||
subtotal = subtotal + vtotal
|
||||
dirs = dirs + vdirs
|
||||
end
|
||||
|
||||
if (dirs == 0) then -- no child dirs
|
||||
if (not bSummary) then
|
||||
printSize(subtotal, rpath)
|
||||
end
|
||||
end
|
||||
|
||||
elseif (not fs.isLink(spath)) then
|
||||
subtotal = fs.size(spath)
|
||||
end
|
||||
|
||||
return subtotal, dirs
|
||||
end
|
||||
|
||||
for i,arg in ipairs(args) do
|
||||
local path = shell.resolve(arg)
|
||||
|
||||
if (not fs.exists(path)) then
|
||||
writeline(string.format("%s does not exist", arg), io.stderr)
|
||||
else
|
||||
if (fs.isDirectory(path)) then
|
||||
local total = visitor(arg)
|
||||
|
||||
if (bSummary) then
|
||||
printSize(total, arg)
|
||||
end
|
||||
elseif (fs.isLink(path)) then
|
||||
printSize(0, arg)
|
||||
else
|
||||
printSize(fs.size(path), arg)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
@ -408,25 +408,25 @@ local function getMatchingPrograms(baseName)
|
||||
return result
|
||||
end
|
||||
|
||||
local function getMatchingFiles(partialPrefix, name)
|
||||
local baseName = shell.resolve(partialPrefix .. name)
|
||||
local result, basePath = {}
|
||||
local function getMatchingFiles(basePath, name)
|
||||
local resolvedPath = shell.resolve(basePath)
|
||||
local result, baseName = {}
|
||||
|
||||
-- note: we strip the trailing / to make it easier to navigate through
|
||||
-- directories using tab completion (since entering the / will then serve
|
||||
-- as the intention to go into the currently hinted one).
|
||||
-- if we have a directory but no trailing slash there may be alternatives
|
||||
-- on the same level, so don't look inside that directory... (cont.)
|
||||
if fs.isDirectory(baseName) and baseName:sub(-1) == "/" then
|
||||
basePath = baseName
|
||||
if fs.isDirectory(resolvedPath) and name:len() == 0 then
|
||||
baseName = "^(.-)/?$"
|
||||
else
|
||||
basePath = fs.path(baseName) or "/"
|
||||
baseName = "^(" .. escapeMagic(fs.name(baseName)) .. ".-)/?$"
|
||||
baseName = "^(" .. escapeMagic(name) .. ".-)/?$"
|
||||
end
|
||||
for file in fs.list(basePath) do
|
||||
|
||||
for file in fs.list(resolvedPath) do
|
||||
local match = file:match(baseName)
|
||||
if match then
|
||||
table.insert(result, partialPrefix .. match)
|
||||
table.insert(result, basePath .. match)
|
||||
end
|
||||
end
|
||||
-- (cont.) but if there's only one match and it's a directory, *then* we
|
||||
@ -450,7 +450,8 @@ local function hintHandler(line, cursor)
|
||||
result = getMatchingPrograms(line)
|
||||
else -- just look normal files
|
||||
local partialPrefix = (partial or line)
|
||||
local name = fs.name(partialPrefix)
|
||||
local name = partialPrefix:gsub("/+", "/")
|
||||
name = name:sub(-1) == '/' and '' or fs.name(name)
|
||||
partialPrefix = partialPrefix:sub(1, -name:len() - 1)
|
||||
result = getMatchingFiles(partialPrefix, name)
|
||||
end
|
||||
|
@ -183,7 +183,7 @@ redstoneCard1 {
|
||||
["", "oc:materialCard", ""]]
|
||||
}
|
||||
redstoneCard2 {
|
||||
input: [[blockRedstone, "oc:circuitChip2", enderPearl]
|
||||
input: [[blockRedstone, "oc:circuitChip2", materialEnderPearl]
|
||||
["", "oc:materialCard", ""]]
|
||||
}
|
||||
lanCard {
|
||||
@ -191,7 +191,7 @@ lanCard {
|
||||
["", "oc:materialCard", ""]]
|
||||
}
|
||||
wlanCard {
|
||||
input: [[enderPearl, "oc:circuitChip2", ""]
|
||||
input: [[materialEnderPearl, "oc:circuitChip2", ""]
|
||||
["", "oc:materialCard", ""]]
|
||||
}
|
||||
linkedCard {
|
||||
@ -211,9 +211,9 @@ worldSensorCard {
|
||||
}
|
||||
|
||||
angelUpgrade {
|
||||
input: [[ingotIron, enderPearl, ingotIron]
|
||||
input: [[ingotIron, materialEnderPearl, ingotIron]
|
||||
["oc:circuitChip1", pistonStickyBase, "oc:circuitChip1"]
|
||||
[ingotIron, enderPearl, ingotIron]]
|
||||
[ingotIron, materialEnderPearl, ingotIron]]
|
||||
}
|
||||
batteryUpgrade1 {
|
||||
input: [[ingotIron, nuggetGold, ingotIron]
|
||||
@ -231,7 +231,7 @@ batteryUpgrade3 {
|
||||
[diamond, "oc:capacitor", diamond]]
|
||||
}
|
||||
chunkloaderUpgrade {
|
||||
input: [[ingotGold, glass, ingotGold]
|
||||
input: [[ingotGold, blockGlass, ingotGold]
|
||||
["oc:circuitChip3", eyeOfEnder, "oc:circuitChip3"]
|
||||
[obsidian, "oc:materialCircuitBoardPrinted", obsidian]]
|
||||
}
|
||||
@ -306,7 +306,7 @@ signUpgrade {
|
||||
[ingotIron, pistonStickyBase, ingotIron]]
|
||||
}
|
||||
solarGeneratorUpgrade {
|
||||
input: [[glass, glass, glass]
|
||||
input: [[blockGlass, blockGlass, blockGlass]
|
||||
["oc:circuitChip3", blockLapis, "oc:circuitChip3"]
|
||||
[ingotIron, "oc:materialCircuitBoardPrinted", ingotIron]]
|
||||
}
|
||||
@ -391,9 +391,9 @@ chameliumBlock {
|
||||
["oc:chamelium", "oc:chamelium", "oc:chamelium"]]
|
||||
}
|
||||
endstone {
|
||||
input: [[enderPearl, "oc:chameliumBlock", enderPearl]
|
||||
["oc:chameliumBlock", enderPearl, "oc:chameliumBlock"]
|
||||
[enderPearl, "oc:chameliumBlock", enderPearl]]
|
||||
input: [[materialEnderPearl, "oc:chameliumBlock", materialEnderPearl]
|
||||
["oc:chameliumBlock", materialEnderPearl, "oc:chameliumBlock"]
|
||||
[materialEnderPearl, "oc:chameliumBlock", materialEnderPearl]]
|
||||
output: 4
|
||||
}
|
||||
inkCartridgeEmpty {
|
||||
@ -508,7 +508,7 @@ card {
|
||||
|
||||
interweb {
|
||||
input: [[string, string, string]
|
||||
[string, enderPearl, string]
|
||||
[string, materialEnderPearl, string]
|
||||
[string, string, string]]
|
||||
}
|
||||
|
||||
@ -554,7 +554,7 @@ case3 {
|
||||
[diamond, "oc:materialCircuitBoardPrinted", diamond]]
|
||||
}
|
||||
disassembler {
|
||||
input: [["oc:materialCU", thinGlass, "oc:analyzer"]
|
||||
input: [["oc:materialCU", paneGlass, "oc:analyzer"]
|
||||
[craftingPiston, "", obsidian]
|
||||
[ingotIron, bucketLava, ingotIron]]
|
||||
}
|
||||
@ -569,12 +569,12 @@ geolyzer {
|
||||
[ingotGold, "oc:materialCircuitBoardPrinted", ingotGold]]
|
||||
}
|
||||
hologram1 {
|
||||
input: [["oc:circuitChip2", thinGlass, "oc:circuitChip2"]
|
||||
input: [["oc:circuitChip2", paneGlass, "oc:circuitChip2"]
|
||||
["oc:materialCircuitBoardPrinted", diamond, "oc:materialCircuitBoardPrinted"]
|
||||
[obsidian, yellowDust, obsidian]]
|
||||
}
|
||||
hologram2 {
|
||||
input: [["oc:circuitChip3", glass, "oc:circuitChip3"]
|
||||
input: [["oc:circuitChip3", blockGlass, "oc:circuitChip3"]
|
||||
["oc:materialCircuitBoardPrinted", blockDiamond, "oc:materialCircuitBoardPrinted"]
|
||||
[obsidian, blazePowder, obsidian]]
|
||||
}
|
||||
@ -629,17 +629,17 @@ relay {
|
||||
}
|
||||
screen1 {
|
||||
input: [[ingotIron, redstone, ingotIron]
|
||||
[redstone, "oc:circuitChip1", glass]
|
||||
[redstone, "oc:circuitChip1", blockGlass]
|
||||
[ingotIron, redstone, ingotIron]]
|
||||
}
|
||||
screen2 {
|
||||
input: [[ingotGold, dyeRed, ingotGold]
|
||||
[dyeGreen, "oc:circuitChip2", glass]
|
||||
[dyeGreen, "oc:circuitChip2", blockGlass]
|
||||
[ingotGold, dyeBlue, ingotGold]]
|
||||
}
|
||||
screen3 {
|
||||
input: [[obsidian, yellowDust, obsidian]
|
||||
[yellowDust, "oc:circuitChip3", glass]
|
||||
[yellowDust, "oc:circuitChip3", blockGlass]
|
||||
[obsidian, yellowDust, obsidian]]
|
||||
}
|
||||
transposer {
|
||||
|
@ -126,7 +126,7 @@ lanCard {
|
||||
}
|
||||
wlanCard {
|
||||
input: [[screwTitanium , "oc:circuitChip3" , screwTitanium]
|
||||
[enderPearl, "oc:lanCard", enderPearl]
|
||||
[materialEnderPearl, "oc:lanCard", materialEnderPearl]
|
||||
[screwTitanium , craftingToolScrewdriver, screwTitanium]]
|
||||
}
|
||||
|
||||
@ -333,7 +333,7 @@ relay {
|
||||
}
|
||||
screen1 {
|
||||
input: [[plateAluminium, plateAluminium, craftingToolWrench]
|
||||
[redstone, "oc:materialTransistor", thinGlass]
|
||||
[redstone, "oc:materialTransistor", paneGlass]
|
||||
[plateAluminium, plateAluminium, craftingToolScrewdriver]]
|
||||
}
|
||||
screen2 {
|
||||
|
@ -109,7 +109,7 @@ redstoneCard1 {
|
||||
["", "oc:materialCard", ""]]
|
||||
}
|
||||
redstoneCard2 {
|
||||
input: [[blockRedstone, "oc:circuitChip2", enderPearl]
|
||||
input: [[blockRedstone, "oc:circuitChip2", materialEnderPearl]
|
||||
["", "oc:redstoneCard1", ""]]
|
||||
}
|
||||
lanCard {
|
||||
@ -117,7 +117,7 @@ lanCard {
|
||||
["", "oc:materialCard", ""]]
|
||||
}
|
||||
wlanCard {
|
||||
input: [[enderPearl, "oc:circuitChip2", ""]
|
||||
input: [[materialEnderPearl, "oc:circuitChip2", ""]
|
||||
["", "oc:lanCard", ""]]
|
||||
}
|
||||
linkedCard {
|
||||
@ -178,7 +178,7 @@ signUpgrade {
|
||||
[ingotIron, pistonStickyBase, ingotIron]]
|
||||
}
|
||||
solarGeneratorUpgrade {
|
||||
input: [[glass, glass, glass]
|
||||
input: [[blockGlass, blockGlass, blockGlass]
|
||||
["oc:circuitChip3", "oc:generatorUpgrade", "oc:circuitChip3"]]
|
||||
}
|
||||
|
||||
@ -291,9 +291,9 @@ card {
|
||||
}
|
||||
|
||||
interweb {
|
||||
input: [[string, enderPearl, string]
|
||||
[enderPearl, string, enderPearl]
|
||||
[string, enderPearl, string]]
|
||||
input: [[string, materialEnderPearl, string]
|
||||
[materialEnderPearl, string, materialEnderPearl]
|
||||
[string, materialEnderPearl, string]]
|
||||
}
|
||||
|
||||
adapter {
|
||||
@ -372,9 +372,9 @@ relay {
|
||||
[ingotIron, "oc:materialCircuitBoardPrinted", ingotIron]]
|
||||
}
|
||||
screen1 {
|
||||
input: [[ingotIron, ingotIron, glass]
|
||||
[redstone, "oc:materialTransistor", glass]
|
||||
[ingotIron, ingotIron, glass]]
|
||||
input: [[ingotIron, ingotIron, blockGlass]
|
||||
[redstone, "oc:materialTransistor", blockGlass]
|
||||
[ingotIron, ingotIron, blockGlass]]
|
||||
}
|
||||
screen2 {
|
||||
input: [[ingotGold, dyeRed, ingotGold]
|
||||
|
@ -21,7 +21,7 @@ angelUpgrade {
|
||||
[ingotIron, diamond, ingotIron]]
|
||||
}
|
||||
chunkloaderUpgrade {
|
||||
input: [[ingotGold, glass, ingotGold]
|
||||
input: [[ingotGold, blockGlass, ingotGold]
|
||||
["oc:circuitChip3", diamond, "oc:circuitChip3"]
|
||||
[obsidian, "oc:materialCircuitBoardPrinted", obsidian]]
|
||||
}
|
||||
@ -69,7 +69,7 @@ geolyzer {
|
||||
[ingotGold, "oc:materialCircuitBoardPrinted", ingotGold]]
|
||||
}
|
||||
hologram2 {
|
||||
input: [["oc:circuitChip3", glass, "oc:circuitChip3"]
|
||||
input: [["oc:circuitChip3", blockGlass, "oc:circuitChip3"]
|
||||
["oc:materialCircuitBoardPrinted", blockDiamond, "oc:materialCircuitBoardPrinted"]
|
||||
[obsidian, yellowDust, obsidian]]
|
||||
}
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 151 B |
Binary file not shown.
After Width: | Height: | Size: 150 B |
Binary file not shown.
After Width: | Height: | Size: 150 B |
@ -392,6 +392,9 @@ class Settings(val config: Config) {
|
||||
val enableCommandBlockDriver = config.getBoolean("integration.vanilla.enableCommandBlockDriver")
|
||||
val allowItemStackNBTTags = config.getBoolean("integration.vanilla.allowItemStackNBTTags")
|
||||
|
||||
// integration.buildcraft
|
||||
val costProgrammingTable = config.getDouble("integration.buildcraft.programmingTableCost") max 0
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
// debug
|
||||
val logLuaCallbackErrors = config.getBoolean("debug.logCallbackErrors")
|
||||
|
@ -121,7 +121,9 @@ object PacketHandler extends CommonPacketHandler {
|
||||
|
||||
def onComputerState(p: PacketParser) =
|
||||
p.readTileEntity[TileEntity]() match {
|
||||
case Some(t: Computer) => t.setRunning(p.readBoolean())
|
||||
case Some(t: Computer) =>
|
||||
t.setRunning(p.readBoolean())
|
||||
t.hasErrored = p.readBoolean()
|
||||
case Some(t: ServerRack) =>
|
||||
val number = p.readInt()
|
||||
if (number == -1) {
|
||||
@ -129,6 +131,7 @@ object PacketHandler extends CommonPacketHandler {
|
||||
}
|
||||
else {
|
||||
t.setRunning(number, p.readBoolean())
|
||||
t.setErrored(number, p.readBoolean())
|
||||
t.sides(number) = p.readDirection()
|
||||
val keyCount = p.readInt()
|
||||
val keys = t.terminals(number).keys
|
||||
|
@ -53,7 +53,7 @@ object Sound {
|
||||
// Set in init event.
|
||||
var manager: SoundManager = _
|
||||
|
||||
def soundSystem = manager.sndSystem
|
||||
def soundSystem = if (manager != null) manager.sndSystem else null
|
||||
|
||||
private def updateVolume() {
|
||||
val volume =
|
||||
|
@ -127,6 +127,7 @@ object Textures {
|
||||
val AssemblerSideOn = L("overlay/assembler_side_on")
|
||||
val AssemblerTopOn = L("overlay/assembler_top_on")
|
||||
val CaseFrontActivity = L("overlay/case_front_activity")
|
||||
val CaseFrontError = L("overlay/case_front_error")
|
||||
val CaseFrontOn = L("overlay/case_front_on")
|
||||
val ChargerFrontOn = L("overlay/charger_front_on")
|
||||
val ChargerSideOn = L("overlay/charger_side_on")
|
||||
@ -136,11 +137,13 @@ object Textures {
|
||||
val GeolyzerTopOn = L("overlay/geolyzer_top_on")
|
||||
val MicrocontrollerFrontLight = L("overlay/microcontroller_front_light")
|
||||
val MicrocontrollerFrontOn = L("overlay/microcontroller_front_on")
|
||||
val MicrocontrollerFrontError = L("overlay/microcontroller_front_error")
|
||||
val NetSplitterOn = L("overlay/netSplitter_on")
|
||||
val PowerDistributorSideOn = L("overlay/powerDistributor_side_on")
|
||||
val PowerDistributorTopOn = L("overlay/powerDistributor_top_on")
|
||||
val RackFrontActivity = L("overlay/serverRack_front_activity")
|
||||
val RackFrontOn = L("overlay/serverRack_front_on")
|
||||
val RackFrontError = L("overlay/serverRack_front_error")
|
||||
val RaidFrontActivity = L("overlay/raid_front_activity")
|
||||
val RaidFrontError = L("overlay/raid_front_error")
|
||||
val ScreenUpIndicator = L("overlay/screen_up_indicator")
|
||||
|
@ -16,6 +16,7 @@ import net.minecraft.inventory.Container
|
||||
import net.minecraft.inventory.Slot
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraftforge.fml.common.Optional
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
||||
import scala.collection.convert.WrapAsScala._
|
||||
@ -175,7 +176,8 @@ abstract class DynamicGuiContainer[C <: Container](container: C) extends CustomG
|
||||
val panel = LayoutManager.itemPanel
|
||||
if (panel == null) return
|
||||
zLevel += 350
|
||||
for (index <- 0 until ItemPanel.items.size()) {
|
||||
val itemsPerPage = ReflectionHelper.getPrivateValue(classOf[ItemPanel], LayoutManager.itemPanel, "itemsPerPage").asInstanceOf[Int]
|
||||
for (index <- 0 until itemsPerPage) {
|
||||
val rect = panel.getSlotRect(index)
|
||||
val slot = panel.getSlotMouseOver(rect.x, rect.y)
|
||||
if (slot != null) hoveredSlot match {
|
||||
|
@ -7,6 +7,7 @@ import net.minecraft.client.renderer.Tessellator
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.util.EnumFacing
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
||||
object CaseRenderer extends TileEntitySpecialRenderer {
|
||||
@ -35,29 +36,13 @@ object CaseRenderer extends TileEntitySpecialRenderer {
|
||||
GL11.glScalef(1, -1, 1)
|
||||
|
||||
if (computer.isRunning) {
|
||||
val t = Tessellator.getInstance
|
||||
val r = t.getWorldRenderer
|
||||
|
||||
Textures.Block.bind()
|
||||
r.startDrawingQuads()
|
||||
|
||||
{
|
||||
val icon = Textures.getSprite(Textures.Block.CaseFrontOn)
|
||||
r.addVertexWithUV(0, 1, 0, icon.getMinU, icon.getMaxV)
|
||||
r.addVertexWithUV(1, 1, 0, icon.getMaxU, icon.getMaxV)
|
||||
r.addVertexWithUV(1, 0, 0, icon.getMaxU, icon.getMinV)
|
||||
r.addVertexWithUV(0, 0, 0, icon.getMinU, icon.getMinV)
|
||||
}
|
||||
|
||||
renderFrontOverlay(Textures.Block.CaseFrontOn)
|
||||
if (System.currentTimeMillis() - computer.lastAccess < 400 && computer.world.rand.nextDouble() > 0.1) {
|
||||
val icon = Textures.getSprite(Textures.Block.CaseFrontActivity)
|
||||
r.addVertexWithUV(0, 1, 0, icon.getMinU, icon.getMaxV)
|
||||
r.addVertexWithUV(1, 1, 0, icon.getMaxU, icon.getMaxV)
|
||||
r.addVertexWithUV(1, 0, 0, icon.getMaxU, icon.getMinV)
|
||||
r.addVertexWithUV(0, 0, 0, icon.getMinU, icon.getMinV)
|
||||
renderFrontOverlay(Textures.Block.CaseFrontActivity)
|
||||
}
|
||||
|
||||
t.draw()
|
||||
}
|
||||
else if (computer.hasErrored && RenderUtil.shouldShowErrorLight(computer.hashCode)) {
|
||||
renderFrontOverlay(Textures.Block.CaseFrontError)
|
||||
}
|
||||
|
||||
RenderState.enableEntityLighting()
|
||||
@ -67,4 +52,20 @@ object CaseRenderer extends TileEntitySpecialRenderer {
|
||||
|
||||
RenderState.checkError(getClass.getName + ".renderTileEntityAt: leaving")
|
||||
}
|
||||
|
||||
private def renderFrontOverlay(texture: ResourceLocation): Unit = {
|
||||
val t = Tessellator.getInstance
|
||||
val r = t.getWorldRenderer
|
||||
|
||||
Textures.Block.bind()
|
||||
r.startDrawingQuads()
|
||||
|
||||
val icon = Textures.getSprite(texture)
|
||||
r.addVertexWithUV(0, 1, 0, icon.getMinU, icon.getMaxV)
|
||||
r.addVertexWithUV(1, 1, 0, icon.getMaxU, icon.getMaxV)
|
||||
r.addVertexWithUV(1, 0, 0, icon.getMaxU, icon.getMinV)
|
||||
r.addVertexWithUV(0, 0, 0, icon.getMinU, icon.getMinV)
|
||||
|
||||
t.draw()
|
||||
}
|
||||
}
|
@ -4,9 +4,11 @@ import li.cil.oc.client.Textures
|
||||
import li.cil.oc.common.tileentity.Microcontroller
|
||||
import li.cil.oc.util.RenderState
|
||||
import net.minecraft.client.renderer.Tessellator
|
||||
import net.minecraft.client.renderer.WorldRenderer
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.util.EnumFacing
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
||||
object MicrocontrollerRenderer extends TileEntitySpecialRenderer {
|
||||
@ -41,20 +43,13 @@ object MicrocontrollerRenderer extends TileEntitySpecialRenderer {
|
||||
Textures.Block.bind()
|
||||
r.startDrawingQuads()
|
||||
|
||||
{
|
||||
val icon = Textures.getSprite(Textures.Block.MicrocontrollerFrontLight)
|
||||
r.addVertexWithUV(0, 1, 0, icon.getMinU, icon.getMaxV)
|
||||
r.addVertexWithUV(1, 1, 0, icon.getMaxU, icon.getMaxV)
|
||||
r.addVertexWithUV(1, 0, 0, icon.getMaxU, icon.getMinV)
|
||||
r.addVertexWithUV(0, 0, 0, icon.getMinU, icon.getMinV)
|
||||
}
|
||||
renderFrontOverlay(Textures.Block.MicrocontrollerFrontLight, r)
|
||||
|
||||
if (mcu.isRunning) {
|
||||
val icon = Textures.getSprite(Textures.Block.MicrocontrollerFrontOn)
|
||||
r.addVertexWithUV(0, 1, 0, icon.getMinU, icon.getMaxV)
|
||||
r.addVertexWithUV(1, 1, 0, icon.getMaxU, icon.getMaxV)
|
||||
r.addVertexWithUV(1, 0, 0, icon.getMaxU, icon.getMinV)
|
||||
r.addVertexWithUV(0, 0, 0, icon.getMinU, icon.getMinV)
|
||||
renderFrontOverlay(Textures.Block.MicrocontrollerFrontOn, r)
|
||||
}
|
||||
else if (mcu.hasErrored && RenderUtil.shouldShowErrorLight(mcu.hashCode)) {
|
||||
renderFrontOverlay(Textures.Block.MicrocontrollerFrontError, r)
|
||||
}
|
||||
|
||||
t.draw()
|
||||
@ -66,4 +61,12 @@ object MicrocontrollerRenderer extends TileEntitySpecialRenderer {
|
||||
|
||||
RenderState.checkError(getClass.getName + ".renderTileEntityAt: leaving")
|
||||
}
|
||||
|
||||
private def renderFrontOverlay(texture: ResourceLocation, r: WorldRenderer): Unit = {
|
||||
val icon = Textures.getSprite(texture)
|
||||
r.addVertexWithUV(0, 1, 0, icon.getMinU, icon.getMaxV)
|
||||
r.addVertexWithUV(1, 1, 0, icon.getMaxU, icon.getMaxV)
|
||||
r.addVertexWithUV(1, 0, 0, icon.getMaxU, icon.getMinV)
|
||||
r.addVertexWithUV(0, 0, 0, icon.getMinU, icon.getMinV)
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package li.cil.oc.client.renderer.tileentity
|
||||
|
||||
object RenderUtil {
|
||||
def shouldShowErrorLight(hash: Int): Boolean = {
|
||||
val time = System.currentTimeMillis + hash
|
||||
val timeSlice = time / 500
|
||||
timeSlice % 2 == 0
|
||||
}
|
||||
}
|
@ -7,9 +7,13 @@ import net.minecraft.client.renderer.Tessellator
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.util.EnumFacing
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
||||
object ServerRackRenderer extends TileEntitySpecialRenderer {
|
||||
private final val v1 = 2 / 16f
|
||||
private final val fs = 3 / 16f
|
||||
|
||||
override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float, damage: Int) {
|
||||
RenderState.checkError(getClass.getName + ".renderTileEntityAt: entering (aka: wasntme)")
|
||||
|
||||
@ -35,44 +39,19 @@ object ServerRackRenderer extends TileEntitySpecialRenderer {
|
||||
GL11.glScalef(1, -1, 1)
|
||||
|
||||
if (rack.anyRunning) {
|
||||
val t = Tessellator.getInstance
|
||||
val r = t.getWorldRenderer
|
||||
|
||||
Textures.Block.bind()
|
||||
r.startDrawingQuads()
|
||||
|
||||
val v1 = 2 / 16f
|
||||
val fs = 3 / 16f
|
||||
|
||||
{
|
||||
val icon = Textures.getSprite(Textures.Block.RackFrontOn)
|
||||
for (i <- 0 until 4 if rack.isRunning(i)) {
|
||||
val l = v1 + i * fs
|
||||
val h = v1 + (i + 1) * fs
|
||||
|
||||
r.addVertexWithUV(0, h, 0, icon.getMinU, icon.getInterpolatedV(h * 16))
|
||||
r.addVertexWithUV(1, h, 0, icon.getMaxU, icon.getInterpolatedV(h * 16))
|
||||
r.addVertexWithUV(1, l, 0, icon.getMaxU, icon.getInterpolatedV(l * 16))
|
||||
r.addVertexWithUV(0, l, 0, icon.getMinU, icon.getInterpolatedV(l * 16))
|
||||
for (i <- 0 until rack.getSizeInventory if rack.isRunning(i)) {
|
||||
renderFrontOverlay(Textures.Block.RackFrontOn, i)
|
||||
}
|
||||
for (i <- 0 until rack.getSizeInventory if System.currentTimeMillis() - rack.lastAccess(i) < 400 && rack.world.rand.nextDouble() > 0.1) {
|
||||
renderFrontOverlay(Textures.Block.RackFrontActivity, i)
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
val icon = Textures.getSprite(Textures.Block.RackFrontActivity)
|
||||
for (i <- 0 until 4 if System.currentTimeMillis() - rack.lastAccess(i) < 400 && rack.world.rand.nextDouble() > 0.1) {
|
||||
val l = v1 + i * fs
|
||||
val h = v1 + (i + 1) * fs
|
||||
|
||||
r.addVertexWithUV(0, h, 0, icon.getMinU, icon.getInterpolatedV(h * 16))
|
||||
r.addVertexWithUV(1, h, 0, icon.getMaxU, icon.getInterpolatedV(h * 16))
|
||||
r.addVertexWithUV(1, l, 0, icon.getMaxU, icon.getInterpolatedV(l * 16))
|
||||
r.addVertexWithUV(0, l, 0, icon.getMinU, icon.getInterpolatedV(l * 16))
|
||||
if (rack.anyErrored) {
|
||||
for (i <- 0 until rack.getSizeInventory if rack.hasErrored(i) && RenderUtil.shouldShowErrorLight(rack.hashCode * (i + 1))) {
|
||||
renderFrontOverlay(Textures.Block.RackFrontError, i)
|
||||
}
|
||||
}
|
||||
|
||||
t.draw()
|
||||
}
|
||||
|
||||
RenderState.enableEntityLighting()
|
||||
|
||||
RenderState.popMatrix()
|
||||
@ -80,4 +59,23 @@ object ServerRackRenderer extends TileEntitySpecialRenderer {
|
||||
|
||||
RenderState.checkError(getClass.getName + ".renderTileEntityAt: leaving")
|
||||
}
|
||||
|
||||
private def renderFrontOverlay(texture: ResourceLocation, i: Int): Unit = {
|
||||
val t = Tessellator.getInstance
|
||||
val r = t.getWorldRenderer
|
||||
|
||||
Textures.Block.bind()
|
||||
r.startDrawingQuads()
|
||||
|
||||
val l = v1 + i * fs
|
||||
val h = v1 + (i + 1) * fs
|
||||
|
||||
val icon = Textures.getSprite(texture)
|
||||
r.addVertexWithUV(0, h, 0, icon.getMinU, icon.getInterpolatedV(h * 16))
|
||||
r.addVertexWithUV(1, h, 0, icon.getMaxU, icon.getInterpolatedV(h * 16))
|
||||
r.addVertexWithUV(1, l, 0, icon.getMaxU, icon.getInterpolatedV(l * 16))
|
||||
r.addVertexWithUV(0, l, 0, icon.getMinU, icon.getInterpolatedV(l * 16))
|
||||
|
||||
t.draw()
|
||||
}
|
||||
}
|
@ -248,9 +248,9 @@ object EventHandler {
|
||||
}) || didRecraft
|
||||
|
||||
// Presents?
|
||||
if (!e.player.worldObj.isRemote) e.player match {
|
||||
e.player match {
|
||||
case _: FakePlayer => // No presents for you, automaton. Such discrimination. Much bad conscience.
|
||||
case player: EntityPlayerMP =>
|
||||
case player: EntityPlayerMP if player.getEntityWorld != null && !player.getEntityWorld.isRemote =>
|
||||
// Presents!? If we didn't recraft, it's an OC item, and the time is right...
|
||||
if (Settings.get.presentChance > 0 && !didRecraft && api.Items.get(e.crafting) != null &&
|
||||
e.player.getRNG.nextFloat() < Settings.get.presentChance && timeForPresents) {
|
||||
|
@ -40,9 +40,10 @@ class Proxy {
|
||||
|
||||
OpenComputers.log.info("Initializing additional OreDict entries.")
|
||||
|
||||
registerExclusive("craftingPiston", new ItemStack(net.minecraft.init.Blocks.piston), new ItemStack(net.minecraft.init.Blocks.sticky_piston))
|
||||
registerExclusive("torchRedstoneActive", new ItemStack(net.minecraft.init.Blocks.redstone_torch))
|
||||
registerExclusive("nuggetGold", new ItemStack(net.minecraft.init.Items.gold_nugget))
|
||||
OreDictionary.registerOre("craftingPiston", net.minecraft.init.Blocks.piston)
|
||||
OreDictionary.registerOre("craftingPiston", net.minecraft.init.Blocks.sticky_piston)
|
||||
OreDictionary.registerOre("torchRedstoneActive", net.minecraft.init.Blocks.redstone_torch)
|
||||
OreDictionary.registerOre("materialEnderPearl", net.minecraft.init.Items.ender_pearl)
|
||||
|
||||
val nuggetIron = Items.get(Constants.ItemName.IronNugget).createItemStack(1)
|
||||
registerExclusive("nuggetIron", nuggetIron)
|
||||
|
@ -207,11 +207,11 @@ class ClassTransformer extends IClassTransformer {
|
||||
toInject.add(new TypeInsnNode(Opcodes.INSTANCEOF, "li/cil/oc/common/entity/Drone"))
|
||||
val skip = new LabelNode()
|
||||
toInject.add(new JumpInsnNode(Opcodes.IFEQ, skip))
|
||||
toInject.add(new LdcInsnNode(double2Double(0.0)))
|
||||
toInject.add(new LdcInsnNode(Double.box(0.0)))
|
||||
toInject.add(new VarInsnNode(Opcodes.DSTORE, 17))
|
||||
toInject.add(new LdcInsnNode(double2Double(0.0)))
|
||||
toInject.add(new LdcInsnNode(Double.box(0.0)))
|
||||
toInject.add(new VarInsnNode(Opcodes.DSTORE, 19))
|
||||
toInject.add(new LdcInsnNode(double2Double(-0.25)))
|
||||
toInject.add(new LdcInsnNode(Double.box(-0.25)))
|
||||
toInject.add(new VarInsnNode(Opcodes.DSTORE, 21))
|
||||
toInject.add(skip)
|
||||
instructions.insertBefore(varNode, toInject)
|
||||
|
@ -829,14 +829,14 @@ object TextBuffer {
|
||||
args += player
|
||||
args += name
|
||||
if (owner.precisionMode) {
|
||||
args += double2Double(x)
|
||||
args += double2Double(y)
|
||||
args += Double.box(x)
|
||||
args += Double.box(y)
|
||||
}
|
||||
else {
|
||||
args += int2Integer(x.toInt + 1)
|
||||
args += int2Integer(y.toInt + 1)
|
||||
args += Int.box(x.toInt + 1)
|
||||
args += Int.box(y.toInt + 1)
|
||||
}
|
||||
args += int2Integer(data)
|
||||
args += Int.box(data)
|
||||
if (Settings.get.inputUsername) {
|
||||
args += player.getName
|
||||
}
|
||||
|
@ -234,24 +234,24 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
|
||||
|
||||
override def entityInit() {
|
||||
// Running or not.
|
||||
dataWatcher.addObject(5, byte2Byte(0: Byte))
|
||||
dataWatcher.addObject(5, Byte.box(0: Byte))
|
||||
// Target position.
|
||||
dataWatcher.addObject(6, float2Float(0f))
|
||||
dataWatcher.addObject(7, float2Float(0f))
|
||||
dataWatcher.addObject(8, float2Float(0f))
|
||||
dataWatcher.addObject(6, Float.box(0f))
|
||||
dataWatcher.addObject(7, Float.box(0f))
|
||||
dataWatcher.addObject(8, Float.box(0f))
|
||||
// Max acceleration.
|
||||
dataWatcher.addObject(9, float2Float(0f))
|
||||
dataWatcher.addObject(9, Float.box(0f))
|
||||
// Selected inventory slot.
|
||||
dataWatcher.addObject(10, byte2Byte(0: Byte))
|
||||
dataWatcher.addObject(10, Byte.box(0: Byte))
|
||||
// Current and maximum energy.
|
||||
dataWatcher.addObject(11, int2Integer(0))
|
||||
dataWatcher.addObject(12, int2Integer(100))
|
||||
dataWatcher.addObject(11, Int.box(0))
|
||||
dataWatcher.addObject(12, Int.box(100))
|
||||
// Status text.
|
||||
dataWatcher.addObject(13, "")
|
||||
// Inventory size for client.
|
||||
dataWatcher.addObject(14, byte2Byte(0: Byte))
|
||||
dataWatcher.addObject(14, Byte.box(0: Byte))
|
||||
// Light color.
|
||||
dataWatcher.addObject(15, int2Integer(0x66DD55))
|
||||
dataWatcher.addObject(15, Int.box(0x66DD55))
|
||||
}
|
||||
|
||||
def initializeAfterPlacement(stack: ItemStack, player: EntityPlayer, position: Vec3) {
|
||||
@ -300,29 +300,29 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
|
||||
|
||||
def lightColor = dataWatcher.getWatchableObjectInt(15)
|
||||
|
||||
def setRunning(value: Boolean) = dataWatcher.updateObject(5, byte2Byte(if (value) 1: Byte else 0: Byte))
|
||||
def setRunning(value: Boolean) = dataWatcher.updateObject(5, Byte.box(if (value) 1: Byte else 0: Byte))
|
||||
|
||||
|
||||
// Round target values to low accuracy to avoid floating point errors accumulating.
|
||||
def targetX_=(value: Float): Unit = dataWatcher.updateObject(6, float2Float(math.round(value * 4) / 4f))
|
||||
def targetX_=(value: Float): Unit = dataWatcher.updateObject(6, Float.box(math.round(value * 4) / 4f))
|
||||
|
||||
def targetY_=(value: Float): Unit = dataWatcher.updateObject(7, float2Float(math.round(value * 4) / 4f))
|
||||
def targetY_=(value: Float): Unit = dataWatcher.updateObject(7, Float.box(math.round(value * 4) / 4f))
|
||||
|
||||
def targetZ_=(value: Float): Unit = dataWatcher.updateObject(8, float2Float(math.round(value * 4) / 4f))
|
||||
def targetZ_=(value: Float): Unit = dataWatcher.updateObject(8, Float.box(math.round(value * 4) / 4f))
|
||||
|
||||
def targetAcceleration_=(value: Float): Unit = dataWatcher.updateObject(9, float2Float(math.max(0, math.min(maxAcceleration, value))))
|
||||
def targetAcceleration_=(value: Float): Unit = dataWatcher.updateObject(9, Float.box(math.max(0, math.min(maxAcceleration, value))))
|
||||
|
||||
def setSelectedSlot(value: Int) = dataWatcher.updateObject(10, byte2Byte(value.toByte))
|
||||
def setSelectedSlot(value: Int) = dataWatcher.updateObject(10, Byte.box(value.toByte))
|
||||
|
||||
def globalBuffer_=(value: Int) = dataWatcher.updateObject(11, int2Integer(value))
|
||||
def globalBuffer_=(value: Int) = dataWatcher.updateObject(11, Int.box(value))
|
||||
|
||||
def globalBufferSize_=(value: Int) = dataWatcher.updateObject(12, int2Integer(value))
|
||||
def globalBufferSize_=(value: Int) = dataWatcher.updateObject(12, Int.box(value))
|
||||
|
||||
def statusText_=(value: String) = dataWatcher.updateObject(13, Option(value).fold("")(_.lines.map(_.take(10)).take(2).mkString("\n")))
|
||||
|
||||
def inventorySize_=(value: Int) = dataWatcher.updateObject(14, byte2Byte(value.toByte))
|
||||
def inventorySize_=(value: Int) = dataWatcher.updateObject(14, Byte.box(value.toByte))
|
||||
|
||||
def lightColor_=(value: Int) = dataWatcher.updateObject(15, int2Integer(value))
|
||||
def lightColor_=(value: Int) = dataWatcher.updateObject(15, Int.box(value))
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def func_180426_a(x: Double, y: Double, z: Double, yaw: Float, pitch: Float, data: Int, unused: Boolean) {
|
||||
@ -453,9 +453,9 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
|
||||
val direction = new Vec3(entity.posX - posX, entity.posY + entity.getEyeHeight - posY, entity.posZ - posZ).normalize()
|
||||
if (!world.isRemote) {
|
||||
if (Settings.get.inputUsername)
|
||||
machine.signal("hit", double2Double(direction.xCoord), double2Double(direction.zCoord), double2Double(direction.yCoord), entity.getName)
|
||||
machine.signal("hit", Double.box(direction.xCoord), Double.box(direction.zCoord), Double.box(direction.yCoord), entity.getName)
|
||||
else
|
||||
machine.signal("hit", double2Double(direction.xCoord), double2Double(direction.zCoord), double2Double(direction.yCoord))
|
||||
machine.signal("hit", Double.box(direction.xCoord), Double.box(direction.zCoord), Double.box(direction.yCoord))
|
||||
}
|
||||
motionX = (motionX - direction.xCoord) * 0.5f
|
||||
motionY = (motionY - direction.yCoord) * 0.5f
|
||||
|
@ -51,14 +51,14 @@ object GeolyzerHandler {
|
||||
val metadata = block.getMetaFromState(state)
|
||||
|
||||
e.data += "name" -> Block.blockRegistry.getNameForObject(block)
|
||||
e.data += "metadata" -> int2Integer(metadata)
|
||||
e.data += "hardness" -> float2Float(block.getBlockHardness(world, blockPos))
|
||||
e.data += "harvestLevel" -> int2Integer(block.getHarvestLevel(state))
|
||||
e.data += "metadata" -> Int.box(metadata)
|
||||
e.data += "hardness" -> Float.box(block.getBlockHardness(world, blockPos))
|
||||
e.data += "harvestLevel" -> Int.box(block.getHarvestLevel(state))
|
||||
e.data += "harvestTool" -> block.getHarvestTool(state)
|
||||
e.data += "color" -> int2Integer(block.getMapColor(state).colorValue)
|
||||
e.data += "color" -> Int.box(block.getMapColor(state).colorValue)
|
||||
|
||||
if (Settings.get.insertIdsInConverters)
|
||||
e.data += "id" -> int2Integer(Block.getIdFromBlock(block))
|
||||
e.data += "id" -> Int.box(Block.getIdFromBlock(block))
|
||||
}
|
||||
|
||||
private def isFluid(block: Block) = FluidRegistry.lookupFluidForBlock(block) != null
|
||||
|
@ -21,6 +21,7 @@ import net.minecraftforge.event.entity.living.LivingEvent
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
|
||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent
|
||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent
|
||||
|
||||
object NanomachinesHandler {
|
||||
|
||||
@ -72,6 +73,14 @@ object NanomachinesHandler {
|
||||
}
|
||||
|
||||
object Common {
|
||||
@SubscribeEvent
|
||||
def onPlayerRespawn(e: PlayerRespawnEvent): Unit = {
|
||||
api.Nanomachines.getController(e.player) match {
|
||||
case controller: Controller => controller.changeBuffer(-controller.getLocalBuffer)
|
||||
case _ => // Not a player with nanomachines.
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
def onLivingUpdate(e: LivingEvent.LivingUpdateEvent): Unit = {
|
||||
e.entity match {
|
||||
|
@ -49,7 +49,7 @@ object RobotCommonHandler {
|
||||
|
||||
def isMovingDown = e.direction == EnumFacing.DOWN
|
||||
def hasAdjacentBlock(pos: BlockPosition) = EnumFacing.values.exists(side => world.isSideSolid(pos.offset(side), side.getOpposite))
|
||||
def isWithinFlyingHeight(pos: BlockPosition) = (1 to maxFlyingHeight).exists(n => !world.isAirBlock(pos.offset(EnumFacing.DOWN, n)))
|
||||
def isWithinFlyingHeight(pos: BlockPosition) = maxFlyingHeight >= world.getHeight || (1 to maxFlyingHeight).exists(n => !world.isAirBlock(pos.offset(EnumFacing.DOWN, n)))
|
||||
val startPos = BlockPosition(robot)
|
||||
val targetPos = startPos.offset(e.direction)
|
||||
// New movement rules as of 1.5:
|
||||
|
@ -1,15 +1,33 @@
|
||||
package li.cil.oc.common.item
|
||||
|
||||
import java.util
|
||||
|
||||
import com.google.common.base.Strings
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.common.item.data.NanomachineData
|
||||
import li.cil.oc.common.nanomachines.ControllerImpl
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.item.EnumAction
|
||||
import net.minecraft.item.EnumRarity
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.world.World
|
||||
import net.minecraftforge.fml.relauncher.Side
|
||||
import net.minecraftforge.fml.relauncher.SideOnly
|
||||
|
||||
class Nanomachines(val parent: Delegator) extends traits.Delegate {
|
||||
override def rarity(stack: ItemStack): EnumRarity = EnumRarity.UNCOMMON
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def tooltipLines(stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean): Unit = {
|
||||
super.tooltipLines(stack, player, tooltip, advanced)
|
||||
if (stack.hasTagCompound) {
|
||||
val data = new NanomachineData(stack)
|
||||
if (!Strings.isNullOrEmpty(data.uuid)) {
|
||||
tooltip.add("§8" + data.uuid.substring(0, 13) + "...§7")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override def onItemRightClick(stack: ItemStack, world: World, player: EntityPlayer): ItemStack = {
|
||||
player.setItemInUse(stack, getMaxItemUseDuration(stack))
|
||||
stack
|
||||
@ -21,8 +39,22 @@ class Nanomachines(val parent: Delegator) extends traits.Delegate {
|
||||
|
||||
override def onItemUseFinish(stack: ItemStack, world: World, player: EntityPlayer): ItemStack = {
|
||||
if (!world.isRemote) {
|
||||
// Reconfigure if already installed.
|
||||
api.Nanomachines.installController(player).reconfigure()
|
||||
val data = new NanomachineData(stack)
|
||||
|
||||
// Re-install to get new address, make sure we're configured.
|
||||
api.Nanomachines.uninstallController(player)
|
||||
api.Nanomachines.installController(player) match {
|
||||
case controller: ControllerImpl =>
|
||||
data.configuration match {
|
||||
case Some(nbt) =>
|
||||
if (!Strings.isNullOrEmpty(data.uuid)) {
|
||||
controller.uuid = data.uuid
|
||||
}
|
||||
controller.configuration.load(nbt)
|
||||
case _ => controller.reconfigure()
|
||||
}
|
||||
case controller => controller.reconfigure() // Huh.
|
||||
}
|
||||
}
|
||||
stack.stackSize -= 1
|
||||
if (stack.stackSize > 0) stack
|
||||
|
@ -180,7 +180,7 @@ class Tablet(val parent: Delegator) extends traits.Delegate with CustomModel wit
|
||||
val computer = Tablet.get(stack, player).machine
|
||||
if (computer.isRunning) {
|
||||
val data = new NBTTagCompound()
|
||||
computer.node.sendToReachable("tablet.use", data, stack, player, position, side, float2Float(hitX), float2Float(hitY), float2Float(hitZ))
|
||||
computer.node.sendToReachable("tablet.use", data, stack, player, position, side, Float.box(hitX), Float.box(hitY), Float.box(hitZ))
|
||||
if (!data.hasNoTags) {
|
||||
computer.signal("tablet_use", data)
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
package li.cil.oc.common.item.data
|
||||
|
||||
import li.cil.oc.common.nanomachines.ControllerImpl
|
||||
import li.cil.oc.Constants
|
||||
import li.cil.oc.Settings
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
|
||||
class NanomachineData extends ItemData(Constants.ItemName.Nanomachines) {
|
||||
def this(stack: ItemStack) {
|
||||
this()
|
||||
load(stack)
|
||||
}
|
||||
|
||||
def this(controller: ControllerImpl) {
|
||||
this()
|
||||
uuid = controller.uuid
|
||||
val nbt = new NBTTagCompound()
|
||||
controller.configuration.save(nbt, forItem = true)
|
||||
configuration = Option(nbt)
|
||||
}
|
||||
|
||||
var uuid = ""
|
||||
var configuration: Option[NBTTagCompound] = None
|
||||
|
||||
override def load(nbt: NBTTagCompound): Unit = {
|
||||
uuid = nbt.getString(Settings.namespace + "uuid")
|
||||
if (nbt.hasKey(Settings.namespace + "configuration")) {
|
||||
configuration = Option(nbt.getCompoundTag(Settings.namespace + "configuration"))
|
||||
}
|
||||
else {
|
||||
configuration = None
|
||||
}
|
||||
}
|
||||
|
||||
override def save(nbt: NBTTagCompound): Unit = {
|
||||
nbt.setString(Settings.namespace + "uuid", uuid)
|
||||
configuration.foreach(nbt.setTag(Settings.namespace + "configuration", _))
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package li.cil.oc.common.item.traits
|
||||
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.common.asm.Injectable
|
||||
import li.cil.oc.integration.Mods
|
||||
import li.cil.oc.integration.util.Power
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
@Injectable.InterfaceList(Array(
|
||||
@ -22,16 +22,16 @@ trait Chargeable extends api.driver.item.Chargeable {
|
||||
// Applied Energistics 2
|
||||
/* TODO AE2
|
||||
def getAECurrentPower(stack: ItemStack): Double =
|
||||
getCharge(stack) / Settings.get.ratioAppliedEnergistics2
|
||||
Power.toAE(getCharge(stack))
|
||||
|
||||
def getAEMaxPower(stack: ItemStack): Double =
|
||||
maxCharge(stack) / Settings.get.ratioAppliedEnergistics2
|
||||
Power.toAE(maxCharge(stack))
|
||||
|
||||
def injectAEPower(stack: ItemStack, value: Double): Double =
|
||||
(charge(stack, value * Settings.get.ratioAppliedEnergistics2, false) / Settings.get.ratioAppliedEnergistics2).toInt
|
||||
Power.toAE(charge(stack, Power.fromAE(value), false))
|
||||
|
||||
def extractAEPower(stack: ItemStack, value: Double): Double =
|
||||
value - (charge(stack, -value * Settings.get.ratioAppliedEnergistics2, false) / Settings.get.ratioAppliedEnergistics2).toInt
|
||||
value - Power.toAE(charge(stack, Power.fromAE(-value), false))
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
|
||||
def getPowerFlow(stack: ItemStack): AccessRestriction = AccessRestriction.WRITE
|
||||
@ -42,10 +42,10 @@ trait Chargeable extends api.driver.item.Chargeable {
|
||||
def getManager(stack: ItemStack): IElectricItemManager = ElectricItemManager
|
||||
|
||||
def getMaxCharge(stack: ItemStack): Double =
|
||||
maxCharge(stack) / Settings.get.ratioIndustrialCraft2
|
||||
Power.toEU(maxCharge(stack))
|
||||
|
||||
def getTransferLimit(stack: ItemStack): Double =
|
||||
Settings.get.chargeRateTablet / Settings.get.ratioIndustrialCraft2
|
||||
Power.toEU(Settings.get.chargeRateTablet)
|
||||
|
||||
def getTier(stack: ItemStack): Int = 1
|
||||
|
||||
@ -56,15 +56,15 @@ trait Chargeable extends api.driver.item.Chargeable {
|
||||
def getChargedItem(stack: ItemStack): Item = stack.getItem
|
||||
*/
|
||||
// Mekanism
|
||||
|
||||
/* TODO Mekanism
|
||||
def getEnergy(stack: ItemStack): Double =
|
||||
getCharge(stack) / Settings.get.ratioMekanism
|
||||
Power.toJoules(getCharge(stack))
|
||||
|
||||
def setEnergy(stack: ItemStack, amount: Double): Unit =
|
||||
setCharge(stack, amount * Settings.get.ratioMekanism)
|
||||
setCharge(stack, Power.fromJoules(amount))
|
||||
|
||||
def getMaxEnergy(stack: ItemStack): Double =
|
||||
maxCharge(stack) / Settings.get.ratioMekanism
|
||||
Power.toJoules(maxCharge(stack))
|
||||
|
||||
def canSend(stack: ItemStack): Boolean = false
|
||||
|
||||
@ -73,19 +73,19 @@ trait Chargeable extends api.driver.item.Chargeable {
|
||||
def isMetadataSpecific(stack: ItemStack): Boolean = false
|
||||
|
||||
def getMaxTransfer(stack: ItemStack): Double =
|
||||
Settings.get.chargeRateTablet / Settings.get.ratioMekanism
|
||||
|
||||
Power.toJoules(Settings.get.chargeRateTablet)
|
||||
*/
|
||||
// Redstone Flux
|
||||
|
||||
def getEnergyStored(stack: ItemStack): Int =
|
||||
(getCharge(stack) / Settings.get.ratioRedstoneFlux).toInt
|
||||
Power.toRF(getCharge(stack))
|
||||
|
||||
def getMaxEnergyStored(stack: ItemStack): Int =
|
||||
(maxCharge(stack) / Settings.get.ratioRedstoneFlux).toInt
|
||||
Power.toRF(maxCharge(stack))
|
||||
|
||||
def receiveEnergy(stack: ItemStack, maxReceive: Int, simulate: Boolean): Int =
|
||||
maxReceive - (charge(stack, maxReceive * Settings.get.ratioRedstoneFlux, simulate) / Settings.get.ratioRedstoneFlux).toInt
|
||||
maxReceive - Power.toRF(charge(stack, Power.fromRF(maxReceive), simulate))
|
||||
|
||||
def extractEnergy(stack: ItemStack, maxExtract: Int, simulate: Boolean): Int =
|
||||
maxExtract - (charge(stack, -maxExtract * Settings.get.ratioRedstoneFlux, simulate) / Settings.get.ratioRedstoneFlux).toInt
|
||||
maxExtract - Power.toRF(charge(stack, Power.fromRF(-maxExtract), simulate))
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package li.cil.oc.common.launch
|
||||
|
||||
import com.google.common.eventbus.EventBus
|
||||
import net.minecraftforge.fml.common.DummyModContainer
|
||||
import net.minecraftforge.fml.common.LoadController
|
||||
import net.minecraftforge.fml.common.ModMetadata
|
||||
|
||||
class CoreModContainer extends DummyModContainer({
|
||||
val md = new ModMetadata()
|
||||
md.authorList.add("Sangar")
|
||||
md.modId = "OpenComputers|Core"
|
||||
md.version = "@VERSION@"
|
||||
md.name = "OpenComputers (Core)"
|
||||
md.url = "http://oc.cil.li/"
|
||||
md.description = "OC core mod used for class transformer and as API owner to avoid cyclic dependencies."
|
||||
md
|
||||
}) {
|
||||
override def registerBus(bus: EventBus, controller: LoadController) = true
|
||||
}
|
@ -2,32 +2,17 @@ package li.cil.oc.common.launch
|
||||
|
||||
import java.util
|
||||
|
||||
import com.google.common.eventbus.EventBus
|
||||
import li.cil.oc.common.asm.ClassTransformer
|
||||
import net.minecraftforge.fml.common.DummyModContainer
|
||||
import net.minecraftforge.fml.common.LoadController
|
||||
import net.minecraftforge.fml.common.ModMetadata
|
||||
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin
|
||||
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin.MCVersion
|
||||
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions
|
||||
|
||||
@TransformerExclusions(Array("li.cil.oc.common.asm"))
|
||||
@MCVersion("1.8")
|
||||
class TransformerLoader extends DummyModContainer({
|
||||
val md = new ModMetadata()
|
||||
md.authorList.add("Sangar")
|
||||
md.modId = "OpenComputers|Core"
|
||||
md.version = "@VERSION@"
|
||||
md.name = "OpenComputers (Core)"
|
||||
md.url = "http://oc.cil.li/"
|
||||
md.description = "OC core mod used for class transformer and as API owner to avoid cyclic dependencies."
|
||||
md
|
||||
}) with IFMLLoadingPlugin {
|
||||
class TransformerLoader extends IFMLLoadingPlugin {
|
||||
val instance = this
|
||||
|
||||
override def getModContainerClass = getClass.getName
|
||||
|
||||
override def registerBus(bus: EventBus, controller: LoadController) = true
|
||||
override def getModContainerClass = "li.cil.oc.common.launch.CoreModContainer"
|
||||
|
||||
override def getASMTransformerClass = Array(classOf[ClassTransformer].getName)
|
||||
|
||||
|
@ -5,6 +5,7 @@ import java.util.UUID
|
||||
|
||||
import com.google.common.base.Charsets
|
||||
import com.google.common.base.Strings
|
||||
import li.cil.oc.Constants
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.nanomachines.Behavior
|
||||
@ -12,10 +13,12 @@ import li.cil.oc.api.nanomachines.Controller
|
||||
import li.cil.oc.api.nanomachines.DisableReason
|
||||
import li.cil.oc.api.network.Packet
|
||||
import li.cil.oc.api.network.WirelessEndpoint
|
||||
import li.cil.oc.common.item.data.NanomachineData
|
||||
import li.cil.oc.integration.util.DamageSourceWithRandomCause
|
||||
import li.cil.oc.server.PacketSender
|
||||
import li.cil.oc.util.BlockPosition
|
||||
import li.cil.oc.util.ExtendedNBT._
|
||||
import li.cil.oc.util.InventoryUtils
|
||||
import li.cil.oc.util.PlayerUtils
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.entity.player.EntityPlayerMP
|
||||
@ -74,7 +77,23 @@ class ControllerImpl(val player: EntityPlayer) extends Controller with WirelessE
|
||||
respond(sender, "port", responsePort)
|
||||
case Array("getPowerState") =>
|
||||
respond(sender, "power", getLocalBuffer, getLocalBufferSize)
|
||||
|
||||
case Array("saveConfiguration") =>
|
||||
val nanomachines = api.Items.get(Constants.ItemName.Nanomachines)
|
||||
try {
|
||||
val index = player.inventory.mainInventory.indexWhere(stack => api.Items.get(stack) == nanomachines && new NanomachineData(stack).configuration.isEmpty)
|
||||
if (index >= 0) {
|
||||
val stack = player.inventory.decrStackSize(index, 1)
|
||||
new NanomachineData(this).save(stack)
|
||||
player.inventory.addItemStackToInventory(stack)
|
||||
InventoryUtils.spawnStackInWorld(BlockPosition(player), stack)
|
||||
respond(sender, "saved", true)
|
||||
}
|
||||
else respond(sender, "saved", false, "no nanomachines")
|
||||
}
|
||||
catch {
|
||||
case _: Throwable =>
|
||||
respond(sender, "saved", false, "error")
|
||||
}
|
||||
case Array("getHealth") =>
|
||||
respond(sender, "health", player.getHealth, player.getMaxHealth)
|
||||
case Array("getHunger") =>
|
||||
|
@ -108,9 +108,13 @@ class NeuralNetwork(controller: ControllerImpl) extends Persistable {
|
||||
}
|
||||
|
||||
override def save(nbt: NBTTagCompound): Unit = {
|
||||
save(nbt, forItem = false)
|
||||
}
|
||||
|
||||
def save(nbt: NBTTagCompound, forItem: Boolean): Unit = {
|
||||
nbt.setNewTagList("triggers", triggers.map(t => {
|
||||
val nbt = new NBTTagCompound()
|
||||
nbt.setBoolean("isActive", t.isActive)
|
||||
nbt.setBoolean("isActive", t.isActive && !forItem)
|
||||
nbt
|
||||
}))
|
||||
|
||||
|
@ -12,7 +12,6 @@ import li.cil.oc.common.item.data.RobotData
|
||||
import li.cil.oc.util.ItemUtils
|
||||
import net.minecraft.inventory.IInventory
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms
|
||||
|
||||
import scala.collection.convert.WrapAsJava._
|
||||
|
||||
@ -41,7 +40,7 @@ object DroneTemplate extends Template {
|
||||
data.save(stack)
|
||||
val energy = Settings.get.droneBaseCost + complexity(inventory) * Settings.get.droneComplexityCost
|
||||
|
||||
Array(stack, double2Double(energy))
|
||||
Array(stack, Double.box(energy))
|
||||
}
|
||||
|
||||
def selectDisassembler(stack: ItemStack) = api.Items.get(stack) == api.Items.get(Constants.ItemName.Drone)
|
||||
|
@ -36,7 +36,7 @@ object MicrocontrollerTemplate extends Template {
|
||||
val stack = data.createItemStack()
|
||||
val energy = Settings.get.microcontrollerBaseCost + complexity(inventory) * Settings.get.microcontrollerComplexityCost
|
||||
|
||||
Array(stack, double2Double(energy))
|
||||
Array(stack, Double.box(energy))
|
||||
}
|
||||
|
||||
def selectDisassembler(stack: ItemStack) = api.Items.get(stack) == api.Items.get(Constants.BlockName.Microcontroller)
|
||||
|
@ -38,7 +38,7 @@ object RobotTemplate extends Template {
|
||||
val stack = data.createItemStack()
|
||||
val energy = Settings.get.robotBaseCost + complexity(inventory) * Settings.get.robotComplexityCost
|
||||
|
||||
Array(stack, double2Double(energy))
|
||||
Array(stack, Double.box(energy))
|
||||
}
|
||||
|
||||
def selectDisassembler(stack: ItemStack) = api.Items.get(stack) == api.Items.get(Constants.BlockName.Robot)
|
||||
|
@ -49,7 +49,7 @@ object TabletTemplate extends Template {
|
||||
data.save(stack)
|
||||
val energy = Settings.get.tabletBaseCost + complexity(inventory) * Settings.get.tabletComplexityCost
|
||||
|
||||
Array(stack, double2Double(energy))
|
||||
Array(stack, Double.box(energy))
|
||||
}
|
||||
|
||||
def selectDisassembler(stack: ItemStack) = api.Items.get(stack) == api.Items.get(Constants.ItemName.Tablet)
|
||||
|
@ -17,7 +17,7 @@ import net.minecraft.util.EnumFacing
|
||||
import net.minecraftforge.fml.relauncher.Side
|
||||
import net.minecraftforge.fml.relauncher.SideOnly
|
||||
|
||||
class Assembler extends traits.Environment with traits.PowerAcceptor with traits.Inventory with traits.Rotatable with SidedEnvironment with traits.StateAware {
|
||||
class Assembler extends traits.Environment with traits.PowerAcceptor with traits.Inventory with SidedEnvironment with traits.StateAware {
|
||||
val node = api.Network.newNode(this, Visibility.Network).
|
||||
withComponent("assembler").
|
||||
withConnector(Settings.get.bufferConverter).
|
||||
|
@ -97,13 +97,13 @@ class Microcontroller extends traits.PowerAcceptor with traits.Hub with traits.C
|
||||
|
||||
@Callback(direct = true, doc = """function(side:number):boolean -- Get whether network messages are sent via the specified side.""")
|
||||
def isSideOpen(context: Context, args: Arguments): Array[AnyRef] = {
|
||||
val side = args.checkSide(0, EnumFacing.values.filter(_ != facing): _*)
|
||||
val side = args.checkSideExcept(0, facing)
|
||||
result(outputSides(side.ordinal()))
|
||||
}
|
||||
|
||||
@Callback(doc = """function(side:number, open:boolean):boolean -- Set whether network messages are sent via the specified side.""")
|
||||
def setSideOpen(context: Context, args: Arguments): Array[AnyRef] = {
|
||||
val side = args.checkSide(0, EnumFacing.values.filter(_ != facing): _*)
|
||||
val side = args.checkSideExcept(0, facing)
|
||||
val oldValue = outputSides(side.ordinal())
|
||||
outputSides(side.ordinal()) = args.checkBoolean(1)
|
||||
result(oldValue)
|
||||
|
@ -44,7 +44,7 @@ class Redstone extends traits.Environment with traits.BundledRedstoneAware {
|
||||
super.onRedstoneInputChanged(side, oldMaxValue, newMaxValue)
|
||||
if (node != null && node.network != null) {
|
||||
node.connect(dummyNode)
|
||||
dummyNode.sendToNeighbors("redstone.changed", side, int2Integer(oldMaxValue), int2Integer(newMaxValue))
|
||||
dummyNode.sendToNeighbors("redstone.changed", side, Int.box(oldMaxValue), Int.box(newMaxValue))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
|
||||
|
||||
// For client side, where we don't create the component.
|
||||
private val _isRunning = new Array[Boolean](getSizeInventory)
|
||||
private val _hasErrored = new Array[Boolean](getSizeInventory)
|
||||
|
||||
private var markChunkDirty = false
|
||||
|
||||
@ -78,16 +79,29 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
|
||||
else _isRunning(number)
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
def setRunning(number: Int, value: Boolean) = {
|
||||
def setRunning(number: Int, value: Boolean): Unit = {
|
||||
_isRunning(number) = value
|
||||
if (!value) {
|
||||
_hasErrored(number) = false
|
||||
}
|
||||
world.markBlockForUpdate(getPos)
|
||||
if (anyRunning) Sound.startLoop(this, "computer_running", 1.5f, 50 + world.rand.nextInt(50))
|
||||
else Sound.stopLoop(this)
|
||||
this
|
||||
}
|
||||
|
||||
def anyRunning = servers.indices.exists(isRunning)
|
||||
|
||||
def hasErrored(number: Int) =
|
||||
if (isServer) servers(number).fold(false)(_.machine.lastError != null)
|
||||
else _hasErrored(number)
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
def setErrored(number: Int, value: Boolean): Unit = {
|
||||
_hasErrored(number) = value
|
||||
}
|
||||
|
||||
def anyErrored = servers.indices.exists(hasErrored)
|
||||
|
||||
override def currentState = {
|
||||
if (anyRunning) util.EnumSet.of(traits.State.IsWorking)
|
||||
else util.EnumSet.noneOf(classOf[traits.State])
|
||||
@ -251,8 +265,11 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
|
||||
|
||||
for (i <- servers.indices) {
|
||||
val isRunning = servers(i).fold(false)(_.machine.isRunning)
|
||||
if (_isRunning(i) != isRunning) {
|
||||
val errored = servers(i).fold(false)(_.machine.lastError != null)
|
||||
if (_isRunning(i) != isRunning || _hasErrored(i) != errored) {
|
||||
_isRunning(i) = isRunning
|
||||
_hasErrored(i) = errored
|
||||
markDirty()
|
||||
ServerPacketSender.sendServerState(this, i)
|
||||
world.notifyNeighborsOfStateChange(getPos, getBlockType)
|
||||
}
|
||||
@ -367,6 +384,8 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
|
||||
super.readFromNBTForClient(nbt)
|
||||
val isRunningNbt = nbt.getBooleanArray("isServerRunning")
|
||||
Array.copy(isRunningNbt, 0, _isRunning, 0, math.min(isRunningNbt.length, _isRunning.length))
|
||||
val hasErroredNbt = nbt.getBooleanArray("hasServerErrored")
|
||||
Array.copy(hasErroredNbt, 0, _hasErrored, 0, math.min(hasErroredNbt.length, _hasErrored.length))
|
||||
val isPresentNbt = nbt.getTagList("isPresent", NBT.TAG_STRING).map((tag: NBTTagString) => {
|
||||
val value = tag.getString
|
||||
if (Strings.isNullOrEmpty(value)) None else Some(value)
|
||||
@ -389,6 +408,7 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
|
||||
override def writeToNBTForClient(nbt: NBTTagCompound) {
|
||||
super.writeToNBTForClient(nbt)
|
||||
nbt.setBooleanArray("isServerRunning", _isRunning)
|
||||
nbt.setBooleanArray("hasServerErrored", _hasErrored)
|
||||
nbt.setNewTagList("isPresent", servers.map(value => new NBTTagString(value.fold("")(_.machine.node.address))))
|
||||
nbt.setByteArray("sides", sides.map {
|
||||
case Some(side) => side.ordinal.toByte
|
||||
@ -469,7 +489,7 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB
|
||||
override protected def onRedstoneInputChanged(side: EnumFacing, oldMaxValue: Int, newMaxValue: Int) {
|
||||
super.onRedstoneInputChanged(side, oldMaxValue, newMaxValue)
|
||||
servers collect {
|
||||
case Some(server) => server.machine.node.sendToNeighbors("redstone.changed", toLocal(side), int2Integer(oldMaxValue), int2Integer(newMaxValue))
|
||||
case Some(server) => server.machine.node.sendToNeighbors("redstone.changed", toLocal(side), Int.box(oldMaxValue), Int.box(newMaxValue))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,9 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
|
||||
|
||||
private var _isRunning = false
|
||||
|
||||
// For client side rendering of error LED indicator.
|
||||
var hasErrored = false
|
||||
|
||||
private val _users = mutable.Set.empty[String]
|
||||
|
||||
protected def runSound = Option("computer_running")
|
||||
@ -51,6 +54,9 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
|
||||
|
||||
def setRunning(value: Boolean): Unit = if (value != _isRunning) {
|
||||
_isRunning = value
|
||||
if (value) {
|
||||
hasErrored = false
|
||||
}
|
||||
if (world != null) {
|
||||
world.markBlockForUpdate(getPos)
|
||||
runSound.foreach(sound =>
|
||||
@ -98,8 +104,11 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
|
||||
if (isServer && isConnected) {
|
||||
updateComputer()
|
||||
|
||||
if (_isRunning != machine.isRunning) {
|
||||
_isRunning = machine.isRunning
|
||||
val running = machine.isRunning
|
||||
val errored = machine.lastError != null
|
||||
if (_isRunning != running || hasErrored != errored) {
|
||||
_isRunning = running
|
||||
hasErrored = errored
|
||||
onRunningChanged()
|
||||
}
|
||||
|
||||
@ -156,6 +165,7 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def readFromNBTForClient(nbt: NBTTagCompound) {
|
||||
super.readFromNBTForClient(nbt)
|
||||
hasErrored = nbt.getBoolean("hasErrored")
|
||||
setRunning(nbt.getBoolean("isRunning"))
|
||||
_users.clear()
|
||||
_users ++= nbt.getTagList("users", NBT.TAG_STRING).map((tag: NBTTagString) => tag.getString)
|
||||
@ -164,6 +174,7 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
|
||||
|
||||
override def writeToNBTForClient(nbt: NBTTagCompound) {
|
||||
super.writeToNBTForClient(nbt)
|
||||
nbt.setBoolean("hasErrored", machine != null && machine.lastError != null)
|
||||
nbt.setBoolean("isRunning", isRunning)
|
||||
nbt.setNewTagList("users", machine.users.map(user => new NBTTagString(user)))
|
||||
}
|
||||
@ -191,7 +202,7 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
|
||||
|
||||
override protected def onRedstoneInputChanged(side: EnumFacing, oldMaxValue: Int, newMaxValue: Int) {
|
||||
super.onRedstoneInputChanged(side, oldMaxValue, newMaxValue)
|
||||
machine.node.sendToNeighbors("redstone.changed", toLocal(side), int2Integer(oldMaxValue), int2Integer(newMaxValue))
|
||||
machine.node.sendToNeighbors("redstone.changed", toLocal(side), Int.box(oldMaxValue), Int.box(newMaxValue))
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
@ -1,136 +1,138 @@
|
||||
//package li.cil.oc.common.tileentity.traits.power
|
||||
//
|
||||
//import java.util
|
||||
//
|
||||
//import appeng.api.AEApi
|
||||
//import appeng.api.config.Actionable
|
||||
//import appeng.api.config.PowerMultiplier
|
||||
//import appeng.api.networking._
|
||||
//import appeng.api.networking.energy.IEnergyGrid
|
||||
//import appeng.api.util.AECableType
|
||||
//import appeng.api.util.AEColor
|
||||
//import appeng.api.util.DimensionalCoord
|
||||
//import net.minecraftforge.fml.common.Optional
|
||||
//import li.cil.oc.Settings
|
||||
//import li.cil.oc.common.EventHandler
|
||||
//import li.cil.oc.common.asm.Injectable
|
||||
//import li.cil.oc.integration.Mods
|
||||
//import net.minecraft.nbt.NBTTagCompound
|
||||
//import net.minecraft.util.EnumFacing
|
||||
//
|
||||
//import scala.collection.convert.WrapAsJava._
|
||||
//
|
||||
//@Injectable.Interface(value = "appeng.api.networking.IGridHost", modid = Mods.IDs.AppliedEnergistics2)
|
||||
//trait AppliedEnergistics2 extends Common {
|
||||
// private lazy val useAppliedEnergistics2Power = isServer && Mods.AppliedEnergistics2.isAvailable
|
||||
//
|
||||
// // 'Manual' lazy val, because lazy vals mess up the class loader, leading to class not found exceptions.
|
||||
// private var node: Option[AnyRef] = None
|
||||
//
|
||||
// override def updateEntity() {
|
||||
// super.updateEntity()
|
||||
// if (useAppliedEnergistics2Power && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
|
||||
// updateEnergy()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
|
||||
// private def updateEnergy() {
|
||||
// tryAllSides((demand, side) => {
|
||||
// val grid = getGridNode(side).getGrid
|
||||
// if (grid != null) {
|
||||
// val cache = grid.getCache(classOf[IEnergyGrid]).asInstanceOf[IEnergyGrid]
|
||||
// if (cache != null) {
|
||||
// cache.extractAEPower(demand, Actionable.MODULATE, PowerMultiplier.CONFIG)
|
||||
// }
|
||||
// else 0.0
|
||||
// }
|
||||
// else 0.0
|
||||
// }, Settings.get.ratioAppliedEnergistics2)
|
||||
// }
|
||||
//
|
||||
// override def validate() {
|
||||
// super.validate()
|
||||
// if (useAppliedEnergistics2Power) EventHandler.scheduleAE2Add(this)
|
||||
// }
|
||||
//
|
||||
// override def invalidate() {
|
||||
// super.invalidate()
|
||||
// if (useAppliedEnergistics2Power) securityBreak()
|
||||
// }
|
||||
//
|
||||
// override def onChunkUnload() {
|
||||
// super.onChunkUnload()
|
||||
// if (useAppliedEnergistics2Power) securityBreak()
|
||||
// }
|
||||
//
|
||||
// // ----------------------------------------------------------------------- //
|
||||
//
|
||||
// override def readFromNBTForServer(nbt: NBTTagCompound) {
|
||||
// super.readFromNBTForServer(nbt)
|
||||
// if (useAppliedEnergistics2Power) loadNode(nbt)
|
||||
// }
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
|
||||
// private def loadNode(nbt: NBTTagCompound): Unit = {
|
||||
// getGridNode(EnumFacing.UNKNOWN).loadFromNBT(Settings.namespace + "ae2power", nbt)
|
||||
// }
|
||||
//
|
||||
// override def writeToNBTForServer(nbt: NBTTagCompound) {
|
||||
// super.writeToNBTForServer(nbt)
|
||||
// if (useAppliedEnergistics2Power) saveNode(nbt)
|
||||
// }
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
|
||||
// private def saveNode(nbt: NBTTagCompound): Unit = {
|
||||
// getGridNode(EnumFacing.UNKNOWN).saveToNBT(Settings.namespace + "ae2power", nbt)
|
||||
// }
|
||||
//
|
||||
// // ----------------------------------------------------------------------- //
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
|
||||
// def getGridNode(side: EnumFacing) = node match {
|
||||
// case Some(gridNode: IGridNode) => gridNode
|
||||
// case _ if isServer =>
|
||||
// val gridNode = AEApi.instance.createGridNode(new AppliedEnergistics2GridBlock(this))
|
||||
// node = Option(gridNode)
|
||||
// gridNode
|
||||
// case _ => null
|
||||
// }
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
|
||||
// def getCableConnectionType(side: EnumFacing) = AECableType.SMART
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
|
||||
// def securityBreak() {
|
||||
// getGridNode(EnumFacing.UNKNOWN).destroy()
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//class AppliedEnergistics2GridBlock(val tileEntity: AppliedEnergistics2) extends IGridBlock {
|
||||
// override def getIdlePowerUsage = 0.0
|
||||
//
|
||||
// override def getFlags = util.EnumSet.noneOf(classOf[GridFlags])
|
||||
//
|
||||
// // rv1
|
||||
// def isWorldAccessable = true
|
||||
//
|
||||
// // rv2
|
||||
// def isWorldAccessible = true
|
||||
//
|
||||
// override def getLocation = new DimensionalCoord(tileEntity)
|
||||
//
|
||||
// override def getGridColor = AEColor.Transparent
|
||||
//
|
||||
// override def onGridNotification(p1: GridNotification) {}
|
||||
//
|
||||
// override def setNetworkStatus(p1: IGrid, p2: Int) {}
|
||||
//
|
||||
// override def getConnectableSides = util.EnumSet.copyOf(EnumFacing.values.filter(tileEntity.canConnectPower).toList)
|
||||
//
|
||||
// override def getMachine = tileEntity.asInstanceOf[IGridHost]
|
||||
//
|
||||
// override def gridChanged() {}
|
||||
//
|
||||
// override def getMachineRepresentation = null
|
||||
//}
|
||||
package li.cil.oc.common.tileentity.traits.power
|
||||
/* TODO AE2
|
||||
import java.util
|
||||
|
||||
import appeng.api.AEApi
|
||||
import appeng.api.config.Actionable
|
||||
import appeng.api.config.PowerMultiplier
|
||||
import appeng.api.networking._
|
||||
import appeng.api.networking.energy.IEnergyGrid
|
||||
import appeng.api.util.AECableType
|
||||
import appeng.api.util.AEColor
|
||||
import appeng.api.util.DimensionalCoord
|
||||
import cpw.mods.fml.common.Optional
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.common.EventHandler
|
||||
import li.cil.oc.common.asm.Injectable
|
||||
import li.cil.oc.integration.Mods
|
||||
import li.cil.oc.integration.util.Power
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
|
||||
import scala.collection.convert.WrapAsJava._
|
||||
|
||||
@Injectable.Interface(value = "appeng.api.networking.IGridHost", modid = Mods.IDs.AppliedEnergistics2)
|
||||
trait AppliedEnergistics2 extends Common {
|
||||
private lazy val useAppliedEnergistics2Power = isServer && Mods.AppliedEnergistics2.isAvailable
|
||||
|
||||
// 'Manual' lazy val, because lazy vals mess up the class loader, leading to class not found exceptions.
|
||||
private var node: Option[AnyRef] = None
|
||||
|
||||
override def updateEntity() {
|
||||
super.updateEntity()
|
||||
if (useAppliedEnergistics2Power && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
|
||||
updateEnergy()
|
||||
}
|
||||
}
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
|
||||
private def updateEnergy() {
|
||||
tryAllSides((demand, side) => {
|
||||
val grid = getGridNode(side).getGrid
|
||||
if (grid != null) {
|
||||
val cache = grid.getCache(classOf[IEnergyGrid]).asInstanceOf[IEnergyGrid]
|
||||
if (cache != null) {
|
||||
cache.extractAEPower(demand, Actionable.MODULATE, PowerMultiplier.CONFIG)
|
||||
}
|
||||
else 0.0
|
||||
}
|
||||
else 0.0
|
||||
}, Power.fromAE, Power.toAE)
|
||||
}
|
||||
|
||||
override def validate() {
|
||||
super.validate()
|
||||
if (useAppliedEnergistics2Power) EventHandler.scheduleAE2Add(this)
|
||||
}
|
||||
|
||||
override def invalidate() {
|
||||
super.invalidate()
|
||||
if (useAppliedEnergistics2Power) securityBreak()
|
||||
}
|
||||
|
||||
override def onChunkUnload() {
|
||||
super.onChunkUnload()
|
||||
if (useAppliedEnergistics2Power) securityBreak()
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override def readFromNBTForServer(nbt: NBTTagCompound) {
|
||||
super.readFromNBTForServer(nbt)
|
||||
if (useAppliedEnergistics2Power) loadNode(nbt)
|
||||
}
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
|
||||
private def loadNode(nbt: NBTTagCompound): Unit = {
|
||||
getGridNode(ForgeDirection.UNKNOWN).loadFromNBT(Settings.namespace + "ae2power", nbt)
|
||||
}
|
||||
|
||||
override def writeToNBTForServer(nbt: NBTTagCompound) {
|
||||
super.writeToNBTForServer(nbt)
|
||||
if (useAppliedEnergistics2Power) saveNode(nbt)
|
||||
}
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
|
||||
private def saveNode(nbt: NBTTagCompound): Unit = {
|
||||
getGridNode(ForgeDirection.UNKNOWN).saveToNBT(Settings.namespace + "ae2power", nbt)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
|
||||
def getGridNode(side: ForgeDirection) = node match {
|
||||
case Some(gridNode: IGridNode) => gridNode
|
||||
case _ if isServer =>
|
||||
val gridNode = AEApi.instance.createGridNode(new AppliedEnergistics2GridBlock(this))
|
||||
node = Option(gridNode)
|
||||
gridNode
|
||||
case _ => null
|
||||
}
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
|
||||
def getCableConnectionType(side: ForgeDirection) = AECableType.SMART
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
|
||||
def securityBreak() {
|
||||
getGridNode(ForgeDirection.UNKNOWN).destroy()
|
||||
}
|
||||
}
|
||||
|
||||
class AppliedEnergistics2GridBlock(val tileEntity: AppliedEnergistics2) extends IGridBlock {
|
||||
override def getIdlePowerUsage = 0.0
|
||||
|
||||
override def getFlags = util.EnumSet.noneOf(classOf[GridFlags])
|
||||
|
||||
// rv1
|
||||
def isWorldAccessable = true
|
||||
|
||||
// rv2
|
||||
def isWorldAccessible = true
|
||||
|
||||
override def getLocation = new DimensionalCoord(tileEntity)
|
||||
|
||||
override def getGridColor = AEColor.Transparent
|
||||
|
||||
override def onGridNotification(p1: GridNotification) {}
|
||||
|
||||
override def setNetworkStatus(p1: IGrid, p2: Int) {}
|
||||
|
||||
override def getConnectableSides = util.EnumSet.copyOf(ForgeDirection.VALID_DIRECTIONS.filter(tileEntity.canConnectPower).toList)
|
||||
|
||||
override def getMachine = tileEntity.asInstanceOf[IGridHost]
|
||||
|
||||
override def gridChanged() {}
|
||||
|
||||
override def getMachineRepresentation = null
|
||||
}
|
||||
*/
|
@ -17,14 +17,14 @@ trait Common extends TileEntity {
|
||||
|
||||
def energyThroughput: Double
|
||||
|
||||
protected def tryAllSides(provider: (Double, EnumFacing) => Double, ratio: Double) {
|
||||
protected def tryAllSides(provider: (Double, EnumFacing) => Double, fromOther: Double => Double, toOther: Double => Double) {
|
||||
// We make sure to only call this every `Settings.get.tickFrequency` ticks,
|
||||
// but our throughput is per tick, so multiply this up for actual budget.
|
||||
var budget = energyThroughput * Settings.get.tickFrequency
|
||||
for (side <- EnumFacing.values) {
|
||||
val demand = math.min(budget, globalDemand(side)) / ratio
|
||||
val demand = fromOther(math.min(budget, globalDemand(side)))
|
||||
if (demand > 1) {
|
||||
val energy = provider(demand, side) * ratio
|
||||
val energy = toOther(provider(demand, side))
|
||||
if (energy > 0) {
|
||||
budget -= tryChangeBuffer(side, energy)
|
||||
}
|
||||
|
@ -1,92 +1,95 @@
|
||||
//package li.cil.oc.common.tileentity.traits.power
|
||||
//
|
||||
//import net.minecraftforge.fml.common.Optional
|
||||
//import factorization.api.Charge
|
||||
//import factorization.api.Coord
|
||||
//import factorization.api.IChargeConductor
|
||||
//import li.cil.oc.OpenComputers
|
||||
//import li.cil.oc.Settings
|
||||
//import li.cil.oc.common.asm.Injectable
|
||||
//import li.cil.oc.integration.Mods
|
||||
//import net.minecraft.nbt.NBTTagCompound
|
||||
//
|
||||
//@Injectable.Interface(value = "factorization.api.IChargeConductor", modid = Mods.IDs.Factorization)
|
||||
//trait Factorization extends Common {
|
||||
// private lazy val useFactorizationPower = isServer && Mods.Factorization.isAvailable
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.Factorization)
|
||||
// private lazy val charge: AnyRef = this match {
|
||||
// case conductor: IChargeConductor => new Charge(conductor)
|
||||
// case _ =>
|
||||
// OpenComputers.log.warn("Failed setting up Factorization power, which most likely means the class transformer did not run. You're probably running in an incorrectly configured development environment. Try adding `-Dfml.coreMods.load=li.cil.oc.common.launch.TransformerLoader` to the VM options of your run configuration.")
|
||||
// null
|
||||
// }
|
||||
//
|
||||
// // ----------------------------------------------------------------------- //
|
||||
//
|
||||
// override def updateEntity() {
|
||||
// if (useFactorizationPower) updateEnergy()
|
||||
// super.updateEntity()
|
||||
// }
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.Factorization)
|
||||
// private def updateEnergy() {
|
||||
// getCharge.update()
|
||||
// if (world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
|
||||
// tryAllSides((demand, _) => getCharge.deplete(demand.toInt), Settings.get.ratioFactorization)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override def invalidate() {
|
||||
// if (useFactorizationPower) invalidateCharge()
|
||||
// super.invalidate()
|
||||
// }
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.Factorization)
|
||||
// private def invalidateCharge() {
|
||||
// getCharge.invalidate()
|
||||
// }
|
||||
//
|
||||
// override def onChunkUnload() {
|
||||
// if (useFactorizationPower) removeCharge()
|
||||
// super.onChunkUnload()
|
||||
// }
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.Factorization)
|
||||
// private def removeCharge() {
|
||||
// if (!isInvalid) getCharge.remove()
|
||||
// }
|
||||
//
|
||||
// // ----------------------------------------------------------------------- //
|
||||
//
|
||||
// override def readFromNBTForServer(nbt: NBTTagCompound) {
|
||||
// super.readFromNBTForServer(nbt)
|
||||
// if (useFactorizationPower) loadCharge(nbt)
|
||||
// }
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.Factorization)
|
||||
// private def loadCharge(nbt: NBTTagCompound) {
|
||||
// getCharge.readFromNBT(nbt, "fzpower")
|
||||
// }
|
||||
//
|
||||
// override def writeToNBTForServer(nbt: NBTTagCompound) {
|
||||
// super.writeToNBTForServer(nbt)
|
||||
// if (useFactorizationPower) saveCharge(nbt)
|
||||
// }
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.Factorization)
|
||||
// private def saveCharge(nbt: NBTTagCompound) {
|
||||
// getCharge.writeToNBT(nbt, "fzpower")
|
||||
// }
|
||||
//
|
||||
// // ----------------------------------------------------------------------- //
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.Factorization)
|
||||
// def getCharge = if (Mods.Factorization.isAvailable) charge.asInstanceOf[Charge] else null
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.Factorization)
|
||||
// def getInfo = ""
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.Factorization)
|
||||
// def getCoord = new Coord(this)
|
||||
//}
|
||||
package li.cil.oc.common.tileentity.traits.power
|
||||
/* TODO Factorization
|
||||
|
||||
import cpw.mods.fml.common.Optional
|
||||
import factorization.api.Charge
|
||||
import factorization.api.Coord
|
||||
import factorization.api.IChargeConductor
|
||||
import li.cil.oc.OpenComputers
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.common.asm.Injectable
|
||||
import li.cil.oc.integration.Mods
|
||||
import li.cil.oc.integration.util.Power
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
|
||||
@Injectable.Interface(value = "factorization.api.IChargeConductor", modid = Mods.IDs.Factorization)
|
||||
trait Factorization extends Common {
|
||||
private lazy val useFactorizationPower = isServer && Mods.Factorization.isAvailable
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.Factorization)
|
||||
private lazy val charge: AnyRef = this match {
|
||||
case conductor: IChargeConductor => new Charge(conductor)
|
||||
case _ =>
|
||||
OpenComputers.log.warn("Failed setting up Factorization power, which most likely means the class transformer did not run. You're probably running in an incorrectly configured development environment. Try adding `-Dfml.coreMods.load=li.cil.oc.common.launch.TransformerLoader` to the VM options of your run configuration.")
|
||||
null
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override def updateEntity() {
|
||||
if (useFactorizationPower) updateEnergy()
|
||||
super.updateEntity()
|
||||
}
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.Factorization)
|
||||
private def updateEnergy() {
|
||||
getCharge.update()
|
||||
if (world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
|
||||
tryAllSides((demand, _) => getCharge.deplete(demand.toInt), Power.fromCharge, Power.toCharge)
|
||||
}
|
||||
}
|
||||
|
||||
override def invalidate() {
|
||||
if (useFactorizationPower) invalidateCharge()
|
||||
super.invalidate()
|
||||
}
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.Factorization)
|
||||
private def invalidateCharge() {
|
||||
getCharge.invalidate()
|
||||
}
|
||||
|
||||
override def onChunkUnload() {
|
||||
if (useFactorizationPower) removeCharge()
|
||||
super.onChunkUnload()
|
||||
}
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.Factorization)
|
||||
private def removeCharge() {
|
||||
if (!isInvalid) getCharge.remove()
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override def readFromNBTForServer(nbt: NBTTagCompound) {
|
||||
super.readFromNBTForServer(nbt)
|
||||
if (useFactorizationPower) loadCharge(nbt)
|
||||
}
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.Factorization)
|
||||
private def loadCharge(nbt: NBTTagCompound) {
|
||||
getCharge.readFromNBT(nbt, "fzpower")
|
||||
}
|
||||
|
||||
override def writeToNBTForServer(nbt: NBTTagCompound) {
|
||||
super.writeToNBTForServer(nbt)
|
||||
if (useFactorizationPower) saveCharge(nbt)
|
||||
}
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.Factorization)
|
||||
private def saveCharge(nbt: NBTTagCompound) {
|
||||
getCharge.writeToNBT(nbt, "fzpower")
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.Factorization)
|
||||
def getCharge = if (Mods.Factorization.isAvailable) charge.asInstanceOf[Charge] else null
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.Factorization)
|
||||
def getInfo = ""
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.Factorization)
|
||||
def getCoord = new Coord(this)
|
||||
}
|
||||
*/
|
@ -1,42 +1,44 @@
|
||||
//package li.cil.oc.common.tileentity.traits.power
|
||||
//
|
||||
//import net.minecraftforge.fml.common.Optional
|
||||
//import li.cil.oc.Settings
|
||||
//import li.cil.oc.common.asm.Injectable
|
||||
//import li.cil.oc.integration.Mods
|
||||
//import micdoodle8.mods.galacticraft.api.power.EnergySource
|
||||
//import micdoodle8.mods.galacticraft.api.transmission.NetworkType
|
||||
//import net.minecraft.util.EnumFacing
|
||||
//
|
||||
//import scala.language.implicitConversions
|
||||
//
|
||||
//@Injectable.InterfaceList(Array(
|
||||
// new Injectable.Interface(value = "micdoodle8.mods.galacticraft.api.power.IEnergyHandlerGC", modid = Mods.IDs.Galacticraft),
|
||||
// new Injectable.Interface(value = "micdoodle8.mods.galacticraft.api.transmission.tile.IConnector", modid = Mods.IDs.Galacticraft)
|
||||
//))
|
||||
//trait Galacticraft extends Common {
|
||||
// private implicit def toDirection(source: EnergySource): EnumFacing = source match {
|
||||
// case adjacent: EnergySource.EnergySourceAdjacent => adjacent.direction
|
||||
// case _ => EnumFacing.UNKNOWN
|
||||
// }
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.Galacticraft)
|
||||
// def nodeAvailable(from: EnergySource) = Mods.Galacticraft.isAvailable && canConnectPower(from)
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.Galacticraft)
|
||||
// def receiveEnergyGC(from: EnergySource, amount: Float, simulate: Boolean) =
|
||||
// if (!Mods.Galacticraft.isAvailable) 0f
|
||||
// else (tryChangeBuffer(from, amount * Settings.get.ratioGalacticraft, !simulate) / Settings.get.ratioGalacticraft).toFloat
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.Galacticraft)
|
||||
// def getEnergyStoredGC(from: EnergySource) = (globalBuffer(from) / Settings.get.ratioGalacticraft).toFloat
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.Galacticraft)
|
||||
// def getMaxEnergyStoredGC(from: EnergySource) = (globalBufferSize(from) / Settings.get.ratioGalacticraft).toFloat
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.Galacticraft)
|
||||
// def extractEnergyGC(from: EnergySource, amount: Float, simulate: Boolean) = 0f
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.Galacticraft)
|
||||
// def canConnect(from: EnumFacing, networkType: NetworkType): Boolean = networkType == NetworkType.POWER && canConnectPower(from)
|
||||
//}
|
||||
package li.cil.oc.common.tileentity.traits.power
|
||||
/* TODO Galacticraft
|
||||
|
||||
import cpw.mods.fml.common.Optional
|
||||
import li.cil.oc.common.asm.Injectable
|
||||
import li.cil.oc.integration.Mods
|
||||
import li.cil.oc.integration.util.Power
|
||||
import micdoodle8.mods.galacticraft.api.power.EnergySource
|
||||
import micdoodle8.mods.galacticraft.api.transmission.NetworkType
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
|
||||
import scala.language.implicitConversions
|
||||
|
||||
@Injectable.InterfaceList(Array(
|
||||
new Injectable.Interface(value = "micdoodle8.mods.galacticraft.api.power.IEnergyHandlerGC", modid = Mods.IDs.Galacticraft),
|
||||
new Injectable.Interface(value = "micdoodle8.mods.galacticraft.api.transmission.tile.IConnector", modid = Mods.IDs.Galacticraft)
|
||||
))
|
||||
trait Galacticraft extends Common {
|
||||
private implicit def toDirection(source: EnergySource): ForgeDirection = source match {
|
||||
case adjacent: EnergySource.EnergySourceAdjacent => adjacent.direction
|
||||
case _ => ForgeDirection.UNKNOWN
|
||||
}
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.Galacticraft)
|
||||
def nodeAvailable(from: EnergySource) = Mods.Galacticraft.isAvailable && canConnectPower(from)
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.Galacticraft)
|
||||
def receiveEnergyGC(from: EnergySource, amount: Float, simulate: Boolean) =
|
||||
if (!Mods.Galacticraft.isAvailable) 0f
|
||||
else Power.toGC(tryChangeBuffer(from, Power.fromGC(amount), !simulate))
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.Galacticraft)
|
||||
def getEnergyStoredGC(from: EnergySource) = Power.toGC(globalBuffer(from))
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.Galacticraft)
|
||||
def getMaxEnergyStoredGC(from: EnergySource) = Power.toGC(globalBufferSize(from))
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.Galacticraft)
|
||||
def extractEnergyGC(from: EnergySource, amount: Float, simulate: Boolean) = 0f
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.Galacticraft)
|
||||
def canConnect(from: ForgeDirection, networkType: NetworkType): Boolean = networkType == NetworkType.POWER && canConnectPower(from)
|
||||
}
|
||||
*/
|
@ -1,98 +1,101 @@
|
||||
//package li.cil.oc.common.tileentity.traits.power
|
||||
//
|
||||
//import net.minecraftforge.fml.common.Optional
|
||||
//import net.minecraftforge.fml.common.eventhandler.Event
|
||||
//import ic2classic.api.Direction
|
||||
//import li.cil.oc.OpenComputers
|
||||
//import li.cil.oc.Settings
|
||||
//import li.cil.oc.common.EventHandler
|
||||
//import li.cil.oc.common.asm.Injectable
|
||||
//import li.cil.oc.integration.Mods
|
||||
//import net.minecraft.nbt.NBTTagCompound
|
||||
//import net.minecraft.tileentity.TileEntity
|
||||
//import net.minecraftforge.common.MinecraftForge
|
||||
//import net.minecraft.util.EnumFacing
|
||||
//
|
||||
//@Injectable.Interface(value = "ic2classic.api.energy.tile.IEnergySink", modid = Mods.IDs.IndustrialCraft2Classic)
|
||||
//trait IndustrialCraft2Classic extends Common with IndustrialCraft2Common {
|
||||
// private var conversionBuffer = 0.0
|
||||
//
|
||||
// private lazy val useIndustrialCraft2ClassicPower = isServer && Mods.IndustrialCraft2Classic.isAvailable
|
||||
//
|
||||
// // ----------------------------------------------------------------------- //
|
||||
//
|
||||
// override def updateEntity() {
|
||||
// super.updateEntity()
|
||||
// if (useIndustrialCraft2ClassicPower && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
|
||||
// updateEnergy()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
|
||||
// private def updateEnergy() {
|
||||
// tryAllSides((demand, _) => {
|
||||
// val result = math.min(demand, conversionBuffer)
|
||||
// conversionBuffer -= result
|
||||
// result
|
||||
// }, Settings.get.ratioIndustrialCraft2)
|
||||
// }
|
||||
//
|
||||
// override def validate() {
|
||||
// super.validate()
|
||||
// if (useIndustrialCraft2ClassicPower && !addedToIC2PowerGrid) EventHandler.scheduleIC2Add(this)
|
||||
// }
|
||||
//
|
||||
// override def invalidate() {
|
||||
// super.invalidate()
|
||||
// if (useIndustrialCraft2ClassicPower && addedToIC2PowerGrid) removeFromIC2Grid()
|
||||
// }
|
||||
//
|
||||
// override def onChunkUnload() {
|
||||
// super.onChunkUnload()
|
||||
// if (useIndustrialCraft2ClassicPower && addedToIC2PowerGrid) removeFromIC2Grid()
|
||||
// }
|
||||
//
|
||||
// private def removeFromIC2Grid() {
|
||||
// try MinecraftForge.EVENT_BUS.post(Class.forName("ic2classic.api.energy.event.EnergyTileUnloadEvent").getConstructor(Class.forName("ic2classic.api.energy.tile.IEnergyTile")).newInstance(this).asInstanceOf[Event]) catch {
|
||||
// case t: Throwable => OpenComputers.log.warn("Error removing node from IC2 grid.", t)
|
||||
// }
|
||||
// addedToIC2PowerGrid = false
|
||||
// }
|
||||
//
|
||||
// // ----------------------------------------------------------------------- //
|
||||
//
|
||||
// override def readFromNBTForServer(nbt: NBTTagCompound) {
|
||||
// super.readFromNBTForServer(nbt)
|
||||
// conversionBuffer = nbt.getDouble(Settings.namespace + "ic2cpower")
|
||||
// }
|
||||
//
|
||||
// override def writeToNBTForServer(nbt: NBTTagCompound) {
|
||||
// super.writeToNBTForServer(nbt)
|
||||
// nbt.setDouble(Settings.namespace + "ic2cpower", conversionBuffer)
|
||||
// }
|
||||
//
|
||||
// // ----------------------------------------------------------------------- //
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
|
||||
// def isAddedToEnergyNet: Boolean = addedToIC2PowerGrid
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
|
||||
// def getMaxSafeInput: Int = Int.MaxValue
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
|
||||
// def acceptsEnergyFrom(emitter: TileEntity, direction: Direction) = useIndustrialCraft2ClassicPower && canConnectPower(direction.toEnumFacing)
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
|
||||
// def injectEnergy(directionFrom: Direction, amount: Int): Boolean = {
|
||||
// conversionBuffer += amount
|
||||
// true
|
||||
// }
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
|
||||
// def demandsEnergy: Int = {
|
||||
// if (!useIndustrialCraft2ClassicPower) 0
|
||||
// else if (conversionBuffer < energyThroughput * Settings.get.tickFrequency)
|
||||
// math.min(EnumFacing.values.map(globalDemand).max, energyThroughput / Settings.get.ratioIndustrialCraft2).toInt
|
||||
// else 0
|
||||
// }
|
||||
//}
|
||||
package li.cil.oc.common.tileentity.traits.power
|
||||
/* TODO IC2 Classic
|
||||
|
||||
import cpw.mods.fml.common.Optional
|
||||
import cpw.mods.fml.common.eventhandler.Event
|
||||
import ic2classic.api.Direction
|
||||
import li.cil.oc.OpenComputers
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.common.EventHandler
|
||||
import li.cil.oc.common.asm.Injectable
|
||||
import li.cil.oc.integration.Mods
|
||||
import li.cil.oc.integration.util.Power
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraftforge.common.MinecraftForge
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
|
||||
@Injectable.Interface(value = "ic2classic.api.energy.tile.IEnergySink", modid = Mods.IDs.IndustrialCraft2Classic)
|
||||
trait IndustrialCraft2Classic extends Common with IndustrialCraft2Common {
|
||||
private var conversionBuffer = 0.0
|
||||
|
||||
private lazy val useIndustrialCraft2ClassicPower = isServer && Mods.IndustrialCraft2Classic.isAvailable
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override def updateEntity() {
|
||||
super.updateEntity()
|
||||
if (useIndustrialCraft2ClassicPower && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
|
||||
updateEnergy()
|
||||
}
|
||||
}
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
|
||||
private def updateEnergy() {
|
||||
tryAllSides((demand, _) => {
|
||||
val result = math.min(demand, conversionBuffer)
|
||||
conversionBuffer -= result
|
||||
result
|
||||
}, Power.fromEU, Power.toEU)
|
||||
}
|
||||
|
||||
override def validate() {
|
||||
super.validate()
|
||||
if (useIndustrialCraft2ClassicPower && !addedToIC2PowerGrid) EventHandler.scheduleIC2Add(this)
|
||||
}
|
||||
|
||||
override def invalidate() {
|
||||
super.invalidate()
|
||||
if (useIndustrialCraft2ClassicPower && addedToIC2PowerGrid) removeFromIC2Grid()
|
||||
}
|
||||
|
||||
override def onChunkUnload() {
|
||||
super.onChunkUnload()
|
||||
if (useIndustrialCraft2ClassicPower && addedToIC2PowerGrid) removeFromIC2Grid()
|
||||
}
|
||||
|
||||
private def removeFromIC2Grid() {
|
||||
try MinecraftForge.EVENT_BUS.post(Class.forName("ic2classic.api.energy.event.EnergyTileUnloadEvent").getConstructor(Class.forName("ic2classic.api.energy.tile.IEnergyTile")).newInstance(this).asInstanceOf[Event]) catch {
|
||||
case t: Throwable => OpenComputers.log.warn("Error removing node from IC2 grid.", t)
|
||||
}
|
||||
addedToIC2PowerGrid = false
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override def readFromNBTForServer(nbt: NBTTagCompound) {
|
||||
super.readFromNBTForServer(nbt)
|
||||
conversionBuffer = nbt.getDouble(Settings.namespace + "ic2cpower")
|
||||
}
|
||||
|
||||
override def writeToNBTForServer(nbt: NBTTagCompound) {
|
||||
super.writeToNBTForServer(nbt)
|
||||
nbt.setDouble(Settings.namespace + "ic2cpower", conversionBuffer)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
|
||||
def isAddedToEnergyNet: Boolean = addedToIC2PowerGrid
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
|
||||
def getMaxSafeInput: Int = Int.MaxValue
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
|
||||
def acceptsEnergyFrom(emitter: TileEntity, direction: Direction) = useIndustrialCraft2ClassicPower && canConnectPower(direction.toForgeDirection)
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
|
||||
def injectEnergy(directionFrom: Direction, amount: Int): Boolean = {
|
||||
conversionBuffer += amount
|
||||
true
|
||||
}
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.IndustrialCraft2Classic)
|
||||
def demandsEnergy: Int = {
|
||||
if (!useIndustrialCraft2ClassicPower) 0
|
||||
else if (conversionBuffer < energyThroughput * Settings.get.tickFrequency)
|
||||
math.min(ForgeDirection.VALID_DIRECTIONS.map(globalDemand).max, Power.toEU(energyThroughput)).toInt
|
||||
else 0
|
||||
}
|
||||
}
|
||||
*/
|
@ -1,93 +1,96 @@
|
||||
//package li.cil.oc.common.tileentity.traits.power
|
||||
//
|
||||
//import net.minecraftforge.fml.common.Optional
|
||||
//import net.minecraftforge.fml.common.eventhandler.Event
|
||||
//import li.cil.oc.OpenComputers
|
||||
//import li.cil.oc.Settings
|
||||
//import li.cil.oc.common.EventHandler
|
||||
//import li.cil.oc.common.asm.Injectable
|
||||
//import li.cil.oc.integration.Mods
|
||||
//import net.minecraft.nbt.NBTTagCompound
|
||||
//import net.minecraftforge.common.MinecraftForge
|
||||
//import net.minecraft.util.EnumFacing
|
||||
//
|
||||
//@Injectable.Interface(value = "ic2.api.energy.tile.IEnergySink", modid = Mods.IDs.IndustrialCraft2)
|
||||
//trait IndustrialCraft2Experimental extends Common with IndustrialCraft2Common {
|
||||
// private var conversionBuffer = 0.0
|
||||
//
|
||||
// private lazy val useIndustrialCraft2Power = isServer && Mods.IndustrialCraft2.isAvailable
|
||||
//
|
||||
// // ----------------------------------------------------------------------- //
|
||||
//
|
||||
// override def updateEntity() {
|
||||
// super.updateEntity()
|
||||
// if (useIndustrialCraft2Power && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
|
||||
// updateEnergy()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.IndustrialCraft2)
|
||||
// private def updateEnergy() {
|
||||
// tryAllSides((demand, _) => {
|
||||
// val result = math.min(demand, conversionBuffer)
|
||||
// conversionBuffer -= result
|
||||
// result
|
||||
// }, Settings.get.ratioIndustrialCraft2)
|
||||
// }
|
||||
//
|
||||
// override def validate() {
|
||||
// super.validate()
|
||||
// if (useIndustrialCraft2Power && !addedToIC2PowerGrid) EventHandler.scheduleIC2Add(this)
|
||||
// }
|
||||
//
|
||||
// override def invalidate() {
|
||||
// super.invalidate()
|
||||
// if (useIndustrialCraft2Power && addedToIC2PowerGrid) removeFromIC2Grid()
|
||||
// }
|
||||
//
|
||||
// override def onChunkUnload() {
|
||||
// super.onChunkUnload()
|
||||
// if (useIndustrialCraft2Power && addedToIC2PowerGrid) removeFromIC2Grid()
|
||||
// }
|
||||
//
|
||||
// private def removeFromIC2Grid() {
|
||||
// try MinecraftForge.EVENT_BUS.post(Class.forName("ic2.api.energy.event.EnergyTileUnloadEvent").getConstructor(Class.forName("ic2.api.energy.tile.IEnergyTile")).newInstance(this).asInstanceOf[Event]) catch {
|
||||
// case t: Throwable => OpenComputers.log.warn("Error removing node from IC2 grid.", t)
|
||||
// }
|
||||
// addedToIC2PowerGrid = false
|
||||
// }
|
||||
//
|
||||
// // ----------------------------------------------------------------------- //
|
||||
//
|
||||
// override def readFromNBTForServer(nbt: NBTTagCompound) {
|
||||
// super.readFromNBTForServer(nbt)
|
||||
// conversionBuffer = nbt.getDouble(Settings.namespace + "ic2power")
|
||||
// }
|
||||
//
|
||||
// override def writeToNBTForServer(nbt: NBTTagCompound) {
|
||||
// super.writeToNBTForServer(nbt)
|
||||
// nbt.setDouble(Settings.namespace + "ic2power", conversionBuffer)
|
||||
// }
|
||||
//
|
||||
// // ----------------------------------------------------------------------- //
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.IndustrialCraft2)
|
||||
// def getSinkTier: Int = Int.MaxValue
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.IndustrialCraft2)
|
||||
// def acceptsEnergyFrom(emitter: net.minecraft.tileentity.TileEntity, direction: EnumFacing): Boolean = useIndustrialCraft2Power && canConnectPower(direction)
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.IndustrialCraft2)
|
||||
// def injectEnergy(directionFrom: EnumFacing, amount: Double, voltage: Double): Double = {
|
||||
// conversionBuffer += amount
|
||||
// 0.0
|
||||
// }
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.IndustrialCraft2)
|
||||
// def getDemandedEnergy: Double = {
|
||||
// if (!useIndustrialCraft2Power) 0.0
|
||||
// else if (conversionBuffer < energyThroughput * Settings.get.tickFrequency)
|
||||
// math.min(EnumFacing.values.map(globalDemand).max, energyThroughput / Settings.get.ratioIndustrialCraft2)
|
||||
// else 0
|
||||
// }
|
||||
//}
|
||||
package li.cil.oc.common.tileentity.traits.power
|
||||
/* TODO IC2
|
||||
|
||||
import cpw.mods.fml.common.Optional
|
||||
import cpw.mods.fml.common.eventhandler.Event
|
||||
import li.cil.oc.OpenComputers
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.common.EventHandler
|
||||
import li.cil.oc.common.asm.Injectable
|
||||
import li.cil.oc.integration.Mods
|
||||
import li.cil.oc.integration.util.Power
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraftforge.common.MinecraftForge
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
|
||||
@Injectable.Interface(value = "ic2.api.energy.tile.IEnergySink", modid = Mods.IDs.IndustrialCraft2)
|
||||
trait IndustrialCraft2Experimental extends Common with IndustrialCraft2Common {
|
||||
private var conversionBuffer = 0.0
|
||||
|
||||
private lazy val useIndustrialCraft2Power = isServer && Mods.IndustrialCraft2.isAvailable
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override def updateEntity() {
|
||||
super.updateEntity()
|
||||
if (useIndustrialCraft2Power && world.getTotalWorldTime % Settings.get.tickFrequency == 0) {
|
||||
updateEnergy()
|
||||
}
|
||||
}
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.IndustrialCraft2)
|
||||
private def updateEnergy() {
|
||||
tryAllSides((demand, _) => {
|
||||
val result = math.min(demand, conversionBuffer)
|
||||
conversionBuffer -= result
|
||||
result
|
||||
}, Power.fromEU, Power.toEU)
|
||||
}
|
||||
|
||||
override def validate() {
|
||||
super.validate()
|
||||
if (useIndustrialCraft2Power && !addedToIC2PowerGrid) EventHandler.scheduleIC2Add(this)
|
||||
}
|
||||
|
||||
override def invalidate() {
|
||||
super.invalidate()
|
||||
if (useIndustrialCraft2Power && addedToIC2PowerGrid) removeFromIC2Grid()
|
||||
}
|
||||
|
||||
override def onChunkUnload() {
|
||||
super.onChunkUnload()
|
||||
if (useIndustrialCraft2Power && addedToIC2PowerGrid) removeFromIC2Grid()
|
||||
}
|
||||
|
||||
private def removeFromIC2Grid() {
|
||||
try MinecraftForge.EVENT_BUS.post(Class.forName("ic2.api.energy.event.EnergyTileUnloadEvent").getConstructor(Class.forName("ic2.api.energy.tile.IEnergyTile")).newInstance(this).asInstanceOf[Event]) catch {
|
||||
case t: Throwable => OpenComputers.log.warn("Error removing node from IC2 grid.", t)
|
||||
}
|
||||
addedToIC2PowerGrid = false
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override def readFromNBTForServer(nbt: NBTTagCompound) {
|
||||
super.readFromNBTForServer(nbt)
|
||||
conversionBuffer = nbt.getDouble(Settings.namespace + "ic2power")
|
||||
}
|
||||
|
||||
override def writeToNBTForServer(nbt: NBTTagCompound) {
|
||||
super.writeToNBTForServer(nbt)
|
||||
nbt.setDouble(Settings.namespace + "ic2power", conversionBuffer)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.IndustrialCraft2)
|
||||
def getSinkTier: Int = Int.MaxValue
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.IndustrialCraft2)
|
||||
def acceptsEnergyFrom(emitter: net.minecraft.tileentity.TileEntity, direction: ForgeDirection): Boolean = useIndustrialCraft2Power && canConnectPower(direction)
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.IndustrialCraft2)
|
||||
def injectEnergy(directionFrom: ForgeDirection, amount: Double, voltage: Double): Double = {
|
||||
conversionBuffer += amount
|
||||
0.0
|
||||
}
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.IndustrialCraft2)
|
||||
def getDemandedEnergy: Double = {
|
||||
if (!useIndustrialCraft2Power) 0.0
|
||||
else if (conversionBuffer < energyThroughput * Settings.get.tickFrequency)
|
||||
math.min(ForgeDirection.VALID_DIRECTIONS.map(globalDemand).max, Power.toEU(energyThroughput))
|
||||
else 0
|
||||
}
|
||||
}
|
||||
*/
|
@ -1,27 +1,29 @@
|
||||
//package li.cil.oc.common.tileentity.traits.power
|
||||
//
|
||||
//import net.minecraftforge.fml.common.Optional
|
||||
//import li.cil.oc.Settings
|
||||
//import li.cil.oc.common.asm.Injectable
|
||||
//import li.cil.oc.integration.Mods
|
||||
//import net.minecraft.util.EnumFacing
|
||||
//
|
||||
//@Injectable.Interface(value = "mekanism.api.energy.IStrictEnergyAcceptor", modid = Mods.IDs.Mekanism)
|
||||
//trait Mekanism extends Common {
|
||||
// @Optional.Method(modid = Mods.IDs.Mekanism)
|
||||
// def canReceiveEnergy(side: EnumFacing) = Mods.Mekanism.isAvailable && canConnectPower(side)
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.Mekanism)
|
||||
// def transferEnergyToAcceptor(side: EnumFacing, amount: Double) =
|
||||
// if (!Mods.Mekanism.isAvailable) 0
|
||||
// else tryChangeBuffer(side, amount * Settings.get.ratioMekanism) / Settings.get.ratioMekanism
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.Mekanism)
|
||||
// def getMaxEnergy = EnumFacing.values.map(globalBufferSize).max / Settings.get.ratioMekanism
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.Mekanism)
|
||||
// def getEnergy = EnumFacing.values.map(globalBuffer).max / Settings.get.ratioMekanism
|
||||
//
|
||||
// @Optional.Method(modid = Mods.IDs.Mekanism)
|
||||
// def setEnergy(energy: Double) {}
|
||||
//}
|
||||
package li.cil.oc.common.tileentity.traits.power
|
||||
/* TODO Mekanism
|
||||
|
||||
import cpw.mods.fml.common.Optional
|
||||
import li.cil.oc.common.asm.Injectable
|
||||
import li.cil.oc.integration.Mods
|
||||
import li.cil.oc.integration.util.Power
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
|
||||
@Injectable.Interface(value = "mekanism.api.energy.IStrictEnergyAcceptor", modid = Mods.IDs.Mekanism)
|
||||
trait Mekanism extends Common {
|
||||
@Optional.Method(modid = Mods.IDs.Mekanism)
|
||||
def canReceiveEnergy(side: ForgeDirection) = Mods.Mekanism.isAvailable && canConnectPower(side)
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.Mekanism)
|
||||
def transferEnergyToAcceptor(side: ForgeDirection, amount: Double) =
|
||||
if (!Mods.Mekanism.isAvailable) 0
|
||||
else Power.toJoules(tryChangeBuffer(side, Power.fromJoules(amount)))
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.Mekanism)
|
||||
def getMaxEnergy = Power.toJoules(ForgeDirection.VALID_DIRECTIONS.map(globalBufferSize).max)
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.Mekanism)
|
||||
def getEnergy = Power.toJoules(ForgeDirection.VALID_DIRECTIONS.map(globalBuffer).max)
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.Mekanism)
|
||||
def setEnergy(energy: Double) {}
|
||||
}
|
||||
*/
|
@ -1,8 +1,8 @@
|
||||
package li.cil.oc.common.tileentity.traits.power
|
||||
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.common.asm.Injectable
|
||||
import li.cil.oc.integration.Mods
|
||||
import li.cil.oc.integration.util.Power
|
||||
import net.minecraft.util.EnumFacing
|
||||
import net.minecraftforge.fml.common.Optional
|
||||
|
||||
@ -14,11 +14,14 @@ trait RedstoneFlux extends Common {
|
||||
@Optional.Method(modid = Mods.IDs.CoFHEnergy)
|
||||
def receiveEnergy(from: EnumFacing, maxReceive: Int, simulate: Boolean) =
|
||||
if (!Mods.CoFHEnergy.isAvailable) 0
|
||||
else (tryChangeBuffer(from, maxReceive * Settings.get.ratioRedstoneFlux, !simulate) / Settings.get.ratioRedstoneFlux).toInt
|
||||
else Power.toRF(tryChangeBuffer(from, Power.fromRF(maxReceive), !simulate))
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.CoFHEnergy)
|
||||
def getEnergyStored(from: EnumFacing) = (globalBuffer(from) / Settings.get.ratioRedstoneFlux).toInt
|
||||
def getEnergyStored(from: EnumFacing) = Power.toRF(globalBuffer(from))
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.CoFHEnergy)
|
||||
def getMaxEnergyStored(from: EnumFacing) = (globalBufferSize(from) / Settings.get.ratioRedstoneFlux).toInt
|
||||
def getMaxEnergyStored(from: EnumFacing) = Power.toRF(globalBufferSize(from))
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.CoFHEnergy)
|
||||
def extractEnergy(from: EnumFacing, maxExtract: Int, simulate: Boolean) = 0
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ object Mods {
|
||||
val BluePower = new SimpleMod(IDs.BluePower, version = "@[0.2.928,)")
|
||||
val BuildCraft = new SimpleMod(IDs.BuildCraft)
|
||||
val BuildCraftLibrary = new SimpleMod(IDs.BuildCraftLibrary, version = "@[7.0.9,)")
|
||||
val BuildCraftRecipes = new SimpleMod(IDs.BuildCraftRecipes)
|
||||
val BuildCraftTiles = new SimpleMod(IDs.BuildCraftTiles)
|
||||
val BuildCraftTools = new SimpleMod(IDs.BuildCraftTools)
|
||||
val BuildCraftTransport = new SimpleMod(IDs.BuildCraftTransport)
|
||||
@ -64,6 +65,7 @@ object Mods {
|
||||
val ProjectRedTransmission = new SimpleMod(IDs.ProjectRedTransmission)
|
||||
val Railcraft = new SimpleMod(IDs.Railcraft)
|
||||
val RedLogic = new SimpleMod(IDs.RedLogic)
|
||||
val RotaryCraft = new SimpleMod(IDs.RotaryCraft)
|
||||
val StargateTech2 = new ModBase {
|
||||
def id = IDs.StargateTech2
|
||||
|
||||
@ -92,9 +94,10 @@ object Mods {
|
||||
// integration.bloodmagic.ModBloodMagic,
|
||||
// integration.bluepower.ModBluePower,
|
||||
// integration.buildcraft.library.ModBuildCraftAPILibrary,
|
||||
// integration.buildcraft.tools.ModBuildCraftAPITools,
|
||||
// integration.buildcraft.tiles.ModBuildCraftAPITiles,
|
||||
// integration.buildcraft.transport.ModBuildCraftAPITransport,
|
||||
// integration.buildcraft.recipes.ModBuildCraftRecipes,
|
||||
// integration.buildcraft.tools.ModBuildCraftTools,
|
||||
// integration.buildcraft.tiles.ModBuildCraftTiles,
|
||||
// integration.buildcraft.transport.ModBuildCraftTransport,
|
||||
// integration.cofh.energy.ModCoFHEnergy,
|
||||
// integration.cofh.item.ModCoFHItem,
|
||||
// integration.cofh.tileentity.ModCoFHTileEntity,
|
||||
@ -117,6 +120,7 @@ object Mods {
|
||||
integration.poweradvantage.ModPowerAdvantage,
|
||||
// integration.railcraft.ModRailcraft,
|
||||
// integration.redlogic.ModRedLogic,
|
||||
// integration.rotarycraft.ModRotaryCraft,
|
||||
// integration.stargatetech2.ModStargateTech2,
|
||||
// integration.thaumcraft.ModThaumcraft,
|
||||
// integration.thermalexpansion.ModThermalExpansion,
|
||||
@ -170,6 +174,7 @@ object Mods {
|
||||
final val BluePower = "bluepowerAPI"
|
||||
final val BuildCraft = "BuildCraft|Core"
|
||||
final val BuildCraftLibrary = "BuildCraftAPI|library"
|
||||
final val BuildCraftRecipes = "BuildCraftAPI|recipes"
|
||||
final val BuildCraftTiles = "BuildCraftAPI|tiles"
|
||||
final val BuildCraftTools = "BuildCraftAPI|tools"
|
||||
final val BuildCraftTransport = "BuildCraftAPI|transport"
|
||||
@ -207,6 +212,7 @@ object Mods {
|
||||
final val ProjectRedTransmission = "ProjRed|Transmission"
|
||||
final val Railcraft = "Railcraft"
|
||||
final val RedLogic = "RedLogic"
|
||||
final val RotaryCraft = "RotaryCraft"
|
||||
final val StargateTech2 = "StargateTech2"
|
||||
final val Thaumcraft = "Thaumcraft"
|
||||
final val ThermalExpansion = "ThermalExpansion"
|
||||
|
@ -2,7 +2,6 @@ package li.cil.oc.integration.agricraft
|
||||
|
||||
import java.util
|
||||
|
||||
import com.InfinityRaider.AgriCraft.api.v1.ISeedStats
|
||||
import li.cil.oc.api.driver.Converter
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
@ -15,12 +14,12 @@ object ConverterSeeds extends Converter {
|
||||
if (api.isHandledByAgricraft(stack) && stack.hasTagCompound && stack.getTagCompound.getBoolean("analyzed")) api.getSeedStats(stack) match {
|
||||
case stats: ISeedStats =>
|
||||
output += "agricraft" -> Map(
|
||||
"gain" -> float2Float(stats.getGain),
|
||||
"maxGain" -> float2Float(stats.getMaxGain),
|
||||
"growth" -> float2Float(stats.getGrowth),
|
||||
"maxGrowth" -> float2Float(stats.getMaxGrowth),
|
||||
"strength" -> float2Float(stats.getStrength),
|
||||
"maxStrength" -> float2Float(stats.getMaxStrength)
|
||||
"gain" -> Float.box(stats.getGain),
|
||||
"maxGain" -> Float.box(stats.getMaxGain),
|
||||
"growth" -> Float.box(stats.getGrowth),
|
||||
"maxGrowth" -> Float.box(stats.getMaxGrowth),
|
||||
"strength" -> Float.box(stats.getStrength),
|
||||
"maxStrength" -> Float.box(stats.getMaxStrength)
|
||||
)
|
||||
case _ =>
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user