Refactored the logging
Using LogManager instead of FMLRelaunchLog to access the logger instance. Added logging of the name of failed exports instead of exception. Improved crafting log to include issuer including their location and the requested item. Removed superfluous FMLRelaunchLog instance. Removed superfluous parameters for PlayerData constructor.
This commit is contained in:
parent
242c05266f
commit
02ac8cf220
|
@ -541,7 +541,7 @@ public class ClientHelper extends ServerHelper
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -413,7 +413,7 @@ public abstract class AEBaseGui extends GuiContainer
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
else if( slot instanceof SlotCraftingTerm )
|
||||
|
@ -782,7 +782,7 @@ public abstract class AEBaseGui extends GuiContainer
|
|||
}
|
||||
catch( final Exception err )
|
||||
{
|
||||
AELog.warning( "[AppEng] AE prevented crash while drawing slot: " + err.toString() );
|
||||
AELog.warn( "[AppEng] AE prevented crash while drawing slot: " + err.toString() );
|
||||
}
|
||||
this.setItemRender( pIR );
|
||||
return;
|
||||
|
@ -850,7 +850,7 @@ public abstract class AEBaseGui extends GuiContainer
|
|||
}
|
||||
catch( final Exception err )
|
||||
{
|
||||
AELog.error( err );
|
||||
AELog.debug( err );
|
||||
}
|
||||
}
|
||||
( (AppEngSlot) s ).setIsValid( isValid ? hasCalculatedValidness.Valid : hasCalculatedValidness.Invalid );
|
||||
|
@ -884,7 +884,7 @@ public abstract class AEBaseGui extends GuiContainer
|
|||
}
|
||||
catch( final Exception err )
|
||||
{
|
||||
AELog.warning( "[AppEng] AE prevented crash while drawing slot: " + err.toString() );
|
||||
AELog.warn( "[AppEng] AE prevented crash while drawing slot: " + err.toString() );
|
||||
}
|
||||
}
|
||||
// do the usual for non-ME Slots.
|
||||
|
|
|
@ -558,7 +558,7 @@ public class GuiCraftConfirm extends AEBaseGui
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -575,7 +575,7 @@ public class GuiCraftConfirm extends AEBaseGui
|
|||
}
|
||||
catch( final Throwable e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ public class GuiCraftingStatus extends GuiCraftingCPU
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -233,7 +233,7 @@ public class GuiLevelEmitter extends GuiUpgradeable
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,7 @@ public class GuiLevelEmitter extends GuiUpgradeable
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -199,7 +199,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ public class GuiNetworkTool extends AEBaseGui
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -240,7 +240,7 @@ public class GuiPriority extends AEBaseGui
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ public class GuiPriority extends AEBaseGui
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -85,7 +85,7 @@ public class GuiQuartzKnife extends AEBaseGui
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -90,7 +90,7 @@ public class GuiSecurity extends GuiMEMonitorable
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ public class GuiStorageBus extends GuiUpgradeable
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,9 +74,9 @@ public class TESRWrapper extends TileEntitySpecialRenderer
|
|||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
AELog.severe( "Hi, Looks like there was a crash while rendering something..." );
|
||||
AELog.error( "Hi, Looks like there was a crash while rendering something..." );
|
||||
t.printStackTrace();
|
||||
AELog.severe( "MC will now crash ( probably )!" );
|
||||
AELog.error( "MC will now crash ( probably )!" );
|
||||
throw new IllegalStateException( t );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,9 +87,9 @@ public final class WorldRender implements ISimpleBlockRenderingHandler
|
|||
if( !this.hasError )
|
||||
{
|
||||
this.hasError = true;
|
||||
AELog.severe( "Invalid render - item/block mismatch" );
|
||||
AELog.severe( " item: " + item.getUnlocalizedName() );
|
||||
AELog.severe( " block: " + blk.getUnlocalizedName() );
|
||||
AELog.error( "Invalid render - item/block mismatch" );
|
||||
AELog.error( " item: " + item.getUnlocalizedName() );
|
||||
AELog.error( " block: " + blk.getUnlocalizedName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ public class RenderBlockCharger extends BaseBlockRender<BlockCharger, TileCharge
|
|||
}
|
||||
catch( final Exception err )
|
||||
{
|
||||
AELog.error( err );
|
||||
AELog.debug( err );
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
|
|
@ -171,7 +171,7 @@ public class RenderBlockCraftingCPUMonitor extends RenderBlockCraftingCPU<BlockC
|
|||
}
|
||||
catch( final Exception e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
|
|
@ -307,7 +307,7 @@ public class RenderBlockInscriber extends BaseBlockRender<BlockInscriber, TileIn
|
|||
}
|
||||
catch( final Exception err )
|
||||
{
|
||||
AELog.error( err );
|
||||
AELog.debug( err );
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
|
|
@ -146,7 +146,7 @@ public abstract class AEBaseContainer extends Container
|
|||
final GuiSync annotation = f.getAnnotation( GuiSync.class );
|
||||
if( this.syncData.containsKey( annotation.value() ) )
|
||||
{
|
||||
AELog.warning( "Channel already in use: " + annotation.value() + " for " + f.getName() );
|
||||
AELog.warn( "Channel already in use: " + annotation.value() + " for " + f.getName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -208,7 +208,7 @@ public abstract class AEBaseContainer extends Container
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
|
||||
this.dataChunks.clear();
|
||||
|
@ -270,7 +270,7 @@ public abstract class AEBaseContainer extends Container
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1109,7 +1109,7 @@ public abstract class AEBaseContainer extends Container
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1178,7 +1178,7 @@ public abstract class AEBaseContainer extends Container
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,15 +70,15 @@ public class SyncData
|
|||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,11 +127,11 @@ public class SyncData
|
|||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,11 +143,11 @@ public class SyncData
|
|||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,11 +199,11 @@ public class SyncData
|
|||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -280,7 +280,7 @@ public class ContainerCraftConfirm extends AEBaseContainer
|
|||
catch( final Throwable e )
|
||||
{
|
||||
this.getPlayerInv().player.addChatMessage( new ChatComponentText( "Error: " + e.toString() ) );
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
this.setValidContainer( false );
|
||||
this.result = null;
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,7 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,12 @@
|
|||
package appeng.core;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.message.ParameterizedMessage;
|
||||
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
||||
|
@ -32,89 +35,354 @@ import appeng.util.Platform;
|
|||
|
||||
public final class AELog
|
||||
{
|
||||
private static final Logger SERVER = LogManager.getFormatterLogger( "AE2:S" );
|
||||
private static final Logger CLIENT = LogManager.getFormatterLogger( "AE2:C" );
|
||||
private static final String LOGGER_PREFIX = "AE2:";
|
||||
private static final String SERVER_SUFFIX = "S";
|
||||
private static final String CLIENT_SUFFIX = "C";
|
||||
|
||||
private static final Logger SERVER = LogManager.getFormatterLogger( LOGGER_PREFIX + SERVER_SUFFIX );
|
||||
private static final Logger CLIENT = LogManager.getFormatterLogger( LOGGER_PREFIX + CLIENT_SUFFIX );
|
||||
|
||||
private static final String BLOCK_UPDATE = "Block Update of %s @ ( %s )";
|
||||
|
||||
private static final String DEFAULT_EXCEPTION_MESSAGE = "Exception: ";
|
||||
|
||||
private AELog()
|
||||
{
|
||||
}
|
||||
|
||||
public static void warning( final String format, final Object... data )
|
||||
/**
|
||||
* Returns a {@link Logger} logger suitable for the effective side (client/server).
|
||||
*
|
||||
* @return a suitable logger instance
|
||||
*/
|
||||
private static Logger getLogger()
|
||||
{
|
||||
log( Level.WARN, format, data );
|
||||
return Platform.isServer() ? SERVER : CLIENT;
|
||||
}
|
||||
|
||||
private static void log( final Level level, final String format, final Object... data )
|
||||
/**
|
||||
* Indicates of the global log is enabled or disabled.
|
||||
*
|
||||
* By default it is enabled.
|
||||
*
|
||||
* @return true when the log is enabled.
|
||||
*/
|
||||
public static boolean isLogEnabled()
|
||||
{
|
||||
if( AEConfig.instance == null || AEConfig.instance.isFeatureEnabled( AEFeature.Logging ) )
|
||||
return AEConfig.instance == null || AEConfig.instance.isFeatureEnabled( AEFeature.Logging );
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a formatted message with a specific log level.
|
||||
*
|
||||
* This uses {@link String#format(String, Object...)} as opposed to the {@link ParameterizedMessage} to allow a more
|
||||
* flexible formatting.
|
||||
*
|
||||
* The output can be globally disabled via the configuration file.
|
||||
*
|
||||
* @param level the intended level.
|
||||
* @param message the message to be formatted.
|
||||
* @param params the parameters used for {@link String#format(String, Object...)}.
|
||||
*/
|
||||
public static void log( @Nonnull final Level level, @Nonnull final String message, final Object... params )
|
||||
{
|
||||
if( AELog.isLogEnabled() )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
SERVER.log( level, format, data );
|
||||
}
|
||||
else
|
||||
{
|
||||
CLIENT.log( level, format, data );
|
||||
}
|
||||
final String formattedMessage = String.format( message, params );
|
||||
final Logger logger = getLogger();
|
||||
|
||||
logger.log( level, formattedMessage );
|
||||
}
|
||||
}
|
||||
|
||||
public static void grinder( final String o )
|
||||
/**
|
||||
* Log an exception with a custom message formated via {@link String#format(String, Object...)}
|
||||
*
|
||||
* Similar to {@link AELog#log(Level, String, Object...)}.
|
||||
*
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
*
|
||||
* @param level the intended level.
|
||||
* @param exception
|
||||
* @param message the message to be formatted.
|
||||
* @param params the parameters used for {@link String#format(String, Object...)}.
|
||||
*/
|
||||
public static void log( @Nonnull final Level level, @Nonnull final Throwable exception, @Nonnull String message, final Object... params )
|
||||
{
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.GrinderLogging ) )
|
||||
if( AELog.isLogEnabled() )
|
||||
{
|
||||
log( Level.DEBUG, "grinder: " + o );
|
||||
final String formattedMessage = String.format( message, params );
|
||||
final Logger logger = getLogger();
|
||||
|
||||
logger.log( level, formattedMessage, exception );
|
||||
}
|
||||
}
|
||||
|
||||
public static void integration( final Throwable exception )
|
||||
/**
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param format
|
||||
* @param params
|
||||
*/
|
||||
public static void info( @Nonnull final String format, final Object... params )
|
||||
{
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.IntegrationLogging ) )
|
||||
{
|
||||
error( exception );
|
||||
}
|
||||
log( Level.INFO, format, params );
|
||||
}
|
||||
|
||||
public static void error( final Throwable e )
|
||||
/**
|
||||
* Log exception as {@link Level#INFO}
|
||||
*
|
||||
* @see AELog#log(Level, Throwable, String, Object...)
|
||||
*
|
||||
* @param exception
|
||||
*/
|
||||
public static void info( @Nonnull final Throwable exception )
|
||||
{
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.Logging ) )
|
||||
{
|
||||
severe( "Error: " + e.getClass().getName() + " : " + e.getMessage() );
|
||||
e.printStackTrace();
|
||||
}
|
||||
log( Level.INFO, exception, DEFAULT_EXCEPTION_MESSAGE );
|
||||
}
|
||||
|
||||
public static void severe( final String format, final Object... data )
|
||||
/**
|
||||
* Log exception as {@link Level#INFO}
|
||||
*
|
||||
* @see AELog#log(Level, Throwable, String, Object...)
|
||||
*
|
||||
* @param exception
|
||||
* @param message
|
||||
*/
|
||||
public static void info( @Nonnull final Throwable exception, @Nonnull final String message )
|
||||
{
|
||||
log( Level.ERROR, format, data );
|
||||
log( Level.INFO, exception, message );
|
||||
}
|
||||
|
||||
public static void blockUpdate( final BlockPos pos, final AEBaseTile aeBaseTile )
|
||||
/**
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param format
|
||||
* @param params
|
||||
*/
|
||||
public static void warn( @Nonnull final String format, final Object... params )
|
||||
{
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.UpdateLogging ) )
|
||||
{
|
||||
info( aeBaseTile.getClass().getName() + " @ " + pos );
|
||||
}
|
||||
log( Level.WARN, format, params );
|
||||
}
|
||||
|
||||
public static void info( final String format, final Object... data )
|
||||
/**
|
||||
* Log exception as {@link Level#WARN}
|
||||
*
|
||||
* @see AELog#log(Level, Throwable, String, Object...)
|
||||
*
|
||||
* @param exception
|
||||
*/
|
||||
public static void warn( @Nonnull final Throwable exception )
|
||||
{
|
||||
log( Level.INFO, format, data );
|
||||
log( Level.WARN, exception, DEFAULT_EXCEPTION_MESSAGE );
|
||||
}
|
||||
|
||||
public static void crafting( final String format, final Object... data )
|
||||
/**
|
||||
* Log exception as {@link Level#WARN}
|
||||
*
|
||||
* @see AELog#log(Level, Throwable, String, Object...)
|
||||
*
|
||||
* @param exception
|
||||
* @param message
|
||||
*/
|
||||
public static void warn( @Nonnull final Throwable exception, @Nonnull final String message )
|
||||
{
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.CraftingLog ) )
|
||||
{
|
||||
log( Level.INFO, format, data );
|
||||
}
|
||||
log( Level.WARN, exception, message );
|
||||
}
|
||||
|
||||
public static void debug( final String format, final Object... data )
|
||||
/**
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param format
|
||||
* @param params
|
||||
*/
|
||||
public static void error( @Nonnull final String format, final Object... params )
|
||||
{
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.DebugLogging ) )
|
||||
log( Level.ERROR, format, params );
|
||||
}
|
||||
|
||||
/**
|
||||
* Log exception as {@link Level#ERROR}
|
||||
*
|
||||
* @see AELog#log(Level, Throwable, String, Object...)
|
||||
*
|
||||
* @param exception
|
||||
*/
|
||||
public static void error( @Nonnull final Throwable exception )
|
||||
{
|
||||
log( Level.ERROR, exception, DEFAULT_EXCEPTION_MESSAGE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Log exception as {@link Level#ERROR}
|
||||
*
|
||||
* @see AELog#log(Level, Throwable, String, Object...)
|
||||
*
|
||||
* @param exception
|
||||
* @param message
|
||||
*/
|
||||
public static void error( @Nonnull final Throwable exception, @Nonnull final String message )
|
||||
{
|
||||
log( Level.ERROR, exception, message );
|
||||
}
|
||||
|
||||
/**
|
||||
* Log message as {@link Level#DEBUG}
|
||||
*
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param format
|
||||
* @param data
|
||||
*/
|
||||
public static void debug( @Nonnull final String format, final Object... data )
|
||||
{
|
||||
if( AELog.isDebugLogEnabled() )
|
||||
{
|
||||
log( Level.DEBUG, format, data );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log exception as {@link Level#DEBUG}
|
||||
*
|
||||
* @see AELog#log(Level, Throwable, String, Object...)
|
||||
*
|
||||
* @param exception
|
||||
*/
|
||||
public static void debug( @Nonnull final Throwable exception )
|
||||
{
|
||||
if( AELog.isDebugLogEnabled() )
|
||||
{
|
||||
log( Level.DEBUG, exception, DEFAULT_EXCEPTION_MESSAGE );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log exception as {@link Level#DEBUG}
|
||||
*
|
||||
* @see AELog#log(Level, Throwable, String, Object...)
|
||||
*
|
||||
* @param exception
|
||||
* @param message
|
||||
*/
|
||||
public static void debug( @Nonnull final Throwable exception, @Nonnull final String message )
|
||||
{
|
||||
if( AELog.isDebugLogEnabled() )
|
||||
{
|
||||
log( Level.DEBUG, exception, message );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use to check for an enabled debug log.
|
||||
*
|
||||
* Can be used to prevent the execution of debug logic.
|
||||
*
|
||||
* @return true when the debug log is enabled.
|
||||
*/
|
||||
public static boolean isDebugLogEnabled()
|
||||
{
|
||||
return AEConfig.instance.isFeatureEnabled( AEFeature.DebugLogging );
|
||||
}
|
||||
|
||||
//
|
||||
// Specialized handlers
|
||||
//
|
||||
|
||||
/**
|
||||
* A specialized logging for grinder recipes, can be disabled inside configuration file.
|
||||
*
|
||||
* @param message String to be logged
|
||||
*/
|
||||
public static void grinder( @Nonnull final String message )
|
||||
{
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.GrinderLogging ) )
|
||||
{
|
||||
log( Level.DEBUG, "grinder: " + message );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A specialized logging for mod integration errors, can be disabled inside configuration file.
|
||||
*
|
||||
* @param exception
|
||||
*/
|
||||
public static void integration( @Nonnull final Throwable exception )
|
||||
{
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.IntegrationLogging ) )
|
||||
{
|
||||
debug( exception );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logging of block updates.
|
||||
*
|
||||
* Off by default, can be enabled inside the configuration file.
|
||||
*
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param pos
|
||||
* @param aeBaseTile
|
||||
*/
|
||||
public static void blockUpdate( @Nonnull final BlockPos pos, @Nonnull final AEBaseTile aeBaseTile )
|
||||
{
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.UpdateLogging ) )
|
||||
{
|
||||
info( BLOCK_UPDATE, aeBaseTile.getClass().getName(), pos );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use to check for an enabled crafting log.
|
||||
*
|
||||
* Can be used to prevent the execution of unneeded logic.
|
||||
*
|
||||
* @return true when the crafting log is enabled.
|
||||
*/
|
||||
public static boolean isCraftingLogEnabled()
|
||||
{
|
||||
return AEConfig.instance.isFeatureEnabled( AEFeature.CraftingLog );
|
||||
}
|
||||
|
||||
/**
|
||||
* Logging for autocrafting.
|
||||
*
|
||||
* Off by default, can be enabled inside the configuration file.
|
||||
*
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param message
|
||||
* @param params
|
||||
*/
|
||||
public static void crafting( @Nonnull final String message, final Object... params )
|
||||
{
|
||||
if( AELog.isCraftingLogEnabled() )
|
||||
{
|
||||
log( Level.INFO, message, params );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use to check for an enabled crafting debug log.
|
||||
*
|
||||
* Can be used to prevent the execution of unneeded logic.
|
||||
*
|
||||
* @return true when the crafting debug log is enabled.
|
||||
*/
|
||||
public static boolean isCraftingDebugLogEnabled()
|
||||
{
|
||||
return AEConfig.instance.isFeatureEnabled( AEFeature.CraftingLog ) && AEConfig.instance.isFeatureEnabled( AEFeature.DebugLogging );
|
||||
}
|
||||
|
||||
/**
|
||||
* Debug logging for autocrafting.
|
||||
*
|
||||
* Off by default, can be enabled inside the configuration file.
|
||||
*
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param message
|
||||
* @param params
|
||||
*/
|
||||
public static void craftingDebug( @Nonnull final String message, final Object... params )
|
||||
{
|
||||
if( AELog.isCraftingDebugLogEnabled() )
|
||||
{
|
||||
log( Level.DEBUG, message, params );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,8 +96,8 @@ public class IMCHandler
|
|||
}
|
||||
catch( final Exception t )
|
||||
{
|
||||
AELog.warning( "Problem detected when processing IMC " + key + " from " + message.getSender() );
|
||||
AELog.error( t );
|
||||
AELog.warn( "Problem detected when processing IMC " + key + " from " + message.getSender() );
|
||||
AELog.debug( t );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,12 +101,12 @@ public class RecipeLoader implements Runnable
|
|||
// on failure use jar parsing
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
this.handler.parseRecipes( new JarLoader( ASSETS_RECIPE_PATH ), "index.recipe" );
|
||||
}
|
||||
catch( final URISyntaxException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
this.handler.parseRecipes( new JarLoader( ASSETS_RECIPE_PATH ), "index.recipe" );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ public class ApiPart implements IPartHelper
|
|||
}
|
||||
catch( final ClassNotFoundException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
Class myCLass;
|
||||
|
||||
|
@ -134,8 +134,8 @@ public class ApiPart implements IPartHelper
|
|||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
AELog.warning( "Error loading " + name );
|
||||
AELog.error( t );
|
||||
AELog.warn( "Error loading " + name );
|
||||
AELog.debug( t );
|
||||
// throw new RuntimeException( t );
|
||||
}
|
||||
f = myCLass.getName();
|
||||
|
@ -164,7 +164,7 @@ public class ApiPart implements IPartHelper
|
|||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
AELog.error( t );
|
||||
AELog.debug( t );
|
||||
}
|
||||
|
||||
for( final MethodNode mn : n.methods )
|
||||
|
@ -197,13 +197,13 @@ public class ApiPart implements IPartHelper
|
|||
if( !rootC.isInstance( fish ) )
|
||||
{
|
||||
hasError = true;
|
||||
AELog.severe( "Error, Expected layer to implement " + root + " did not." );
|
||||
AELog.error( "Error, Expected layer to implement " + root + " did not." );
|
||||
}
|
||||
|
||||
if( fish instanceof LayerBase )
|
||||
{
|
||||
hasError = true;
|
||||
AELog.severe( "Error, Expected layer to NOT implement LayerBase but it DID." );
|
||||
AELog.error( "Error, Expected layer to NOT implement LayerBase but it DID." );
|
||||
}
|
||||
|
||||
if( !fullPath.contains( ".fmp." ) )
|
||||
|
@ -211,13 +211,13 @@ public class ApiPart implements IPartHelper
|
|||
if( !( fish instanceof TileCableBus ) )
|
||||
{
|
||||
hasError = true;
|
||||
AELog.severe( "Error, Expected layer to implement TileCableBus did not." );
|
||||
AELog.error( "Error, Expected layer to implement TileCableBus did not." );
|
||||
}
|
||||
|
||||
if( !( fish instanceof TileEntity ) )
|
||||
{
|
||||
hasError = true;
|
||||
AELog.severe( "Error, Expected layer to implement TileEntity did not." );
|
||||
AELog.error( "Error, Expected layer to implement TileEntity did not." );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,8 +228,8 @@ public class ApiPart implements IPartHelper
|
|||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
AELog.severe( "Layer: " + n.name + " Failed." );
|
||||
AELog.error( t );
|
||||
AELog.error( "Layer: " + n.name + " Failed." );
|
||||
AELog.debug( t );
|
||||
}
|
||||
|
||||
this.roots.put( fullPath, clazz );
|
||||
|
@ -297,7 +297,7 @@ public class ApiPart implements IPartHelper
|
|||
}
|
||||
catch( final Exception e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
throw new IllegalStateException( "Unable to manage part API.", e );
|
||||
}
|
||||
return clazz;
|
||||
|
|
|
@ -61,22 +61,22 @@ public final class GridCacheRegistry implements IGridCacheRegistry
|
|||
}
|
||||
catch( final NoSuchMethodException e )
|
||||
{
|
||||
AELog.severe( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
AELog.error( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
throw new IllegalArgumentException( e );
|
||||
}
|
||||
catch( final InvocationTargetException e )
|
||||
{
|
||||
AELog.severe( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
AELog.error( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final InstantiationException e )
|
||||
{
|
||||
AELog.severe( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
AELog.error( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
AELog.severe( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
AELog.error( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,8 +73,8 @@ public class RecipeHandlerRegistry implements IRecipeHandlerRegistry
|
|||
}
|
||||
catch( final Throwable e )
|
||||
{
|
||||
AELog.severe( "Error Caused when trying to construct " + clz.getName() );
|
||||
AELog.error( e );
|
||||
AELog.error( "Error Caused when trying to construct " + clz.getName() );
|
||||
AELog.debug( e );
|
||||
|
||||
this.handlers.put( name, null ); // clear it..
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class RecipeHandlerRegistry implements IRecipeHandlerRegistry
|
|||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
AELog.error( t );
|
||||
AELog.debug( t );
|
||||
}
|
||||
|
||||
if( rr != null )
|
||||
|
|
|
@ -63,19 +63,19 @@ public class AppEngClientPacketHandler extends AppEngPacketHandlerBase implement
|
|||
}
|
||||
catch( final InstantiationException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final InvocationTargetException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,19 +63,19 @@ public final class AppEngServerPacketHandler extends AppEngPacketHandlerBase imp
|
|||
}
|
||||
catch( final InstantiationException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final InvocationTargetException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ public class PacketCraftRequest extends AppEngPacket
|
|||
{
|
||||
futureJob.cancel( true );
|
||||
}
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ public class PacketMEInventoryUpdate extends AppEngPacket
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -75,7 +75,7 @@ class PlayerMappingsInitializer
|
|||
}
|
||||
else
|
||||
{
|
||||
AELog.warning( "The configuration for players contained an outdated entry instead an expected UUID " + maybeUUID + " for the player " + id + ". Please clean this up." );
|
||||
AELog.warn( "The configuration for players contained an outdated entry instead an expected UUID " + maybeUUID + " for the player " + id + ". Please clean this up." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ final class SpawnData implements IWorldSpawnData
|
|||
catch( final Throwable e )
|
||||
{
|
||||
data = new NBTTagCompound();
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -165,7 +165,7 @@ final class SpawnData implements IWorldSpawnData
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ final class SpawnData implements IWorldSpawnData
|
|||
}
|
||||
catch( final Throwable e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -208,7 +208,7 @@ final class SpawnData implements IWorldSpawnData
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ final class StorageData implements IWorldGridStorageData, IOnWorldStartable, IOn
|
|||
}
|
||||
catch( final NumberFormatException err )
|
||||
{
|
||||
AELog.warning( "The config contained a value which was not represented as a Long: %s", lastString );
|
||||
AELog.warn( "The config contained a value which was not represented as a Long: %s", lastString );
|
||||
|
||||
this.lastGridStorage = 0;
|
||||
}
|
||||
|
|
|
@ -24,26 +24,35 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import com.google.common.base.Stopwatch;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.ICraftingCallback;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.crafting.ICraftingJob;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.security.PlayerSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.AELog;
|
||||
import appeng.hooks.TickHandler;
|
||||
|
||||
|
||||
public class CraftingJob implements Runnable, ICraftingJob
|
||||
{
|
||||
private static final String LOG_CRAFTING_JOB = "CraftingJob (%s) issued by %s requesting [%s] using %s bytes took %s ms";
|
||||
private static final String LOG_MACHINE_SOURCE_DETAILS = "Machine[object=%s, %s]";
|
||||
|
||||
private final MECraftingInventory original;
|
||||
private final World world;
|
||||
|
@ -145,7 +154,7 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||
AELog.crafting( s + " * " + ti.times + " = " + ( ti.perOp * ti.times ) );
|
||||
}
|
||||
|
||||
AELog.crafting( "------------- " + this.bytes + "b real" + timer.elapsed( TimeUnit.MILLISECONDS ) + "ms" );
|
||||
this.logCraftingJob( "real", timer );
|
||||
// if ( mode == Actionable.MODULATE )
|
||||
// craftingInventory.moveItemsToStorage( storage );
|
||||
}
|
||||
|
@ -171,15 +180,15 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||
AELog.crafting( s + " * " + ti.times + " = " + ( ti.perOp * ti.times ) );
|
||||
}
|
||||
|
||||
AELog.crafting( "------------- " + this.bytes + "b simulate" + timer.elapsed( TimeUnit.MILLISECONDS ) + "ms" );
|
||||
this.logCraftingJob( "simulate", timer );
|
||||
}
|
||||
catch( final CraftBranchFailure e1 )
|
||||
{
|
||||
AELog.error( e1 );
|
||||
AELog.debug( e1 );
|
||||
}
|
||||
catch( final CraftingCalculationFailure f )
|
||||
{
|
||||
AELog.error( f );
|
||||
AELog.debug( f );
|
||||
}
|
||||
catch( final InterruptedException e1 )
|
||||
{
|
||||
|
@ -190,7 +199,7 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||
}
|
||||
catch( final CraftingCalculationFailure f )
|
||||
{
|
||||
AELog.error( f );
|
||||
AELog.debug( f );
|
||||
}
|
||||
catch( final InterruptedException e1 )
|
||||
{
|
||||
|
@ -199,7 +208,7 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||
return;
|
||||
}
|
||||
|
||||
this.log( "crafting job now done" );
|
||||
AELog.craftingDebug( "crafting job now done" );
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
|
@ -227,14 +236,14 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||
|
||||
if( !this.running )
|
||||
{
|
||||
this.log( "crafting job will now sleep" );
|
||||
AELog.craftingDebug( "crafting job will now sleep" );
|
||||
|
||||
while( !this.running )
|
||||
{
|
||||
this.monitor.wait();
|
||||
}
|
||||
|
||||
this.log( "crafting job now active" );
|
||||
AELog.craftingDebug( "crafting job now active" );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -263,11 +272,6 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||
}
|
||||
}
|
||||
|
||||
private void log( final String string )
|
||||
{
|
||||
// AELog.crafting( string );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSimulation()
|
||||
{
|
||||
|
@ -327,7 +331,7 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||
this.watch.start();
|
||||
this.running = true;
|
||||
|
||||
this.log( "main thread is now going to sleep" );
|
||||
AELog.craftingDebug( "main thread is now going to sleep" );
|
||||
|
||||
this.monitor.notify();
|
||||
|
||||
|
@ -342,7 +346,7 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||
}
|
||||
}
|
||||
|
||||
this.log( "main thread is now active" );
|
||||
AELog.craftingDebug( "main thread is now active" );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -363,9 +367,41 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||
this.tree = tree;
|
||||
}
|
||||
|
||||
private void logCraftingJob( String type, Stopwatch timer )
|
||||
{
|
||||
if( AELog.isCraftingLogEnabled() )
|
||||
{
|
||||
final String itemToOutput = this.output.toString();
|
||||
final long elapsedTime = timer.elapsed( TimeUnit.MILLISECONDS );
|
||||
final String actionSource;
|
||||
|
||||
if( this.actionSrc instanceof MachineSource )
|
||||
{
|
||||
final IActionHost machineSource = ( (MachineSource) this.actionSrc ).via;
|
||||
final IGridNode actionableNode = machineSource.getActionableNode();
|
||||
final IGridHost machine = actionableNode.getMachine();
|
||||
final DimensionalCoord location = actionableNode.getGridBlock().getLocation();
|
||||
|
||||
actionSource = String.format( LOG_MACHINE_SOURCE_DETAILS, machine, location );
|
||||
}
|
||||
else if( this.actionSrc instanceof PlayerSource )
|
||||
{
|
||||
final PlayerSource source = (PlayerSource) this.actionSrc;
|
||||
final EntityPlayer player = source.player;
|
||||
|
||||
actionSource = player.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
actionSource = "[unknown source]";
|
||||
}
|
||||
|
||||
AELog.crafting( LOG_CRAFTING_JOB, type, actionSource, itemToOutput, this.bytes, elapsedTime );
|
||||
}
|
||||
}
|
||||
|
||||
private static class TwoIntegers
|
||||
{
|
||||
|
||||
private final long perOp = 0;
|
||||
private final long times = 0;
|
||||
}
|
||||
|
|
|
@ -344,7 +344,7 @@ public class FacadePart implements IFacadePart, IBoxProvider
|
|||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
AELog.error( t );
|
||||
AELog.debug( t );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,709 @@
|
|||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.fmp;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import codechicken.lib.data.MCDataInput;
|
||||
import codechicken.lib.data.MCDataOutput;
|
||||
import codechicken.lib.raytracer.IndexedCuboid6;
|
||||
import codechicken.lib.vec.Cuboid6;
|
||||
import codechicken.lib.vec.Vector3;
|
||||
import codechicken.multipart.IMaskedRedstonePart;
|
||||
import codechicken.multipart.JCuboidPart;
|
||||
import codechicken.multipart.JNormalOcclusion;
|
||||
import codechicken.multipart.NormalOcclusionTest;
|
||||
import codechicken.multipart.NormallyOccludedPart;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import codechicken.multipart.scalatraits.TIInventoryTile;
|
||||
|
||||
import appeng.api.implementations.parts.IPartCable;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.parts.IFacadeContainer;
|
||||
import appeng.api.parts.IFacadePart;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import appeng.api.parts.LayerFlags;
|
||||
import appeng.api.parts.PartItemStack;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.client.render.BusRenderHelper;
|
||||
import appeng.client.render.BusRenderer;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.AEMultiTile;
|
||||
import appeng.parts.BusCollisionHelper;
|
||||
import appeng.parts.CableBusContainer;
|
||||
import appeng.parts.PartPlacement;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
/**
|
||||
* Implementing these might help improve visuals for hollow covers
|
||||
*
|
||||
* TSlottedPart,ISidedHollowConnect
|
||||
*/
|
||||
public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IMaskedRedstonePart, AEMultiTile
|
||||
{
|
||||
private static final ThreadLocal<Boolean> DISABLE_FACADE_OCCLUSION = new ThreadLocal<Boolean>();
|
||||
private static final double SHORTER = 6.0 / 16.0;
|
||||
private static final double LONGER = 10.0 / 16.0;
|
||||
private static final double MIN_DIRECTION = 0;
|
||||
private static final double MAX_DIRECTION = 1.0;
|
||||
private static final Cuboid6[] SIDE_TESTS = {
|
||||
|
||||
// DOWN(0, -1, 0),
|
||||
new Cuboid6( SHORTER, MIN_DIRECTION, SHORTER, LONGER, SHORTER, LONGER ),
|
||||
|
||||
// UP(0, 1, 0),
|
||||
new Cuboid6( SHORTER, LONGER, SHORTER, LONGER, MAX_DIRECTION, LONGER ),
|
||||
|
||||
// NORTH(0, 0, -1),
|
||||
new Cuboid6( SHORTER, SHORTER, MIN_DIRECTION, LONGER, LONGER, SHORTER ),
|
||||
|
||||
// SOUTH(0, 0, 1),
|
||||
new Cuboid6( SHORTER, SHORTER, LONGER, LONGER, LONGER, MAX_DIRECTION ),
|
||||
|
||||
// WEST(-1, 0, 0),
|
||||
new Cuboid6( MIN_DIRECTION, SHORTER, SHORTER, SHORTER, LONGER, LONGER ),
|
||||
|
||||
// EAST(1, 0, 0),
|
||||
new Cuboid6( LONGER, SHORTER, SHORTER, MAX_DIRECTION, LONGER, LONGER ),
|
||||
};
|
||||
|
||||
/**
|
||||
* Mask for {@link IMaskedRedstonePart#getConnectionMask(int)}
|
||||
*
|
||||
* the bits are derived from the rotation, where 4 is the center
|
||||
*/
|
||||
private static final int CONNECTION_MASK = 0x000010;
|
||||
private CableBusContainer cb = new CableBusContainer( this );
|
||||
private boolean canUpdate = false;
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock( final ForgeDirection side, final AEColor colour, final EntityPlayer who )
|
||||
{
|
||||
return this.getCableBus().recolourBlock( side, colour, who );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cuboid6 getBounds()
|
||||
{
|
||||
AxisAlignedBB b = null;
|
||||
|
||||
for( final AxisAlignedBB bx : this.getCableBus().getSelectedBoundingBoxesFromPool( false, true, null, true ) )
|
||||
{
|
||||
if( b == null )
|
||||
{
|
||||
b = bx;
|
||||
}
|
||||
else
|
||||
{
|
||||
final double minX = Math.min( b.minX, bx.minX );
|
||||
final double minY = Math.min( b.minY, bx.minY );
|
||||
final double minZ = Math.min( b.minZ, bx.minZ );
|
||||
final double maxX = Math.max( b.maxX, bx.maxX );
|
||||
final double maxY = Math.max( b.maxY, bx.maxY );
|
||||
final double maxZ = Math.max( b.maxZ, bx.maxZ );
|
||||
b.setBounds( minX, minY, minZ, maxX, maxY, maxZ );
|
||||
}
|
||||
}
|
||||
|
||||
if( b == null )
|
||||
{
|
||||
return new Cuboid6( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 );
|
||||
}
|
||||
|
||||
return new Cuboid6( b.minX, b.minY, b.minZ, b.maxX, b.maxY, b.maxZ );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return PartRegistry.CableBusPart.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue()
|
||||
{
|
||||
return this.getCableBus().getLightValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWorldJoin()
|
||||
{
|
||||
this.canUpdate = true;
|
||||
this.getCableBus().updateConnections();
|
||||
this.getCableBus().addToWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean occlusionTest( final TMultiPart part )
|
||||
{
|
||||
return NormalOcclusionTest.apply( this, part );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderStatic( final Vector3 pos, final int pass )
|
||||
{
|
||||
if( pass == 0 || ( pass == 1 && AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) ) )
|
||||
{
|
||||
BusRenderHelper.INSTANCE.setPass( pass );
|
||||
BusRenderer.INSTANCE.getRenderer().renderAllFaces = true;
|
||||
BusRenderer.INSTANCE.getRenderer().blockAccess = this.world();
|
||||
BusRenderer.INSTANCE.getRenderer().overrideBlockTexture = null;
|
||||
this.getCableBus().renderStatic( pos.x, pos.y, pos.z );
|
||||
return BusRenderHelper.INSTANCE.getItemsRendered() > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderDynamic( final Vector3 pos, final float frame, final int pass )
|
||||
{
|
||||
if( pass == 0 || ( pass == 1 && AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) ) )
|
||||
{
|
||||
BusRenderHelper.INSTANCE.setPass( pass );
|
||||
this.getCableBus().renderDynamic( pos.x, pos.y, pos.z );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPartChanged( final TMultiPart part )
|
||||
{
|
||||
this.getCableBus().updateConnections();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision( final Entity entity )
|
||||
{
|
||||
this.getCableBus().onEntityCollision( entity );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activate( final EntityPlayer player, final MovingObjectPosition hit, final ItemStack item )
|
||||
{
|
||||
return this.getCableBus().activate( player, hit.hitVec.addVector( -hit.blockX, -hit.blockY, -hit.blockZ ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load( final NBTTagCompound tag )
|
||||
{
|
||||
this.getCableBus().readFromNBT( tag );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWorldSeparate()
|
||||
{
|
||||
this.canUpdate = false;
|
||||
this.getCableBus().removeFromWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save( final NBTTagCompound tag )
|
||||
{
|
||||
this.getCableBus().writeToNBT( tag );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDesc( final MCDataOutput packet )
|
||||
{
|
||||
final ByteBuf stream = Unpooled.buffer();
|
||||
|
||||
try
|
||||
{
|
||||
this.getCableBus().writeToStream( stream );
|
||||
packet.writeInt( stream.readableBytes() );
|
||||
stream.capacity( stream.readableBytes() );
|
||||
packet.writeByteArray( stream.array() );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack pickItem( final MovingObjectPosition hit )
|
||||
{
|
||||
final Vec3 v3 = hit.hitVec.addVector( -hit.blockX, -hit.blockY, -hit.blockZ );
|
||||
final SelectedPart sp = this.getCableBus().selectPart( v3 );
|
||||
if( sp != null )
|
||||
{
|
||||
if( sp.part != null )
|
||||
{
|
||||
return sp.part.getItemStack( PartItemStack.Break );
|
||||
}
|
||||
if( sp.facade != null )
|
||||
{
|
||||
return sp.facade.getItemStack();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<ItemStack> getDrops()
|
||||
{
|
||||
return this.getCableBus().getDrops( new ArrayList() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
this.getCableBus().onNeighborChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesTick()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateConvertedTile()
|
||||
{
|
||||
this.getCableBus().setHost( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readDesc( final MCDataInput packet )
|
||||
{
|
||||
final int len = packet.readInt();
|
||||
final byte[] data = packet.readByteArray( len );
|
||||
|
||||
try
|
||||
{
|
||||
if( len > 0 )
|
||||
{
|
||||
final ByteBuf byteBuffer = Unpooled.wrappedBuffer( data );
|
||||
this.getCableBus().readFromStream( byteBuffer );
|
||||
}
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone( final int side )
|
||||
{
|
||||
return this.getCableBus().canConnectRedstone( EnumSet.of( ForgeDirection.getOrientation( side ) ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int weakPowerLevel( final int side )
|
||||
{
|
||||
return this.getCableBus().isProvidingWeakPower( ForgeDirection.getOrientation( side ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int strongPowerLevel( final int side )
|
||||
{
|
||||
return this.getCableBus().isProvidingStrongPower( ForgeDirection.getOrientation( side ) );
|
||||
}
|
||||
|
||||
public void convertFromTile( final TileEntity blockTileEntity )
|
||||
{
|
||||
final TileCableBus tcb = (TileCableBus) blockTileEntity;
|
||||
this.setCableBus( tcb.getCableBus() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Cuboid6> getOcclusionBoxes()
|
||||
{
|
||||
final LinkedList<Cuboid6> l = new LinkedList<Cuboid6>();
|
||||
for( final AxisAlignedBB b : this.getCableBus().getSelectedBoundingBoxesFromPool( true, DISABLE_FACADE_OCCLUSION.get() == null, null, true ) )
|
||||
{
|
||||
l.add( new Cuboid6( b.minX, b.minY, b.minZ, b.maxX, b.maxY, b.maxZ ) );
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode( final ForgeDirection dir )
|
||||
{
|
||||
return this.getCableBus().getGridNode( dir );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( final ForgeDirection dir )
|
||||
{
|
||||
return this.getCableBus().getCableConnectionType( dir );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void securityBreak()
|
||||
{
|
||||
this.getCableBus().securityBreak();
|
||||
}
|
||||
|
||||
// @Override
|
||||
public int getHollowSize( final int side )
|
||||
{
|
||||
final IPartCable cable = (IPartCable) this.getPart( ForgeDirection.UNKNOWN );
|
||||
|
||||
final ForgeDirection dir = ForgeDirection.getOrientation( side );
|
||||
if( cable != null && cable.isConnected( dir ) )
|
||||
{
|
||||
final List<AxisAlignedBB> boxes = new ArrayList<AxisAlignedBB>();
|
||||
|
||||
final BusCollisionHelper bch = new BusCollisionHelper( boxes, ForgeDirection.EAST, ForgeDirection.UP, ForgeDirection.SOUTH, null, true );
|
||||
|
||||
for( final ForgeDirection whichSide : ForgeDirection.values() )
|
||||
{
|
||||
final IPart fPart = this.getPart( whichSide );
|
||||
|
||||
if( fPart != null )
|
||||
{
|
||||
fPart.getBoxes( bch );
|
||||
}
|
||||
}
|
||||
|
||||
AxisAlignedBB b = null;
|
||||
final AxisAlignedBB pb = Platform.getPrimaryBox( dir, 2 );
|
||||
|
||||
for( final AxisAlignedBB bb : boxes )
|
||||
{
|
||||
if( bb.intersectsWith( pb ) )
|
||||
{
|
||||
if( b == null )
|
||||
{
|
||||
b = bb;
|
||||
}
|
||||
else
|
||||
{
|
||||
b.maxX = Math.max( b.maxX, bb.maxX );
|
||||
b.maxY = Math.max( b.maxY, bb.maxY );
|
||||
b.maxZ = Math.max( b.maxZ, bb.maxZ );
|
||||
b.minX = Math.min( b.minX, bb.minX );
|
||||
b.minY = Math.min( b.minY, bb.minY );
|
||||
b.minZ = Math.min( b.minZ, bb.minZ );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( b == null )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch( dir )
|
||||
{
|
||||
case WEST:
|
||||
case EAST:
|
||||
return this.getSize( b.minZ, b.maxZ, b.minY, b.maxY );
|
||||
case DOWN:
|
||||
case NORTH:
|
||||
return this.getSize( b.minX, b.maxX, b.minZ, b.maxZ );
|
||||
case SOUTH:
|
||||
case UP:
|
||||
return this.getSize( b.minX, b.maxX, b.minY, b.maxY );
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
return 12;
|
||||
}
|
||||
|
||||
private int getSize( final double a, final double b, final double c, final double d )
|
||||
{
|
||||
double r = Math.abs( a - 0.5 );
|
||||
r = Math.max( Math.abs( b - 0.5 ), r );
|
||||
r = Math.max( Math.abs( c - 0.5 ), r );
|
||||
return( 8 * (int) Math.max( Math.abs( d - 0.5 ), r ) );
|
||||
}
|
||||
|
||||
// @Override
|
||||
public int getSlotMask()
|
||||
{
|
||||
int mask = 0;
|
||||
|
||||
for( final ForgeDirection side : ForgeDirection.values() )
|
||||
{
|
||||
if( this.getPart( side ) != null )
|
||||
{
|
||||
mask |= 1 << side.ordinal();
|
||||
}
|
||||
else if( side != ForgeDirection.UNKNOWN && this.getFacadeContainer().getFacade( side ) != null )
|
||||
{
|
||||
mask |= 1 << side.ordinal();
|
||||
}
|
||||
}
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFacadeContainer getFacadeContainer()
|
||||
{
|
||||
return this.getCableBus().getFacadeContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAddPart( ItemStack is, final ForgeDirection side )
|
||||
{
|
||||
final IFacadePart fp = PartPlacement.isFacade( is, side );
|
||||
if( fp != null )
|
||||
{
|
||||
if( !( side == null || side == ForgeDirection.UNKNOWN || this.tile() == null ) )
|
||||
{
|
||||
final List<AxisAlignedBB> boxes = new ArrayList<AxisAlignedBB>();
|
||||
final IPartCollisionHelper bch = new BusCollisionHelper( boxes, side, null, true );
|
||||
fp.getBoxes( bch, null );
|
||||
for( final AxisAlignedBB bb : boxes )
|
||||
{
|
||||
DISABLE_FACADE_OCCLUSION.set( true );
|
||||
final boolean canAdd = this.tile().canAddPart( new NormallyOccludedPart( new Cuboid6( bb ) ) );
|
||||
DISABLE_FACADE_OCCLUSION.remove();
|
||||
if( !canAdd )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if( is.getItem() instanceof IPartItem )
|
||||
{
|
||||
final IPartItem bi = (IPartItem) is.getItem();
|
||||
|
||||
is = is.copy();
|
||||
is.stackSize = 1;
|
||||
|
||||
final IPart bp = bi.createPartFromItemStack( is );
|
||||
if( !( side == null || side == ForgeDirection.UNKNOWN || this.tile() == null ) )
|
||||
{
|
||||
final List<AxisAlignedBB> boxes = new ArrayList<AxisAlignedBB>();
|
||||
final IPartCollisionHelper bch = new BusCollisionHelper( boxes, side, null, true );
|
||||
if( bp != null )
|
||||
{
|
||||
bp.getBoxes( bch );
|
||||
}
|
||||
for( final AxisAlignedBB bb : boxes )
|
||||
{
|
||||
if( !this.tile().canAddPart( new NormallyOccludedPart( new Cuboid6( bb ) ) ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.getCableBus().canAddPart( is, side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection addPart( final ItemStack is, final ForgeDirection side, final EntityPlayer owner )
|
||||
{
|
||||
return this.getCableBus().addPart( is, side, owner );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPart getPart( final ForgeDirection side )
|
||||
{
|
||||
return this.getCableBus().getPart( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePart( final ForgeDirection side, final boolean suppressUpdate )
|
||||
{
|
||||
this.getCableBus().removePart( side, suppressUpdate );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForUpdate()
|
||||
{
|
||||
if( Platform.isServer() && this.canUpdate )
|
||||
{
|
||||
this.sendDescUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
{
|
||||
return new DimensionalCoord( this.tile() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColor getColor()
|
||||
{
|
||||
return this.getCableBus().getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearContainer()
|
||||
{
|
||||
this.setCableBus( new CableBusContainer( this ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlocked( final ForgeDirection side )
|
||||
{
|
||||
if( side == null || side == ForgeDirection.UNKNOWN || this.tile() == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DISABLE_FACADE_OCCLUSION.set( true );
|
||||
|
||||
final int ordinal = side.ordinal();
|
||||
final Cuboid6 sideTest = SIDE_TESTS[ordinal];
|
||||
final NormallyOccludedPart occludedPart = new NormallyOccludedPart( sideTest );
|
||||
final boolean blocked = !this.tile().canAddPart( occludedPart );
|
||||
DISABLE_FACADE_OCCLUSION.remove();
|
||||
|
||||
return blocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SelectedPart selectPart( final Vec3 pos )
|
||||
{
|
||||
return this.getCableBus().selectPart( pos );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForSave()
|
||||
{
|
||||
// mark the chunk for save...
|
||||
final TileEntity te = this.tile();
|
||||
if( te != null && te.getWorldObj() != null )
|
||||
{
|
||||
te.getWorldObj().getChunkFromBlockCoords( this.x(), this.z() ).isModified = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void partChanged()
|
||||
{
|
||||
if( this.isInWorld() )
|
||||
{
|
||||
this.notifyNeighbors();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRedstone( final ForgeDirection side )
|
||||
{
|
||||
return this.getCableBus().hasRedstone( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return this.getCableBus().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<LayerFlags> getLayerFlags()
|
||||
{
|
||||
return this.getCableBus().getLayerFlags();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup()
|
||||
{
|
||||
this.tile().remPart( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyNeighbors()
|
||||
{
|
||||
if( this.tile() instanceof TIInventoryTile )
|
||||
{
|
||||
( (TIInventoryTile) this.tile() ).rebuildSlotMap();
|
||||
}
|
||||
|
||||
if( this.world() != null && this.world().blockExists( this.x(), this.y(), this.z() ) && !CableBusContainer.isLoading() )
|
||||
{
|
||||
Platform.notifyBlocksOfNeighbors( this.world(), this.x(), this.y(), this.z() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInWorld()
|
||||
{
|
||||
return this.getCableBus().isInWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Cuboid6> getCollisionBoxes()
|
||||
{
|
||||
final LinkedList<Cuboid6> l = new LinkedList<Cuboid6>();
|
||||
for( final AxisAlignedBB b : this.getCableBus().getSelectedBoundingBoxesFromPool( false, true, null, true ) )
|
||||
{
|
||||
l.add( new Cuboid6( b.minX, b.minY, b.minZ, b.maxX, b.maxY, b.maxZ ) );
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<IndexedCuboid6> getSubParts()
|
||||
{
|
||||
final LinkedList<IndexedCuboid6> l = new LinkedList<IndexedCuboid6>();
|
||||
for( final Cuboid6 c : this.getCollisionBoxes() )
|
||||
{
|
||||
l.add( new IndexedCuboid6( 0, c ) );
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConnectionMask( final int side )
|
||||
{
|
||||
return CONNECTION_MASK;
|
||||
}
|
||||
|
||||
public CableBusContainer getCableBus()
|
||||
{
|
||||
return this.cb;
|
||||
}
|
||||
|
||||
private void setCableBus( final CableBusContainer cb )
|
||||
{
|
||||
this.cb = cb;
|
||||
}
|
||||
}
|
|
@ -286,7 +286,7 @@ public class TickHandler
|
|||
}
|
||||
catch( final Exception e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -256,7 +256,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
|||
}
|
||||
catch( final Exception err )
|
||||
{
|
||||
AELog.error( err );
|
||||
AELog.debug( err );
|
||||
}
|
||||
|
||||
if( pos != null && type != null && type.getItem() instanceof ItemPaintBall )
|
||||
|
@ -373,7 +373,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
|||
}
|
||||
catch( final Exception err )
|
||||
{
|
||||
AELog.error( err );
|
||||
AELog.debug( err );
|
||||
}
|
||||
|
||||
if( pos != null )
|
||||
|
|
|
@ -110,7 +110,7 @@ public class GridStorage implements IGridStorage
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
|
||||
return "";
|
||||
|
|
|
@ -184,10 +184,10 @@ public class NetworkEventBus
|
|||
}
|
||||
catch( final Throwable e1 )
|
||||
{
|
||||
AELog.severe( "[AppEng] Network Event caused exception:" );
|
||||
AELog.severe( "Offending Class: " + obj.getClass().getName() );
|
||||
AELog.severe( "Offending Object: " + obj.toString() );
|
||||
AELog.error( e1 );
|
||||
AELog.error( "[AppEng] Network Event caused exception:" );
|
||||
AELog.error( "Offending Class: " + obj.getClass().getName() );
|
||||
AELog.error( "Offending Object: " + obj.toString() );
|
||||
AELog.debug( e1 );
|
||||
throw new IllegalStateException( e1 );
|
||||
}
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ public abstract class MBCalculator
|
|||
}
|
||||
catch( final Throwable err )
|
||||
{
|
||||
AELog.error( err );
|
||||
AELog.debug( err );
|
||||
}
|
||||
|
||||
this.disconnect();
|
||||
|
|
|
@ -82,6 +82,8 @@ import appeng.util.item.AEItemStack;
|
|||
public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
{
|
||||
|
||||
private static final String LOG_MARK_AS_COMPLETE = "Completed job for %s.";
|
||||
|
||||
private final WorldCoord min;
|
||||
private final WorldCoord max;
|
||||
private final int[] usedOps = new int[3];
|
||||
|
@ -426,12 +428,19 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
|||
( (CraftingLink) this.myLastLink ).markDone();
|
||||
}
|
||||
|
||||
AELog.crafting( "marking job as complete" );
|
||||
if( AELog.isCraftingLogEnabled() )
|
||||
{
|
||||
final IAEItemStack logStack = this.finalOutput.copy();
|
||||
logStack.setStackSize( this.startItemCount );
|
||||
AELog.crafting( LOG_MARK_AS_COMPLETE, logStack );
|
||||
}
|
||||
|
||||
this.remainingItemCount = 0;
|
||||
this.startItemCount = 0;
|
||||
this.lastTime = 0;
|
||||
this.elapsedTime = 0;
|
||||
this.isComplete = true;
|
||||
|
||||
}
|
||||
|
||||
private void updateCPU()
|
||||
|
|
|
@ -1081,7 +1081,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
|
|||
}
|
||||
else
|
||||
{
|
||||
AELog.warning( "Invalid NBT For CableBus Container: " + iss.getItem().getClass().getName() + " is not a valid part; it was ignored." );
|
||||
AELog.warn( "Invalid NBT For CableBus Container: " + iss.getItem().getClass().getName() + " is not a valid part; it was ignored." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -305,7 +305,7 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
|||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
|
||||
return items;
|
||||
|
|
|
@ -233,14 +233,15 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
|
|||
{
|
||||
final TileEntity start = this.getTile();
|
||||
final TileEntity end = me.getTile();
|
||||
AELog.warning( "Failed to establish a ME P2P Tunnel between the tunnels at [x=%d, y=%d, z=%d] and [x=%d, y=%d, z=%d]", start.getPos().getX(), start.getPos().getY(), start.getPos().getZ(), end.getPos().getX(), end.getPos().getY(), end.getPos().getZ() );
|
||||
|
||||
AELog.warn( "Failed to establish a ME P2P Tunnel between the tunnels at [x=%d, y=%d, z=%d] and [x=%d, y=%d, z=%d]", start.getPos().getX(), start.getPos().getY(), start.getPos().getZ(), end.getPos().getX(), end.getPos().getY(), end.getPos().getZ() );
|
||||
// :(
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -374,7 +374,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
|
|||
}
|
||||
catch( final Exception e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -252,10 +252,10 @@ public class RecipeHandler implements IRecipeHandler
|
|||
}
|
||||
catch( final Exception err )
|
||||
{
|
||||
AELog.warning( "Error Loading Recipe File:" + path );
|
||||
AELog.warn( "Error Loading Recipe File:" + path );
|
||||
if( this.data.exceptions )
|
||||
{
|
||||
AELog.error( err );
|
||||
AELog.debug( err );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ public class RecipeHandler implements IRecipeHandler
|
|||
}
|
||||
catch( final Throwable e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
if( this.data.crash )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
|
@ -393,10 +393,10 @@ public class RecipeHandler implements IRecipeHandler
|
|||
}
|
||||
catch( final RegistrationError e )
|
||||
{
|
||||
AELog.warning( "Unable to register a recipe: " + e.getMessage() );
|
||||
AELog.warn( "Unable to register a recipe: " + e.getMessage() );
|
||||
if( this.data.exceptions )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
if( this.data.crash )
|
||||
{
|
||||
|
@ -407,10 +407,10 @@ public class RecipeHandler implements IRecipeHandler
|
|||
{
|
||||
if( this.data.errorOnMissing )
|
||||
{
|
||||
AELog.warning( "Unable to register a recipe:" + e.getMessage() );
|
||||
AELog.warn( "Unable to register a recipe:" + e.getMessage() );
|
||||
if( this.data.exceptions )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
if( this.data.crash )
|
||||
{
|
||||
|
@ -424,7 +424,7 @@ public class RecipeHandler implements IRecipeHandler
|
|||
{
|
||||
if( this.data.exceptions )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
if( this.data.crash )
|
||||
{
|
||||
|
@ -500,11 +500,11 @@ public class RecipeHandler implements IRecipeHandler
|
|||
}
|
||||
catch( final FileNotFoundException e1 )
|
||||
{
|
||||
AELog.error( e1 );
|
||||
AELog.debug( e1 );
|
||||
}
|
||||
catch( final IOException e1 )
|
||||
{
|
||||
AELog.error( e1 );
|
||||
AELog.debug( e1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -524,7 +524,7 @@ public class RecipeHandler implements IRecipeHandler
|
|||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
AELog.error( t );
|
||||
AELog.debug( t );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -673,10 +673,10 @@ public class RecipeHandler implements IRecipeHandler
|
|||
}
|
||||
catch( final RecipeError e )
|
||||
{
|
||||
AELog.warning( "Recipe Error '" + e.getMessage() + "' near line:" + line + " in " + file + " with: " + this.tokens.toString() );
|
||||
AELog.warn( "Recipe Error '" + e.getMessage() + "' near line:" + line + " in " + file + " with: " + this.tokens.toString() );
|
||||
if( this.data.exceptions )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
if( this.data.crash )
|
||||
{
|
||||
|
|
|
@ -117,7 +117,7 @@ public class Shaped implements ICraftHandler, IWebsiteSerializer
|
|||
}
|
||||
catch( final Throwable e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
throw new RegistrationError( "Error while adding shaped recipe." );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ public class Shapeless implements ICraftHandler, IWebsiteSerializer
|
|||
}
|
||||
catch( final Throwable e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
throw new RegistrationError( "Error while adding shapeless recipe." );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public class OreDictionaryHandler
|
|||
}
|
||||
catch( final Throwable e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ public final class VersionChecker implements Runnable
|
|||
catch( final Exception exception )
|
||||
{
|
||||
// Log any unhandled exception to prevent the JVM from reporting them as unhandled.
|
||||
AELog.error( exception );
|
||||
AELog.debug( exception );
|
||||
}
|
||||
|
||||
AELog.info( "Stopping AE2 VersionChecker" );
|
||||
|
|
|
@ -117,8 +117,8 @@ final class MinecraftItemCSVExporter implements Exporter
|
|||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.warning( EXPORT_UNSUCCESSFUL_MESSAGE );
|
||||
AELog.error( e );
|
||||
AELog.warn( EXPORT_UNSUCCESSFUL_MESSAGE );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -198,6 +198,7 @@ final class MinecraftItemCSVExporter implements Exporter
|
|||
private static final String LOCALIZATION_NAME_EXTENSION = ".name";
|
||||
private static final String EXPORTING_NOTHING_MESSAGE = "Exporting nothing";
|
||||
private static final String EXPORTING_SUBTYPES_MESSAGE = "Exporting input %s with subtypes: %b";
|
||||
private static final String EXPORTING_SUBTYPES_FAILED_MESSAGE = "Could not export subtypes of: %s";
|
||||
|
||||
@Nonnull
|
||||
private final FMLControlledNamespacedRegistry<Item> itemRegistry;
|
||||
|
@ -243,7 +244,8 @@ final class MinecraftItemCSVExporter implements Exporter
|
|||
}
|
||||
catch( final Exception ignored )
|
||||
{
|
||||
AELog.error( ignored );
|
||||
AELog.warn( EXPORTING_SUBTYPES_FAILED_MESSAGE, input.getUnlocalizedName() );
|
||||
AELog.debug( ignored );
|
||||
|
||||
// ignore if mods do bullshit in their code
|
||||
return null;
|
||||
|
|
|
@ -67,7 +67,7 @@ public final class ModVersionFetcher implements VersionFetcher
|
|||
}
|
||||
catch( final VersionCheckerException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
|
||||
return EXCEPTIONAL_VERSION;
|
||||
}
|
||||
|
|
|
@ -75,15 +75,15 @@ public final class ReleaseFetcher
|
|||
}
|
||||
catch( final VersionCheckerException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final MalformedURLException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
|
||||
return EXCEPTIONAL_RELEASE;
|
||||
|
|
|
@ -181,7 +181,7 @@ public class CachedPlane
|
|||
}
|
||||
catch( final Exception e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ public class CachedPlane
|
|||
}
|
||||
catch( final Throwable e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
|
||||
final BlockPos pos = new BlockPos( x, y, z );
|
||||
|
||||
|
@ -325,7 +325,7 @@ public class CachedPlane
|
|||
}
|
||||
catch( final Throwable e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
|||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
AELog.error( t );
|
||||
AELog.debug( t );
|
||||
}
|
||||
|
||||
stream.capacity( stream.readableBytes() );
|
||||
|
@ -280,7 +280,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
|||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
AELog.error( t );
|
||||
AELog.debug( t );
|
||||
}
|
||||
|
||||
return output;
|
||||
|
@ -320,7 +320,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
|||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
AELog.error( t );
|
||||
AELog.debug( t );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
|
|||
}
|
||||
catch( final Exception e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -262,7 +262,7 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
|
|||
}
|
||||
catch( final Exception e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ public class ClassInstantiation<T>
|
|||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
AELog.error( t );
|
||||
AELog.debug( t );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ public final class ConfigManager implements IConfigManager
|
|||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -594,8 +594,8 @@ public class Platform
|
|||
}
|
||||
catch( final Throwable z )
|
||||
{
|
||||
AELog.error( t );
|
||||
AELog.error( z );
|
||||
AELog.debug( t );
|
||||
AELog.debug( z );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -607,7 +607,7 @@ public class Platform
|
|||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
AELog.error( t );
|
||||
AELog.debug( t );
|
||||
}
|
||||
|
||||
return new ArrayList<NBTBase>();
|
||||
|
@ -2149,7 +2149,7 @@ public class Platform
|
|||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
AELog.error( t );
|
||||
AELog.debug( t );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue