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