mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 13:42:59 +00:00 
			
		
		
		
	Remove some unnecessary constructs
- Replace for and while loops with for iterators - Remove unused casts
This commit is contained in:
		| @@ -74,7 +74,10 @@ import java.io.IOException; | ||||
| import java.net.MalformedURLException; | ||||
| import java.net.URISyntaxException; | ||||
| import java.net.URL; | ||||
| import java.util.*; | ||||
| import java.util.ArrayList; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| /////////////// | ||||
| // UNIVERSAL // | ||||
| @@ -509,9 +512,8 @@ public class ComputerCraft | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         for( int i=0; i<permissionProviders.size(); ++i ) | ||||
|         for( ITurtlePermissionProvider provider : permissionProviders ) | ||||
|         { | ||||
|             ITurtlePermissionProvider provider = permissionProviders.get( i ); | ||||
|             if( !provider.isBlockEnterable( world, pos ) ) | ||||
|             { | ||||
|                 return false; | ||||
| @@ -531,9 +533,8 @@ public class ComputerCraft | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         for( int i=0; i<permissionProviders.size(); ++i ) | ||||
|         for( ITurtlePermissionProvider provider : permissionProviders ) | ||||
|         { | ||||
|             ITurtlePermissionProvider provider = permissionProviders.get( i ); | ||||
|             if( !provider.isBlockEditable( world, pos ) ) | ||||
|             { | ||||
|                 return false; | ||||
| @@ -581,12 +582,11 @@ public class ComputerCraft | ||||
|     public static IPeripheral getPeripheralAt( World world, BlockPos pos, EnumFacing side ) | ||||
|     { | ||||
|         // Try the handlers in order: | ||||
|         Iterator<IPeripheralProvider> it = peripheralProviders.iterator(); | ||||
|         while( it.hasNext() ) | ||||
|         for( IPeripheralProvider peripheralProvider : peripheralProviders ) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 IPeripheralProvider handler = it.next(); | ||||
|                 IPeripheralProvider handler = peripheralProvider; | ||||
|                 IPeripheral peripheral = handler.getPeripheral( world, pos, side ); | ||||
|                 if( peripheral != null ) | ||||
|                 { | ||||
| @@ -620,12 +620,11 @@ public class ComputerCraft | ||||
|  | ||||
|         // Try the handlers in order: | ||||
|         int combinedSignal = -1; | ||||
|         Iterator<IBundledRedstoneProvider> it = bundledRedstoneProviders.iterator(); | ||||
|         while( it.hasNext() ) | ||||
|         for( IBundledRedstoneProvider bundledRedstoneProvider : bundledRedstoneProviders ) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 IBundledRedstoneProvider handler = it.next(); | ||||
|                 IBundledRedstoneProvider handler = bundledRedstoneProvider; | ||||
|                 int signal = handler.getBundledRedstoneOutput( world, pos, side ); | ||||
|                 if( signal >= 0 ) | ||||
|                 { | ||||
| @@ -652,12 +651,11 @@ public class ComputerCraft | ||||
|         if( stack != null ) | ||||
|         { | ||||
|             // Try the handlers in order: | ||||
|             Iterator<IMediaProvider> it = mediaProviders.iterator(); | ||||
|             while( it.hasNext() ) | ||||
|             for( IMediaProvider mediaProvider : mediaProviders ) | ||||
|             { | ||||
|                 try | ||||
|                 { | ||||
|                     IMediaProvider handler = it.next(); | ||||
|                     IMediaProvider handler = mediaProvider; | ||||
|                     IMedia media = handler.getMedia( stack ); | ||||
|                     if( media != null ) | ||||
|                     { | ||||
| @@ -760,11 +758,11 @@ public class ComputerCraft | ||||
|         if( resourcePackDir.exists() && resourcePackDir.isDirectory() ) | ||||
|         { | ||||
|             String[] resourcePacks = resourcePackDir.list(); | ||||
|             for( int i=0; i<resourcePacks.length; ++i ) | ||||
|             for( String resourcePack1 : resourcePacks ) | ||||
|             { | ||||
|                 try | ||||
|                 { | ||||
|                     File resourcePack = new File( resourcePackDir, resourcePacks[i] ); | ||||
|                     File resourcePack = new File( resourcePackDir, resourcePack1 ); | ||||
|                     if( !resourcePack.isDirectory() ) | ||||
|                     { | ||||
|                         // Mount a resource pack from a jar | ||||
|   | ||||
| @@ -14,7 +14,6 @@ import net.minecraft.client.gui.inventory.GuiContainer; | ||||
| import net.minecraft.client.renderer.GlStateManager; | ||||
| import net.minecraft.util.ResourceLocation; | ||||
| import org.lwjgl.input.Mouse; | ||||
| import org.lwjgl.opengl.GL11; | ||||
|  | ||||
| import java.io.IOException; | ||||
|  | ||||
|   | ||||
| @@ -11,13 +11,10 @@ import net.minecraft.client.audio.PositionedSoundRecord; | ||||
| import net.minecraft.client.gui.FontRenderer; | ||||
| import net.minecraft.client.gui.Gui; | ||||
| import net.minecraft.client.renderer.*; | ||||
| import net.minecraft.client.renderer.RenderItem; | ||||
| import net.minecraft.client.renderer.vertex.DefaultVertexFormats; | ||||
| import net.minecraft.init.SoundEvents; | ||||
| import net.minecraft.item.ItemStack; | ||||
| import net.minecraft.util.ResourceLocation; | ||||
| import org.lwjgl.opengl.GL11; | ||||
| import org.lwjgl.opengl.GL12; | ||||
|  | ||||
| public abstract class Widget extends Gui | ||||
| { | ||||
| @@ -269,9 +266,8 @@ public abstract class Widget extends Gui | ||||
|         FontRenderer fontRenderer = mc.fontRendererObj; | ||||
|  | ||||
|         int width = 0; | ||||
|         for( int i=0; i<lines.length; ++i ) | ||||
|         for( String line : lines ) | ||||
|         { | ||||
|             String line = lines[i]; | ||||
|             width = Math.max( fontRenderer.getStringWidth( line ), width ); | ||||
|         } | ||||
|         int startX = x + 12; | ||||
|   | ||||
| @@ -48,10 +48,10 @@ public class WidgetContainer extends Widget | ||||
| 	@Override | ||||
| 	public void update() | ||||
| 	{ | ||||
| 		for( int i=0; i<m_widgets.size(); ++i ) | ||||
| 		{ | ||||
| 			m_widgets.get( i ).update(); | ||||
| 		} | ||||
|         for( Widget m_widget : m_widgets ) | ||||
|         { | ||||
|             m_widget.update(); | ||||
|         } | ||||
| 		if( m_modalWidget != null ) | ||||
| 		{ | ||||
| 			m_modalWidget.update(); | ||||
| @@ -61,20 +61,19 @@ public class WidgetContainer extends Widget | ||||
| 	@Override | ||||
| 	public void draw( Minecraft mc, int xOrigin, int yOrigin, int mouseX, int mouseY ) | ||||
| 	{ | ||||
| 		for( int i=0; i<m_widgets.size(); ++i ) | ||||
| 		{ | ||||
| 			Widget widget = m_widgets.get( i ); | ||||
| 			if( widget.isVisible() ) | ||||
| 			{ | ||||
| 				widget.draw( | ||||
| 						mc, | ||||
| 						xOrigin + getXPosition(), | ||||
| 						yOrigin + getYPosition(), | ||||
| 						(m_modalWidget == null) ? (mouseX - getXPosition()) : -99, | ||||
| 						(m_modalWidget == null) ? (mouseY - getYPosition()) : -99 | ||||
| 				); | ||||
| 			} | ||||
| 		} | ||||
|         for( Widget widget : m_widgets ) | ||||
|         { | ||||
|             if( widget.isVisible() ) | ||||
|             { | ||||
|                 widget.draw( | ||||
|                     mc, | ||||
|                     xOrigin + getXPosition(), | ||||
|                     yOrigin + getYPosition(), | ||||
|                     (m_modalWidget == null) ? (mouseX - getXPosition()) : -99, | ||||
|                     (m_modalWidget == null) ? (mouseY - getYPosition()) : -99 | ||||
|                 ); | ||||
|             } | ||||
|         } | ||||
| 		if( m_modalWidget != null ) | ||||
| 		{ | ||||
| 			if( m_modalWidget.isVisible() ) | ||||
| @@ -102,20 +101,19 @@ public class WidgetContainer extends Widget | ||||
| 	@Override | ||||
| 	public void drawForeground( Minecraft mc, int xOrigin, int yOrigin, int mouseX, int mouseY ) | ||||
| 	{ | ||||
| 		for( int i=0; i<m_widgets.size(); ++i ) | ||||
| 		{ | ||||
| 			Widget widget = m_widgets.get( i ); | ||||
| 			if( widget.isVisible() ) | ||||
| 			{ | ||||
| 				widget.drawForeground( | ||||
| 						mc, | ||||
| 						xOrigin + getXPosition(), | ||||
| 						yOrigin + getYPosition(), | ||||
| 						(m_modalWidget == null) ? (mouseX - getXPosition()) : -99, | ||||
| 						(m_modalWidget == null) ? (mouseY - getYPosition()) : -99 | ||||
| 				); | ||||
| 			} | ||||
| 		} | ||||
|         for( Widget widget : m_widgets ) | ||||
|         { | ||||
|             if( widget.isVisible() ) | ||||
|             { | ||||
|                 widget.drawForeground( | ||||
|                     mc, | ||||
|                     xOrigin + getXPosition(), | ||||
|                     yOrigin + getYPosition(), | ||||
|                     (m_modalWidget == null) ? (mouseX - getXPosition()) : -99, | ||||
|                     (m_modalWidget == null) ? (mouseY - getYPosition()) : -99 | ||||
|                 ); | ||||
|             } | ||||
|         } | ||||
|  | ||||
| 		if( m_modalWidget != null ) | ||||
| 		{ | ||||
| @@ -148,14 +146,13 @@ public class WidgetContainer extends Widget | ||||
| 		pos.y -= getYPosition(); | ||||
| 		if( m_modalWidget == null ) | ||||
| 		{ | ||||
| 			for( int i = 0; i < m_widgets.size(); ++i ) | ||||
| 			{ | ||||
| 				Widget widget = m_widgets.get( i ); | ||||
| 				if( widget.isVisible() ) | ||||
| 				{ | ||||
| 					widget.modifyMousePosition( pos ); | ||||
| 				} | ||||
| 			} | ||||
|             for( Widget widget : m_widgets ) | ||||
|             { | ||||
|                 if( widget.isVisible() ) | ||||
|                 { | ||||
|                     widget.modifyMousePosition( pos ); | ||||
|                 } | ||||
|             } | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| @@ -173,23 +170,22 @@ public class WidgetContainer extends Widget | ||||
| 	{ | ||||
| 		if( m_modalWidget == null ) | ||||
| 		{ | ||||
| 			for( int i = 0; i < m_widgets.size(); ++i ) | ||||
| 			{ | ||||
| 				Widget widget = m_widgets.get( i ); | ||||
| 				if( widget.isVisible() ) | ||||
| 				{ | ||||
| 					if( widget.suppressItemTooltips( | ||||
| 							mc, | ||||
| 							xOrigin + getXPosition(), | ||||
| 							yOrigin + getYPosition(), | ||||
| 							mouseX - getXPosition(), | ||||
| 							mouseY - getYPosition() | ||||
| 					) ) | ||||
| 					{ | ||||
| 						return true; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
|             for( Widget widget : m_widgets ) | ||||
|             { | ||||
|                 if( widget.isVisible() ) | ||||
|                 { | ||||
|                     if( widget.suppressItemTooltips( | ||||
|                         mc, | ||||
|                         xOrigin + getXPosition(), | ||||
|                         yOrigin + getYPosition(), | ||||
|                         mouseX - getXPosition(), | ||||
|                         mouseY - getYPosition() | ||||
|                     ) ) | ||||
|                     { | ||||
|                         return true; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| @@ -211,17 +207,16 @@ public class WidgetContainer extends Widget | ||||
| 	{ | ||||
| 		if( m_modalWidget == null ) | ||||
| 		{ | ||||
| 			for( int i = 0; i < m_widgets.size(); ++i ) | ||||
| 			{ | ||||
| 				Widget widget = m_widgets.get( i ); | ||||
| 				if( widget.isVisible() ) | ||||
| 				{ | ||||
| 					if( widget.suppressKeyPress( c, k ) ) | ||||
| 					{ | ||||
| 						return true; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
|             for( Widget widget : m_widgets ) | ||||
|             { | ||||
|                 if( widget.isVisible() ) | ||||
|                 { | ||||
|                     if( widget.suppressKeyPress( c, k ) ) | ||||
|                     { | ||||
|                         return true; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| @@ -241,17 +236,16 @@ public class WidgetContainer extends Widget | ||||
| 	{ | ||||
| 		if( m_modalWidget == null ) | ||||
| 		{ | ||||
| 			for( int i = 0; i < m_widgets.size(); ++i ) | ||||
| 			{ | ||||
| 				Widget widget = m_widgets.get( i ); | ||||
| 				if( widget.isVisible() ) | ||||
| 				{ | ||||
| 					widget.handleMouseInput( | ||||
| 							mouseX - getXPosition(), | ||||
| 							mouseY - getYPosition() | ||||
| 					); | ||||
| 				} | ||||
| 			} | ||||
|             for( Widget widget : m_widgets ) | ||||
|             { | ||||
|                 if( widget.isVisible() ) | ||||
|                 { | ||||
|                     widget.handleMouseInput( | ||||
|                         mouseX - getXPosition(), | ||||
|                         mouseY - getYPosition() | ||||
|                     ); | ||||
|                 } | ||||
|             } | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| @@ -270,14 +264,13 @@ public class WidgetContainer extends Widget | ||||
| 	{ | ||||
| 		if( m_modalWidget == null ) | ||||
| 		{ | ||||
| 			for( int i = 0; i < m_widgets.size(); ++i ) | ||||
| 			{ | ||||
| 				Widget widget = m_widgets.get( i ); | ||||
| 				if( widget.isVisible() ) | ||||
| 				{ | ||||
| 					widget.handleKeyboardInput(); | ||||
| 				} | ||||
| 			} | ||||
|             for( Widget widget : m_widgets ) | ||||
|             { | ||||
|                 if( widget.isVisible() ) | ||||
|                 { | ||||
|                     widget.handleKeyboardInput(); | ||||
|                 } | ||||
|             } | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| @@ -293,18 +286,17 @@ public class WidgetContainer extends Widget | ||||
| 	{ | ||||
| 		if( m_modalWidget == null ) | ||||
| 		{ | ||||
| 			for( int i = 0; i < m_widgets.size(); ++i ) | ||||
| 			{ | ||||
| 				Widget widget = m_widgets.get( i ); | ||||
| 				if( widget.isVisible() ) | ||||
| 				{ | ||||
| 					widget.mouseClicked( | ||||
| 							mouseX - getXPosition(), | ||||
| 							mouseY - getYPosition(), | ||||
| 							mouseButton | ||||
| 					); | ||||
| 				} | ||||
| 			} | ||||
|             for( Widget widget : m_widgets ) | ||||
|             { | ||||
|                 if( widget.isVisible() ) | ||||
|                 { | ||||
|                     widget.mouseClicked( | ||||
|                         mouseX - getXPosition(), | ||||
|                         mouseY - getYPosition(), | ||||
|                         mouseButton | ||||
|                     ); | ||||
|                 } | ||||
|             } | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| @@ -324,14 +316,13 @@ public class WidgetContainer extends Widget | ||||
| 	{ | ||||
| 		if( m_modalWidget == null ) | ||||
| 		{ | ||||
| 			for( int i = 0; i < m_widgets.size(); ++i ) | ||||
| 			{ | ||||
| 				Widget widget = m_widgets.get( i ); | ||||
| 				if( widget.isVisible() ) | ||||
| 				{ | ||||
| 					widget.keyTyped( c, k ); | ||||
| 				} | ||||
| 			} | ||||
|             for( Widget widget : m_widgets ) | ||||
|             { | ||||
|                 if( widget.isVisible() ) | ||||
|                 { | ||||
|                     widget.keyTyped( c, k ); | ||||
|                 } | ||||
|             } | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
|   | ||||
| @@ -49,7 +49,6 @@ import net.minecraftforge.client.event.RenderPlayerEvent; | ||||
| import net.minecraftforge.common.MinecraftForge; | ||||
| import net.minecraftforge.fml.client.FMLClientHandler; | ||||
| import net.minecraftforge.fml.client.registry.ClientRegistry; | ||||
| import net.minecraftforge.fml.common.FMLCommonHandler; | ||||
| import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||||
| import net.minecraftforge.fml.common.gameevent.TickEvent; | ||||
| import net.minecraftforge.fml.relauncher.Side; | ||||
| @@ -405,7 +404,7 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon | ||||
|                 { | ||||
|                     ComputerCraft.clientComputerRegistry.add( instanceID, new ClientComputer( instanceID ) ); | ||||
|                 } | ||||
|                 ComputerCraft.clientComputerRegistry.get( instanceID ).handlePacket( packet, (EntityPlayer) player ); | ||||
|                 ComputerCraft.clientComputerRegistry.get( instanceID ).handlePacket( packet, player ); | ||||
|                 break; | ||||
|             } | ||||
|             case ComputerCraftPacket.ComputerDeleted: | ||||
|   | ||||
| @@ -139,9 +139,8 @@ public class TurtleMultiModel implements IBakedModel | ||||
|         else | ||||
|         { | ||||
|             List<BakedQuad> output = new ArrayList<BakedQuad>( input.size() ); | ||||
|             for( int i=0; i<input.size(); ++i ) | ||||
|             for( BakedQuad quad : input ) | ||||
|             { | ||||
|                 BakedQuad quad = input.get( i ); | ||||
|                 output.add( transformQuad( quad, transform ) ); | ||||
|             } | ||||
|             return output; | ||||
|   | ||||
| @@ -26,8 +26,6 @@ import net.minecraft.item.ItemStack; | ||||
| import net.minecraft.util.EnumFacing; | ||||
| import net.minecraft.util.ResourceLocation; | ||||
| import net.minecraft.world.World; | ||||
| import net.minecraftforge.client.model.IModel; | ||||
| import net.minecraftforge.client.model.ISmartVariant; | ||||
| import org.apache.commons.lang3.tuple.Pair; | ||||
|  | ||||
| import javax.annotation.Nonnull; | ||||
|   | ||||
| @@ -157,9 +157,8 @@ public class HTTPAPI implements ILuaAPI | ||||
|     { | ||||
|         synchronized( m_httpRequests ) | ||||
|         { | ||||
|             Iterator<HTTPRequest> it = m_httpRequests.iterator(); | ||||
|             while( it.hasNext() ) { | ||||
|                 HTTPRequest r = it.next(); | ||||
|             for( HTTPRequest r : m_httpRequests ) | ||||
|             { | ||||
|                 r.cancel(); | ||||
|             } | ||||
|             m_httpRequests.clear(); | ||||
|   | ||||
| @@ -19,6 +19,8 @@ import java.util.Map; | ||||
| import java.util.regex.Pattern; | ||||
|  | ||||
| class HTTPRequestException extends Exception { | ||||
|     private static final long serialVersionUID = 7591208619422744652L; | ||||
|  | ||||
|     public HTTPRequestException( String s ) { | ||||
|         super( s ); | ||||
|     } | ||||
| @@ -49,9 +51,8 @@ public class HTTPRequest | ||||
|         boolean allowed = false; | ||||
|         String whitelistString = ComputerCraft.http_whitelist; | ||||
|         String[] allowedURLs = whitelistString.split( ";" ); | ||||
|         for( int i=0; i<allowedURLs.length; ++i ) | ||||
|         for( String allowedURL : allowedURLs ) | ||||
|         { | ||||
|             String allowedURL = allowedURLs[i]; | ||||
|             Pattern allowedURLPattern = Pattern.compile( "^\\Q" + allowedURL.replaceAll( "\\*", "\\\\E.*\\\\Q" ) + "\\E$" ); | ||||
|             if( allowedURLPattern.matcher( url.getHost() ).matches() ) | ||||
|             { | ||||
| @@ -274,7 +275,7 @@ public class HTTPRequest | ||||
|      | ||||
|     public BufferedReader getContents() | ||||
|     { | ||||
|         String result = null; | ||||
|         String result; | ||||
|         synchronized(m_lock) { | ||||
|             result = m_result; | ||||
|         } | ||||
|   | ||||
| @@ -89,9 +89,9 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange | ||||
|             m_attached = false; | ||||
|              | ||||
|             // Unmount everything the detach function forgot to do | ||||
|             Iterator<String> it = m_mounts.iterator(); | ||||
|             while( it.hasNext() ) { | ||||
|                 m_fileSystem.unmount( it.next() ); | ||||
|             for( String m_mount : m_mounts ) | ||||
|             { | ||||
|                 m_fileSystem.unmount( m_mount ); | ||||
|             } | ||||
|             m_mounts.clear(); | ||||
|         } | ||||
| @@ -133,7 +133,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange | ||||
|             } | ||||
|              | ||||
|             // Mount the location | ||||
|             String location = null; | ||||
|             String location; | ||||
|             synchronized( m_fileSystem ) | ||||
|             { | ||||
|                 location = findFreeLocation( desiredLoc ); | ||||
| @@ -168,7 +168,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange | ||||
|             } | ||||
|              | ||||
|             // Mount the location | ||||
|             String location = null; | ||||
|             String location; | ||||
|             synchronized( m_fileSystem ) | ||||
|             { | ||||
|                 location = findFreeLocation( desiredLoc ); | ||||
| @@ -470,7 +470,7 @@ public class PeripheralAPI implements ILuaAPI, IAPIEnvironment.IPeripheralChange | ||||
|                 int side = parseSide( args ); | ||||
|                 if( side >= 0 ) | ||||
|                 { | ||||
|                     PeripheralWrapper p = null; | ||||
|                     PeripheralWrapper p; | ||||
|                     synchronized( m_peripherals ) | ||||
|                     { | ||||
|                         p = m_peripherals[ side ]; | ||||
|   | ||||
| @@ -91,7 +91,7 @@ public class RedstoneAPI implements ILuaAPI | ||||
|                     throw new LuaException( "Expected string, boolean" ); | ||||
|                 } | ||||
|                 int side = parseSide( args ); | ||||
|                 boolean output = ((Boolean)args[1]).booleanValue(); | ||||
|                 boolean output = (Boolean) args[ 1 ]; | ||||
|                 m_environment.setOutput( side, output ? 15 : 0 ); | ||||
|                 return null; | ||||
|             } | ||||
|   | ||||
| @@ -163,7 +163,7 @@ public class TermAPI implements ILuaAPI | ||||
|                 { | ||||
|                     throw new LuaException( "Expected boolean" ); | ||||
|                 } | ||||
|                 boolean b = ((Boolean)args[0]).booleanValue(); | ||||
|                 boolean b = (Boolean) args[ 0 ]; | ||||
|                 synchronized( m_terminal ) | ||||
|                 { | ||||
|                     m_terminal.setCursorBlink( b ); | ||||
|   | ||||
| @@ -21,7 +21,6 @@ import dan200.computercraft.core.terminal.Terminal; | ||||
| import java.io.IOException; | ||||
| import java.io.InputStream; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Iterator; | ||||
| import java.util.List; | ||||
|  | ||||
| public class Computer | ||||
| @@ -370,10 +369,8 @@ public class Computer | ||||
|                 // Advance our APIs | ||||
|                 synchronized( m_apis ) | ||||
|                 { | ||||
|                     Iterator<ILuaAPI> it = m_apis.iterator(); | ||||
|                     while( it.hasNext() ) | ||||
|                     for(ILuaAPI api : m_apis) | ||||
|                     { | ||||
|                         ILuaAPI api = it.next(); | ||||
|                         api.advance( _dt ); | ||||
|                     } | ||||
|                 } | ||||
| @@ -628,10 +625,8 @@ public class Computer | ||||
|         ILuaMachine machine = new LuaJLuaMachine( this ); | ||||
|          | ||||
|         // Add the APIs | ||||
|         Iterator<ILuaAPI> it = m_apis.iterator(); | ||||
|         while( it.hasNext() ) | ||||
|         for(ILuaAPI api : m_apis) | ||||
|         { | ||||
|             ILuaAPI api = it.next(); | ||||
|             machine.addAPI( api ); | ||||
|             api.startup(); | ||||
|         } | ||||
| @@ -794,10 +789,8 @@ public class Computer | ||||
|                     // Shutdown our APIs | ||||
|                     synchronized( m_apis ) | ||||
|                     { | ||||
|                         Iterator<ILuaAPI> it = m_apis.iterator(); | ||||
|                         while( it.hasNext() ) | ||||
|                         for(ILuaAPI api : m_apis) | ||||
|                         { | ||||
|                             ILuaAPI api = it.next(); | ||||
|                             api.shutdown(); | ||||
|                         } | ||||
|                     } | ||||
|   | ||||
| @@ -84,9 +84,8 @@ public class ComboMount implements IMount | ||||
|         { | ||||
|             // We found multiple directories, so filter for duplicates | ||||
|             Set<String> seen = new HashSet<String>(); | ||||
|             for( int i=0; i<foundFiles.size(); ++i ) | ||||
|             for(String file : foundFiles) | ||||
|             { | ||||
|                 String file = foundFiles.get(i); | ||||
|                 if( seen.add( file ) ) | ||||
|                 { | ||||
|                     contents.add( file ); | ||||
|   | ||||
| @@ -261,9 +261,9 @@ public class FileMount implements IWritableMount | ||||
|         if( file.isDirectory() ) | ||||
|         { | ||||
|             String[] children = file.list(); | ||||
|             for( int i=0; i<children.length; i++ ) | ||||
|             for( String aChildren : children ) | ||||
|             { | ||||
|                 deleteRecursively( new File( file, children[i] ) ); | ||||
|                 deleteRecursively( new File( file, aChildren ) ); | ||||
|             } | ||||
|         } | ||||
|          | ||||
| @@ -376,9 +376,9 @@ public class FileMount implements IWritableMount | ||||
|         { | ||||
|             long size = MINIMUM_FILE_SIZE; | ||||
|             String[] contents = file.list(); | ||||
|             for( int i=0; i<contents.length; ++i ) | ||||
|             for( String content : contents ) | ||||
|             { | ||||
|                 size += measureUsedSpace( new File( file, contents[i] ) ); | ||||
|                 size += measureUsedSpace( new File( file, content ) ); | ||||
|             } | ||||
|             return size; | ||||
|         } | ||||
|   | ||||
| @@ -327,7 +327,7 @@ public class FileSystem | ||||
|             throw new NullPointerException(); | ||||
|         } | ||||
|         location = sanitizePath( location ); | ||||
|         if( location.indexOf( ".." ) != -1 ) { | ||||
|         if( location.contains( ".." ) ) { | ||||
|             throw new FileSystemException( "Cannot mount below the root" ); | ||||
|         }                     | ||||
|         mount( new MountWrapper( label, location, mount ) ); | ||||
| @@ -427,10 +427,10 @@ public class FileSystem | ||||
|         mount.list( path, list ); | ||||
|          | ||||
|         // Add any mounts that are mounted at this location | ||||
|         Iterator<MountWrapper> it = m_mounts.values().iterator(); | ||||
|         while( it.hasNext() ) { | ||||
|             MountWrapper otherMount = it.next(); | ||||
|             if( getDirectory( otherMount.getLocation() ).equals( path ) ) { | ||||
|         for( MountWrapper otherMount : m_mounts.values() ) | ||||
|         { | ||||
|             if( getDirectory( otherMount.getLocation() ).equals( path ) ) | ||||
|             { | ||||
|                 list.add( getName( otherMount.getLocation() ) ); | ||||
|             } | ||||
|         } | ||||
| @@ -445,9 +445,8 @@ public class FileSystem | ||||
|     private void findIn( String dir, List<String> matches, Pattern wildPattern ) throws FileSystemException | ||||
|     { | ||||
|         String[] list = list( dir ); | ||||
|         for( int i=0; i<list.length; ++i ) | ||||
|         for( String entry : list ) | ||||
|         { | ||||
|             String entry = list[i]; | ||||
|             String entryPath = dir.isEmpty() ? entry : (dir + "/" + entry); | ||||
|             if( wildPattern.matcher( entryPath ).matches() ) | ||||
|             { | ||||
| @@ -910,7 +909,7 @@ public class FileSystem | ||||
|             char c = path.charAt(i); | ||||
|             if( c >= 32 && Arrays.binarySearch( specialChars, c ) < 0 && (allowWildcards || c != '*') ) | ||||
|             { | ||||
|                 cleanName.append((char)c); | ||||
|                 cleanName.append( c ); | ||||
|             } | ||||
|         } | ||||
|         path = cleanName.toString(); | ||||
| @@ -918,30 +917,42 @@ public class FileSystem | ||||
|         // Collapse the string into its component parts, removing ..'s | ||||
|         String[] parts = path.split("/"); | ||||
|         Stack<String> outputParts = new Stack<String>(); | ||||
|         for( int n=0; n<parts.length; ++n ) { | ||||
|             String part = parts[n]; | ||||
|             if( part.length() == 0 || part.equals(".") ) | ||||
|         for( String part : parts ) | ||||
|         { | ||||
|             if( part.length() == 0 || part.equals( "." ) ) | ||||
|             { | ||||
|                 // . is redundant | ||||
|                 continue; | ||||
|             } else if( part.equals("..") || part.equals( "..." ) ) { | ||||
|             } | ||||
|             else if( part.equals( ".." ) || part.equals( "..." ) ) | ||||
|             { | ||||
|                 // .. or ... can cancel out the last folder entered | ||||
|                 if( !outputParts.empty() ) { | ||||
|                 if( !outputParts.empty() ) | ||||
|                 { | ||||
|                     String top = outputParts.peek(); | ||||
|                     if( !top.equals("..") ) { | ||||
|                     if( !top.equals( ".." ) ) | ||||
|                     { | ||||
|                         outputParts.pop(); | ||||
|                     } else { | ||||
|                         outputParts.push(".."); | ||||
|                     } | ||||
|                 } else { | ||||
|                     outputParts.push(".."); | ||||
|                     else | ||||
|                     { | ||||
|                         outputParts.push( ".." ); | ||||
|                     } | ||||
|                 } | ||||
|             } else if (part.length() >= 255) { | ||||
|                 else | ||||
|                 { | ||||
|                     outputParts.push( ".." ); | ||||
|                 } | ||||
|             } | ||||
|             else if( part.length() >= 255 ) | ||||
|             { | ||||
|                 // If part length > 255 and it is the last part | ||||
|                 outputParts.push( part.substring(0, 255) ); | ||||
|             } else { | ||||
|                 outputParts.push( part.substring( 0, 255 ) ); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 // Anything else we add to the stack | ||||
|                 outputParts.push(part); | ||||
|                 outputParts.push( part ); | ||||
|             } | ||||
|         } | ||||
|          | ||||
|   | ||||
| @@ -7,6 +7,8 @@ | ||||
| package dan200.computercraft.core.filesystem; | ||||
|  | ||||
| public class FileSystemException extends Exception { | ||||
|     private static final long serialVersionUID = -2500631644868104029L; | ||||
|  | ||||
|     FileSystemException( String s ) { | ||||
|         super( s ); | ||||
|     } | ||||
|   | ||||
| @@ -54,10 +54,7 @@ public class JarMount implements IMount | ||||
|          | ||||
|         public void list( List<String> contents ) | ||||
|         { | ||||
|             for( String child : m_children.keySet() ) | ||||
|             { | ||||
|                 contents.add( child ); | ||||
|             } | ||||
|             contents.addAll( m_children.keySet() ); | ||||
|         } | ||||
|                  | ||||
|         public void insertChild( FileInZip child ) | ||||
|   | ||||
| @@ -25,7 +25,6 @@ import javax.annotation.Nonnull; | ||||
| import java.io.*; | ||||
| import java.util.HashMap; | ||||
| import java.util.IdentityHashMap; | ||||
| import java.util.Iterator; | ||||
| import java.util.Map; | ||||
|  | ||||
| public class LuaJLuaMachine implements ILuaMachine | ||||
| @@ -129,9 +128,9 @@ public class LuaJLuaMachine implements ILuaMachine | ||||
|         // Add the methods of an API to the global table | ||||
|         LuaTable table = wrapLuaObject( api ); | ||||
|         String[] names = api.getNames(); | ||||
|         for( int i=0; i<names.length; ++i ) | ||||
|         for( String name : names ) | ||||
|         { | ||||
|             m_globals.set( names[i], table ); | ||||
|             m_globals.set( name, table ); | ||||
|         } | ||||
|     } | ||||
|      | ||||
| @@ -147,7 +146,7 @@ public class LuaJLuaMachine implements ILuaMachine | ||||
|         try | ||||
|         { | ||||
|             // Read the whole bios into a string | ||||
|             String biosText = null; | ||||
|             String biosText; | ||||
|             try | ||||
|             { | ||||
|                 InputStreamReader isr; | ||||
| @@ -336,7 +335,7 @@ public class LuaJLuaMachine implements ILuaMachine | ||||
|                     { | ||||
|                         tryAbort(); | ||||
|                         Object[] arguments = toObjects( _args, 1 ); | ||||
|                         Object[] results = null; | ||||
|                         Object[] results; | ||||
|                         try | ||||
|                         { | ||||
|                             results = apiObject.callMethod( new ILuaContext() { | ||||
| @@ -399,10 +398,7 @@ public class LuaJLuaMachine implements ILuaMachine | ||||
|                                                     Object[] eventArguments = new Object[ results.length + 2 ]; | ||||
|                                                     eventArguments[ 0 ] = taskID; | ||||
|                                                     eventArguments[ 1 ] = true; | ||||
|                                                     for( int i = 0; i < results.length; ++i ) | ||||
|                                                     { | ||||
|                                                         eventArguments[ i + 2 ] = results[ i ]; | ||||
|                                                     } | ||||
|                                                     System.arraycopy( results, 0, eventArguments, 2, results.length ); | ||||
|                                                     m_computer.queueEvent( "task_complete", eventArguments ); | ||||
|                                                 } | ||||
|                                                 else | ||||
| @@ -452,10 +448,7 @@ public class LuaJLuaMachine implements ILuaMachine | ||||
|                                                 if( (Boolean)response[ 2 ] ) | ||||
|                                                 { | ||||
|                                                     // Extract the return values from the event and return them | ||||
|                                                     for( int i = 0; i < returnValues.length; ++i ) | ||||
|                                                     { | ||||
|                                                         returnValues[ i ] = response[ i + 3 ]; | ||||
|                                                     } | ||||
|                                                     System.arraycopy( response, 3, returnValues, 0, returnValues.length ); | ||||
|                                                     return returnValues; | ||||
|                                                 } | ||||
|                                                 else | ||||
| @@ -510,7 +503,7 @@ public class LuaJLuaMachine implements ILuaMachine | ||||
|         } | ||||
|         else if( object instanceof Boolean ) | ||||
|         { | ||||
|             boolean b = ((Boolean)object).booleanValue(); | ||||
|             boolean b = (Boolean) object; | ||||
|             return LuaValue.valueOf( b ); | ||||
|         } | ||||
|         else if( object instanceof String ) | ||||
| @@ -538,10 +531,9 @@ public class LuaJLuaMachine implements ILuaMachine | ||||
|                 m_valuesInProgress.put( object, table ); | ||||
|  | ||||
|                 // Convert all keys | ||||
|                 Iterator it = ((Map)object).entrySet().iterator(); | ||||
|                 while( it.hasNext() ) | ||||
|                 for( Object o : ((Map) object).entrySet() ) | ||||
|                 { | ||||
|                     Map.Entry pair = (Map.Entry)it.next(); | ||||
|                     Map.Entry pair = (Map.Entry) o; | ||||
|                     LuaValue key = toValue( pair.getKey() ); | ||||
|                     LuaValue value = toValue( pair.getValue() ); | ||||
|                     if( !key.isnil() && !value.isnil() ) | ||||
|   | ||||
| @@ -6,7 +6,6 @@ | ||||
|  | ||||
| package dan200.computercraft.server.proxy; | ||||
|  | ||||
| import dan200.computercraft.ComputerCraft; | ||||
| import dan200.computercraft.shared.computer.blocks.TileComputer; | ||||
| import dan200.computercraft.shared.peripheral.diskdrive.TileDiskDrive; | ||||
| import dan200.computercraft.shared.peripheral.printer.TilePrinter; | ||||
|   | ||||
| @@ -10,7 +10,6 @@ import net.minecraft.block.Block; | ||||
| import net.minecraft.block.ITileEntityProvider; | ||||
| import net.minecraft.block.material.Material; | ||||
| import net.minecraft.block.state.IBlockState; | ||||
| import net.minecraft.enchantment.EnchantmentHelper; | ||||
| import net.minecraft.entity.Entity; | ||||
| import net.minecraft.entity.EntityLivingBase; | ||||
| import net.minecraft.entity.player.EntityPlayer; | ||||
| @@ -27,7 +26,6 @@ import net.minecraft.world.World; | ||||
|  | ||||
| import javax.annotation.Nonnull; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Iterator; | ||||
| import java.util.List; | ||||
|  | ||||
| public abstract class BlockGeneric extends Block implements | ||||
| @@ -97,10 +95,8 @@ public abstract class BlockGeneric extends Block implements | ||||
|         // Drop items | ||||
|         if( drops.size() > 0 ) | ||||
|         { | ||||
|             Iterator<ItemStack> it = drops.iterator(); | ||||
|             while( it.hasNext() ) | ||||
|             for (ItemStack item : drops) | ||||
|             { | ||||
|                 ItemStack item = it.next(); | ||||
|                 dropItem( world, pos, item ); | ||||
|             } | ||||
|         } | ||||
| @@ -272,10 +268,8 @@ public abstract class BlockGeneric extends Block implements | ||||
|             // Add collision bounds to list | ||||
|             if( collision.size() > 0 ) | ||||
|             { | ||||
|                 Iterator<AxisAlignedBB> it = collision.iterator(); | ||||
|                 while( it.hasNext() ) | ||||
|                 for (AxisAlignedBB localBounds : collision) | ||||
|                 { | ||||
|                     AxisAlignedBB localBounds = it.next(); | ||||
|                     addCollisionBoxToList( pos, bigBox, list, localBounds ); | ||||
|                 } | ||||
|             } | ||||
|   | ||||
| @@ -15,7 +15,6 @@ import net.minecraft.entity.player.EntityPlayer; | ||||
| import net.minecraft.item.ItemStack; | ||||
| import net.minecraft.nbt.NBTTagCompound; | ||||
| import net.minecraft.network.NetworkManager; | ||||
| import net.minecraft.network.Packet; | ||||
| import net.minecraft.network.play.server.SPacketUpdateTileEntity; | ||||
| import net.minecraft.tileentity.TileEntity; | ||||
| import net.minecraft.util.math.AxisAlignedBB; | ||||
|   | ||||
| @@ -21,7 +21,6 @@ import net.minecraft.command.ICommandManager; | ||||
| import net.minecraft.command.ICommandSender; | ||||
| import net.minecraft.server.MinecraftServer; | ||||
| import net.minecraft.util.math.BlockPos; | ||||
| import net.minecraft.util.ResourceLocation; | ||||
| import net.minecraft.world.World; | ||||
|  | ||||
| import javax.annotation.Nonnull; | ||||
| @@ -113,7 +112,7 @@ public class CommandAPI implements ILuaAPI | ||||
|         // Get the details of the block | ||||
|         IBlockState state = world.getBlockState( pos ); | ||||
|         Block block = state.getBlock(); | ||||
|         String name = ((ResourceLocation)Block.REGISTRY.getNameForObject( block )).toString(); | ||||
|         String name = Block.REGISTRY.getNameForObject( block ).toString(); | ||||
|         int metadata = block.getMetaFromState( state ); | ||||
|  | ||||
|         Map<Object, Object> table = new HashMap<Object, Object>(); | ||||
|   | ||||
| @@ -9,7 +9,6 @@ package dan200.computercraft.shared.computer.blocks; | ||||
| import dan200.computercraft.ComputerCraft; | ||||
| import dan200.computercraft.shared.computer.core.ComputerFamily; | ||||
| import dan200.computercraft.shared.computer.core.IComputer; | ||||
| import dan200.computercraft.shared.peripheral.common.TilePeripheralBase; | ||||
| import dan200.computercraft.shared.util.DirectionUtil; | ||||
| import net.minecraft.block.material.Material; | ||||
| import net.minecraft.block.properties.IProperty; | ||||
| @@ -34,7 +33,7 @@ public class BlockCommandComputer extends BlockComputerBase | ||||
|     public static class Properties | ||||
|     { | ||||
|         public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); | ||||
|         public static final PropertyEnum<ComputerState> STATE = PropertyEnum.<ComputerState>create("state", ComputerState.class); | ||||
|         public static final PropertyEnum<ComputerState> STATE = PropertyEnum.create("state", ComputerState.class); | ||||
|     } | ||||
|  | ||||
|     // Members | ||||
| @@ -77,7 +76,7 @@ public class BlockCommandComputer extends BlockComputerBase | ||||
|     @Override | ||||
|     public int getMetaFromState( IBlockState state ) | ||||
|     { | ||||
|         return ((EnumFacing)state.getValue( Properties.FACING )).getIndex(); | ||||
|         return state.getValue( Properties.FACING ).getIndex(); | ||||
|     } | ||||
|  | ||||
|     @Nonnull | ||||
|   | ||||
| @@ -36,7 +36,7 @@ public class BlockComputer extends BlockComputerBase | ||||
|     { | ||||
|         public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); | ||||
|         public static final PropertyBool ADVANCED = PropertyBool.create("advanced"); | ||||
|         public static final PropertyEnum<ComputerState> STATE = PropertyEnum.<ComputerState>create("state", ComputerState.class); | ||||
|         public static final PropertyEnum<ComputerState> STATE = PropertyEnum.create("state", ComputerState.class); | ||||
|     } | ||||
|  | ||||
|     // Members | ||||
| @@ -90,8 +90,8 @@ public class BlockComputer extends BlockComputerBase | ||||
|     @Override | ||||
|     public int getMetaFromState( IBlockState state ) | ||||
|     { | ||||
|         int meta = ((EnumFacing)state.getValue( Properties.FACING )).getIndex(); | ||||
|         if( (Boolean)state.getValue( Properties.ADVANCED ) ) | ||||
|         int meta = state.getValue( Properties.FACING ).getIndex(); | ||||
|         if( state.getValue( Properties.ADVANCED ) ) | ||||
|         { | ||||
|             meta += 8; | ||||
|         } | ||||
| @@ -153,7 +153,7 @@ public class BlockComputer extends BlockComputerBase | ||||
|     @Override | ||||
|     public ComputerFamily getFamily( IBlockState state ) | ||||
|     { | ||||
|         if( (Boolean)state.getValue( Properties.ADVANCED ) ) { | ||||
|         if( state.getValue( Properties.ADVANCED ) ) { | ||||
|             return ComputerFamily.Advanced; | ||||
|         } else { | ||||
|             return ComputerFamily.Normal; | ||||
|   | ||||
| @@ -22,7 +22,6 @@ import net.minecraft.util.*; | ||||
| import net.minecraft.world.World; | ||||
|  | ||||
| import javax.annotation.Nonnull; | ||||
| import javax.annotation.Nullable; | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
|  | ||||
| @@ -147,7 +146,7 @@ public class TileCommandComputer extends TileComputer | ||||
|     public EnumFacing getDirection() | ||||
|     { | ||||
|         IBlockState state = getBlockState(); | ||||
|         return (EnumFacing)state.getValue( BlockCommandComputer.Properties.FACING ); | ||||
|         return state.getValue( BlockCommandComputer.Properties.FACING ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
| @@ -87,7 +87,7 @@ public class TileComputer extends TileComputerBase | ||||
|     public EnumFacing getDirection() | ||||
|     { | ||||
|         IBlockState state = getBlockState(); | ||||
|         return (EnumFacing)state.getValue( BlockComputer.Properties.FACING ); | ||||
|         return state.getValue( BlockComputer.Properties.FACING ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
| @@ -10,7 +10,6 @@ import dan200.computercraft.ComputerCraft; | ||||
| import dan200.computercraft.api.filesystem.IMount; | ||||
| import dan200.computercraft.api.media.IMedia; | ||||
| import dan200.computercraft.shared.computer.core.ComputerFamily; | ||||
| import dan200.computercraft.shared.computer.core.ServerComputer; | ||||
| import net.minecraft.block.Block; | ||||
| import net.minecraft.entity.player.EntityPlayer; | ||||
| import net.minecraft.item.ItemBlock; | ||||
|   | ||||
| @@ -23,10 +23,7 @@ import net.minecraft.world.World; | ||||
|  | ||||
| import javax.annotation.Nonnull; | ||||
| import java.io.IOException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
| import java.util.Random; | ||||
|  | ||||
| public class ItemTreasureDisk extends Item | ||||
|     implements IMedia | ||||
|   | ||||
| @@ -85,7 +85,7 @@ public class DiskRecipe implements IRecipe | ||||
|         int[] var3 = new int[3]; | ||||
|         int var4 = 0; | ||||
|         int var5 = 0; | ||||
|         ItemDiskLegacy var6 = null; | ||||
|         ItemDiskLegacy var6; | ||||
|         int var7; | ||||
|         int var9; | ||||
|         float var10; | ||||
|   | ||||
| @@ -29,7 +29,7 @@ public class BlockCable extends BlockPeripheralBase | ||||
|  | ||||
|     public static class Properties | ||||
|     { | ||||
|         public static final PropertyEnum<BlockCableModemVariant> MODEM = PropertyEnum.<BlockCableModemVariant>create( "modem", BlockCableModemVariant.class ); | ||||
|         public static final PropertyEnum<BlockCableModemVariant> MODEM = PropertyEnum.create( "modem", BlockCableModemVariant.class ); | ||||
|         public static final PropertyBool CABLE = PropertyBool.create( "cable" ); | ||||
|         public static final PropertyBool NORTH = PropertyBool.create( "north" ); | ||||
|         public static final PropertyBool SOUTH = PropertyBool.create( "south" ); | ||||
| @@ -118,8 +118,8 @@ public class BlockCable extends BlockPeripheralBase | ||||
|     public int getMetaFromState( IBlockState state ) | ||||
|     { | ||||
|         int meta = 0; | ||||
|         boolean cable = (Boolean)state.getValue( Properties.CABLE ); | ||||
|         BlockCableModemVariant modem = (BlockCableModemVariant)state.getValue( Properties.MODEM ); | ||||
|         boolean cable = state.getValue( Properties.CABLE ); | ||||
|         BlockCableModemVariant modem = state.getValue( Properties.MODEM ); | ||||
|         if( cable && modem != BlockCableModemVariant.None ) | ||||
|         { | ||||
|             meta = 6 + modem.getFacing().getIndex(); | ||||
| @@ -164,11 +164,11 @@ public class BlockCable extends BlockPeripheralBase | ||||
|  | ||||
|     private boolean doesConnect( IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing dir ) | ||||
|     { | ||||
|         if( !((Boolean)state.getValue( Properties.CABLE )) ) | ||||
|         if( !state.getValue( Properties.CABLE ) ) | ||||
|         { | ||||
|             return false; | ||||
|         } | ||||
|         else if( ((BlockCableModemVariant)state.getValue( Properties.MODEM )).getFacing() == dir ) | ||||
|         else if( state.getValue( Properties.MODEM ).getFacing() == dir ) | ||||
|         { | ||||
|             return true; | ||||
|         } | ||||
| @@ -201,7 +201,7 @@ public class BlockCable extends BlockPeripheralBase | ||||
|             anim = 0; | ||||
|         } | ||||
|  | ||||
|         BlockCableModemVariant modem = ((BlockCableModemVariant)state.getValue( Properties.MODEM )); | ||||
|         BlockCableModemVariant modem = state.getValue( Properties.MODEM ); | ||||
|         if( modem != BlockCableModemVariant.None ) | ||||
|         { | ||||
|             modem = BlockCableModemVariant.values()[ | ||||
| @@ -228,8 +228,8 @@ public class BlockCable extends BlockPeripheralBase | ||||
|     @Override | ||||
|     public PeripheralType getPeripheralType( IBlockState state ) | ||||
|     { | ||||
|         boolean cable = (Boolean)state.getValue( Properties.CABLE ); | ||||
|         BlockCableModemVariant modem = (BlockCableModemVariant)state.getValue( Properties.MODEM ); | ||||
|         boolean cable = state.getValue( Properties.CABLE ); | ||||
|         BlockCableModemVariant modem = state.getValue( Properties.MODEM ); | ||||
|         if( cable && modem != BlockCableModemVariant.None ) | ||||
|         { | ||||
|             return PeripheralType.WiredModemWithCable; | ||||
|   | ||||
| @@ -37,7 +37,7 @@ public class BlockPeripheral extends BlockPeripheralBase | ||||
|     public static class Properties | ||||
|     { | ||||
|         public static final PropertyDirection FACING = PropertyDirection.create( "facing", EnumFacing.Plane.HORIZONTAL ); | ||||
|         public static final PropertyEnum<BlockPeripheralVariant> VARIANT = PropertyEnum.<BlockPeripheralVariant>create( "variant", BlockPeripheralVariant.class ); | ||||
|         public static final PropertyEnum<BlockPeripheralVariant> VARIANT = PropertyEnum.create( "variant", BlockPeripheralVariant.class ); | ||||
|     } | ||||
|  | ||||
|     public BlockPeripheral() | ||||
| @@ -115,12 +115,12 @@ public class BlockPeripheral extends BlockPeripheralBase | ||||
|     public int getMetaFromState( IBlockState state ) | ||||
|     { | ||||
|         int meta = 0; | ||||
|         BlockPeripheralVariant variant = (BlockPeripheralVariant)state.getValue( Properties.VARIANT ); | ||||
|         BlockPeripheralVariant variant = state.getValue( Properties.VARIANT ); | ||||
|         switch( variant.getPeripheralType() ) | ||||
|         { | ||||
|             case DiskDrive: | ||||
|             { | ||||
|                 EnumFacing dir = (EnumFacing)state.getValue( Properties.FACING ); | ||||
|                 EnumFacing dir = state.getValue( Properties.FACING ); | ||||
|                 if( dir.getAxis() == EnumFacing.Axis.Y ) { | ||||
|                     dir = EnumFacing.NORTH; | ||||
|                 } | ||||
| @@ -145,7 +145,7 @@ public class BlockPeripheral extends BlockPeripheralBase | ||||
|                     } | ||||
|                     default: | ||||
|                     { | ||||
|                         EnumFacing dir = (EnumFacing)state.getValue( Properties.FACING ); | ||||
|                         EnumFacing dir = state.getValue( Properties.FACING ); | ||||
|                         meta = dir.getIndex() + 4; | ||||
|                         break; | ||||
|                     } | ||||
| @@ -187,8 +187,8 @@ public class BlockPeripheral extends BlockPeripheralBase | ||||
|         else | ||||
|         { | ||||
|             anim = 0; | ||||
|             dir = (EnumFacing)state.getValue( Properties.FACING ); | ||||
|             switch( (BlockPeripheralVariant)state.getValue( BlockPeripheral.Properties.VARIANT ) ) | ||||
|             dir = state.getValue( Properties.FACING ); | ||||
|             switch( state.getValue( Properties.VARIANT ) ) | ||||
|             { | ||||
|                 case WirelessModemDownOff: | ||||
|                 case WirelessModemDownOn: | ||||
| @@ -503,7 +503,7 @@ public class BlockPeripheral extends BlockPeripheralBase | ||||
|     @Override | ||||
|     public PeripheralType getPeripheralType( IBlockState state ) | ||||
|     { | ||||
|         return ((BlockPeripheralVariant)state.getValue( Properties.VARIANT )).getPeripheralType(); | ||||
|         return state.getValue( Properties.VARIANT ).getPeripheralType(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
| @@ -13,7 +13,6 @@ import net.minecraft.block.Block; | ||||
| import net.minecraft.block.state.IBlockState; | ||||
| import net.minecraft.creativetab.CreativeTabs; | ||||
| import net.minecraft.entity.player.EntityPlayer; | ||||
| import net.minecraft.init.Blocks; | ||||
| import net.minecraft.item.Item; | ||||
| import net.minecraft.item.ItemStack; | ||||
| import net.minecraft.tileentity.TileEntity; | ||||
|   | ||||
| @@ -47,7 +47,7 @@ public class ContainerDiskDrive extends Container | ||||
|     public ItemStack transferStackInSlot( EntityPlayer player, int i ) | ||||
|     { | ||||
|         ItemStack itemstack = null; | ||||
|         Slot slot = (Slot)inventorySlots.get(i); | ||||
|         Slot slot = inventorySlots.get(i); | ||||
|         if(slot != null && slot.getHasStack()) | ||||
|         { | ||||
|             ItemStack itemstack1 = slot.getStack(); | ||||
|   | ||||
| @@ -17,13 +17,11 @@ import dan200.computercraft.shared.peripheral.common.BlockPeripheral; | ||||
| import dan200.computercraft.shared.peripheral.common.TilePeripheralBase; | ||||
| import dan200.computercraft.shared.util.InventoryUtil; | ||||
| import net.minecraft.block.state.IBlockState; | ||||
| import net.minecraft.client.audio.Sound; | ||||
| import net.minecraft.entity.item.EntityItem; | ||||
| import net.minecraft.entity.player.EntityPlayer; | ||||
| import net.minecraft.inventory.IInventory; | ||||
| import net.minecraft.item.ItemStack; | ||||
| import net.minecraft.nbt.NBTTagCompound; | ||||
| import net.minecraft.util.ITickable; | ||||
| import net.minecraft.util.*; | ||||
| import net.minecraft.util.math.*; | ||||
| import net.minecraft.util.text.*; | ||||
| @@ -31,7 +29,6 @@ import net.minecraft.world.World; | ||||
|  | ||||
| import javax.annotation.Nonnull; | ||||
| import java.util.HashMap; | ||||
| import java.util.Iterator; | ||||
| import java.util.Map; | ||||
| import java.util.Set; | ||||
|  | ||||
| @@ -121,7 +118,7 @@ public class TileDiskDrive extends TilePeripheralBase | ||||
|     public EnumFacing getDirection() | ||||
|     { | ||||
|         IBlockState state = getBlockState(); | ||||
|         return (EnumFacing)state.getValue( BlockPeripheral.Properties.FACING ); | ||||
|         return state.getValue( BlockPeripheral.Properties.FACING ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
| @@ -278,10 +275,8 @@ public class TileDiskDrive extends TilePeripheralBase | ||||
|             if( m_diskStack != null ) | ||||
|             { | ||||
|                 Set<IComputerAccess> computers = m_computers.keySet(); | ||||
|                 Iterator<IComputerAccess> it = computers.iterator(); | ||||
|                 while( it.hasNext() ) | ||||
|                 for( IComputerAccess computer : computers ) | ||||
|                 { | ||||
|                     IComputerAccess computer = it.next(); | ||||
|                     unmountDisk( computer ); | ||||
|                 } | ||||
|             } | ||||
| @@ -306,10 +301,8 @@ public class TileDiskDrive extends TilePeripheralBase | ||||
|             if( m_diskStack != null ) | ||||
|             { | ||||
|                 Set<IComputerAccess> computers = m_computers.keySet(); | ||||
|                 Iterator<IComputerAccess> it = computers.iterator(); | ||||
|                 while( it.hasNext() ) | ||||
|                 for( IComputerAccess computer : computers ) | ||||
|                 { | ||||
|                     IComputerAccess computer = it.next(); | ||||
|                     mountDisk( computer ); | ||||
|                 } | ||||
|             } | ||||
|   | ||||
| @@ -15,13 +15,10 @@ import net.minecraft.block.properties.PropertyBool; | ||||
| import net.minecraft.block.properties.PropertyDirection; | ||||
| import net.minecraft.block.state.BlockStateContainer; | ||||
| 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.world.IBlockAccess; | ||||
| import net.minecraft.world.World; | ||||
|  | ||||
| import javax.annotation.Nonnull; | ||||
|  | ||||
| @@ -87,7 +84,7 @@ public class BlockAdvancedModem extends BlockPeripheralBase | ||||
|         else | ||||
|         { | ||||
|             anim = 0; | ||||
|             dir = (EnumFacing)state.getValue( Properties.FACING ); | ||||
|             dir = state.getValue( Properties.FACING ); | ||||
|         } | ||||
|  | ||||
|         state = state.withProperty( Properties.FACING, dir ); | ||||
|   | ||||
| @@ -15,7 +15,6 @@ import net.minecraft.world.World; | ||||
|  | ||||
| import javax.annotation.Nonnull; | ||||
| import java.util.HashMap; | ||||
| import java.util.Iterator; | ||||
| import java.util.Map; | ||||
|  | ||||
| public abstract class ModemPeripheral | ||||
| @@ -107,10 +106,9 @@ public abstract class ModemPeripheral | ||||
|             // Leave old network | ||||
|             if( m_network != null ) | ||||
|             { | ||||
|                 Iterator<IReceiver> it = m_channels.values().iterator(); | ||||
|                 while( it.hasNext() ) | ||||
|                 for( IReceiver iReceiver : m_channels.values() ) | ||||
|                 { | ||||
|                     m_network.removeReceiver( it.next() ); | ||||
|                     m_network.removeReceiver( iReceiver ); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
| @@ -120,10 +118,9 @@ public abstract class ModemPeripheral | ||||
|             // Join new network | ||||
|             if( m_network != null ) | ||||
|             { | ||||
|                 Iterator<IReceiver> it = m_channels.values().iterator(); | ||||
|                 while( it.hasNext() ) | ||||
|                 for( IReceiver iReceiver : m_channels.values() ) | ||||
|                 { | ||||
|                     m_network.addReceiver( it.next() ); | ||||
|                     m_network.addReceiver( iReceiver ); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| @@ -315,10 +312,9 @@ public abstract class ModemPeripheral | ||||
|                     { | ||||
|                         if( m_network != null ) | ||||
|                         { | ||||
|                             Iterator<IReceiver> it = m_channels.values().iterator(); | ||||
|                             while( it.hasNext() ) | ||||
|                             for( IReceiver iReceiver : m_channels.values() ) | ||||
|                             { | ||||
|                                 m_network.removeReceiver( it.next() ); | ||||
|                                 m_network.removeReceiver( iReceiver ); | ||||
|                             } | ||||
|                         } | ||||
|                         m_channels.clear(); | ||||
| @@ -381,10 +377,9 @@ public abstract class ModemPeripheral | ||||
|     { | ||||
|         if( m_network != null ) | ||||
|         { | ||||
|             Iterator<IReceiver> it = m_channels.values().iterator(); | ||||
|             while( it.hasNext() ) | ||||
|             for( IReceiver iReceiver : m_channels.values() ) | ||||
|             { | ||||
|                 m_network.removeReceiver( it.next() ); | ||||
|                 m_network.removeReceiver( iReceiver ); | ||||
|             } | ||||
|             m_channels.clear(); | ||||
|             m_network = null; | ||||
|   | ||||
| @@ -7,7 +7,6 @@ | ||||
| package dan200.computercraft.shared.peripheral.modem; | ||||
|  | ||||
| import dan200.computercraft.api.peripheral.IPeripheral; | ||||
| import dan200.computercraft.shared.peripheral.common.BlockPeripheral; | ||||
| import net.minecraft.block.state.IBlockState; | ||||
| import net.minecraft.util.math.BlockPos; | ||||
| import net.minecraft.util.EnumFacing; | ||||
| @@ -64,7 +63,7 @@ public class TileAdvancedModem extends TileModemBase | ||||
|     { | ||||
|         // Wireless Modem | ||||
|         IBlockState state = getBlockState(); | ||||
|         return (EnumFacing)state.getValue( BlockAdvancedModem.Properties.FACING ); | ||||
|         return state.getValue( BlockAdvancedModem.Properties.FACING ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
| @@ -26,9 +26,11 @@ import net.minecraft.entity.player.EntityPlayer; | ||||
| import net.minecraft.item.ItemStack; | ||||
| import net.minecraft.nbt.NBTTagCompound; | ||||
| import net.minecraft.tileentity.TileEntity; | ||||
| import net.minecraft.util.*; | ||||
| import net.minecraft.util.math.*; | ||||
| import net.minecraft.util.text.*; | ||||
| import net.minecraft.util.EnumFacing; | ||||
| import net.minecraft.util.math.AxisAlignedBB; | ||||
| import net.minecraft.util.math.BlockPos; | ||||
| import net.minecraft.util.math.Vec3d; | ||||
| import net.minecraft.util.text.TextComponentTranslation; | ||||
| import net.minecraft.world.World; | ||||
|  | ||||
| import javax.annotation.Nonnull; | ||||
| @@ -131,10 +133,8 @@ public class TileCable extends TileModemBase | ||||
|                     { | ||||
|                         int idx = 1; | ||||
|                         Map<Object,Object> table = new HashMap<Object,Object>(); | ||||
|                         Iterator<String> it = m_entity.m_peripheralWrappersByName.keySet().iterator(); | ||||
|                         while( it.hasNext() ) | ||||
|                         for( String name : m_entity.m_peripheralWrappersByName.keySet() ) | ||||
|                         { | ||||
|                             String name = it.next(); | ||||
|                             table.put( idx++, name ); | ||||
|                         } | ||||
|                         return new Object[] { table }; | ||||
| @@ -193,10 +193,8 @@ public class TileCable extends TileModemBase | ||||
|             super.attach( computer ); | ||||
|             synchronized( m_entity.m_peripheralsByName ) | ||||
|             { | ||||
|                 Iterator<String> it = m_entity.m_peripheralsByName.keySet().iterator(); | ||||
|                 while( it.hasNext() ) | ||||
|                 for (String periphName : m_entity.m_peripheralsByName.keySet()) | ||||
|                 { | ||||
|                     String periphName = it.next(); | ||||
|                     IPeripheral peripheral = m_entity.m_peripheralsByName.get( periphName ); | ||||
|                     if( peripheral != null ) | ||||
|                     { | ||||
| @@ -211,10 +209,8 @@ public class TileCable extends TileModemBase | ||||
|         { | ||||
|             synchronized( m_entity.m_peripheralsByName ) | ||||
|             { | ||||
|                 Iterator<String> it = m_entity.m_peripheralsByName.keySet().iterator(); | ||||
|                 while( it.hasNext() ) | ||||
|                 for (String periphName : m_entity.m_peripheralsByName.keySet()) | ||||
|                 { | ||||
|                     String periphName = it.next(); | ||||
|                     m_entity.detachPeripheral( periphName ); | ||||
|                 } | ||||
|             } | ||||
| @@ -281,7 +277,7 @@ public class TileCable extends TileModemBase | ||||
|     public EnumFacing getDirection() | ||||
|     { | ||||
|         IBlockState state = getBlockState(); | ||||
|         BlockCableModemVariant modem = (BlockCableModemVariant)state.getValue( BlockCable.Properties.MODEM ); | ||||
|         BlockCableModemVariant modem = state.getValue( BlockCable.Properties.MODEM ); | ||||
|         if( modem != BlockCableModemVariant.None ) | ||||
|         { | ||||
|             return modem.getFacing(); | ||||
| @@ -296,7 +292,7 @@ public class TileCable extends TileModemBase | ||||
|     public void setDirection( EnumFacing dir ) | ||||
|     { | ||||
|         IBlockState state = getBlockState(); | ||||
|         BlockCableModemVariant modem = ( BlockCableModemVariant )state.getValue( BlockCable.Properties.MODEM ); | ||||
|         BlockCableModemVariant modem = state.getValue( BlockCable.Properties.MODEM ); | ||||
|         if( modem != BlockCableModemVariant.None ) | ||||
|         { | ||||
|             setBlockState( state.withProperty( BlockCable.Properties.MODEM, BlockCableModemVariant.fromFacing( dir ) ) ); | ||||
| @@ -756,11 +752,9 @@ public class TileCable extends TileModemBase | ||||
|             Set<IReceiver> receivers = m_receivers.get( packet.channel ); | ||||
|             if( receivers != null ) | ||||
|             { | ||||
|                 Iterator<IReceiver> it = receivers.iterator(); | ||||
|                 while( it.hasNext() ) | ||||
|                 for( IReceiver receiver : receivers ) | ||||
|                 { | ||||
|                     IReceiver receiver = it.next(); | ||||
|                     receiver.receiveSameDimension( packet.replyChannel, packet.payload, (double)distanceTravelled, packet.senderObject ); | ||||
|                     receiver.receiveSameDimension( packet.replyChannel, packet.payload, (double) distanceTravelled, packet.senderObject ); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| @@ -920,10 +914,8 @@ public class TileCable extends TileModemBase | ||||
|             } | ||||
|  | ||||
|             // Attach all the new peripherals | ||||
|             Iterator<String> it2 = newPeripheralsByName.keySet().iterator(); | ||||
|             while( it2.hasNext() ) | ||||
|             for( String periphName : newPeripheralsByName.keySet() ) | ||||
|             { | ||||
|                 String periphName = it2.next(); | ||||
|                 if( !m_peripheralsByName.containsKey( periphName ) ) | ||||
|                 { | ||||
|                     IPeripheral peripheral = newPeripheralsByName.get( periphName ); | ||||
|   | ||||
| @@ -69,7 +69,7 @@ public class TileWirelessModem extends TileModemBase | ||||
|     { | ||||
|         // Wireless Modem | ||||
|         IBlockState state = getBlockState(); | ||||
|         switch( (BlockPeripheralVariant)state.getValue( BlockPeripheral.Properties.VARIANT ) ) | ||||
|         switch( state.getValue( BlockPeripheral.Properties.VARIANT ) ) | ||||
|         { | ||||
|             case WirelessModemDownOff: | ||||
|             case WirelessModemDownOn: | ||||
| @@ -83,7 +83,7 @@ public class TileWirelessModem extends TileModemBase | ||||
|             } | ||||
|             default: | ||||
|             { | ||||
|                 return (EnumFacing)state.getValue( BlockPeripheral.Properties.FACING ); | ||||
|                 return state.getValue( BlockPeripheral.Properties.FACING ); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -66,10 +66,8 @@ public class WirelessNetwork implements INetwork | ||||
|         Set<IReceiver> receivers = m_receivers.get( channel ); | ||||
|         if( receivers != null ) | ||||
|         { | ||||
|             Iterator<IReceiver> it = receivers.iterator(); | ||||
|             while( it.hasNext() ) | ||||
|             for( IReceiver receiver : receivers ) | ||||
|             { | ||||
|                 IReceiver receiver = it.next(); | ||||
|                 tryTransmit( receiver, replyChannel, payload, world, pos, range, interdimensional, senderObject ); | ||||
|             } | ||||
|         } | ||||
|   | ||||
| @@ -111,7 +111,7 @@ public class MonitorPeripheral implements IPeripheral | ||||
|                     throw new LuaException( "Expected boolean" ); | ||||
|                 } | ||||
|                 Terminal terminal = m_monitor.getTerminal().getTerminal(); | ||||
|                 terminal.setCursorBlink( ((Boolean)args[0]).booleanValue() ); | ||||
|                 terminal.setCursorBlink( (Boolean) args[ 0 ] ); | ||||
|                 return null; | ||||
|             } | ||||
|             case 4: | ||||
|   | ||||
| @@ -77,9 +77,9 @@ public class ContainerPrinter extends Container | ||||
|         if( !m_printer.getWorld().isRemote ) | ||||
|         { | ||||
|             boolean printing = m_printer.isPrinting(); | ||||
|             for (int i=0; i<listeners.size(); ++i) | ||||
|             for( IContainerListener listener : listeners ) | ||||
|             { | ||||
|                 IContainerListener icrafting = (IContainerListener)listeners.get(i); | ||||
|                 IContainerListener icrafting = listener; | ||||
|                 if( printing != m_lastPrinting ) | ||||
|                 { | ||||
|                     icrafting.sendProgressBarUpdate( this, 0, printing ? 1 : 0 ); | ||||
| @@ -108,7 +108,7 @@ public class ContainerPrinter extends Container | ||||
|     public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) | ||||
|     { | ||||
|         ItemStack itemstack = null; | ||||
|         Slot slot = (Slot)inventorySlots.get(i); | ||||
|         Slot slot = inventorySlots.get(i); | ||||
|         if( slot != null && slot.getHasStack() ) | ||||
|         { | ||||
|             ItemStack itemstack1 = slot.getStack(); | ||||
|   | ||||
| @@ -8,7 +8,6 @@ package dan200.computercraft.shared.proxy; | ||||
|  | ||||
| import dan200.computercraft.ComputerCraft; | ||||
| import dan200.computercraft.api.turtle.ITurtleUpgrade; | ||||
| import dan200.computercraft.api.turtle.TurtleUpgradeType; | ||||
| import dan200.computercraft.shared.computer.core.ComputerFamily; | ||||
| import dan200.computercraft.shared.computer.items.ComputerItemFactory; | ||||
| import dan200.computercraft.shared.turtle.blocks.BlockTurtle; | ||||
| @@ -177,23 +176,23 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy | ||||
|         { | ||||
|             boolean captured = ObfuscationReflectionHelper.<Boolean, Entity>getPrivateValue( | ||||
|                 Entity.class, | ||||
|                 entity,  | ||||
|                 entity, | ||||
|                 "captureDrops" | ||||
|             ).booleanValue(); | ||||
|             ); | ||||
|              | ||||
|             if( !captured ) | ||||
|             { | ||||
|                 ObfuscationReflectionHelper.setPrivateValue( | ||||
|                         Entity.class, | ||||
|                         entity, | ||||
|                         new Boolean( true ), | ||||
|                         "captureDrops" | ||||
|                     Entity.class, | ||||
|                     entity, | ||||
|                     Boolean.TRUE, | ||||
|                     "captureDrops" | ||||
|                 ); | ||||
|                  | ||||
|                 ArrayList<EntityItem> items = ObfuscationReflectionHelper.getPrivateValue( | ||||
|                         Entity.class, | ||||
|                         entity, | ||||
|                         "capturedDrops" | ||||
|                     Entity.class, | ||||
|                     entity, | ||||
|                     "capturedDrops" | ||||
|                 ); | ||||
|                  | ||||
|                 if( items == null || items.size() == 0 ) | ||||
| @@ -219,15 +218,15 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy | ||||
|             { | ||||
|                 ObfuscationReflectionHelper.setPrivateValue( | ||||
|                     Entity.class, | ||||
|                     entity,  | ||||
|                     new Boolean( false ), | ||||
|                     entity, | ||||
|                     Boolean.FALSE, | ||||
|                     "captureDrops" | ||||
|                 ); | ||||
|                  | ||||
|                 ArrayList<EntityItem> items = ObfuscationReflectionHelper.getPrivateValue( | ||||
|                         Entity.class, | ||||
|                         entity, | ||||
|                         "capturedDrops" | ||||
|                     Entity.class, | ||||
|                     entity, | ||||
|                     "capturedDrops" | ||||
|                 ); | ||||
|                  | ||||
|                 if( items != null ) | ||||
| @@ -437,10 +436,8 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy | ||||
|         if( consumer != null ) | ||||
|         { | ||||
|             // All checks have passed, lets dispatch the drops | ||||
|             Iterator<EntityItem> it = drops.iterator(); | ||||
|             while( it.hasNext() ) | ||||
|             for(EntityItem entityItem : drops) | ||||
|             { | ||||
|                 EntityItem entityItem = (EntityItem)it.next(); | ||||
|                 consumer.consumeDrop( entity, entityItem.getEntityItem() ); | ||||
|             } | ||||
|             drops.clear(); | ||||
|   | ||||
| @@ -17,7 +17,6 @@ import dan200.computercraft.core.apis.ILuaAPI; | ||||
| import dan200.computercraft.shared.turtle.core.*; | ||||
| import net.minecraft.item.Item; | ||||
| import net.minecraft.item.ItemStack; | ||||
| import net.minecraft.util.ResourceLocation; | ||||
|  | ||||
| import javax.annotation.Nonnull; | ||||
| import java.util.HashMap; | ||||
| @@ -480,7 +479,7 @@ public class TurtleAPI implements ILuaAPI | ||||
|                 if( stack != null && stack.stackSize > 0 ) | ||||
|                 { | ||||
|                     Item item = stack.getItem(); | ||||
|                     String name = ((ResourceLocation)Item.REGISTRY.getNameForObject( item )).toString(); | ||||
|                     String name = Item.REGISTRY.getNameForObject( item ).toString(); | ||||
|                     int damage = stack.getItemDamage(); | ||||
|                     int count = stack.stackSize; | ||||
|  | ||||
|   | ||||
| @@ -8,14 +8,11 @@ package dan200.computercraft.shared.turtle.blocks; | ||||
|  | ||||
| import dan200.computercraft.ComputerCraft; | ||||
| import dan200.computercraft.shared.computer.blocks.BlockComputerBase; | ||||
| import dan200.computercraft.shared.computer.blocks.TileCommandComputer; | ||||
| import dan200.computercraft.shared.computer.blocks.TileComputerBase; | ||||
| import dan200.computercraft.shared.computer.core.ComputerFamily; | ||||
| import dan200.computercraft.shared.util.DirectionUtil; | ||||
| import net.minecraft.block.material.Material; | ||||
| import net.minecraft.block.properties.IProperty; | ||||
| import net.minecraft.block.properties.PropertyDirection; | ||||
| import net.minecraft.block.properties.PropertyEnum; | ||||
| import net.minecraft.block.state.BlockStateContainer; | ||||
| import net.minecraft.block.state.IBlockState; | ||||
| import net.minecraft.entity.EntityLivingBase; | ||||
|   | ||||
| @@ -10,7 +10,6 @@ import dan200.computercraft.ComputerCraft; | ||||
| import dan200.computercraft.api.turtle.ITurtleAccess; | ||||
| import dan200.computercraft.api.turtle.ITurtleUpgrade; | ||||
| import dan200.computercraft.api.turtle.TurtleSide; | ||||
| import dan200.computercraft.api.turtle.TurtleUpgradeType; | ||||
| import dan200.computercraft.shared.computer.blocks.TileComputerBase; | ||||
| import dan200.computercraft.shared.computer.core.ComputerFamily; | ||||
| import dan200.computercraft.shared.computer.core.IComputer; | ||||
| @@ -28,7 +27,6 @@ import net.minecraft.inventory.IInventory; | ||||
| import net.minecraft.item.ItemStack; | ||||
| import net.minecraft.nbt.NBTTagCompound; | ||||
| import net.minecraft.nbt.NBTTagList; | ||||
| import net.minecraft.util.ITickable; | ||||
| import net.minecraft.util.*; | ||||
| import net.minecraft.util.math.*; | ||||
| import net.minecraft.util.text.*; | ||||
|   | ||||
| @@ -28,7 +28,6 @@ import net.minecraft.nbt.NBTTagCompound; | ||||
| import net.minecraft.tileentity.TileEntity; | ||||
| import net.minecraft.util.*; | ||||
| import net.minecraft.util.math.*; | ||||
| import net.minecraft.util.text.*; | ||||
| import net.minecraft.world.World; | ||||
| import net.minecraftforge.common.util.Constants; | ||||
|  | ||||
| @@ -335,11 +334,11 @@ public class TurtleBrain implements ITurtleAccess | ||||
|         // Write NBT | ||||
|         if( m_upgradeNBTData.containsKey( TurtleSide.Left ) ) | ||||
|         { | ||||
|             nbttagcompound.setTag( "leftUpgradeNBT", (NBTTagCompound) getUpgradeNBTData( TurtleSide.Left ).copy() ); | ||||
|             nbttagcompound.setTag( "leftUpgradeNBT", getUpgradeNBTData( TurtleSide.Left ).copy() ); | ||||
|         } | ||||
|         if( m_upgradeNBTData.containsKey( TurtleSide.Right ) ) | ||||
|         { | ||||
|             nbttagcompound.setTag( "rightUpgradeNBT", (NBTTagCompound) getUpgradeNBTData( TurtleSide.Right ).copy() ); | ||||
|             nbttagcompound.setTag( "rightUpgradeNBT", getUpgradeNBTData( TurtleSide.Right ).copy() ); | ||||
|         } | ||||
|  | ||||
|         return nbttagcompound; | ||||
| @@ -371,11 +370,11 @@ public class TurtleBrain implements ITurtleAccess | ||||
|         // NBT | ||||
|         if( m_upgradeNBTData.containsKey( TurtleSide.Left ) ) | ||||
|         { | ||||
|             nbttagcompound.setTag( "leftUpgradeNBT", (NBTTagCompound) getUpgradeNBTData( TurtleSide.Left ).copy() ); | ||||
|             nbttagcompound.setTag( "leftUpgradeNBT", getUpgradeNBTData( TurtleSide.Left ).copy() ); | ||||
|         } | ||||
|         if( m_upgradeNBTData.containsKey( TurtleSide.Right ) ) | ||||
|         { | ||||
|             nbttagcompound.setTag( "rightUpgradeNBT", (NBTTagCompound) getUpgradeNBTData( TurtleSide.Right ).copy() ); | ||||
|             nbttagcompound.setTag( "rightUpgradeNBT", getUpgradeNBTData( TurtleSide.Right ).copy() ); | ||||
|         } | ||||
|  | ||||
|         // Colour | ||||
| @@ -738,10 +737,7 @@ public class TurtleBrain implements ITurtleAccess | ||||
|                 if( ( (Number) response[ 1 ] ).intValue() == commandID ) | ||||
|                 { | ||||
|                     Object[] returnValues = new Object[ response.length - 2 ]; | ||||
|                     for( int i = 0; i < returnValues.length; ++i ) | ||||
|                     { | ||||
|                         returnValues[ i ] = response[ i + 2 ]; | ||||
|                     } | ||||
|                     System.arraycopy( response, 2, returnValues, 0, returnValues.length ); | ||||
|                     return returnValues; | ||||
|                 } | ||||
|             } | ||||
| @@ -1033,10 +1029,7 @@ public class TurtleBrain implements ITurtleAccess | ||||
|                                 Object[] arguments = new Object[ results.length + 2 ]; | ||||
|                                 arguments[0] = callbackID; | ||||
|                                 arguments[1] = true; | ||||
|                                 for( int i=0; i<results.length; ++i ) | ||||
|                                 { | ||||
|                                     arguments[2+i] = results[i]; | ||||
|                                 } | ||||
|                                 System.arraycopy( results, 0, arguments, 2, results.length ); | ||||
|                                 computer.queueEvent( "turtle_response", arguments ); | ||||
|                             } | ||||
|                             else | ||||
| @@ -1140,16 +1133,16 @@ public class TurtleBrain implements ITurtleAccess | ||||
|                     } | ||||
|  | ||||
|                     AxisAlignedBB aabb = new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ); | ||||
|                     List list = world.getEntitiesWithinAABBExcludingEntity( (Entity)null, aabb ); | ||||
|                     List list = world.getEntitiesWithinAABBExcludingEntity( null, aabb ); | ||||
|                     if( !list.isEmpty() ) | ||||
|                     { | ||||
|                         double pushStep = 1.0f / (float) ANIM_DURATION; | ||||
|                         double pushStepX = (double) moveDir.getFrontOffsetX() * pushStep; | ||||
|                         double pushStepY = (double) moveDir.getFrontOffsetY() * pushStep; | ||||
|                         double pushStepZ = (double) moveDir.getFrontOffsetZ() * pushStep; | ||||
|                         for( int i = 0; i < list.size(); ++i ) | ||||
|                         for (Object aList : list) | ||||
|                         { | ||||
|                             Entity entity = (Entity) list.get( i ); | ||||
|                             Entity entity = (Entity) aList; | ||||
|                             entity.moveEntity( | ||||
|                                 pushStepX, pushStepY, pushStepZ | ||||
|                             ); | ||||
|   | ||||
| @@ -21,7 +21,6 @@ import net.minecraftforge.fml.relauncher.ReflectionHelper; | ||||
|  | ||||
| import javax.annotation.Nonnull; | ||||
| import java.lang.reflect.Method; | ||||
| import java.util.Iterator; | ||||
|  | ||||
| public class TurtleCompareCommand implements ITurtleCommand | ||||
| { | ||||
| @@ -84,10 +83,8 @@ public class TurtleCompareCommand implements ITurtleCommand | ||||
|                         java.util.List<ItemStack> drops = lookAtBlock.getDrops( world, newPosition, lookAtState, 0 ); | ||||
|                         if( drops != null && drops.size() > 0 ) | ||||
|                         { | ||||
|                             Iterator<ItemStack> it = drops.iterator(); | ||||
|                             while( it.hasNext() ) | ||||
|                             for( ItemStack drop : drops ) | ||||
|                             { | ||||
|                                 ItemStack drop = it.next(); | ||||
|                                 if( drop.getItem() == Item.getItemFromBlock( lookAtBlock ) ) | ||||
|                                 { | ||||
|                                     lookAtStack = drop; | ||||
|   | ||||
| @@ -38,9 +38,8 @@ public class TurtleCraftCommand implements ITurtleCommand | ||||
|         if( results != null ) | ||||
|         { | ||||
|             // Store the results | ||||
|             for( int i=0; i<results.size(); ++i ) | ||||
|             for( ItemStack stack : results ) | ||||
|             { | ||||
|                 ItemStack stack = results.get( i ); | ||||
|                 ItemStack remainder = InventoryUtil.storeItems( stack, turtle.getInventory(), 0, turtle.getInventory().getSizeInventory(), turtle.getSelectedSlot() ); | ||||
|                 if( remainder != null ) | ||||
|                 { | ||||
|   | ||||
| @@ -12,11 +12,8 @@ import dan200.computercraft.api.turtle.TurtleAnimation; | ||||
| import dan200.computercraft.api.turtle.TurtleCommandResult; | ||||
| import dan200.computercraft.shared.util.InventoryUtil; | ||||
| import dan200.computercraft.shared.util.WorldUtil; | ||||
| import net.minecraft.init.SoundEvents; | ||||
| import net.minecraft.inventory.IInventory; | ||||
| import net.minecraft.item.ItemStack; | ||||
| import net.minecraft.util.SoundCategory; | ||||
| import net.minecraft.util.SoundEvent; | ||||
| import net.minecraft.util.math.BlockPos; | ||||
| import net.minecraft.util.EnumFacing; | ||||
| import net.minecraft.world.World; | ||||
|   | ||||
| @@ -16,7 +16,6 @@ import net.minecraft.block.properties.IProperty; | ||||
| import net.minecraft.block.state.IBlockState; | ||||
| import net.minecraft.util.math.BlockPos; | ||||
| import net.minecraft.util.EnumFacing; | ||||
| import net.minecraft.util.ResourceLocation; | ||||
| import net.minecraft.world.World; | ||||
|  | ||||
| import javax.annotation.Nonnull; | ||||
| @@ -51,7 +50,7 @@ public class TurtleInspectCommand implements ITurtleCommand | ||||
|             { | ||||
|                 IBlockState state = world.getBlockState( newPosition ); | ||||
|                 Block block = state.getBlock(); | ||||
|                 String name = ((ResourceLocation)Block.REGISTRY.getNameForObject( block )).toString(); | ||||
|                 String name = Block.REGISTRY.getNameForObject( block ).toString(); | ||||
|                 int metadata = block.getMetaFromState( state ); | ||||
|  | ||||
|                 Map<Object, Object> table = new HashMap<Object, Object>(); | ||||
|   | ||||
| @@ -72,10 +72,10 @@ public class TurtleMoveCommand implements ITurtleCommand | ||||
|             if( ComputerCraft.turtlesCanPush && m_direction != MoveDirection.Up && m_direction != MoveDirection.Down ) | ||||
|             { | ||||
|                 // Check there is space for all the pushable entities to be pushed | ||||
|                 List list = oldWorld.getEntitiesWithinAABBExcludingEntity( (Entity)null, aabb ); | ||||
|                 for( int i=0; i<list.size(); ++i ) | ||||
|                 List list = oldWorld.getEntitiesWithinAABBExcludingEntity( null, aabb ); | ||||
|                 for( Object aList : list ) | ||||
|                 { | ||||
|                     Entity entity = (Entity)list.get( i ); | ||||
|                     Entity entity = (Entity) aList; | ||||
|                     if( !entity.isDead && entity.preventEntitySpawning ) | ||||
|                     { | ||||
|                         AxisAlignedBB entityBB = entity.getEntityBoundingBox(); | ||||
|   | ||||
| @@ -95,14 +95,14 @@ public class TurtleSuckCommand implements ITurtleCommand | ||||
|             { | ||||
|                 boolean foundItems = false; | ||||
|                 boolean storedItems = false; | ||||
|                 for( int i=0; i<list.size(); i++ ) | ||||
|                 for( Object aList : list ) | ||||
|                 { | ||||
|                     Entity entity = (Entity)list.get(i); | ||||
|                     Entity entity = (Entity) aList; | ||||
|                     if( entity != null && entity instanceof EntityItem && !entity.isDead ) | ||||
|                     { | ||||
|                         // Suck up the item | ||||
|                         foundItems = true; | ||||
|                         EntityItem entityItem = (EntityItem)entity; | ||||
|                         EntityItem entityItem = (EntityItem) entity; | ||||
|                         ItemStack stack = entityItem.getEntityItem().copy(); | ||||
|                         ItemStack storeStack; | ||||
|                         ItemStack leaveStack; | ||||
|   | ||||
| @@ -108,12 +108,11 @@ public class ContainerTurtle extends Container | ||||
|         super.detectAndSendChanges(); | ||||
|          | ||||
|         int selectedSlot = m_turtle.getSelectedSlot(); | ||||
|         for( int i=0; i<listeners.size(); ++i ) | ||||
|         for( IContainerListener listener : listeners ) | ||||
|         { | ||||
|             IContainerListener icrafting = (IContainerListener)listeners.get(i); | ||||
|             if( m_selectedSlot != selectedSlot ) | ||||
|             { | ||||
|                 icrafting.sendProgressBarUpdate( this, PROGRESS_ID_SELECTED_SLOT, selectedSlot ); | ||||
|                 listener.sendProgressBarUpdate( this, PROGRESS_ID_SELECTED_SLOT, selectedSlot ); | ||||
|             } | ||||
|         } | ||||
|         m_selectedSlot = selectedSlot; | ||||
| @@ -146,7 +145,7 @@ public class ContainerTurtle extends Container | ||||
|  | ||||
|     protected ItemStack tryItemMerge( EntityPlayer player, int slotNum, int firstSlot, int lastSlot, boolean reverse ) | ||||
|     { | ||||
|         Slot slot = (Slot)inventorySlots.get( slotNum ); | ||||
|         Slot slot = inventorySlots.get( slotNum ); | ||||
|         ItemStack originalStack = null; | ||||
|         if( slot != null && slot.getHasStack() ) | ||||
|         { | ||||
|   | ||||
| @@ -11,7 +11,6 @@ import dan200.computercraft.api.turtle.TurtleCommandResult; | ||||
| import dan200.computercraft.api.turtle.TurtleSide; | ||||
| import dan200.computercraft.api.turtle.TurtleVerb; | ||||
| import dan200.computercraft.shared.turtle.core.TurtlePlaceCommand; | ||||
| import net.minecraft.block.Block; | ||||
| import net.minecraft.block.material.Material; | ||||
| import net.minecraft.block.state.IBlockState; | ||||
| import net.minecraft.item.Item; | ||||
|   | ||||
| @@ -5,7 +5,6 @@ | ||||
|  */ | ||||
|  | ||||
| package dan200.computercraft.shared.turtle.upgrades; | ||||
| import net.minecraft.block.Block; | ||||
| import net.minecraft.block.material.Material; | ||||
| import net.minecraft.block.state.IBlockState; | ||||
| import net.minecraft.item.Item; | ||||
|   | ||||
| @@ -5,7 +5,6 @@ | ||||
|  */ | ||||
|  | ||||
| package dan200.computercraft.shared.turtle.upgrades; | ||||
| import net.minecraft.block.Block; | ||||
| import net.minecraft.block.material.Material; | ||||
| import net.minecraft.block.state.IBlockState; | ||||
| import net.minecraft.item.Item; | ||||
|   | ||||
| @@ -19,7 +19,6 @@ import net.minecraft.block.Block; | ||||
| import net.minecraft.block.state.IBlockState; | ||||
| import net.minecraft.client.Minecraft; | ||||
| import net.minecraft.client.renderer.block.model.IBakedModel; | ||||
| import net.minecraft.client.renderer.block.model.IBakedModel; | ||||
| import net.minecraft.entity.Entity; | ||||
| import net.minecraft.entity.SharedMonsterAttributes; | ||||
| import net.minecraft.entity.item.EntityArmorStand; | ||||
| @@ -37,7 +36,6 @@ import org.apache.commons.lang3.tuple.Pair; | ||||
|  | ||||
| import javax.annotation.Nonnull; | ||||
| import javax.vecmath.Matrix4f; | ||||
| import java.util.Iterator; | ||||
|  | ||||
| public class TurtleTool implements ITurtleUpgrade | ||||
| { | ||||
| @@ -271,10 +269,8 @@ public class TurtleTool implements ITurtleUpgrade | ||||
|                 java.util.List<ItemStack> items = getBlockDropped( world, newPosition ); | ||||
|                 if( items != null && items.size() > 0 ) | ||||
|                 { | ||||
|                     Iterator<ItemStack> it = items.iterator(); | ||||
|                     while( it.hasNext() ) | ||||
|                     for( ItemStack stack : items ) | ||||
|                     { | ||||
|                         ItemStack stack = it.next(); | ||||
|                         ItemStack remainder = InventoryUtil.storeItems( stack, turtle.getInventory(), 0, turtle.getInventory().getSizeInventory(), turtle.getSelectedSlot() ); | ||||
|                         if( remainder != null ) | ||||
|                         { | ||||
|   | ||||
| @@ -21,7 +21,7 @@ public class IDAssigner | ||||
|     private static int getNextID( File location, boolean directory ) | ||||
|     { | ||||
|         // Determine where to locate ID file | ||||
|         File lastidFile = null;     | ||||
|         File lastidFile; | ||||
|         if( directory ) | ||||
|         { | ||||
|             location.mkdirs(); | ||||
| @@ -41,12 +41,15 @@ public class IDAssigner | ||||
|             if( directory && location.exists() && location.isDirectory() ) | ||||
|             { | ||||
|                 String[] contents = location.list(); | ||||
|                 for( int i=0; i<contents.length; ++i ) | ||||
|                 for( String content : contents ) | ||||
|                 { | ||||
|                     try { | ||||
|                         int number = Integer.parseInt( contents[i] ); | ||||
|                     try | ||||
|                     { | ||||
|                         int number = Integer.parseInt( content ); | ||||
|                         id = Math.max( number + 1, id ); | ||||
|                     } catch( NumberFormatException e ) { | ||||
|                     } | ||||
|                     catch( NumberFormatException e ) | ||||
|                     { | ||||
|                         continue; | ||||
|                     } | ||||
|                 } | ||||
| @@ -55,7 +58,7 @@ public class IDAssigner | ||||
|         else | ||||
|         { | ||||
|             // If an ID file does exist, parse the file to get the ID string | ||||
|             String idString = "0"; | ||||
|             String idString; | ||||
|             try | ||||
|             { | ||||
|                 FileInputStream in = new FileInputStream( lastidFile ); | ||||
|   | ||||
| @@ -206,12 +206,11 @@ public class InventoryUtil | ||||
|  | ||||
|         // Inspect the slots in order and try to find empty or stackable slots | ||||
|         ItemStack remainder = stack; | ||||
|         for( int n=0; n<slots.length; ++n ) | ||||
|         for( int slot : slots ) | ||||
|         { | ||||
|             int slot = slots[n]; | ||||
|             if( canPlaceItemThroughFace( inventory, slot, remainder, face ) ) | ||||
|             { | ||||
|                 ItemStack slotContents = inventory.getStackInSlot(slot); | ||||
|                 ItemStack slotContents = inventory.getStackInSlot( slot ); | ||||
|                 if( slotContents == null ) | ||||
|                 { | ||||
|                     // Slot is empty | ||||
| @@ -286,9 +285,8 @@ public class InventoryUtil | ||||
|         // Combine multiple stacks from inventory into one if necessary | ||||
|         ItemStack partialStack = null; | ||||
|         int countRemaining = count; | ||||
|         for( int n=0; n<slots.length; ++n ) | ||||
|         for( int slot : slots ) | ||||
|         { | ||||
|             int slot = slots[n]; | ||||
|             if( countRemaining > 0 ) | ||||
|             { | ||||
|                 ItemStack stack = inventory.getStackInSlot( slot ); | ||||
|   | ||||
| @@ -20,7 +20,7 @@ public class NBTUtil | ||||
|         { | ||||
|             if( object instanceof Boolean ) | ||||
|             { | ||||
|                 boolean b = ((Boolean)object).booleanValue(); | ||||
|                 boolean b = (Boolean) object; | ||||
|                 return new NBTTagByte( b ? (byte)1 : (byte)0 ); | ||||
|             } | ||||
|             else if( object instanceof Number ) | ||||
|   | ||||
| @@ -35,11 +35,11 @@ public class ReflectionUtil | ||||
|                 Class[] declaredClasses = enclosingClass.getDeclaredClasses(); | ||||
|                 if( declaredClasses != null ) | ||||
|                 { | ||||
|                     for( int i=0; i<declaredClasses.length; ++i ) | ||||
|                     for( Class declaredClass : declaredClasses ) | ||||
|                     { | ||||
|                         if( declaredClasses[i].getSimpleName().equals( name ) ) | ||||
|                         if( declaredClass.getSimpleName().equals( name ) ) | ||||
|                         { | ||||
|                             return declaredClasses[i]; | ||||
|                             return declaredClass; | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|   | ||||
| @@ -6,8 +6,6 @@ | ||||
|  | ||||
| package dan200.computercraft.shared.util; | ||||
|  | ||||
| import net.minecraft.block.Block; | ||||
| import net.minecraft.block.state.IBlockState; | ||||
| import net.minecraft.entity.Entity; | ||||
| import net.minecraft.entity.item.EntityItem; | ||||
| import net.minecraft.item.ItemStack; | ||||
| @@ -63,9 +61,9 @@ public class WorldUtil | ||||
|         Entity closest = null; | ||||
|         double closestDist = 99.0; | ||||
|         List list = world.getEntitiesWithinAABBExcludingEntity( null, bigBox ); | ||||
|         for( int i=0; i<list.size(); i++ ) | ||||
|         for( Object aList : list ) | ||||
|         { | ||||
|             Entity entity = (net.minecraft.entity.Entity)list.get(i); | ||||
|             Entity entity = (Entity) aList; | ||||
|             if( entity.isDead || !entity.canBeCollidedWith() ) | ||||
|             { | ||||
|                 continue; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 SquidDev
					SquidDev