Permalink
Browse files

Merge branch 'master' into feature/minecraft-1.11.2

  • Loading branch information...
SquidDev committed Jan 15, 2018
2 parents 78da682 + 3b3dd80 commit cbd4dd435bf8c7e9a9ae23336298f148c00dfe3e
@@ -774,7 +774,7 @@ public static IPocketUpgrade getPocketUpgrade( @Nonnull ItemStack stack )
return upgrades;
}
public IPacketNetwork getWirelessNetwork()
public static IPacketNetwork getWirelessNetwork()
{
return WirelessNetwork.getUniversal();
}
@@ -147,7 +147,7 @@ private IBakedModel buildModel( TurtleModelCombination combo )
ModelResourceLocation baseModelLocation = TileEntityTurtleRenderer.getTurtleModel( combo.m_family, combo.m_colour );
ModelResourceLocation overlayModelLocation = TileEntityTurtleRenderer.getTurtleOverlayModel( combo.m_family, combo.m_overlay, combo.m_christmas );
IBakedModel baseModel = modelManager.getModel( baseModelLocation );
IBakedModel overlayModel = (overlayModelLocation != null) ? modelManager.getModel( baseModelLocation ) : null;
IBakedModel overlayModel = (overlayModelLocation != null) ? modelManager.getModel( overlayModelLocation ) : null;
Pair<IBakedModel, Matrix4f> leftModel = (combo.m_leftUpgrade != null) ? combo.m_leftUpgrade.getModel( null, TurtleSide.Left ) : null;
Pair<IBakedModel, Matrix4f> rightModel = (combo.m_rightUpgrade != null) ? combo.m_rightUpgrade.getModel( null, TurtleSide.Right ) : null;
if( leftModel != null && rightModel != null )
@@ -6,6 +6,8 @@
import javax.annotation.Nonnull;
import java.io.*;
import static dan200.computercraft.core.apis.ArgumentHelper.*;
public class EncodedInputHandle extends HandleGeneric
{
private final BufferedReader m_reader;
@@ -49,6 +51,7 @@ private static BufferedReader makeReader( InputStream stream, String encoding )
"readLine",
"readAll",
"close",
"read",
};
}
@@ -102,6 +105,26 @@ private static BufferedReader makeReader( InputStream stream, String encoding )
// close
close();
return null;
case 3:
// read
checkOpen();
try
{
int count = optInt( args, 0, 1 );
if( count <= 0 || count >= 1024 * 16 )
{
throw new LuaException( "Count out of range" );
}
char[] bytes = new char[ count ];
count = m_reader.read( bytes );
if( count < 0 ) return null;
String str = new String( bytes, 0, count );
return new Object[] { str };
}
catch( IOException e )
{
return null;
}
default:
return null;
}
@@ -241,10 +241,9 @@ public final AxisAlignedBB getCollisionBoundingBox( IBlockState state, @Nonnull
if( collision.size() > 0 )
{
AxisAlignedBB aabb = collision.get( 0 );
for (int i=1; i<collision.size(); ++i )
for( int i = 1; i < collision.size(); i++ )
{
AxisAlignedBB other = collision.get( 1 );
aabb = aabb.union( other );
aabb = aabb.union( collision.get( i ) );
}
return aabb;
}
@@ -493,21 +493,6 @@ private boolean inputPage()
ItemStack paperStack = m_inventory.get( i );
if( !paperStack.isEmpty() && isPaper(paperStack) )
{
// Decrement ink
inkStack.shrink( 1 );
if( inkStack.isEmpty() )
{
m_inventory.set( 0, ItemStack.EMPTY );
}
// Decrement paper
paperStack.shrink( 1 );
if( paperStack.isEmpty() )
{
m_inventory.set( i, ItemStack.EMPTY );
updateAnim();
}
// Setup the new page
int colour = inkStack.getItemDamage();
if( colour >= 0 && colour < 16 ) {
@@ -532,6 +517,21 @@ private boolean inputPage()
m_pageTitle = "";
}
m_page.setCursorPos( 0, 0 );
// Decrement ink
inkStack.shrink( 1 );
if( inkStack.isEmpty() )
{
m_inventory.set( 0, ItemStack.EMPTY );
}
// Decrement paper
paperStack.shrink( 1 );
if( paperStack.isEmpty() )
{
m_inventory.set( i, ItemStack.EMPTY );
updateAnim();
}
markDirty();
m_printing = true;
@@ -206,8 +206,8 @@ function sleep( nTime )
end
function write( sText )
if sText ~= nil and type( sText ) ~= "string" and type( sText ) ~= "number" then
error( "bad argument #1 (expected string, got " .. type( sText ) .. ")", 2 )
if type( sText ) ~= "string" and type( sText ) ~= "number" then
error( "bad argument #1 (expected string or number, got " .. type( sText ) .. ")", 2 )
end
local w,h = term.getSize()
@@ -23,8 +23,11 @@ local g_defaultOutput = {
bClosed = false,
close = function( self )
end,
write = function( self, _sText )
_G.write( _sText )
write = function( self, ... )
local nLimit = select("#", ... )
for n = 1, nLimit do
_G.write( select( n, ... ) )
end
end,
flush = function( self )
end,
@@ -54,7 +57,7 @@ function input( _arg )
end
function lines( _sFileName )
if _G.type( _sFileNamel ) ~= "string" then
if _G.type( _sFileName ) ~= "string" then
error( "bad argument #1 (expected string, got " .. _G.type( _sFileName ) .. ")", 2 )
end
if _sFileName then
@@ -91,6 +94,8 @@ function open( _sPath, _sMode )
return file.readLine()
elseif sFormat == "*a" then
return file.readAll()
elseif _G.type( sFormat ) == "number" then
return file.read( sFormat )
else
error( "Unsupported format", 2 )
end
@@ -115,8 +120,11 @@ function open( _sPath, _sMode )
file.close()
self.bClosed = true
end,
write = function( self, _sText )
file.write( _sText )
write = function( self, ... )
local nLimit = select("#", ... )
for n = 1, nLimit do
file.write( select( n, ... ) )
end
end,
flush = function( self )
file.flush()
@@ -144,8 +152,11 @@ function open( _sPath, _sMode )
file.close()
self.bClosed = true
end,
write = function( self, _number )
file.write( _number )
write = function( self, ... )
local nLimit = select("#", ... )
for n = 1, nLimit do
file.write( select( n, ... ) )
end
end,
flush = function( self )
file.flush()
@@ -1,6 +1,6 @@
cd changes the the directory you're in.
cd changes the directory you're in.
ex:
"cd rom" will move to "rom" folder.
"cd .." will move up one folder.
"cd /" will move to the root.
"cd /" will move to the root.
@@ -22,6 +22,7 @@ Functions on files opened with mode "r":
readLine()
readAll()
close()
read( number )
Functions on files opened with mode "w" or "a":
write( string )
@@ -36,4 +37,4 @@ close()
Functions on files opened with mode "wb" or "ab":
write( byte )
flush()
close()
close()
@@ -0,0 +1,4 @@
--[[
Alright then, don't ignore me. This file is to ensure the existence of the "modules/command" folder.
You can use this folder to add modules who can be loaded with require() to your Resourcepack.
]]
@@ -0,0 +1,4 @@
--[[
Alright then, don't ignore me. This file is to ensure the existence of the "modules/main" folder.
You can use this folder to add modules who can be loaded with require() to your Resourcepack.
]]
@@ -0,0 +1,4 @@
--[[
Alright then, don't ignore me. This file is to ensure the existence of the "modules/turtle" folder.
You can use this folder to add modules who can be loaded with require() to your Resourcepack.
]]
@@ -13,7 +13,11 @@ if #tFiles > 0 then
if fs.isDir( sDest ) then
fs.copy( sFile, fs.combine( sDest, fs.getName(sFile) ) )
elseif #tFiles == 1 then
fs.copy( sFile, sDest )
if fs.exists( sDest ) then
printError( "Destination exists" )
else
fs.copy( sFile, sDest )
end
else
printError( "Cannot overwrite file multiple times" )
return
@@ -16,7 +16,7 @@ end
-- Create .lua files by default
if not fs.exists( sPath ) and not string.find( sPath, "%." ) then
local sExtension = settings.get("edit.default_extension", "" )
if sExtension ~= "" then
if sExtension ~= "" and type( sExtension ) == "string" then
sPath = sPath .. "." .. sExtension
end
end
@@ -47,7 +47,7 @@ end
-- Create .nfp files by default
if not fs.exists( sPath ) and not string.find( sPath, "%." ) then
local sExtension = settings.get("paint.default_extension", "" )
if sExtension ~= "" then
if sExtension ~= "" and type( sExtension ) == "string" then
sPath = sPath .. "." .. sExtension
end
end
@@ -5,5 +5,11 @@ if #tArgs < 1 then
end
local sNewDir = shell.resolve( tArgs[1] )
if fs.exists( sNewDir ) and not fs.isDir(sNewDir) then
printError( "Destination exists" )
return
end
fs.makeDir( sNewDir )
@@ -6,4 +6,9 @@ end
local sSource = shell.resolve( tArgs[1] )
local sDest = shell.resolve( tArgs[2] )
if fs.exists( sDest ) then
printError( "Destination exists" )
end
fs.move( sSource, sDest )
@@ -30,7 +30,12 @@ local function createShellEnv( sDir )
string = string,
table = table,
}
package.path = "?;?.lua;?/init.lua"
package.path = "?;?.lua;?/init.lua;/rom/modules/main/?;/rom/modules/main/?.lua;/rom/modules/main/?/init.lua"
if turtle then
package.path = package.path..";/rom/modules/turtle/?;/rom/modules/turtle/?.lua;/rom/modules/turtle/?/init.lua"
elseif command then
package.path = package.path..";/rom/modules/command/?;/rom/modules/command/?.lua;/rom/modules/command/?/init.lua"
end
package.config = "/\n;\n?\n!\n-"
package.preload = {}
package.loaders = {

0 comments on commit cbd4dd4

Please sign in to comment.