From c7bae7f448ad1e0591158918bbeebd4ba21ba661 Mon Sep 17 00:00:00 2001 From: thatsIch Date: Thu, 6 Nov 2014 22:08:14 +0100 Subject: [PATCH] Smash the typos --- src/api/java/appeng/api | 2 +- .../services/helpers/CompassRegion.java | 88 +++++++++++-------- 2 files changed, 54 insertions(+), 36 deletions(-) diff --git a/src/api/java/appeng/api b/src/api/java/appeng/api index bbe2ad8e..5dd2dd9d 160000 --- a/src/api/java/appeng/api +++ b/src/api/java/appeng/api @@ -1 +1 @@ -Subproject commit bbe2ad8e709a366faf34e6efac9aef37cb3d8013 +Subproject commit 5dd2dd9d4cf50eeeb1b6d57d4770cbff82ebe935 diff --git a/src/main/java/appeng/services/helpers/CompassRegion.java b/src/main/java/appeng/services/helpers/CompassRegion.java index dbc6a958..caa7ab7d 100644 --- a/src/main/java/appeng/services/helpers/CompassRegion.java +++ b/src/main/java/appeng/services/helpers/CompassRegion.java @@ -1,5 +1,24 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + package appeng.services.helpers; + import java.io.File; import java.io.RandomAccessFile; import java.nio.ByteBuffer; @@ -7,9 +26,9 @@ import java.nio.channels.FileChannel; import appeng.core.AELog; + public class CompassRegion { - final int low_x; final int low_z; @@ -17,31 +36,13 @@ public class CompassRegion final int hi_z; final int world; - - boolean hasFile = false; final File rootFolder; + boolean hasFile = false; RandomAccessFile raf = null; ByteBuffer buffer; - public void close() + public CompassRegion( int cx, int cz, int worldID, File rootFolder ) { - try - { - if ( hasFile ) - { - buffer = null; - raf.close(); - raf = null; - hasFile = false; - } - } - catch (Throwable t) - { - throw new CompassException( t ); - } - } - - public CompassRegion(int cx, int cz, int worldID, File rootFolder) { world = worldID; this.rootFolder = rootFolder; @@ -58,7 +59,25 @@ public class CompassRegion openFile( false ); } - public boolean hasBeacon(int cx, int cz) + public void close() + { + try + { + if ( hasFile ) + { + buffer = null; + raf.close(); + raf = null; + hasFile = false; + } + } + catch ( Throwable t ) + { + throw new CompassException( t ); + } + } + + public boolean hasBeacon( int cx, int cz ) { if ( hasFile ) { @@ -73,7 +92,7 @@ public class CompassRegion return false; } - public void setHasBeacon(int cx, int cz, int cdy, boolean hasBeacon) + public void setHasBeacon( int cx, int cz, int cdy, boolean hasBeacon ) { cx &= 0x3FF; cz &= 0x3FF; @@ -88,28 +107,28 @@ public class CompassRegion if ( hasBeacon ) val |= 1 << cdy; else - val &= ~(1 << cdy); + val &= ~( 1 << cdy ); if ( originalVal != val ) write( cx, cz, val ); } } - private void write(int cx, int cz, int val) + private void write( int cx, int cz, int val ) { try { - buffer.put( cx + cz * 0x400, (byte) val ); + buffer.put( cx + cz * 0x400, ( byte ) val ); // raf.seek( cx + cz * 0x400 ); // raf.writeByte( val ); } - catch (Throwable t) + catch ( Throwable t ) { throw new CompassException( t ); } } - private int read(int cx, int cz) + private int read( int cx, int cz ) { try { @@ -117,17 +136,17 @@ public class CompassRegion // raf.seek( cx + cz * 0x400 ); // return raf.readByte(); } - catch (IndexOutOfBoundsException outOfBounds) + catch ( IndexOutOfBoundsException outOfBounds ) { return 0; } - catch (Throwable t) + catch ( Throwable t ) { throw new CompassException( t ); } } - private void openFile(boolean create) + private void openFile( boolean create ) { File fName = getFileName(); if ( hasFile ) @@ -142,7 +161,7 @@ public class CompassRegion buffer = fc.map( FileChannel.MapMode.READ_WRITE, 0, 0x400 * 0x400 );// fc.size() ); hasFile = true; } - catch (Throwable t) + catch ( Throwable t ) { throw new CompassException( t ); } @@ -150,7 +169,7 @@ public class CompassRegion } - private boolean fileExists(File name) + private boolean fileExists( File name ) { return name.exists() && name.isFile(); } @@ -163,10 +182,9 @@ public class CompassRegion if ( !folderFile.exists() || !folderFile.isDirectory() ) { if ( !folderFile.mkdir() ) - AELog.info( "Failed to created AE2/compass/" ); + AELog.info( "Failed to create AE2/compass/" ); } return new File( folder + File.separatorChar + world + "_" + low_x + "_" + low_z + ".dat" ); } - }