mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-07-03 02:22:51 +00:00
Reformat everything
It's been a long time comin' But tonight is the end of the war, my friend Tomorrow only one style will remain.
This commit is contained in:
parent
72b9d3d802
commit
2032e7a83a
@ -219,7 +219,8 @@ public class ComputerCraft
|
||||
public static PocketSpeaker pocketSpeaker;
|
||||
}
|
||||
|
||||
public static class Config {
|
||||
public static class Config
|
||||
{
|
||||
public static Configuration config;
|
||||
|
||||
public static Property http_enable;
|
||||
@ -408,7 +409,8 @@ public class ComputerCraft
|
||||
syncConfig();
|
||||
}
|
||||
|
||||
public static void syncConfig() {
|
||||
public static void syncConfig()
|
||||
{
|
||||
|
||||
http_enable = Config.http_enable.getBoolean();
|
||||
http_websocket_enable = Config.http_websocket_enable.getBoolean();
|
||||
@ -843,7 +845,8 @@ public class ComputerCraft
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IPocketUpgrade getPocketUpgrade(String id) {
|
||||
public static IPocketUpgrade getPocketUpgrade( String id )
|
||||
{
|
||||
return pocketUpgrades.get( id );
|
||||
}
|
||||
|
||||
@ -863,10 +866,13 @@ public class ComputerCraft
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Iterable<IPocketUpgrade> getVanillaPocketUpgrades() {
|
||||
public static Iterable<IPocketUpgrade> getVanillaPocketUpgrades()
|
||||
{
|
||||
List<IPocketUpgrade> upgrades = new ArrayList<>();
|
||||
for(IPocketUpgrade upgrade : pocketUpgrades.values()) {
|
||||
if(upgrade instanceof PocketModem || upgrade instanceof PocketSpeaker) {
|
||||
for( IPocketUpgrade upgrade : pocketUpgrades.values() )
|
||||
{
|
||||
if( upgrade instanceof PocketModem || upgrade instanceof PocketSpeaker )
|
||||
{
|
||||
upgrades.add( upgrade );
|
||||
}
|
||||
}
|
||||
@ -1078,16 +1084,22 @@ public class ComputerCraft
|
||||
}
|
||||
|
||||
URL url;
|
||||
try {
|
||||
try
|
||||
{
|
||||
url = new URL( path );
|
||||
} catch (MalformedURLException e1) {
|
||||
}
|
||||
catch( MalformedURLException e1 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
File file;
|
||||
try {
|
||||
try
|
||||
{
|
||||
file = new File( url.toURI() );
|
||||
} catch(URISyntaxException e) {
|
||||
}
|
||||
catch( URISyntaxException e )
|
||||
{
|
||||
file = new File( url.getPath() );
|
||||
}
|
||||
return file;
|
||||
|
@ -49,9 +49,12 @@ public final class ComputerCraftAPI
|
||||
findCC();
|
||||
if( computerCraft_getVersion != null )
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
return (String) computerCraft_getVersion.invoke( null );
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// It failed
|
||||
}
|
||||
}
|
||||
@ -82,9 +85,12 @@ public final class ComputerCraftAPI
|
||||
findCC();
|
||||
if( computerCraft_createUniqueNumberedSaveDir != null )
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
return (Integer) computerCraft_createUniqueNumberedSaveDir.invoke( null, world, parentSubPath );
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// It failed
|
||||
}
|
||||
}
|
||||
@ -115,9 +121,12 @@ public final class ComputerCraftAPI
|
||||
findCC();
|
||||
if( computerCraft_createSaveDirMount != null )
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
return (IWritableMount) computerCraft_createSaveDirMount.invoke( null, world, subPath, capacity );
|
||||
} catch (Exception e){
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// It failed
|
||||
}
|
||||
}
|
||||
@ -148,9 +157,12 @@ public final class ComputerCraftAPI
|
||||
findCC();
|
||||
if( computerCraft_createResourceMount != null )
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
return (IMount) computerCraft_createResourceMount.invoke( null, modClass, domain, subPath );
|
||||
} catch (Exception e){
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// It failed
|
||||
}
|
||||
}
|
||||
@ -169,9 +181,12 @@ public final class ComputerCraftAPI
|
||||
findCC();
|
||||
if( computerCraft_registerPeripheralProvider != null )
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
computerCraft_registerPeripheralProvider.invoke( null, handler );
|
||||
} catch (Exception e){
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// It failed
|
||||
}
|
||||
}
|
||||
@ -192,9 +207,12 @@ public final class ComputerCraftAPI
|
||||
findCC();
|
||||
if( computerCraft_registerTurtleUpgrade != null )
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
computerCraft_registerTurtleUpgrade.invoke( null, upgrade );
|
||||
} catch( Exception e ) {
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// It failed
|
||||
}
|
||||
}
|
||||
@ -212,9 +230,12 @@ public final class ComputerCraftAPI
|
||||
findCC();
|
||||
if( computerCraft_registerBundledRedstoneProvider != null )
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
computerCraft_registerBundledRedstoneProvider.invoke( null, handler );
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// It failed
|
||||
}
|
||||
}
|
||||
@ -235,9 +256,12 @@ public final class ComputerCraftAPI
|
||||
findCC();
|
||||
if( computerCraft_getDefaultBundledRedstoneOutput != null )
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
return (Integer) computerCraft_getDefaultBundledRedstoneOutput.invoke( null, world, pos, side );
|
||||
} catch (Exception e){
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// It failed
|
||||
}
|
||||
}
|
||||
@ -255,9 +279,12 @@ public final class ComputerCraftAPI
|
||||
findCC();
|
||||
if( computerCraft_registerMediaProvider != null )
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
computerCraft_registerMediaProvider.invoke( null, handler );
|
||||
} catch (Exception e){
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// It failed
|
||||
}
|
||||
}
|
||||
@ -276,9 +303,12 @@ public final class ComputerCraftAPI
|
||||
findCC();
|
||||
if( computerCraft_registerPermissionProvider != null )
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
computerCraft_registerPermissionProvider.invoke( null, handler );
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// It failed
|
||||
}
|
||||
}
|
||||
@ -287,10 +317,14 @@ public final class ComputerCraftAPI
|
||||
public static void registerPocketUpgrade( @Nonnull IPocketUpgrade upgrade )
|
||||
{
|
||||
findCC();
|
||||
if(computerCraft_registerPocketUpgrade != null) {
|
||||
try {
|
||||
if( computerCraft_registerPocketUpgrade != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
computerCraft_registerPocketUpgrade.invoke( null, upgrade );
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// It failed
|
||||
}
|
||||
}
|
||||
@ -309,7 +343,9 @@ public final class ComputerCraftAPI
|
||||
try
|
||||
{
|
||||
return (IPacketNetwork) computerCraft_getWirelessNetwork.invoke( null );
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
// It failed;
|
||||
}
|
||||
}
|
||||
@ -394,8 +430,10 @@ public final class ComputerCraftAPI
|
||||
|
||||
private static void findCC()
|
||||
{
|
||||
if( !ccSearched ) {
|
||||
try {
|
||||
if( !ccSearched )
|
||||
{
|
||||
try
|
||||
{
|
||||
computerCraft = Class.forName( "dan200.computercraft.ComputerCraft" );
|
||||
computerCraft_getVersion = findCCMethod( "getVersion", new Class<?>[] {
|
||||
} );
|
||||
@ -440,9 +478,13 @@ public final class ComputerCraftAPI
|
||||
computerCraft_getWiredElementAt = findCCMethod( "getWiredElementAt", new Class<?>[] {
|
||||
IBlockAccess.class, BlockPos.class, EnumFacing.class
|
||||
} );
|
||||
} catch( Exception e ) {
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
System.out.println( "ComputerCraftAPI: ComputerCraft not found." );
|
||||
} finally {
|
||||
}
|
||||
finally
|
||||
{
|
||||
ccSearched = true;
|
||||
}
|
||||
}
|
||||
@ -450,13 +492,16 @@ public final class ComputerCraftAPI
|
||||
|
||||
private static Method findCCMethod( String name, Class<?>[] args )
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
if( computerCraft != null )
|
||||
{
|
||||
return computerCraft.getMethod( name, args );
|
||||
}
|
||||
return null;
|
||||
} catch( NoSuchMethodException e ) {
|
||||
}
|
||||
catch( NoSuchMethodException e )
|
||||
{
|
||||
System.out.println( "ComputerCraftAPI: ComputerCraft method " + name + " not found." );
|
||||
return null;
|
||||
}
|
||||
|
@ -31,11 +31,11 @@ public class GuiPrintout extends GuiContainer
|
||||
|
||||
String[] text = ItemPrintout.getText( container.getStack() );
|
||||
m_text = new TextBuffer[text.length];
|
||||
for( int i = 0; i < m_text.length; ++i ) m_text[ i ] = new TextBuffer( text[ i ] );
|
||||
for( int i = 0; i < m_text.length; i++ ) m_text[i] = new TextBuffer( text[i] );
|
||||
|
||||
String[] colours = ItemPrintout.getColours( container.getStack() );
|
||||
m_colours = new TextBuffer[colours.length];
|
||||
for( int i = 0; i < m_colours.length; ++i ) m_colours[ i ] = new TextBuffer( colours[ i ] );
|
||||
for( int i = 0; i < m_colours.length; i++ ) m_colours[i] = new TextBuffer( colours[i] );
|
||||
|
||||
m_page = 0;
|
||||
m_pages = Math.max( m_text.length / ItemPrintout.LINES_PER_PAGE, 1 );
|
||||
|
@ -433,7 +433,8 @@ public class WidgetTerminal extends Widget
|
||||
palette
|
||||
);
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
// Draw a black background
|
||||
mc.getTextureManager().bindTexture( background );
|
||||
@ -442,7 +443,8 @@ public class WidgetTerminal extends Widget
|
||||
try
|
||||
{
|
||||
drawTexturedModalRect( startX, startY, 0, 0, getWidth(), getHeight() );
|
||||
} finally
|
||||
}
|
||||
finally
|
||||
{
|
||||
GlStateManager.color( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public class CCTurtleProxyClient extends CCTurtleProxyCommon
|
||||
private void registerItemModel( Item item, ItemMeshDefinition definition, String[] names )
|
||||
{
|
||||
ResourceLocation[] resources = new ResourceLocation[names.length];
|
||||
for( int i=0; i<names.length; ++i )
|
||||
for( int i = 0; i < names.length; i++ )
|
||||
{
|
||||
resources[i] = new ResourceLocation( "computercraft:" + names[i] );
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
private void registerItemModel( Item item, ItemMeshDefinition definition, String[] names )
|
||||
{
|
||||
ResourceLocation[] resources = new ResourceLocation[names.length];
|
||||
for( int i=0; i<resources.length; ++i )
|
||||
for( int i = 0; i < resources.length; i++ )
|
||||
{
|
||||
resources[i] = new ResourceLocation( "computercraft", names[i] );
|
||||
}
|
||||
@ -316,9 +316,12 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
||||
{
|
||||
List<String> info = new ArrayList<>( 1 );
|
||||
recordStack.getItem().addInformation( recordStack, null, info, ITooltipFlag.TooltipFlags.NORMAL );
|
||||
if( info.size() > 0 ) {
|
||||
if( info.size() > 0 )
|
||||
{
|
||||
return info.get( 0 );
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.getRecordInfo( recordStack );
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
|
@ -158,7 +158,7 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon
|
||||
}
|
||||
|
||||
// Backgrounds
|
||||
for( int y = 0; y < height; ++y )
|
||||
for( int y = 0; y < height; y++ )
|
||||
{
|
||||
fontRenderer.drawStringBackgroundPart(
|
||||
0, FixedWidthFontRenderer.FONT_HEIGHT * y,
|
||||
@ -186,7 +186,7 @@ public class TileEntityMonitorRenderer extends TileEntitySpecialRenderer<TileMon
|
||||
try
|
||||
{
|
||||
// Lines
|
||||
for( int y = 0; y < height; ++y )
|
||||
for( int y = 0; y < height; y++ )
|
||||
{
|
||||
fontRenderer.drawStringTextPart(
|
||||
0, FixedWidthFontRenderer.FONT_HEIGHT * y,
|
||||
|
@ -94,10 +94,12 @@ public class FSAPI implements ILuaAPI
|
||||
// list
|
||||
String path = getString( args, 0 );
|
||||
m_env.addTrackingChange( TrackingField.FS_OPS );
|
||||
try {
|
||||
try
|
||||
{
|
||||
String[] results = m_fileSystem.list( path );
|
||||
Map<Object, Object> table = new HashMap<>();
|
||||
for(int i=0; i<results.length; ++i ) {
|
||||
for( int i = 0; i < results.length; i++ )
|
||||
{
|
||||
table.put( i + 1, results[i] );
|
||||
}
|
||||
return new Object[] { table };
|
||||
@ -137,9 +139,12 @@ public class FSAPI implements ILuaAPI
|
||||
{
|
||||
// exists
|
||||
String path = getString( args, 0 );
|
||||
try {
|
||||
try
|
||||
{
|
||||
return new Object[] { m_fileSystem.exists( path ) };
|
||||
} catch( FileSystemException e ) {
|
||||
}
|
||||
catch( FileSystemException e )
|
||||
{
|
||||
return new Object[] { false };
|
||||
}
|
||||
}
|
||||
@ -147,9 +152,12 @@ public class FSAPI implements ILuaAPI
|
||||
{
|
||||
// isDir
|
||||
String path = getString( args, 0 );
|
||||
try {
|
||||
try
|
||||
{
|
||||
return new Object[] { m_fileSystem.isDir( path ) };
|
||||
} catch( FileSystemException e ) {
|
||||
}
|
||||
catch( FileSystemException e )
|
||||
{
|
||||
return new Object[] { false };
|
||||
}
|
||||
}
|
||||
@ -157,9 +165,12 @@ public class FSAPI implements ILuaAPI
|
||||
{
|
||||
// isReadOnly
|
||||
String path = getString( args, 0 );
|
||||
try {
|
||||
try
|
||||
{
|
||||
return new Object[] { m_fileSystem.isReadOnly( path ) };
|
||||
} catch( FileSystemException e ) {
|
||||
}
|
||||
catch( FileSystemException e )
|
||||
{
|
||||
return new Object[] { false };
|
||||
}
|
||||
}
|
||||
@ -167,11 +178,14 @@ public class FSAPI implements ILuaAPI
|
||||
{
|
||||
// makeDir
|
||||
String path = getString( args, 0 );
|
||||
try {
|
||||
try
|
||||
{
|
||||
m_env.addTrackingChange( TrackingField.FS_OPS );
|
||||
m_fileSystem.makeDir( path );
|
||||
return null;
|
||||
} catch( FileSystemException e ) {
|
||||
}
|
||||
catch( FileSystemException e )
|
||||
{
|
||||
throw new LuaException( e.getMessage() );
|
||||
}
|
||||
}
|
||||
@ -180,11 +194,14 @@ public class FSAPI implements ILuaAPI
|
||||
// move
|
||||
String path = getString( args, 0 );
|
||||
String dest = getString( args, 1 );
|
||||
try {
|
||||
try
|
||||
{
|
||||
m_env.addTrackingChange( TrackingField.FS_OPS );
|
||||
m_fileSystem.move( path, dest );
|
||||
return null;
|
||||
} catch( FileSystemException e ) {
|
||||
}
|
||||
catch( FileSystemException e )
|
||||
{
|
||||
throw new LuaException( e.getMessage() );
|
||||
}
|
||||
}
|
||||
@ -193,11 +210,14 @@ public class FSAPI implements ILuaAPI
|
||||
// copy
|
||||
String path = getString( args, 0 );
|
||||
String dest = getString( args, 1 );
|
||||
try {
|
||||
try
|
||||
{
|
||||
m_env.addTrackingChange( TrackingField.FS_OPS );
|
||||
m_fileSystem.copy( path, dest );
|
||||
return null;
|
||||
} catch( FileSystemException e ) {
|
||||
}
|
||||
catch( FileSystemException e )
|
||||
{
|
||||
throw new LuaException( e.getMessage() );
|
||||
}
|
||||
}
|
||||
@ -205,11 +225,14 @@ public class FSAPI implements ILuaAPI
|
||||
{
|
||||
// delete
|
||||
String path = getString( args, 0 );
|
||||
try {
|
||||
try
|
||||
{
|
||||
m_env.addTrackingChange( TrackingField.FS_OPS );
|
||||
m_fileSystem.delete( path );
|
||||
return null;
|
||||
} catch( FileSystemException e ) {
|
||||
}
|
||||
catch( FileSystemException e )
|
||||
{
|
||||
throw new LuaException( e.getMessage() );
|
||||
}
|
||||
}
|
||||
@ -219,7 +242,8 @@ public class FSAPI implements ILuaAPI
|
||||
String path = getString( args, 0 );
|
||||
String mode = getString( args, 1 );
|
||||
m_env.addTrackingChange( TrackingField.FS_OPS );
|
||||
try {
|
||||
try
|
||||
{
|
||||
switch( mode )
|
||||
{
|
||||
case "r":
|
||||
@ -261,7 +285,9 @@ public class FSAPI implements ILuaAPI
|
||||
default:
|
||||
throw new LuaException( "Unsupported mode" );
|
||||
}
|
||||
} catch( FileSystemException e ) {
|
||||
}
|
||||
catch( FileSystemException e )
|
||||
{
|
||||
return new Object[] { null, e.getMessage() };
|
||||
}
|
||||
}
|
||||
@ -269,13 +295,16 @@ public class FSAPI implements ILuaAPI
|
||||
{
|
||||
// getDrive
|
||||
String path = getString( args, 0 );
|
||||
try {
|
||||
try
|
||||
{
|
||||
if( !m_fileSystem.exists( path ) )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Object[] { m_fileSystem.getMountLabel( path ) };
|
||||
} catch( FileSystemException e ) {
|
||||
}
|
||||
catch( FileSystemException e )
|
||||
{
|
||||
throw new LuaException( e.getMessage() );
|
||||
}
|
||||
}
|
||||
@ -283,14 +312,17 @@ public class FSAPI implements ILuaAPI
|
||||
{
|
||||
// getFreeSpace
|
||||
String path = getString( args, 0 );
|
||||
try {
|
||||
try
|
||||
{
|
||||
long freeSpace = m_fileSystem.getFreeSpace( path );
|
||||
if( freeSpace >= 0 )
|
||||
{
|
||||
return new Object[] { freeSpace };
|
||||
}
|
||||
return new Object[] { "unlimited" };
|
||||
} catch( FileSystemException e ) {
|
||||
}
|
||||
catch( FileSystemException e )
|
||||
{
|
||||
throw new LuaException( e.getMessage() );
|
||||
}
|
||||
}
|
||||
@ -298,15 +330,19 @@ public class FSAPI implements ILuaAPI
|
||||
{
|
||||
// find
|
||||
String path = getString( args, 0 );
|
||||
try {
|
||||
try
|
||||
{
|
||||
m_env.addTrackingChange( TrackingField.FS_OPS );
|
||||
String[] results = m_fileSystem.find( path );
|
||||
Map<Object, Object> table = new HashMap<>();
|
||||
for(int i=0; i<results.length; ++i ) {
|
||||
for( int i = 0; i < results.length; i++ )
|
||||
{
|
||||
table.put( i + 1, results[i] );
|
||||
}
|
||||
return new Object[] { table };
|
||||
} catch( FileSystemException e ) {
|
||||
}
|
||||
catch( FileSystemException e )
|
||||
{
|
||||
throw new LuaException( e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
@ -23,27 +23,39 @@ public interface IAPIEnvironment extends IComputerOwned
|
||||
|
||||
@Override
|
||||
Computer getComputer();
|
||||
|
||||
int getComputerID();
|
||||
|
||||
IComputerEnvironment getComputerEnvironment();
|
||||
|
||||
Terminal getTerminal();
|
||||
|
||||
FileSystem getFileSystem();
|
||||
|
||||
void shutdown();
|
||||
|
||||
void reboot();
|
||||
|
||||
void queueEvent( String event, Object[] args );
|
||||
|
||||
void setOutput( int side, int output );
|
||||
|
||||
int getOutput( int side );
|
||||
|
||||
int getInput( int side );
|
||||
|
||||
void setBundledOutput( int side, int output );
|
||||
|
||||
int getBundledOutput( int side );
|
||||
|
||||
int getBundledInput( int side );
|
||||
|
||||
void setPeripheralChangeListener( IPeripheralChangeListener listener );
|
||||
|
||||
IPeripheral getPeripheral( int side );
|
||||
|
||||
String getLabel();
|
||||
|
||||
void setLabel( String label );
|
||||
|
||||
void addTrackingChange( TrackingField field, long change );
|
||||
|
@ -55,11 +55,16 @@ public class OSAPI implements ILuaAPI
|
||||
{
|
||||
double t = m_day * 24.0 + m_time;
|
||||
double ot = m_day * 24.0 + m_time;
|
||||
if( t < ot ) {
|
||||
if( t < ot )
|
||||
{
|
||||
return -1;
|
||||
} else if( t > ot ) {
|
||||
}
|
||||
else if( t > ot )
|
||||
{
|
||||
return 1;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -207,7 +212,7 @@ public class OSAPI implements ILuaAPI
|
||||
GregorianCalendar g = (c instanceof GregorianCalendar) ? (GregorianCalendar) c : new GregorianCalendar();
|
||||
int year = c.get( Calendar.YEAR );
|
||||
int day = 0;
|
||||
for( int y=1970; y<year; ++y )
|
||||
for( int y = 1970; y < year; y++ )
|
||||
{
|
||||
day += g.isLeapYear( y ) ? 366 : 365;
|
||||
}
|
||||
|
@ -51,8 +51,10 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
assert (m_methods != null);
|
||||
|
||||
m_methodMap = new HashMap<>();
|
||||
for(int i=0; i<m_methods.length; ++i ) {
|
||||
if( m_methods[i] != null ) {
|
||||
for( int i = 0; i < m_methods.length; i++ )
|
||||
{
|
||||
if( m_methods[i] != null )
|
||||
{
|
||||
m_methodMap.put( m_methods[i], i );
|
||||
}
|
||||
}
|
||||
@ -235,7 +237,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
m_environment.setPeripheralChangeListener( this );
|
||||
|
||||
m_peripherals = new PeripheralWrapper[6];
|
||||
for(int i=0; i<6; ++i)
|
||||
for( int i = 0; i < 6; i++ )
|
||||
{
|
||||
m_peripherals[i] = null;
|
||||
}
|
||||
@ -254,16 +256,21 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
{
|
||||
// Queue a detachment
|
||||
final PeripheralWrapper wrapper = m_peripherals[side];
|
||||
ComputerThread.queueTask(new ITask() {
|
||||
ComputerThread.queueTask( new ITask()
|
||||
{
|
||||
@Override
|
||||
public Computer getOwner() {
|
||||
public Computer getOwner()
|
||||
{
|
||||
return m_environment.getComputer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
synchronized (m_peripherals) {
|
||||
if (wrapper.isAttached()) {
|
||||
public void execute()
|
||||
{
|
||||
synchronized( m_peripherals )
|
||||
{
|
||||
if( wrapper.isAttached() )
|
||||
{
|
||||
wrapper.detach();
|
||||
}
|
||||
}
|
||||
@ -288,14 +295,17 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
{
|
||||
// Queue an attachment
|
||||
final PeripheralWrapper wrapper = m_peripherals[side];
|
||||
ComputerThread.queueTask( new ITask() {
|
||||
ComputerThread.queueTask( new ITask()
|
||||
{
|
||||
@Override
|
||||
public Computer getOwner() {
|
||||
public Computer getOwner()
|
||||
{
|
||||
return m_environment.getComputer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
public void execute()
|
||||
{
|
||||
synchronized( m_peripherals )
|
||||
{
|
||||
if( m_running && !wrapper.isAttached() )
|
||||
@ -328,7 +338,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
synchronized( m_peripherals )
|
||||
{
|
||||
m_running = true;
|
||||
for( int i=0; i<6; ++i )
|
||||
for( int i = 0; i < 6; i++ )
|
||||
{
|
||||
PeripheralWrapper wrapper = m_peripherals[i];
|
||||
if( wrapper != null && !wrapper.isAttached() )
|
||||
@ -345,7 +355,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
synchronized( m_peripherals )
|
||||
{
|
||||
m_running = false;
|
||||
for( int i=0; i<6; ++i )
|
||||
for( int i = 0; i < 6; i++ )
|
||||
{
|
||||
PeripheralWrapper wrapper = m_peripherals[i];
|
||||
if( wrapper != null && wrapper.isAttached() )
|
||||
@ -432,7 +442,8 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
if( methods != null )
|
||||
{
|
||||
Map<Object, Object> table = new HashMap<>();
|
||||
for(int i=0; i<methods.length; ++i ) {
|
||||
for( int i = 0; i < methods.length; i++ )
|
||||
{
|
||||
table.put( i + 1, methods[i] );
|
||||
}
|
||||
return new Object[] { table };
|
||||
@ -472,7 +483,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange
|
||||
private int parseSide( Object[] args ) throws LuaException
|
||||
{
|
||||
String side = getString( args, 0 );
|
||||
for( int n=0; n<Computer.s_sideNames.length; ++n )
|
||||
for( int n = 0; n < Computer.s_sideNames.length; n++ )
|
||||
{
|
||||
if( side.equals( Computer.s_sideNames[n] ) )
|
||||
{
|
||||
|
@ -65,7 +65,7 @@ public class RedstoneAPI implements ILuaAPI
|
||||
{
|
||||
// getSides
|
||||
Map<Object, Object> table = new HashMap<>();
|
||||
for(int i=0; i< Computer.s_sideNames.length; ++i )
|
||||
for( int i = 0; i < Computer.s_sideNames.length; i++ )
|
||||
{
|
||||
table.put( i + 1, Computer.s_sideNames[i] );
|
||||
}
|
||||
@ -156,7 +156,7 @@ public class RedstoneAPI implements ILuaAPI
|
||||
private int parseSide( Object[] args ) throws LuaException
|
||||
{
|
||||
String side = getString( args, 0 );
|
||||
for( int n=0; n<Computer.s_sideNames.length; ++n )
|
||||
for( int n = 0; n < Computer.s_sideNames.length; n++ )
|
||||
{
|
||||
if( side.equals( Computer.s_sideNames[n] ) )
|
||||
{
|
||||
|
@ -109,9 +109,12 @@ public class TermAPI implements ILuaAPI
|
||||
{
|
||||
// write
|
||||
String text;
|
||||
if( args.length > 0 && args[0] != null ) {
|
||||
if( args.length > 0 && args[0] != null )
|
||||
{
|
||||
text = args[0].toString();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
text = "";
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,8 @@ import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.filesystem.IFileSystem;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.filesystem.IWritableMount;
|
||||
import dan200.computercraft.api.lua.*;
|
||||
import dan200.computercraft.api.lua.ILuaAPI;
|
||||
import dan200.computercraft.api.lua.*;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.core.apis.*;
|
||||
import dan200.computercraft.core.filesystem.FileSystem;
|
||||
@ -337,7 +337,7 @@ public class Computer
|
||||
m_inputChanged = false;
|
||||
|
||||
m_peripherals = new IPeripheral[6];
|
||||
for( int i=0; i<6; ++i )
|
||||
for( int i = 0; i < 6; i++ )
|
||||
{
|
||||
m_peripherals[i] = null;
|
||||
}
|
||||
@ -480,7 +480,7 @@ public class Computer
|
||||
if( m_internalOutputChanged )
|
||||
{
|
||||
boolean changed = false;
|
||||
for( int i=0; i<6; ++i )
|
||||
for( int i = 0; i < 6; i++ )
|
||||
{
|
||||
if( m_externalOutput[i] != m_internalOutput[i] )
|
||||
{
|
||||
@ -519,7 +519,8 @@ public class Computer
|
||||
|
||||
public boolean pollAndResetChanged()
|
||||
{
|
||||
synchronized(this) {
|
||||
synchronized( this )
|
||||
{
|
||||
boolean changed = m_externalOutputChanged;
|
||||
m_externalOutputChanged = false;
|
||||
return changed;
|
||||
@ -756,9 +757,12 @@ public class Computer
|
||||
if( biosStream != null )
|
||||
{
|
||||
machine.loadBios( biosStream );
|
||||
try {
|
||||
try
|
||||
{
|
||||
biosStream.close();
|
||||
} catch( IOException e ) {
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
// meh
|
||||
}
|
||||
|
||||
@ -804,7 +808,8 @@ public class Computer
|
||||
|
||||
// Turn the computercraft on
|
||||
final Computer computer = this;
|
||||
ComputerThread.queueTask( new ITask() {
|
||||
ComputerThread.queueTask( new ITask()
|
||||
{
|
||||
@Override
|
||||
public Computer getOwner()
|
||||
{
|
||||
@ -882,7 +887,8 @@ public class Computer
|
||||
|
||||
// Turn the computercraft off
|
||||
final Computer computer = this;
|
||||
ComputerThread.queueTask( new ITask() {
|
||||
ComputerThread.queueTask( new ITask()
|
||||
{
|
||||
@Override
|
||||
public Computer getOwner()
|
||||
{
|
||||
@ -932,7 +938,7 @@ public class Computer
|
||||
// Reset redstone output
|
||||
synchronized( m_internalOutput )
|
||||
{
|
||||
for( int i=0; i<6; ++i )
|
||||
for( int i = 0; i < 6; i++ )
|
||||
{
|
||||
m_internalOutput[i] = 0;
|
||||
m_internalBundledOutput[i] = 0;
|
||||
@ -962,7 +968,8 @@ public class Computer
|
||||
}
|
||||
|
||||
final Computer computer = this;
|
||||
ITask task = new ITask() {
|
||||
ITask task = new ITask()
|
||||
{
|
||||
@Override
|
||||
public Computer getOwner()
|
||||
{
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
package dan200.computercraft.core.computer;
|
||||
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.filesystem.IWritableMount;
|
||||
|
||||
@ -13,13 +14,20 @@ import java.io.InputStream;
|
||||
public interface IComputerEnvironment
|
||||
{
|
||||
int getDay();
|
||||
|
||||
double getTimeOfDay();
|
||||
|
||||
boolean isColour();
|
||||
|
||||
long getComputerSpaceLimit();
|
||||
|
||||
String getHostString();
|
||||
|
||||
int assignNewID();
|
||||
|
||||
IWritableMount createSaveDirMount( String subPath, long capacity );
|
||||
|
||||
IMount createResourceMount( String domain, String subPath );
|
||||
|
||||
InputStream createResourceFile( String domain, String subPath );
|
||||
}
|
||||
|
@ -9,5 +9,6 @@ package dan200.computercraft.core.computer;
|
||||
public interface ITask
|
||||
{
|
||||
Computer getOwner();
|
||||
|
||||
void execute();
|
||||
}
|
||||
|
@ -344,7 +344,8 @@ public class FileSystem
|
||||
{
|
||||
if( mount == null ) throw new NullPointerException();
|
||||
location = sanitizePath( location );
|
||||
if( location.contains( ".." ) ) {
|
||||
if( location.contains( ".." ) )
|
||||
{
|
||||
throw new FileSystemException( "Cannot mount below the root" );
|
||||
}
|
||||
mount( new MountWrapper( label, location, mount ) );
|
||||
@ -382,11 +383,16 @@ public class FileSystem
|
||||
path = sanitizePath( path, true );
|
||||
childPath = sanitizePath( childPath, true );
|
||||
|
||||
if( path.isEmpty() ) {
|
||||
if( path.isEmpty() )
|
||||
{
|
||||
return childPath;
|
||||
} else if( childPath.isEmpty() ) {
|
||||
}
|
||||
else if( childPath.isEmpty() )
|
||||
{
|
||||
return path;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return sanitizePath( path + '/' + childPath, true );
|
||||
}
|
||||
}
|
||||
@ -394,14 +400,18 @@ public class FileSystem
|
||||
public static String getDirectory( String path )
|
||||
{
|
||||
path = sanitizePath( path, true );
|
||||
if( path.isEmpty() ) {
|
||||
if( path.isEmpty() )
|
||||
{
|
||||
return "..";
|
||||
}
|
||||
|
||||
int lastSlash = path.lastIndexOf( '/' );
|
||||
if( lastSlash >= 0 ) {
|
||||
if( lastSlash >= 0 )
|
||||
{
|
||||
return path.substring( 0, lastSlash );
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@ -409,14 +419,18 @@ public class FileSystem
|
||||
public static String getName( String path )
|
||||
{
|
||||
path = sanitizePath( path, true );
|
||||
if( path.isEmpty() ) {
|
||||
if( path.isEmpty() )
|
||||
{
|
||||
return "root";
|
||||
}
|
||||
|
||||
int lastSlash = path.lastIndexOf( '/' );
|
||||
if( lastSlash >= 0 ) {
|
||||
if( lastSlash >= 0 )
|
||||
{
|
||||
return path.substring( lastSlash + 1 );
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
||||
@ -546,16 +560,20 @@ public class FileSystem
|
||||
{
|
||||
sourcePath = sanitizePath( sourcePath );
|
||||
destPath = sanitizePath( destPath );
|
||||
if( isReadOnly( sourcePath ) || isReadOnly( destPath ) ) {
|
||||
if( isReadOnly( sourcePath ) || isReadOnly( destPath ) )
|
||||
{
|
||||
throw new FileSystemException( "Access denied" );
|
||||
}
|
||||
if( !exists( sourcePath ) ) {
|
||||
if( !exists( sourcePath ) )
|
||||
{
|
||||
throw new FileSystemException( "No such file" );
|
||||
}
|
||||
if( exists( destPath ) ) {
|
||||
if( exists( destPath ) )
|
||||
{
|
||||
throw new FileSystemException( "File exists" );
|
||||
}
|
||||
if( contains( sourcePath, destPath ) ) {
|
||||
if( contains( sourcePath, destPath ) )
|
||||
{
|
||||
throw new FileSystemException( "Can't move a directory inside itself" );
|
||||
}
|
||||
copy( sourcePath, destPath );
|
||||
@ -566,16 +584,20 @@ public class FileSystem
|
||||
{
|
||||
sourcePath = sanitizePath( sourcePath );
|
||||
destPath = sanitizePath( destPath );
|
||||
if( isReadOnly( destPath ) ) {
|
||||
if( isReadOnly( destPath ) )
|
||||
{
|
||||
throw new FileSystemException( "/" + destPath + ": Access denied" );
|
||||
}
|
||||
if( !exists( sourcePath ) ) {
|
||||
if( !exists( sourcePath ) )
|
||||
{
|
||||
throw new FileSystemException( "/" + sourcePath + ": No such file" );
|
||||
}
|
||||
if( exists( destPath ) ) {
|
||||
if( exists( destPath ) )
|
||||
{
|
||||
throw new FileSystemException( "/" + destPath + ": File exists" );
|
||||
}
|
||||
if( contains( sourcePath, destPath ) ) {
|
||||
if( contains( sourcePath, destPath ) )
|
||||
{
|
||||
throw new FileSystemException( "/" + sourcePath + ": Can't copy a directory inside itself" );
|
||||
}
|
||||
copyRecursive( sourcePath, getMount( sourcePath ), destPath, getMount( destPath ) );
|
||||
@ -707,9 +729,11 @@ public class FileSystem
|
||||
while( it.hasNext() )
|
||||
{
|
||||
MountWrapper mount = it.next();
|
||||
if( contains( mount.getLocation(), path ) ) {
|
||||
if( contains( mount.getLocation(), path ) )
|
||||
{
|
||||
int len = toLocal( path, mount.getLocation() ).length();
|
||||
if( match == null || len < matchLength ) {
|
||||
if( match == null || len < matchLength )
|
||||
{
|
||||
match = mount;
|
||||
matchLength = len;
|
||||
}
|
||||
@ -733,6 +757,7 @@ public class FileSystem
|
||||
}
|
||||
|
||||
private static final Pattern threeDotsPattern = Pattern.compile( "^\\.{3,}$" );
|
||||
|
||||
private static String sanitizePath( String path, boolean allowWildcards )
|
||||
{
|
||||
// Allow windowsy slashes
|
||||
@ -744,7 +769,8 @@ public class FileSystem
|
||||
};
|
||||
|
||||
StringBuilder cleanName = new StringBuilder();
|
||||
for( int i = 0; i < path.length(); i++ ) {
|
||||
for( int i = 0; i < path.length(); i++ )
|
||||
{
|
||||
char c = path.charAt( i );
|
||||
if( c >= 32 && Arrays.binarySearch( specialChars, c ) < 0 && (allowWildcards || c != '*') )
|
||||
{
|
||||
@ -799,10 +825,12 @@ public class FileSystem
|
||||
// Recombine the output parts into a new string
|
||||
StringBuilder result = new StringBuilder( "" );
|
||||
Iterator<String> it = outputParts.iterator();
|
||||
while( it.hasNext() ) {
|
||||
while( it.hasNext() )
|
||||
{
|
||||
String part = it.next();
|
||||
result.append( part );
|
||||
if( it.hasNext() ) {
|
||||
if( it.hasNext() )
|
||||
{
|
||||
result.append( '/' );
|
||||
}
|
||||
}
|
||||
@ -844,9 +872,12 @@ public class FileSystem
|
||||
|
||||
assert (contains( location, path ));
|
||||
String local = path.substring( location.length() );
|
||||
if( local.startsWith("/") ) {
|
||||
if( local.startsWith( "/" ) )
|
||||
{
|
||||
return local.substring( 1 );
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return local;
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,12 @@
|
||||
|
||||
package dan200.computercraft.core.filesystem;
|
||||
|
||||
public class FileSystemException extends Exception {
|
||||
public class FileSystemException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = -2500631644868104029L;
|
||||
|
||||
FileSystemException( String s ) {
|
||||
FileSystemException( String s )
|
||||
{
|
||||
super( s );
|
||||
}
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ public class CobaltLuaMachine implements ILuaMachine
|
||||
{
|
||||
LuaTable table = new LuaTable();
|
||||
String[] methods = object.getMethodNames();
|
||||
for( int i = 0; i < methods.length; ++i )
|
||||
for( int i = 0; i < methods.length; i++ )
|
||||
{
|
||||
if( methods[i] != null )
|
||||
{
|
||||
@ -546,7 +546,7 @@ public class CobaltLuaMachine implements ILuaMachine
|
||||
}
|
||||
|
||||
LuaValue[] values = new LuaValue[objects.length];
|
||||
for( int i = 0; i < values.length; ++i )
|
||||
for( int i = 0; i < values.length; i++ )
|
||||
{
|
||||
Object object = objects[i];
|
||||
values[i] = toValue( object, null );
|
||||
@ -633,7 +633,7 @@ public class CobaltLuaMachine implements ILuaMachine
|
||||
{
|
||||
int count = values.count();
|
||||
Object[] objects = new Object[count - startIdx + 1];
|
||||
for( int n = startIdx; n <= count; ++n )
|
||||
for( int n = startIdx; n <= count; n++ )
|
||||
{
|
||||
int i = n - startIdx;
|
||||
LuaValue value = values.arg( n );
|
||||
@ -700,7 +700,8 @@ public class CobaltLuaMachine implements ILuaMachine
|
||||
try
|
||||
{
|
||||
s = OperationHelper.call( state, func );
|
||||
} catch (LuaError e)
|
||||
}
|
||||
catch( LuaError e )
|
||||
{
|
||||
throw new IOException( e );
|
||||
}
|
||||
@ -713,7 +714,8 @@ public class CobaltLuaMachine implements ILuaMachine
|
||||
try
|
||||
{
|
||||
ls = s.strvalue();
|
||||
} catch (LuaError e)
|
||||
}
|
||||
catch( LuaError e )
|
||||
{
|
||||
throw new IOException( e );
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
package dan200.computercraft.core.lua;
|
||||
|
||||
import dan200.computercraft.api.lua.ILuaAPI;
|
||||
|
||||
import java.io.InputStream;
|
||||
@ -15,11 +16,15 @@ public interface ILuaMachine
|
||||
void addAPI( ILuaAPI api );
|
||||
|
||||
void loadBios( InputStream bios );
|
||||
|
||||
void handleEvent( String eventName, Object[] arguments );
|
||||
|
||||
void softAbort( String abortMessage );
|
||||
|
||||
void hardAbort( String abortMessage );
|
||||
|
||||
boolean saveState( OutputStream output );
|
||||
|
||||
boolean restoreState( InputStream input );
|
||||
|
||||
boolean isFinished();
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
package dan200.computercraft.core.terminal;
|
||||
|
||||
import dan200.computercraft.shared.util.Palette;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@ -40,7 +41,7 @@ public class Terminal
|
||||
m_text = new TextBuffer[m_height];
|
||||
m_textColour = new TextBuffer[m_height];
|
||||
m_backgroundColour = new TextBuffer[m_height];
|
||||
for( int i=0; i<m_height; ++i )
|
||||
for( int i = 0; i < m_height; i++ )
|
||||
{
|
||||
m_text[i] = new TextBuffer( ' ', m_width );
|
||||
m_textColour[i] = new TextBuffer( base16.charAt( m_cursorColour ), m_width );
|
||||
@ -68,11 +69,13 @@ public class Terminal
|
||||
m_palette.resetColours();
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
public int getWidth()
|
||||
{
|
||||
return m_width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
public int getHeight()
|
||||
{
|
||||
return m_height;
|
||||
}
|
||||
|
||||
@ -95,7 +98,7 @@ public class Terminal
|
||||
m_text = new TextBuffer[m_height];
|
||||
m_textColour = new TextBuffer[m_height];
|
||||
m_backgroundColour = new TextBuffer[m_height];
|
||||
for( int i=0; i<m_height; ++i )
|
||||
for( int i = 0; i < m_height; i++ )
|
||||
{
|
||||
if( i >= oldHeight )
|
||||
{
|
||||
@ -222,7 +225,7 @@ public class Terminal
|
||||
TextBuffer[] newText = new TextBuffer[m_height];
|
||||
TextBuffer[] newTextColour = new TextBuffer[m_height];
|
||||
TextBuffer[] newBackgroundColour = new TextBuffer[m_height];
|
||||
for( int y = 0; y < m_height; ++y )
|
||||
for( int y = 0; y < m_height; y++ )
|
||||
{
|
||||
int oldY = y + yDiff;
|
||||
if( oldY >= 0 && oldY < m_height )
|
||||
@ -247,7 +250,7 @@ public class Terminal
|
||||
|
||||
public synchronized void clear()
|
||||
{
|
||||
for( int y = 0; y < m_height; ++y )
|
||||
for( int y = 0; y < m_height; y++ )
|
||||
{
|
||||
m_text[y].fill( ' ' );
|
||||
m_textColour[y].fill( base16.charAt( m_cursorColour ) );
|
||||
@ -325,7 +328,7 @@ public class Terminal
|
||||
nbttagcompound.setBoolean( "term_cursorBlink", m_cursorBlink );
|
||||
nbttagcompound.setInteger( "term_textColour", m_cursorColour );
|
||||
nbttagcompound.setInteger( "term_bgColour", m_cursorBackgroundColour );
|
||||
for( int n=0; n<m_height; ++n )
|
||||
for( int n = 0; n < m_height; n++ )
|
||||
{
|
||||
nbttagcompound.setString( "term_text_" + n, m_text[n].toString() );
|
||||
nbttagcompound.setString( "term_textColour_" + n, m_textColour[n].toString() );
|
||||
@ -346,7 +349,7 @@ public class Terminal
|
||||
m_cursorColour = nbttagcompound.getInteger( "term_textColour" );
|
||||
m_cursorBackgroundColour = nbttagcompound.getInteger( "term_bgColour" );
|
||||
|
||||
for( int n=0; n<m_height; ++n )
|
||||
for( int n = 0; n < m_height; n++ )
|
||||
{
|
||||
m_text[n].fill( ' ' );
|
||||
if( nbttagcompound.hasKey( "term_text_" + n ) )
|
||||
|
@ -13,7 +13,7 @@ public class TextBuffer
|
||||
public TextBuffer( char c, int length )
|
||||
{
|
||||
m_text = new char[length];
|
||||
for( int i = 0; i < length; ++i )
|
||||
for( int i = 0; i < length; i++ )
|
||||
{
|
||||
m_text[i] = c;
|
||||
}
|
||||
@ -28,9 +28,9 @@ public class TextBuffer
|
||||
{
|
||||
int textLength = text.length();
|
||||
m_text = new char[textLength * repetitions];
|
||||
for( int i = 0; i < repetitions; ++i )
|
||||
for( int i = 0; i < repetitions; i++ )
|
||||
{
|
||||
for( int j = 0; j < textLength; ++j )
|
||||
for( int j = 0; j < textLength; j++ )
|
||||
{
|
||||
m_text[j + i * textLength] = text.charAt( j );
|
||||
}
|
||||
@ -46,9 +46,9 @@ public class TextBuffer
|
||||
{
|
||||
int textLength = text.length();
|
||||
m_text = new char[textLength * repetitions];
|
||||
for( int i = 0; i < repetitions; ++i )
|
||||
for( int i = 0; i < repetitions; i++ )
|
||||
{
|
||||
for( int j = 0; j < textLength; ++j )
|
||||
for( int j = 0; j < textLength; j++ )
|
||||
{
|
||||
m_text[j + i * textLength] = text.charAt( j );
|
||||
}
|
||||
@ -94,7 +94,7 @@ public class TextBuffer
|
||||
start = Math.max( start, 0 );
|
||||
end = Math.min( end, pos + text.length() );
|
||||
end = Math.min( end, m_text.length );
|
||||
for( int i=start; i<end; ++i )
|
||||
for( int i = start; i < end; i++ )
|
||||
{
|
||||
m_text[i] = text.charAt( i - pos );
|
||||
}
|
||||
@ -116,7 +116,7 @@ public class TextBuffer
|
||||
start = Math.max( start, 0 );
|
||||
end = Math.min( end, pos + text.length() );
|
||||
end = Math.min( end, m_text.length );
|
||||
for( int i=start; i<end; ++i )
|
||||
for( int i = start; i < end; i++ )
|
||||
{
|
||||
m_text[i] = text.charAt( i - pos );
|
||||
}
|
||||
@ -136,7 +136,7 @@ public class TextBuffer
|
||||
{
|
||||
start = Math.max( start, 0 );
|
||||
end = Math.min( end, m_text.length );
|
||||
for( int i=start; i<end; ++i )
|
||||
for( int i = start; i < end; i++ )
|
||||
{
|
||||
m_text[i] = c;
|
||||
}
|
||||
@ -159,7 +159,7 @@ public class TextBuffer
|
||||
end = Math.min( end, m_text.length );
|
||||
|
||||
int textLength = text.length();
|
||||
for( int i=start; i<end; ++i )
|
||||
for( int i = start; i < end; i++ )
|
||||
{
|
||||
m_text[i] = text.charAt( (i - pos) % textLength );
|
||||
}
|
||||
@ -182,7 +182,7 @@ public class TextBuffer
|
||||
end = Math.min( end, m_text.length );
|
||||
|
||||
int textLength = text.length();
|
||||
for( int i=start; i<end; ++i )
|
||||
for( int i = start; i < end; i++ )
|
||||
{
|
||||
m_text[i] = text.charAt( (i - pos) % textLength );
|
||||
}
|
||||
|
@ -6,11 +6,9 @@
|
||||
|
||||
package dan200.computercraft.server.proxy;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.computer.blocks.TileComputer;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.IComputer;
|
||||
import dan200.computercraft.shared.network.ComputerCraftPacket;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.TileDiskDrive;
|
||||
import dan200.computercraft.shared.peripheral.printer.TilePrinter;
|
||||
import dan200.computercraft.shared.proxy.ComputerCraftProxyCommon;
|
||||
@ -18,8 +16,6 @@ import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
|
@ -8,8 +8,8 @@ package dan200.computercraft.shared.common;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@ -40,7 +40,9 @@ public abstract class BlockGeneric extends Block implements
|
||||
}
|
||||
|
||||
protected abstract IBlockState getDefaultBlockState( int damage, EnumFacing placedSide );
|
||||
|
||||
protected abstract TileGeneric createTile( IBlockState state );
|
||||
|
||||
protected abstract TileGeneric createTile( int damage );
|
||||
|
||||
@Override
|
||||
|
@ -51,7 +51,7 @@ public class ColourableRecipe extends IForgeRegistryEntry.Impl<IRecipe> implemen
|
||||
|
||||
ColourTracker tracker = new ColourTracker();
|
||||
|
||||
for( int i = 0; i < inv.getSizeInventory(); ++i )
|
||||
for( int i = 0; i < inv.getSizeInventory(); i++ )
|
||||
{
|
||||
ItemStack stack = inv.getStackInSlot( i );
|
||||
|
||||
@ -103,7 +103,7 @@ public class ColourableRecipe extends IForgeRegistryEntry.Impl<IRecipe> implemen
|
||||
public NonNullList<ItemStack> getRemainingItems( @Nonnull InventoryCrafting inventoryCrafting )
|
||||
{
|
||||
NonNullList<ItemStack> results = NonNullList.withSize( inventoryCrafting.getSizeInventory(), ItemStack.EMPTY );
|
||||
for( int i = 0; i < results.size(); ++i )
|
||||
for( int i = 0; i < results.size(); i++ )
|
||||
{
|
||||
ItemStack stack = inventoryCrafting.getStackInSlot( i );
|
||||
results.set( i, ForgeHooks.getContainerItem( stack ) );
|
||||
|
@ -8,8 +8,8 @@ package dan200.computercraft.shared.common;
|
||||
|
||||
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -11,5 +11,6 @@ import net.minecraft.util.EnumFacing;
|
||||
public interface IDirectionalTile
|
||||
{
|
||||
EnumFacing getDirection();
|
||||
|
||||
void setDirection( EnumFacing dir );
|
||||
}
|
||||
|
@ -11,5 +11,6 @@ import dan200.computercraft.core.terminal.Terminal;
|
||||
public interface ITerminal
|
||||
{
|
||||
Terminal getTerminal();
|
||||
|
||||
boolean isColour();
|
||||
}
|
||||
|
@ -17,10 +17,10 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -225,11 +225,11 @@ public class CommandAPI implements ILuaAPI
|
||||
}
|
||||
int i = 1;
|
||||
Map<Object, Object> results = new HashMap<>();
|
||||
for( int y=min.getY(); y<= max.getY(); ++y )
|
||||
for( int y = min.getY(); y <= max.getY(); y++ )
|
||||
{
|
||||
for( int z = min.getZ(); z <= max.getZ(); ++z )
|
||||
for( int z = min.getZ(); z <= max.getZ(); z++ )
|
||||
{
|
||||
for( int x = min.getX(); x <= max.getX(); ++x )
|
||||
for( int x = min.getX(); x <= max.getX(); x++ )
|
||||
{
|
||||
BlockPos pos = new BlockPos( x, y, z );
|
||||
results.put( i++, getBlockInfo( world, pos ) );
|
||||
|
@ -18,8 +18,8 @@ import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@ -150,9 +150,12 @@ public class BlockComputer extends BlockComputerBase
|
||||
@Override
|
||||
public ComputerFamily getFamily( IBlockState state )
|
||||
{
|
||||
if( state.getValue( Properties.ADVANCED ) ) {
|
||||
if( state.getValue( Properties.ADVANCED ) )
|
||||
{
|
||||
return ComputerFamily.Advanced;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return ComputerFamily.Normal;
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@ -40,8 +40,11 @@ public abstract class BlockComputerBase extends BlockDirectional
|
||||
}
|
||||
|
||||
protected abstract IBlockState getDefaultBlockState( ComputerFamily family, EnumFacing placedSide );
|
||||
|
||||
protected abstract ComputerFamily getFamily( int damage );
|
||||
|
||||
protected abstract ComputerFamily getFamily( IBlockState state );
|
||||
|
||||
protected abstract TileComputerBase createTile( ComputerFamily family );
|
||||
|
||||
@Override
|
||||
|
@ -13,8 +13,12 @@ import dan200.computercraft.shared.computer.core.IComputer;
|
||||
public interface IComputerTile extends ITerminalTile
|
||||
{
|
||||
void setComputerID( int id );
|
||||
|
||||
void setLabel( String label );
|
||||
|
||||
IComputer getComputer();
|
||||
|
||||
IComputer createComputer();
|
||||
|
||||
ComputerFamily getFamily();
|
||||
}
|
||||
|
@ -16,9 +16,12 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.CommandBlockBaseLogic;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.util.text.*;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -11,15 +11,22 @@ import dan200.computercraft.shared.common.ITerminal;
|
||||
public interface IComputer extends ITerminal
|
||||
{
|
||||
int getInstanceID();
|
||||
|
||||
int getID();
|
||||
|
||||
String getLabel();
|
||||
|
||||
boolean isOn();
|
||||
|
||||
boolean isCursorDisplayed();
|
||||
|
||||
void turnOn();
|
||||
|
||||
void shutdown();
|
||||
|
||||
void reboot();
|
||||
|
||||
void queueEvent( String event );
|
||||
|
||||
void queueEvent( String event, Object[] arguments );
|
||||
}
|
||||
|
@ -65,7 +65,8 @@ public class ServerComputer extends ServerTerminal
|
||||
m_ticksSincePing = 0;
|
||||
}
|
||||
|
||||
public ComputerFamily getFamily(){
|
||||
public ComputerFamily getFamily()
|
||||
{
|
||||
return m_family;
|
||||
}
|
||||
|
||||
@ -145,7 +146,8 @@ public class ServerComputer extends ServerTerminal
|
||||
m_changed = true;
|
||||
}
|
||||
|
||||
private ComputerCraftPacket createComputerPacket() {
|
||||
private ComputerCraftPacket createComputerPacket()
|
||||
{
|
||||
ComputerCraftPacket packet = new ComputerCraftPacket();
|
||||
packet.m_packetType = ComputerCraftPacket.ComputerChanged;
|
||||
packet.m_dataInt = new int[] { getInstanceID() };
|
||||
@ -154,7 +156,8 @@ public class ServerComputer extends ServerTerminal
|
||||
return packet;
|
||||
}
|
||||
|
||||
protected ComputerCraftPacket createTerminalPacket() {
|
||||
protected ComputerCraftPacket createTerminalPacket()
|
||||
{
|
||||
ComputerCraftPacket packet = new ComputerCraftPacket();
|
||||
packet.m_packetType = ComputerCraftPacket.ComputerTerminalChanged;
|
||||
packet.m_dataInt = new int[] { getInstanceID() };
|
||||
|
@ -14,7 +14,10 @@ import javax.annotation.Nonnull;
|
||||
public interface IComputerItem
|
||||
{
|
||||
int getComputerID( @Nonnull ItemStack stack );
|
||||
|
||||
String getLabel( @Nonnull ItemStack stack );
|
||||
|
||||
ComputerFamily getFamily( @Nonnull ItemStack stack );
|
||||
|
||||
ItemStack withFamily( @Nonnull ItemStack stack, @Nonnull ComputerFamily family );
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -28,9 +28,9 @@ public abstract class ComputerConvertRecipe extends ShapedRecipes
|
||||
{
|
||||
// See if we match the recipe, and extract the input computercraft ID
|
||||
ItemStack computerStack = null;
|
||||
for( int y = 0; y < 3; ++y )
|
||||
for( int y = 0; y < 3; y++ )
|
||||
{
|
||||
for( int x = 0; x < 3; ++x )
|
||||
for( int x = 0; x < 3; x++ )
|
||||
{
|
||||
ItemStack stack = inventory.getStackInRowAndColumn( x, y );
|
||||
Ingredient target = getIngredients().get( x + y * 3 );
|
||||
@ -50,9 +50,9 @@ public abstract class ComputerConvertRecipe extends ShapedRecipes
|
||||
@Override
|
||||
public ItemStack getCraftingResult( @Nonnull InventoryCrafting inventory )
|
||||
{
|
||||
for( int y = 0; y < 3; ++y )
|
||||
for( int y = 0; y < 3; y++ )
|
||||
{
|
||||
for( int x = 0; x < 3; ++x )
|
||||
for( int x = 0; x < 3; x++ )
|
||||
{
|
||||
ItemStack item = inventory.getStackInRowAndColumn( x, y );
|
||||
|
||||
|
@ -133,7 +133,7 @@ public class ItemPrintout extends Item
|
||||
if( text != null )
|
||||
{
|
||||
nbt.setInteger( "pages", text.length / LINES_PER_PAGE );
|
||||
for(int i=0; i<text.length; ++i)
|
||||
for( int i = 0; i < text.length; i++ )
|
||||
{
|
||||
if( text[i] != null )
|
||||
{
|
||||
@ -143,7 +143,7 @@ public class ItemPrintout extends Item
|
||||
}
|
||||
if( colours != null )
|
||||
{
|
||||
for(int i=0; i<colours.length; ++i)
|
||||
for( int i = 0; i < colours.length; i++ )
|
||||
{
|
||||
if( colours[i] != null )
|
||||
{
|
||||
@ -221,7 +221,7 @@ public class ItemPrintout extends Item
|
||||
NBTTagCompound nbt = stack.getTagCompound();
|
||||
int numLines = getPageCount( stack ) * LINES_PER_PAGE;
|
||||
String[] lines = new String[numLines];
|
||||
for( int i=0; i<lines.length; ++i )
|
||||
for( int i = 0; i < lines.length; i++ )
|
||||
{
|
||||
if( nbt != null )
|
||||
{
|
||||
@ -240,7 +240,7 @@ public class ItemPrintout extends Item
|
||||
NBTTagCompound nbt = stack.getTagCompound();
|
||||
int numLines = getPageCount( stack ) * LINES_PER_PAGE;
|
||||
String[] lines = new String[numLines];
|
||||
for( int i=0; i<lines.length; ++i )
|
||||
for( int i = 0; i < lines.length; i++ )
|
||||
{
|
||||
if( nbt != null )
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ public class DiskRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRe
|
||||
boolean paperFound = false;
|
||||
boolean redstoneFound = false;
|
||||
|
||||
for( int i = 0; i < inv.getSizeInventory(); ++i )
|
||||
for( int i = 0; i < inv.getSizeInventory(); i++ )
|
||||
{
|
||||
ItemStack stack = inv.getStackInSlot( i );
|
||||
|
||||
@ -65,7 +65,7 @@ public class DiskRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRe
|
||||
{
|
||||
ColourTracker tracker = new ColourTracker();
|
||||
|
||||
for( int i = 0; i < inv.getSizeInventory(); ++i )
|
||||
for( int i = 0; i < inv.getSizeInventory(); i++ )
|
||||
{
|
||||
ItemStack stack = inv.getStackInSlot( i );
|
||||
|
||||
@ -108,7 +108,7 @@ public class DiskRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRe
|
||||
public NonNullList<ItemStack> getRemainingItems( @Nonnull InventoryCrafting inventoryCrafting )
|
||||
{
|
||||
NonNullList<ItemStack> results = NonNullList.withSize( inventoryCrafting.getSizeInventory(), ItemStack.EMPTY );
|
||||
for( int i = 0; i < results.size(); ++i )
|
||||
for( int i = 0; i < results.size(); i++ )
|
||||
{
|
||||
ItemStack stack = inventoryCrafting.getStackInSlot( i );
|
||||
results.set( i, ForgeHooks.getContainerItem( stack ) );
|
||||
|
@ -8,7 +8,6 @@ package dan200.computercraft.shared.media.recipes;
|
||||
|
||||
import dan200.computercraft.shared.media.items.ItemPrintout;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
@ -62,9 +61,9 @@ public class PrintoutRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements
|
||||
boolean stringFound = false;
|
||||
boolean leatherFound = false;
|
||||
boolean printoutFound = false;
|
||||
for( int y=0; y<inventory.getHeight(); ++y )
|
||||
for( int y = 0; y < inventory.getHeight(); y++ )
|
||||
{
|
||||
for( int x=0; x<inventory.getWidth(); ++x )
|
||||
for( int x = 0; x < inventory.getWidth(); x++ )
|
||||
{
|
||||
ItemStack stack = inventory.getStackInRowAndColumn( x, y );
|
||||
if( !stack.isEmpty() )
|
||||
@ -164,7 +163,7 @@ public class PrintoutRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements
|
||||
public NonNullList<ItemStack> getRemainingItems( @Nonnull InventoryCrafting inventoryCrafting )
|
||||
{
|
||||
NonNullList<ItemStack> results = NonNullList.withSize( inventoryCrafting.getSizeInventory(), ItemStack.EMPTY );
|
||||
for( int i = 0; i < results.size(); ++i )
|
||||
for( int i = 0; i < results.size(); i++ )
|
||||
{
|
||||
ItemStack stack = inventoryCrafting.getStackInSlot( i );
|
||||
results.set( i, ForgeHooks.getContainerItem( stack ) );
|
||||
|
@ -232,7 +232,8 @@ public class ComputerCraftPacket
|
||||
* Determine whether this packet requires the player to be interacting with the
|
||||
* target.
|
||||
*/
|
||||
public boolean requiresContainer() {
|
||||
public boolean requiresContainer()
|
||||
{
|
||||
return m_packetType != RequestComputerUpdate && m_packetType != RequestTileEntityUpdate;
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
package dan200.computercraft.shared.network;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public interface INetworkedThing
|
||||
|
@ -10,8 +10,8 @@ import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.peripheral.IPeripheralProvider;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityCommandBlock;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -10,7 +10,8 @@ public enum BlockCableCableVariant implements IStringSerializable
|
||||
ANY( "any" ),
|
||||
X_AXIS( "x" ),
|
||||
Y_AXIS( "y" ),
|
||||
Z_AXIS( "z" ),;
|
||||
Z_AXIS( "z" ),
|
||||
;
|
||||
|
||||
private final String m_name;
|
||||
|
||||
|
@ -43,12 +43,18 @@ public enum BlockCableModemVariant implements IStringSerializable
|
||||
{
|
||||
switch( facing )
|
||||
{
|
||||
case DOWN: return DownOff;
|
||||
case UP: return UpOff;
|
||||
case NORTH: return NorthOff;
|
||||
case SOUTH: return SouthOff;
|
||||
case WEST: return WestOff;
|
||||
case EAST: return EastOff;
|
||||
case DOWN:
|
||||
return DownOff;
|
||||
case UP:
|
||||
return UpOff;
|
||||
case NORTH:
|
||||
return NorthOff;
|
||||
case SOUTH:
|
||||
return SouthOff;
|
||||
case WEST:
|
||||
return WestOff;
|
||||
case EAST:
|
||||
return EastOff;
|
||||
}
|
||||
return NorthOff;
|
||||
}
|
||||
|
@ -125,7 +125,8 @@ public class BlockPeripheral extends BlockPeripheralBase
|
||||
case DiskDrive:
|
||||
{
|
||||
EnumFacing dir = state.getValue( Properties.FACING );
|
||||
if( dir.getAxis() == EnumFacing.Axis.Y ) {
|
||||
if( dir.getAxis() == EnumFacing.Axis.Y )
|
||||
{
|
||||
dir = EnumFacing.NORTH;
|
||||
}
|
||||
meta = dir.getIndex();
|
||||
|
@ -12,8 +12,8 @@ import dan200.computercraft.shared.peripheral.PeripheralType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@ -27,8 +27,11 @@ public abstract class BlockPeripheralBase extends BlockDirectional
|
||||
}
|
||||
|
||||
protected abstract IBlockState getDefaultBlockState( PeripheralType type, EnumFacing placedSide );
|
||||
|
||||
protected abstract PeripheralType getPeripheralType( int damage );
|
||||
|
||||
protected abstract PeripheralType getPeripheralType( IBlockState state );
|
||||
|
||||
protected abstract TilePeripheralBase createTile( PeripheralType type );
|
||||
|
||||
@Override
|
||||
|
@ -12,8 +12,8 @@ import dan200.computercraft.shared.computer.blocks.ComputerPeripheral;
|
||||
import dan200.computercraft.shared.computer.blocks.TileComputerBase;
|
||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -14,6 +14,8 @@ import net.minecraft.util.EnumFacing;
|
||||
public interface IPeripheralTile extends IDirectionalTile
|
||||
{
|
||||
PeripheralType getPeripheralType();
|
||||
|
||||
IPeripheral getPeripheral( EnumFacing side );
|
||||
|
||||
String getLabel();
|
||||
}
|
||||
|
@ -11,12 +11,11 @@ import dan200.computercraft.shared.common.TileGeneric;
|
||||
import dan200.computercraft.shared.peripheral.PeripheralType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class TilePeripheralBase extends TileGeneric
|
||||
implements IPeripheralTile, ITickable
|
||||
|
@ -559,9 +559,12 @@ public class TileDiskDrive extends TilePeripheralBase
|
||||
if( !m_diskStack.isEmpty() )
|
||||
{
|
||||
IMedia contents = getDiskMedia();
|
||||
if( contents != null ) {
|
||||
if( contents != null )
|
||||
{
|
||||
setAnim( 2 );
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
setAnim( 1 );
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW
|
||||
|
||||
String[] methodNames = wrapper.getMethodNames();
|
||||
Map<Object, Object> table = new HashMap<>();
|
||||
for( int i = 0; i < methodNames.length; ++i )
|
||||
for( int i = 0; i < methodNames.length; i++ )
|
||||
{
|
||||
table.put( i + 1, methodNames[i] );
|
||||
}
|
||||
@ -226,7 +226,8 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW
|
||||
{
|
||||
synchronized( peripheralWrappers )
|
||||
{
|
||||
for(ConcurrentMap<String, RemotePeripheralWrapper> wrappers : peripheralWrappers.values()) {
|
||||
for( ConcurrentMap<String, RemotePeripheralWrapper> wrappers : peripheralWrappers.values() )
|
||||
{
|
||||
RemotePeripheralWrapper wrapper = wrappers.remove( name );
|
||||
if( wrapper != null ) wrapper.detach();
|
||||
}
|
||||
@ -244,7 +245,8 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW
|
||||
}
|
||||
}
|
||||
|
||||
private ConcurrentMap<String, RemotePeripheralWrapper> getWrappers( IComputerAccess computer ) {
|
||||
private ConcurrentMap<String, RemotePeripheralWrapper> getWrappers( IComputerAccess computer )
|
||||
{
|
||||
synchronized( peripheralWrappers )
|
||||
{
|
||||
return peripheralWrappers.get( computer );
|
||||
@ -281,7 +283,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW
|
||||
assert (m_methods != null);
|
||||
|
||||
m_methodMap = new HashMap<>();
|
||||
for( int i = 0; i < m_methods.length; ++i )
|
||||
for( int i = 0; i < m_methods.length; i++ )
|
||||
{
|
||||
if( m_methods[i] != null )
|
||||
{
|
||||
|
@ -86,9 +86,12 @@ public class MonitorPeripheral implements IPeripheral
|
||||
{
|
||||
// write
|
||||
String text;
|
||||
if( args.length > 0 && args[0] != null ) {
|
||||
if( args.length > 0 && args[0] != null )
|
||||
{
|
||||
text = args[0].toString();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
text = "";
|
||||
}
|
||||
terminal.write( text );
|
||||
|
@ -322,11 +322,16 @@ public class TileMonitor extends TilePeripheralBase
|
||||
public EnumFacing getDirection()
|
||||
{
|
||||
int dir = getDir() % 6;
|
||||
switch( dir ) {
|
||||
case 2: return EnumFacing.NORTH;
|
||||
case 3: return EnumFacing.SOUTH;
|
||||
case 4: return EnumFacing.WEST;
|
||||
case 5: return EnumFacing.EAST;
|
||||
switch( dir )
|
||||
{
|
||||
case 2:
|
||||
return EnumFacing.NORTH;
|
||||
case 3:
|
||||
return EnumFacing.SOUTH;
|
||||
case 4:
|
||||
return EnumFacing.WEST;
|
||||
case 5:
|
||||
return EnumFacing.EAST;
|
||||
}
|
||||
return EnumFacing.NORTH;
|
||||
}
|
||||
@ -350,11 +355,16 @@ public class TileMonitor extends TilePeripheralBase
|
||||
public EnumFacing getRight()
|
||||
{
|
||||
int dir = getDir() % 6;
|
||||
switch( dir ) {
|
||||
case 2: return EnumFacing.WEST;
|
||||
case 3: return EnumFacing.EAST;
|
||||
case 4: return EnumFacing.SOUTH;
|
||||
case 5: return EnumFacing.NORTH;
|
||||
switch( dir )
|
||||
{
|
||||
case 2:
|
||||
return EnumFacing.WEST;
|
||||
case 3:
|
||||
return EnumFacing.EAST;
|
||||
case 4:
|
||||
return EnumFacing.SOUTH;
|
||||
case 5:
|
||||
return EnumFacing.NORTH;
|
||||
}
|
||||
return EnumFacing.WEST;
|
||||
}
|
||||
@ -364,17 +374,26 @@ public class TileMonitor extends TilePeripheralBase
|
||||
int dir = getDir();
|
||||
if( dir <= 5 ) return EnumFacing.UP;
|
||||
|
||||
switch( dir ) {
|
||||
switch( dir )
|
||||
{
|
||||
// up facing
|
||||
case 8: return EnumFacing.NORTH;
|
||||
case 9: return EnumFacing.SOUTH;
|
||||
case 10: return EnumFacing.WEST;
|
||||
case 11: return EnumFacing.EAST;
|
||||
case 8:
|
||||
return EnumFacing.NORTH;
|
||||
case 9:
|
||||
return EnumFacing.SOUTH;
|
||||
case 10:
|
||||
return EnumFacing.WEST;
|
||||
case 11:
|
||||
return EnumFacing.EAST;
|
||||
// down facing
|
||||
case 14: return EnumFacing.SOUTH;
|
||||
case 15: return EnumFacing.NORTH;
|
||||
case 16: return EnumFacing.EAST;
|
||||
case 17: return EnumFacing.WEST;
|
||||
case 14:
|
||||
return EnumFacing.SOUTH;
|
||||
case 15:
|
||||
return EnumFacing.NORTH;
|
||||
case 16:
|
||||
return EnumFacing.EAST;
|
||||
case 17:
|
||||
return EnumFacing.WEST;
|
||||
}
|
||||
return EnumFacing.NORTH;
|
||||
}
|
||||
@ -587,33 +606,43 @@ public class TileMonitor extends TilePeripheralBase
|
||||
|
||||
public void expand()
|
||||
{
|
||||
while( mergeLeft() || mergeRight() || mergeUp() || mergeDown() ) {}
|
||||
while( mergeLeft() || mergeRight() || mergeUp() || mergeDown() )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void contractNeighbours()
|
||||
{
|
||||
m_ignoreMe = true;
|
||||
if( m_xIndex > 0 ) {
|
||||
if( m_xIndex > 0 )
|
||||
{
|
||||
TileMonitor left = getNeighbour( m_xIndex - 1, m_yIndex );
|
||||
if( left != null ) {
|
||||
if( left != null )
|
||||
{
|
||||
left.contract();
|
||||
}
|
||||
}
|
||||
if( m_xIndex + 1 < m_width ) {
|
||||
if( m_xIndex + 1 < m_width )
|
||||
{
|
||||
TileMonitor right = getNeighbour( m_xIndex + 1, m_yIndex );
|
||||
if( right != null ) {
|
||||
if( right != null )
|
||||
{
|
||||
right.contract();
|
||||
}
|
||||
}
|
||||
if( m_yIndex > 0 ) {
|
||||
if( m_yIndex > 0 )
|
||||
{
|
||||
TileMonitor below = getNeighbour( m_xIndex, m_yIndex - 1 );
|
||||
if( below != null ) {
|
||||
if( below != null )
|
||||
{
|
||||
below.contract();
|
||||
}
|
||||
}
|
||||
if( m_yIndex + 1 < m_height ) {
|
||||
if( m_yIndex + 1 < m_height )
|
||||
{
|
||||
TileMonitor above = getNeighbour( m_xIndex, m_yIndex + 1 );
|
||||
if( above != null ) {
|
||||
if( above != null )
|
||||
{
|
||||
above.contract();
|
||||
}
|
||||
}
|
||||
@ -630,30 +659,36 @@ public class TileMonitor extends TilePeripheralBase
|
||||
{
|
||||
TileMonitor right = null;
|
||||
TileMonitor below = null;
|
||||
if( width > 1 ) {
|
||||
if( width > 1 )
|
||||
{
|
||||
right = getNeighbour( 1, 0 );
|
||||
}
|
||||
if( height > 1 ) {
|
||||
if( height > 1 )
|
||||
{
|
||||
below = getNeighbour( 0, 1 );
|
||||
}
|
||||
if( right != null ) {
|
||||
if( right != null )
|
||||
{
|
||||
right.resize( width - 1, 1 );
|
||||
}
|
||||
if( below != null ) {
|
||||
if( below != null )
|
||||
{
|
||||
below.resize( width, height - 1 );
|
||||
}
|
||||
if( right != null ) {
|
||||
if( right != null )
|
||||
{
|
||||
right.expand();
|
||||
}
|
||||
if( below != null ) {
|
||||
if( below != null )
|
||||
{
|
||||
below.expand();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for( int y=0; y<height; ++y )
|
||||
for( int y = 0; y < height; y++ )
|
||||
{
|
||||
for( int x=0; x<width; ++x )
|
||||
for( int x = 0; x < width; x++ )
|
||||
{
|
||||
TileMonitor monitor = origin.getNeighbour( x, y );
|
||||
if( monitor == null )
|
||||
@ -664,34 +699,42 @@ public class TileMonitor extends TilePeripheralBase
|
||||
TileMonitor right = null;
|
||||
TileMonitor below = null;
|
||||
|
||||
if( y > 0 ) {
|
||||
if( y > 0 )
|
||||
{
|
||||
above = origin;
|
||||
above.resize( width, y );
|
||||
}
|
||||
if( x > 0 ) {
|
||||
if( x > 0 )
|
||||
{
|
||||
left = origin.getNeighbour( 0, y );
|
||||
left.resize( x, 1 );
|
||||
}
|
||||
if( x + 1 < width ) {
|
||||
if( x + 1 < width )
|
||||
{
|
||||
right = origin.getNeighbour( x + 1, y );
|
||||
right.resize( width - (x + 1), 1 );
|
||||
}
|
||||
if( y + 1 < height ) {
|
||||
if( y + 1 < height )
|
||||
{
|
||||
below = origin.getNeighbour( 0, y + 1 );
|
||||
below.resize( width, height - (y + 1) );
|
||||
}
|
||||
|
||||
// Re-expand
|
||||
if( above != null ) {
|
||||
if( above != null )
|
||||
{
|
||||
above.expand();
|
||||
}
|
||||
if( left != null ) {
|
||||
if( left != null )
|
||||
{
|
||||
left.expand();
|
||||
}
|
||||
if( right != null ) {
|
||||
if( right != null )
|
||||
{
|
||||
right.expand();
|
||||
}
|
||||
if( below != null ) {
|
||||
if( below != null )
|
||||
{
|
||||
below.expand();
|
||||
}
|
||||
return;
|
||||
@ -723,9 +766,9 @@ public class TileMonitor extends TilePeripheralBase
|
||||
int xCharPos = (int) Math.min( originTerminal.getWidth(), Math.max( ((pair.x - RENDER_BORDER - RENDER_MARGIN) / xCharWidth) + 1.0, 1.0 ) );
|
||||
int yCharPos = (int) Math.min( originTerminal.getHeight(), Math.max( ((pair.y - RENDER_BORDER - RENDER_MARGIN) / yCharHeight) + 1.0, 1.0 ) );
|
||||
|
||||
for( int y = 0; y < m_height; ++y )
|
||||
for( int y = 0; y < m_height; y++ )
|
||||
{
|
||||
for( int x = 0; x < m_width; ++x )
|
||||
for( int x = 0; x < m_width; x++ )
|
||||
{
|
||||
TileMonitor monitor = getNeighbour( x, y );
|
||||
if( monitor == null ) continue;
|
||||
|
@ -30,13 +30,13 @@ public class ContainerPrinter extends Container
|
||||
addSlotToContainer( new Slot( m_printer, 0, 13, 35 ) );
|
||||
|
||||
// In-tray
|
||||
for( int i = 0; i < 6; ++i )
|
||||
for( int i = 0; i < 6; i++ )
|
||||
{
|
||||
addSlotToContainer( new Slot( m_printer, i + 1, 61 + i * 18, 22 ) );
|
||||
}
|
||||
|
||||
// Out-tray
|
||||
for( int i = 0; i < 6; ++i )
|
||||
for( int i = 0; i < 6; i++ )
|
||||
{
|
||||
addSlotToContainer( new Slot( m_printer, i + 7, 61 + i * 18, 49 ) );
|
||||
}
|
||||
|
@ -59,9 +59,12 @@ public class PrinterPeripheral implements IPeripheral
|
||||
{
|
||||
// write
|
||||
String text;
|
||||
if( args.length > 0 && args[0] != null ) {
|
||||
if( args.length > 0 && args[0] != null )
|
||||
{
|
||||
text = args[0].toString();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
text = "";
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class TilePrinter extends TilePeripheralBase
|
||||
synchronized( m_inventory )
|
||||
{
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList( "Items", Constants.NBT.TAG_COMPOUND );
|
||||
for( int i=0; i<nbttaglist.tagCount(); ++i )
|
||||
for( int i = 0; i < nbttaglist.tagCount(); i++ )
|
||||
{
|
||||
NBTTagCompound itemTag = nbttaglist.getCompoundTagAt( i );
|
||||
int j = itemTag.getByte( "Slot" ) & 0xff;
|
||||
@ -134,7 +134,7 @@ public class TilePrinter extends TilePeripheralBase
|
||||
synchronized( m_inventory )
|
||||
{
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
for(int i=0; i<m_inventory.size(); ++i)
|
||||
for( int i = 0; i < m_inventory.size(); i++ )
|
||||
{
|
||||
if( !m_inventory.get( i ).isEmpty() )
|
||||
{
|
||||
@ -253,7 +253,7 @@ public class TilePrinter extends TilePeripheralBase
|
||||
{
|
||||
synchronized( m_inventory )
|
||||
{
|
||||
for( int i=0; i<m_inventory.size(); ++i )
|
||||
for( int i = 0; i < m_inventory.size(); i++ )
|
||||
{
|
||||
m_inventory.set( i, ItemStack.EMPTY );
|
||||
}
|
||||
@ -350,9 +350,12 @@ public class TilePrinter extends TilePeripheralBase
|
||||
{
|
||||
switch( side )
|
||||
{
|
||||
case DOWN: return bottomSlots; // Bottom (Out tray)
|
||||
case UP: return topSlots; // Top (In tray)
|
||||
default: return sideSlots; // Sides (Ink)
|
||||
case DOWN:
|
||||
return bottomSlots; // Bottom (Out tray)
|
||||
case UP:
|
||||
return topSlots; // Top (In tray)
|
||||
default:
|
||||
return sideSlots; // Sides (Ink)
|
||||
}
|
||||
}
|
||||
|
||||
@ -434,7 +437,7 @@ public class TilePrinter extends TilePeripheralBase
|
||||
int count = 0;
|
||||
synchronized( m_inventory )
|
||||
{
|
||||
for( int i=1; i<7; ++i )
|
||||
for( int i = 1; i < 7; i++ )
|
||||
{
|
||||
ItemStack paperStack = m_inventory.get( i );
|
||||
if( !paperStack.isEmpty() && isPaper( paperStack ) )
|
||||
@ -484,16 +487,19 @@ public class TilePrinter extends TilePeripheralBase
|
||||
return false;
|
||||
}
|
||||
|
||||
for( int i=1; i<7; ++i )
|
||||
for( int i = 1; i < 7; i++ )
|
||||
{
|
||||
ItemStack paperStack = m_inventory.get( i );
|
||||
if( !paperStack.isEmpty() && isPaper( paperStack ) )
|
||||
{
|
||||
// Setup the new page
|
||||
int colour = inkStack.getItemDamage();
|
||||
if( colour >= 0 && colour < 16 ) {
|
||||
if( colour >= 0 && colour < 16 )
|
||||
{
|
||||
m_page.setTextColour( 15 - colour );
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
m_page.setTextColour( 15 );
|
||||
}
|
||||
|
||||
@ -503,7 +509,7 @@ public class TilePrinter extends TilePeripheralBase
|
||||
m_pageTitle = ItemPrintout.getTitle( paperStack );
|
||||
String[] text = ItemPrintout.getText( paperStack );
|
||||
String[] textColour = ItemPrintout.getColours( paperStack );
|
||||
for( int y=0; y<m_page.getHeight(); ++y )
|
||||
for( int y = 0; y < m_page.getHeight(); y++ )
|
||||
{
|
||||
m_page.setLine( y, text[y], textColour[y], "" );
|
||||
}
|
||||
@ -545,7 +551,7 @@ public class TilePrinter extends TilePeripheralBase
|
||||
int height = m_page.getHeight();
|
||||
String[] lines = new String[height];
|
||||
String[] colours = new String[height];
|
||||
for( int i=0; i<height; ++i )
|
||||
for( int i = 0; i < height; i++ )
|
||||
{
|
||||
lines[i] = m_page.getLine( i ).toString();
|
||||
colours[i] = m_page.getTextColourLine( i ).toString();
|
||||
@ -569,7 +575,7 @@ public class TilePrinter extends TilePeripheralBase
|
||||
{
|
||||
synchronized( m_inventory )
|
||||
{
|
||||
for( int i=0; i<13; ++i )
|
||||
for( int i = 0; i < 13; i++ )
|
||||
{
|
||||
ItemStack stack = m_inventory.get( i );
|
||||
if( !stack.isEmpty() )
|
||||
@ -597,7 +603,7 @@ public class TilePrinter extends TilePeripheralBase
|
||||
synchronized( m_inventory )
|
||||
{
|
||||
int anim = 0;
|
||||
for( int i=1;i<7;++i )
|
||||
for( int i = 1; i < 7; i++ )
|
||||
{
|
||||
ItemStack stack = m_inventory.get( i );
|
||||
if( !stack.isEmpty() && isPaper( stack ) )
|
||||
@ -606,7 +612,7 @@ public class TilePrinter extends TilePeripheralBase
|
||||
break;
|
||||
}
|
||||
}
|
||||
for( int i=7;i<13;++i )
|
||||
for( int i = 7; i < 13; i++ )
|
||||
{
|
||||
ItemStack stack = m_inventory.get( i );
|
||||
if( !stack.isEmpty() && isPaper( stack ) )
|
||||
|
@ -20,7 +20,6 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static dan200.computercraft.core.apis.ArgumentHelper.getString;
|
||||
|
@ -11,7 +11,6 @@ import dan200.computercraft.api.pocket.IPocketAccess;
|
||||
import dan200.computercraft.api.pocket.IPocketUpgrade;
|
||||
import dan200.computercraft.shared.peripheral.PeripheralType;
|
||||
import dan200.computercraft.shared.peripheral.common.PeripheralItemFactory;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -60,9 +60,9 @@ public class PocketComputerUpgradeRecipe extends IForgeRegistryEntry.Impl<IRecip
|
||||
ItemStack computer = ItemStack.EMPTY;
|
||||
int computerX = -1;
|
||||
int computerY = -1;
|
||||
for (int y = 0; y < inventory.getHeight(); ++y)
|
||||
for( int y = 0; y < inventory.getHeight(); y++ )
|
||||
{
|
||||
for (int x = 0; x < inventory.getWidth(); ++x)
|
||||
for( int x = 0; x < inventory.getWidth(); x++ )
|
||||
{
|
||||
ItemStack item = inventory.getStackInRowAndColumn( x, y );
|
||||
if( !item.isEmpty() && item.getItem() instanceof ItemPocketComputer )
|
||||
@ -92,9 +92,9 @@ public class PocketComputerUpgradeRecipe extends IForgeRegistryEntry.Impl<IRecip
|
||||
|
||||
// Check for upgrades around the item
|
||||
IPocketUpgrade upgrade = null;
|
||||
for (int y = 0; y < inventory.getHeight(); ++y)
|
||||
for( int y = 0; y < inventory.getHeight(); y++ )
|
||||
{
|
||||
for (int x = 0; x < inventory.getWidth(); ++x)
|
||||
for( int x = 0; x < inventory.getWidth(); x++ )
|
||||
{
|
||||
ItemStack item = inventory.getStackInRowAndColumn( x, y );
|
||||
if( x == computerX && y == computerY )
|
||||
@ -131,7 +131,7 @@ public class PocketComputerUpgradeRecipe extends IForgeRegistryEntry.Impl<IRecip
|
||||
public NonNullList<ItemStack> getRemainingItems( @Nonnull InventoryCrafting inventoryCrafting )
|
||||
{
|
||||
NonNullList<ItemStack> results = NonNullList.withSize( inventoryCrafting.getSizeInventory(), ItemStack.EMPTY );
|
||||
for( int i = 0; i < results.size(); ++i )
|
||||
for( int i = 0; i < results.size(); i++ )
|
||||
{
|
||||
ItemStack stack = inventoryCrafting.getStackInSlot( i );
|
||||
results.set( i, ForgeHooks.getContainerItem( stack ) );
|
||||
|
@ -528,7 +528,8 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTurtleAction( TurtleActionEvent event) {
|
||||
public void onTurtleAction( TurtleActionEvent event )
|
||||
{
|
||||
if( ComputerCraft.turtleDisabledActions.contains( event.getAction() ) )
|
||||
{
|
||||
event.setCanceled( true, "Action has been disabled" );
|
||||
|
@ -209,7 +209,8 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
if( listener.isCallingFromMinecraftThread() )
|
||||
{
|
||||
processPacket( packet, player );
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
listener.addScheduledTask( () -> processPacket( packet, player ) );
|
||||
}
|
||||
@ -709,7 +710,8 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onConfigChanged( ConfigChangedEvent.OnConfigChangedEvent event) {
|
||||
public void onConfigChanged( ConfigChangedEvent.OnConfigChangedEvent event )
|
||||
{
|
||||
if( event.getModID().equals( ComputerCraft.MOD_ID ) )
|
||||
{
|
||||
ComputerCraft.syncConfig();
|
||||
|
@ -15,21 +15,27 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public interface ICCTurtleProxy
|
||||
{
|
||||
void preInit();
|
||||
|
||||
void init();
|
||||
|
||||
void registerTurtleUpgrade( ITurtleUpgrade upgrade );
|
||||
|
||||
ITurtleUpgrade getTurtleUpgrade( String id );
|
||||
|
||||
ITurtleUpgrade getTurtleUpgrade( int legacyId );
|
||||
|
||||
ITurtleUpgrade getTurtleUpgrade( @Nonnull ItemStack item );
|
||||
|
||||
void addAllUpgradedTurtles( NonNullList<ItemStack> list );
|
||||
|
||||
void setDropConsumer( Entity entity, Function<ItemStack, ItemStack> consumer );
|
||||
|
||||
void setDropConsumer( World world, BlockPos pos, Function<ItemStack, ItemStack> consumer );
|
||||
|
||||
List<ItemStack> clearDropConsumer();
|
||||
}
|
||||
|
@ -28,25 +28,38 @@ import java.io.File;
|
||||
public interface IComputerCraftProxy
|
||||
{
|
||||
void preInit();
|
||||
|
||||
void init();
|
||||
|
||||
void initServer( MinecraftServer server );
|
||||
|
||||
boolean isClient();
|
||||
|
||||
boolean getGlobalCursorBlink();
|
||||
|
||||
long getRenderFrame();
|
||||
|
||||
Object getFixedWidthFontRenderer();
|
||||
|
||||
String getRecordInfo( @Nonnull ItemStack item );
|
||||
|
||||
void playRecord( SoundEvent record, String recordInfo, World world, BlockPos pos );
|
||||
|
||||
Object getDiskDriveGUI( InventoryPlayer inventory, TileDiskDrive drive );
|
||||
|
||||
Object getComputerGUI( TileComputer computer );
|
||||
|
||||
Object getPrinterGUI( InventoryPlayer inventory, TilePrinter printer );
|
||||
|
||||
Object getTurtleGUI( InventoryPlayer inventory, TileTurtle turtle );
|
||||
|
||||
Object getPrintoutGUI( EntityPlayer player, EnumHand hand );
|
||||
|
||||
Object getPocketComputerGUI( EntityPlayer player, EnumHand hand );
|
||||
|
||||
Object getComputerGUI( IComputer computer, int width, int height, ComputerFamily family );
|
||||
|
||||
File getWorldDir( World world );
|
||||
|
||||
void handlePacket( ComputerCraftPacket packet, EntityPlayer player );
|
||||
}
|
||||
|
@ -17,11 +17,16 @@ import net.minecraft.util.math.Vec3d;
|
||||
public interface ITurtleTile extends IComputerTile, IDirectionalTile
|
||||
{
|
||||
int getColour();
|
||||
|
||||
ResourceLocation getOverlay();
|
||||
|
||||
ITurtleUpgrade getUpgrade( TurtleSide side );
|
||||
|
||||
ITurtleAccess getAccess();
|
||||
|
||||
Vec3d getRenderOffset( float f );
|
||||
|
||||
float getRenderYaw( float f );
|
||||
|
||||
float getToolRenderAngle( TurtleSide side, float f );
|
||||
}
|
||||
|
@ -31,7 +31,10 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
@ -140,7 +143,7 @@ public class TileTurtle extends TileComputerBase
|
||||
if( !getWorld().isRemote )
|
||||
{
|
||||
int size = getSizeInventory();
|
||||
for( int i=0; i<size; ++i )
|
||||
for( int i = 0; i < size; i++ )
|
||||
{
|
||||
ItemStack stack = getStackInSlot( i );
|
||||
if( !stack.isEmpty() )
|
||||
@ -299,7 +302,7 @@ public class TileTurtle extends TileComputerBase
|
||||
}
|
||||
|
||||
m_inventoryChanged = false;
|
||||
for( int n=0; n<getSizeInventory(); ++n )
|
||||
for( int n = 0; n < getSizeInventory(); n++ )
|
||||
{
|
||||
m_previousInventory.set( n, InventoryUtil.copyItem( getStackInSlot( n ) ) );
|
||||
}
|
||||
@ -351,7 +354,7 @@ public class TileTurtle extends TileComputerBase
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList( "Items", Constants.NBT.TAG_COMPOUND );
|
||||
m_inventory = NonNullList.withSize( INVENTORY_SIZE, ItemStack.EMPTY );
|
||||
m_previousInventory = NonNullList.withSize( INVENTORY_SIZE, ItemStack.EMPTY );
|
||||
for( int i=0; i<nbttaglist.tagCount(); ++i )
|
||||
for( int i = 0; i < nbttaglist.tagCount(); i++ )
|
||||
{
|
||||
NBTTagCompound itemtag = nbttaglist.getCompoundTagAt( i );
|
||||
int slot = itemtag.getByte( "Slot" ) & 0xff;
|
||||
@ -374,7 +377,7 @@ public class TileTurtle extends TileComputerBase
|
||||
|
||||
// Write inventory
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
for( int i=0; i<INVENTORY_SIZE; ++i )
|
||||
for( int i = 0; i < INVENTORY_SIZE; i++ )
|
||||
{
|
||||
if( !m_inventory.get( i ).isEmpty() )
|
||||
{
|
||||
@ -570,7 +573,7 @@ public class TileTurtle extends TileComputerBase
|
||||
synchronized( m_inventory )
|
||||
{
|
||||
boolean changed = false;
|
||||
for( int i = 0; i < INVENTORY_SIZE; ++i )
|
||||
for( int i = 0; i < INVENTORY_SIZE; i++ )
|
||||
{
|
||||
if( !m_inventory.get( i ).isEmpty() )
|
||||
{
|
||||
@ -660,7 +663,7 @@ public class TileTurtle extends TileComputerBase
|
||||
{
|
||||
if( !m_inventoryChanged )
|
||||
{
|
||||
for( int n=0; n<getSizeInventory(); ++n )
|
||||
for( int n = 0; n < getSizeInventory(); n++ )
|
||||
{
|
||||
if( !ItemStack.areItemStacksEqual( getStackInSlot( n ), m_previousInventory.get( n ) ) )
|
||||
{
|
||||
@ -735,9 +738,14 @@ public class TileTurtle extends TileComputerBase
|
||||
ITurtleUpgrade upgrade;
|
||||
switch( side )
|
||||
{
|
||||
case 4: upgrade = getUpgrade( TurtleSide.Right ); break;
|
||||
case 5: upgrade = getUpgrade( TurtleSide.Left ); break;
|
||||
default: return false;
|
||||
case 4:
|
||||
upgrade = getUpgrade( TurtleSide.Right );
|
||||
break;
|
||||
case 5:
|
||||
upgrade = getUpgrade( TurtleSide.Left );
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return upgrade != null && upgrade.getType().isPeripheral();
|
||||
}
|
||||
|
@ -178,7 +178,8 @@ public class TurtleBrain implements ITurtleAccess
|
||||
|
||||
public ComputerProxy getProxy()
|
||||
{
|
||||
if(m_proxy == null) {
|
||||
if( m_proxy == null )
|
||||
{
|
||||
m_proxy = new ComputerProxy()
|
||||
{
|
||||
@Override
|
||||
|
@ -75,7 +75,7 @@ public class TurtleCompareCommand implements ITurtleCommand
|
||||
|
||||
// See if the block drops anything with the same ID as itself
|
||||
// (try 5 times to try and beat random number generators)
|
||||
for( int i=0; (i<5) && lookAtStack.isEmpty(); ++i )
|
||||
for( int i = 0; (i < 5) && lookAtStack.isEmpty(); i++ )
|
||||
{
|
||||
NonNullList<ItemStack> drops = NonNullList.create();
|
||||
lookAtBlock.getDrops( drops, world, newPosition, lookAtState, 0 );
|
||||
|
@ -10,8 +10,8 @@ import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -107,7 +107,7 @@ public class TurtlePlayer extends FakePlayer
|
||||
// Store (or drop) anything else we found
|
||||
BlockPos dropPosition = turtle.getPosition();
|
||||
EnumFacing dropDirection = turtle.getDirection().getOpposite();
|
||||
for( int i = 0; i < inventory.getSizeInventory(); ++i )
|
||||
for( int i = 0; i < inventory.getSizeInventory(); i++ )
|
||||
{
|
||||
ItemStack stack = inventory.getStackInSlot( i );
|
||||
if( !stack.isEmpty() )
|
||||
|
@ -18,8 +18,11 @@ import javax.annotation.Nonnull;
|
||||
public interface ITurtleItem extends IComputerItem, IColouredItem
|
||||
{
|
||||
ITurtleUpgrade getUpgrade( ItemStack stack, TurtleSide side );
|
||||
|
||||
int getFuelLevel( ItemStack stack );
|
||||
|
||||
ResourceLocation getOverlay( ItemStack stack );
|
||||
|
||||
@Override
|
||||
int getColour( @Nonnull ItemStack stack );
|
||||
}
|
||||
|
@ -64,40 +64,56 @@ public class TurtleUpgradeRecipe extends IForgeRegistryEntry.Impl<IRecipe> imple
|
||||
ItemStack turtle = ItemStack.EMPTY;
|
||||
ItemStack rightItem = ItemStack.EMPTY;
|
||||
|
||||
for( int y=0; y<inventory.getHeight(); ++y )
|
||||
for( int y = 0; y < inventory.getHeight(); y++ )
|
||||
{
|
||||
if( turtle.isEmpty() )
|
||||
{
|
||||
// Search this row for potential turtles
|
||||
boolean finishedRow = false;
|
||||
for( int x=0; x<inventory.getWidth(); ++x )
|
||||
for( int x = 0; x < inventory.getWidth(); x++ )
|
||||
{
|
||||
ItemStack item = inventory.getStackInRowAndColumn( x, y );
|
||||
if( !item.isEmpty() ) {
|
||||
if( finishedRow ) {
|
||||
if( !item.isEmpty() )
|
||||
{
|
||||
if( finishedRow )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if( item.getItem() instanceof ITurtleItem ) {
|
||||
if( item.getItem() instanceof ITurtleItem )
|
||||
{
|
||||
// Item is a turtle
|
||||
if( turtle.isEmpty() ) {
|
||||
if( turtle.isEmpty() )
|
||||
{
|
||||
turtle = item;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Item is not a turtle
|
||||
if( turtle.isEmpty() && leftItem.isEmpty() ) {
|
||||
if( turtle.isEmpty() && leftItem.isEmpty() )
|
||||
{
|
||||
leftItem = item;
|
||||
} else if( !turtle.isEmpty() && rightItem.isEmpty() ) {
|
||||
}
|
||||
else if( !turtle.isEmpty() && rightItem.isEmpty() )
|
||||
{
|
||||
rightItem = item;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Item is empty
|
||||
if( !leftItem.isEmpty() || !turtle.isEmpty() ) {
|
||||
if( !leftItem.isEmpty() || !turtle.isEmpty() )
|
||||
{
|
||||
finishedRow = true;
|
||||
}
|
||||
}
|
||||
@ -112,10 +128,11 @@ public class TurtleUpgradeRecipe extends IForgeRegistryEntry.Impl<IRecipe> imple
|
||||
else
|
||||
{
|
||||
// Turtle is already found, just check this row is empty
|
||||
for( int x=0; x<inventory.getWidth(); ++x )
|
||||
for( int x = 0; x < inventory.getWidth(); x++ )
|
||||
{
|
||||
ItemStack item = inventory.getStackInRowAndColumn( x, y );
|
||||
if( !item.isEmpty() ) {
|
||||
if( !item.isEmpty() )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
@ -139,7 +156,7 @@ public class TurtleUpgradeRecipe extends IForgeRegistryEntry.Impl<IRecipe> imple
|
||||
|
||||
// Get the upgrades for the new items
|
||||
ItemStack[] items = new ItemStack[] { rightItem, leftItem };
|
||||
for( int i=0; i<2; ++i )
|
||||
for( int i = 0; i < 2; i++ )
|
||||
{
|
||||
if( !items[i].isEmpty() )
|
||||
{
|
||||
@ -174,7 +191,7 @@ public class TurtleUpgradeRecipe extends IForgeRegistryEntry.Impl<IRecipe> imple
|
||||
public NonNullList<ItemStack> getRemainingItems( @Nonnull InventoryCrafting inventoryCrafting )
|
||||
{
|
||||
NonNullList<ItemStack> results = NonNullList.withSize( inventoryCrafting.getSizeInventory(), ItemStack.EMPTY );
|
||||
for( int i = 0; i < results.size(); ++i )
|
||||
for( int i = 0; i < results.size(); i++ )
|
||||
{
|
||||
ItemStack stack = inventoryCrafting.getStackInSlot( i );
|
||||
results.set( i, ForgeHooks.getContainerItem( stack ) );
|
||||
|
@ -43,9 +43,9 @@ public class TurtleInventoryCrafting extends InventoryCrafting
|
||||
m_yStart = yStart;
|
||||
|
||||
// Check the non-relevant parts of the inventory are empty
|
||||
for( int x=0; x<TileTurtle.INVENTORY_WIDTH; ++x )
|
||||
for( int x = 0; x < TileTurtle.INVENTORY_WIDTH; x++ )
|
||||
{
|
||||
for( int y=0; y<TileTurtle.INVENTORY_HEIGHT; ++y )
|
||||
for( int y = 0; y < TileTurtle.INVENTORY_HEIGHT; y++ )
|
||||
{
|
||||
if( x < m_xStart || x >= m_xStart + 3 ||
|
||||
y < m_yStart || y >= m_yStart + 3 )
|
||||
@ -100,7 +100,7 @@ public class TurtleInventoryCrafting extends InventoryCrafting
|
||||
if( maxCount > 1 )
|
||||
{
|
||||
int minStackSize = 0;
|
||||
for( int n=0; n<size; ++n )
|
||||
for( int n = 0; n < size; n++ )
|
||||
{
|
||||
ItemStack stack = getStackInSlot( n );
|
||||
if( !stack.isEmpty() && (minStackSize == 0 || minStackSize > stack.getCount()) )
|
||||
@ -124,7 +124,7 @@ public class TurtleInventoryCrafting extends InventoryCrafting
|
||||
|
||||
// Consume resources from the inventory
|
||||
NonNullList<ItemStack> remainingItems = CraftingManager.getRemainingItems( this, world );
|
||||
for( int n=0; n<size; ++n )
|
||||
for( int n = 0; n < size; n++ )
|
||||
{
|
||||
ItemStack stack = getStackInSlot( n );
|
||||
if( !stack.isEmpty() )
|
||||
@ -304,7 +304,7 @@ public class TurtleInventoryCrafting extends InventoryCrafting
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
for( int i=0; i<getSizeInventory(); ++i )
|
||||
for( int i = 0; i < getSizeInventory(); i++ )
|
||||
{
|
||||
int j = modifyIndex( i );
|
||||
m_turtle.getInventory().setInventorySlotContents( j, ItemStack.EMPTY );
|
||||
|
@ -36,7 +36,8 @@ public enum Colour
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Colour fromHex(int colour) {
|
||||
public static Colour fromHex( int colour )
|
||||
{
|
||||
for( Colour entry : VALUES )
|
||||
{
|
||||
if( entry.getHex() == colour ) return entry;
|
||||
|
@ -89,11 +89,16 @@ public class DirectionUtil
|
||||
public static EnumFacing fromEntityRot( EntityLivingBase player )
|
||||
{
|
||||
int rot = MathHelper.floor( (player.rotationYaw / 90.0f) + 0.5f ) & 0x3;
|
||||
switch( rot ) {
|
||||
case 0: return EnumFacing.NORTH;
|
||||
case 1: return EnumFacing.EAST;
|
||||
case 2: return EnumFacing.SOUTH;
|
||||
case 3: return EnumFacing.WEST;
|
||||
switch( rot )
|
||||
{
|
||||
case 0:
|
||||
return EnumFacing.NORTH;
|
||||
case 1:
|
||||
return EnumFacing.EAST;
|
||||
case 2:
|
||||
return EnumFacing.SOUTH;
|
||||
case 3:
|
||||
return EnumFacing.WEST;
|
||||
}
|
||||
return EnumFacing.NORTH;
|
||||
}
|
||||
@ -102,11 +107,16 @@ public class DirectionUtil
|
||||
{
|
||||
switch( dir )
|
||||
{
|
||||
case NORTH: return 180.0f;
|
||||
case SOUTH: return 0.0f;
|
||||
case WEST: return 90.0f;
|
||||
case EAST: return 270.0f;
|
||||
default: return 0.0f;
|
||||
case NORTH:
|
||||
return 180.0f;
|
||||
case SOUTH:
|
||||
return 0.0f;
|
||||
case WEST:
|
||||
return 90.0f;
|
||||
case EAST:
|
||||
return 270.0f;
|
||||
default:
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,9 +124,12 @@ public class DirectionUtil
|
||||
{
|
||||
switch( dir )
|
||||
{
|
||||
case DOWN: return 90.0f;
|
||||
case UP: return 270.0f;
|
||||
default: return 0.0f;
|
||||
case DOWN:
|
||||
return 90.0f;
|
||||
case UP:
|
||||
return 270.0f;
|
||||
default:
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class NBTUtil
|
||||
{
|
||||
nbt.setTag( "k" + Integer.toString( i ), key );
|
||||
nbt.setTag( "v" + Integer.toString( i ), value );
|
||||
++i;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
nbt.setInteger( "len", m.size() );
|
||||
@ -62,7 +62,7 @@ public class NBTUtil
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setInteger( "len", objects.length );
|
||||
for( int i=0; i<objects.length; ++i )
|
||||
for( int i = 0; i < objects.length; i++ )
|
||||
{
|
||||
Object object = objects[i];
|
||||
NBTBase tag = toNBTTag( object );
|
||||
@ -100,7 +100,7 @@ public class NBTUtil
|
||||
NBTTagCompound c = (NBTTagCompound) tag;
|
||||
int len = c.getInteger( "len" );
|
||||
Map<Object, Object> map = new HashMap<>( len );
|
||||
for( int i=0; i<len; ++i )
|
||||
for( int i = 0; i < len; i++ )
|
||||
{
|
||||
Object key = fromNBTTag( c.getTag( "k" + Integer.toString( i ) ) );
|
||||
Object value = fromNBTTag( c.getTag( "v" + Integer.toString( i ) ) );
|
||||
@ -122,7 +122,7 @@ public class NBTUtil
|
||||
if( len > 0 )
|
||||
{
|
||||
Object[] objects = new Object[len];
|
||||
for( int i=0; i<len; ++i )
|
||||
for( int i = 0; i < len; i++ )
|
||||
{
|
||||
String key = Integer.toString( i );
|
||||
if( tagCompound.hasKey( key ) )
|
||||
|
@ -49,7 +49,7 @@ public class Palette
|
||||
|
||||
public void resetColours()
|
||||
{
|
||||
for(int i = 0; i < Colour.values().length; ++i)
|
||||
for( int i = 0; i < Colour.values().length; i++ )
|
||||
{
|
||||
resetColour( i );
|
||||
}
|
||||
@ -78,7 +78,7 @@ public class Palette
|
||||
{
|
||||
int[] rgb8 = new int[colours.length];
|
||||
|
||||
for(int i = 0; i < colours.length; ++i)
|
||||
for( int i = 0; i < colours.length; i++ )
|
||||
{
|
||||
rgb8[i] = encodeRGB8( colours[i] );
|
||||
}
|
||||
@ -94,7 +94,7 @@ public class Palette
|
||||
|
||||
if( rgb8.length != colours.length ) return;
|
||||
|
||||
for(int i = 0; i < colours.length; ++i)
|
||||
for( int i = 0; i < colours.length; i++ )
|
||||
{
|
||||
colours[i] = decodeRGB8( rgb8[i] );
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ package dan200.computercraft.shared.util;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class PeripheralUtil
|
||||
|
@ -43,10 +43,12 @@ public class RecipeUtil
|
||||
JsonArray patternJ = JsonUtils.getJsonArray( json, "pattern" );
|
||||
|
||||
if( patternJ.size() == 0 )
|
||||
{
|
||||
throw new JsonSyntaxException( "Invalid pattern: empty pattern not allowed" );
|
||||
}
|
||||
|
||||
String[] pattern = new String[patternJ.size()];
|
||||
for( int x = 0; x < pattern.length; ++x )
|
||||
for( int x = 0; x < pattern.length; x++ )
|
||||
{
|
||||
String line = JsonUtils.getString( patternJ.get( x ), "pattern[" + x + "]" );
|
||||
if( x > 0 && pattern[0].length() != line.length() )
|
||||
|
@ -46,7 +46,7 @@ public class StringUtil
|
||||
{
|
||||
byte[] chars = new byte[string.length()];
|
||||
|
||||
for( int i = 0; i < chars.length; ++i )
|
||||
for( int i = 0; i < chars.length; i++ )
|
||||
{
|
||||
char c = string.charAt( i );
|
||||
chars[i] = c < 256 ? (byte) c : 63;
|
||||
|
@ -6,12 +6,10 @@
|
||||
|
||||
package dan200.computercraft.shared.util;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
@ -125,13 +123,15 @@ public class WorldUtil
|
||||
return new Vec3d( entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ );
|
||||
}
|
||||
|
||||
public static Vec3d getRayEnd( EntityPlayer player) {
|
||||
public static Vec3d getRayEnd( EntityPlayer player )
|
||||
{
|
||||
double reach = player.getEntityAttribute( EntityPlayer.REACH_DISTANCE ).getAttributeValue();
|
||||
Vec3d look = player.getLookVec();
|
||||
return getRayStart( player ).add( look.x * reach, look.y * reach, look.z * reach );
|
||||
}
|
||||
|
||||
public static boolean isVecInsideInclusive(AxisAlignedBB bb , Vec3d vec) {
|
||||
public static boolean isVecInsideInclusive( AxisAlignedBB bb, Vec3d vec )
|
||||
{
|
||||
return vec.x >= bb.minX && vec.x <= bb.maxX && vec.y >= bb.minY && vec.y <= bb.maxY && vec.z >= bb.minZ && vec.z <= bb.maxZ;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user