pick 97420a31d The big reformat of 2020
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,16 @@
|
||||
package appeng.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IBlocks;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AEItemGroup extends ItemGroup {
|
||||
|
||||
|
||||
@@ -18,374 +18,345 @@
|
||||
|
||||
package appeng.core;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.BlockState;
|
||||
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.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public final class AELog {
|
||||
private static final String LOGGER_PREFIX = "AE2:";
|
||||
private static final String SERVER_SUFFIX = "S";
|
||||
private static final String CLIENT_SUFFIX = "C";
|
||||
|
||||
public final class AELog
|
||||
{
|
||||
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 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 ). State %s -> %s";
|
||||
|
||||
private static final String BLOCK_UPDATE = "Block Update of %s @ ( %s ). State %s -> %s";
|
||||
private static final String DEFAULT_EXCEPTION_MESSAGE = "Exception: ";
|
||||
|
||||
private static final String DEFAULT_EXCEPTION_MESSAGE = "Exception: ";
|
||||
private AELog() {
|
||||
}
|
||||
|
||||
private AELog()
|
||||
{
|
||||
}
|
||||
/**
|
||||
* Returns a {@link Logger} logger suitable for the effective side
|
||||
* (client/server).
|
||||
*
|
||||
* @return a suitable logger instance
|
||||
*/
|
||||
private static Logger getLogger() {
|
||||
return Platform.isServer() ? SERVER : CLIENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link Logger} logger suitable for the effective side (client/server).
|
||||
*
|
||||
* @return a suitable logger instance
|
||||
*/
|
||||
private static Logger getLogger()
|
||||
{
|
||||
return Platform.isServer() ? SERVER : CLIENT;
|
||||
}
|
||||
/**
|
||||
* 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() {
|
||||
return AEConfig.instance() == null || AEConfig.instance().isFeatureEnabled(AEFeature.LOGGING);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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()
|
||||
{
|
||||
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()) {
|
||||
final String formattedMessage = String.format(message, params);
|
||||
final Logger logger = getLogger();
|
||||
|
||||
/**
|
||||
* 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() )
|
||||
{
|
||||
final String formattedMessage = String.format( message, params );
|
||||
final Logger logger = getLogger();
|
||||
logger.log(level, formattedMessage);
|
||||
}
|
||||
}
|
||||
|
||||
logger.log( level, formattedMessage );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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 (AELog.isLogEnabled()) {
|
||||
final String formattedMessage = String.format(message, params);
|
||||
final Logger logger = getLogger();
|
||||
|
||||
/**
|
||||
* 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( AELog.isLogEnabled() )
|
||||
{
|
||||
final String formattedMessage = String.format( message, params );
|
||||
final Logger logger = getLogger();
|
||||
logger.log(level, formattedMessage, exception);
|
||||
}
|
||||
}
|
||||
|
||||
logger.log( level, formattedMessage, exception );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param format
|
||||
* @param params
|
||||
*/
|
||||
public static void info(@Nonnull final String format, final Object... params) {
|
||||
log(Level.INFO, format, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param format
|
||||
* @param params
|
||||
*/
|
||||
public static void info( @Nonnull final String format, final Object... params )
|
||||
{
|
||||
log( Level.INFO, format, params );
|
||||
}
|
||||
/**
|
||||
* Log exception as {@link Level#INFO}
|
||||
*
|
||||
* @see AELog#log(Level, Throwable, String, Object...)
|
||||
*
|
||||
* @param exception
|
||||
*/
|
||||
public static void info(@Nonnull final Throwable exception) {
|
||||
log(Level.INFO, exception, DEFAULT_EXCEPTION_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log exception as {@link Level#INFO}
|
||||
*
|
||||
* @see AELog#log(Level, Throwable, String, Object...)
|
||||
*
|
||||
* @param exception
|
||||
*/
|
||||
public static void info( @Nonnull final Throwable exception )
|
||||
{
|
||||
log( Level.INFO, exception, DEFAULT_EXCEPTION_MESSAGE );
|
||||
}
|
||||
/**
|
||||
* 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.INFO, exception, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.INFO, exception, message );
|
||||
}
|
||||
/**
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param format
|
||||
* @param params
|
||||
*/
|
||||
public static void warn(@Nonnull final String format, final Object... params) {
|
||||
log(Level.WARN, format, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param format
|
||||
* @param params
|
||||
*/
|
||||
public static void warn( @Nonnull final String format, final Object... params )
|
||||
{
|
||||
log( Level.WARN, format, params );
|
||||
}
|
||||
/**
|
||||
* 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.WARN, exception, DEFAULT_EXCEPTION_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.WARN, exception, DEFAULT_EXCEPTION_MESSAGE );
|
||||
}
|
||||
/**
|
||||
* 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) {
|
||||
log(Level.WARN, exception, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 )
|
||||
{
|
||||
log( Level.WARN, exception, message );
|
||||
}
|
||||
/**
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param format
|
||||
* @param params
|
||||
*/
|
||||
public static void error(@Nonnull final String format, final Object... params) {
|
||||
log(Level.ERROR, format, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param format
|
||||
* @param params
|
||||
*/
|
||||
public static void error( @Nonnull final String format, final Object... params )
|
||||
{
|
||||
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
|
||||
*/
|
||||
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 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 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
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.DEBUG_LOGGING);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.DEBUG_LOGGING );
|
||||
}
|
||||
//
|
||||
// Specialized handlers
|
||||
//
|
||||
|
||||
//
|
||||
// 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, final Object... params) {
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.GRINDER_LOGGING)) {
|
||||
log(Level.DEBUG, "grinder: " + message, params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, final Object... params )
|
||||
{
|
||||
if( AEConfig.instance().isFeatureEnabled( AEFeature.GRINDER_LOGGING ) )
|
||||
{
|
||||
log( Level.DEBUG, "grinder: " + message, params );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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.INTEGRATION_LOGGING)) {
|
||||
debug(exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.INTEGRATION_LOGGING ) )
|
||||
{
|
||||
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 currentState
|
||||
* @param newState
|
||||
* @param aeBaseTile
|
||||
*/
|
||||
public static void blockUpdate(@Nonnull final BlockPos pos, @Nonnull BlockState currentState,
|
||||
@Nonnull BlockState newState, @Nonnull final AEBaseTile aeBaseTile) {
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.UPDATE_LOGGING)) {
|
||||
info(BLOCK_UPDATE, aeBaseTile.getClass().getName(), pos, currentState, newState);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logging of block updates.
|
||||
*
|
||||
* Off by default, can be enabled inside the configuration file.
|
||||
*
|
||||
* @see AELog#log(Level, String, Object...)
|
||||
* @param pos
|
||||
* @param currentState
|
||||
* @param newState
|
||||
* @param aeBaseTile
|
||||
*/
|
||||
public static void blockUpdate(@Nonnull final BlockPos pos, @Nonnull BlockState currentState, @Nonnull BlockState newState, @Nonnull final AEBaseTile aeBaseTile)
|
||||
{
|
||||
if( AEConfig.instance().isFeatureEnabled( AEFeature.UPDATE_LOGGING ) )
|
||||
{
|
||||
info( BLOCK_UPDATE, aeBaseTile.getClass().getName(), pos, currentState, newState );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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.CRAFTING_LOG);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.CRAFTING_LOG );
|
||||
}
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.CRAFTING_LOG)
|
||||
&& AEConfig.instance().isFeatureEnabled(AEFeature.DEBUG_LOGGING);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.CRAFTING_LOG ) && AEConfig.instance().isFeatureEnabled( AEFeature.DEBUG_LOGGING );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package appeng.core;
|
||||
|
||||
import appeng.recipes.handlers.GrinderRecipe;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.recipes.handlers.GrinderRecipe;
|
||||
|
||||
public class AERecipeType<T extends IRecipe<?>> implements IRecipeType<T> {
|
||||
private final String id;
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core;
|
||||
|
||||
|
||||
import appeng.api.IAppEngApi;
|
||||
import appeng.api.features.IRegistryContainer;
|
||||
import appeng.api.networking.IGridHelper;
|
||||
@@ -31,69 +30,59 @@ import appeng.core.api.ApiStorage;
|
||||
import appeng.core.features.registries.PartModels;
|
||||
import appeng.core.features.registries.RegistryContainer;
|
||||
|
||||
public final class Api implements IAppEngApi {
|
||||
public static final Api INSTANCE = new Api();
|
||||
|
||||
public final class Api implements IAppEngApi
|
||||
{
|
||||
public static final Api INSTANCE = new Api();
|
||||
private final ApiPart partHelper;
|
||||
|
||||
private final ApiPart partHelper;
|
||||
// private MovableTileRegistry MovableRegistry = new MovableTileRegistry();
|
||||
private final IRegistryContainer registryContainer;
|
||||
private final IStorageHelper storageHelper;
|
||||
private final IGridHelper networkHelper;
|
||||
private final ApiDefinitions definitions;
|
||||
private final IClientHelper client;
|
||||
|
||||
// private MovableTileRegistry MovableRegistry = new MovableTileRegistry();
|
||||
private final IRegistryContainer registryContainer;
|
||||
private final IStorageHelper storageHelper;
|
||||
private final IGridHelper networkHelper;
|
||||
private final ApiDefinitions definitions;
|
||||
private final IClientHelper client;
|
||||
private Api() {
|
||||
this.storageHelper = new ApiStorage();
|
||||
this.networkHelper = new ApiGrid();
|
||||
this.registryContainer = new RegistryContainer();
|
||||
this.partHelper = new ApiPart();
|
||||
this.definitions = new ApiDefinitions((PartModels) this.registryContainer.partModels());
|
||||
this.client = new ApiClientHelper();
|
||||
}
|
||||
|
||||
private Api()
|
||||
{
|
||||
this.storageHelper = new ApiStorage();
|
||||
this.networkHelper = new ApiGrid();
|
||||
this.registryContainer = new RegistryContainer();
|
||||
this.partHelper = new ApiPart();
|
||||
this.definitions = new ApiDefinitions( (PartModels) this.registryContainer.partModels() );
|
||||
this.client = new ApiClientHelper();
|
||||
}
|
||||
public PartModels getPartModels() {
|
||||
return (PartModels) this.registryContainer.partModels();
|
||||
}
|
||||
|
||||
public PartModels getPartModels()
|
||||
{
|
||||
return (PartModels) this.registryContainer.partModels();
|
||||
}
|
||||
@Override
|
||||
public IRegistryContainer registries() {
|
||||
return this.registryContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRegistryContainer registries()
|
||||
{
|
||||
return this.registryContainer;
|
||||
}
|
||||
@Override
|
||||
public IStorageHelper storage() {
|
||||
return this.storageHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageHelper storage()
|
||||
{
|
||||
return this.storageHelper;
|
||||
}
|
||||
@Override
|
||||
public IGridHelper grid() {
|
||||
return this.networkHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridHelper grid()
|
||||
{
|
||||
return this.networkHelper;
|
||||
}
|
||||
@Override
|
||||
public ApiPart partHelper() {
|
||||
return this.partHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiPart partHelper()
|
||||
{
|
||||
return this.partHelper;
|
||||
}
|
||||
@Override
|
||||
public ApiDefinitions definitions() {
|
||||
return this.definitions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiDefinitions definitions()
|
||||
{
|
||||
return this.definitions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClientHelper client()
|
||||
{
|
||||
return this.client;
|
||||
}
|
||||
@Override
|
||||
public IClientHelper client() {
|
||||
return this.client;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core;
|
||||
|
||||
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IItems;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
@@ -30,53 +29,45 @@ import appeng.core.api.definitions.ApiMaterials;
|
||||
import appeng.core.api.definitions.ApiParts;
|
||||
import appeng.core.features.registries.PartModels;
|
||||
|
||||
|
||||
/**
|
||||
* Internal implementation of the definitions for the API
|
||||
*/
|
||||
public final class ApiDefinitions implements IDefinitions
|
||||
{
|
||||
private final ApiBlocks blocks;
|
||||
private final ApiItems items;
|
||||
private final ApiMaterials materials;
|
||||
private final ApiParts parts;
|
||||
public final class ApiDefinitions implements IDefinitions {
|
||||
private final ApiBlocks blocks;
|
||||
private final ApiItems items;
|
||||
private final ApiMaterials materials;
|
||||
private final ApiParts parts;
|
||||
|
||||
private final FeatureFactory registry = new FeatureFactory();
|
||||
private final FeatureFactory registry = new FeatureFactory();
|
||||
|
||||
public ApiDefinitions( final PartModels partModels )
|
||||
{
|
||||
this.blocks = new ApiBlocks( this.registry);
|
||||
this.materials = new ApiMaterials( this.registry );
|
||||
this.items = new ApiItems( this.registry, this.materials );
|
||||
this.parts = new ApiParts( this.registry, partModels );
|
||||
}
|
||||
public ApiDefinitions(final PartModels partModels) {
|
||||
this.blocks = new ApiBlocks(this.registry);
|
||||
this.materials = new ApiMaterials(this.registry);
|
||||
this.items = new ApiItems(this.registry, this.materials);
|
||||
this.parts = new ApiParts(this.registry, partModels);
|
||||
}
|
||||
|
||||
public FeatureFactory getRegistry()
|
||||
{
|
||||
return registry;
|
||||
}
|
||||
public FeatureFactory getRegistry() {
|
||||
return registry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiBlocks blocks()
|
||||
{
|
||||
return this.blocks;
|
||||
}
|
||||
@Override
|
||||
public ApiBlocks blocks() {
|
||||
return this.blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItems items()
|
||||
{
|
||||
return items;
|
||||
}
|
||||
@Override
|
||||
public IItems items() {
|
||||
return items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMaterials materials()
|
||||
{
|
||||
return materials;
|
||||
}
|
||||
@Override
|
||||
public IMaterials materials() {
|
||||
return materials;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IParts parts()
|
||||
{
|
||||
return parts;
|
||||
}
|
||||
@Override
|
||||
public IParts parts() {
|
||||
return parts;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,33 +18,13 @@
|
||||
|
||||
package appeng.core;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.block.paint.PaintSplotchesModel;
|
||||
import appeng.block.qnb.QnbFormedModel;
|
||||
import appeng.bootstrap.components.IClientSetupComponent;
|
||||
import appeng.bootstrap.components.IInitComponent;
|
||||
import appeng.bootstrap.components.IPostInitComponent;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.client.ClientHelper;
|
||||
import appeng.client.render.DummyFluidItemModel;
|
||||
import appeng.client.render.SimpleModelLoader;
|
||||
import appeng.client.render.cablebus.CableBusModelLoader;
|
||||
import appeng.client.render.cablebus.P2PTunnelFrequencyModel;
|
||||
import appeng.client.render.crafting.CraftingCubeModelLoader;
|
||||
import appeng.client.render.crafting.EncodedPatternModelLoader;
|
||||
import appeng.client.render.model.*;
|
||||
import appeng.client.render.spatial.SpatialPylonModel;
|
||||
import appeng.core.crash.ModCrashEnhancement;
|
||||
import appeng.core.features.registries.PartModels;
|
||||
import appeng.core.stats.AdvancementTriggers;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.worlddata.WorldData;
|
||||
import appeng.entity.*;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.parts.PartPlacement;
|
||||
import appeng.parts.automation.PlaneModelLoader;
|
||||
import appeng.server.ServerHelper;
|
||||
import com.google.common.base.Stopwatch;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||
@@ -77,146 +57,179 @@ import net.minecraftforge.fml.event.server.FMLServerStoppedEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import appeng.block.paint.PaintSplotchesModel;
|
||||
import appeng.block.qnb.QnbFormedModel;
|
||||
import appeng.bootstrap.components.IClientSetupComponent;
|
||||
import appeng.bootstrap.components.IInitComponent;
|
||||
import appeng.bootstrap.components.IPostInitComponent;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.client.ClientHelper;
|
||||
import appeng.client.render.DummyFluidItemModel;
|
||||
import appeng.client.render.SimpleModelLoader;
|
||||
import appeng.client.render.cablebus.CableBusModelLoader;
|
||||
import appeng.client.render.cablebus.P2PTunnelFrequencyModel;
|
||||
import appeng.client.render.crafting.CraftingCubeModelLoader;
|
||||
import appeng.client.render.crafting.EncodedPatternModelLoader;
|
||||
import appeng.client.render.model.*;
|
||||
import appeng.client.render.spatial.SpatialPylonModel;
|
||||
import appeng.core.crash.ModCrashEnhancement;
|
||||
import appeng.core.features.registries.PartModels;
|
||||
import appeng.core.stats.AdvancementTriggers;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.worlddata.WorldData;
|
||||
import appeng.entity.*;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.parts.PartPlacement;
|
||||
import appeng.parts.automation.PlaneModelLoader;
|
||||
import appeng.server.ServerHelper;
|
||||
|
||||
@Mod(AppEng.MOD_ID)
|
||||
public final class AppEng
|
||||
{
|
||||
public static CommonHelper proxy;
|
||||
public final class AppEng {
|
||||
public static CommonHelper proxy;
|
||||
|
||||
public static final String MOD_ID = "appliedenergistics2";
|
||||
public static final String MOD_NAME = "Applied Energistics 2";
|
||||
public static final String MOD_ID = "appliedenergistics2";
|
||||
public static final String MOD_NAME = "Applied Energistics 2";
|
||||
|
||||
public static final String ASSETS = "appliedenergistics2:";
|
||||
public static final String ASSETS = "appliedenergistics2:";
|
||||
|
||||
// FIXME replicate this in mods.toml!
|
||||
// FIXME private static final String FORGE_CURRENT_VERSION = ForgeVersion.getVersion();
|
||||
// FIXME private static final String FORGE_MAX_VERSION = ( ForgeVersion.majorVersion + 1 ) + ".0.0.0";
|
||||
// FIXME public static final String MOD_DEPENDENCIES = "required-after:forge@[" + FORGE_CURRENT_VERSION + "," + FORGE_MAX_VERSION + ");after:ctm@[" + CTM.VERSION + ",);";
|
||||
// FIXME replicate this in mods.toml!
|
||||
// FIXME private static final String FORGE_CURRENT_VERSION =
|
||||
// ForgeVersion.getVersion();
|
||||
// FIXME private static final String FORGE_MAX_VERSION = (
|
||||
// ForgeVersion.majorVersion + 1 ) + ".0.0.0";
|
||||
// FIXME public static final String MOD_DEPENDENCIES = "required-after:forge@["
|
||||
// + FORGE_CURRENT_VERSION + "," + FORGE_MAX_VERSION + ");after:ctm@[" +
|
||||
// CTM.VERSION + ",);";
|
||||
|
||||
private static AppEng INSTANCE;
|
||||
private static AppEng INSTANCE;
|
||||
|
||||
private final Registration registration;
|
||||
private final Registration registration;
|
||||
|
||||
/**
|
||||
* determined in pre-init but used in init
|
||||
*/
|
||||
/**
|
||||
* determined in pre-init but used in init
|
||||
*/
|
||||
|
||||
public AppEng()
|
||||
{
|
||||
if (INSTANCE != null) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
INSTANCE = this;
|
||||
public AppEng() {
|
||||
if (INSTANCE != null) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
INSTANCE = this;
|
||||
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, AEConfig.CLIENT_SPEC);
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, AEConfig.CLIENT_SPEC);
|
||||
|
||||
proxy = DistExecutor.runForDist(() -> ClientHelper::new, () -> ServerHelper::new);
|
||||
proxy = DistExecutor.runForDist(() -> ClientHelper::new, () -> ServerHelper::new);
|
||||
|
||||
CrashReportExtender.registerCrashCallable( new ModCrashEnhancement() );
|
||||
CrashReportExtender.registerCrashCallable(new ModCrashEnhancement());
|
||||
|
||||
//FIXMEthis.registration = new Registration();
|
||||
//FIXMEMinecraftForge.EVENT_BUS.register( this.registration );
|
||||
// FIXMEthis.registration = new Registration();
|
||||
// FIXMEMinecraftForge.EVENT_BUS.register( this.registration );
|
||||
|
||||
CreativeTab.init();
|
||||
CreativeTabFacade.init();
|
||||
CreativeTab.init();
|
||||
CreativeTabFacade.init();
|
||||
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
registration = new Registration();
|
||||
modEventBus.addGenericListener(Block.class, registration::registerBlocks);
|
||||
modEventBus.addGenericListener(Item.class, registration::registerItems);
|
||||
modEventBus.addGenericListener(EntityType.class, registration::registerEntities);
|
||||
modEventBus.addGenericListener(ParticleType.class, registration::registerParticleTypes);
|
||||
modEventBus.addGenericListener(TileEntityType.class, registration::registerTileEntities);
|
||||
modEventBus.addGenericListener(ContainerType.class, registration::registerContainerTypes);
|
||||
modEventBus.addGenericListener(IRecipeSerializer.class, registration::registerRecipeSerializers);
|
||||
modEventBus.addGenericListener(Feature.class, registration::registerWorldGen);
|
||||
modEventBus.addGenericListener(Biome.class, registration::registerBiomes);
|
||||
modEventBus.addGenericListener(ModDimension.class, registration::registerModDimension);
|
||||
modEventBus.addListener(registration::registerParticleFactories);
|
||||
modEventBus.addListener(registration::registerTextures);
|
||||
modEventBus.addListener(registration::registerCommands);
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
registration = new Registration();
|
||||
modEventBus.addGenericListener(Block.class, registration::registerBlocks);
|
||||
modEventBus.addGenericListener(Item.class, registration::registerItems);
|
||||
modEventBus.addGenericListener(EntityType.class, registration::registerEntities);
|
||||
modEventBus.addGenericListener(ParticleType.class, registration::registerParticleTypes);
|
||||
modEventBus.addGenericListener(TileEntityType.class, registration::registerTileEntities);
|
||||
modEventBus.addGenericListener(ContainerType.class, registration::registerContainerTypes);
|
||||
modEventBus.addGenericListener(IRecipeSerializer.class, registration::registerRecipeSerializers);
|
||||
modEventBus.addGenericListener(Feature.class, registration::registerWorldGen);
|
||||
modEventBus.addGenericListener(Biome.class, registration::registerBiomes);
|
||||
modEventBus.addGenericListener(ModDimension.class, registration::registerModDimension);
|
||||
modEventBus.addListener(registration::registerParticleFactories);
|
||||
modEventBus.addListener(registration::registerTextures);
|
||||
modEventBus.addListener(registration::registerCommands);
|
||||
|
||||
modEventBus.addListener(this::commonSetup);
|
||||
modEventBus.addListener(this::commonSetup);
|
||||
|
||||
// Register client-only events
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> modEventBus.addListener(this::clientSetup));
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> modEventBus.addListener(registration::modelRegistryEvent));
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> modEventBus.addListener(registration::registerItemColors));
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> modEventBus.addListener(registration::handleModelBake));
|
||||
// Register client-only events
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> modEventBus.addListener(this::clientSetup));
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> modEventBus.addListener(registration::modelRegistryEvent));
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> modEventBus.addListener(registration::registerItemColors));
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> modEventBus.addListener(registration::handleModelBake));
|
||||
|
||||
MinecraftForge.EVENT_BUS.addListener( TickHandler.INSTANCE::unloadWorld );
|
||||
MinecraftForge.EVENT_BUS.addListener( TickHandler.INSTANCE::onTick );
|
||||
MinecraftForge.EVENT_BUS.addListener( this::onServerAboutToStart );
|
||||
MinecraftForge.EVENT_BUS.addListener( this::serverStopped );
|
||||
MinecraftForge.EVENT_BUS.addListener( this::serverStopping );
|
||||
MinecraftForge.EVENT_BUS.addListener(TickHandler.INSTANCE::unloadWorld);
|
||||
MinecraftForge.EVENT_BUS.addListener(TickHandler.INSTANCE::onTick);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::onServerAboutToStart);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::serverStopped);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::serverStopping);
|
||||
|
||||
MinecraftForge.EVENT_BUS.register( new PartPlacement() );
|
||||
}
|
||||
MinecraftForge.EVENT_BUS.register(new PartPlacement());
|
||||
}
|
||||
|
||||
private void commonSetup(FMLCommonSetupEvent event) {
|
||||
private void commonSetup(FMLCommonSetupEvent event) {
|
||||
|
||||
ApiDefinitions definitions = Api.INSTANCE.definitions();
|
||||
definitions.getRegistry().getBootstrapComponents( IInitComponent.class ).forEachRemaining(IInitComponent::initialize);
|
||||
definitions.getRegistry().getBootstrapComponents( IPostInitComponent.class ).forEachRemaining(IPostInitComponent::postInitialize);
|
||||
ApiDefinitions definitions = Api.INSTANCE.definitions();
|
||||
definitions.getRegistry().getBootstrapComponents(IInitComponent.class)
|
||||
.forEachRemaining(IInitComponent::initialize);
|
||||
definitions.getRegistry().getBootstrapComponents(IPostInitComponent.class)
|
||||
.forEachRemaining(IPostInitComponent::postInitialize);
|
||||
|
||||
Capabilities.register();
|
||||
Registration.setupInternalRegistries();
|
||||
Registration.postInit();
|
||||
Capabilities.register();
|
||||
Registration.setupInternalRegistries();
|
||||
Registration.postInit();
|
||||
|
||||
registerNetworkHandler();
|
||||
registerNetworkHandler();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private void clientSetup(FMLClientSetupEvent event) {
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private void clientSetup(FMLClientSetupEvent event) {
|
||||
|
||||
((ClientHelper) proxy).clientInit();
|
||||
((ClientHelper) proxy).clientInit();
|
||||
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityTinyTNTPrimed.TYPE, RenderTinyTNTPrimed::new);
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityFloatingItem.TYPE, RenderFloatingItem::new);
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntitySingularity.TYPE, m -> new ItemRenderer(m, Minecraft.getInstance().getItemRenderer()));
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityGrowingCrystal.TYPE, m -> new ItemRenderer(m, Minecraft.getInstance().getItemRenderer()));
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityChargedQuartz.TYPE, m -> new ItemRenderer(m, Minecraft.getInstance().getItemRenderer()));
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityTinyTNTPrimed.TYPE, RenderTinyTNTPrimed::new);
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityFloatingItem.TYPE, RenderFloatingItem::new);
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntitySingularity.TYPE,
|
||||
m -> new ItemRenderer(m, Minecraft.getInstance().getItemRenderer()));
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityGrowingCrystal.TYPE,
|
||||
m -> new ItemRenderer(m, Minecraft.getInstance().getItemRenderer()));
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityChargedQuartz.TYPE,
|
||||
m -> new ItemRenderer(m, Minecraft.getInstance().getItemRenderer()));
|
||||
|
||||
// TODO: Do not use the internal API
|
||||
final ApiDefinitions definitions = Api.INSTANCE.definitions();
|
||||
definitions.getRegistry().getBootstrapComponents( IClientSetupComponent.class ).forEachRemaining(IClientSetupComponent::setup);
|
||||
// TODO: Do not use the internal API
|
||||
final ApiDefinitions definitions = Api.INSTANCE.definitions();
|
||||
definitions.getRegistry().getBootstrapComponents(IClientSetupComponent.class)
|
||||
.forEachRemaining(IClientSetupComponent::setup);
|
||||
|
||||
addBuiltInModel("glass", GlassModel::new);
|
||||
addBuiltInModel("sky_compass", SkyCompassModel::new);
|
||||
addBuiltInModel("dummy_fluid_item", DummyFluidItemModel::new);
|
||||
addBuiltInModel("memory_card", MemoryCardModel::new);
|
||||
addBuiltInModel("biometric_card", BiometricCardModel::new);
|
||||
addBuiltInModel("drive", DriveModel::new);
|
||||
addBuiltInModel("color_applicator", ColorApplicatorModel::new);
|
||||
addBuiltInModel("spatial_pylon", SpatialPylonModel::new);
|
||||
addBuiltInModel("paint_splotches", PaintSplotchesModel::new);
|
||||
addBuiltInModel("quantum_bridge_formed", QnbFormedModel::new);
|
||||
addBuiltInModel("p2p_tunnel_frequency", P2PTunnelFrequencyModel::new);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "encoded_pattern"), EncodedPatternModelLoader.INSTANCE);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "part_plane"), PlaneModelLoader.INSTANCE);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "crafting_cube"), CraftingCubeModelLoader.INSTANCE);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "uvlightmap"), UVLModelLoader.INSTANCE);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "cable_bus"), new CableBusModelLoader((PartModels) Api.INSTANCE.registries().partModels()));
|
||||
addBuiltInModel("glass", GlassModel::new);
|
||||
addBuiltInModel("sky_compass", SkyCompassModel::new);
|
||||
addBuiltInModel("dummy_fluid_item", DummyFluidItemModel::new);
|
||||
addBuiltInModel("memory_card", MemoryCardModel::new);
|
||||
addBuiltInModel("biometric_card", BiometricCardModel::new);
|
||||
addBuiltInModel("drive", DriveModel::new);
|
||||
addBuiltInModel("color_applicator", ColorApplicatorModel::new);
|
||||
addBuiltInModel("spatial_pylon", SpatialPylonModel::new);
|
||||
addBuiltInModel("paint_splotches", PaintSplotchesModel::new);
|
||||
addBuiltInModel("quantum_bridge_formed", QnbFormedModel::new);
|
||||
addBuiltInModel("p2p_tunnel_frequency", P2PTunnelFrequencyModel::new);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "encoded_pattern"),
|
||||
EncodedPatternModelLoader.INSTANCE);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "part_plane"),
|
||||
PlaneModelLoader.INSTANCE);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "crafting_cube"),
|
||||
CraftingCubeModelLoader.INSTANCE);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "uvlightmap"), UVLModelLoader.INSTANCE);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "cable_bus"),
|
||||
new CableBusModelLoader((PartModels) Api.INSTANCE.registries().partModels()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static <T extends IModelGeometry<T>> void addBuiltInModel(String id, Supplier<T> modelFactory) {
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, id), new SimpleModelLoader<T>(modelFactory));
|
||||
}
|
||||
private static <T extends IModelGeometry<T>> void addBuiltInModel(String id, Supplier<T> modelFactory) {
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, id),
|
||||
new SimpleModelLoader<T>(modelFactory));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static AppEng instance()
|
||||
{
|
||||
if (INSTANCE == null) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
@Nonnull
|
||||
public static AppEng instance() {
|
||||
if (INSTANCE == null) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
// public Biome getStorageBiome()
|
||||
// {
|
||||
@@ -233,10 +246,9 @@ public final class AppEng
|
||||
// return this.registration.storageDimensionID;
|
||||
// }
|
||||
|
||||
public AdvancementTriggers getAdvancementTriggers()
|
||||
{
|
||||
return this.registration.advancementTriggers;
|
||||
}
|
||||
public AdvancementTriggers getAdvancementTriggers() {
|
||||
return this.registration.advancementTriggers;
|
||||
}
|
||||
|
||||
// @EventHandler
|
||||
// private void preInit( final FMLPreInitializationEvent event )
|
||||
@@ -278,45 +290,41 @@ public final class AppEng
|
||||
// new PluginLoader().loadPlugins( injectables, event.getAsmData() );
|
||||
// }
|
||||
|
||||
private void startService( final String serviceName, final Thread thread )
|
||||
{
|
||||
thread.setName( serviceName );
|
||||
thread.setPriority( Thread.MIN_PRIORITY );
|
||||
private void startService(final String serviceName, final Thread thread) {
|
||||
thread.setName(serviceName);
|
||||
thread.setPriority(Thread.MIN_PRIORITY);
|
||||
|
||||
AELog.info( "Starting " + serviceName );
|
||||
thread.start();
|
||||
}
|
||||
AELog.info("Starting " + serviceName);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
private void registerNetworkHandler()
|
||||
{
|
||||
final Stopwatch start = Stopwatch.createStarted();
|
||||
AELog.info( "Post Initialization ( started )" );
|
||||
private void registerNetworkHandler() {
|
||||
final Stopwatch start = Stopwatch.createStarted();
|
||||
AELog.info("Post Initialization ( started )");
|
||||
|
||||
// FIXME IntegrationRegistry.INSTANCE.postInit();
|
||||
// FIXME CrashReportExtender.registerCrashCallable( new IntegrationCrashEnhancement() );
|
||||
// FIXME IntegrationRegistry.INSTANCE.postInit();
|
||||
// FIXME CrashReportExtender.registerCrashCallable( new
|
||||
// IntegrationCrashEnhancement() );
|
||||
|
||||
AppEng.proxy.postInit();
|
||||
AEConfig.instance().save();
|
||||
AppEng.proxy.postInit();
|
||||
AEConfig.instance().save();
|
||||
|
||||
NetworkHandler.init( new ResourceLocation(MOD_ID, "main") );
|
||||
NetworkHandler.init(new ResourceLocation(MOD_ID, "main"));
|
||||
|
||||
AELog.info( "Post Initialization ( ended after " + start.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
|
||||
}
|
||||
AELog.info("Post Initialization ( ended after " + start.elapsed(TimeUnit.MILLISECONDS) + "ms )");
|
||||
}
|
||||
|
||||
private void onServerAboutToStart(final FMLServerAboutToStartEvent evt)
|
||||
{
|
||||
WorldData.onServerStarting( evt.getServer() );
|
||||
}
|
||||
private void onServerAboutToStart(final FMLServerAboutToStartEvent evt) {
|
||||
WorldData.onServerStarting(evt.getServer());
|
||||
}
|
||||
|
||||
private void serverStopping( final FMLServerStoppingEvent event )
|
||||
{
|
||||
WorldData.instance().onServerStopping();
|
||||
}
|
||||
private void serverStopping(final FMLServerStoppingEvent event) {
|
||||
WorldData.instance().onServerStopping();
|
||||
}
|
||||
|
||||
private void serverStopped( final FMLServerStoppedEvent event )
|
||||
{
|
||||
WorldData.instance().onServerStoppped();
|
||||
TickHandler.INSTANCE.shutdown();
|
||||
}
|
||||
private void serverStopped(final FMLServerStoppedEvent event) {
|
||||
WorldData.instance().onServerStoppped();
|
||||
TickHandler.INSTANCE.shutdown();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@@ -36,32 +35,32 @@ import appeng.client.ActionKey;
|
||||
import appeng.client.EffectType;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
|
||||
public abstract class CommonHelper {
|
||||
|
||||
public abstract class CommonHelper
|
||||
{
|
||||
public abstract World getWorld();
|
||||
|
||||
public abstract World getWorld();
|
||||
public abstract void bindTileEntitySpecialRenderer(Class<? extends TileEntity> tile, AEBaseBlock blk);
|
||||
|
||||
public abstract void bindTileEntitySpecialRenderer( Class<? extends TileEntity> tile, AEBaseBlock blk );
|
||||
public abstract List<? extends PlayerEntity> getPlayers();
|
||||
|
||||
public abstract List<? extends PlayerEntity> getPlayers();
|
||||
public abstract void sendToAllNearExcept(PlayerEntity p, double x, double y, double z, double dist, World w,
|
||||
AppEngPacket packet);
|
||||
|
||||
public abstract void sendToAllNearExcept( PlayerEntity p, double x, double y, double z, double dist, World w, AppEngPacket packet );
|
||||
public abstract void spawnEffect(EffectType effect, World world, double posX, double posY, double posZ,
|
||||
Object extra);
|
||||
|
||||
public abstract void spawnEffect( EffectType effect, World world, double posX, double posY, double posZ, Object extra );
|
||||
public abstract boolean shouldAddParticles(Random r);
|
||||
|
||||
public abstract boolean shouldAddParticles( Random r );
|
||||
public abstract RayTraceResult getRTR();
|
||||
|
||||
public abstract RayTraceResult getRTR();
|
||||
public abstract void postInit();
|
||||
|
||||
public abstract void postInit();
|
||||
public abstract CableRenderMode getRenderMode();
|
||||
|
||||
public abstract CableRenderMode getRenderMode();
|
||||
public abstract void triggerUpdates();
|
||||
|
||||
public abstract void triggerUpdates();
|
||||
public abstract void updateRenderMode(PlayerEntity player);
|
||||
|
||||
public abstract void updateRenderMode( PlayerEntity player );
|
||||
|
||||
public abstract boolean isActionKey( @Nonnull final ActionKey key, InputMappings.Input input );
|
||||
public abstract boolean isActionKey(@Nonnull final ActionKey key, InputMappings.Input input);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,14 +18,12 @@
|
||||
|
||||
package appeng.core;
|
||||
|
||||
public final class CreativeTab {
|
||||
|
||||
public final class CreativeTab
|
||||
{
|
||||
public static AEItemGroup INSTANCE;
|
||||
|
||||
public static AEItemGroup INSTANCE;
|
||||
|
||||
public static void init() {
|
||||
INSTANCE = new AEItemGroup( "appliedenergistics2" );
|
||||
}
|
||||
public static void init() {
|
||||
INSTANCE = new AEItemGroup("appliedenergistics2");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core;
|
||||
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
@@ -28,28 +27,25 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
|
||||
public final class CreativeTabFacade {
|
||||
public static ItemGroup instance = null;
|
||||
|
||||
public final class CreativeTabFacade
|
||||
{
|
||||
public static ItemGroup instance = null;
|
||||
static void init() {
|
||||
instance = new ItemGroup("appliedenergistics2.facades") {
|
||||
|
||||
static void init()
|
||||
{
|
||||
instance = new ItemGroup("appliedenergistics2.facades") {
|
||||
@Override
|
||||
public ItemStack createIcon() {
|
||||
|
||||
@Override
|
||||
public ItemStack createIcon()
|
||||
{
|
||||
// FIXME final Optional<Item> maybeFacade =
|
||||
// AEApi.instance().definitions().items().facade().maybeItem();
|
||||
// FIXME if( maybeFacade.isPresent() )
|
||||
{
|
||||
// FIXME return ( (ItemFacade) maybeFacade.get() ).getCreativeTabIcon();
|
||||
}
|
||||
|
||||
// FIXME final Optional<Item> maybeFacade = AEApi.instance().definitions().items().facade().maybeItem();
|
||||
// FIXME if( maybeFacade.isPresent() )
|
||||
{
|
||||
// FIXME return ( (ItemFacade) maybeFacade.get() ).getCreativeTabIcon();
|
||||
}
|
||||
|
||||
return new ItemStack( Blocks.OAK_PLANKS );
|
||||
}
|
||||
};
|
||||
}
|
||||
return new ItemStack(Blocks.OAK_PLANKS);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,52 +18,48 @@
|
||||
|
||||
package appeng.core;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntArrayMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.io.File;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntArrayMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
|
||||
public class FacadeConfig {
|
||||
|
||||
public class FacadeConfig
|
||||
{
|
||||
private static final String CONFIG_VERSION = "1";
|
||||
private static final String CONFIG_COMMON_KEY = "common";
|
||||
private static final String CONFIG_COMMON_COMMENT = "Settings applied to all facades.\n\n" //
|
||||
+ "By default full blocks with no tile entity and a model do not need whitelisting.\n"//
|
||||
+ "This will only be read once during client startup.";
|
||||
private static final String CONFIG_COMMON_ALLOW_TILEENTITIES_KEY = "allowTileEntityFacades";
|
||||
private static final String CONFIG_COMMON_ALLOW_TILEENTITIES_COMMENT = "Unsupported: Allows whitelisting TileEntity as facades. Could work, have render issues, or corrupt your world. USE AT YOUR OWN RISK.";
|
||||
private static final String CONFIG_FACADES_KEY = "facades";
|
||||
private static final String CONFIG_FACADES_COMMENT = "A way to explicitly handle certain blocks as facades.\n\n" //
|
||||
+ "Blocks can be added by their resource location under the following rules.\n" //
|
||||
+ " - One category per domain like minecraft or appliedenergistics2\n" //
|
||||
+ " - One key per id. E.g. glass in case of minecraft:glass\n" //
|
||||
+ " - An integer value ranging from 0 to 16 representing the metadata 0-15 and 16 as wildcard for all" //
|
||||
+ " - Multiple entries for the same id but different metadata are possible when needed";
|
||||
|
||||
private static final String CONFIG_VERSION = "1";
|
||||
private static final String CONFIG_COMMON_KEY = "common";
|
||||
private static final String CONFIG_COMMON_COMMENT = "Settings applied to all facades.\n\n" //
|
||||
+ "By default full blocks with no tile entity and a model do not need whitelisting.\n"//
|
||||
+ "This will only be read once during client startup.";
|
||||
private static final String CONFIG_COMMON_ALLOW_TILEENTITIES_KEY = "allowTileEntityFacades";
|
||||
private static final String CONFIG_COMMON_ALLOW_TILEENTITIES_COMMENT = "Unsupported: Allows whitelisting TileEntity as facades. Could work, have render issues, or corrupt your world. USE AT YOUR OWN RISK.";
|
||||
private static final String CONFIG_FACADES_KEY = "facades";
|
||||
private static final String CONFIG_FACADES_COMMENT = "A way to explicitly handle certain blocks as facades.\n\n" //
|
||||
+ "Blocks can be added by their resource location under the following rules.\n" //
|
||||
+ " - One category per domain like minecraft or appliedenergistics2\n" //
|
||||
+ " - One key per id. E.g. glass in case of minecraft:glass\n" //
|
||||
+ " - An integer value ranging from 0 to 16 representing the metadata 0-15 and 16 as wildcard for all" //
|
||||
+ " - Multiple entries for the same id but different metadata are possible when needed";
|
||||
private static FacadeConfig instance;
|
||||
|
||||
private static FacadeConfig instance;
|
||||
private final boolean allowTileEntityFacades;
|
||||
private final Object2IntMap<ResourceLocation> whiteList;
|
||||
|
||||
private final boolean allowTileEntityFacades;
|
||||
private final Object2IntMap<ResourceLocation> whiteList;
|
||||
private FacadeConfig(boolean allowTileEntityFacades, Object2IntMap<ResourceLocation> whiteList) {
|
||||
this.allowTileEntityFacades = allowTileEntityFacades;
|
||||
this.whiteList = whiteList;
|
||||
}
|
||||
|
||||
private FacadeConfig( boolean allowTileEntityFacades, Object2IntMap<ResourceLocation> whiteList )
|
||||
{
|
||||
this.allowTileEntityFacades = allowTileEntityFacades;
|
||||
this.whiteList = whiteList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a custom confuration based on a {@link Configuration}, but ultimately throws it away after reading it
|
||||
* once to save a couple MB of memory.
|
||||
*
|
||||
* @param configFile
|
||||
*/
|
||||
public static void init( final File configFile )
|
||||
{
|
||||
/**
|
||||
* Creates a custom confuration based on a {@link Configuration}, but ultimately
|
||||
* throws it away after reading it once to save a couple MB of memory.
|
||||
*
|
||||
* @param configFile
|
||||
*/
|
||||
public static void init(final File configFile) {
|
||||
// FIXME final Configuration configurartion = migrate( new Configuration( configFile, CONFIG_VERSION ) );
|
||||
// FIXME
|
||||
// FIXME final boolean allowTileEntityFacades = configurartion
|
||||
@@ -91,8 +87,8 @@ public class FacadeConfig
|
||||
// FIXME configurartion.save();
|
||||
// FIXME }
|
||||
|
||||
instance = new FacadeConfig( false, new Object2IntArrayMap<>() ); // FIXME
|
||||
}
|
||||
instance = new FacadeConfig(false, new Object2IntArrayMap<>()); // FIXME
|
||||
}
|
||||
|
||||
// FIXME private static Configuration migrate( Configuration configurartion )
|
||||
// FIXME {
|
||||
@@ -132,25 +128,21 @@ public class FacadeConfig
|
||||
// FIXME return configurartion;
|
||||
// FIXME }
|
||||
|
||||
public static FacadeConfig instance()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
public static FacadeConfig instance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public boolean allowTileEntityFacades()
|
||||
{
|
||||
return this.allowTileEntityFacades;
|
||||
}
|
||||
public boolean allowTileEntityFacades() {
|
||||
return this.allowTileEntityFacades;
|
||||
}
|
||||
|
||||
public boolean isWhiteListed( final Block block, final int metadata )
|
||||
{
|
||||
final Integer entry = this.whiteList.get( block.getRegistryName() );
|
||||
public boolean isWhiteListed(final Block block, final int metadata) {
|
||||
final Integer entry = this.whiteList.get(block.getRegistryName());
|
||||
|
||||
if( entry != null )
|
||||
{
|
||||
return entry == metadata || entry == 16;
|
||||
}
|
||||
if (entry != null) {
|
||||
return entry == metadata || entry == 16;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core;
|
||||
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.Collection;
|
||||
@@ -37,131 +36,113 @@ import net.minecraftforge.forgespi.language.ModFileScanData;
|
||||
import appeng.api.AEInjectable;
|
||||
import appeng.api.AEPlugin;
|
||||
|
||||
|
||||
/**
|
||||
* Loads AE plugins on startup and provides them with access to various components of the AE API.
|
||||
* Loads AE plugins on startup and provides them with access to various
|
||||
* components of the AE API.
|
||||
*/
|
||||
class PluginLoader
|
||||
{
|
||||
class PluginLoader {
|
||||
|
||||
public void loadPlugins( Collection<Object> injectables )
|
||||
{
|
||||
Map<Class<?>, Object> injectableMap = mapInjectables( injectables );
|
||||
findAndInstantiatePlugins( injectableMap );
|
||||
}
|
||||
public void loadPlugins(Collection<Object> injectables) {
|
||||
Map<Class<?>, Object> injectableMap = mapInjectables(injectables);
|
||||
findAndInstantiatePlugins(injectableMap);
|
||||
}
|
||||
|
||||
private static void findAndInstantiatePlugins( Map<Class<?>, Object> injectableMap )
|
||||
{
|
||||
Type aType = Type.getType( AEPlugin.class );
|
||||
Set<ModFileScanData.AnnotationData> allAnnotated = ModList.get().getAllScanData().stream().map( ModFileScanData::getAnnotations ).flatMap( Collection::stream ).filter( a -> a.getAnnotationType().equals( aType ) ).filter( a -> a.getTargetType() == ElementType.TYPE ).collect( Collectors.toSet() );
|
||||
private static void findAndInstantiatePlugins(Map<Class<?>, Object> injectableMap) {
|
||||
Type aType = Type.getType(AEPlugin.class);
|
||||
Set<ModFileScanData.AnnotationData> allAnnotated = ModList.get().getAllScanData().stream()
|
||||
.map(ModFileScanData::getAnnotations).flatMap(Collection::stream)
|
||||
.filter(a -> a.getAnnotationType().equals(aType)).filter(a -> a.getTargetType() == ElementType.TYPE)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
for( ModFileScanData.AnnotationData candidate : allAnnotated )
|
||||
{
|
||||
for (ModFileScanData.AnnotationData candidate : allAnnotated) {
|
||||
|
||||
String cName = candidate.getMemberName();
|
||||
Class<?> aClass;
|
||||
try
|
||||
{
|
||||
aClass = Class.forName( cName );
|
||||
}
|
||||
catch( ClassNotFoundException e )
|
||||
{
|
||||
AELog.error( e, "Couldn't find annotated AE plugin class " + cName );
|
||||
throw new RuntimeException( "Couldn't find annotated AE plugin class " + cName, e );
|
||||
}
|
||||
String cName = candidate.getMemberName();
|
||||
Class<?> aClass;
|
||||
try {
|
||||
aClass = Class.forName(cName);
|
||||
} catch (ClassNotFoundException e) {
|
||||
AELog.error(e, "Couldn't find annotated AE plugin class " + cName);
|
||||
throw new RuntimeException("Couldn't find annotated AE plugin class " + cName, e);
|
||||
}
|
||||
|
||||
// Try instantiating the plugin
|
||||
try
|
||||
{
|
||||
Object plugin = instantiatePlugin( aClass, injectableMap );
|
||||
AELog.info( "Loaded AE2 Plugin {}", plugin.getClass() );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
AELog.error( e, "Unable to instantiate AE plugin " + cName );
|
||||
throw new RuntimeException( "Unable to instantiate AE plugin " + cName, e );
|
||||
}
|
||||
}
|
||||
}
|
||||
// Try instantiating the plugin
|
||||
try {
|
||||
Object plugin = instantiatePlugin(aClass, injectableMap);
|
||||
AELog.info("Loaded AE2 Plugin {}", plugin.getClass());
|
||||
} catch (Exception e) {
|
||||
AELog.error(e, "Unable to instantiate AE plugin " + cName);
|
||||
throw new RuntimeException("Unable to instantiate AE plugin " + cName, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Object instantiatePlugin( Class<?> aClass, Map<Class<?>, Object> injectableMap ) throws Exception
|
||||
{
|
||||
private static Object instantiatePlugin(Class<?> aClass, Map<Class<?>, Object> injectableMap) throws Exception {
|
||||
|
||||
Constructor<?>[] constructors = aClass.getDeclaredConstructors();
|
||||
Constructor<?>[] constructors = aClass.getDeclaredConstructors();
|
||||
|
||||
if( constructors.length == 0 )
|
||||
{
|
||||
// This is the default no-arg constructor, although it seems pointless to instantiate anything but not take
|
||||
// any AE dependencies as parameters
|
||||
return aClass.newInstance();
|
||||
}
|
||||
else if( constructors.length != 1 )
|
||||
{
|
||||
throw new IllegalArgumentException( "Expected a single constructor, but found: " + constructors.length );
|
||||
}
|
||||
if (constructors.length == 0) {
|
||||
// This is the default no-arg constructor, although it seems pointless to
|
||||
// instantiate anything but not take
|
||||
// any AE dependencies as parameters
|
||||
return aClass.newInstance();
|
||||
} else if (constructors.length != 1) {
|
||||
throw new IllegalArgumentException("Expected a single constructor, but found: " + constructors.length);
|
||||
}
|
||||
|
||||
Constructor<?> constructor = constructors[0];
|
||||
constructor.setAccessible( true );
|
||||
Constructor<?> constructor = constructors[0];
|
||||
constructor.setAccessible(true);
|
||||
|
||||
Object[] args = findInjectables( constructor, injectableMap );
|
||||
Object[] args = findInjectables(constructor, injectableMap);
|
||||
|
||||
return constructor.newInstance( args );
|
||||
}
|
||||
return constructor.newInstance(args);
|
||||
}
|
||||
|
||||
private static Object[] findInjectables( Constructor<?> constructor, Map<Class<?>, Object> injectableMap )
|
||||
{
|
||||
private static Object[] findInjectables(Constructor<?> constructor, Map<Class<?>, Object> injectableMap) {
|
||||
|
||||
Class<?>[] types = constructor.getParameterTypes();
|
||||
Object[] args = new Object[types.length];
|
||||
Class<?>[] types = constructor.getParameterTypes();
|
||||
Object[] args = new Object[types.length];
|
||||
|
||||
for( int i = 0; i < types.length; i++ )
|
||||
{
|
||||
args[i] = injectableMap.get( types[i] );
|
||||
if( args[i] == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "Constructor has parameter of type " + types[i] + " which is not an injectable type." + " Please see the documentation for @AEPlugin." );
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
args[i] = injectableMap.get(types[i]);
|
||||
if (args[i] == null) {
|
||||
throw new IllegalArgumentException("Constructor has parameter of type " + types[i]
|
||||
+ " which is not an injectable type." + " Please see the documentation for @AEPlugin.");
|
||||
}
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
private static Map<Class<?>, Object> mapInjectables( Collection<Object> injectables )
|
||||
{
|
||||
ImmutableMap.Builder<Class<?>, Object> builder = ImmutableMap.builder();
|
||||
private static Map<Class<?>, Object> mapInjectables(Collection<Object> injectables) {
|
||||
ImmutableMap.Builder<Class<?>, Object> builder = ImmutableMap.builder();
|
||||
|
||||
for( Object injectable : injectables )
|
||||
{
|
||||
// Get all super-interfaces that were annotated with @AEInjectable
|
||||
Set<Class<?>> injectableIfs = getInjectableInterfaces( injectable.getClass() );
|
||||
for( Class<?> injectableIf : injectableIfs )
|
||||
{
|
||||
builder.put( injectableIf, injectable );
|
||||
}
|
||||
}
|
||||
for (Object injectable : injectables) {
|
||||
// Get all super-interfaces that were annotated with @AEInjectable
|
||||
Set<Class<?>> injectableIfs = getInjectableInterfaces(injectable.getClass());
|
||||
for (Class<?> injectableIf : injectableIfs) {
|
||||
builder.put(injectableIf, injectable);
|
||||
}
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private static Set<Class<?>> getInjectableInterfaces( Class<?> aClass )
|
||||
{
|
||||
Set<Class<?>> hierarchy = new HashSet<>();
|
||||
getFullHierarchy( aClass, hierarchy );
|
||||
private static Set<Class<?>> getInjectableInterfaces(Class<?> aClass) {
|
||||
Set<Class<?>> hierarchy = new HashSet<>();
|
||||
getFullHierarchy(aClass, hierarchy);
|
||||
|
||||
return hierarchy.stream().filter( c -> c.getAnnotation( AEInjectable.class ) != null ).collect( Collectors.toSet() );
|
||||
}
|
||||
return hierarchy.stream().filter(c -> c.getAnnotation(AEInjectable.class) != null).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
// Recursively gather all superclasses and superinterfaces of the given class and put them into the given collection
|
||||
private static void getFullHierarchy( Class<?> aClass, Set<Class<?>> classes )
|
||||
{
|
||||
classes.add( aClass );
|
||||
for( Class<?> anIf : aClass.getInterfaces() )
|
||||
{
|
||||
getFullHierarchy( anIf, classes );
|
||||
}
|
||||
if( aClass.getSuperclass() != null )
|
||||
{
|
||||
getFullHierarchy( aClass.getSuperclass(), classes );
|
||||
}
|
||||
}
|
||||
// Recursively gather all superclasses and superinterfaces of the given class
|
||||
// and put them into the given collection
|
||||
private static void getFullHierarchy(Class<?> aClass, Set<Class<?>> classes) {
|
||||
classes.add(aClass);
|
||||
for (Class<?> anIf : aClass.getInterfaces()) {
|
||||
getFullHierarchy(anIf, classes);
|
||||
}
|
||||
if (aClass.getSuperclass() != null) {
|
||||
getFullHierarchy(aClass.getSuperclass(), classes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,62 +1,51 @@
|
||||
|
||||
package appeng.core.api;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
|
||||
import appeng.api.config.IncludeExclude;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.IClientHelper;
|
||||
import appeng.core.localization.GuiText;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
|
||||
public class ApiClientHelper implements IClientHelper {
|
||||
@Override
|
||||
public <T extends IAEStack<T>> void addCellInformation(ICellInventoryHandler<T> handler,
|
||||
List<ITextComponent> lines) {
|
||||
if (handler == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
public class ApiClientHelper implements IClientHelper
|
||||
{
|
||||
@Override
|
||||
public <T extends IAEStack<T>> void addCellInformation( ICellInventoryHandler<T> handler, List<ITextComponent> lines )
|
||||
{
|
||||
if( handler == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final ICellInventory<?> cellInventory = handler.getCellInv();
|
||||
|
||||
final ICellInventory<?> cellInventory = handler.getCellInv();
|
||||
if (cellInventory != null) {
|
||||
lines.add(new StringTextComponent(cellInventory.getUsedBytes() + " ")
|
||||
.appendSibling(GuiText.Of.textComponent()).appendText(" " + cellInventory.getTotalBytes() + " ")
|
||||
.appendSibling(GuiText.BytesUsed.textComponent()));
|
||||
|
||||
if( cellInventory != null )
|
||||
{
|
||||
lines.add(new StringTextComponent(cellInventory.getUsedBytes() + " ")
|
||||
.appendSibling(GuiText.Of.textComponent())
|
||||
.appendText(" " + cellInventory.getTotalBytes() + " ")
|
||||
.appendSibling(GuiText.BytesUsed.textComponent()));
|
||||
lines.add(new StringTextComponent(cellInventory.getStoredItemTypes() + " ")
|
||||
.appendSibling(GuiText.Of.textComponent()).appendText(" " + cellInventory.getTotalItemTypes() + " ")
|
||||
.appendSibling(GuiText.Types.textComponent()));
|
||||
}
|
||||
|
||||
lines.add(new StringTextComponent(cellInventory.getStoredItemTypes() + " ")
|
||||
.appendSibling(GuiText.Of.textComponent())
|
||||
.appendText(" " + cellInventory.getTotalItemTypes() + " ")
|
||||
.appendSibling(GuiText.Types.textComponent()));
|
||||
}
|
||||
if (handler.isPreformatted()) {
|
||||
final String list = (handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included
|
||||
: GuiText.Excluded).getLocal();
|
||||
|
||||
if( handler.isPreformatted() )
|
||||
{
|
||||
final String list = ( handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included : GuiText.Excluded ).getLocal();
|
||||
if (handler.isFuzzy()) {
|
||||
lines.add(GuiText.Partitioned.textComponent().appendText(" - " + list + " ")
|
||||
.appendSibling(GuiText.Fuzzy.textComponent()));
|
||||
} else {
|
||||
lines.add(GuiText.Partitioned.textComponent().appendText(" - " + list + " ")
|
||||
.appendSibling(GuiText.Precise.textComponent()));
|
||||
}
|
||||
}
|
||||
|
||||
if( handler.isFuzzy() )
|
||||
{
|
||||
lines.add( GuiText.Partitioned.textComponent()
|
||||
.appendText(" - " + list + " ")
|
||||
.appendSibling(GuiText.Fuzzy.textComponent()));
|
||||
}
|
||||
else
|
||||
{
|
||||
lines.add( GuiText.Partitioned.textComponent()
|
||||
.appendText(" - " + list + " ")
|
||||
.appendSibling(GuiText.Precise.textComponent()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.api;
|
||||
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import appeng.api.exceptions.FailedConnectionException;
|
||||
@@ -31,35 +30,30 @@ import appeng.me.GridConnection;
|
||||
import appeng.me.GridNode;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
/**
|
||||
* @author yueh
|
||||
* @version rv5
|
||||
* @since rv5
|
||||
*/
|
||||
public class ApiGrid implements IGridHelper
|
||||
{
|
||||
public class ApiGrid implements IGridHelper {
|
||||
|
||||
@Override
|
||||
public IGridNode createGridNode( final IGridBlock blk )
|
||||
{
|
||||
Preconditions.checkNotNull( blk );
|
||||
@Override
|
||||
public IGridNode createGridNode(final IGridBlock blk) {
|
||||
Preconditions.checkNotNull(blk);
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
throw new IllegalStateException( "Grid features for " + blk + " are server side only." );
|
||||
}
|
||||
if (Platform.isClient()) {
|
||||
throw new IllegalStateException("Grid features for " + blk + " are server side only.");
|
||||
}
|
||||
|
||||
return new GridNode( blk );
|
||||
}
|
||||
return new GridNode(blk);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridConnection createGridConnection( final IGridNode a, final IGridNode b ) throws FailedConnectionException
|
||||
{
|
||||
Preconditions.checkNotNull( a );
|
||||
Preconditions.checkNotNull( b );
|
||||
@Override
|
||||
public IGridConnection createGridConnection(final IGridNode a, final IGridNode b) throws FailedConnectionException {
|
||||
Preconditions.checkNotNull(a);
|
||||
Preconditions.checkNotNull(b);
|
||||
|
||||
return GridConnection.create( a, b, AEPartLocation.INTERNAL );
|
||||
}
|
||||
return GridConnection.create(a, b, AEPartLocation.INTERNAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.api;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
@@ -32,19 +31,16 @@ import appeng.api.parts.IPartHelper;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.parts.PartPlacement;
|
||||
|
||||
public class ApiPart implements IPartHelper {
|
||||
|
||||
public class ApiPart implements IPartHelper
|
||||
{
|
||||
@Override
|
||||
public ActionResultType placeBus(final ItemStack is, final BlockPos pos, final Direction side,
|
||||
final PlayerEntity player, final Hand hand, final World w) {
|
||||
return PartPlacement.place(is, pos, side, player, hand, w, PartPlacement.PlaceType.PLACE_ITEM, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType placeBus( final ItemStack is, final BlockPos pos, final Direction side, final PlayerEntity player, final Hand hand, final World w )
|
||||
{
|
||||
return PartPlacement.place( is, pos, side, player, hand, w, PartPlacement.PlaceType.PLACE_ITEM, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public CableRenderMode getCableRenderMode()
|
||||
{
|
||||
return AppEng.proxy.getRenderMode();
|
||||
}
|
||||
@Override
|
||||
public CableRenderMode getCableRenderMode() {
|
||||
return AppEng.proxy.getRenderMode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.api;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -56,177 +55,152 @@ import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import appeng.util.item.ItemList;
|
||||
|
||||
public class ApiStorage implements IStorageHelper {
|
||||
|
||||
public class ApiStorage implements IStorageHelper
|
||||
{
|
||||
private final ClassToInstanceMap<IStorageChannel<?>> channels;
|
||||
|
||||
private final ClassToInstanceMap<IStorageChannel<?>> channels;
|
||||
public ApiStorage() {
|
||||
this.channels = MutableClassToInstanceMap.create();
|
||||
this.registerStorageChannel(IItemStorageChannel.class, new ItemStorageChannel());
|
||||
this.registerStorageChannel(IFluidStorageChannel.class, new FluidStorageChannel());
|
||||
}
|
||||
|
||||
public ApiStorage()
|
||||
{
|
||||
this.channels = MutableClassToInstanceMap.create();
|
||||
this.registerStorageChannel( IItemStorageChannel.class, new ItemStorageChannel() );
|
||||
this.registerStorageChannel( IFluidStorageChannel.class, new FluidStorageChannel() );
|
||||
}
|
||||
@Override
|
||||
public <T extends IAEStack<T>, C extends IStorageChannel<T>> void registerStorageChannel(Class<C> channel,
|
||||
C factory) {
|
||||
Preconditions.checkNotNull(channel);
|
||||
Preconditions.checkNotNull(factory);
|
||||
Preconditions.checkArgument(channel.isInstance(factory));
|
||||
Preconditions.checkArgument(!this.channels.containsKey(channel));
|
||||
|
||||
@Override
|
||||
public <T extends IAEStack<T>, C extends IStorageChannel<T>> void registerStorageChannel( Class<C> channel, C factory )
|
||||
{
|
||||
Preconditions.checkNotNull( channel );
|
||||
Preconditions.checkNotNull( factory );
|
||||
Preconditions.checkArgument( channel.isInstance( factory ) );
|
||||
Preconditions.checkArgument( !this.channels.containsKey( channel ) );
|
||||
this.channels.putInstance(channel, factory);
|
||||
}
|
||||
|
||||
this.channels.putInstance( channel, factory );
|
||||
}
|
||||
@Override
|
||||
public <T extends IAEStack<T>, C extends IStorageChannel<T>> C getStorageChannel(Class<C> channel) {
|
||||
Preconditions.checkNotNull(channel);
|
||||
|
||||
@Override
|
||||
public <T extends IAEStack<T>, C extends IStorageChannel<T>> C getStorageChannel( Class<C> channel )
|
||||
{
|
||||
Preconditions.checkNotNull( channel );
|
||||
final C type = this.channels.getInstance(channel);
|
||||
|
||||
final C type = this.channels.getInstance( channel );
|
||||
Preconditions.checkNotNull(type);
|
||||
|
||||
Preconditions.checkNotNull( type );
|
||||
return type;
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
@Override
|
||||
public Collection<IStorageChannel<? extends IAEStack<?>>> storageChannels() {
|
||||
return Collections.unmodifiableCollection(this.channels.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IStorageChannel<? extends IAEStack<?>>> storageChannels()
|
||||
{
|
||||
return Collections.unmodifiableCollection( this.channels.values() );
|
||||
}
|
||||
@Override
|
||||
public ICraftingLink loadCraftingLink(final CompoundNBT data, final ICraftingRequester req) {
|
||||
Preconditions.checkNotNull(data);
|
||||
Preconditions.checkNotNull(req);
|
||||
|
||||
@Override
|
||||
public ICraftingLink loadCraftingLink( final CompoundNBT data, final ICraftingRequester req )
|
||||
{
|
||||
Preconditions.checkNotNull( data );
|
||||
Preconditions.checkNotNull( req );
|
||||
return new CraftingLink(data, req);
|
||||
}
|
||||
|
||||
return new CraftingLink( data, req );
|
||||
}
|
||||
@Override
|
||||
public <T extends IAEStack<T>> T poweredInsert(IEnergySource energy, IMEInventory<T> inv, T input,
|
||||
IActionSource src, Actionable mode) {
|
||||
return Platform.poweredInsert(energy, inv, input, src, mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IAEStack<T>> T poweredInsert( IEnergySource energy, IMEInventory<T> inv, T input, IActionSource src, Actionable mode )
|
||||
{
|
||||
return Platform.poweredInsert( energy, inv, input, src, mode );
|
||||
}
|
||||
@Override
|
||||
public <T extends IAEStack<T>> T poweredExtraction(IEnergySource energy, IMEInventory<T> inv, T request,
|
||||
IActionSource src, Actionable mode) {
|
||||
return Platform.poweredExtraction(energy, inv, request, src, mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IAEStack<T>> T poweredExtraction( IEnergySource energy, IMEInventory<T> inv, T request, IActionSource src, Actionable mode )
|
||||
{
|
||||
return Platform.poweredExtraction( energy, inv, request, src, mode );
|
||||
}
|
||||
@Override
|
||||
public void postChanges(IStorageGrid gs, ItemStack removedCell, ItemStack addedCell, IActionSource src) {
|
||||
Preconditions.checkNotNull(gs);
|
||||
Preconditions.checkNotNull(removedCell);
|
||||
Preconditions.checkNotNull(addedCell);
|
||||
Preconditions.checkNotNull(src);
|
||||
|
||||
@Override
|
||||
public void postChanges( IStorageGrid gs, ItemStack removedCell, ItemStack addedCell, IActionSource src )
|
||||
{
|
||||
Preconditions.checkNotNull( gs );
|
||||
Preconditions.checkNotNull( removedCell );
|
||||
Preconditions.checkNotNull( addedCell );
|
||||
Preconditions.checkNotNull( src );
|
||||
Platform.postChanges(gs, removedCell, addedCell, src);
|
||||
}
|
||||
|
||||
Platform.postChanges( gs, removedCell, addedCell, src );
|
||||
}
|
||||
private static final class ItemStorageChannel implements IItemStorageChannel {
|
||||
|
||||
private static final class ItemStorageChannel implements IItemStorageChannel
|
||||
{
|
||||
@Override
|
||||
public IItemList<IAEItemStack> createList() {
|
||||
return new ItemList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> createList()
|
||||
{
|
||||
return new ItemList();
|
||||
}
|
||||
@Override
|
||||
public IAEItemStack createStack(Object input) {
|
||||
Preconditions.checkNotNull(input);
|
||||
|
||||
@Override
|
||||
public IAEItemStack createStack( Object input )
|
||||
{
|
||||
Preconditions.checkNotNull( input );
|
||||
if (input instanceof ItemStack) {
|
||||
return AEItemStack.fromItemStack((ItemStack) input);
|
||||
}
|
||||
|
||||
if( input instanceof ItemStack )
|
||||
{
|
||||
return AEItemStack.fromItemStack( (ItemStack) input );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public IAEItemStack createFromNBT(CompoundNBT nbt) {
|
||||
Preconditions.checkNotNull(nbt);
|
||||
return AEItemStack.fromNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack createFromNBT( CompoundNBT nbt )
|
||||
{
|
||||
Preconditions.checkNotNull( nbt );
|
||||
return AEItemStack.fromNBT( nbt );
|
||||
}
|
||||
@Override
|
||||
public IAEItemStack readFromPacket(PacketBuffer input) {
|
||||
Preconditions.checkNotNull(input);
|
||||
|
||||
@Override
|
||||
public IAEItemStack readFromPacket( PacketBuffer input )
|
||||
{
|
||||
Preconditions.checkNotNull( input );
|
||||
return AEItemStack.fromPacket(input);
|
||||
}
|
||||
}
|
||||
|
||||
return AEItemStack.fromPacket( input );
|
||||
}
|
||||
}
|
||||
private static final class FluidStorageChannel implements IFluidStorageChannel {
|
||||
|
||||
private static final class FluidStorageChannel implements IFluidStorageChannel
|
||||
{
|
||||
@Override
|
||||
public int transferFactor() {
|
||||
return 125;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int transferFactor()
|
||||
{
|
||||
return 125;
|
||||
}
|
||||
@Override
|
||||
public int getUnitsPerByte() {
|
||||
return 8000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnitsPerByte()
|
||||
{
|
||||
return 8000;
|
||||
}
|
||||
@Override
|
||||
public IItemList<IAEFluidStack> createList() {
|
||||
return new FluidList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEFluidStack> createList()
|
||||
{
|
||||
return new FluidList();
|
||||
}
|
||||
@Override
|
||||
public IAEFluidStack createStack(Object input) {
|
||||
Preconditions.checkNotNull(input);
|
||||
|
||||
@Override
|
||||
public IAEFluidStack createStack( Object input )
|
||||
{
|
||||
Preconditions.checkNotNull( input );
|
||||
if (input instanceof FluidStack) {
|
||||
return AEFluidStack.fromFluidStack((FluidStack) input);
|
||||
}
|
||||
if (input instanceof ItemStack) {
|
||||
final ItemStack is = (ItemStack) input;
|
||||
if (is.getItem() instanceof FluidDummyItem) {
|
||||
return AEFluidStack.fromFluidStack(((FluidDummyItem) is.getItem()).getFluidStack(is));
|
||||
} else {
|
||||
return AEFluidStack.fromFluidStack(FluidUtil.getFluidContained(is).orElse(null));
|
||||
}
|
||||
}
|
||||
|
||||
if( input instanceof FluidStack )
|
||||
{
|
||||
return AEFluidStack.fromFluidStack( (FluidStack) input );
|
||||
}
|
||||
if( input instanceof ItemStack )
|
||||
{
|
||||
final ItemStack is = (ItemStack) input;
|
||||
if( is.getItem() instanceof FluidDummyItem )
|
||||
{
|
||||
return AEFluidStack.fromFluidStack( ( (FluidDummyItem) is.getItem() ).getFluidStack( is ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return AEFluidStack.fromFluidStack( FluidUtil.getFluidContained( is ).orElse( null ) );
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public IAEFluidStack readFromPacket(PacketBuffer input) {
|
||||
Preconditions.checkNotNull(input);
|
||||
|
||||
@Override
|
||||
public IAEFluidStack readFromPacket( PacketBuffer input )
|
||||
{
|
||||
Preconditions.checkNotNull( input );
|
||||
return AEFluidStack.fromPacket(input);
|
||||
}
|
||||
|
||||
return AEFluidStack.fromPacket( input );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack createFromNBT( CompoundNBT nbt )
|
||||
{
|
||||
Preconditions.checkNotNull( nbt );
|
||||
return AEFluidStack.fromNBT( nbt );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public IAEFluidStack createFromNBT(CompoundNBT nbt) {
|
||||
Preconditions.checkNotNull(nbt);
|
||||
return AEFluidStack.fromNBT(nbt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -18,6 +18,9 @@
|
||||
|
||||
package appeng.core.api.definitions;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
@@ -29,524 +32,463 @@ import appeng.entity.EntityChargedQuartz;
|
||||
import appeng.entity.EntitySingularity;
|
||||
import appeng.items.materials.ItemMaterial;
|
||||
import appeng.items.materials.MaterialType;
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
|
||||
|
||||
/**
|
||||
* Internal implementation for the API materials
|
||||
*/
|
||||
public final class ApiMaterials implements IMaterials
|
||||
{
|
||||
private final IItemDefinition cell2SpatialPart;
|
||||
private final IItemDefinition cell16SpatialPart;
|
||||
private final IItemDefinition cell128SpatialPart;
|
||||
|
||||
private final IItemDefinition silicon;
|
||||
private final IItemDefinition skyDust;
|
||||
|
||||
private final IItemDefinition calcProcessorPress;
|
||||
private final IItemDefinition engProcessorPress;
|
||||
private final IItemDefinition logicProcessorPress;
|
||||
|
||||
private final IItemDefinition calcProcessorPrint;
|
||||
private final IItemDefinition engProcessorPrint;
|
||||
private final IItemDefinition logicProcessorPrint;
|
||||
|
||||
private final IItemDefinition siliconPress;
|
||||
private final IItemDefinition siliconPrint;
|
||||
|
||||
private final IItemDefinition namePress;
|
||||
|
||||
private final IItemDefinition logicProcessor;
|
||||
private final IItemDefinition calcProcessor;
|
||||
private final IItemDefinition engProcessor;
|
||||
|
||||
private final IItemDefinition basicCard;
|
||||
private final IItemDefinition advCard;
|
||||
|
||||
private final IItemDefinition purifiedCertusQuartzCrystal;
|
||||
private final IItemDefinition purifiedNetherQuartzCrystal;
|
||||
private final IItemDefinition purifiedFluixCrystal;
|
||||
|
||||
private final IItemDefinition cell1kPart;
|
||||
private final IItemDefinition cell4kPart;
|
||||
private final IItemDefinition cell16kPart;
|
||||
private final IItemDefinition cell64kPart;
|
||||
private final IItemDefinition emptyStorageCell;
|
||||
|
||||
private final IItemDefinition cardRedstone;
|
||||
private final IItemDefinition cardSpeed;
|
||||
private final IItemDefinition cardCapacity;
|
||||
private final IItemDefinition cardFuzzy;
|
||||
private final IItemDefinition cardInverter;
|
||||
private final IItemDefinition cardCrafting;
|
||||
|
||||
private final IItemDefinition enderDust;
|
||||
private final IItemDefinition flour;
|
||||
private final IItemDefinition goldDust;
|
||||
private final IItemDefinition ironDust;
|
||||
private final IItemDefinition fluixDust;
|
||||
private final IItemDefinition certusQuartzDust;
|
||||
private final IItemDefinition netherQuartzDust;
|
||||
|
||||
private final IItemDefinition matterBall;
|
||||
|
||||
private final IItemDefinition certusQuartzCrystal;
|
||||
private final IItemDefinition certusQuartzCrystalCharged;
|
||||
private final IItemDefinition fluixCrystal;
|
||||
private final IItemDefinition fluixPearl;
|
||||
|
||||
private final IItemDefinition woodenGear;
|
||||
|
||||
private final IItemDefinition wirelessReceiver;
|
||||
private final IItemDefinition wirelessBooster;
|
||||
|
||||
private final IItemDefinition annihilationCore;
|
||||
private final IItemDefinition formationCore;
|
||||
|
||||
private final IItemDefinition singularity;
|
||||
private final IItemDefinition qESingularity;
|
||||
private final IItemDefinition blankPattern;
|
||||
|
||||
private final IItemDefinition fluidCell1kPart;
|
||||
private final IItemDefinition fluidCell4kPart;
|
||||
private final IItemDefinition fluidCell16kPart;
|
||||
private final IItemDefinition fluidCell64kPart;
|
||||
|
||||
private final FeatureFactory registry;
|
||||
|
||||
public ApiMaterials( FeatureFactory registry )
|
||||
{
|
||||
this.registry = registry;
|
||||
|
||||
EntitySingularity.TYPE = registry.<EntitySingularity>entity("singularity", EntitySingularity::new, EntityClassification.MISC)
|
||||
.customize(builder -> builder.size(0.2f, 0.2f).setTrackingRange(16).setUpdateInterval(4).setShouldReceiveVelocityUpdates(true))
|
||||
.build();
|
||||
|
||||
EntityChargedQuartz.TYPE = registry.<EntityChargedQuartz>entity("charged_quartz", EntityChargedQuartz::new, EntityClassification.MISC)
|
||||
.customize(builder -> builder.size(0.2f, 0.2f).setTrackingRange(16).setUpdateInterval(4).setShouldReceiveVelocityUpdates(true))
|
||||
.build();
|
||||
|
||||
this.cell2SpatialPart = createMaterial(MaterialType.SPATIAL_2_CELL_COMPONENT );
|
||||
this.cell16SpatialPart = createMaterial(MaterialType.SPATIAL_16_CELL_COMPONENT );
|
||||
this.cell128SpatialPart = createMaterial(MaterialType.SPATIAL_128_CELL_COMPONENT );
|
||||
this.silicon = createMaterial(MaterialType.SILICON );
|
||||
this.skyDust = createMaterial(MaterialType.SKY_DUST );
|
||||
this.calcProcessorPress = createMaterial(MaterialType.CALCULATION_PROCESSOR_PRESS );
|
||||
this.engProcessorPress = createMaterial(MaterialType.ENGINEERING_PROCESSOR_PRESS );
|
||||
this.logicProcessorPress = createMaterial(MaterialType.LOGIC_PROCESSOR_PRESS );
|
||||
this.siliconPress = createMaterial(MaterialType.SILICON_PRESS );
|
||||
this.namePress = createMaterial(MaterialType.NAME_PRESS );
|
||||
this.calcProcessorPrint = createMaterial(MaterialType.CALCULATION_PROCESSOR_PRINT );
|
||||
this.engProcessorPrint = createMaterial(MaterialType.ENGINEERING_PROCESSOR_PRINT );
|
||||
this.logicProcessorPrint = createMaterial(MaterialType.LOGIC_PROCESSOR_PRINT );
|
||||
this.siliconPrint = createMaterial(MaterialType.SILICON_PRINT );
|
||||
this.logicProcessor = createMaterial(MaterialType.LOGIC_PROCESSOR );
|
||||
this.calcProcessor = createMaterial(MaterialType.CALCULATION_PROCESSOR );
|
||||
this.engProcessor = createMaterial(MaterialType.ENGINEERING_PROCESSOR );
|
||||
this.basicCard = createMaterial(MaterialType.BASIC_CARD );
|
||||
this.advCard = createMaterial(MaterialType.ADVANCED_CARD );
|
||||
this.purifiedCertusQuartzCrystal = createMaterial(MaterialType.PURIFIED_CERTUS_QUARTZ_CRYSTAL );
|
||||
this.purifiedNetherQuartzCrystal = createMaterial(MaterialType.PURIFIED_NETHER_QUARTZ_CRYSTAL );
|
||||
this.purifiedFluixCrystal = createMaterial(MaterialType.PURIFIED_FLUIX_CRYSTAL );
|
||||
this.cell1kPart = createMaterial(MaterialType.ITEM_1K_CELL_COMPONENT );
|
||||
this.cell4kPart = createMaterial(MaterialType.ITEM_4K_CELL_COMPONENT );
|
||||
this.cell16kPart = createMaterial(MaterialType.ITEM_16K_CELL_COMPONENT );
|
||||
this.cell64kPart = createMaterial(MaterialType.ITEM_64K_CELL_COMPONENT );
|
||||
this.emptyStorageCell = createMaterial(MaterialType.EMPTY_STORAGE_CELL );
|
||||
this.cardRedstone = createMaterial(MaterialType.CARD_REDSTONE );
|
||||
this.cardSpeed = createMaterial(MaterialType.CARD_SPEED );
|
||||
this.cardCapacity = createMaterial(MaterialType.CARD_CAPACITY );
|
||||
this.cardFuzzy = createMaterial(MaterialType.CARD_FUZZY );
|
||||
this.cardInverter = createMaterial(MaterialType.CARD_INVERTER );
|
||||
this.cardCrafting = createMaterial(MaterialType.CARD_CRAFTING );
|
||||
this.enderDust = createMaterial(MaterialType.ENDER_DUST );
|
||||
this.flour = createMaterial(MaterialType.FLOUR );
|
||||
this.goldDust = createMaterial(MaterialType.GOLD_DUST );
|
||||
this.ironDust = createMaterial(MaterialType.IRON_DUST );
|
||||
this.fluixDust = createMaterial(MaterialType.FLUIX_DUST );
|
||||
this.certusQuartzDust = createMaterial(MaterialType.CERTUS_QUARTZ_DUST );
|
||||
this.netherQuartzDust = createMaterial(MaterialType.NETHER_QUARTZ_DUST );
|
||||
this.matterBall = createMaterial(MaterialType.MATTER_BALL );
|
||||
this.certusQuartzCrystal = createMaterial(MaterialType.CERTUS_QUARTZ_CRYSTAL );
|
||||
this.certusQuartzCrystalCharged = createMaterial(MaterialType.CERTUS_QUARTZ_CRYSTAL_CHARGED );
|
||||
this.fluixCrystal = createMaterial(MaterialType.FLUIX_CRYSTAL );
|
||||
this.fluixPearl = createMaterial(MaterialType.FLUIX_PEARL );
|
||||
this.woodenGear = createMaterial(MaterialType.WOODEN_GEAR );
|
||||
this.wirelessReceiver = createMaterial(MaterialType.WIRELESS_RECEIVER);
|
||||
this.wirelessBooster = createMaterial(MaterialType.WIRELESS_BOOSTER );
|
||||
this.annihilationCore = createMaterial(MaterialType.ANNIHILATION_CORE );
|
||||
this.formationCore = createMaterial(MaterialType.FORMATION_CORE );
|
||||
this.singularity = createMaterial(MaterialType.SINGULARITY );
|
||||
this.qESingularity = createMaterial(MaterialType.QUANTUM_ENTANGLED_SINGULARITY );
|
||||
this.blankPattern = createMaterial(MaterialType.BLANK_PATTERN );
|
||||
this.fluidCell1kPart = createMaterial(MaterialType.FLUID_1K_CELL_COMPONENT );
|
||||
this.fluidCell4kPart = createMaterial(MaterialType.FLUID_4K_CELL_COMPONENT );
|
||||
this.fluidCell16kPart = createMaterial(MaterialType.FLUID_16K_CELL_COMPONENT );
|
||||
this.fluidCell64kPart = createMaterial(MaterialType.FLUID_64K_CELL_COMPONENT );
|
||||
}
|
||||
|
||||
private IItemDefinition createMaterial(final MaterialType mat)
|
||||
{
|
||||
Preconditions.checkState( !mat.isRegistered(), "Cannot create the same material twice." );
|
||||
|
||||
IItemDefinition def = registry.item(mat.getId(), props -> new ItemMaterial(props, mat))
|
||||
.features(mat.getFeature().toArray(new AEFeature[0]))
|
||||
.build();
|
||||
|
||||
boolean enabled = true;
|
||||
|
||||
for( final AEFeature f : mat.getFeature() )
|
||||
{
|
||||
enabled = enabled && AEConfig.instance().isFeatureEnabled( f );
|
||||
}
|
||||
|
||||
mat.setStackSrc( new MaterialStackSrc( mat, enabled ) );
|
||||
mat.setItemInstance( def.item() );
|
||||
mat.markReady();
|
||||
return def;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cell2SpatialPart()
|
||||
{
|
||||
return this.cell2SpatialPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cell16SpatialPart()
|
||||
{
|
||||
return this.cell16SpatialPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cell128SpatialPart()
|
||||
{
|
||||
return this.cell128SpatialPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition silicon()
|
||||
{
|
||||
return this.silicon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition skyDust()
|
||||
{
|
||||
return this.skyDust;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition calcProcessorPress()
|
||||
{
|
||||
return this.calcProcessorPress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition engProcessorPress()
|
||||
{
|
||||
return this.engProcessorPress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition logicProcessorPress()
|
||||
{
|
||||
return this.logicProcessorPress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition calcProcessorPrint()
|
||||
{
|
||||
return this.calcProcessorPrint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition engProcessorPrint()
|
||||
{
|
||||
return this.engProcessorPrint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition logicProcessorPrint()
|
||||
{
|
||||
return this.logicProcessorPrint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition siliconPress()
|
||||
{
|
||||
return this.siliconPress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition siliconPrint()
|
||||
{
|
||||
return this.siliconPrint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition namePress()
|
||||
{
|
||||
return this.namePress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition logicProcessor()
|
||||
{
|
||||
return this.logicProcessor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition calcProcessor()
|
||||
{
|
||||
return this.calcProcessor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition engProcessor()
|
||||
{
|
||||
return this.engProcessor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition basicCard()
|
||||
{
|
||||
return this.basicCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition advCard()
|
||||
{
|
||||
return this.advCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition purifiedCertusQuartzCrystal()
|
||||
{
|
||||
return this.purifiedCertusQuartzCrystal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition purifiedNetherQuartzCrystal()
|
||||
{
|
||||
return this.purifiedNetherQuartzCrystal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition purifiedFluixCrystal()
|
||||
{
|
||||
return this.purifiedFluixCrystal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cell1kPart()
|
||||
{
|
||||
return this.cell1kPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cell4kPart()
|
||||
{
|
||||
return this.cell4kPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cell16kPart()
|
||||
{
|
||||
return this.cell16kPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cell64kPart()
|
||||
{
|
||||
return this.cell64kPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition emptyStorageCell()
|
||||
{
|
||||
return this.emptyStorageCell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cardRedstone()
|
||||
{
|
||||
return this.cardRedstone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cardSpeed()
|
||||
{
|
||||
return this.cardSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cardCapacity()
|
||||
{
|
||||
return this.cardCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cardFuzzy()
|
||||
{
|
||||
return this.cardFuzzy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cardInverter()
|
||||
{
|
||||
return this.cardInverter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cardCrafting()
|
||||
{
|
||||
return this.cardCrafting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition enderDust()
|
||||
{
|
||||
return this.enderDust;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition flour()
|
||||
{
|
||||
return this.flour;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition goldDust()
|
||||
{
|
||||
return this.goldDust;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition ironDust()
|
||||
{
|
||||
return this.ironDust;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluixDust()
|
||||
{
|
||||
return this.fluixDust;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition certusQuartzDust()
|
||||
{
|
||||
return this.certusQuartzDust;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition netherQuartzDust()
|
||||
{
|
||||
return this.netherQuartzDust;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition matterBall()
|
||||
{
|
||||
return this.matterBall;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition certusQuartzCrystal()
|
||||
{
|
||||
return this.certusQuartzCrystal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition certusQuartzCrystalCharged()
|
||||
{
|
||||
return this.certusQuartzCrystalCharged;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluixCrystal()
|
||||
{
|
||||
return this.fluixCrystal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluixPearl()
|
||||
{
|
||||
return this.fluixPearl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition woodenGear()
|
||||
{
|
||||
return this.woodenGear;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition wirelessReceiver()
|
||||
{
|
||||
return this.wirelessReceiver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition wirelessBooster()
|
||||
{
|
||||
return this.wirelessBooster;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition annihilationCore()
|
||||
{
|
||||
return this.annihilationCore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition formationCore()
|
||||
{
|
||||
return this.formationCore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition singularity()
|
||||
{
|
||||
return this.singularity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition qESingularity()
|
||||
{
|
||||
return this.qESingularity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition blankPattern()
|
||||
{
|
||||
return this.blankPattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluidCell1kPart()
|
||||
{
|
||||
return this.fluidCell1kPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluidCell4kPart()
|
||||
{
|
||||
return this.fluidCell4kPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluidCell16kPart()
|
||||
{
|
||||
return this.fluidCell16kPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluidCell64kPart()
|
||||
{
|
||||
return this.fluidCell64kPart;
|
||||
}
|
||||
public final class ApiMaterials implements IMaterials {
|
||||
private final IItemDefinition cell2SpatialPart;
|
||||
private final IItemDefinition cell16SpatialPart;
|
||||
private final IItemDefinition cell128SpatialPart;
|
||||
|
||||
private final IItemDefinition silicon;
|
||||
private final IItemDefinition skyDust;
|
||||
|
||||
private final IItemDefinition calcProcessorPress;
|
||||
private final IItemDefinition engProcessorPress;
|
||||
private final IItemDefinition logicProcessorPress;
|
||||
|
||||
private final IItemDefinition calcProcessorPrint;
|
||||
private final IItemDefinition engProcessorPrint;
|
||||
private final IItemDefinition logicProcessorPrint;
|
||||
|
||||
private final IItemDefinition siliconPress;
|
||||
private final IItemDefinition siliconPrint;
|
||||
|
||||
private final IItemDefinition namePress;
|
||||
|
||||
private final IItemDefinition logicProcessor;
|
||||
private final IItemDefinition calcProcessor;
|
||||
private final IItemDefinition engProcessor;
|
||||
|
||||
private final IItemDefinition basicCard;
|
||||
private final IItemDefinition advCard;
|
||||
|
||||
private final IItemDefinition purifiedCertusQuartzCrystal;
|
||||
private final IItemDefinition purifiedNetherQuartzCrystal;
|
||||
private final IItemDefinition purifiedFluixCrystal;
|
||||
|
||||
private final IItemDefinition cell1kPart;
|
||||
private final IItemDefinition cell4kPart;
|
||||
private final IItemDefinition cell16kPart;
|
||||
private final IItemDefinition cell64kPart;
|
||||
private final IItemDefinition emptyStorageCell;
|
||||
|
||||
private final IItemDefinition cardRedstone;
|
||||
private final IItemDefinition cardSpeed;
|
||||
private final IItemDefinition cardCapacity;
|
||||
private final IItemDefinition cardFuzzy;
|
||||
private final IItemDefinition cardInverter;
|
||||
private final IItemDefinition cardCrafting;
|
||||
|
||||
private final IItemDefinition enderDust;
|
||||
private final IItemDefinition flour;
|
||||
private final IItemDefinition goldDust;
|
||||
private final IItemDefinition ironDust;
|
||||
private final IItemDefinition fluixDust;
|
||||
private final IItemDefinition certusQuartzDust;
|
||||
private final IItemDefinition netherQuartzDust;
|
||||
|
||||
private final IItemDefinition matterBall;
|
||||
|
||||
private final IItemDefinition certusQuartzCrystal;
|
||||
private final IItemDefinition certusQuartzCrystalCharged;
|
||||
private final IItemDefinition fluixCrystal;
|
||||
private final IItemDefinition fluixPearl;
|
||||
|
||||
private final IItemDefinition woodenGear;
|
||||
|
||||
private final IItemDefinition wirelessReceiver;
|
||||
private final IItemDefinition wirelessBooster;
|
||||
|
||||
private final IItemDefinition annihilationCore;
|
||||
private final IItemDefinition formationCore;
|
||||
|
||||
private final IItemDefinition singularity;
|
||||
private final IItemDefinition qESingularity;
|
||||
private final IItemDefinition blankPattern;
|
||||
|
||||
private final IItemDefinition fluidCell1kPart;
|
||||
private final IItemDefinition fluidCell4kPart;
|
||||
private final IItemDefinition fluidCell16kPart;
|
||||
private final IItemDefinition fluidCell64kPart;
|
||||
|
||||
private final FeatureFactory registry;
|
||||
|
||||
public ApiMaterials(FeatureFactory registry) {
|
||||
this.registry = registry;
|
||||
|
||||
EntitySingularity.TYPE = registry
|
||||
.<EntitySingularity>entity("singularity", EntitySingularity::new, EntityClassification.MISC)
|
||||
.customize(builder -> builder.size(0.2f, 0.2f).setTrackingRange(16).setUpdateInterval(4)
|
||||
.setShouldReceiveVelocityUpdates(true))
|
||||
.build();
|
||||
|
||||
EntityChargedQuartz.TYPE = registry
|
||||
.<EntityChargedQuartz>entity("charged_quartz", EntityChargedQuartz::new, EntityClassification.MISC)
|
||||
.customize(builder -> builder.size(0.2f, 0.2f).setTrackingRange(16).setUpdateInterval(4)
|
||||
.setShouldReceiveVelocityUpdates(true))
|
||||
.build();
|
||||
|
||||
this.cell2SpatialPart = createMaterial(MaterialType.SPATIAL_2_CELL_COMPONENT);
|
||||
this.cell16SpatialPart = createMaterial(MaterialType.SPATIAL_16_CELL_COMPONENT);
|
||||
this.cell128SpatialPart = createMaterial(MaterialType.SPATIAL_128_CELL_COMPONENT);
|
||||
this.silicon = createMaterial(MaterialType.SILICON);
|
||||
this.skyDust = createMaterial(MaterialType.SKY_DUST);
|
||||
this.calcProcessorPress = createMaterial(MaterialType.CALCULATION_PROCESSOR_PRESS);
|
||||
this.engProcessorPress = createMaterial(MaterialType.ENGINEERING_PROCESSOR_PRESS);
|
||||
this.logicProcessorPress = createMaterial(MaterialType.LOGIC_PROCESSOR_PRESS);
|
||||
this.siliconPress = createMaterial(MaterialType.SILICON_PRESS);
|
||||
this.namePress = createMaterial(MaterialType.NAME_PRESS);
|
||||
this.calcProcessorPrint = createMaterial(MaterialType.CALCULATION_PROCESSOR_PRINT);
|
||||
this.engProcessorPrint = createMaterial(MaterialType.ENGINEERING_PROCESSOR_PRINT);
|
||||
this.logicProcessorPrint = createMaterial(MaterialType.LOGIC_PROCESSOR_PRINT);
|
||||
this.siliconPrint = createMaterial(MaterialType.SILICON_PRINT);
|
||||
this.logicProcessor = createMaterial(MaterialType.LOGIC_PROCESSOR);
|
||||
this.calcProcessor = createMaterial(MaterialType.CALCULATION_PROCESSOR);
|
||||
this.engProcessor = createMaterial(MaterialType.ENGINEERING_PROCESSOR);
|
||||
this.basicCard = createMaterial(MaterialType.BASIC_CARD);
|
||||
this.advCard = createMaterial(MaterialType.ADVANCED_CARD);
|
||||
this.purifiedCertusQuartzCrystal = createMaterial(MaterialType.PURIFIED_CERTUS_QUARTZ_CRYSTAL);
|
||||
this.purifiedNetherQuartzCrystal = createMaterial(MaterialType.PURIFIED_NETHER_QUARTZ_CRYSTAL);
|
||||
this.purifiedFluixCrystal = createMaterial(MaterialType.PURIFIED_FLUIX_CRYSTAL);
|
||||
this.cell1kPart = createMaterial(MaterialType.ITEM_1K_CELL_COMPONENT);
|
||||
this.cell4kPart = createMaterial(MaterialType.ITEM_4K_CELL_COMPONENT);
|
||||
this.cell16kPart = createMaterial(MaterialType.ITEM_16K_CELL_COMPONENT);
|
||||
this.cell64kPart = createMaterial(MaterialType.ITEM_64K_CELL_COMPONENT);
|
||||
this.emptyStorageCell = createMaterial(MaterialType.EMPTY_STORAGE_CELL);
|
||||
this.cardRedstone = createMaterial(MaterialType.CARD_REDSTONE);
|
||||
this.cardSpeed = createMaterial(MaterialType.CARD_SPEED);
|
||||
this.cardCapacity = createMaterial(MaterialType.CARD_CAPACITY);
|
||||
this.cardFuzzy = createMaterial(MaterialType.CARD_FUZZY);
|
||||
this.cardInverter = createMaterial(MaterialType.CARD_INVERTER);
|
||||
this.cardCrafting = createMaterial(MaterialType.CARD_CRAFTING);
|
||||
this.enderDust = createMaterial(MaterialType.ENDER_DUST);
|
||||
this.flour = createMaterial(MaterialType.FLOUR);
|
||||
this.goldDust = createMaterial(MaterialType.GOLD_DUST);
|
||||
this.ironDust = createMaterial(MaterialType.IRON_DUST);
|
||||
this.fluixDust = createMaterial(MaterialType.FLUIX_DUST);
|
||||
this.certusQuartzDust = createMaterial(MaterialType.CERTUS_QUARTZ_DUST);
|
||||
this.netherQuartzDust = createMaterial(MaterialType.NETHER_QUARTZ_DUST);
|
||||
this.matterBall = createMaterial(MaterialType.MATTER_BALL);
|
||||
this.certusQuartzCrystal = createMaterial(MaterialType.CERTUS_QUARTZ_CRYSTAL);
|
||||
this.certusQuartzCrystalCharged = createMaterial(MaterialType.CERTUS_QUARTZ_CRYSTAL_CHARGED);
|
||||
this.fluixCrystal = createMaterial(MaterialType.FLUIX_CRYSTAL);
|
||||
this.fluixPearl = createMaterial(MaterialType.FLUIX_PEARL);
|
||||
this.woodenGear = createMaterial(MaterialType.WOODEN_GEAR);
|
||||
this.wirelessReceiver = createMaterial(MaterialType.WIRELESS_RECEIVER);
|
||||
this.wirelessBooster = createMaterial(MaterialType.WIRELESS_BOOSTER);
|
||||
this.annihilationCore = createMaterial(MaterialType.ANNIHILATION_CORE);
|
||||
this.formationCore = createMaterial(MaterialType.FORMATION_CORE);
|
||||
this.singularity = createMaterial(MaterialType.SINGULARITY);
|
||||
this.qESingularity = createMaterial(MaterialType.QUANTUM_ENTANGLED_SINGULARITY);
|
||||
this.blankPattern = createMaterial(MaterialType.BLANK_PATTERN);
|
||||
this.fluidCell1kPart = createMaterial(MaterialType.FLUID_1K_CELL_COMPONENT);
|
||||
this.fluidCell4kPart = createMaterial(MaterialType.FLUID_4K_CELL_COMPONENT);
|
||||
this.fluidCell16kPart = createMaterial(MaterialType.FLUID_16K_CELL_COMPONENT);
|
||||
this.fluidCell64kPart = createMaterial(MaterialType.FLUID_64K_CELL_COMPONENT);
|
||||
}
|
||||
|
||||
private IItemDefinition createMaterial(final MaterialType mat) {
|
||||
Preconditions.checkState(!mat.isRegistered(), "Cannot create the same material twice.");
|
||||
|
||||
IItemDefinition def = registry.item(mat.getId(), props -> new ItemMaterial(props, mat))
|
||||
.features(mat.getFeature().toArray(new AEFeature[0])).build();
|
||||
|
||||
boolean enabled = true;
|
||||
|
||||
for (final AEFeature f : mat.getFeature()) {
|
||||
enabled = enabled && AEConfig.instance().isFeatureEnabled(f);
|
||||
}
|
||||
|
||||
mat.setStackSrc(new MaterialStackSrc(mat, enabled));
|
||||
mat.setItemInstance(def.item());
|
||||
mat.markReady();
|
||||
return def;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cell2SpatialPart() {
|
||||
return this.cell2SpatialPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cell16SpatialPart() {
|
||||
return this.cell16SpatialPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cell128SpatialPart() {
|
||||
return this.cell128SpatialPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition silicon() {
|
||||
return this.silicon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition skyDust() {
|
||||
return this.skyDust;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition calcProcessorPress() {
|
||||
return this.calcProcessorPress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition engProcessorPress() {
|
||||
return this.engProcessorPress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition logicProcessorPress() {
|
||||
return this.logicProcessorPress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition calcProcessorPrint() {
|
||||
return this.calcProcessorPrint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition engProcessorPrint() {
|
||||
return this.engProcessorPrint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition logicProcessorPrint() {
|
||||
return this.logicProcessorPrint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition siliconPress() {
|
||||
return this.siliconPress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition siliconPrint() {
|
||||
return this.siliconPrint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition namePress() {
|
||||
return this.namePress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition logicProcessor() {
|
||||
return this.logicProcessor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition calcProcessor() {
|
||||
return this.calcProcessor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition engProcessor() {
|
||||
return this.engProcessor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition basicCard() {
|
||||
return this.basicCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition advCard() {
|
||||
return this.advCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition purifiedCertusQuartzCrystal() {
|
||||
return this.purifiedCertusQuartzCrystal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition purifiedNetherQuartzCrystal() {
|
||||
return this.purifiedNetherQuartzCrystal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition purifiedFluixCrystal() {
|
||||
return this.purifiedFluixCrystal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cell1kPart() {
|
||||
return this.cell1kPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cell4kPart() {
|
||||
return this.cell4kPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cell16kPart() {
|
||||
return this.cell16kPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cell64kPart() {
|
||||
return this.cell64kPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition emptyStorageCell() {
|
||||
return this.emptyStorageCell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cardRedstone() {
|
||||
return this.cardRedstone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cardSpeed() {
|
||||
return this.cardSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cardCapacity() {
|
||||
return this.cardCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cardFuzzy() {
|
||||
return this.cardFuzzy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cardInverter() {
|
||||
return this.cardInverter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cardCrafting() {
|
||||
return this.cardCrafting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition enderDust() {
|
||||
return this.enderDust;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition flour() {
|
||||
return this.flour;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition goldDust() {
|
||||
return this.goldDust;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition ironDust() {
|
||||
return this.ironDust;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluixDust() {
|
||||
return this.fluixDust;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition certusQuartzDust() {
|
||||
return this.certusQuartzDust;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition netherQuartzDust() {
|
||||
return this.netherQuartzDust;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition matterBall() {
|
||||
return this.matterBall;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition certusQuartzCrystal() {
|
||||
return this.certusQuartzCrystal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition certusQuartzCrystalCharged() {
|
||||
return this.certusQuartzCrystalCharged;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluixCrystal() {
|
||||
return this.fluixCrystal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluixPearl() {
|
||||
return this.fluixPearl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition woodenGear() {
|
||||
return this.woodenGear;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition wirelessReceiver() {
|
||||
return this.wirelessReceiver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition wirelessBooster() {
|
||||
return this.wirelessBooster;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition annihilationCore() {
|
||||
return this.annihilationCore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition formationCore() {
|
||||
return this.formationCore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition singularity() {
|
||||
return this.singularity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition qESingularity() {
|
||||
return this.qESingularity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition blankPattern() {
|
||||
return this.blankPattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluidCell1kPart() {
|
||||
return this.fluidCell1kPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluidCell4kPart() {
|
||||
return this.fluidCell4kPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluidCell16kPart() {
|
||||
return this.fluidCell16kPart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluidCell64kPart() {
|
||||
return this.fluidCell64kPart;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,13 @@
|
||||
|
||||
package appeng.core.api.definitions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.definitions.IParts;
|
||||
@@ -40,391 +47,361 @@ import appeng.parts.misc.*;
|
||||
import appeng.parts.networking.*;
|
||||
import appeng.parts.p2p.*;
|
||||
import appeng.parts.reporting.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* Internal implementation for the API parts
|
||||
*/
|
||||
public final class ApiParts implements IParts
|
||||
{
|
||||
private final AEColoredItemDefinition cableSmart;
|
||||
private final AEColoredItemDefinition cableCovered;
|
||||
private final AEColoredItemDefinition cableGlass;
|
||||
private final AEColoredItemDefinition cableDenseCovered;
|
||||
private final AEColoredItemDefinition cableDenseSmart;
|
||||
private final IItemDefinition quartzFiber;
|
||||
private final IItemDefinition toggleBus;
|
||||
private final IItemDefinition invertedToggleBus;
|
||||
private final IItemDefinition storageBus;
|
||||
private final IItemDefinition importBus;
|
||||
private final IItemDefinition exportBus;
|
||||
private final IItemDefinition iface;
|
||||
private final IItemDefinition fluidIface;
|
||||
private final IItemDefinition levelEmitter;
|
||||
private final IItemDefinition fluidLevelEmitter;
|
||||
private final IItemDefinition annihilationPlane;
|
||||
private final IItemDefinition identityAnnihilationPlane;
|
||||
private final IItemDefinition fluidAnnihilationPlane;
|
||||
private final IItemDefinition formationPlane;
|
||||
private final IItemDefinition fluidFormationPlane;
|
||||
private final IItemDefinition p2PTunnelME;
|
||||
private final IItemDefinition p2PTunnelRedstone;
|
||||
private final IItemDefinition p2PTunnelItems;
|
||||
private final IItemDefinition p2PTunnelFluids;
|
||||
private final IItemDefinition p2PTunnelEU;
|
||||
private final IItemDefinition p2PTunnelFE;
|
||||
private final IItemDefinition p2PTunnelLight;
|
||||
private final IItemDefinition cableAnchor;
|
||||
private final IItemDefinition monitor;
|
||||
private final IItemDefinition semiDarkMonitor;
|
||||
private final IItemDefinition darkMonitor;
|
||||
private final IItemDefinition interfaceTerminal;
|
||||
private final IItemDefinition patternTerminal;
|
||||
private final IItemDefinition craftingTerminal;
|
||||
private final IItemDefinition terminal;
|
||||
private final IItemDefinition storageMonitor;
|
||||
private final IItemDefinition conversionMonitor;
|
||||
private final IItemDefinition fluidImportBus;
|
||||
private final IItemDefinition fluidExportBus;
|
||||
private final IItemDefinition fluidTerminal;
|
||||
private final IItemDefinition fluidStorageBus;
|
||||
public final class ApiParts implements IParts {
|
||||
private final AEColoredItemDefinition cableSmart;
|
||||
private final AEColoredItemDefinition cableCovered;
|
||||
private final AEColoredItemDefinition cableGlass;
|
||||
private final AEColoredItemDefinition cableDenseCovered;
|
||||
private final AEColoredItemDefinition cableDenseSmart;
|
||||
private final IItemDefinition quartzFiber;
|
||||
private final IItemDefinition toggleBus;
|
||||
private final IItemDefinition invertedToggleBus;
|
||||
private final IItemDefinition storageBus;
|
||||
private final IItemDefinition importBus;
|
||||
private final IItemDefinition exportBus;
|
||||
private final IItemDefinition iface;
|
||||
private final IItemDefinition fluidIface;
|
||||
private final IItemDefinition levelEmitter;
|
||||
private final IItemDefinition fluidLevelEmitter;
|
||||
private final IItemDefinition annihilationPlane;
|
||||
private final IItemDefinition identityAnnihilationPlane;
|
||||
private final IItemDefinition fluidAnnihilationPlane;
|
||||
private final IItemDefinition formationPlane;
|
||||
private final IItemDefinition fluidFormationPlane;
|
||||
private final IItemDefinition p2PTunnelME;
|
||||
private final IItemDefinition p2PTunnelRedstone;
|
||||
private final IItemDefinition p2PTunnelItems;
|
||||
private final IItemDefinition p2PTunnelFluids;
|
||||
private final IItemDefinition p2PTunnelEU;
|
||||
private final IItemDefinition p2PTunnelFE;
|
||||
private final IItemDefinition p2PTunnelLight;
|
||||
private final IItemDefinition cableAnchor;
|
||||
private final IItemDefinition monitor;
|
||||
private final IItemDefinition semiDarkMonitor;
|
||||
private final IItemDefinition darkMonitor;
|
||||
private final IItemDefinition interfaceTerminal;
|
||||
private final IItemDefinition patternTerminal;
|
||||
private final IItemDefinition craftingTerminal;
|
||||
private final IItemDefinition terminal;
|
||||
private final IItemDefinition storageMonitor;
|
||||
private final IItemDefinition conversionMonitor;
|
||||
private final IItemDefinition fluidImportBus;
|
||||
private final IItemDefinition fluidExportBus;
|
||||
private final IItemDefinition fluidTerminal;
|
||||
private final IItemDefinition fluidStorageBus;
|
||||
|
||||
public ApiParts( FeatureFactory registry, PartModels partModels )
|
||||
{
|
||||
registerPartModels(partModels);
|
||||
public ApiParts(FeatureFactory registry, PartModels partModels) {
|
||||
registerPartModels(partModels);
|
||||
|
||||
this.cableSmart = constructColoredDefinition(registry, "smart_cable", PartType.CABLE_SMART, PartCableSmart::new);
|
||||
this.cableCovered = constructColoredDefinition(registry, "covered_cable", PartType.CABLE_COVERED, PartCableCovered::new);
|
||||
this.cableGlass = constructColoredDefinition(registry, "glass_cable", PartType.CABLE_GLASS, PartCableGlass::new);
|
||||
this.cableDenseCovered = constructColoredDefinition(registry, "covered_dense_cable", PartType.CABLE_DENSE_COVERED, PartDenseCableCovered::new);
|
||||
this.cableDenseSmart = constructColoredDefinition(registry, "smart_dense_cable", PartType.CABLE_DENSE_SMART, PartDenseCableSmart::new);
|
||||
this.quartzFiber = createPart(registry, "quartz_fiber", PartType.QUARTZ_FIBER, PartQuartzFiber::new );
|
||||
this.toggleBus = createPart(registry, "toggle_bus", PartType.TOGGLE_BUS, PartToggleBus::new );
|
||||
this.invertedToggleBus = createPart(registry, "inverted_toggle_bus", PartType.INVERTED_TOGGLE_BUS, PartInvertedToggleBus::new );
|
||||
this.cableAnchor = createPart(registry, "cable_anchor", PartType.CABLE_ANCHOR, PartCableAnchor::new );
|
||||
this.monitor = createPart(registry, "monitor", PartType.MONITOR, PartPanel::new );
|
||||
this.semiDarkMonitor = createPart(registry, "semi_dark_monitor", PartType.SEMI_DARK_MONITOR, PartSemiDarkPanel::new );
|
||||
this.darkMonitor = createPart(registry, "dark_monitor", PartType.DARK_MONITOR, PartDarkPanel::new );
|
||||
this.storageBus = createPart(registry, "storage_bus", PartType.STORAGE_BUS, PartStorageBus::new );
|
||||
this.fluidStorageBus = createPart(registry, "fluid_storage_bus", PartType.FLUID_STORAGE_BUS, PartFluidStorageBus::new );
|
||||
this.importBus = createPart(registry, "import_bus", PartType.IMPORT_BUS, PartImportBus::new );
|
||||
this.fluidImportBus = createPart(registry, "fluid_import_bus", PartType.FLUID_IMPORT_BUS, PartFluidImportBus::new );
|
||||
this.exportBus = createPart(registry, "export_bus", PartType.EXPORT_BUS, PartExportBus::new );
|
||||
this.fluidExportBus = createPart(registry, "fluid_export_bus", PartType.FLUID_EXPORT_BUS, PartFluidExportBus::new );
|
||||
this.levelEmitter = createPart(registry, "level_emitter", PartType.LEVEL_EMITTER, PartLevelEmitter::new );
|
||||
this.fluidLevelEmitter = createPart(registry, "fluid_level_emitter", PartType.FLUID_LEVEL_EMITTER, PartFluidLevelEmitter::new );
|
||||
this.annihilationPlane = createPart(registry, "annihilation_plane", PartType.ANNIHILATION_PLANE, PartAnnihilationPlane::new );
|
||||
this.identityAnnihilationPlane = createPart(registry, "identity_annihilation_plane", PartType.IDENTITY_ANNIHILATION_PLANE, PartIdentityAnnihilationPlane::new );
|
||||
this.fluidAnnihilationPlane = createPart(registry, "fluid_annihilation_plane", PartType.FLUID_ANNIHILATION_PLANE, PartFluidAnnihilationPlane::new );
|
||||
this.formationPlane = createPart(registry, "formation_plane", PartType.FORMATION_PLANE, PartFormationPlane::new );
|
||||
this.fluidFormationPlane = createPart(registry, "fluid_formation_plane", PartType.FLUID_FORMATION_PLANE, PartFluidFormationPlane::new );
|
||||
this.patternTerminal = createPart(registry, "pattern_terminal", PartType.PATTERN_TERMINAL, PartPatternTerminal::new );
|
||||
this.craftingTerminal = createPart(registry, "crafting_terminal", PartType.CRAFTING_TERMINAL, PartCraftingTerminal::new );
|
||||
this.terminal = createPart(registry, "terminal", PartType.TERMINAL, PartTerminal::new );
|
||||
this.storageMonitor = createPart(registry, "storage_monitor", PartType.STORAGE_MONITOR, PartStorageMonitor::new );
|
||||
this.conversionMonitor = createPart(registry, "conversion_monitor", PartType.CONVERSION_MONITOR, PartConversionMonitor::new );
|
||||
this.iface = createPart(registry, "cable_interface", PartType.INTERFACE, PartInterface::new );
|
||||
this.fluidIface = createPart(registry, "cable_fluid_interface", PartType.FLUID_INTERFACE, PartFluidInterface::new );
|
||||
this.p2PTunnelME = createPart(registry, "me_p2p_tunnel", PartType.P2P_TUNNEL_ME, PartP2PTunnelME::new );
|
||||
this.p2PTunnelRedstone = createPart(registry, "redstone_p2p_tunnel", PartType.P2P_TUNNEL_REDSTONE, PartP2PRedstone::new );
|
||||
this.p2PTunnelItems = createPart(registry, "item_p2p_tunnel", PartType.P2P_TUNNEL_ITEM, PartP2PItems::new );
|
||||
this.p2PTunnelFluids = createPart(registry, "fluid_p2p_tunnel", PartType.P2P_TUNNEL_FLUID, PartP2PFluids::new );
|
||||
this.p2PTunnelEU = null; // FIXME createPart( "ic2_p2p_tunnel", PartType.P2P_TUNNEL_IC2, PartP2PIC2Power::new);
|
||||
this.p2PTunnelFE = createPart(registry, "fe_p2p_tunnel", PartType.P2P_TUNNEL_FE, PartP2PFEPower::new );
|
||||
this.p2PTunnelLight = createPart(registry, "light_p2p_tunnel", PartType.P2P_TUNNEL_LIGHT, PartP2PLight::new );
|
||||
this.interfaceTerminal = createPart(registry, "interface_terminal", PartType.INTERFACE_TERMINAL, PartInterfaceTerminal::new );
|
||||
this.fluidTerminal = createPart(registry, "fluid_terminal", PartType.FLUID_TERMINAL, PartFluidTerminal::new );
|
||||
}
|
||||
this.cableSmart = constructColoredDefinition(registry, "smart_cable", PartType.CABLE_SMART,
|
||||
PartCableSmart::new);
|
||||
this.cableCovered = constructColoredDefinition(registry, "covered_cable", PartType.CABLE_COVERED,
|
||||
PartCableCovered::new);
|
||||
this.cableGlass = constructColoredDefinition(registry, "glass_cable", PartType.CABLE_GLASS,
|
||||
PartCableGlass::new);
|
||||
this.cableDenseCovered = constructColoredDefinition(registry, "covered_dense_cable",
|
||||
PartType.CABLE_DENSE_COVERED, PartDenseCableCovered::new);
|
||||
this.cableDenseSmart = constructColoredDefinition(registry, "smart_dense_cable", PartType.CABLE_DENSE_SMART,
|
||||
PartDenseCableSmart::new);
|
||||
this.quartzFiber = createPart(registry, "quartz_fiber", PartType.QUARTZ_FIBER, PartQuartzFiber::new);
|
||||
this.toggleBus = createPart(registry, "toggle_bus", PartType.TOGGLE_BUS, PartToggleBus::new);
|
||||
this.invertedToggleBus = createPart(registry, "inverted_toggle_bus", PartType.INVERTED_TOGGLE_BUS,
|
||||
PartInvertedToggleBus::new);
|
||||
this.cableAnchor = createPart(registry, "cable_anchor", PartType.CABLE_ANCHOR, PartCableAnchor::new);
|
||||
this.monitor = createPart(registry, "monitor", PartType.MONITOR, PartPanel::new);
|
||||
this.semiDarkMonitor = createPart(registry, "semi_dark_monitor", PartType.SEMI_DARK_MONITOR,
|
||||
PartSemiDarkPanel::new);
|
||||
this.darkMonitor = createPart(registry, "dark_monitor", PartType.DARK_MONITOR, PartDarkPanel::new);
|
||||
this.storageBus = createPart(registry, "storage_bus", PartType.STORAGE_BUS, PartStorageBus::new);
|
||||
this.fluidStorageBus = createPart(registry, "fluid_storage_bus", PartType.FLUID_STORAGE_BUS,
|
||||
PartFluidStorageBus::new);
|
||||
this.importBus = createPart(registry, "import_bus", PartType.IMPORT_BUS, PartImportBus::new);
|
||||
this.fluidImportBus = createPart(registry, "fluid_import_bus", PartType.FLUID_IMPORT_BUS,
|
||||
PartFluidImportBus::new);
|
||||
this.exportBus = createPart(registry, "export_bus", PartType.EXPORT_BUS, PartExportBus::new);
|
||||
this.fluidExportBus = createPart(registry, "fluid_export_bus", PartType.FLUID_EXPORT_BUS,
|
||||
PartFluidExportBus::new);
|
||||
this.levelEmitter = createPart(registry, "level_emitter", PartType.LEVEL_EMITTER, PartLevelEmitter::new);
|
||||
this.fluidLevelEmitter = createPart(registry, "fluid_level_emitter", PartType.FLUID_LEVEL_EMITTER,
|
||||
PartFluidLevelEmitter::new);
|
||||
this.annihilationPlane = createPart(registry, "annihilation_plane", PartType.ANNIHILATION_PLANE,
|
||||
PartAnnihilationPlane::new);
|
||||
this.identityAnnihilationPlane = createPart(registry, "identity_annihilation_plane",
|
||||
PartType.IDENTITY_ANNIHILATION_PLANE, PartIdentityAnnihilationPlane::new);
|
||||
this.fluidAnnihilationPlane = createPart(registry, "fluid_annihilation_plane",
|
||||
PartType.FLUID_ANNIHILATION_PLANE, PartFluidAnnihilationPlane::new);
|
||||
this.formationPlane = createPart(registry, "formation_plane", PartType.FORMATION_PLANE,
|
||||
PartFormationPlane::new);
|
||||
this.fluidFormationPlane = createPart(registry, "fluid_formation_plane", PartType.FLUID_FORMATION_PLANE,
|
||||
PartFluidFormationPlane::new);
|
||||
this.patternTerminal = createPart(registry, "pattern_terminal", PartType.PATTERN_TERMINAL,
|
||||
PartPatternTerminal::new);
|
||||
this.craftingTerminal = createPart(registry, "crafting_terminal", PartType.CRAFTING_TERMINAL,
|
||||
PartCraftingTerminal::new);
|
||||
this.terminal = createPart(registry, "terminal", PartType.TERMINAL, PartTerminal::new);
|
||||
this.storageMonitor = createPart(registry, "storage_monitor", PartType.STORAGE_MONITOR,
|
||||
PartStorageMonitor::new);
|
||||
this.conversionMonitor = createPart(registry, "conversion_monitor", PartType.CONVERSION_MONITOR,
|
||||
PartConversionMonitor::new);
|
||||
this.iface = createPart(registry, "cable_interface", PartType.INTERFACE, PartInterface::new);
|
||||
this.fluidIface = createPart(registry, "cable_fluid_interface", PartType.FLUID_INTERFACE,
|
||||
PartFluidInterface::new);
|
||||
this.p2PTunnelME = createPart(registry, "me_p2p_tunnel", PartType.P2P_TUNNEL_ME, PartP2PTunnelME::new);
|
||||
this.p2PTunnelRedstone = createPart(registry, "redstone_p2p_tunnel", PartType.P2P_TUNNEL_REDSTONE,
|
||||
PartP2PRedstone::new);
|
||||
this.p2PTunnelItems = createPart(registry, "item_p2p_tunnel", PartType.P2P_TUNNEL_ITEM, PartP2PItems::new);
|
||||
this.p2PTunnelFluids = createPart(registry, "fluid_p2p_tunnel", PartType.P2P_TUNNEL_FLUID, PartP2PFluids::new);
|
||||
this.p2PTunnelEU = null; // FIXME createPart( "ic2_p2p_tunnel", PartType.P2P_TUNNEL_IC2,
|
||||
// PartP2PIC2Power::new);
|
||||
this.p2PTunnelFE = createPart(registry, "fe_p2p_tunnel", PartType.P2P_TUNNEL_FE, PartP2PFEPower::new);
|
||||
this.p2PTunnelLight = createPart(registry, "light_p2p_tunnel", PartType.P2P_TUNNEL_LIGHT, PartP2PLight::new);
|
||||
this.interfaceTerminal = createPart(registry, "interface_terminal", PartType.INTERFACE_TERMINAL,
|
||||
PartInterfaceTerminal::new);
|
||||
this.fluidTerminal = createPart(registry, "fluid_terminal", PartType.FLUID_TERMINAL, PartFluidTerminal::new);
|
||||
}
|
||||
|
||||
private void registerPartModels(PartModels partModels) {
|
||||
private void registerPartModels(PartModels partModels) {
|
||||
|
||||
// Register the built-in models for annihilation planes
|
||||
ResourceLocation fluidFormationPlaneTexture = new ResourceLocation( AppEng.MOD_ID, "item/part/fluid_formation_plane" );
|
||||
ResourceLocation fluidFormationPlaneOnTexture = new ResourceLocation( AppEng.MOD_ID, "parts/fluid_formation_plane_on" );
|
||||
// Register the built-in models for annihilation planes
|
||||
ResourceLocation fluidFormationPlaneTexture = new ResourceLocation(AppEng.MOD_ID,
|
||||
"item/part/fluid_formation_plane");
|
||||
ResourceLocation fluidFormationPlaneOnTexture = new ResourceLocation(AppEng.MOD_ID,
|
||||
"parts/fluid_formation_plane_on");
|
||||
|
||||
// Register all part models
|
||||
for( PartType partType : PartType.values() )
|
||||
{
|
||||
partModels.registerModels( partType.getModels() );
|
||||
}
|
||||
}
|
||||
// Register all part models
|
||||
for (PartType partType : PartType.values()) {
|
||||
partModels.registerModels(partType.getModels());
|
||||
}
|
||||
}
|
||||
|
||||
private <T extends IPart> IItemDefinition createPart(FeatureFactory registry, String id, PartType type, Function<ItemStack, T> factory) {
|
||||
return registry.item(id, props -> new ItemPart<>(props, type, factory))
|
||||
.itemGroup(CreativeTab.INSTANCE)
|
||||
.rendering(new ItemPartRendering())
|
||||
.build();
|
||||
}
|
||||
private <T extends IPart> IItemDefinition createPart(FeatureFactory registry, String id, PartType type,
|
||||
Function<ItemStack, T> factory) {
|
||||
return registry.item(id, props -> new ItemPart<>(props, type, factory)).itemGroup(CreativeTab.INSTANCE)
|
||||
.rendering(new ItemPartRendering()).build();
|
||||
}
|
||||
|
||||
private <T extends IPart> AEColoredItemDefinition constructColoredDefinition(FeatureFactory registry, String idSuffix, PartType type, Function<ItemStack, T> factory)
|
||||
{
|
||||
final ColoredItemDefinition definition = new ColoredItemDefinition();
|
||||
private <T extends IPart> AEColoredItemDefinition constructColoredDefinition(FeatureFactory registry,
|
||||
String idSuffix, PartType type, Function<ItemStack, T> factory) {
|
||||
final ColoredItemDefinition definition = new ColoredItemDefinition();
|
||||
|
||||
for( final AEColor color : AEColor.values() )
|
||||
{
|
||||
String id = color.registryPrefix + '_' + idSuffix;
|
||||
for (final AEColor color : AEColor.values()) {
|
||||
String id = color.registryPrefix + '_' + idSuffix;
|
||||
|
||||
IItemDefinition itemDef = registry.item(id, props -> new ColoredPartItem<>(props, type, factory, color))
|
||||
.itemGroup(CreativeTab.INSTANCE)
|
||||
.rendering(new ItemPartRendering(color))
|
||||
.build();
|
||||
IItemDefinition itemDef = registry.item(id, props -> new ColoredPartItem<>(props, type, factory, color))
|
||||
.itemGroup(CreativeTab.INSTANCE).rendering(new ItemPartRendering(color)).build();
|
||||
|
||||
definition.add( color, new ItemStackSrc(itemDef.item(), ActivityState.Enabled) );
|
||||
}
|
||||
definition.add(color, new ItemStackSrc(itemDef.item(), ActivityState.Enabled));
|
||||
}
|
||||
|
||||
return definition;
|
||||
}
|
||||
return definition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColoredItemDefinition cableSmart()
|
||||
{
|
||||
return this.cableSmart;
|
||||
}
|
||||
@Override
|
||||
public AEColoredItemDefinition cableSmart() {
|
||||
return this.cableSmart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColoredItemDefinition cableCovered()
|
||||
{
|
||||
return this.cableCovered;
|
||||
}
|
||||
@Override
|
||||
public AEColoredItemDefinition cableCovered() {
|
||||
return this.cableCovered;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColoredItemDefinition cableGlass()
|
||||
{
|
||||
return this.cableGlass;
|
||||
}
|
||||
@Override
|
||||
public AEColoredItemDefinition cableGlass() {
|
||||
return this.cableGlass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColoredItemDefinition cableDenseCovered()
|
||||
{
|
||||
return this.cableDenseCovered;
|
||||
}
|
||||
@Override
|
||||
public AEColoredItemDefinition cableDenseCovered() {
|
||||
return this.cableDenseCovered;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColoredItemDefinition cableDenseSmart()
|
||||
{
|
||||
return this.cableDenseSmart;
|
||||
}
|
||||
@Override
|
||||
public AEColoredItemDefinition cableDenseSmart() {
|
||||
return this.cableDenseSmart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition quartzFiber()
|
||||
{
|
||||
return this.quartzFiber;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition quartzFiber() {
|
||||
return this.quartzFiber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition toggleBus()
|
||||
{
|
||||
return this.toggleBus;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition toggleBus() {
|
||||
return this.toggleBus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition invertedToggleBus()
|
||||
{
|
||||
return this.invertedToggleBus;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition invertedToggleBus() {
|
||||
return this.invertedToggleBus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition storageBus()
|
||||
{
|
||||
return this.storageBus;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition storageBus() {
|
||||
return this.storageBus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition importBus()
|
||||
{
|
||||
return this.importBus;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition importBus() {
|
||||
return this.importBus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition exportBus()
|
||||
{
|
||||
return this.exportBus;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition exportBus() {
|
||||
return this.exportBus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition iface()
|
||||
{
|
||||
return this.iface;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition iface() {
|
||||
return this.iface;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluidIface()
|
||||
{
|
||||
return this.fluidIface;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition fluidIface() {
|
||||
return this.fluidIface;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition levelEmitter()
|
||||
{
|
||||
return this.levelEmitter;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition levelEmitter() {
|
||||
return this.levelEmitter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition annihilationPlane()
|
||||
{
|
||||
return this.annihilationPlane;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition annihilationPlane() {
|
||||
return this.annihilationPlane;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition identityAnnihilationPlane()
|
||||
{
|
||||
return this.identityAnnihilationPlane;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition identityAnnihilationPlane() {
|
||||
return this.identityAnnihilationPlane;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition formationPlane()
|
||||
{
|
||||
return this.formationPlane;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition formationPlane() {
|
||||
return this.formationPlane;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition p2PTunnelME()
|
||||
{
|
||||
return this.p2PTunnelME;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition p2PTunnelME() {
|
||||
return this.p2PTunnelME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition p2PTunnelRedstone()
|
||||
{
|
||||
return this.p2PTunnelRedstone;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition p2PTunnelRedstone() {
|
||||
return this.p2PTunnelRedstone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition p2PTunnelItems()
|
||||
{
|
||||
return this.p2PTunnelItems;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition p2PTunnelItems() {
|
||||
return this.p2PTunnelItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition p2PTunnelFluids()
|
||||
{
|
||||
return this.p2PTunnelFluids;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition p2PTunnelFluids() {
|
||||
return this.p2PTunnelFluids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition p2PTunnelEU()
|
||||
{
|
||||
return this.p2PTunnelEU;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition p2PTunnelEU() {
|
||||
return this.p2PTunnelEU;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition p2PTunnelFE()
|
||||
{
|
||||
return this.p2PTunnelFE;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition p2PTunnelFE() {
|
||||
return this.p2PTunnelFE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition p2PTunnelLight()
|
||||
{
|
||||
return this.p2PTunnelLight;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition p2PTunnelLight() {
|
||||
return this.p2PTunnelLight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cableAnchor()
|
||||
{
|
||||
return this.cableAnchor;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition cableAnchor() {
|
||||
return this.cableAnchor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition monitor()
|
||||
{
|
||||
return this.monitor;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition monitor() {
|
||||
return this.monitor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition semiDarkMonitor()
|
||||
{
|
||||
return this.semiDarkMonitor;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition semiDarkMonitor() {
|
||||
return this.semiDarkMonitor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition darkMonitor()
|
||||
{
|
||||
return this.darkMonitor;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition darkMonitor() {
|
||||
return this.darkMonitor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition interfaceTerminal()
|
||||
{
|
||||
return this.interfaceTerminal;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition interfaceTerminal() {
|
||||
return this.interfaceTerminal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition patternTerminal()
|
||||
{
|
||||
return this.patternTerminal;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition patternTerminal() {
|
||||
return this.patternTerminal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition craftingTerminal()
|
||||
{
|
||||
return this.craftingTerminal;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition craftingTerminal() {
|
||||
return this.craftingTerminal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition terminal()
|
||||
{
|
||||
return this.terminal;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition terminal() {
|
||||
return this.terminal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition storageMonitor()
|
||||
{
|
||||
return this.storageMonitor;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition storageMonitor() {
|
||||
return this.storageMonitor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition conversionMonitor()
|
||||
{
|
||||
return this.conversionMonitor;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition conversionMonitor() {
|
||||
return this.conversionMonitor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluidTerminal()
|
||||
{
|
||||
return this.fluidTerminal;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition fluidTerminal() {
|
||||
return this.fluidTerminal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluidImportBus()
|
||||
{
|
||||
return this.fluidImportBus;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition fluidImportBus() {
|
||||
return this.fluidImportBus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluidExportBus()
|
||||
{
|
||||
return this.fluidExportBus;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition fluidExportBus() {
|
||||
return this.fluidExportBus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluidStorageBus()
|
||||
{
|
||||
return this.fluidStorageBus;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition fluidStorageBus() {
|
||||
return this.fluidStorageBus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluidLevelEmitter()
|
||||
{
|
||||
return this.fluidLevelEmitter;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition fluidLevelEmitter() {
|
||||
return this.fluidLevelEmitter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluidAnnihilationPlane()
|
||||
{
|
||||
return this.fluidAnnihilationPlane;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition fluidAnnihilationPlane() {
|
||||
return this.fluidAnnihilationPlane;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluidFormationnPlane()
|
||||
{
|
||||
return this.fluidFormationPlane;
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition fluidFormationnPlane() {
|
||||
return this.fluidFormationPlane;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,10 @@
|
||||
|
||||
package appeng.core.crash;
|
||||
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import net.minecraftforge.fml.common.ICrashCallable;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
|
||||
public class ModCrashEnhancement implements ICrashCallable {
|
||||
|
||||
@@ -33,8 +32,7 @@ public class ModCrashEnhancement implements ICrashCallable {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return AEConfig.CHANNEL + ' ' + AEConfig.VERSION + " for Forge " +
|
||||
ForgeVersion.getVersion();
|
||||
return AEConfig.CHANNEL + ' ' + AEConfig.VERSION + " for Forge " + ForgeVersion.getVersion();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,20 +18,14 @@
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
public enum ActivityState {
|
||||
Enabled, Disabled;
|
||||
|
||||
public enum ActivityState
|
||||
{
|
||||
Enabled, Disabled;
|
||||
|
||||
public static ActivityState from( final boolean enabled )
|
||||
{
|
||||
if( enabled )
|
||||
{
|
||||
return ActivityState.Enabled;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ActivityState.Disabled;
|
||||
}
|
||||
}
|
||||
public static ActivityState from(final boolean enabled) {
|
||||
if (enabled) {
|
||||
return ActivityState.Enabled;
|
||||
} else {
|
||||
return ActivityState.Disabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,8 @@
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -31,44 +29,38 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.api.features.AEFeature;
|
||||
|
||||
public class BlockDefinition extends ItemDefinition implements IBlockDefinition {
|
||||
private final Block block;
|
||||
|
||||
public class BlockDefinition extends ItemDefinition implements IBlockDefinition
|
||||
{
|
||||
private final Block block;
|
||||
private final BlockItem blockItem;
|
||||
|
||||
private final BlockItem blockItem;
|
||||
public BlockDefinition(String registryName, Block block, BlockItem item, Set<AEFeature> features) {
|
||||
super(registryName, item, features);
|
||||
this.block = block;
|
||||
this.blockItem = item;
|
||||
}
|
||||
|
||||
public BlockDefinition( String registryName, Block block, BlockItem item, Set<AEFeature> features )
|
||||
{
|
||||
super( registryName, item, features );
|
||||
this.block = block;
|
||||
this.blockItem = item;
|
||||
}
|
||||
@Override
|
||||
public final Block block() {
|
||||
return this.block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Block block()
|
||||
{
|
||||
return this.block;
|
||||
}
|
||||
@Override
|
||||
public BlockItem blockItem() {
|
||||
return blockItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItem blockItem()
|
||||
{
|
||||
return blockItem;
|
||||
}
|
||||
@Override
|
||||
public final ItemStack stack(int stackSize) {
|
||||
Preconditions.checkArgument(stackSize > 0);
|
||||
|
||||
@Override
|
||||
public final ItemStack stack( int stackSize )
|
||||
{
|
||||
Preconditions.checkArgument( stackSize > 0 );
|
||||
return new ItemStack(block, stackSize);
|
||||
}
|
||||
|
||||
return new ItemStack(block, stackSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isSameAs( final IBlockReader world, final BlockPos pos )
|
||||
{
|
||||
return world.getBlockState( pos ).getBlock() == this.block;
|
||||
}
|
||||
@Override
|
||||
public final boolean isSameAs(final IBlockReader world, final BlockPos pos) {
|
||||
return world.getBlockState(pos).getBlock() == this.block;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
@@ -27,39 +26,33 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class BlockStackSrc implements IStackSrc {
|
||||
|
||||
public class BlockStackSrc implements IStackSrc
|
||||
{
|
||||
private final Block block;
|
||||
private final boolean enabled;
|
||||
|
||||
private final Block block;
|
||||
private final boolean enabled;
|
||||
public BlockStackSrc(final Block block, final ActivityState state) {
|
||||
Preconditions.checkNotNull(block);
|
||||
Preconditions.checkNotNull(state);
|
||||
Preconditions.checkArgument(state == ActivityState.Enabled || state == ActivityState.Disabled);
|
||||
|
||||
public BlockStackSrc( final Block block, final ActivityState state )
|
||||
{
|
||||
Preconditions.checkNotNull( block );
|
||||
Preconditions.checkNotNull( state );
|
||||
Preconditions.checkArgument( state == ActivityState.Enabled || state == ActivityState.Disabled );
|
||||
this.block = block;
|
||||
this.enabled = state == ActivityState.Enabled;
|
||||
}
|
||||
|
||||
this.block = block;
|
||||
this.enabled = state == ActivityState.Enabled;
|
||||
}
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack stack(final int i) {
|
||||
return new ItemStack(this.block, i);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack stack( final int i )
|
||||
{
|
||||
return new ItemStack( this.block, i );
|
||||
}
|
||||
@Override
|
||||
public Item getItem() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItem()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return this.enabled;
|
||||
}
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -27,76 +26,63 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEColoredItemDefinition;
|
||||
|
||||
public final class ColoredItemDefinition implements AEColoredItemDefinition {
|
||||
|
||||
public final class ColoredItemDefinition implements AEColoredItemDefinition
|
||||
{
|
||||
private final ItemStackSrc[] colors = new ItemStackSrc[17];
|
||||
|
||||
private final ItemStackSrc[] colors = new ItemStackSrc[17];
|
||||
public void add(final AEColor v, final ItemStackSrc is) {
|
||||
this.colors[v.ordinal()] = is;
|
||||
}
|
||||
|
||||
public void add( final AEColor v, final ItemStackSrc is )
|
||||
{
|
||||
this.colors[v.ordinal()] = is;
|
||||
}
|
||||
@Override
|
||||
public Block block(final AEColor color) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block block( final AEColor color )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Item item(final AEColor color) {
|
||||
final ItemStackSrc is = this.colors[color.ordinal()];
|
||||
|
||||
@Override
|
||||
public Item item( final AEColor color )
|
||||
{
|
||||
final ItemStackSrc is = this.colors[color.ordinal()];
|
||||
if (is == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if( is == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return is.getItem();
|
||||
}
|
||||
|
||||
return is.getItem();
|
||||
}
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity(final AEColor color) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity( final AEColor color )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public ItemStack stack(final AEColor color, final int stackSize) {
|
||||
final ItemStackSrc is = this.colors[color.ordinal()];
|
||||
|
||||
@Override
|
||||
public ItemStack stack( final AEColor color, final int stackSize )
|
||||
{
|
||||
final ItemStackSrc is = this.colors[color.ordinal()];
|
||||
if (is == null) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if( is == null )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
return is.stack(stackSize);
|
||||
}
|
||||
|
||||
return is.stack( stackSize );
|
||||
}
|
||||
@Override
|
||||
public ItemStack[] allStacks(final int stackSize) {
|
||||
final ItemStack[] is = new ItemStack[this.colors.length];
|
||||
for (int x = 0; x < is.length; x++) {
|
||||
is[x] = this.colors[x].stack(1);
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] allStacks( final int stackSize )
|
||||
{
|
||||
final ItemStack[] is = new ItemStack[this.colors.length];
|
||||
for( int x = 0; x < is.length; x++ )
|
||||
{
|
||||
is[x] = this.colors[x].stack( 1 );
|
||||
}
|
||||
return is;
|
||||
}
|
||||
@Override
|
||||
public boolean sameAs(final AEColor color, final ItemStack comparableItem) {
|
||||
final ItemStackSrc is = this.colors[color.ordinal()];
|
||||
|
||||
@Override
|
||||
public boolean sameAs( final AEColor color, final ItemStack comparableItem )
|
||||
{
|
||||
final ItemStackSrc is = this.colors[color.ordinal()];
|
||||
if (comparableItem.isEmpty() || is == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( comparableItem.isEmpty() || is == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return comparableItem.getItem() == is.getItem();
|
||||
}
|
||||
return comparableItem.getItem() == is.getItem();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,77 +18,67 @@
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.features.AEFeature;
|
||||
|
||||
public final class DamagedItemDefinition implements IItemDefinition {
|
||||
private final String identifier;
|
||||
private final IStackSrc source;
|
||||
|
||||
public final class DamagedItemDefinition implements IItemDefinition
|
||||
{
|
||||
private final String identifier;
|
||||
private final IStackSrc source;
|
||||
public DamagedItemDefinition(@Nonnull final String identifier, @Nonnull final IStackSrc source) {
|
||||
this.identifier = Preconditions.checkNotNull(identifier);
|
||||
this.source = Preconditions.checkNotNull(source);
|
||||
}
|
||||
|
||||
public DamagedItemDefinition( @Nonnull final String identifier, @Nonnull final IStackSrc source )
|
||||
{
|
||||
this.identifier = Preconditions.checkNotNull( identifier );
|
||||
this.source = Preconditions.checkNotNull( source );
|
||||
}
|
||||
@Override
|
||||
public Item item() {
|
||||
return source.getItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item() {
|
||||
return source.getItem();
|
||||
}
|
||||
@Override
|
||||
public ItemStack stack(int stackSize) {
|
||||
return source.stack(stackSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(int stackSize) {
|
||||
return source.stack(stackSize);
|
||||
}
|
||||
@Nonnull
|
||||
@Override
|
||||
public String identifier() {
|
||||
return this.identifier;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String identifier()
|
||||
{
|
||||
return this.identifier;
|
||||
}
|
||||
@Override
|
||||
public Optional<Item> maybeItem() {
|
||||
return Optional.of(this.source.getItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Item> maybeItem()
|
||||
{
|
||||
return Optional.of(this.source.getItem());
|
||||
}
|
||||
@Override
|
||||
public Optional<ItemStack> maybeStack(final int stackSize) {
|
||||
return Optional.of(this.source.stack(stackSize));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ItemStack> maybeStack( final int stackSize )
|
||||
{
|
||||
return Optional.of(this.source.stack(stackSize));
|
||||
}
|
||||
@Override
|
||||
public Set<AEFeature> features() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<AEFeature> features()
|
||||
{
|
||||
return Collections.emptySet();
|
||||
}
|
||||
@Override
|
||||
public boolean isSameAs(final ItemStack comparableStack) {
|
||||
if (comparableStack.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameAs( final ItemStack comparableStack )
|
||||
{
|
||||
if( comparableStack.isEmpty() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return comparableStack.getItem() == this.source.getItem();
|
||||
}
|
||||
return comparableStack.getItem() == this.source.getItem();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,17 +18,14 @@
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IStackSrc {
|
||||
|
||||
public interface IStackSrc
|
||||
{
|
||||
ItemStack stack(int i);
|
||||
|
||||
ItemStack stack( int i );
|
||||
Item getItem();
|
||||
|
||||
Item getItem();
|
||||
|
||||
boolean isEnabled();
|
||||
boolean isEnabled();
|
||||
}
|
||||
|
||||
@@ -18,66 +18,57 @@
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ItemDefinition implements IItemDefinition {
|
||||
private final String identifier;
|
||||
private final Item item;
|
||||
private final Set<AEFeature> features;
|
||||
|
||||
public class ItemDefinition implements IItemDefinition
|
||||
{
|
||||
private final String identifier;
|
||||
private final Item item;
|
||||
private final Set<AEFeature> features;
|
||||
public ItemDefinition(String registryName, Item item, Set<AEFeature> features) {
|
||||
Preconditions.checkArgument(!Strings.isNullOrEmpty(registryName), "registryName");
|
||||
this.identifier = registryName;
|
||||
this.item = item;
|
||||
this.features = ImmutableSet.copyOf(features);
|
||||
}
|
||||
|
||||
public ItemDefinition( String registryName, Item item, Set<AEFeature> features )
|
||||
{
|
||||
Preconditions.checkArgument( !Strings.isNullOrEmpty( registryName ), "registryName" );
|
||||
this.identifier = registryName;
|
||||
this.item = item;
|
||||
this.features = ImmutableSet.copyOf(features);
|
||||
}
|
||||
@Nonnull
|
||||
@Override
|
||||
public String identifier() {
|
||||
return this.identifier;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String identifier()
|
||||
{
|
||||
return this.identifier;
|
||||
}
|
||||
@Override
|
||||
public final Item item() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Item item()
|
||||
{
|
||||
return this.item;
|
||||
}
|
||||
@Override
|
||||
public ItemStack stack(final int stackSize) {
|
||||
return new ItemStack(item, stackSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack( final int stackSize )
|
||||
{
|
||||
return new ItemStack( item, stackSize );
|
||||
}
|
||||
@Override
|
||||
public Set<AEFeature> features() {
|
||||
return features;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<AEFeature> features()
|
||||
{
|
||||
return features;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isSameAs( final ItemStack comparableStack )
|
||||
{
|
||||
return Platform.itemComparisons().isEqualItemType( comparableStack, this.stack( 1 ) );
|
||||
}
|
||||
@Override
|
||||
public final boolean isSameAs(final ItemStack comparableStack) {
|
||||
return Platform.itemComparisons().isEqualItemType(comparableStack, this.stack(1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
@@ -26,39 +25,33 @@ import com.google.common.base.Preconditions;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemStackSrc implements IStackSrc {
|
||||
|
||||
public class ItemStackSrc implements IStackSrc
|
||||
{
|
||||
private final Item item;
|
||||
private final boolean enabled;
|
||||
|
||||
private final Item item;
|
||||
private final boolean enabled;
|
||||
public ItemStackSrc(final Item item, final ActivityState state) {
|
||||
Preconditions.checkNotNull(item);
|
||||
Preconditions.checkNotNull(state);
|
||||
Preconditions.checkArgument(state == ActivityState.Enabled || state == ActivityState.Disabled);
|
||||
|
||||
public ItemStackSrc( final Item item, final ActivityState state )
|
||||
{
|
||||
Preconditions.checkNotNull( item );
|
||||
Preconditions.checkNotNull( state );
|
||||
Preconditions.checkArgument( state == ActivityState.Enabled || state == ActivityState.Disabled );
|
||||
this.item = item;
|
||||
this.enabled = state == ActivityState.Enabled;
|
||||
}
|
||||
|
||||
this.item = item;
|
||||
this.enabled = state == ActivityState.Enabled;
|
||||
}
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack stack(final int i) {
|
||||
return new ItemStack(this.item, i);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack stack( final int i )
|
||||
{
|
||||
return new ItemStack( this.item, i );
|
||||
}
|
||||
@Override
|
||||
public Item getItem() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItem()
|
||||
{
|
||||
return this.item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return this.enabled;
|
||||
}
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
@@ -26,35 +25,29 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.items.materials.MaterialType;
|
||||
|
||||
public class MaterialStackSrc implements IStackSrc {
|
||||
private final MaterialType src;
|
||||
private final boolean enabled;
|
||||
|
||||
public class MaterialStackSrc implements IStackSrc
|
||||
{
|
||||
private final MaterialType src;
|
||||
private final boolean enabled;
|
||||
public MaterialStackSrc(final MaterialType src, boolean enabled) {
|
||||
Preconditions.checkNotNull(src);
|
||||
|
||||
public MaterialStackSrc( final MaterialType src, boolean enabled )
|
||||
{
|
||||
Preconditions.checkNotNull( src );
|
||||
this.src = src;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
this.src = src;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
@Override
|
||||
public ItemStack stack(final int stackSize) {
|
||||
return this.src.stack(stackSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack( final int stackSize )
|
||||
{
|
||||
return this.src.stack( stackSize );
|
||||
}
|
||||
@Override
|
||||
public Item getItem() {
|
||||
return this.src.getItemInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItem()
|
||||
{
|
||||
return this.src.getItemInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return this.enabled;
|
||||
}
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,33 +18,29 @@
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.api.definitions.ITileDefinition;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
|
||||
public final class TileDefinition extends BlockDefinition implements ITileDefinition {
|
||||
private final AEBaseTileBlock<?> block;
|
||||
|
||||
public final class TileDefinition extends BlockDefinition implements ITileDefinition
|
||||
{
|
||||
private final AEBaseTileBlock<?> block;
|
||||
public TileDefinition(@Nonnull String registryName, AEBaseTileBlock<?> block, BlockItem item,
|
||||
Set<AEFeature> features) {
|
||||
super(registryName, block, item, features);
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public TileDefinition( @Nonnull String registryName, AEBaseTileBlock<?> block, BlockItem item, Set<AEFeature> features )
|
||||
{
|
||||
super( registryName, block, item, features );
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<? extends Class<? extends TileEntity>> maybeEntity()
|
||||
{
|
||||
return Optional.of(this.block.getTileEntityClass());
|
||||
}
|
||||
@Override
|
||||
public Optional<? extends Class<? extends TileEntity>> maybeEntity() {
|
||||
return Optional.of(this.block.getTileEntityClass());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
@@ -29,58 +28,44 @@ import appeng.api.networking.IGridCache;
|
||||
import appeng.api.networking.IGridCacheRegistry;
|
||||
import appeng.core.AELog;
|
||||
|
||||
public final class GridCacheRegistry implements IGridCacheRegistry {
|
||||
private final Map<Class<? extends IGridCache>, Class<? extends IGridCache>> caches = new HashMap<>();
|
||||
|
||||
public final class GridCacheRegistry implements IGridCacheRegistry
|
||||
{
|
||||
private final Map<Class<? extends IGridCache>, Class<? extends IGridCache>> caches = new HashMap<>();
|
||||
@Override
|
||||
public void registerGridCache(final Class<? extends IGridCache> iface,
|
||||
final Class<? extends IGridCache> implementation) {
|
||||
if (iface.isAssignableFrom(implementation)) {
|
||||
this.caches.put(iface, implementation);
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid setup, grid cache must either be the same class, or an interface that the implementation implements. Gotten: "
|
||||
+ iface + " and " + implementation);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerGridCache( final Class<? extends IGridCache> iface, final Class<? extends IGridCache> implementation )
|
||||
{
|
||||
if( iface.isAssignableFrom( implementation ) )
|
||||
{
|
||||
this.caches.put( iface, implementation );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException( "Invalid setup, grid cache must either be the same class, or an interface that the implementation implements. Gotten: " + iface + " and " + implementation );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public HashMap<Class<? extends IGridCache>, IGridCache> createCacheInstance(final IGrid g) {
|
||||
final HashMap<Class<? extends IGridCache>, IGridCache> map = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public HashMap<Class<? extends IGridCache>, IGridCache> createCacheInstance( final IGrid g )
|
||||
{
|
||||
final HashMap<Class<? extends IGridCache>, IGridCache> map = new HashMap<>();
|
||||
for (final Class<? extends IGridCache> iface : this.caches.keySet()) {
|
||||
try {
|
||||
final Constructor<? extends IGridCache> c = this.caches.get(iface).getConstructor(IGrid.class);
|
||||
map.put(iface, c.newInstance(g));
|
||||
} catch (final NoSuchMethodException e) {
|
||||
AELog.error("Grid Caches must have a constructor with IGrid as the single param.");
|
||||
throw new IllegalArgumentException(e);
|
||||
} catch (final InvocationTargetException e) {
|
||||
AELog.error("Grid Caches must have a constructor with IGrid as the single param.");
|
||||
throw new IllegalStateException(e);
|
||||
} catch (final InstantiationException e) {
|
||||
AELog.error("Grid Caches must have a constructor with IGrid as the single param.");
|
||||
throw new IllegalStateException(e);
|
||||
} catch (final IllegalAccessException e) {
|
||||
AELog.error("Grid Caches must have a constructor with IGrid as the single param.");
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
for( final Class<? extends IGridCache> iface : this.caches.keySet() )
|
||||
{
|
||||
try
|
||||
{
|
||||
final Constructor<? extends IGridCache> c = this.caches.get( iface ).getConstructor( IGrid.class );
|
||||
map.put( iface, c.newInstance( g ) );
|
||||
}
|
||||
catch( final NoSuchMethodException e )
|
||||
{
|
||||
AELog.error( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
throw new IllegalArgumentException( e );
|
||||
}
|
||||
catch( final InvocationTargetException e )
|
||||
{
|
||||
AELog.error( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final InstantiationException e )
|
||||
{
|
||||
AELog.error( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
AELog.error( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -31,38 +30,29 @@ import appeng.api.features.ILocatable;
|
||||
import appeng.api.features.ILocatableRegistry;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public final class LocatableRegistry implements ILocatableRegistry {
|
||||
private final Map<Long, ILocatable> set;
|
||||
|
||||
public final class LocatableRegistry implements ILocatableRegistry
|
||||
{
|
||||
private final Map<Long, ILocatable> set;
|
||||
public LocatableRegistry() {
|
||||
this.set = new HashMap<>();
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
public LocatableRegistry()
|
||||
{
|
||||
this.set = new HashMap<>();
|
||||
MinecraftForge.EVENT_BUS.register( this );
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void updateLocatable(final LocatableEventAnnounce e) {
|
||||
if (Platform.isClient()) {
|
||||
return; // IGNORE!
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void updateLocatable( final LocatableEventAnnounce e )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return; // IGNORE!
|
||||
}
|
||||
if (e.change == LocatableEvent.REGISTER) {
|
||||
this.set.put(e.target.getLocatableSerial(), e.target);
|
||||
} else if (e.change == LocatableEvent.UNREGISTER) {
|
||||
this.set.remove(e.target.getLocatableSerial());
|
||||
}
|
||||
}
|
||||
|
||||
if( e.change == LocatableEvent.REGISTER )
|
||||
{
|
||||
this.set.put( e.target.getLocatableSerial(), e.target );
|
||||
}
|
||||
else if( e.change == LocatableEvent.UNREGISTER )
|
||||
{
|
||||
this.set.remove( e.target.getLocatableSerial() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILocatable getLocatableBy( final long serial )
|
||||
{
|
||||
return this.set.get( serial );
|
||||
}
|
||||
@Override
|
||||
public ILocatable getLocatableBy(final long serial) {
|
||||
return this.set.get(serial);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -26,36 +25,29 @@ import net.minecraft.item.Items;
|
||||
|
||||
import appeng.api.features.IMatterCannonAmmoRegistry;
|
||||
|
||||
public class MatterCannonAmmoRegistry implements /* FIXME IOreListener, */ IMatterCannonAmmoRegistry {
|
||||
|
||||
public class MatterCannonAmmoRegistry implements /* FIXME IOreListener, */ IMatterCannonAmmoRegistry
|
||||
{
|
||||
private final HashMap<ItemStack, Double> DamageModifiers = new HashMap<>();
|
||||
|
||||
private final HashMap<ItemStack, Double> DamageModifiers = new HashMap<>();
|
||||
public MatterCannonAmmoRegistry() {
|
||||
// FIXME OreDictionaryHandler.INSTANCE.observe( this );
|
||||
this.registerAmmo(new ItemStack(Items.GOLD_NUGGET), 196.96655);
|
||||
}
|
||||
|
||||
public MatterCannonAmmoRegistry()
|
||||
{
|
||||
// FIXME OreDictionaryHandler.INSTANCE.observe( this );
|
||||
this.registerAmmo( new ItemStack( Items.GOLD_NUGGET ), 196.96655 );
|
||||
}
|
||||
@Override
|
||||
public void registerAmmo(final ItemStack ammo, final double weight) {
|
||||
this.DamageModifiers.put(ammo, weight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAmmo( final ItemStack ammo, final double weight )
|
||||
{
|
||||
this.DamageModifiers.put( ammo, weight );
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPenetration( final ItemStack is )
|
||||
{
|
||||
for( final ItemStack o : this.DamageModifiers.keySet() )
|
||||
{
|
||||
if( ItemStack.areItemsEqual( o, is ) )
|
||||
{
|
||||
return this.DamageModifiers.get( o ).floatValue();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public float getPenetration(final ItemStack is) {
|
||||
for (final ItemStack o : this.DamageModifiers.keySet()) {
|
||||
if (ItemStack.areItemsEqual(o, is)) {
|
||||
return this.DamageModifiers.get(o).floatValue();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// FIXME @Override
|
||||
// FIXME public void oreRegistered( final String name, final ItemStack item )
|
||||
@@ -138,11 +130,9 @@ public class MatterCannonAmmoRegistry implements /* FIXME IOreListener, */ IMatt
|
||||
// FIXME this.considerItem( name, item, "Electrum", ( 107.8682 + 196.96655 ) / 2.0 );
|
||||
// FIXME }
|
||||
|
||||
private void considerItem( final String ore, final ItemStack item, final String name, final double weight )
|
||||
{
|
||||
if( ore.equals( "berry" + name ) || ore.equals( "nugget" + name ) )
|
||||
{
|
||||
this.registerAmmo( item, weight );
|
||||
}
|
||||
}
|
||||
private void considerItem(final String ore, final ItemStack item, final String name, final double weight) {
|
||||
if (ore.equals("berry" + name) || ore.equals("nugget" + name)) {
|
||||
this.registerAmmo(item, weight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -33,136 +32,115 @@ import appeng.api.movable.IMovableRegistry;
|
||||
import appeng.api.movable.IMovableTile;
|
||||
import appeng.spatial.DefaultSpatialHandler;
|
||||
|
||||
public class MovableTileRegistry implements IMovableRegistry {
|
||||
|
||||
public class MovableTileRegistry implements IMovableRegistry
|
||||
{
|
||||
private final HashSet<Block> blacklisted = new HashSet<>();
|
||||
|
||||
private final HashSet<Block> blacklisted = new HashSet<>();
|
||||
private final HashMap<Class<? extends TileEntity>, IMovableHandler> Valid = new HashMap<>();
|
||||
private final List<Class<? extends TileEntity>> test = new ArrayList<>();
|
||||
private final List<IMovableHandler> handlers = new ArrayList<>();
|
||||
private final DefaultSpatialHandler dsh = new DefaultSpatialHandler();
|
||||
|
||||
private final HashMap<Class<? extends TileEntity>, IMovableHandler> Valid = new HashMap<>();
|
||||
private final List<Class<? extends TileEntity>> test = new ArrayList<>();
|
||||
private final List<IMovableHandler> handlers = new ArrayList<>();
|
||||
private final DefaultSpatialHandler dsh = new DefaultSpatialHandler();
|
||||
private final IMovableHandler nullHandler = new DefaultSpatialHandler();
|
||||
|
||||
private final IMovableHandler nullHandler = new DefaultSpatialHandler();
|
||||
@Override
|
||||
public void blacklistBlock(final Block blk) {
|
||||
this.blacklisted.add(blk);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blacklistBlock( final Block blk )
|
||||
{
|
||||
this.blacklisted.add( blk );
|
||||
}
|
||||
@Override
|
||||
public void whiteListTileEntity(final Class<? extends TileEntity> c) {
|
||||
if (c.getName().equals(TileEntity.class.getName())) {
|
||||
throw new IllegalArgumentException(new AppEngException("Someone tried to make all tiles movable with " + c
|
||||
+ ", this is a clear violation of the purpose of the white list."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whiteListTileEntity( final Class<? extends TileEntity> c )
|
||||
{
|
||||
if( c.getName().equals( TileEntity.class.getName() ) )
|
||||
{
|
||||
throw new IllegalArgumentException( new AppEngException( "Someone tried to make all tiles movable with " + c + ", this is a clear violation of the purpose of the white list." ) );
|
||||
}
|
||||
this.test.add(c);
|
||||
}
|
||||
|
||||
this.test.add( c );
|
||||
}
|
||||
@Override
|
||||
public boolean askToMove(final TileEntity te) {
|
||||
final Class myClass = te.getClass();
|
||||
IMovableHandler canMove = this.Valid.get(myClass);
|
||||
|
||||
@Override
|
||||
public boolean askToMove( final TileEntity te )
|
||||
{
|
||||
final Class myClass = te.getClass();
|
||||
IMovableHandler canMove = this.Valid.get( myClass );
|
||||
if (canMove == null) {
|
||||
canMove = this.testClass(myClass, te);
|
||||
}
|
||||
|
||||
if( canMove == null )
|
||||
{
|
||||
canMove = this.testClass( myClass, te );
|
||||
}
|
||||
if (canMove != this.nullHandler) {
|
||||
if (te instanceof IMovableTile) {
|
||||
((IMovableTile) te).prepareToMove();
|
||||
}
|
||||
|
||||
if( canMove != this.nullHandler )
|
||||
{
|
||||
if( te instanceof IMovableTile )
|
||||
{
|
||||
( (IMovableTile) te ).prepareToMove();
|
||||
}
|
||||
te.remove();
|
||||
return true;
|
||||
}
|
||||
|
||||
te.remove();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
private IMovableHandler testClass(final Class myClass, final TileEntity te) {
|
||||
IMovableHandler handler = null;
|
||||
|
||||
private IMovableHandler testClass( final Class myClass, final TileEntity te )
|
||||
{
|
||||
IMovableHandler handler = null;
|
||||
// ask handlers...
|
||||
for (final IMovableHandler han : this.handlers) {
|
||||
if (han.canHandle(myClass, te)) {
|
||||
handler = han;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ask handlers...
|
||||
for( final IMovableHandler han : this.handlers )
|
||||
{
|
||||
if( han.canHandle( myClass, te ) )
|
||||
{
|
||||
handler = han;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if you have a handler your opted in
|
||||
if (handler != null) {
|
||||
this.Valid.put(myClass, handler);
|
||||
return handler;
|
||||
}
|
||||
|
||||
// if you have a handler your opted in
|
||||
if( handler != null )
|
||||
{
|
||||
this.Valid.put( myClass, handler );
|
||||
return handler;
|
||||
}
|
||||
// if your movable our opted in
|
||||
if (te instanceof IMovableTile) {
|
||||
this.Valid.put(myClass, this.dsh);
|
||||
return this.dsh;
|
||||
}
|
||||
|
||||
// if your movable our opted in
|
||||
if( te instanceof IMovableTile )
|
||||
{
|
||||
this.Valid.put( myClass, this.dsh );
|
||||
return this.dsh;
|
||||
}
|
||||
// if you are on the white list your opted in.
|
||||
for (final Class<? extends TileEntity> testClass : this.test) {
|
||||
if (testClass.isAssignableFrom(myClass)) {
|
||||
this.Valid.put(myClass, this.dsh);
|
||||
return this.dsh;
|
||||
}
|
||||
}
|
||||
|
||||
// if you are on the white list your opted in.
|
||||
for( final Class<? extends TileEntity> testClass : this.test )
|
||||
{
|
||||
if( testClass.isAssignableFrom( myClass ) )
|
||||
{
|
||||
this.Valid.put( myClass, this.dsh );
|
||||
return this.dsh;
|
||||
}
|
||||
}
|
||||
this.Valid.put(myClass, this.nullHandler);
|
||||
return this.nullHandler;
|
||||
}
|
||||
|
||||
this.Valid.put( myClass, this.nullHandler );
|
||||
return this.nullHandler;
|
||||
}
|
||||
@Override
|
||||
public void doneMoving(final TileEntity te) {
|
||||
if (te instanceof IMovableTile) {
|
||||
final IMovableTile mt = (IMovableTile) te;
|
||||
mt.doneMoving();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doneMoving( final TileEntity te )
|
||||
{
|
||||
if( te instanceof IMovableTile )
|
||||
{
|
||||
final IMovableTile mt = (IMovableTile) te;
|
||||
mt.doneMoving();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void addHandler(final IMovableHandler han) {
|
||||
this.handlers.add(han);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHandler( final IMovableHandler han )
|
||||
{
|
||||
this.handlers.add( han );
|
||||
}
|
||||
@Override
|
||||
public IMovableHandler getHandler(final TileEntity te) {
|
||||
final Class myClass = te.getClass();
|
||||
final IMovableHandler h = this.Valid.get(myClass);
|
||||
return h == null ? this.dsh : h;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMovableHandler getHandler( final TileEntity te )
|
||||
{
|
||||
final Class myClass = te.getClass();
|
||||
final IMovableHandler h = this.Valid.get( myClass );
|
||||
return h == null ? this.dsh : h;
|
||||
}
|
||||
@Override
|
||||
public IMovableHandler getDefaultHandler() {
|
||||
return this.dsh;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMovableHandler getDefaultHandler()
|
||||
{
|
||||
return this.dsh;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlacklisted( final Block blk )
|
||||
{
|
||||
return this.blacklisted.contains( blk );
|
||||
}
|
||||
@Override
|
||||
public boolean isBlacklisted(final Block blk) {
|
||||
return this.blacklisted.contains(blk);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@@ -46,36 +45,33 @@ import appeng.api.features.IP2PTunnelRegistry;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.capabilities.Capabilities;
|
||||
|
||||
public final class P2PTunnelRegistry implements IP2PTunnelRegistry {
|
||||
private static final int INITIAL_CAPACITY = 40;
|
||||
|
||||
public final class P2PTunnelRegistry implements IP2PTunnelRegistry
|
||||
{
|
||||
private static final int INITIAL_CAPACITY = 40;
|
||||
private final Map<ItemStack, TunnelType> tunnels = new HashMap<>(INITIAL_CAPACITY);
|
||||
private final Map<String, TunnelType> modIdTunnels = new HashMap<>(INITIAL_CAPACITY);
|
||||
private final Map<Capability<?>, TunnelType> capTunnels = new HashMap<>(INITIAL_CAPACITY);
|
||||
|
||||
private final Map<ItemStack, TunnelType> tunnels = new HashMap<>( INITIAL_CAPACITY );
|
||||
private final Map<String, TunnelType> modIdTunnels = new HashMap<>( INITIAL_CAPACITY );
|
||||
private final Map<Capability<?>, TunnelType> capTunnels = new HashMap<>( INITIAL_CAPACITY );
|
||||
public void configure() {
|
||||
|
||||
public void configure()
|
||||
{
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IBlocks blocks = definitions.blocks();
|
||||
final IParts parts = definitions.parts();
|
||||
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IBlocks blocks = definitions.blocks();
|
||||
final IParts parts = definitions.parts();
|
||||
/**
|
||||
* light!
|
||||
*/
|
||||
this.addNewAttunement(new ItemStack(Blocks.TORCH), TunnelType.LIGHT);
|
||||
this.addNewAttunement(new ItemStack(Blocks.GLOWSTONE), TunnelType.LIGHT);
|
||||
|
||||
/**
|
||||
* light!
|
||||
*/
|
||||
this.addNewAttunement( new ItemStack( Blocks.TORCH ), TunnelType.LIGHT );
|
||||
this.addNewAttunement( new ItemStack( Blocks.GLOWSTONE ), TunnelType.LIGHT );
|
||||
/**
|
||||
* Forge energy tunnel items
|
||||
*/
|
||||
|
||||
/**
|
||||
* Forge energy tunnel items
|
||||
*/
|
||||
|
||||
this.addNewAttunement( blocks.energyCellDense(), TunnelType.FE_POWER );
|
||||
this.addNewAttunement( blocks.energyAcceptor(), TunnelType.FE_POWER );
|
||||
this.addNewAttunement( blocks.energyCell(), TunnelType.FE_POWER );
|
||||
this.addNewAttunement( blocks.energyCellCreative(), TunnelType.FE_POWER );
|
||||
this.addNewAttunement(blocks.energyCellDense(), TunnelType.FE_POWER);
|
||||
this.addNewAttunement(blocks.energyAcceptor(), TunnelType.FE_POWER);
|
||||
this.addNewAttunement(blocks.energyCell(), TunnelType.FE_POWER);
|
||||
this.addNewAttunement(blocks.energyCellCreative(), TunnelType.FE_POWER);
|
||||
|
||||
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 0 ), TunnelType.FE_POWER );
|
||||
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 1 ), TunnelType.FE_POWER );
|
||||
@@ -84,9 +80,9 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
|
||||
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 4 ), TunnelType.FE_POWER );
|
||||
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 5 ), TunnelType.FE_POWER );
|
||||
|
||||
/**
|
||||
* EU tunnel items
|
||||
*/
|
||||
/**
|
||||
* EU tunnel items
|
||||
*/
|
||||
|
||||
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 0 ), TunnelType.IC2_POWER ); // Copper cable
|
||||
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 1 ), TunnelType.IC2_POWER ); // Glass fibre cable
|
||||
@@ -94,31 +90,31 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
|
||||
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 3 ), TunnelType.IC2_POWER ); // HV cable
|
||||
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 4 ), TunnelType.IC2_POWER ); // Tin cable
|
||||
|
||||
/**
|
||||
* attune based on most redstone base items.
|
||||
*/
|
||||
this.addNewAttunement( new ItemStack( Items.REDSTONE ), TunnelType.REDSTONE );
|
||||
this.addNewAttunement( new ItemStack( Items.REPEATER ), TunnelType.REDSTONE );
|
||||
this.addNewAttunement( new ItemStack( Blocks.REDSTONE_LAMP ), TunnelType.REDSTONE );
|
||||
this.addNewAttunement( new ItemStack( Blocks.COMPARATOR ), TunnelType.REDSTONE );
|
||||
this.addNewAttunement( new ItemStack( Blocks.DAYLIGHT_DETECTOR ), TunnelType.REDSTONE );
|
||||
this.addNewAttunement( new ItemStack( Blocks.REDSTONE_WIRE ), TunnelType.REDSTONE );
|
||||
this.addNewAttunement( new ItemStack( Blocks.REDSTONE_BLOCK ), TunnelType.REDSTONE );
|
||||
this.addNewAttunement( new ItemStack( Blocks.LEVER ), TunnelType.REDSTONE );
|
||||
/**
|
||||
* attune based on most redstone base items.
|
||||
*/
|
||||
this.addNewAttunement(new ItemStack(Items.REDSTONE), TunnelType.REDSTONE);
|
||||
this.addNewAttunement(new ItemStack(Items.REPEATER), TunnelType.REDSTONE);
|
||||
this.addNewAttunement(new ItemStack(Blocks.REDSTONE_LAMP), TunnelType.REDSTONE);
|
||||
this.addNewAttunement(new ItemStack(Blocks.COMPARATOR), TunnelType.REDSTONE);
|
||||
this.addNewAttunement(new ItemStack(Blocks.DAYLIGHT_DETECTOR), TunnelType.REDSTONE);
|
||||
this.addNewAttunement(new ItemStack(Blocks.REDSTONE_WIRE), TunnelType.REDSTONE);
|
||||
this.addNewAttunement(new ItemStack(Blocks.REDSTONE_BLOCK), TunnelType.REDSTONE);
|
||||
this.addNewAttunement(new ItemStack(Blocks.LEVER), TunnelType.REDSTONE);
|
||||
|
||||
/**
|
||||
* attune based on lots of random item related stuff
|
||||
*/
|
||||
/**
|
||||
* attune based on lots of random item related stuff
|
||||
*/
|
||||
|
||||
this.addNewAttunement( blocks.iface(), TunnelType.ITEM );
|
||||
this.addNewAttunement( parts.iface(), TunnelType.ITEM );
|
||||
this.addNewAttunement( parts.storageBus(), TunnelType.ITEM );
|
||||
this.addNewAttunement( parts.importBus(), TunnelType.ITEM );
|
||||
this.addNewAttunement( parts.exportBus(), TunnelType.ITEM );
|
||||
this.addNewAttunement(blocks.iface(), TunnelType.ITEM);
|
||||
this.addNewAttunement(parts.iface(), TunnelType.ITEM);
|
||||
this.addNewAttunement(parts.storageBus(), TunnelType.ITEM);
|
||||
this.addNewAttunement(parts.importBus(), TunnelType.ITEM);
|
||||
this.addNewAttunement(parts.exportBus(), TunnelType.ITEM);
|
||||
|
||||
this.addNewAttunement( new ItemStack( Blocks.HOPPER ), TunnelType.ITEM );
|
||||
this.addNewAttunement( new ItemStack( Blocks.CHEST ), TunnelType.ITEM );
|
||||
this.addNewAttunement( new ItemStack( Blocks.TRAPPED_CHEST ), TunnelType.ITEM );
|
||||
this.addNewAttunement(new ItemStack(Blocks.HOPPER), TunnelType.ITEM);
|
||||
this.addNewAttunement(new ItemStack(Blocks.CHEST), TunnelType.ITEM);
|
||||
this.addNewAttunement(new ItemStack(Blocks.TRAPPED_CHEST), TunnelType.ITEM);
|
||||
// FIXME this.addNewAttunement( this.getModItem( "extrautilities", "extractor_base", 0 ), TunnelType.ITEM );
|
||||
// FIXME this.addNewAttunement( this.getModItem( "mekanism", "parttransmitter", 9 ), TunnelType.ITEM );
|
||||
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 0 ), TunnelType.ITEM ); // itemduct
|
||||
@@ -128,15 +124,15 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
|
||||
// FIXME // itemduct
|
||||
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 3 ), TunnelType.ITEM ); // impulse
|
||||
// FIXME // itemduct
|
||||
// (opaque)
|
||||
// (opaque)
|
||||
|
||||
/**
|
||||
* attune based on lots of random item related stuff
|
||||
*/
|
||||
this.addNewAttunement( new ItemStack( Items.BUCKET ), TunnelType.FLUID );
|
||||
this.addNewAttunement( new ItemStack( Items.LAVA_BUCKET ), TunnelType.FLUID );
|
||||
this.addNewAttunement( new ItemStack( Items.MILK_BUCKET ), TunnelType.FLUID );
|
||||
this.addNewAttunement( new ItemStack( Items.WATER_BUCKET ), TunnelType.FLUID );
|
||||
/**
|
||||
* attune based on lots of random item related stuff
|
||||
*/
|
||||
this.addNewAttunement(new ItemStack(Items.BUCKET), TunnelType.FLUID);
|
||||
this.addNewAttunement(new ItemStack(Items.LAVA_BUCKET), TunnelType.FLUID);
|
||||
this.addNewAttunement(new ItemStack(Items.MILK_BUCKET), TunnelType.FLUID);
|
||||
this.addNewAttunement(new ItemStack(Items.WATER_BUCKET), TunnelType.FLUID);
|
||||
// FIXME this.addNewAttunement( this.getModItem( "mekanism", "machineblock2", 11 ), TunnelType.FLUID );
|
||||
// FIXME this.addNewAttunement( this.getModItem( "mekanism", "parttransmitter", 4 ), TunnelType.FLUID );
|
||||
// FIXME this.addNewAttunement( this.getModItem( "extrautilities", "extractor_base", 6 ), TunnelType.FLUID );
|
||||
@@ -149,132 +145,115 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
|
||||
// FIXME // hardened
|
||||
// FIXME // (opaque)
|
||||
// FIXME
|
||||
for( final AEColor c : AEColor.values() )
|
||||
{
|
||||
this.addNewAttunement( parts.cableGlass().stack( c, 1 ), TunnelType.ME );
|
||||
this.addNewAttunement( parts.cableCovered().stack( c, 1 ), TunnelType.ME );
|
||||
this.addNewAttunement( parts.cableSmart().stack( c, 1 ), TunnelType.ME );
|
||||
this.addNewAttunement( parts.cableDenseSmart().stack( c, 1 ), TunnelType.ME );
|
||||
}
|
||||
for (final AEColor c : AEColor.values()) {
|
||||
this.addNewAttunement(parts.cableGlass().stack(c, 1), TunnelType.ME);
|
||||
this.addNewAttunement(parts.cableCovered().stack(c, 1), TunnelType.ME);
|
||||
this.addNewAttunement(parts.cableSmart().stack(c, 1), TunnelType.ME);
|
||||
this.addNewAttunement(parts.cableDenseSmart().stack(c, 1), TunnelType.ME);
|
||||
}
|
||||
|
||||
/**
|
||||
* attune based caps
|
||||
*/
|
||||
this.addNewAttunement( Capabilities.FORGE_ENERGY, TunnelType.FE_POWER );
|
||||
this.addNewAttunement( CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, TunnelType.FLUID );
|
||||
/**
|
||||
* attune based caps
|
||||
*/
|
||||
this.addNewAttunement(Capabilities.FORGE_ENERGY, TunnelType.FE_POWER);
|
||||
this.addNewAttunement(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, TunnelType.FLUID);
|
||||
|
||||
/**
|
||||
* attune based on the ItemStack's modId
|
||||
*/
|
||||
/**
|
||||
* attune based on the ItemStack's modId
|
||||
*/
|
||||
|
||||
this.addNewAttunement( "thermaldynamics", TunnelType.FE_POWER );
|
||||
this.addNewAttunement( "thermalexpansion", TunnelType.FE_POWER );
|
||||
this.addNewAttunement( "thermalfoundation", TunnelType.FE_POWER );
|
||||
// TODO: Remove when confirmed that the official 1.12 version of EnderIO will support FE.
|
||||
this.addNewAttunement( "enderio", TunnelType.FE_POWER );
|
||||
// TODO: Remove when confirmed that the official 1.12 version of Mekanism will support FE.
|
||||
this.addNewAttunement( "mekanism", TunnelType.FE_POWER );
|
||||
// TODO: Remove when support for RFTools' Powercells support is added
|
||||
this.addNewAttunement( "rftools", TunnelType.FE_POWER );
|
||||
this.addNewAttunement( "ic2", TunnelType.IC2_POWER );
|
||||
this.addNewAttunement("thermaldynamics", TunnelType.FE_POWER);
|
||||
this.addNewAttunement("thermalexpansion", TunnelType.FE_POWER);
|
||||
this.addNewAttunement("thermalfoundation", TunnelType.FE_POWER);
|
||||
// TODO: Remove when confirmed that the official 1.12 version of EnderIO will
|
||||
// support FE.
|
||||
this.addNewAttunement("enderio", TunnelType.FE_POWER);
|
||||
// TODO: Remove when confirmed that the official 1.12 version of Mekanism will
|
||||
// support FE.
|
||||
this.addNewAttunement("mekanism", TunnelType.FE_POWER);
|
||||
// TODO: Remove when support for RFTools' Powercells support is added
|
||||
this.addNewAttunement("rftools", TunnelType.FE_POWER);
|
||||
this.addNewAttunement("ic2", TunnelType.IC2_POWER);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNewAttunement( @Nonnull final String modId, @Nullable final TunnelType type )
|
||||
{
|
||||
if( type == null || modId == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.modIdTunnels.put( modId, type );
|
||||
}
|
||||
@Override
|
||||
public void addNewAttunement(@Nonnull final String modId, @Nullable final TunnelType type) {
|
||||
if (type == null || modId == null) {
|
||||
return;
|
||||
}
|
||||
this.modIdTunnels.put(modId, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNewAttunement( @Nonnull final Capability<?> cap, @Nullable final TunnelType type )
|
||||
{
|
||||
if( type == null || cap == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.capTunnels.put( cap, type );
|
||||
}
|
||||
@Override
|
||||
public void addNewAttunement(@Nonnull final Capability<?> cap, @Nullable final TunnelType type) {
|
||||
if (type == null || cap == null) {
|
||||
return;
|
||||
}
|
||||
this.capTunnels.put(cap, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNewAttunement( @Nonnull final ItemStack trigger, @Nullable final TunnelType type )
|
||||
{
|
||||
if( type == null || trigger.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void addNewAttunement(@Nonnull final ItemStack trigger, @Nullable final TunnelType type) {
|
||||
if (type == null || trigger.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.tunnels.put( trigger, type );
|
||||
}
|
||||
this.tunnels.put(trigger, type);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TunnelType getTunnelTypeByItem( final ItemStack trigger )
|
||||
{
|
||||
if( !trigger.isEmpty() )
|
||||
{
|
||||
// First match exact items
|
||||
for( final Entry<ItemStack, TunnelType> entry : this.tunnels.entrySet() )
|
||||
{
|
||||
final ItemStack is = entry.getKey();
|
||||
@Nullable
|
||||
@Override
|
||||
public TunnelType getTunnelTypeByItem(final ItemStack trigger) {
|
||||
if (!trigger.isEmpty()) {
|
||||
// First match exact items
|
||||
for (final Entry<ItemStack, TunnelType> entry : this.tunnels.entrySet()) {
|
||||
final ItemStack is = entry.getKey();
|
||||
|
||||
if( is.getItem() == trigger.getItem() )
|
||||
{
|
||||
return entry.getValue();
|
||||
}
|
||||
if (is.getItem() == trigger.getItem()) {
|
||||
return entry.getValue();
|
||||
}
|
||||
|
||||
if( ItemStack.areItemsEqual( is, trigger ) )
|
||||
{
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
if (ItemStack.areItemsEqual(is, trigger)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
// Next, check if the Item you're holding supports any registered capability
|
||||
for( Direction face : Direction.values() )
|
||||
{
|
||||
for( Entry<Capability<?>, TunnelType> entry : this.capTunnels.entrySet() )
|
||||
{
|
||||
if( trigger.getCapability( entry.getKey(), face ).isPresent() )
|
||||
{
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Next, check if the Item you're holding supports any registered capability
|
||||
for (Direction face : Direction.values()) {
|
||||
for (Entry<Capability<?>, TunnelType> entry : this.capTunnels.entrySet()) {
|
||||
if (trigger.getCapability(entry.getKey(), face).isPresent()) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Use the mod id as last option.
|
||||
for( final Entry<String, TunnelType> entry : this.modIdTunnels.entrySet() )
|
||||
{
|
||||
if( trigger.getItem().getRegistryName() != null && trigger.getItem().getRegistryName().getNamespace().equals( entry.getKey() ) )
|
||||
{
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Use the mod id as last option.
|
||||
for (final Entry<String, TunnelType> entry : this.modIdTunnels.entrySet()) {
|
||||
if (trigger.getItem().getRegistryName() != null
|
||||
&& trigger.getItem().getRegistryName().getNamespace().equals(entry.getKey())) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private ItemStack getModItem( final String modID, final String name )
|
||||
{
|
||||
@Nonnull
|
||||
private ItemStack getModItem(final String modID, final String name) {
|
||||
|
||||
final Item item = ForgeRegistries.ITEMS.getValue( new ResourceLocation( modID + ":" + name ) );
|
||||
final Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(modID + ":" + name));
|
||||
|
||||
if( item == null )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
if (item == null) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
final ItemStack myItemStack = new ItemStack( item, 1 );
|
||||
return myItemStack;
|
||||
}
|
||||
final ItemStack myItemStack = new ItemStack(item, 1);
|
||||
return myItemStack;
|
||||
}
|
||||
|
||||
private void addNewAttunement( final IItemDefinition definition, final TunnelType type )
|
||||
{
|
||||
definition.maybeStack( 1 ).ifPresent( definitionStack -> this.addNewAttunement( definitionStack, type ) );
|
||||
}
|
||||
private void addNewAttunement(final IItemDefinition definition, final TunnelType type) {
|
||||
definition.maybeStack(1).ifPresent(definitionStack -> this.addNewAttunement(definitionStack, type));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -27,32 +26,26 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.api.parts.IPartModels;
|
||||
|
||||
public class PartModels implements IPartModels {
|
||||
|
||||
public class PartModels implements IPartModels
|
||||
{
|
||||
private final Set<ResourceLocation> models = new HashSet<>();
|
||||
|
||||
private final Set<ResourceLocation> models = new HashSet<>();
|
||||
private boolean initialized = false;
|
||||
|
||||
private boolean initialized = false;
|
||||
@Override
|
||||
public void registerModels(Collection<ResourceLocation> partModels) {
|
||||
if (this.initialized) {
|
||||
throw new IllegalStateException("Cannot register models after the pre-initialization phase!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerModels( Collection<ResourceLocation> partModels )
|
||||
{
|
||||
if( this.initialized )
|
||||
{
|
||||
throw new IllegalStateException( "Cannot register models after the pre-initialization phase!" );
|
||||
}
|
||||
this.models.addAll(partModels);
|
||||
}
|
||||
|
||||
this.models.addAll( partModels );
|
||||
}
|
||||
public Set<ResourceLocation> getModels() {
|
||||
return this.models;
|
||||
}
|
||||
|
||||
public Set<ResourceLocation> getModels()
|
||||
{
|
||||
return this.models;
|
||||
}
|
||||
|
||||
public void setInitialized( boolean initialized )
|
||||
{
|
||||
this.initialized = initialized;
|
||||
}
|
||||
public void setInitialized(boolean initialized) {
|
||||
this.initialized = initialized;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,57 +18,48 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
||||
import appeng.api.features.IPlayerRegistry;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.worlddata.WorldData;
|
||||
|
||||
import java.util.UUID;
|
||||
public class PlayerRegistry implements IPlayerRegistry {
|
||||
|
||||
@Override
|
||||
public int getID(final GameProfile username) {
|
||||
if (username == null || !username.isComplete()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public class PlayerRegistry implements IPlayerRegistry
|
||||
{
|
||||
return WorldData.instance().playerData().getMePlayerId(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getID( final GameProfile username )
|
||||
{
|
||||
if( username == null || !username.isComplete() )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@Override
|
||||
public int getID(final PlayerEntity player) {
|
||||
return this.getID(player.getGameProfile());
|
||||
}
|
||||
|
||||
return WorldData.instance().playerData().getMePlayerId( username );
|
||||
}
|
||||
@Nullable
|
||||
@Override
|
||||
public PlayerEntity findPlayer(final int playerID) {
|
||||
UUID profileId = WorldData.instance().playerData().getProfileId(playerID);
|
||||
if (profileId == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getID( final PlayerEntity player )
|
||||
{
|
||||
return this.getID( player.getGameProfile() );
|
||||
}
|
||||
for (final PlayerEntity player : AppEng.proxy.getPlayers()) {
|
||||
if (player.getUniqueID().equals(profileId)) {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PlayerEntity findPlayer( final int playerID )
|
||||
{
|
||||
UUID profileId = WorldData.instance().playerData().getProfileId(playerID);
|
||||
if (profileId == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for( final PlayerEntity player : AppEng.proxy.getPlayers() )
|
||||
{
|
||||
if( player.getUniqueID().equals( profileId ) )
|
||||
{
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import appeng.api.features.IChargerRegistry;
|
||||
import appeng.api.features.ILocatableRegistry;
|
||||
import appeng.api.features.IMatterCannonAmmoRegistry;
|
||||
@@ -35,7 +34,6 @@ import appeng.api.storage.ICellRegistry;
|
||||
import appeng.core.features.registries.cell.CellRegistry;
|
||||
import appeng.core.features.registries.charger.ChargerRegistry;
|
||||
|
||||
|
||||
/**
|
||||
* represents all registries
|
||||
*
|
||||
@@ -45,90 +43,77 @@ import appeng.core.features.registries.charger.ChargerRegistry;
|
||||
* @version rv5
|
||||
* @since rv0
|
||||
*/
|
||||
public class RegistryContainer implements IRegistryContainer
|
||||
{
|
||||
private final IChargerRegistry charger = new ChargerRegistry();
|
||||
private final ICellRegistry cell = new CellRegistry();
|
||||
private final ILocatableRegistry locatable = new LocatableRegistry();
|
||||
private final ISpecialComparisonRegistry comparison = new SpecialComparisonRegistry();
|
||||
private final IWirelessTermRegistry wireless = new WirelessRegistry();
|
||||
private final IGridCacheRegistry gridCache = new GridCacheRegistry();
|
||||
private final IP2PTunnelRegistry p2pTunnel = new P2PTunnelRegistry();
|
||||
private final IMovableRegistry movable = new MovableTileRegistry();
|
||||
private final IMatterCannonAmmoRegistry matterCannonReg = new MatterCannonAmmoRegistry();
|
||||
private final IPlayerRegistry playerRegistry = new PlayerRegistry();
|
||||
private final IPartModels partModels = new PartModels();
|
||||
public class RegistryContainer implements IRegistryContainer {
|
||||
private final IChargerRegistry charger = new ChargerRegistry();
|
||||
private final ICellRegistry cell = new CellRegistry();
|
||||
private final ILocatableRegistry locatable = new LocatableRegistry();
|
||||
private final ISpecialComparisonRegistry comparison = new SpecialComparisonRegistry();
|
||||
private final IWirelessTermRegistry wireless = new WirelessRegistry();
|
||||
private final IGridCacheRegistry gridCache = new GridCacheRegistry();
|
||||
private final IP2PTunnelRegistry p2pTunnel = new P2PTunnelRegistry();
|
||||
private final IMovableRegistry movable = new MovableTileRegistry();
|
||||
private final IMatterCannonAmmoRegistry matterCannonReg = new MatterCannonAmmoRegistry();
|
||||
private final IPlayerRegistry playerRegistry = new PlayerRegistry();
|
||||
private final IPartModels partModels = new PartModels();
|
||||
|
||||
@Override
|
||||
public IMovableRegistry movable()
|
||||
{
|
||||
return this.movable;
|
||||
}
|
||||
@Override
|
||||
public IMovableRegistry movable() {
|
||||
return this.movable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridCacheRegistry gridCache()
|
||||
{
|
||||
return this.gridCache;
|
||||
}
|
||||
@Override
|
||||
public IGridCacheRegistry gridCache() {
|
||||
return this.gridCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISpecialComparisonRegistry specialComparison()
|
||||
{
|
||||
return this.comparison;
|
||||
}
|
||||
@Override
|
||||
public ISpecialComparisonRegistry specialComparison() {
|
||||
return this.comparison;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWirelessTermRegistry wireless()
|
||||
{
|
||||
return this.wireless;
|
||||
}
|
||||
@Override
|
||||
public IWirelessTermRegistry wireless() {
|
||||
return this.wireless;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICellRegistry cell()
|
||||
{
|
||||
return this.cell;
|
||||
}
|
||||
@Override
|
||||
public ICellRegistry cell() {
|
||||
return this.cell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChargerRegistry charger()
|
||||
{
|
||||
return this.charger;
|
||||
}
|
||||
@Override
|
||||
public IChargerRegistry charger() {
|
||||
return this.charger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILocatableRegistry locatable()
|
||||
{
|
||||
return this.locatable;
|
||||
}
|
||||
@Override
|
||||
public ILocatableRegistry locatable() {
|
||||
return this.locatable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IP2PTunnelRegistry p2pTunnel()
|
||||
{
|
||||
return this.p2pTunnel;
|
||||
}
|
||||
@Override
|
||||
public IP2PTunnelRegistry p2pTunnel() {
|
||||
return this.p2pTunnel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMatterCannonAmmoRegistry matterCannon()
|
||||
{
|
||||
return this.matterCannonReg;
|
||||
}
|
||||
@Override
|
||||
public IMatterCannonAmmoRegistry matterCannon() {
|
||||
return this.matterCannonReg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPlayerRegistry players()
|
||||
{
|
||||
return this.playerRegistry;
|
||||
}
|
||||
@Override
|
||||
public IPlayerRegistry players() {
|
||||
return this.playerRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWorldGen worldgen()
|
||||
{
|
||||
return WorldGenRegistry.INSTANCE;
|
||||
}
|
||||
@Override
|
||||
public IWorldGen worldgen() {
|
||||
return WorldGenRegistry.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartModels partModels()
|
||||
{
|
||||
return this.partModels;
|
||||
}
|
||||
@Override
|
||||
public IPartModels partModels() {
|
||||
return this.partModels;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -28,35 +27,28 @@ import appeng.api.features.IItemComparison;
|
||||
import appeng.api.features.IItemComparisonProvider;
|
||||
import appeng.api.features.ISpecialComparisonRegistry;
|
||||
|
||||
public class SpecialComparisonRegistry implements ISpecialComparisonRegistry {
|
||||
|
||||
public class SpecialComparisonRegistry implements ISpecialComparisonRegistry
|
||||
{
|
||||
private final List<IItemComparisonProvider> CompRegistry;
|
||||
|
||||
private final List<IItemComparisonProvider> CompRegistry;
|
||||
public SpecialComparisonRegistry() {
|
||||
this.CompRegistry = new ArrayList<>();
|
||||
}
|
||||
|
||||
public SpecialComparisonRegistry()
|
||||
{
|
||||
this.CompRegistry = new ArrayList<>();
|
||||
}
|
||||
@Override
|
||||
public IItemComparison getSpecialComparison(final ItemStack stack) {
|
||||
for (final IItemComparisonProvider i : this.CompRegistry) {
|
||||
final IItemComparison comp = i.getComparison(stack);
|
||||
if (comp != null) {
|
||||
return comp;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemComparison getSpecialComparison( final ItemStack stack )
|
||||
{
|
||||
for( final IItemComparisonProvider i : this.CompRegistry )
|
||||
{
|
||||
final IItemComparison comp = i.getComparison( stack );
|
||||
if( comp != null )
|
||||
{
|
||||
return comp;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addComparisonProvider( final IItemComparisonProvider prov )
|
||||
{
|
||||
this.CompRegistry.add( prov );
|
||||
}
|
||||
@Override
|
||||
public void addComparisonProvider(final IItemComparisonProvider prov) {
|
||||
this.CompRegistry.add(prov);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,9 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerMEPortableCell;
|
||||
import appeng.container.implementations.ContainerWirelessTerm;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Hand;
|
||||
@@ -35,92 +30,76 @@ import appeng.api.AEApi;
|
||||
import appeng.api.features.ILocatable;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.features.IWirelessTermRegistry;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerMEPortableCell;
|
||||
import appeng.container.implementations.ContainerWirelessTerm;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
|
||||
import appeng.util.Platform;
|
||||
|
||||
public final class WirelessRegistry implements IWirelessTermRegistry {
|
||||
private final List<IWirelessTermHandler> handlers;
|
||||
|
||||
public final class WirelessRegistry implements IWirelessTermRegistry
|
||||
{
|
||||
private final List<IWirelessTermHandler> handlers;
|
||||
public WirelessRegistry() {
|
||||
this.handlers = new ArrayList<>();
|
||||
}
|
||||
|
||||
public WirelessRegistry()
|
||||
{
|
||||
this.handlers = new ArrayList<>();
|
||||
}
|
||||
@Override
|
||||
public void registerWirelessHandler(final IWirelessTermHandler handler) {
|
||||
if (handler != null) {
|
||||
this.handlers.add(handler);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerWirelessHandler( final IWirelessTermHandler handler )
|
||||
{
|
||||
if( handler != null )
|
||||
{
|
||||
this.handlers.add( handler );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean isWirelessTerminal(final ItemStack is) {
|
||||
for (final IWirelessTermHandler h : this.handlers) {
|
||||
if (h.canHandle(is)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWirelessTerminal( final ItemStack is )
|
||||
{
|
||||
for( final IWirelessTermHandler h : this.handlers )
|
||||
{
|
||||
if( h.canHandle( is ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public IWirelessTermHandler getWirelessTerminalHandler(final ItemStack is) {
|
||||
for (final IWirelessTermHandler h : this.handlers) {
|
||||
if (h.canHandle(is)) {
|
||||
return h;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWirelessTermHandler getWirelessTerminalHandler( final ItemStack is )
|
||||
{
|
||||
for( final IWirelessTermHandler h : this.handlers )
|
||||
{
|
||||
if( h.canHandle( is ) )
|
||||
{
|
||||
return h;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public void openWirelessTerminalGui(ItemStack item, IBlockReader world, PlayerEntity player, Hand hand) {
|
||||
if (Platform.isClient()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openWirelessTerminalGui( ItemStack item, IBlockReader world, PlayerEntity player, Hand hand )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!this.isWirelessTerminal(item)) {
|
||||
player.sendMessage(PlayerMessages.DeviceNotWirelessTerminal.get());
|
||||
return;
|
||||
}
|
||||
|
||||
if( !this.isWirelessTerminal( item ) )
|
||||
{
|
||||
player.sendMessage( PlayerMessages.DeviceNotWirelessTerminal.get() );
|
||||
return;
|
||||
}
|
||||
final IWirelessTermHandler handler = this.getWirelessTerminalHandler(item);
|
||||
final String unparsedKey = handler.getEncryptionKey(item);
|
||||
if (unparsedKey.isEmpty()) {
|
||||
player.sendMessage(PlayerMessages.DeviceNotLinked.get());
|
||||
return;
|
||||
}
|
||||
|
||||
final IWirelessTermHandler handler = this.getWirelessTerminalHandler( item );
|
||||
final String unparsedKey = handler.getEncryptionKey( item );
|
||||
if( unparsedKey.isEmpty() )
|
||||
{
|
||||
player.sendMessage( PlayerMessages.DeviceNotLinked.get() );
|
||||
return;
|
||||
}
|
||||
final long parsedKey = Long.parseLong(unparsedKey);
|
||||
final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy(parsedKey);
|
||||
if (securityStation == null) {
|
||||
player.sendMessage(PlayerMessages.StationCanNotBeLocated.get());
|
||||
return;
|
||||
}
|
||||
|
||||
final long parsedKey = Long.parseLong( unparsedKey );
|
||||
final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy( parsedKey );
|
||||
if( securityStation == null )
|
||||
{
|
||||
player.sendMessage( PlayerMessages.StationCanNotBeLocated.get() );
|
||||
return;
|
||||
}
|
||||
|
||||
if( handler.hasPower( player, 0.5, item ) )
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerWirelessTerm.TYPE, player, ContainerLocator.forHand(player, hand));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage( PlayerMessages.DeviceNotPowered.get() );
|
||||
}
|
||||
}
|
||||
if (handler.hasPower(player, 0.5, item)) {
|
||||
ContainerOpener.openContainer(ContainerWirelessTerm.TYPE, player, ContainerLocator.forHand(player, hand));
|
||||
} else {
|
||||
player.sendMessage(PlayerMessages.DeviceNotPowered.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,109 +18,91 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.Dimension;
|
||||
|
||||
import appeng.api.features.IWorldGen;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.common.extensions.IForgeDimension;
|
||||
|
||||
import appeng.api.features.IWorldGen;
|
||||
|
||||
public final class WorldGenRegistry implements IWorldGen
|
||||
{
|
||||
public final class WorldGenRegistry implements IWorldGen {
|
||||
|
||||
public static final WorldGenRegistry INSTANCE = new WorldGenRegistry();
|
||||
private final TypeSet[] types;
|
||||
public static final WorldGenRegistry INSTANCE = new WorldGenRegistry();
|
||||
private final TypeSet[] types;
|
||||
|
||||
private WorldGenRegistry()
|
||||
{
|
||||
private WorldGenRegistry() {
|
||||
|
||||
this.types = new TypeSet[WorldGenType.values().length];
|
||||
this.types = new TypeSet[WorldGenType.values().length];
|
||||
|
||||
for( final WorldGenType type : WorldGenType.values() )
|
||||
{
|
||||
this.types[type.ordinal()] = new TypeSet();
|
||||
}
|
||||
}
|
||||
for (final WorldGenType type : WorldGenType.values()) {
|
||||
this.types[type.ordinal()] = new TypeSet();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableWorldGenForProviderID( WorldGenType type, Class<? extends Dimension> provider )
|
||||
{
|
||||
if( type == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "Bad Type Passed" );
|
||||
}
|
||||
@Override
|
||||
public void disableWorldGenForProviderID(WorldGenType type, Class<? extends Dimension> provider) {
|
||||
if (type == null) {
|
||||
throw new IllegalArgumentException("Bad Type Passed");
|
||||
}
|
||||
|
||||
if( provider == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "Bad Provider Passed" );
|
||||
}
|
||||
if (provider == null) {
|
||||
throw new IllegalArgumentException("Bad Provider Passed");
|
||||
}
|
||||
|
||||
this.types[type.ordinal()].badProviders.add( provider );
|
||||
}
|
||||
this.types[type.ordinal()].badProviders.add(provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableWorldGenForDimension( final WorldGenType type, final ResourceLocation dimensionID )
|
||||
{
|
||||
if( type == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "Bad Type Passed" );
|
||||
}
|
||||
@Override
|
||||
public void enableWorldGenForDimension(final WorldGenType type, final ResourceLocation dimensionID) {
|
||||
if (type == null) {
|
||||
throw new IllegalArgumentException("Bad Type Passed");
|
||||
}
|
||||
|
||||
this.types[type.ordinal()].enabledDimensions.add( dimensionID );
|
||||
}
|
||||
this.types[type.ordinal()].enabledDimensions.add(dimensionID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableWorldGenForDimension( final WorldGenType type, final ResourceLocation dimensionID )
|
||||
{
|
||||
if( type == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "Bad Type Passed" );
|
||||
}
|
||||
@Override
|
||||
public void disableWorldGenForDimension(final WorldGenType type, final ResourceLocation dimensionID) {
|
||||
if (type == null) {
|
||||
throw new IllegalArgumentException("Bad Type Passed");
|
||||
}
|
||||
|
||||
this.types[type.ordinal()].badDimensions.add( dimensionID );
|
||||
}
|
||||
this.types[type.ordinal()].badDimensions.add(dimensionID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorldGenEnabled( final WorldGenType type, final World w )
|
||||
{
|
||||
if( type == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "Bad Type Passed" );
|
||||
}
|
||||
@Override
|
||||
public boolean isWorldGenEnabled(final WorldGenType type, final World w) {
|
||||
if (type == null) {
|
||||
throw new IllegalArgumentException("Bad Type Passed");
|
||||
}
|
||||
|
||||
if( w == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "Bad Provider Passed" );
|
||||
}
|
||||
if (w == null) {
|
||||
throw new IllegalArgumentException("Bad Provider Passed");
|
||||
}
|
||||
|
||||
ResourceLocation id = w.dimension.getDimension().getType().getRegistryName();
|
||||
final boolean isBadProvider = this.types[type.ordinal()].badProviders.contains( w.dimension.getClass() );
|
||||
final boolean isBadDimension = this.types[type.ordinal()].badDimensions.contains( id );
|
||||
final boolean isGoodDimension = this.types[type.ordinal()].enabledDimensions.contains( id );
|
||||
ResourceLocation id = w.dimension.getDimension().getType().getRegistryName();
|
||||
final boolean isBadProvider = this.types[type.ordinal()].badProviders.contains(w.dimension.getClass());
|
||||
final boolean isBadDimension = this.types[type.ordinal()].badDimensions.contains(id);
|
||||
final boolean isGoodDimension = this.types[type.ordinal()].enabledDimensions.contains(id);
|
||||
|
||||
if( isBadProvider || isBadDimension )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (isBadProvider || isBadDimension) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !isGoodDimension && type == WorldGenType.METEORITES )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!isGoodDimension && type == WorldGenType.METEORITES) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static class TypeSet
|
||||
{
|
||||
private static class TypeSet {
|
||||
|
||||
final HashSet<Class<? extends Dimension>> badProviders = new HashSet<>();
|
||||
final HashSet<ResourceLocation> badDimensions = new HashSet<>();
|
||||
final HashSet<ResourceLocation> enabledDimensions = new HashSet<>();
|
||||
}
|
||||
final HashSet<Class<? extends Dimension>> badProviders = new HashSet<>();
|
||||
final HashSet<ResourceLocation> badDimensions = new HashSet<>();
|
||||
final HashSet<ResourceLocation> enabledDimensions = new HashSet<>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.features.registries.cell;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.storage.ICellHandler;
|
||||
@@ -30,25 +29,21 @@ import appeng.api.storage.data.IAEStack;
|
||||
import appeng.me.storage.BasicCellInventory;
|
||||
import appeng.me.storage.BasicCellInventoryHandler;
|
||||
|
||||
public class BasicCellHandler implements ICellHandler {
|
||||
|
||||
public class BasicCellHandler implements ICellHandler
|
||||
{
|
||||
@Override
|
||||
public boolean isCell(final ItemStack is) {
|
||||
return BasicCellInventory.isCell(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCell( final ItemStack is )
|
||||
{
|
||||
return BasicCellInventory.isCell( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel<T> channel )
|
||||
{
|
||||
final ICellInventory<T> inv = BasicCellInventory.createInventory( is, container );
|
||||
if( inv == null || inv.getChannel() != channel )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new BasicCellInventoryHandler<>( inv, channel );
|
||||
}
|
||||
@Override
|
||||
public <T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory(final ItemStack is,
|
||||
final ISaveProvider container, final IStorageChannel<T> channel) {
|
||||
final ICellInventory<T> inv = BasicCellInventory.createInventory(is, container);
|
||||
if (inv == null || inv.getChannel() != channel) {
|
||||
return null;
|
||||
}
|
||||
return new BasicCellInventoryHandler<>(inv, channel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
|
||||
package appeng.core.features.registries.cell;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerMEMonitorable;
|
||||
import appeng.container.implementations.ContainerWireless;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -19,21 +14,22 @@ import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerMEMonitorable;
|
||||
import appeng.container.implementations.ContainerWireless;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BasicItemCellGuiHandler implements ICellGuiHandler {
|
||||
@Override
|
||||
public <T extends IAEStack<T>> boolean isHandlerFor(final IStorageChannel<T> channel) {
|
||||
return channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
|
||||
}
|
||||
|
||||
public class BasicItemCellGuiHandler implements ICellGuiHandler
|
||||
{
|
||||
@Override
|
||||
public <T extends IAEStack<T>> boolean isHandlerFor( final IStorageChannel<T> channel )
|
||||
{
|
||||
return channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChestGui( final PlayerEntity player, final IChestOrDrive chest, final ICellHandler cellHandler, final IMEInventoryHandler inv, final ItemStack is, final IStorageChannel chan )
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerMEMonitorable.TYPE, player, ContainerLocator.forTileEntitySide((TileEntity) chest, chest.getUp()));
|
||||
}
|
||||
@Override
|
||||
public void openChestGui(final PlayerEntity player, final IChestOrDrive chest, final ICellHandler cellHandler,
|
||||
final IMEInventoryHandler inv, final ItemStack is, final IStorageChannel chan) {
|
||||
ContainerOpener.openContainer(ContainerMEMonitorable.TYPE, player,
|
||||
ContainerLocator.forTileEntitySide((TileEntity) chest, chest.getUp()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.features.registries.cell;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -35,108 +34,88 @@ import appeng.api.storage.ISaveProvider;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
public class CellRegistry implements ICellRegistry {
|
||||
|
||||
public class CellRegistry implements ICellRegistry
|
||||
{
|
||||
private final List<ICellHandler> handlers;
|
||||
private final List<ICellGuiHandler> guiHandlers;
|
||||
|
||||
private final List<ICellHandler> handlers;
|
||||
private final List<ICellGuiHandler> guiHandlers;
|
||||
public CellRegistry() {
|
||||
this.handlers = new ArrayList<>();
|
||||
this.guiHandlers = new ArrayList<>();
|
||||
}
|
||||
|
||||
public CellRegistry()
|
||||
{
|
||||
this.handlers = new ArrayList<>();
|
||||
this.guiHandlers = new ArrayList<>();
|
||||
}
|
||||
@Override
|
||||
public void addCellHandler(final ICellHandler handler) {
|
||||
Preconditions.checkNotNull(handler, "Called before FMLCommonSetupEvent.");
|
||||
Preconditions.checkArgument(!this.handlers.contains(handler),
|
||||
"Tried to register the same handler instance twice.");
|
||||
|
||||
@Override
|
||||
public void addCellHandler( final ICellHandler handler )
|
||||
{
|
||||
Preconditions.checkNotNull( handler, "Called before FMLCommonSetupEvent." );
|
||||
Preconditions.checkArgument( !this.handlers.contains( handler ), "Tried to register the same handler instance twice." );
|
||||
this.handlers.add(handler);
|
||||
|
||||
this.handlers.add( handler );
|
||||
// Verify that the first entry is always our own handler.
|
||||
Verify.verify(this.handlers.get(0) instanceof BasicCellHandler);
|
||||
}
|
||||
|
||||
// Verify that the first entry is always our own handler.
|
||||
Verify.verify( this.handlers.get( 0 ) instanceof BasicCellHandler );
|
||||
}
|
||||
@Override
|
||||
public boolean isCellHandled(final ItemStack is) {
|
||||
if (is.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
for (final ICellHandler ch : this.handlers) {
|
||||
if (ch.isCell(is)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellHandled( final ItemStack is )
|
||||
{
|
||||
if( is.isEmpty() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for( final ICellHandler ch : this.handlers )
|
||||
{
|
||||
if( ch.isCell( is ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public ICellHandler getHandler(final ItemStack is) {
|
||||
if (is.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
for (final ICellHandler ch : this.handlers) {
|
||||
if (ch.isCell(is)) {
|
||||
return ch;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICellHandler getHandler( final ItemStack is )
|
||||
{
|
||||
if( is.isEmpty() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
for( final ICellHandler ch : this.handlers )
|
||||
{
|
||||
if( ch.isCell( is ) )
|
||||
{
|
||||
return ch;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public <T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory(final ItemStack is,
|
||||
final ISaveProvider container, final IStorageChannel<T> chan) {
|
||||
if (is.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
for (final ICellHandler ch : this.handlers) {
|
||||
if (ch.isCell(is)) {
|
||||
return ch.getCellInventory(is, container, chan);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel<T> chan )
|
||||
{
|
||||
if( is.isEmpty() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
for( final ICellHandler ch : this.handlers )
|
||||
{
|
||||
if( ch.isCell( is ) )
|
||||
{
|
||||
return ch.getCellInventory( is, container, chan );
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public void addCellGuiHandler(ICellGuiHandler handler) {
|
||||
this.guiHandlers.add(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCellGuiHandler( ICellGuiHandler handler )
|
||||
{
|
||||
this.guiHandlers.add( handler );
|
||||
}
|
||||
@Override
|
||||
public <T extends IAEStack<T>> ICellGuiHandler getGuiHandler(final IStorageChannel<T> channel, final ItemStack is) {
|
||||
ICellGuiHandler fallBack = null;
|
||||
|
||||
@Override
|
||||
public <T extends IAEStack<T>> ICellGuiHandler getGuiHandler( final IStorageChannel<T> channel, final ItemStack is )
|
||||
{
|
||||
ICellGuiHandler fallBack = null;
|
||||
for (final ICellGuiHandler ch : this.guiHandlers) {
|
||||
if (ch.isHandlerFor(channel)) {
|
||||
if (ch.isSpecializedFor(is)) {
|
||||
return ch;
|
||||
}
|
||||
|
||||
for( final ICellGuiHandler ch : this.guiHandlers )
|
||||
{
|
||||
if( ch.isHandlerFor( channel ) )
|
||||
{
|
||||
if( ch.isSpecializedFor( is ) )
|
||||
{
|
||||
return ch;
|
||||
}
|
||||
|
||||
if( fallBack == null )
|
||||
{
|
||||
fallBack = ch;
|
||||
}
|
||||
}
|
||||
}
|
||||
return fallBack;
|
||||
}
|
||||
if (fallBack == null) {
|
||||
fallBack = ch;
|
||||
}
|
||||
}
|
||||
}
|
||||
return fallBack;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.features.registries.cell;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
@@ -30,36 +29,30 @@ import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.items.storage.ItemCreativeStorageCell;
|
||||
import appeng.me.storage.CreativeCellInventory;
|
||||
|
||||
public final class CreativeCellHandler implements ICellHandler {
|
||||
|
||||
public final class CreativeCellHandler implements ICellHandler
|
||||
{
|
||||
@Override
|
||||
public boolean isCell(final ItemStack is) {
|
||||
return !is.isEmpty() && is.getItem() instanceof ItemCreativeStorageCell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCell( final ItemStack is )
|
||||
{
|
||||
return !is.isEmpty() && is.getItem() instanceof ItemCreativeStorageCell;
|
||||
}
|
||||
@Override
|
||||
public ICellInventoryHandler getCellInventory(final ItemStack is, final ISaveProvider container,
|
||||
final IStorageChannel channel) {
|
||||
if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) && !is.isEmpty()
|
||||
&& is.getItem() instanceof ItemCreativeStorageCell) {
|
||||
return CreativeCellInventory.getCell(is);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICellInventoryHandler getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel channel )
|
||||
{
|
||||
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) && !is.isEmpty() && is
|
||||
.getItem() instanceof ItemCreativeStorageCell )
|
||||
{
|
||||
return CreativeCellInventory.getCell( is );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public int getStatusForCell(final ItemStack is, final ICellInventoryHandler handler) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusForCell( final ItemStack is, final ICellInventoryHandler handler )
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double cellIdleDrain( final ItemStack is, final ICellInventoryHandler handler )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public double cellIdleDrain(final ItemStack is, final ICellInventoryHandler handler) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.features.registries.charger;
|
||||
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -31,45 +30,39 @@ import net.minecraft.item.Item;
|
||||
|
||||
import appeng.api.features.IChargerRegistry;
|
||||
|
||||
public class ChargerRegistry implements IChargerRegistry {
|
||||
private static final double DEFAULT_CHARGE_RATE = 160d;
|
||||
private static final double CAPPED_CHARGE_RATE = 16000d;
|
||||
|
||||
public class ChargerRegistry implements IChargerRegistry
|
||||
{
|
||||
private static final double DEFAULT_CHARGE_RATE = 160d;
|
||||
private static final double CAPPED_CHARGE_RATE = 16000d;
|
||||
private final Map<Item, Double> chargeRates;
|
||||
|
||||
private final Map<Item, Double> chargeRates;
|
||||
public ChargerRegistry() {
|
||||
this.chargeRates = new IdentityHashMap<>();
|
||||
}
|
||||
|
||||
public ChargerRegistry()
|
||||
{
|
||||
this.chargeRates = new IdentityHashMap<>();
|
||||
}
|
||||
@Override
|
||||
@Nonnegative
|
||||
public double getChargeRate(@Nonnull Item item) {
|
||||
Preconditions.checkNotNull(item);
|
||||
|
||||
@Override
|
||||
@Nonnegative
|
||||
public double getChargeRate( @Nonnull Item item )
|
||||
{
|
||||
Preconditions.checkNotNull( item );
|
||||
return this.chargeRates.getOrDefault(item, DEFAULT_CHARGE_RATE);
|
||||
}
|
||||
|
||||
return this.chargeRates.getOrDefault( item, DEFAULT_CHARGE_RATE );
|
||||
}
|
||||
@Override
|
||||
public void addChargeRate(@Nonnull Item item, @Nonnegative double value) {
|
||||
Preconditions.checkNotNull(item);
|
||||
Preconditions.checkArgument(value > 0d);
|
||||
|
||||
@Override
|
||||
public void addChargeRate( @Nonnull Item item, @Nonnegative double value )
|
||||
{
|
||||
Preconditions.checkNotNull( item );
|
||||
Preconditions.checkArgument( value > 0d );
|
||||
final double cappedValue = Math.min(value, CAPPED_CHARGE_RATE);
|
||||
|
||||
final double cappedValue = Math.min( value, CAPPED_CHARGE_RATE );
|
||||
this.chargeRates.put(item, cappedValue);
|
||||
}
|
||||
|
||||
this.chargeRates.put( item, cappedValue );
|
||||
}
|
||||
@Override
|
||||
public void removeChargeRate(@Nonnull Item item) {
|
||||
Preconditions.checkNotNull(item);
|
||||
|
||||
@Override
|
||||
public void removeChargeRate( @Nonnull Item item )
|
||||
{
|
||||
Preconditions.checkNotNull( item );
|
||||
|
||||
this.chargeRates.remove( item );
|
||||
}
|
||||
this.chargeRates.remove(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,161 +18,76 @@
|
||||
|
||||
package appeng.core.localization;
|
||||
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
|
||||
public enum ButtonToolTips {
|
||||
PowerUnits, IOMode, CondenserOutput, RedstoneMode, MatchingFuzzy,
|
||||
|
||||
public enum ButtonToolTips
|
||||
{
|
||||
PowerUnits,
|
||||
IOMode,
|
||||
CondenserOutput,
|
||||
RedstoneMode,
|
||||
MatchingFuzzy,
|
||||
MatchingMode, TransferDirection, SortOrder, SortBy, View,
|
||||
|
||||
MatchingMode,
|
||||
TransferDirection,
|
||||
SortOrder,
|
||||
SortBy,
|
||||
View,
|
||||
PartitionStorage, Clear, FuzzyMode, OperationMode, TrashController,
|
||||
|
||||
PartitionStorage,
|
||||
Clear,
|
||||
FuzzyMode,
|
||||
OperationMode,
|
||||
TrashController,
|
||||
InterfaceBlockingMode, InterfaceCraftingMode, Trash, MatterBalls,
|
||||
|
||||
InterfaceBlockingMode,
|
||||
InterfaceCraftingMode,
|
||||
Trash,
|
||||
MatterBalls,
|
||||
Singularity, Read, Write, ReadWrite, AlwaysActive,
|
||||
|
||||
Singularity,
|
||||
Read,
|
||||
Write,
|
||||
ReadWrite,
|
||||
AlwaysActive,
|
||||
ActiveWithoutSignal, ActiveWithSignal, ActiveOnPulse,
|
||||
|
||||
ActiveWithoutSignal,
|
||||
ActiveWithSignal,
|
||||
ActiveOnPulse,
|
||||
EmitLevelsBelow, EmitLevelAbove, MatchingExact, TransferToNetwork,
|
||||
|
||||
EmitLevelsBelow,
|
||||
EmitLevelAbove,
|
||||
MatchingExact,
|
||||
TransferToNetwork,
|
||||
TransferToStorageCell, ToggleSortDirection,
|
||||
|
||||
TransferToStorageCell,
|
||||
ToggleSortDirection,
|
||||
SearchMode_Auto, SearchMode_Standard, SearchMode_JEIAuto, SearchMode_JEIStandard, SearchMode_AutoKeep,
|
||||
SearchMode_StandardKeep, SearchMode_JEIAutoKeep, SearchMode_JEIStandardKeep,
|
||||
|
||||
SearchMode_Auto,
|
||||
SearchMode_Standard,
|
||||
SearchMode_JEIAuto,
|
||||
SearchMode_JEIStandard,
|
||||
SearchMode_AutoKeep,
|
||||
SearchMode_StandardKeep,
|
||||
SearchMode_JEIAutoKeep,
|
||||
SearchMode_JEIStandardKeep,
|
||||
SearchMode, ItemName, NumberOfItems, PartitionStorageHint,
|
||||
|
||||
SearchMode,
|
||||
ItemName,
|
||||
NumberOfItems,
|
||||
PartitionStorageHint,
|
||||
ClearSettings, StoredItems, StoredCraftable, Craftable,
|
||||
|
||||
ClearSettings,
|
||||
StoredItems,
|
||||
StoredCraftable,
|
||||
Craftable,
|
||||
FZPercent_25, FZPercent_50, FZPercent_75, FZPercent_99, FZIgnoreAll,
|
||||
|
||||
FZPercent_25,
|
||||
FZPercent_50,
|
||||
FZPercent_75,
|
||||
FZPercent_99,
|
||||
FZIgnoreAll,
|
||||
MoveWhenEmpty, MoveWhenWorkIsDone, MoveWhenFull, Disabled, Enable,
|
||||
|
||||
MoveWhenEmpty,
|
||||
MoveWhenWorkIsDone,
|
||||
MoveWhenFull,
|
||||
Disabled,
|
||||
Enable,
|
||||
Blocking, NonBlocking,
|
||||
|
||||
Blocking,
|
||||
NonBlocking,
|
||||
LevelType, LevelType_Energy, LevelType_Item, InventoryTweaks, TerminalStyle, TerminalStyle_Full, TerminalStyle_Tall,
|
||||
TerminalStyle_Small,
|
||||
|
||||
LevelType,
|
||||
LevelType_Energy,
|
||||
LevelType_Item,
|
||||
InventoryTweaks,
|
||||
TerminalStyle,
|
||||
TerminalStyle_Full,
|
||||
TerminalStyle_Tall,
|
||||
TerminalStyle_Small,
|
||||
Stash, StashDesc, Encode, EncodeDescription, Substitutions, SubstitutionsOn, SubstitutionsOff,
|
||||
SubstitutionsDescEnabled, SubstitutionsDescDisabled, CraftOnly, CraftEither,
|
||||
|
||||
Stash,
|
||||
StashDesc,
|
||||
Encode,
|
||||
EncodeDescription,
|
||||
Substitutions,
|
||||
SubstitutionsOn,
|
||||
SubstitutionsOff,
|
||||
SubstitutionsDescEnabled,
|
||||
SubstitutionsDescDisabled,
|
||||
CraftOnly,
|
||||
CraftEither,
|
||||
Craft, Mod, DoesntDespawn, EmitterMode, CraftViaRedstone, EmitWhenCrafting, ReportInaccessibleItems,
|
||||
ReportInaccessibleItemsYes, ReportInaccessibleItemsNo, ReportInaccessibleFluids, ReportInaccessibleFluidsYes,
|
||||
ReportInaccessibleFluidsNo,
|
||||
|
||||
Craft,
|
||||
Mod,
|
||||
DoesntDespawn,
|
||||
EmitterMode,
|
||||
CraftViaRedstone,
|
||||
EmitWhenCrafting,
|
||||
ReportInaccessibleItems,
|
||||
ReportInaccessibleItemsYes,
|
||||
ReportInaccessibleItemsNo,
|
||||
ReportInaccessibleFluids,
|
||||
ReportInaccessibleFluidsYes,
|
||||
ReportInaccessibleFluidsNo,
|
||||
BlockPlacement, BlockPlacementYes, BlockPlacementNo,
|
||||
|
||||
BlockPlacement,
|
||||
BlockPlacementYes,
|
||||
BlockPlacementNo,
|
||||
// Used in the tooltips of the items in the terminal, when moused over
|
||||
ItemsStored, ItemsRequestable,
|
||||
|
||||
// Used in the tooltips of the items in the terminal, when moused over
|
||||
ItemsStored,
|
||||
ItemsRequestable,
|
||||
SchedulingMode, SchedulingModeDefault, SchedulingModeRoundRobin, SchedulingModeRandom,
|
||||
|
||||
SchedulingMode,
|
||||
SchedulingModeDefault,
|
||||
SchedulingModeRoundRobin,
|
||||
SchedulingModeRandom,
|
||||
FilterMode, FilterModeKeep, FilterModeClear;
|
||||
|
||||
FilterMode,
|
||||
FilterModeKeep,
|
||||
FilterModeClear;
|
||||
private final String root;
|
||||
|
||||
private final String root;
|
||||
ButtonToolTips() {
|
||||
this.root = "gui.tooltips.appliedenergistics2";
|
||||
}
|
||||
|
||||
ButtonToolTips()
|
||||
{
|
||||
this.root = "gui.tooltips.appliedenergistics2";
|
||||
}
|
||||
ButtonToolTips(final String r) {
|
||||
this.root = r;
|
||||
}
|
||||
|
||||
ButtonToolTips( final String r )
|
||||
{
|
||||
this.root = r;
|
||||
}
|
||||
@Deprecated
|
||||
public String getLocal() {
|
||||
return getTranslationKey().getFormattedText();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getLocal()
|
||||
{
|
||||
return getTranslationKey().getFormattedText();
|
||||
}
|
||||
|
||||
public ITextComponent getTranslationKey()
|
||||
{
|
||||
return new TranslationTextComponent( this.root + '.' + this.toString() );
|
||||
}
|
||||
public ITextComponent getTranslationKey() {
|
||||
return new TranslationTextComponent(this.root + '.' + this.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,207 +18,96 @@
|
||||
|
||||
package appeng.core.localization;
|
||||
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
|
||||
public enum GuiText {
|
||||
inventory("container"), // mc's default Inventory localization.
|
||||
|
||||
public enum GuiText
|
||||
{
|
||||
inventory( "container" ), // mc's default Inventory localization.
|
||||
Chest, StoredEnergy, Of, Condenser, Drive, GrindStone, SkyChest,
|
||||
|
||||
Chest,
|
||||
StoredEnergy,
|
||||
Of,
|
||||
Condenser,
|
||||
Drive,
|
||||
GrindStone,
|
||||
SkyChest,
|
||||
VibrationChamber, SpatialIOPort, LevelEmitter, FluidLevelEmitter, Terminal,
|
||||
|
||||
VibrationChamber,
|
||||
SpatialIOPort,
|
||||
LevelEmitter,
|
||||
FluidLevelEmitter,
|
||||
Terminal,
|
||||
Interface, FluidInterface, Config, StoredItems, StoredFluids, Patterns, ImportBus, ImportBusFluids, ExportBus,
|
||||
ExportBusFluids,
|
||||
|
||||
Interface,
|
||||
FluidInterface,
|
||||
Config,
|
||||
StoredItems,
|
||||
StoredFluids,
|
||||
Patterns,
|
||||
ImportBus,
|
||||
ImportBusFluids,
|
||||
ExportBus,
|
||||
ExportBusFluids,
|
||||
CellWorkbench, NetworkDetails, StorageCells, IOBuses, IOBusesFluids,
|
||||
|
||||
CellWorkbench,
|
||||
NetworkDetails,
|
||||
StorageCells,
|
||||
IOBuses,
|
||||
IOBusesFluids,
|
||||
IOPort, BytesUsed, Types, QuantumLinkChamber, PortableCell,
|
||||
|
||||
IOPort,
|
||||
BytesUsed,
|
||||
Types,
|
||||
QuantumLinkChamber,
|
||||
PortableCell,
|
||||
NetworkTool, PowerUsageRate, PowerInputRate, Installed, EnergyDrain,
|
||||
|
||||
NetworkTool,
|
||||
PowerUsageRate,
|
||||
PowerInputRate,
|
||||
Installed,
|
||||
EnergyDrain,
|
||||
StorageBus, StorageBusFluids, Priority, Security, Encoded, Blank, Unlinked, Linked,
|
||||
|
||||
StorageBus,
|
||||
StorageBusFluids,
|
||||
Priority,
|
||||
Security,
|
||||
Encoded,
|
||||
Blank,
|
||||
Unlinked,
|
||||
Linked,
|
||||
SecurityCardEditor, NoPermissions, WirelessTerminal, Wireless,
|
||||
|
||||
SecurityCardEditor,
|
||||
NoPermissions,
|
||||
WirelessTerminal,
|
||||
Wireless,
|
||||
CraftingTerminal, FormationPlane, FluidFormationPlane, Inscriber, QuartzCuttingKnife,
|
||||
|
||||
CraftingTerminal,
|
||||
FormationPlane,
|
||||
FluidFormationPlane,
|
||||
Inscriber,
|
||||
QuartzCuttingKnife,
|
||||
// spatial
|
||||
SpatialCapacity, StoredSize, Unformatted, SerialNumber,
|
||||
|
||||
// spatial
|
||||
SpatialCapacity,
|
||||
StoredSize,
|
||||
Unformatted,
|
||||
SerialNumber,
|
||||
CopyMode, CopyModeDesc, PatternTerminal,
|
||||
|
||||
CopyMode,
|
||||
CopyModeDesc,
|
||||
PatternTerminal,
|
||||
// Pattern tooltips
|
||||
CraftingPattern, ProcessingPattern, Crafts, Creates, And, With, Substitute, Yes, No,
|
||||
|
||||
// Pattern tooltips
|
||||
CraftingPattern,
|
||||
ProcessingPattern,
|
||||
Crafts,
|
||||
Creates,
|
||||
And,
|
||||
With,
|
||||
Substitute,
|
||||
Yes,
|
||||
No,
|
||||
MolecularAssembler,
|
||||
|
||||
MolecularAssembler,
|
||||
StoredPower, MaxPower, RequiredPower, Efficiency, SCSSize, SCSInvalid, InWorldCrafting,
|
||||
|
||||
StoredPower,
|
||||
MaxPower,
|
||||
RequiredPower,
|
||||
Efficiency,
|
||||
SCSSize,
|
||||
SCSInvalid,
|
||||
InWorldCrafting,
|
||||
inWorldFluix, inWorldPurificationCertus, inWorldPurificationNether,
|
||||
|
||||
inWorldFluix,
|
||||
inWorldPurificationCertus,
|
||||
inWorldPurificationNether,
|
||||
inWorldPurificationFluix, inWorldSingularity, ChargedQuartz,
|
||||
|
||||
inWorldPurificationFluix,
|
||||
inWorldSingularity,
|
||||
ChargedQuartz,
|
||||
NoSecondOutput, OfSecondOutput, MultipleOutputs,
|
||||
|
||||
NoSecondOutput,
|
||||
OfSecondOutput,
|
||||
MultipleOutputs,
|
||||
Stores, Next, SelectAmount, Lumen, Empty,
|
||||
|
||||
Stores,
|
||||
Next,
|
||||
SelectAmount,
|
||||
Lumen,
|
||||
Empty,
|
||||
ConfirmCrafting, Stored, Crafting, Scheduled, CraftingStatus, Cancel, ETA, ETAFormat,
|
||||
|
||||
ConfirmCrafting,
|
||||
Stored,
|
||||
Crafting,
|
||||
Scheduled,
|
||||
CraftingStatus,
|
||||
Cancel,
|
||||
ETA,
|
||||
ETAFormat,
|
||||
FromStorage, ToCraft, CraftingPlan, CalculatingWait, Start, Bytes,
|
||||
|
||||
FromStorage,
|
||||
ToCraft,
|
||||
CraftingPlan,
|
||||
CalculatingWait,
|
||||
Start,
|
||||
Bytes,
|
||||
CraftingCPU, Automatic, CoProcessors, Simulation, Missing,
|
||||
|
||||
CraftingCPU,
|
||||
Automatic,
|
||||
CoProcessors,
|
||||
Simulation,
|
||||
Missing,
|
||||
InterfaceTerminal, NoCraftingCPUs, Clean, InvalidPattern,
|
||||
|
||||
InterfaceTerminal,
|
||||
NoCraftingCPUs,
|
||||
Clean,
|
||||
InvalidPattern,
|
||||
InterfaceTerminalHint, Range, TransparentFacades, TransparentFacadesHint,
|
||||
|
||||
InterfaceTerminalHint,
|
||||
Range,
|
||||
TransparentFacades,
|
||||
TransparentFacadesHint,
|
||||
NoCraftingJobs, CPUs, FacadeCrafting, inWorldCraftingPresses, ChargedQuartzFind,
|
||||
|
||||
NoCraftingJobs,
|
||||
CPUs,
|
||||
FacadeCrafting,
|
||||
inWorldCraftingPresses,
|
||||
ChargedQuartzFind,
|
||||
Included, Excluded, Partitioned, Precise, Fuzzy,
|
||||
|
||||
Included,
|
||||
Excluded,
|
||||
Partitioned,
|
||||
Precise,
|
||||
Fuzzy,
|
||||
// Used in a terminal to indicate that an item is craftable
|
||||
SmallFontCraft, LargeFontCraft,
|
||||
|
||||
// Used in a terminal to indicate that an item is craftable
|
||||
SmallFontCraft,
|
||||
LargeFontCraft,
|
||||
// Used in a ME Interface when no appropriate TileEntity was detected near it
|
||||
Nothing;
|
||||
|
||||
// Used in a ME Interface when no appropriate TileEntity was detected near it
|
||||
Nothing;
|
||||
private final String root;
|
||||
|
||||
private final String root;
|
||||
GuiText() {
|
||||
this.root = "gui.appliedenergistics2";
|
||||
}
|
||||
|
||||
GuiText()
|
||||
{
|
||||
this.root = "gui.appliedenergistics2";
|
||||
}
|
||||
GuiText(final String r) {
|
||||
this.root = r;
|
||||
}
|
||||
|
||||
GuiText( final String r )
|
||||
{
|
||||
this.root = r;
|
||||
}
|
||||
public String getLocal() {
|
||||
return I18n.format(this.getTranslationKey());
|
||||
}
|
||||
|
||||
public String getLocal()
|
||||
{
|
||||
return I18n.format( this.getTranslationKey() );
|
||||
}
|
||||
public String getTranslationKey() {
|
||||
return this.root + '.' + this.toString();
|
||||
}
|
||||
|
||||
public String getTranslationKey()
|
||||
{
|
||||
return this.root + '.' + this.toString();
|
||||
}
|
||||
public ITextComponent textComponent() {
|
||||
return new TranslationTextComponent(getTranslationKey());
|
||||
}
|
||||
|
||||
public ITextComponent textComponent() {
|
||||
return new TranslationTextComponent(getTranslationKey());
|
||||
}
|
||||
|
||||
public ITextComponent textComponent(Object... args) {
|
||||
return new TranslationTextComponent(getTranslationKey(), args);
|
||||
}
|
||||
public ITextComponent textComponent(Object... args) {
|
||||
return new TranslationTextComponent(getTranslationKey(), args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,39 +18,21 @@
|
||||
|
||||
package appeng.core.localization;
|
||||
|
||||
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
|
||||
public enum PlayerMessages {
|
||||
ChestCannotReadStorageCell, InvalidMachine, LoadedSettings, SavedSettings, ResetSettings, MachineNotPowered,
|
||||
|
||||
public enum PlayerMessages
|
||||
{
|
||||
ChestCannotReadStorageCell,
|
||||
InvalidMachine,
|
||||
LoadedSettings,
|
||||
SavedSettings,
|
||||
ResetSettings,
|
||||
MachineNotPowered,
|
||||
isNowLocked, isNowUnlocked, AmmoDepleted, CommunicationError, OutOfRange, DeviceNotPowered,
|
||||
DeviceNotWirelessTerminal, DeviceNotLinked, StationCanNotBeLocated, SettingCleared,;
|
||||
|
||||
isNowLocked,
|
||||
isNowUnlocked,
|
||||
AmmoDepleted,
|
||||
CommunicationError,
|
||||
OutOfRange,
|
||||
DeviceNotPowered,
|
||||
DeviceNotWirelessTerminal,
|
||||
DeviceNotLinked,
|
||||
StationCanNotBeLocated,
|
||||
SettingCleared,;
|
||||
public ITextComponent get() {
|
||||
return new TranslationTextComponent(this.getTranslationKey());
|
||||
}
|
||||
|
||||
public ITextComponent get()
|
||||
{
|
||||
return new TranslationTextComponent( this.getTranslationKey() );
|
||||
}
|
||||
|
||||
String getTranslationKey()
|
||||
{
|
||||
return "chat.appliedenergistics2." + this.toString();
|
||||
}
|
||||
String getTranslationKey() {
|
||||
return "chat.appliedenergistics2." + this.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,62 +18,45 @@
|
||||
|
||||
package appeng.core.localization;
|
||||
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
|
||||
public enum WailaText {
|
||||
Crafting,
|
||||
|
||||
public enum WailaText
|
||||
{
|
||||
Crafting,
|
||||
DeviceOnline, DeviceOffline, DeviceMissingChannel,
|
||||
|
||||
DeviceOnline,
|
||||
DeviceOffline,
|
||||
DeviceMissingChannel,
|
||||
P2PUnlinked, P2PInputOneOutput, P2PInputManyOutputs, P2POutput,
|
||||
|
||||
P2PUnlinked,
|
||||
P2PInputOneOutput,
|
||||
P2PInputManyOutputs,
|
||||
P2POutput,
|
||||
Locked, Unlocked, Showing,
|
||||
|
||||
Locked,
|
||||
Unlocked,
|
||||
Showing,
|
||||
Contains, Channels;
|
||||
|
||||
Contains,
|
||||
Channels;
|
||||
private final String root;
|
||||
|
||||
private final String root;
|
||||
WailaText() {
|
||||
this.root = "waila.appliedenergistics2";
|
||||
}
|
||||
|
||||
WailaText()
|
||||
{
|
||||
this.root = "waila.appliedenergistics2";
|
||||
}
|
||||
WailaText(final String r) {
|
||||
this.root = r;
|
||||
}
|
||||
|
||||
WailaText( final String r )
|
||||
{
|
||||
this.root = r;
|
||||
}
|
||||
public String getLocal() {
|
||||
return I18n.format(this.getTranslationKey());
|
||||
}
|
||||
|
||||
public String getLocal()
|
||||
{
|
||||
return I18n.format( this.getTranslationKey() );
|
||||
}
|
||||
public String getTranslationKey() {
|
||||
return this.root + '.' + this.toString();
|
||||
}
|
||||
|
||||
public String getTranslationKey()
|
||||
{
|
||||
return this.root + '.' + this.toString();
|
||||
}
|
||||
public ITextComponent textComponent() {
|
||||
return new TranslationTextComponent(this.root + '.' + this.toString());
|
||||
}
|
||||
|
||||
public ITextComponent textComponent()
|
||||
{
|
||||
return new TranslationTextComponent(this.root + '.' + this.toString());
|
||||
}
|
||||
|
||||
public ITextComponent textComponent(Object... args)
|
||||
{
|
||||
return new TranslationTextComponent(this.root + '.' + this.toString(), args);
|
||||
}
|
||||
public ITextComponent textComponent(Object... args) {
|
||||
return new TranslationTextComponent(this.root + '.' + this.toString(), args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,82 +18,76 @@
|
||||
|
||||
package appeng.core.settings;
|
||||
|
||||
public enum TickRates
|
||||
{
|
||||
public enum TickRates {
|
||||
|
||||
Interface( 5, 120 ),
|
||||
Interface(5, 120),
|
||||
|
||||
ImportBus( 5, 40 ),
|
||||
ImportBus(5, 40),
|
||||
|
||||
FluidImportBus( 5, 40 ),
|
||||
FluidImportBus(5, 40),
|
||||
|
||||
ExportBus( 5, 60 ),
|
||||
ExportBus(5, 60),
|
||||
|
||||
FluidExportBus( 5, 60 ),
|
||||
FluidExportBus(5, 60),
|
||||
|
||||
AnnihilationPlane( 2, 120 ),
|
||||
AnnihilationPlane(2, 120),
|
||||
|
||||
METunnel( 5, 20 ),
|
||||
METunnel(5, 20),
|
||||
|
||||
Inscriber( 1, 1 ),
|
||||
Inscriber(1, 1),
|
||||
|
||||
Charger( 10, 120 ),
|
||||
Charger(10, 120),
|
||||
|
||||
IOPort( 1, 5 ),
|
||||
IOPort(1, 5),
|
||||
|
||||
VibrationChamber( 10, 40 ),
|
||||
VibrationChamber(10, 40),
|
||||
|
||||
StorageBus( 5, 60 ),
|
||||
StorageBus(5, 60),
|
||||
|
||||
FluidStorageBus( 5, 60 ),
|
||||
FluidStorageBus(5, 60),
|
||||
|
||||
ItemTunnel( 5, 60 ),
|
||||
ItemTunnel(5, 60),
|
||||
|
||||
LightTunnel( 5, 60 ),
|
||||
LightTunnel(5, 60),
|
||||
|
||||
OpenComputersTunnel( 1, 5 ),
|
||||
OpenComputersTunnel(1, 5),
|
||||
|
||||
PressureTunnel( 1, 120 );
|
||||
PressureTunnel(1, 120);
|
||||
|
||||
private final int defaultMin;
|
||||
private final int defaultMax;
|
||||
private int min;
|
||||
private int max;
|
||||
private final int defaultMin;
|
||||
private final int defaultMax;
|
||||
private int min;
|
||||
private int max;
|
||||
|
||||
TickRates( final int min, final int max )
|
||||
{
|
||||
this.defaultMin = min;
|
||||
this.defaultMax = max;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
TickRates(final int min, final int max) {
|
||||
this.defaultMin = min;
|
||||
this.defaultMax = max;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public int getDefaultMin() {
|
||||
return defaultMin;
|
||||
}
|
||||
public int getDefaultMin() {
|
||||
return defaultMin;
|
||||
}
|
||||
|
||||
public int getDefaultMax() {
|
||||
return defaultMax;
|
||||
}
|
||||
public int getDefaultMax() {
|
||||
return defaultMax;
|
||||
}
|
||||
|
||||
public int getMax()
|
||||
{
|
||||
return this.max;
|
||||
}
|
||||
public int getMax() {
|
||||
return this.max;
|
||||
}
|
||||
|
||||
public void setMax( final int max )
|
||||
{
|
||||
this.max = max;
|
||||
}
|
||||
public void setMax(final int max) {
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public int getMin()
|
||||
{
|
||||
return this.min;
|
||||
}
|
||||
public int getMin() {
|
||||
return this.min;
|
||||
}
|
||||
|
||||
public void setMin( final int min )
|
||||
{
|
||||
this.min = min;
|
||||
}
|
||||
public void setMin(final int min) {
|
||||
this.min = min;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,42 +18,34 @@
|
||||
|
||||
package appeng.core.stats;
|
||||
|
||||
|
||||
import appeng.bootstrap.ICriterionTriggerRegistry;
|
||||
|
||||
public class AdvancementTriggers {
|
||||
private AppEngAdvancementTrigger networkApprentice = new AppEngAdvancementTrigger("network_apprentice");
|
||||
private AppEngAdvancementTrigger networkEngineer = new AppEngAdvancementTrigger("network_engineer");
|
||||
private AppEngAdvancementTrigger networkAdmin = new AppEngAdvancementTrigger("network_admin");
|
||||
private AppEngAdvancementTrigger spatialExplorer = new AppEngAdvancementTrigger("spatial_explorer");
|
||||
|
||||
public class AdvancementTriggers
|
||||
{
|
||||
private AppEngAdvancementTrigger networkApprentice = new AppEngAdvancementTrigger( "network_apprentice" );
|
||||
private AppEngAdvancementTrigger networkEngineer = new AppEngAdvancementTrigger( "network_engineer" );
|
||||
private AppEngAdvancementTrigger networkAdmin = new AppEngAdvancementTrigger( "network_admin" );
|
||||
private AppEngAdvancementTrigger spatialExplorer = new AppEngAdvancementTrigger( "spatial_explorer" );
|
||||
public AdvancementTriggers(ICriterionTriggerRegistry registry) {
|
||||
registry.register(this.networkApprentice);
|
||||
registry.register(this.networkEngineer);
|
||||
registry.register(this.networkAdmin);
|
||||
registry.register(this.spatialExplorer);
|
||||
}
|
||||
|
||||
public AdvancementTriggers( ICriterionTriggerRegistry registry )
|
||||
{
|
||||
registry.register( this.networkApprentice );
|
||||
registry.register( this.networkEngineer );
|
||||
registry.register( this.networkAdmin );
|
||||
registry.register( this.spatialExplorer );
|
||||
}
|
||||
public IAdvancementTrigger getNetworkApprentice() {
|
||||
return this.networkApprentice;
|
||||
}
|
||||
|
||||
public IAdvancementTrigger getNetworkApprentice()
|
||||
{
|
||||
return this.networkApprentice;
|
||||
}
|
||||
public IAdvancementTrigger getNetworkEngineer() {
|
||||
return this.networkEngineer;
|
||||
}
|
||||
|
||||
public IAdvancementTrigger getNetworkEngineer()
|
||||
{
|
||||
return this.networkEngineer;
|
||||
}
|
||||
public IAdvancementTrigger getNetworkAdmin() {
|
||||
return this.networkAdmin;
|
||||
}
|
||||
|
||||
public IAdvancementTrigger getNetworkAdmin()
|
||||
{
|
||||
return this.networkAdmin;
|
||||
}
|
||||
|
||||
public IAdvancementTrigger getSpatialExplorer()
|
||||
{
|
||||
return this.spatialExplorer;
|
||||
}
|
||||
public IAdvancementTrigger getSpatialExplorer() {
|
||||
return this.spatialExplorer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,49 +18,46 @@
|
||||
|
||||
package appeng.core.stats;
|
||||
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.stats.IStatFormatter;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public enum AeStats
|
||||
{
|
||||
public enum AeStats {
|
||||
|
||||
// done
|
||||
ItemsInserted("items_inserted"),
|
||||
// done
|
||||
ItemsInserted("items_inserted"),
|
||||
|
||||
// done
|
||||
ItemsExtracted("items_extracted"),
|
||||
// done
|
||||
ItemsExtracted("items_extracted"),
|
||||
|
||||
// done
|
||||
TurnedCranks("turned_cranks");
|
||||
// done
|
||||
TurnedCranks("turned_cranks");
|
||||
|
||||
private final ResourceLocation registryName;
|
||||
private final ResourceLocation registryName;
|
||||
|
||||
AeStats(String id) {
|
||||
this.registryName = new ResourceLocation(AppEng.MOD_ID, id);
|
||||
}
|
||||
AeStats(String id) {
|
||||
this.registryName = new ResourceLocation(AppEng.MOD_ID, id);
|
||||
}
|
||||
|
||||
public void addToPlayer(final PlayerEntity player, final int howMany )
|
||||
{
|
||||
player.addStat( this.registryName, howMany );
|
||||
}
|
||||
public void addToPlayer(final PlayerEntity player, final int howMany) {
|
||||
player.addStat(this.registryName, howMany);
|
||||
}
|
||||
|
||||
public ResourceLocation getRegistryName() {
|
||||
return registryName;
|
||||
}
|
||||
public ResourceLocation getRegistryName() {
|
||||
return registryName;
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
for (AeStats stat : AeStats.values()) {
|
||||
// Compare with net.minecraft.stats.Stats#registerCustom
|
||||
ResourceLocation registryName = stat.getRegistryName();
|
||||
Registry.register(Registry.CUSTOM_STAT, registryName.getPath(), registryName);
|
||||
Stats.CUSTOM.get(registryName, IStatFormatter.DEFAULT);
|
||||
}
|
||||
}
|
||||
public static void register() {
|
||||
for (AeStats stat : AeStats.values()) {
|
||||
// Compare with net.minecraft.stats.Stats#registerCustom
|
||||
ResourceLocation registryName = stat.getRegistryName();
|
||||
Registry.register(Registry.CUSTOM_STAT, registryName.getPath(), registryName);
|
||||
Stats.CUSTOM.get(registryName, IStatFormatter.DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.stats;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -38,139 +37,115 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public class AppEngAdvancementTrigger
|
||||
implements ICriterionTrigger<AppEngAdvancementTrigger.Instance>, IAdvancementTrigger {
|
||||
private final ResourceLocation ID;
|
||||
private final Map<PlayerAdvancements, AppEngAdvancementTrigger.Listeners> listeners = new HashMap<>();
|
||||
|
||||
public class AppEngAdvancementTrigger implements ICriterionTrigger<AppEngAdvancementTrigger.Instance>, IAdvancementTrigger
|
||||
{
|
||||
private final ResourceLocation ID;
|
||||
private final Map<PlayerAdvancements, AppEngAdvancementTrigger.Listeners> listeners = new HashMap<>();
|
||||
public AppEngAdvancementTrigger(String parString) {
|
||||
super();
|
||||
this.ID = new ResourceLocation(AppEng.MOD_ID, parString);
|
||||
}
|
||||
|
||||
public AppEngAdvancementTrigger( String parString )
|
||||
{
|
||||
super();
|
||||
this.ID = new ResourceLocation( AppEng.MOD_ID, parString );
|
||||
}
|
||||
@Override
|
||||
public ResourceLocation getId() {
|
||||
return this.ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getId()
|
||||
{
|
||||
return this.ID;
|
||||
}
|
||||
@Override
|
||||
public void addListener(PlayerAdvancements playerAdvancementsIn,
|
||||
ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance> listener) {
|
||||
AppEngAdvancementTrigger.Listeners l = this.listeners.get(playerAdvancementsIn);
|
||||
|
||||
@Override
|
||||
public void addListener( PlayerAdvancements playerAdvancementsIn, ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance> listener )
|
||||
{
|
||||
AppEngAdvancementTrigger.Listeners l = this.listeners.get( playerAdvancementsIn );
|
||||
if (l == null) {
|
||||
l = new AppEngAdvancementTrigger.Listeners(playerAdvancementsIn);
|
||||
this.listeners.put(playerAdvancementsIn, l);
|
||||
}
|
||||
|
||||
if( l == null )
|
||||
{
|
||||
l = new AppEngAdvancementTrigger.Listeners( playerAdvancementsIn );
|
||||
this.listeners.put( playerAdvancementsIn, l );
|
||||
}
|
||||
l.add(listener);
|
||||
}
|
||||
|
||||
l.add( listener );
|
||||
}
|
||||
@Override
|
||||
public void removeListener(PlayerAdvancements playerAdvancementsIn,
|
||||
ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance> listener) {
|
||||
AppEngAdvancementTrigger.Listeners l = this.listeners.get(playerAdvancementsIn);
|
||||
|
||||
@Override
|
||||
public void removeListener( PlayerAdvancements playerAdvancementsIn, ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance> listener )
|
||||
{
|
||||
AppEngAdvancementTrigger.Listeners l = this.listeners.get( playerAdvancementsIn );
|
||||
if (l != null) {
|
||||
l.remove(listener);
|
||||
|
||||
if( l != null )
|
||||
{
|
||||
l.remove( listener );
|
||||
if (l.isEmpty()) {
|
||||
this.listeners.remove(playerAdvancementsIn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( l.isEmpty() )
|
||||
{
|
||||
this.listeners.remove( playerAdvancementsIn );
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void removeAllListeners(PlayerAdvancements playerAdvancementsIn) {
|
||||
this.listeners.remove(playerAdvancementsIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAllListeners( PlayerAdvancements playerAdvancementsIn )
|
||||
{
|
||||
this.listeners.remove( playerAdvancementsIn );
|
||||
}
|
||||
@Override
|
||||
public AppEngAdvancementTrigger.Instance deserializeInstance(JsonObject json, JsonDeserializationContext context) {
|
||||
return new AppEngAdvancementTrigger.Instance(this.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppEngAdvancementTrigger.Instance deserializeInstance( JsonObject json, JsonDeserializationContext context )
|
||||
{
|
||||
return new AppEngAdvancementTrigger.Instance( this.getId() );
|
||||
}
|
||||
@Override
|
||||
public void trigger(ServerPlayerEntity parPlayer) {
|
||||
AppEngAdvancementTrigger.Listeners l = this.listeners.get(parPlayer.getAdvancements());
|
||||
|
||||
@Override
|
||||
public void trigger( ServerPlayerEntity parPlayer )
|
||||
{
|
||||
AppEngAdvancementTrigger.Listeners l = this.listeners.get( parPlayer.getAdvancements() );
|
||||
if (l != null) {
|
||||
l.trigger(parPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
if( l != null )
|
||||
{
|
||||
l.trigger( parPlayer );
|
||||
}
|
||||
}
|
||||
public static class Instance extends CriterionInstance {
|
||||
public Instance(ResourceLocation parID) {
|
||||
super(parID);
|
||||
}
|
||||
|
||||
public static class Instance extends CriterionInstance
|
||||
{
|
||||
public Instance( ResourceLocation parID )
|
||||
{
|
||||
super( parID );
|
||||
}
|
||||
public boolean test() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean test()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
static class Listeners {
|
||||
private final PlayerAdvancements playerAdvancements;
|
||||
private final Set<ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance>> listeners = new HashSet<>();
|
||||
|
||||
static class Listeners
|
||||
{
|
||||
private final PlayerAdvancements playerAdvancements;
|
||||
private final Set<ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance>> listeners = new HashSet<>();
|
||||
Listeners(PlayerAdvancements playerAdvancementsIn) {
|
||||
this.playerAdvancements = playerAdvancementsIn;
|
||||
}
|
||||
|
||||
Listeners( PlayerAdvancements playerAdvancementsIn )
|
||||
{
|
||||
this.playerAdvancements = playerAdvancementsIn;
|
||||
}
|
||||
public boolean isEmpty() {
|
||||
return this.listeners.isEmpty();
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return this.listeners.isEmpty();
|
||||
}
|
||||
public void add(ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance> listener) {
|
||||
this.listeners.add(listener);
|
||||
}
|
||||
|
||||
public void add( ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance> listener )
|
||||
{
|
||||
this.listeners.add( listener );
|
||||
}
|
||||
public void remove(ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance> listener) {
|
||||
this.listeners.remove(listener);
|
||||
}
|
||||
|
||||
public void remove( ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance> listener )
|
||||
{
|
||||
this.listeners.remove( listener );
|
||||
}
|
||||
public void trigger(PlayerEntity player) {
|
||||
List<ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance>> list = null;
|
||||
|
||||
public void trigger( PlayerEntity player )
|
||||
{
|
||||
List<ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance>> list = null;
|
||||
for (ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance> listener : this.listeners) {
|
||||
if (listener.getCriterionInstance().test()) {
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
|
||||
for( ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance> listener : this.listeners )
|
||||
{
|
||||
if( listener.getCriterionInstance().test() )
|
||||
{
|
||||
if( list == null )
|
||||
{
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
list.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
list.add( listener );
|
||||
}
|
||||
}
|
||||
|
||||
if( list != null )
|
||||
{
|
||||
for( ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance> l : list )
|
||||
{
|
||||
l.grantCriterion( this.playerAdvancements );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (list != null) {
|
||||
for (ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance> l : list) {
|
||||
l.grantCriterion(this.playerAdvancements);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,13 +18,10 @@
|
||||
|
||||
package appeng.core.stats;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IAdvancementTrigger
|
||||
{
|
||||
void trigger( ServerPlayerEntity parPlayer );
|
||||
public interface IAdvancementTrigger {
|
||||
void trigger(ServerPlayerEntity parPlayer);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.stats;
|
||||
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.advancements.criterion.ItemPredicate;
|
||||
@@ -30,41 +29,31 @@ import appeng.core.AppEng;
|
||||
import appeng.items.parts.ItemPart;
|
||||
import appeng.items.parts.PartType;
|
||||
|
||||
public class PartItemPredicate extends ItemPredicate {
|
||||
private final PartType partType;
|
||||
|
||||
public class PartItemPredicate extends ItemPredicate
|
||||
{
|
||||
private final PartType partType;
|
||||
public PartItemPredicate(String partName) {
|
||||
this.partType = PartType.valueOf(partName.toUpperCase());
|
||||
}
|
||||
|
||||
public PartItemPredicate( String partName )
|
||||
{
|
||||
this.partType = PartType.valueOf( partName.toUpperCase() );
|
||||
}
|
||||
@Override
|
||||
public boolean test(ItemStack item) {
|
||||
if (item.getItem() instanceof ItemPart) {
|
||||
ItemPart<?> itemPart = (ItemPart<?>) item.getItem();
|
||||
return itemPart.getType() == partType;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test( ItemStack item )
|
||||
{
|
||||
if( item.getItem() instanceof ItemPart )
|
||||
{
|
||||
ItemPart<?> itemPart = (ItemPart<?>) item.getItem();
|
||||
return itemPart.getType() == partType;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static ItemPredicate deserialize(JsonObject jsonobject) {
|
||||
if (jsonobject.has("part")) {
|
||||
return new PartItemPredicate(JSONUtils.getString(jsonobject, "part"));
|
||||
} else {
|
||||
return ItemPredicate.ANY;
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemPredicate deserialize( JsonObject jsonobject )
|
||||
{
|
||||
if( jsonobject.has( "part" ) )
|
||||
{
|
||||
return new PartItemPredicate( JSONUtils.getString( jsonobject, "part" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return ItemPredicate.ANY;
|
||||
}
|
||||
}
|
||||
|
||||
public static void register()
|
||||
{
|
||||
ItemPredicate.register( new ResourceLocation( AppEng.MOD_ID, "part" ), PartItemPredicate::deserialize );
|
||||
}
|
||||
public static void register() {
|
||||
ItemPredicate.register(new ResourceLocation(AppEng.MOD_ID, "part"), PartItemPredicate::deserialize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,57 +18,52 @@
|
||||
|
||||
package appeng.core.sync;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.network.NetworkDirection;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
|
||||
public abstract class AppEngPacket {
|
||||
private PacketBuffer p;
|
||||
|
||||
public abstract class AppEngPacket
|
||||
{
|
||||
private PacketBuffer p;
|
||||
public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) {
|
||||
throw new UnsupportedOperationException(
|
||||
"This packet ( " + this.getPacketID() + " does not implement a server side handler.");
|
||||
}
|
||||
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
throw new UnsupportedOperationException( "This packet ( " + this.getPacketID() + " does not implement a server side handler." );
|
||||
}
|
||||
public final int getPacketID() {
|
||||
return AppEngPacketHandlerBase.PacketTypes.getID(this.getClass()).ordinal();
|
||||
}
|
||||
|
||||
public final int getPacketID()
|
||||
{
|
||||
return AppEngPacketHandlerBase.PacketTypes.getID( this.getClass() ).ordinal();
|
||||
}
|
||||
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
|
||||
throw new UnsupportedOperationException(
|
||||
"This packet ( " + this.getPacketID() + " does not implement a client side handler.");
|
||||
}
|
||||
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
throw new UnsupportedOperationException( "This packet ( " + this.getPacketID() + " does not implement a client side handler." );
|
||||
}
|
||||
protected void configureWrite(final PacketBuffer data) {
|
||||
data.capacity(data.readableBytes());
|
||||
this.p = data;
|
||||
}
|
||||
|
||||
protected void configureWrite( final PacketBuffer data )
|
||||
{
|
||||
data.capacity( data.readableBytes() );
|
||||
this.p = data;
|
||||
}
|
||||
public IPacket<?> toPacket(NetworkDirection direction) {
|
||||
if (this.p.array().length > 2 * 1024 * 1024) // 2k walking room :)
|
||||
{
|
||||
throw new IllegalArgumentException(
|
||||
"Sorry AE2 made a " + this.p.array().length + " byte packet by accident!");
|
||||
}
|
||||
|
||||
public IPacket<?> toPacket( NetworkDirection direction )
|
||||
{
|
||||
if( this.p.array().length > 2 * 1024 * 1024 ) // 2k walking room :)
|
||||
{
|
||||
throw new IllegalArgumentException( "Sorry AE2 made a " + this.p.array().length + " byte packet by accident!" );
|
||||
}
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.PACKET_LOGGING)) {
|
||||
AELog.info(this.getClass().getName() + " : " + p.readableBytes());
|
||||
}
|
||||
|
||||
if( AEConfig.instance().isFeatureEnabled( AEFeature.PACKET_LOGGING ) )
|
||||
{
|
||||
AELog.info( this.getClass().getName() + " : " + p.readableBytes() );
|
||||
}
|
||||
|
||||
return direction.buildPacket( Pair.of( p, 0 ), NetworkHandler.instance().getChannel() ).getThis();
|
||||
}
|
||||
return direction.buildPacket(Pair.of(p, 0), NetworkHandler.instance().getChannel()).getThis();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync;
|
||||
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -53,86 +52,78 @@ import appeng.core.sync.packets.PacketTargetItemStack;
|
||||
import appeng.core.sync.packets.PacketTransitionEffect;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
|
||||
public class AppEngPacketHandlerBase {
|
||||
private static final Map<Class<? extends AppEngPacket>, PacketTypes> REVERSE_LOOKUP = new HashMap<>();
|
||||
|
||||
public class AppEngPacketHandlerBase
|
||||
{
|
||||
private static final Map<Class<? extends AppEngPacket>, PacketTypes> REVERSE_LOOKUP = new HashMap<>();
|
||||
public enum PacketTypes {
|
||||
PACKET_COMPASS_REQUEST(PacketCompassRequest.class, PacketCompassRequest::new),
|
||||
|
||||
PACKET_COMPASS_RESPONSE(PacketCompassResponse.class, PacketCompassResponse::new),
|
||||
|
||||
public enum PacketTypes
|
||||
{
|
||||
PACKET_COMPASS_REQUEST( PacketCompassRequest.class, PacketCompassRequest::new ),
|
||||
PACKET_INVENTORY_ACTION(PacketInventoryAction.class, PacketInventoryAction::new),
|
||||
|
||||
PACKET_COMPASS_RESPONSE( PacketCompassResponse.class, PacketCompassResponse::new ),
|
||||
PACKET_ME_INVENTORY_UPDATE(PacketMEInventoryUpdate.class, PacketMEInventoryUpdate::new),
|
||||
|
||||
PACKET_INVENTORY_ACTION( PacketInventoryAction.class, PacketInventoryAction::new ),
|
||||
PACKET_ME_FLUID_INVENTORY_UPDATE(PacketMEFluidInventoryUpdate.class, PacketMEFluidInventoryUpdate::new),
|
||||
|
||||
PACKET_ME_INVENTORY_UPDATE( PacketMEInventoryUpdate.class, PacketMEInventoryUpdate::new ),
|
||||
PACKET_CONFIG_BUTTON(PacketConfigButton.class, PacketConfigButton::new),
|
||||
|
||||
PACKET_ME_FLUID_INVENTORY_UPDATE( PacketMEFluidInventoryUpdate.class, PacketMEFluidInventoryUpdate::new ),
|
||||
PACKET_PART_PLACEMENT(PacketPartPlacement.class, PacketPartPlacement::new),
|
||||
|
||||
PACKET_CONFIG_BUTTON( PacketConfigButton.class, PacketConfigButton::new ),
|
||||
PACKET_LIGHTNING(PacketLightning.class, PacketLightning::new),
|
||||
|
||||
PACKET_PART_PLACEMENT( PacketPartPlacement.class, PacketPartPlacement::new ),
|
||||
PACKET_MATTER_CANNON(PacketMatterCannon.class, PacketMatterCannon::new),
|
||||
|
||||
PACKET_LIGHTNING( PacketLightning.class, PacketLightning::new ),
|
||||
PACKET_MOCK_EXPLOSION(PacketMockExplosion.class, PacketMockExplosion::new),
|
||||
|
||||
PACKET_MATTER_CANNON( PacketMatterCannon.class, PacketMatterCannon::new ),
|
||||
PACKET_VALUE_CONFIG(PacketValueConfig.class, PacketValueConfig::new),
|
||||
|
||||
PACKET_MOCK_EXPLOSION( PacketMockExplosion.class, PacketMockExplosion::new ),
|
||||
PACKET_TRANSITION_EFFECT(PacketTransitionEffect.class, PacketTransitionEffect::new),
|
||||
|
||||
PACKET_VALUE_CONFIG( PacketValueConfig.class, PacketValueConfig::new ),
|
||||
PACKET_PROGRESS_VALUE(PacketProgressBar.class, PacketProgressBar::new),
|
||||
|
||||
PACKET_TRANSITION_EFFECT( PacketTransitionEffect.class, PacketTransitionEffect::new ),
|
||||
PACKET_CLICK(PacketClick.class, PacketClick::new),
|
||||
|
||||
PACKET_PROGRESS_VALUE( PacketProgressBar.class, PacketProgressBar::new ),
|
||||
PACKET_SWITCH_GUIS(PacketSwitchGuis.class, PacketSwitchGuis::new),
|
||||
|
||||
PACKET_CLICK( PacketClick.class, PacketClick::new ),
|
||||
PACKET_SWAP_SLOTS(PacketSwapSlots.class, PacketSwapSlots::new),
|
||||
|
||||
PACKET_SWITCH_GUIS( PacketSwitchGuis.class, PacketSwitchGuis::new ),
|
||||
PACKET_PATTERN_SLOT(PacketPatternSlot.class, PacketPatternSlot::new),
|
||||
|
||||
PACKET_SWAP_SLOTS( PacketSwapSlots.class, PacketSwapSlots::new ),
|
||||
PACKET_RECIPE_JEI(PacketJEIRecipe.class, PacketJEIRecipe::new),
|
||||
|
||||
PACKET_PATTERN_SLOT( PacketPatternSlot.class, PacketPatternSlot::new ),
|
||||
PACKET_TARGET_ITEM(PacketTargetItemStack.class, PacketTargetItemStack::new),
|
||||
|
||||
PACKET_RECIPE_JEI( PacketJEIRecipe.class, PacketJEIRecipe::new ),
|
||||
PACKET_TARGET_FLUID(PacketTargetFluidStack.class, PacketTargetFluidStack::new),
|
||||
|
||||
PACKET_TARGET_ITEM( PacketTargetItemStack.class, PacketTargetItemStack::new ),
|
||||
PACKET_CRAFTING_REQUEST(PacketCraftRequest.class, PacketCraftRequest::new),
|
||||
|
||||
PACKET_TARGET_FLUID( PacketTargetFluidStack.class, PacketTargetFluidStack::new ),
|
||||
PACKET_ASSEMBLER_ANIMATION(PacketAssemblerAnimation.class, PacketAssemblerAnimation::new),
|
||||
|
||||
PACKET_CRAFTING_REQUEST( PacketCraftRequest.class, PacketCraftRequest::new ),
|
||||
PACKET_COMPRESSED_NBT(PacketCompressedNBT.class, PacketCompressedNBT::new),
|
||||
|
||||
PACKET_ASSEMBLER_ANIMATION( PacketAssemblerAnimation.class, PacketAssemblerAnimation::new ),
|
||||
PACKET_PAINTED_ENTITY(PacketPaintedEntity.class, PacketPaintedEntity::new),
|
||||
|
||||
PACKET_COMPRESSED_NBT( PacketCompressedNBT.class, PacketCompressedNBT::new ),
|
||||
PACKET_FLUID_TANK(PacketFluidSlot.class, PacketFluidSlot::new);
|
||||
|
||||
PACKET_PAINTED_ENTITY( PacketPaintedEntity.class, PacketPaintedEntity::new ),
|
||||
private final Function<PacketBuffer, AppEngPacket> factory;
|
||||
|
||||
PACKET_FLUID_TANK( PacketFluidSlot.class, PacketFluidSlot::new );
|
||||
PacketTypes(Class<? extends AppEngPacket> packetClass, Function<PacketBuffer, AppEngPacket> factory) {
|
||||
this.factory = factory;
|
||||
|
||||
private final Function<PacketBuffer, AppEngPacket> factory;
|
||||
REVERSE_LOOKUP.put(packetClass, this);
|
||||
}
|
||||
|
||||
PacketTypes( Class<? extends AppEngPacket> packetClass, Function<PacketBuffer, AppEngPacket> factory )
|
||||
{
|
||||
this.factory = factory;
|
||||
public static PacketTypes getPacket(final int id) {
|
||||
return (values())[id];
|
||||
}
|
||||
|
||||
REVERSE_LOOKUP.put(packetClass, this );
|
||||
}
|
||||
static PacketTypes getID(final Class<? extends AppEngPacket> c) {
|
||||
return REVERSE_LOOKUP.get(c);
|
||||
}
|
||||
|
||||
public static PacketTypes getPacket( final int id )
|
||||
{
|
||||
return ( values() )[id];
|
||||
}
|
||||
|
||||
static PacketTypes getID( final Class<? extends AppEngPacket> c )
|
||||
{
|
||||
return REVERSE_LOOKUP.get( c );
|
||||
}
|
||||
|
||||
public AppEngPacket parsePacket( final PacketBuffer in ) throws IllegalArgumentException
|
||||
{
|
||||
return this.factory.apply( in );
|
||||
}
|
||||
}
|
||||
public AppEngPacket parsePacket(final PacketBuffer in) throws IllegalArgumentException {
|
||||
return this.factory.apply(in);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync;
|
||||
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -48,8 +47,8 @@ import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.container.implementations.ContainerCellWorkbench;
|
||||
import appeng.container.implementations.ContainerChest;
|
||||
import appeng.container.implementations.ContainerCondenser;
|
||||
@@ -121,420 +120,368 @@ import appeng.tile.storage.TileIOPort;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public enum GuiBridge {
|
||||
GUI_Handler(),
|
||||
|
||||
public enum GuiBridge
|
||||
{
|
||||
GUI_Handler(),
|
||||
GUI_GRINDER(ContainerGrinder.class, TileGrinder.class, GuiHostType.WORLD, null),
|
||||
|
||||
GUI_GRINDER( ContainerGrinder.class, TileGrinder.class, GuiHostType.WORLD, null ),
|
||||
GUI_QNB(ContainerQNB.class, TileQuantumBridge.class, GuiHostType.WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_QNB( ContainerQNB.class, TileQuantumBridge.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
GUI_SKYCHEST(ContainerSkyChest.class, TileSkyChest.class, GuiHostType.WORLD, null),
|
||||
|
||||
GUI_SKYCHEST( ContainerSkyChest.class, TileSkyChest.class, GuiHostType.WORLD, null ),
|
||||
GUI_CHEST(ContainerChest.class, TileChest.class, GuiHostType.WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_CHEST( ContainerChest.class, TileChest.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
GUI_WIRELESS(ContainerWireless.class, TileWireless.class, GuiHostType.WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_WIRELESS( ContainerWireless.class, TileWireless.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
GUI_ME(ContainerMEMonitorable.class, ITerminalHost.class, GuiHostType.WORLD, null),
|
||||
|
||||
GUI_ME( ContainerMEMonitorable.class, ITerminalHost.class, GuiHostType.WORLD, null ),
|
||||
GUI_PORTABLE_CELL(ContainerMEPortableCell.class, IPortableCell.class, GuiHostType.ITEM, null),
|
||||
|
||||
GUI_PORTABLE_CELL( ContainerMEPortableCell.class, IPortableCell.class, GuiHostType.ITEM, null ),
|
||||
GUI_WIRELESS_TERM(ContainerWirelessTerm.class, WirelessTerminalGuiObject.class, GuiHostType.ITEM, null),
|
||||
|
||||
GUI_WIRELESS_TERM( ContainerWirelessTerm.class, WirelessTerminalGuiObject.class, GuiHostType.ITEM, null ),
|
||||
GUI_NETWORK_STATUS(ContainerNetworkStatus.class, INetworkTool.class, GuiHostType.ITEM, null),
|
||||
|
||||
GUI_NETWORK_STATUS( ContainerNetworkStatus.class, INetworkTool.class, GuiHostType.ITEM, null ),
|
||||
GUI_CRAFTING_CPU(ContainerCraftingCPU.class, TileCraftingTile.class, GuiHostType.WORLD, SecurityPermissions.CRAFT),
|
||||
|
||||
GUI_CRAFTING_CPU( ContainerCraftingCPU.class, TileCraftingTile.class, GuiHostType.WORLD, SecurityPermissions.CRAFT ),
|
||||
GUI_NETWORK_TOOL(ContainerNetworkTool.class, INetworkTool.class, GuiHostType.ITEM, null),
|
||||
|
||||
GUI_NETWORK_TOOL( ContainerNetworkTool.class, INetworkTool.class, GuiHostType.ITEM, null ),
|
||||
GUI_QUARTZ_KNIFE(ContainerQuartzKnife.class, QuartzKnifeObj.class, GuiHostType.ITEM, null),
|
||||
|
||||
GUI_QUARTZ_KNIFE( ContainerQuartzKnife.class, QuartzKnifeObj.class, GuiHostType.ITEM, null ),
|
||||
GUI_DRIVE(ContainerDrive.class, TileDrive.class, GuiHostType.WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_DRIVE( ContainerDrive.class, TileDrive.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
GUI_VIBRATION_CHAMBER(ContainerVibrationChamber.class, TileVibrationChamber.class, GuiHostType.WORLD, null),
|
||||
|
||||
GUI_VIBRATION_CHAMBER( ContainerVibrationChamber.class, TileVibrationChamber.class, GuiHostType.WORLD, null ),
|
||||
GUI_CONDENSER(ContainerCondenser.class, TileCondenser.class, GuiHostType.WORLD, null),
|
||||
|
||||
GUI_CONDENSER( ContainerCondenser.class, TileCondenser.class, GuiHostType.WORLD, null ),
|
||||
GUI_INTERFACE(ContainerInterface.class, IInterfaceHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_INTERFACE( ContainerInterface.class, IInterfaceHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
GUI_FLUID_INTERFACE(ContainerFluidInterface.class, IFluidInterfaceHost.class, GuiHostType.WORLD,
|
||||
SecurityPermissions.BUILD),
|
||||
|
||||
GUI_FLUID_INTERFACE( ContainerFluidInterface.class, IFluidInterfaceHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
GUI_BUS(ContainerUpgradeable.class, IUpgradeableHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_BUS( ContainerUpgradeable.class, IUpgradeableHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
GUI_BUS_FLUID(ContainerFluidIO.class, PartSharedFluidBus.class, GuiHostType.WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_BUS_FLUID( ContainerFluidIO.class, PartSharedFluidBus.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
GUI_IOPORT(ContainerIOPort.class, TileIOPort.class, GuiHostType.WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_IOPORT( ContainerIOPort.class, TileIOPort.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
GUI_STORAGEBUS(ContainerStorageBus.class, PartStorageBus.class, GuiHostType.WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_STORAGEBUS( ContainerStorageBus.class, PartStorageBus.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
GUI_STORAGEBUS_FLUID(ContainerFluidStorageBus.class, PartFluidStorageBus.class, GuiHostType.WORLD,
|
||||
SecurityPermissions.BUILD),
|
||||
|
||||
GUI_STORAGEBUS_FLUID( ContainerFluidStorageBus.class, PartFluidStorageBus.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
GUI_FORMATION_PLANE(ContainerFormationPlane.class, PartFormationPlane.class, GuiHostType.WORLD,
|
||||
SecurityPermissions.BUILD),
|
||||
|
||||
GUI_FORMATION_PLANE( ContainerFormationPlane.class, PartFormationPlane.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
GUI_FLUID_FORMATION_PLANE(ContainerFluidFormationPlane.class, PartFluidFormationPlane.class, GuiHostType.WORLD,
|
||||
SecurityPermissions.BUILD),
|
||||
|
||||
GUI_FLUID_FORMATION_PLANE( ContainerFluidFormationPlane.class, PartFluidFormationPlane.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
GUI_PRIORITY(ContainerPriority.class, IPriorityHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_PRIORITY( ContainerPriority.class, IPriorityHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
GUI_SECURITY(ContainerSecurityStation.class, TileSecurityStation.class, GuiHostType.WORLD,
|
||||
SecurityPermissions.SECURITY),
|
||||
|
||||
GUI_SECURITY( ContainerSecurityStation.class, TileSecurityStation.class, GuiHostType.WORLD, SecurityPermissions.SECURITY ),
|
||||
GUI_CRAFTING_TERMINAL(ContainerCraftingTerm.class, PartCraftingTerminal.class, GuiHostType.WORLD,
|
||||
SecurityPermissions.CRAFT),
|
||||
|
||||
GUI_CRAFTING_TERMINAL( ContainerCraftingTerm.class, PartCraftingTerminal.class, GuiHostType.WORLD, SecurityPermissions.CRAFT ),
|
||||
GUI_PATTERN_TERMINAL(ContainerPatternTerm.class, PartPatternTerminal.class, GuiHostType.WORLD,
|
||||
SecurityPermissions.CRAFT),
|
||||
|
||||
GUI_PATTERN_TERMINAL( ContainerPatternTerm.class, PartPatternTerminal.class, GuiHostType.WORLD, SecurityPermissions.CRAFT ),
|
||||
GUI_FLUID_TERMINAL(ContainerFluidTerminal.class, ITerminalHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_FLUID_TERMINAL( ContainerFluidTerminal.class, ITerminalHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
// extends (Container/Gui) + Bus
|
||||
GUI_LEVEL_EMITTER(ContainerLevelEmitter.class, PartLevelEmitter.class, GuiHostType.WORLD,
|
||||
SecurityPermissions.BUILD),
|
||||
|
||||
// extends (Container/Gui) + Bus
|
||||
GUI_LEVEL_EMITTER( ContainerLevelEmitter.class, PartLevelEmitter.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
GUI_FLUID_LEVEL_EMITTER(ContainerFluidLevelEmitter.class, PartFluidLevelEmitter.class, GuiHostType.WORLD,
|
||||
SecurityPermissions.BUILD),
|
||||
|
||||
GUI_FLUID_LEVEL_EMITTER( ContainerFluidLevelEmitter.class, PartFluidLevelEmitter.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
GUI_SPATIAL_IO_PORT(ContainerSpatialIOPort.class, TileSpatialIOPort.class, GuiHostType.WORLD,
|
||||
SecurityPermissions.BUILD),
|
||||
|
||||
GUI_SPATIAL_IO_PORT( ContainerSpatialIOPort.class, TileSpatialIOPort.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
GUI_INSCRIBER(ContainerInscriber.class, TileInscriber.class, GuiHostType.WORLD, null),
|
||||
|
||||
GUI_INSCRIBER( ContainerInscriber.class, TileInscriber.class, GuiHostType.WORLD, null ),
|
||||
GUI_CELL_WORKBENCH(ContainerCellWorkbench.class, TileCellWorkbench.class, GuiHostType.WORLD, null),
|
||||
|
||||
GUI_CELL_WORKBENCH( ContainerCellWorkbench.class, TileCellWorkbench.class, GuiHostType.WORLD, null ),
|
||||
GUI_MAC(ContainerMAC.class, TileMolecularAssembler.class, GuiHostType.WORLD, null),
|
||||
|
||||
GUI_MAC( ContainerMAC.class, TileMolecularAssembler.class, GuiHostType.WORLD, null ),
|
||||
GUI_CRAFTING_AMOUNT(ContainerCraftAmount.class, ITerminalHost.class, GuiHostType.ITEM_OR_WORLD,
|
||||
SecurityPermissions.CRAFT),
|
||||
|
||||
GUI_CRAFTING_AMOUNT( ContainerCraftAmount.class, ITerminalHost.class, GuiHostType.ITEM_OR_WORLD, SecurityPermissions.CRAFT ),
|
||||
GUI_CRAFTING_CONFIRM(ContainerCraftConfirm.class, ITerminalHost.class, GuiHostType.ITEM_OR_WORLD,
|
||||
SecurityPermissions.CRAFT),
|
||||
|
||||
GUI_CRAFTING_CONFIRM( ContainerCraftConfirm.class, ITerminalHost.class, GuiHostType.ITEM_OR_WORLD, SecurityPermissions.CRAFT ),
|
||||
GUI_INTERFACE_TERMINAL(ContainerInterfaceTerminal.class, PartInterfaceTerminal.class, GuiHostType.WORLD,
|
||||
SecurityPermissions.BUILD),
|
||||
|
||||
GUI_INTERFACE_TERMINAL( ContainerInterfaceTerminal.class, PartInterfaceTerminal.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
GUI_CRAFTING_STATUS(ContainerCraftingStatus.class, ITerminalHost.class, GuiHostType.ITEM_OR_WORLD,
|
||||
SecurityPermissions.CRAFT);
|
||||
|
||||
GUI_CRAFTING_STATUS( ContainerCraftingStatus.class, ITerminalHost.class, GuiHostType.ITEM_OR_WORLD, SecurityPermissions.CRAFT );
|
||||
private final Class tileClass;
|
||||
private final Class containerClass;
|
||||
private Class guiClass;
|
||||
private GuiHostType type;
|
||||
private SecurityPermissions requiredPermission;
|
||||
|
||||
private final Class tileClass;
|
||||
private final Class containerClass;
|
||||
private Class guiClass;
|
||||
private GuiHostType type;
|
||||
private SecurityPermissions requiredPermission;
|
||||
GuiBridge() {
|
||||
this.tileClass = null;
|
||||
this.guiClass = null;
|
||||
this.containerClass = null;
|
||||
}
|
||||
|
||||
GuiBridge()
|
||||
{
|
||||
this.tileClass = null;
|
||||
this.guiClass = null;
|
||||
this.containerClass = null;
|
||||
}
|
||||
|
||||
GuiBridge( final Class containerClass, final SecurityPermissions requiredPermission )
|
||||
{
|
||||
this.requiredPermission = requiredPermission;
|
||||
this.containerClass = containerClass;
|
||||
this.tileClass = null;
|
||||
this.getGui();
|
||||
}
|
||||
|
||||
/**
|
||||
* I honestly wish I could just use the GuiClass Names myself, but I can't access them without MC's Server
|
||||
* Exploding.
|
||||
*/
|
||||
private void getGui()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
AEBaseGui.class.getName();
|
||||
|
||||
final String start = this.containerClass.getName();
|
||||
final String guiClass = start.replaceFirst( "container.", "client.gui." ).replace( ".Container", ".Gui" );
|
||||
|
||||
if( start.equals( guiClass ) )
|
||||
{
|
||||
throw new IllegalStateException( "Unable to find gui class" );
|
||||
}
|
||||
this.guiClass = null; // FIXME ReflectionHelper.getClass( this.getClass().getClassLoader(), guiClass );
|
||||
if( this.guiClass == null )
|
||||
{
|
||||
throw new IllegalStateException( "Cannot Load class: " + guiClass );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GuiBridge( final Class containerClass, final Class tileClass, final GuiHostType type, final SecurityPermissions requiredPermission )
|
||||
{
|
||||
this.requiredPermission = requiredPermission;
|
||||
this.containerClass = containerClass;
|
||||
this.type = type;
|
||||
this.tileClass = tileClass;
|
||||
this.getGui();
|
||||
}
|
||||
|
||||
public Object getServerGuiElement( final int ordinal, final PlayerEntity player, final World w, final int x, final int y, final int z )
|
||||
{
|
||||
final AEPartLocation side = AEPartLocation.fromOrdinal( ordinal & 0x07 );
|
||||
final GuiBridge ID = values()[ordinal >> 4];
|
||||
final boolean stem = ( ( ordinal >> 3 ) & 1 ) == 1;
|
||||
if( ID.type.isItem() )
|
||||
{
|
||||
ItemStack it = ItemStack.EMPTY;
|
||||
if( stem )
|
||||
{
|
||||
it = player.inventory.getCurrentItem();
|
||||
}
|
||||
else if( x >= 0 && x < player.inventory.mainInventory.size() )
|
||||
{
|
||||
it = player.inventory.getStackInSlot( x );
|
||||
}
|
||||
final Object myItem = this.getGuiObject( it, player, w, x, y, z );
|
||||
if( myItem != null && ID.CorrectTileOrPart( myItem ) )
|
||||
{
|
||||
return this.updateGui( ID.ConstructContainer( player.inventory, side, myItem ), w, x, y, z, side, myItem );
|
||||
}
|
||||
}
|
||||
if( ID.type.isTile() )
|
||||
{
|
||||
final TileEntity TE = w.getTileEntity( new BlockPos( x, y, z ) );
|
||||
if( TE instanceof IPartHost )
|
||||
{
|
||||
( (IPartHost) TE ).getPart( side );
|
||||
final IPart part = ( (IPartHost) TE ).getPart( side );
|
||||
if( ID.CorrectTileOrPart( part ) )
|
||||
{
|
||||
return this.updateGui( ID.ConstructContainer( player.inventory, side, part ), w, x, y, z, side, part );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ID.CorrectTileOrPart( TE ) )
|
||||
{
|
||||
return this.updateGui( ID.ConstructContainer( player.inventory, side, TE ), w, x, y, z, side, TE );
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ContainerNull();
|
||||
}
|
||||
|
||||
private Object getGuiObject( final ItemStack it, final PlayerEntity player, final World w, final int x, final int y, final int z )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean CorrectTileOrPart( final Object tE )
|
||||
{
|
||||
if( this.tileClass == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "This Gui Cannot use the standard Handler." );
|
||||
}
|
||||
|
||||
return this.tileClass.isInstance( tE );
|
||||
}
|
||||
|
||||
private Object updateGui( final Object newContainer, final World w, final int x, final int y, final int z, final AEPartLocation side, final Object myItem )
|
||||
{
|
||||
if( newContainer instanceof AEBaseContainer )
|
||||
{
|
||||
// FIXME final AEBaseContainer bc = (AEBaseContainer) newContainer;
|
||||
// FIXME bc.setLocator( new ContainerLocator( myItem ) );
|
||||
// FIXME bc.getLocator().setWorld( w );
|
||||
// FIXME bc.getLocator().setX( x );
|
||||
// FIXME bc.getLocator().setY( y );
|
||||
// FIXME bc.getLocator().setZ( z );
|
||||
// FIXME bc.getLocator().setSide( side );
|
||||
}
|
||||
|
||||
return newContainer;
|
||||
}
|
||||
|
||||
public Object ConstructContainer( final PlayerInventory inventory, final AEPartLocation side, final Object tE )
|
||||
{
|
||||
try
|
||||
{
|
||||
final Constructor[] c = this.containerClass.getConstructors();
|
||||
if( c.length == 0 )
|
||||
{
|
||||
throw new AppEngException( "Invalid Gui Class" );
|
||||
}
|
||||
|
||||
final Constructor target = this.findConstructor( c, inventory, tE );
|
||||
|
||||
if( target == null )
|
||||
{
|
||||
throw new IllegalStateException( "Cannot find " + this.containerClass.getName() + "( " + this.typeName( inventory ) + ", " + this
|
||||
.typeName( tE ) + " )" );
|
||||
}
|
||||
|
||||
return target.newInstance( inventory, tE );
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
throw new IllegalStateException( t );
|
||||
}
|
||||
}
|
||||
|
||||
private Constructor findConstructor( final Constructor[] c, final PlayerInventory inventory, final Object tE )
|
||||
{
|
||||
for( final Constructor con : c )
|
||||
{
|
||||
final Class[] types = con.getParameterTypes();
|
||||
if( types.length == 2 )
|
||||
{
|
||||
if( types[0].isAssignableFrom( inventory.getClass() ) && types[1].isAssignableFrom( tE.getClass() ) )
|
||||
{
|
||||
return con;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String typeName( final Object inventory )
|
||||
{
|
||||
if( inventory == null )
|
||||
{
|
||||
return "NULL";
|
||||
}
|
||||
|
||||
return inventory.getClass().getName();
|
||||
}
|
||||
|
||||
public Object getClientGuiElement( final int ordinal, final PlayerEntity player, final World w, final int x, final int y, final int z )
|
||||
{
|
||||
final AEPartLocation side = AEPartLocation.fromOrdinal( ordinal & 0x07 );
|
||||
final GuiBridge ID = values()[ordinal >> 4];
|
||||
final boolean stem = ( ( ordinal >> 3 ) & 1 ) == 1;
|
||||
if( ID.type.isItem() )
|
||||
{
|
||||
ItemStack it = ItemStack.EMPTY;
|
||||
if( stem )
|
||||
{
|
||||
it = player.inventory.getCurrentItem();
|
||||
}
|
||||
else if( x >= 0 && x < player.inventory.mainInventory.size() )
|
||||
{
|
||||
it = player.inventory.getStackInSlot( x );
|
||||
}
|
||||
final Object myItem = this.getGuiObject( it, player, w, x, y, z );
|
||||
if( myItem != null && ID.CorrectTileOrPart( myItem ) )
|
||||
{
|
||||
return ID.ConstructGui( player.inventory, side, myItem );
|
||||
}
|
||||
}
|
||||
if( ID.type.isTile() )
|
||||
{
|
||||
final TileEntity TE = w.getTileEntity( new BlockPos( x, y, z ) );
|
||||
if( TE instanceof IPartHost )
|
||||
{
|
||||
( (IPartHost) TE ).getPart( side );
|
||||
final IPart part = ( (IPartHost) TE ).getPart( side );
|
||||
if( ID.CorrectTileOrPart( part ) )
|
||||
{
|
||||
return ID.ConstructGui( player.inventory, side, part );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ID.CorrectTileOrPart( TE ) )
|
||||
{
|
||||
return ID.ConstructGui( player.inventory, side, TE );
|
||||
}
|
||||
}
|
||||
}
|
||||
return null; // FIXME
|
||||
}
|
||||
|
||||
public Object ConstructGui( final PlayerInventory inventory, final AEPartLocation side, final Object tE )
|
||||
{
|
||||
try
|
||||
{
|
||||
final Constructor[] c = this.guiClass.getConstructors();
|
||||
if( c.length == 0 )
|
||||
{
|
||||
throw new AppEngException( "Invalid Gui Class" );
|
||||
}
|
||||
|
||||
final Constructor target = this.findConstructor( c, inventory, tE );
|
||||
|
||||
if( target == null )
|
||||
{
|
||||
throw new IllegalStateException( "Cannot find " + this.containerClass.getName() + "( " + this.typeName( inventory ) + ", " + this
|
||||
.typeName( tE ) + " )" );
|
||||
}
|
||||
|
||||
return target.newInstance( inventory, tE );
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
throw new IllegalStateException( t );
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasPermissions( final TileEntity te, final int x, final int y, final int z, final AEPartLocation side, final PlayerEntity player )
|
||||
{
|
||||
final World w = player.getEntityWorld();
|
||||
final BlockPos pos = new BlockPos( x, y, z );
|
||||
|
||||
if( Platform.hasPermissions( te != null ? new DimensionalCoord( te ) : new DimensionalCoord( player.world, pos ), player ) )
|
||||
{
|
||||
if( this.type.isItem() )
|
||||
{
|
||||
final ItemStack it = player.inventory.getCurrentItem();
|
||||
if( !it.isEmpty() && it.getItem() instanceof IGuiItem )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if( this.type.isTile() )
|
||||
{
|
||||
final TileEntity TE = w.getTileEntity( pos );
|
||||
if( TE instanceof IPartHost )
|
||||
{
|
||||
( (IPartHost) TE ).getPart( side );
|
||||
final IPart part = ( (IPartHost) TE ).getPart( side );
|
||||
if( this.CorrectTileOrPart( part ) )
|
||||
{
|
||||
return this.securityCheck( part, player );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( this.CorrectTileOrPart( TE ) )
|
||||
{
|
||||
return this.securityCheck( TE, player );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean securityCheck( final Object te, final PlayerEntity player )
|
||||
{
|
||||
if( te instanceof IActionHost && this.requiredPermission != null )
|
||||
{
|
||||
|
||||
final IGridNode gn = ( (IActionHost) te ).getActionableNode();
|
||||
if( gn != null )
|
||||
{
|
||||
final IGrid g = gn.getGrid();
|
||||
if( g != null )
|
||||
{
|
||||
final boolean requirePower = false;
|
||||
if( requirePower )
|
||||
{
|
||||
final IEnergyGrid eg = g.getCache( IEnergyGrid.class );
|
||||
if( !eg.isNetworkPowered() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final ISecurityGrid sg = g.getCache( ISecurityGrid.class );
|
||||
if( sg.hasPermission( player, this.requiredPermission ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public GuiHostType getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
GuiBridge(final Class containerClass, final SecurityPermissions requiredPermission) {
|
||||
this.requiredPermission = requiredPermission;
|
||||
this.containerClass = containerClass;
|
||||
this.tileClass = null;
|
||||
this.getGui();
|
||||
}
|
||||
|
||||
/**
|
||||
* I honestly wish I could just use the GuiClass Names myself, but I can't
|
||||
* access them without MC's Server Exploding.
|
||||
*/
|
||||
private void getGui() {
|
||||
if (Platform.isClient()) {
|
||||
AEBaseGui.class.getName();
|
||||
|
||||
final String start = this.containerClass.getName();
|
||||
final String guiClass = start.replaceFirst("container.", "client.gui.").replace(".Container", ".Gui");
|
||||
|
||||
if (start.equals(guiClass)) {
|
||||
throw new IllegalStateException("Unable to find gui class");
|
||||
}
|
||||
this.guiClass = null; // FIXME ReflectionHelper.getClass( this.getClass().getClassLoader(), guiClass
|
||||
// );
|
||||
if (this.guiClass == null) {
|
||||
throw new IllegalStateException("Cannot Load class: " + guiClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GuiBridge(final Class containerClass, final Class tileClass, final GuiHostType type,
|
||||
final SecurityPermissions requiredPermission) {
|
||||
this.requiredPermission = requiredPermission;
|
||||
this.containerClass = containerClass;
|
||||
this.type = type;
|
||||
this.tileClass = tileClass;
|
||||
this.getGui();
|
||||
}
|
||||
|
||||
public Object getServerGuiElement(final int ordinal, final PlayerEntity player, final World w, final int x,
|
||||
final int y, final int z) {
|
||||
final AEPartLocation side = AEPartLocation.fromOrdinal(ordinal & 0x07);
|
||||
final GuiBridge ID = values()[ordinal >> 4];
|
||||
final boolean stem = ((ordinal >> 3) & 1) == 1;
|
||||
if (ID.type.isItem()) {
|
||||
ItemStack it = ItemStack.EMPTY;
|
||||
if (stem) {
|
||||
it = player.inventory.getCurrentItem();
|
||||
} else if (x >= 0 && x < player.inventory.mainInventory.size()) {
|
||||
it = player.inventory.getStackInSlot(x);
|
||||
}
|
||||
final Object myItem = this.getGuiObject(it, player, w, x, y, z);
|
||||
if (myItem != null && ID.CorrectTileOrPart(myItem)) {
|
||||
return this.updateGui(ID.ConstructContainer(player.inventory, side, myItem), w, x, y, z, side, myItem);
|
||||
}
|
||||
}
|
||||
if (ID.type.isTile()) {
|
||||
final TileEntity TE = w.getTileEntity(new BlockPos(x, y, z));
|
||||
if (TE instanceof IPartHost) {
|
||||
((IPartHost) TE).getPart(side);
|
||||
final IPart part = ((IPartHost) TE).getPart(side);
|
||||
if (ID.CorrectTileOrPart(part)) {
|
||||
return this.updateGui(ID.ConstructContainer(player.inventory, side, part), w, x, y, z, side, part);
|
||||
}
|
||||
} else {
|
||||
if (ID.CorrectTileOrPart(TE)) {
|
||||
return this.updateGui(ID.ConstructContainer(player.inventory, side, TE), w, x, y, z, side, TE);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ContainerNull();
|
||||
}
|
||||
|
||||
private Object getGuiObject(final ItemStack it, final PlayerEntity player, final World w, final int x, final int y,
|
||||
final int z) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean CorrectTileOrPart(final Object tE) {
|
||||
if (this.tileClass == null) {
|
||||
throw new IllegalArgumentException("This Gui Cannot use the standard Handler.");
|
||||
}
|
||||
|
||||
return this.tileClass.isInstance(tE);
|
||||
}
|
||||
|
||||
private Object updateGui(final Object newContainer, final World w, final int x, final int y, final int z,
|
||||
final AEPartLocation side, final Object myItem) {
|
||||
if (newContainer instanceof AEBaseContainer) {
|
||||
// FIXME final AEBaseContainer bc = (AEBaseContainer) newContainer;
|
||||
// FIXME bc.setLocator( new ContainerLocator( myItem ) );
|
||||
// FIXME bc.getLocator().setWorld( w );
|
||||
// FIXME bc.getLocator().setX( x );
|
||||
// FIXME bc.getLocator().setY( y );
|
||||
// FIXME bc.getLocator().setZ( z );
|
||||
// FIXME bc.getLocator().setSide( side );
|
||||
}
|
||||
|
||||
return newContainer;
|
||||
}
|
||||
|
||||
public Object ConstructContainer(final PlayerInventory inventory, final AEPartLocation side, final Object tE) {
|
||||
try {
|
||||
final Constructor[] c = this.containerClass.getConstructors();
|
||||
if (c.length == 0) {
|
||||
throw new AppEngException("Invalid Gui Class");
|
||||
}
|
||||
|
||||
final Constructor target = this.findConstructor(c, inventory, tE);
|
||||
|
||||
if (target == null) {
|
||||
throw new IllegalStateException("Cannot find " + this.containerClass.getName() + "( "
|
||||
+ this.typeName(inventory) + ", " + this.typeName(tE) + " )");
|
||||
}
|
||||
|
||||
return target.newInstance(inventory, tE);
|
||||
} catch (final Throwable t) {
|
||||
throw new IllegalStateException(t);
|
||||
}
|
||||
}
|
||||
|
||||
private Constructor findConstructor(final Constructor[] c, final PlayerInventory inventory, final Object tE) {
|
||||
for (final Constructor con : c) {
|
||||
final Class[] types = con.getParameterTypes();
|
||||
if (types.length == 2) {
|
||||
if (types[0].isAssignableFrom(inventory.getClass()) && types[1].isAssignableFrom(tE.getClass())) {
|
||||
return con;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String typeName(final Object inventory) {
|
||||
if (inventory == null) {
|
||||
return "NULL";
|
||||
}
|
||||
|
||||
return inventory.getClass().getName();
|
||||
}
|
||||
|
||||
public Object getClientGuiElement(final int ordinal, final PlayerEntity player, final World w, final int x,
|
||||
final int y, final int z) {
|
||||
final AEPartLocation side = AEPartLocation.fromOrdinal(ordinal & 0x07);
|
||||
final GuiBridge ID = values()[ordinal >> 4];
|
||||
final boolean stem = ((ordinal >> 3) & 1) == 1;
|
||||
if (ID.type.isItem()) {
|
||||
ItemStack it = ItemStack.EMPTY;
|
||||
if (stem) {
|
||||
it = player.inventory.getCurrentItem();
|
||||
} else if (x >= 0 && x < player.inventory.mainInventory.size()) {
|
||||
it = player.inventory.getStackInSlot(x);
|
||||
}
|
||||
final Object myItem = this.getGuiObject(it, player, w, x, y, z);
|
||||
if (myItem != null && ID.CorrectTileOrPart(myItem)) {
|
||||
return ID.ConstructGui(player.inventory, side, myItem);
|
||||
}
|
||||
}
|
||||
if (ID.type.isTile()) {
|
||||
final TileEntity TE = w.getTileEntity(new BlockPos(x, y, z));
|
||||
if (TE instanceof IPartHost) {
|
||||
((IPartHost) TE).getPart(side);
|
||||
final IPart part = ((IPartHost) TE).getPart(side);
|
||||
if (ID.CorrectTileOrPart(part)) {
|
||||
return ID.ConstructGui(player.inventory, side, part);
|
||||
}
|
||||
} else {
|
||||
if (ID.CorrectTileOrPart(TE)) {
|
||||
return ID.ConstructGui(player.inventory, side, TE);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null; // FIXME
|
||||
}
|
||||
|
||||
public Object ConstructGui(final PlayerInventory inventory, final AEPartLocation side, final Object tE) {
|
||||
try {
|
||||
final Constructor[] c = this.guiClass.getConstructors();
|
||||
if (c.length == 0) {
|
||||
throw new AppEngException("Invalid Gui Class");
|
||||
}
|
||||
|
||||
final Constructor target = this.findConstructor(c, inventory, tE);
|
||||
|
||||
if (target == null) {
|
||||
throw new IllegalStateException("Cannot find " + this.containerClass.getName() + "( "
|
||||
+ this.typeName(inventory) + ", " + this.typeName(tE) + " )");
|
||||
}
|
||||
|
||||
return target.newInstance(inventory, tE);
|
||||
} catch (final Throwable t) {
|
||||
throw new IllegalStateException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasPermissions(final TileEntity te, final int x, final int y, final int z, final AEPartLocation side,
|
||||
final PlayerEntity player) {
|
||||
final World w = player.getEntityWorld();
|
||||
final BlockPos pos = new BlockPos(x, y, z);
|
||||
|
||||
if (Platform.hasPermissions(te != null ? new DimensionalCoord(te) : new DimensionalCoord(player.world, pos),
|
||||
player)) {
|
||||
if (this.type.isItem()) {
|
||||
final ItemStack it = player.inventory.getCurrentItem();
|
||||
if (!it.isEmpty() && it.getItem() instanceof IGuiItem) {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.type.isTile()) {
|
||||
final TileEntity TE = w.getTileEntity(pos);
|
||||
if (TE instanceof IPartHost) {
|
||||
((IPartHost) TE).getPart(side);
|
||||
final IPart part = ((IPartHost) TE).getPart(side);
|
||||
if (this.CorrectTileOrPart(part)) {
|
||||
return this.securityCheck(part, player);
|
||||
}
|
||||
} else {
|
||||
if (this.CorrectTileOrPart(TE)) {
|
||||
return this.securityCheck(TE, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean securityCheck(final Object te, final PlayerEntity player) {
|
||||
if (te instanceof IActionHost && this.requiredPermission != null) {
|
||||
|
||||
final IGridNode gn = ((IActionHost) te).getActionableNode();
|
||||
if (gn != null) {
|
||||
final IGrid g = gn.getGrid();
|
||||
if (g != null) {
|
||||
final boolean requirePower = false;
|
||||
if (requirePower) {
|
||||
final IEnergyGrid eg = g.getCache(IEnergyGrid.class);
|
||||
if (!eg.isNetworkPowered()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final ISecurityGrid sg = g.getCache(ISecurityGrid.class);
|
||||
if (sg.hasPermission(player, this.requiredPermission)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public GuiHostType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,18 +18,14 @@
|
||||
|
||||
package appeng.core.sync;
|
||||
|
||||
public enum GuiHostType {
|
||||
ITEM_OR_WORLD, ITEM, WORLD;
|
||||
|
||||
public enum GuiHostType
|
||||
{
|
||||
ITEM_OR_WORLD, ITEM, WORLD;
|
||||
public boolean isItem() {
|
||||
return this != WORLD;
|
||||
}
|
||||
|
||||
public boolean isItem()
|
||||
{
|
||||
return this != WORLD;
|
||||
}
|
||||
|
||||
boolean isTile()
|
||||
{
|
||||
return this != ITEM;
|
||||
}
|
||||
boolean isTile() {
|
||||
return this != ITEM;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync.network;
|
||||
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -30,22 +29,17 @@ import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.AppEngPacketHandlerBase;
|
||||
|
||||
public class AppEngClientPacketHandler extends AppEngPacketHandlerBase implements IPacketHandler {
|
||||
|
||||
public class AppEngClientPacketHandler extends AppEngPacketHandlerBase implements IPacketHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onPacketData( final INetworkInfo manager, final INetHandler handler, final PacketBuffer packet, final PlayerEntity player )
|
||||
{
|
||||
try
|
||||
{
|
||||
final int packetType = packet.readInt();
|
||||
final AppEngPacket pack = PacketTypes.getPacket( packetType ).parsePacket( packet );
|
||||
pack.clientPacketData( manager, Minecraft.getInstance().player );
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onPacketData(final INetworkInfo manager, final INetHandler handler, final PacketBuffer packet,
|
||||
final PlayerEntity player) {
|
||||
try {
|
||||
final int packetType = packet.readInt();
|
||||
final AppEngPacket pack = PacketTypes.getPacket(packetType).parsePacket(packet);
|
||||
pack.clientPacketData(manager, Minecraft.getInstance().player);
|
||||
} catch (final IllegalArgumentException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync.network;
|
||||
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -29,22 +28,17 @@ import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.AppEngPacketHandlerBase;
|
||||
|
||||
public final class AppEngServerPacketHandler extends AppEngPacketHandlerBase implements IPacketHandler {
|
||||
|
||||
public final class AppEngServerPacketHandler extends AppEngPacketHandlerBase implements IPacketHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onPacketData( final INetworkInfo manager, final INetHandler handler, final PacketBuffer packet, final PlayerEntity player )
|
||||
{
|
||||
try
|
||||
{
|
||||
final int packetType = packet.readInt();
|
||||
final AppEngPacket pack = PacketTypes.getPacket( packetType ).parsePacket( packet );
|
||||
pack.serverPacketData( manager, player );
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onPacketData(final INetworkInfo manager, final INetHandler handler, final PacketBuffer packet,
|
||||
final PlayerEntity player) {
|
||||
try {
|
||||
final int packetType = packet.readInt();
|
||||
final AppEngPacket pack = PacketTypes.getPacket(packetType).parsePacket(packet);
|
||||
pack.serverPacketData(manager, player);
|
||||
} catch (final IllegalArgumentException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
package appeng.core.sync.network;
|
||||
|
||||
|
||||
public interface INetworkInfo
|
||||
{
|
||||
public interface INetworkInfo {
|
||||
|
||||
}
|
||||
|
||||
@@ -18,15 +18,12 @@
|
||||
|
||||
package appeng.core.sync.network;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
public interface IPacketHandler {
|
||||
|
||||
public interface IPacketHandler
|
||||
{
|
||||
|
||||
void onPacketData(INetworkInfo manager, INetHandler handler, PacketBuffer packet, PlayerEntity player );
|
||||
void onPacketData(INetworkInfo manager, INetHandler handler, PacketBuffer packet, PlayerEntity player);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync.network;
|
||||
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.network.INetHandler;
|
||||
@@ -38,136 +37,109 @@ import net.minecraftforge.fml.network.event.EventNetworkChannel;
|
||||
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
|
||||
public class NetworkHandler {
|
||||
private static NetworkHandler instance;
|
||||
|
||||
public class NetworkHandler
|
||||
{
|
||||
private static NetworkHandler instance;
|
||||
private final EventNetworkChannel ec;
|
||||
private final ResourceLocation myChannelName;
|
||||
|
||||
private final EventNetworkChannel ec;
|
||||
private final ResourceLocation myChannelName;
|
||||
private final IPacketHandler clientHandler;
|
||||
private final IPacketHandler serveHandler;
|
||||
|
||||
private final IPacketHandler clientHandler;
|
||||
private final IPacketHandler serveHandler;
|
||||
public NetworkHandler(final ResourceLocation channelName) {
|
||||
ec = NetworkRegistry.ChannelBuilder.named(myChannelName = channelName).networkProtocolVersion(() -> "1")
|
||||
.clientAcceptedVersions(s -> true).serverAcceptedVersions(s -> true).eventNetworkChannel();
|
||||
ec.registerObject(this);
|
||||
|
||||
public NetworkHandler( final ResourceLocation channelName )
|
||||
{
|
||||
ec = NetworkRegistry.ChannelBuilder.named( myChannelName = channelName ).networkProtocolVersion( () -> "1" ).clientAcceptedVersions( s -> true ).serverAcceptedVersions( s -> true ).eventNetworkChannel();
|
||||
ec.registerObject( this );
|
||||
this.clientHandler = this.createClientSide();
|
||||
this.serveHandler = this.createServerSide();
|
||||
}
|
||||
|
||||
this.clientHandler = this.createClientSide();
|
||||
this.serveHandler = this.createServerSide();
|
||||
}
|
||||
public static void init(final ResourceLocation channelName) {
|
||||
instance = new NetworkHandler(channelName);
|
||||
}
|
||||
|
||||
public static void init( final ResourceLocation channelName )
|
||||
{
|
||||
instance = new NetworkHandler( channelName );
|
||||
}
|
||||
public static NetworkHandler instance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static NetworkHandler instance()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
private IPacketHandler createClientSide() {
|
||||
try {
|
||||
return new AppEngClientPacketHandler();
|
||||
} catch (final Throwable t) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IPacketHandler createClientSide()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new AppEngClientPacketHandler();
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private IPacketHandler createServerSide() {
|
||||
try {
|
||||
return new AppEngServerPacketHandler();
|
||||
} catch (final Throwable t) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IPacketHandler createServerSide()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new AppEngServerPacketHandler();
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void serverPacket(final NetworkEvent.ClientCustomPayloadEvent ev) {
|
||||
if (this.serveHandler != null) {
|
||||
try {
|
||||
NetworkEvent.Context ctx = ev.getSource().get();
|
||||
ServerPlayNetHandler netHandler = (ServerPlayNetHandler) ctx.getNetworkManager().getNetHandler();
|
||||
ctx.setPacketHandled(true);
|
||||
ctx.enqueueWork(
|
||||
() -> this.serveHandler.onPacketData(null, netHandler, ev.getPayload(), netHandler.player));
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverPacket( final NetworkEvent.ClientCustomPayloadEvent ev )
|
||||
{
|
||||
if( this.serveHandler != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkEvent.Context ctx = ev.getSource().get();
|
||||
ServerPlayNetHandler netHandler = (ServerPlayNetHandler) ctx.getNetworkManager().getNetHandler();
|
||||
ctx.setPacketHandled( true );
|
||||
ctx.enqueueWork( () -> this.serveHandler.onPacketData( null, netHandler, ev.getPayload(), netHandler.player ) );
|
||||
} catch (final ThreadQuickExitException ignored) {
|
||||
|
||||
}
|
||||
catch( final ThreadQuickExitException ignored )
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void clientPacket(final NetworkEvent.ServerCustomPayloadEvent ev) {
|
||||
if (ev instanceof NetworkEvent.ServerCustomPayloadLoginEvent) {
|
||||
return;
|
||||
}
|
||||
if (this.clientHandler != null) {
|
||||
try {
|
||||
NetworkEvent.Context ctx = ev.getSource().get();
|
||||
INetHandler netHandler = ctx.getNetworkManager().getNetHandler();
|
||||
ctx.setPacketHandled(true);
|
||||
ctx.enqueueWork(() -> this.clientHandler.onPacketData(null, netHandler, ev.getPayload(), null));
|
||||
} catch (final ThreadQuickExitException ignored) {
|
||||
|
||||
@SubscribeEvent
|
||||
public void clientPacket( final NetworkEvent.ServerCustomPayloadEvent ev )
|
||||
{
|
||||
if( ev instanceof NetworkEvent.ServerCustomPayloadLoginEvent )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if( this.clientHandler != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkEvent.Context ctx = ev.getSource().get();
|
||||
INetHandler netHandler = ctx.getNetworkManager().getNetHandler();
|
||||
ctx.setPacketHandled( true );
|
||||
ctx.enqueueWork( () -> this.clientHandler.onPacketData( null, netHandler, ev.getPayload(), null ) );
|
||||
}
|
||||
catch( final ThreadQuickExitException ignored )
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public ResourceLocation getChannel() {
|
||||
return this.myChannelName;
|
||||
}
|
||||
|
||||
public ResourceLocation getChannel()
|
||||
{
|
||||
return this.myChannelName;
|
||||
}
|
||||
public void sendToAll(final AppEngPacket message) {
|
||||
getServer().getPlayerList().sendPacketToAllPlayers(message.toPacket(NetworkDirection.PLAY_TO_CLIENT));
|
||||
}
|
||||
|
||||
public void sendToAll( final AppEngPacket message )
|
||||
{
|
||||
getServer().getPlayerList().sendPacketToAllPlayers( message.toPacket( NetworkDirection.PLAY_TO_CLIENT ) );
|
||||
}
|
||||
public void sendTo(final AppEngPacket message, final ServerPlayerEntity player) {
|
||||
player.connection.sendPacket(message.toPacket(NetworkDirection.PLAY_TO_CLIENT));
|
||||
}
|
||||
|
||||
public void sendTo( final AppEngPacket message, final ServerPlayerEntity player )
|
||||
{
|
||||
player.connection.sendPacket( message.toPacket( NetworkDirection.PLAY_TO_CLIENT ) );
|
||||
}
|
||||
public void sendToAllAround(final AppEngPacket message, final TargetPoint point) {
|
||||
IPacket<?> pkt = message.toPacket(NetworkDirection.PLAY_TO_CLIENT);
|
||||
getServer().getPlayerList().sendToAllNearExcept(point.excluded, point.x, point.y, point.z, point.r2, point.dim,
|
||||
pkt);
|
||||
}
|
||||
|
||||
public void sendToAllAround( final AppEngPacket message, final TargetPoint point )
|
||||
{
|
||||
IPacket<?> pkt = message.toPacket( NetworkDirection.PLAY_TO_CLIENT );
|
||||
getServer().getPlayerList().sendToAllNearExcept( point.excluded, point.x, point.y, point.z, point.r2, point.dim, pkt);
|
||||
}
|
||||
public void sendToDimension(final AppEngPacket message, final DimensionType dim) {
|
||||
getServer().getPlayerList().sendPacketToAllPlayersInDimension(message.toPacket(NetworkDirection.PLAY_TO_CLIENT),
|
||||
dim);
|
||||
}
|
||||
|
||||
public void sendToDimension( final AppEngPacket message, final DimensionType dim )
|
||||
{
|
||||
getServer().getPlayerList().sendPacketToAllPlayersInDimension( message.toPacket( NetworkDirection.PLAY_TO_CLIENT ), dim );
|
||||
}
|
||||
public void sendToServer(final AppEngPacket message) {
|
||||
Minecraft.getInstance().getConnection().sendPacket(message.toPacket(NetworkDirection.PLAY_TO_SERVER));
|
||||
}
|
||||
|
||||
public void sendToServer( final AppEngPacket message )
|
||||
{
|
||||
Minecraft.getInstance().getConnection().sendPacket( message.toPacket( NetworkDirection.PLAY_TO_SERVER ) );
|
||||
}
|
||||
|
||||
private MinecraftServer getServer()
|
||||
{
|
||||
return LogicalSidedProvider.INSTANCE.get( LogicalSide.SERVER );
|
||||
}
|
||||
private MinecraftServer getServer() {
|
||||
return LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,44 +1,39 @@
|
||||
package appeng.core.sync.network;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
|
||||
/**
|
||||
* Created by covers1624 on 1/6/20.
|
||||
*/
|
||||
public class TargetPoint
|
||||
{
|
||||
|
||||
public final ServerPlayerEntity excluded;
|
||||
public final double x;
|
||||
public final double y;
|
||||
public final double z;
|
||||
public final double r2;
|
||||
public final DimensionType dim;
|
||||
public class TargetPoint {
|
||||
|
||||
public TargetPoint( double x, double y, double z, double r2, DimensionType dim )
|
||||
{
|
||||
this( null, x, y, z, r2, dim );
|
||||
}
|
||||
public final ServerPlayerEntity excluded;
|
||||
public final double x;
|
||||
public final double y;
|
||||
public final double z;
|
||||
public final double r2;
|
||||
public final DimensionType dim;
|
||||
|
||||
public TargetPoint( ServerPlayerEntity excluded, double x, double y, double z, double r2, DimensionType dim )
|
||||
{
|
||||
this.excluded = excluded;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.r2 = r2;
|
||||
this.dim = dim;
|
||||
}
|
||||
public TargetPoint(double x, double y, double z, double r2, DimensionType dim) {
|
||||
this(null, x, y, z, r2, dim);
|
||||
}
|
||||
|
||||
public TargetPoint(ServerPlayerEntity excluded, double x, double y, double z, double r2, DimensionType dim) {
|
||||
this.excluded = excluded;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.r2 = r2;
|
||||
this.dim = dim;
|
||||
}
|
||||
|
||||
public static TargetPoint at(double x, double y, double z, double r2, DimensionType dim) {
|
||||
return new TargetPoint( x, y, z, r2, dim );
|
||||
}
|
||||
public static TargetPoint at(double x, double y, double z, double r2, DimensionType dim) {
|
||||
return new TargetPoint(x, y, z, r2, dim);
|
||||
}
|
||||
|
||||
public static TargetPoint at(ServerPlayerEntity excluded, double x, double y, double z, double r2, DimensionType dim) {
|
||||
return new TargetPoint( excluded, x, y, z, r2, dim );
|
||||
}
|
||||
public static TargetPoint at(ServerPlayerEntity excluded, double x, double y, double z, double r2,
|
||||
DimensionType dim) {
|
||||
return new TargetPoint(excluded, x, y, z, r2, dim);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
@@ -36,50 +35,46 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class PacketAssemblerAnimation extends AppEngPacket {
|
||||
|
||||
public class PacketAssemblerAnimation extends AppEngPacket
|
||||
{
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
public final byte rate;
|
||||
public final IAEItemStack is;
|
||||
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
public final byte rate;
|
||||
public final IAEItemStack is;
|
||||
public PacketAssemblerAnimation(final PacketBuffer stream) {
|
||||
this.x = stream.readInt();
|
||||
this.y = stream.readInt();
|
||||
this.z = stream.readInt();
|
||||
this.rate = stream.readByte();
|
||||
this.is = AEItemStack.fromPacket(stream);
|
||||
}
|
||||
|
||||
public PacketAssemblerAnimation( final PacketBuffer stream )
|
||||
{
|
||||
this.x = stream.readInt();
|
||||
this.y = stream.readInt();
|
||||
this.z = stream.readInt();
|
||||
this.rate = stream.readByte();
|
||||
this.is = AEItemStack.fromPacket( stream );
|
||||
}
|
||||
// api
|
||||
public PacketAssemblerAnimation(final BlockPos pos, final byte rate, final IAEItemStack is) {
|
||||
|
||||
// api
|
||||
public PacketAssemblerAnimation( final BlockPos pos, final byte rate, final IAEItemStack is )
|
||||
{
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeInt(this.x = pos.getX());
|
||||
data.writeInt(this.y = pos.getY());
|
||||
data.writeInt(this.z = pos.getZ());
|
||||
data.writeByte(this.rate = rate);
|
||||
is.writeToPacket(data);
|
||||
this.is = is;
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( this.x = pos.getX() );
|
||||
data.writeInt( this.y = pos.getY() );
|
||||
data.writeInt( this.z = pos.getZ() );
|
||||
data.writeByte( this.rate = rate );
|
||||
is.writeToPacket( data );
|
||||
this.is = is;
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
|
||||
final double d0 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
|
||||
final double d1 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
|
||||
final double d2 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
final double d0 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
|
||||
final double d1 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
|
||||
final double d2 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
|
||||
|
||||
AppEng.proxy.spawnEffect( EffectType.Assembler, player.getEntityWorld(), this.x + d0, this.y + d1, this.z + d2, this );
|
||||
}
|
||||
AppEng.proxy.spawnEffect(EffectType.Assembler, player.getEntityWorld(), this.x + d0, this.y + d1, this.z + d2,
|
||||
this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,18 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IComparableDefinition;
|
||||
@@ -32,149 +44,122 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.items.tools.ToolNetworkTool;
|
||||
import appeng.items.tools.powered.ToolColorApplicator;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class PacketClick extends AppEngPacket {
|
||||
|
||||
public class PacketClick extends AppEngPacket
|
||||
{
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
private Direction side;
|
||||
private final float hitX;
|
||||
private final float hitY;
|
||||
private final float hitZ;
|
||||
private Hand hand;
|
||||
private final boolean leftClick;
|
||||
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
private Direction side;
|
||||
private final float hitX;
|
||||
private final float hitY;
|
||||
private final float hitZ;
|
||||
private Hand hand;
|
||||
private final boolean leftClick;
|
||||
public PacketClick(final PacketBuffer stream) {
|
||||
this.x = stream.readInt();
|
||||
this.y = stream.readInt();
|
||||
this.z = stream.readInt();
|
||||
byte side = stream.readByte();
|
||||
if (side != -1) {
|
||||
this.side = Direction.values()[side];
|
||||
} else {
|
||||
this.side = null;
|
||||
}
|
||||
this.hitX = stream.readFloat();
|
||||
this.hitY = stream.readFloat();
|
||||
this.hitZ = stream.readFloat();
|
||||
this.hand = Hand.values()[stream.readByte()];
|
||||
this.leftClick = stream.readBoolean();
|
||||
}
|
||||
|
||||
public PacketClick( final PacketBuffer stream )
|
||||
{
|
||||
this.x = stream.readInt();
|
||||
this.y = stream.readInt();
|
||||
this.z = stream.readInt();
|
||||
byte side = stream.readByte();
|
||||
if( side != -1 )
|
||||
{
|
||||
this.side = Direction.values()[side];
|
||||
}
|
||||
else
|
||||
{
|
||||
this.side = null;
|
||||
}
|
||||
this.hitX = stream.readFloat();
|
||||
this.hitY = stream.readFloat();
|
||||
this.hitZ = stream.readFloat();
|
||||
this.hand = Hand.values()[stream.readByte()];
|
||||
this.leftClick = stream.readBoolean();
|
||||
}
|
||||
// API for when a block was right clicked
|
||||
public PacketClick(ItemUseContext context) {
|
||||
this(context.getPos(), context.getFace(), context.getPos().getX(), context.getPos().getY(),
|
||||
context.getPos().getZ(), context.getHand());
|
||||
}
|
||||
|
||||
// API for when a block was right clicked
|
||||
public PacketClick( ItemUseContext context )
|
||||
{
|
||||
this(context.getPos(), context.getFace(), context.getPos().getX(), context.getPos().getY(), context.getPos().getZ(), context.getHand());
|
||||
}
|
||||
// API for when an item in hand was right-clicked, with no block context
|
||||
public PacketClick(Hand hand) {
|
||||
this(BlockPos.ZERO, null, 0, 0, 0, hand);
|
||||
}
|
||||
|
||||
// API for when an item in hand was right-clicked, with no block context
|
||||
public PacketClick( Hand hand )
|
||||
{
|
||||
this(BlockPos.ZERO, null, 0, 0, 0, hand);
|
||||
}
|
||||
private PacketClick(final BlockPos pos, final Direction side, final float hitX, final float hitY, final float hitZ,
|
||||
final Hand hand) {
|
||||
this(pos, side, hitX, hitY, hitZ, hand, false);
|
||||
}
|
||||
|
||||
private PacketClick( final BlockPos pos, final Direction side, final float hitX, final float hitY, final float hitZ, final Hand hand )
|
||||
{
|
||||
this( pos, side, hitX, hitY, hitZ, hand, false );
|
||||
}
|
||||
public PacketClick(final BlockPos pos, final Direction side, final float hitX, final float hitY, final float hitZ,
|
||||
final Hand hand, boolean leftClick) {
|
||||
|
||||
public PacketClick( final BlockPos pos, final Direction side, final float hitX, final float hitY, final float hitZ, final Hand hand, boolean leftClick )
|
||||
{
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeInt(this.x = pos.getX());
|
||||
data.writeInt(this.y = pos.getY());
|
||||
data.writeInt(this.z = pos.getZ());
|
||||
if (side == null) {
|
||||
data.writeByte(-1);
|
||||
} else {
|
||||
data.writeByte(side.ordinal());
|
||||
}
|
||||
data.writeFloat(this.hitX = hitX);
|
||||
data.writeFloat(this.hitY = hitY);
|
||||
data.writeFloat(this.hitZ = hitZ);
|
||||
data.writeByte(hand.ordinal());
|
||||
data.writeBoolean(this.leftClick = leftClick);
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( this.x = pos.getX() );
|
||||
data.writeInt( this.y = pos.getY() );
|
||||
data.writeInt( this.z = pos.getZ() );
|
||||
if( side == null )
|
||||
{
|
||||
data.writeByte( -1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
data.writeByte( side.ordinal() );
|
||||
}
|
||||
data.writeFloat( this.hitX = hitX );
|
||||
data.writeFloat( this.hitY = hitY );
|
||||
data.writeFloat( this.hitZ = hitZ );
|
||||
data.writeByte( hand.ordinal() );
|
||||
data.writeBoolean( this.leftClick = leftClick );
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
// Indicates that block pos, side and hit vector have valid data
|
||||
private boolean hasBlockContext() {
|
||||
return side != null;
|
||||
}
|
||||
|
||||
// Indicates that block pos, side and hit vector have valid data
|
||||
private boolean hasBlockContext() {
|
||||
return side != null;
|
||||
}
|
||||
@Override
|
||||
public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) {
|
||||
final BlockPos pos = new BlockPos(this.x, this.y, this.z);
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final BlockPos pos = new BlockPos( this.x, this.y, this.z );
|
||||
final ItemStack is = player.getHeldItem(hand);
|
||||
final IItems items = AEApi.instance().definitions().items();
|
||||
final IComparableDefinition maybeMemoryCard = items.memoryCard();
|
||||
final IComparableDefinition maybeColorApplicator = items.colorApplicator();
|
||||
|
||||
final ItemStack is = player.getHeldItem(hand);
|
||||
final IItems items = AEApi.instance().definitions().items();
|
||||
final IComparableDefinition maybeMemoryCard = items.memoryCard();
|
||||
final IComparableDefinition maybeColorApplicator = items.colorApplicator();
|
||||
if (this.leftClick) {
|
||||
final Block block = player.world.getBlockState(pos).getBlock();
|
||||
if (block instanceof BlockCableBus) {
|
||||
((BlockCableBus) block).onBlockClickPacket(player.world, pos, player, this.hand,
|
||||
new Vec3d(this.hitX, this.hitY, this.hitZ));
|
||||
}
|
||||
} else {
|
||||
if (!is.isEmpty()) {
|
||||
if (is.getItem() instanceof ToolNetworkTool) {
|
||||
final ToolNetworkTool tnt = (ToolNetworkTool) is.getItem();
|
||||
|
||||
if( this.leftClick )
|
||||
{
|
||||
final Block block = player.world.getBlockState( pos ).getBlock();
|
||||
if( block instanceof BlockCableBus)
|
||||
{
|
||||
( (BlockCableBus) block ).onBlockClickPacket( player.world, pos, player, this.hand, new Vec3d( this.hitX, this.hitY, this.hitZ ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
if( is.getItem() instanceof ToolNetworkTool)
|
||||
{
|
||||
final ToolNetworkTool tnt = (ToolNetworkTool) is.getItem();
|
||||
if (hasBlockContext()) {
|
||||
// Reconstruct an item use context
|
||||
ItemUseContext useContext = new ItemUseContext(player, hand,
|
||||
new BlockRayTraceResult(new Vec3d(hitX, hitY, hitZ), side, pos, false));
|
||||
tnt.serverSideToolLogic(useContext);
|
||||
} else {
|
||||
ContainerOpener.openContainer(ContainerNetworkTool.TYPE, player,
|
||||
ContainerLocator.forHand(player, hand));
|
||||
}
|
||||
}
|
||||
|
||||
if (hasBlockContext()) {
|
||||
// Reconstruct an item use context
|
||||
ItemUseContext useContext = new ItemUseContext(player, hand, new BlockRayTraceResult(new Vec3d(hitX, hitY, hitZ), side, pos, false));
|
||||
tnt.serverSideToolLogic(useContext);
|
||||
} else {
|
||||
ContainerOpener.openContainer(ContainerNetworkTool.TYPE, player, ContainerLocator.forHand(player, hand));
|
||||
}
|
||||
}
|
||||
if (maybeMemoryCard.isSameAs(is)) {
|
||||
final IMemoryCard mem = (IMemoryCard) is.getItem();
|
||||
mem.notifyUser(player, MemoryCardMessages.SETTINGS_CLEARED);
|
||||
is.setTag(null);
|
||||
}
|
||||
|
||||
if( maybeMemoryCard.isSameAs( is ) )
|
||||
{
|
||||
final IMemoryCard mem = (IMemoryCard) is.getItem();
|
||||
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
|
||||
is.setTag( null );
|
||||
}
|
||||
|
||||
else if( maybeColorApplicator.isSameAs( is ) )
|
||||
{
|
||||
final ToolColorApplicator mem = (ToolColorApplicator) is.getItem();
|
||||
mem.cycleColors( is, mem.getColor( is ), 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (maybeColorApplicator.isSameAs(is)) {
|
||||
final ToolColorApplicator mem = (ToolColorApplicator) is.getItem();
|
||||
mem.cycleColors(is, mem.getColor(is), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import appeng.core.worlddata.WorldData;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -30,54 +28,51 @@ import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.worlddata.WorldData;
|
||||
import appeng.services.compass.ICompassCallback;
|
||||
|
||||
public class PacketCompassRequest extends AppEngPacket implements ICompassCallback {
|
||||
|
||||
public class PacketCompassRequest extends AppEngPacket implements ICompassCallback
|
||||
{
|
||||
final long attunement;
|
||||
final int cx;
|
||||
final int cz;
|
||||
final int cdy;
|
||||
|
||||
final long attunement;
|
||||
final int cx;
|
||||
final int cz;
|
||||
final int cdy;
|
||||
private PlayerEntity talkBackTo;
|
||||
|
||||
private PlayerEntity talkBackTo;
|
||||
public PacketCompassRequest(final PacketBuffer stream) {
|
||||
this.attunement = stream.readLong();
|
||||
this.cx = stream.readInt();
|
||||
this.cz = stream.readInt();
|
||||
this.cdy = stream.readInt();
|
||||
}
|
||||
|
||||
public PacketCompassRequest( final PacketBuffer stream )
|
||||
{
|
||||
this.attunement = stream.readLong();
|
||||
this.cx = stream.readInt();
|
||||
this.cz = stream.readInt();
|
||||
this.cdy = stream.readInt();
|
||||
}
|
||||
// api
|
||||
public PacketCompassRequest(final long attunement, final int cx, final int cz, final int cdy) {
|
||||
|
||||
// api
|
||||
public PacketCompassRequest( final long attunement, final int cx, final int cz, final int cdy )
|
||||
{
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeLong(this.attunement = attunement);
|
||||
data.writeInt(this.cx = cx);
|
||||
data.writeInt(this.cz = cz);
|
||||
data.writeInt(this.cdy = cdy);
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeLong( this.attunement = attunement );
|
||||
data.writeInt( this.cx = cx );
|
||||
data.writeInt( this.cz = cz );
|
||||
data.writeInt( this.cdy = cdy );
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
@Override
|
||||
public void calculatedDirection(final boolean hasResult, final boolean spin, final double radians,
|
||||
final double dist) {
|
||||
NetworkHandler.instance().sendTo(new PacketCompassResponse(this, hasResult, spin, radians),
|
||||
(ServerPlayerEntity) this.talkBackTo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculatedDirection( final boolean hasResult, final boolean spin, final double radians, final double dist )
|
||||
{
|
||||
NetworkHandler.instance().sendTo( new PacketCompassResponse( this, hasResult, spin, radians ), (ServerPlayerEntity) this.talkBackTo );
|
||||
}
|
||||
@Override
|
||||
public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) {
|
||||
this.talkBackTo = player;
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
this.talkBackTo = player;
|
||||
|
||||
final DimensionalCoord loc = new DimensionalCoord( player.world, this.cx << 4, this.cdy << 5, this.cz << 4 );
|
||||
WorldData.instance().compassData().service().getCompassDirection( loc, 174, this );
|
||||
}
|
||||
final DimensionalCoord loc = new DimensionalCoord(player.world, this.cx << 4, this.cdy << 5, this.cz << 4);
|
||||
WorldData.instance().compassData().service().getCompassDirection(loc, 174, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import appeng.hooks.CompassManager;
|
||||
import appeng.hooks.CompassResult;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -28,50 +25,48 @@ import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.hooks.CompassManager;
|
||||
import appeng.hooks.CompassResult;
|
||||
|
||||
public class PacketCompassResponse extends AppEngPacket {
|
||||
|
||||
public class PacketCompassResponse extends AppEngPacket
|
||||
{
|
||||
private final long attunement;
|
||||
private final int cx;
|
||||
private final int cz;
|
||||
private final int cdy;
|
||||
|
||||
private final long attunement;
|
||||
private final int cx;
|
||||
private final int cz;
|
||||
private final int cdy;
|
||||
private CompassResult cr;
|
||||
|
||||
private CompassResult cr;
|
||||
public PacketCompassResponse(final PacketBuffer stream) {
|
||||
this.attunement = stream.readLong();
|
||||
this.cx = stream.readInt();
|
||||
this.cz = stream.readInt();
|
||||
this.cdy = stream.readInt();
|
||||
|
||||
public PacketCompassResponse( final PacketBuffer stream )
|
||||
{
|
||||
this.attunement = stream.readLong();
|
||||
this.cx = stream.readInt();
|
||||
this.cz = stream.readInt();
|
||||
this.cdy = stream.readInt();
|
||||
this.cr = new CompassResult(stream.readBoolean(), stream.readBoolean(), stream.readDouble());
|
||||
}
|
||||
|
||||
this.cr = new CompassResult( stream.readBoolean(), stream.readBoolean(), stream.readDouble() );
|
||||
}
|
||||
// api
|
||||
public PacketCompassResponse(final PacketCompassRequest req, final boolean hasResult, final boolean spin,
|
||||
final double radians) {
|
||||
|
||||
// api
|
||||
public PacketCompassResponse( final PacketCompassRequest req, final boolean hasResult, final boolean spin, final double radians )
|
||||
{
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeLong(this.attunement = req.attunement);
|
||||
data.writeInt(this.cx = req.cx);
|
||||
data.writeInt(this.cz = req.cz);
|
||||
data.writeInt(this.cdy = req.cdy);
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeLong( this.attunement = req.attunement );
|
||||
data.writeInt( this.cx = req.cx );
|
||||
data.writeInt( this.cz = req.cz );
|
||||
data.writeInt( this.cdy = req.cdy );
|
||||
data.writeBoolean(hasResult);
|
||||
data.writeBoolean(spin);
|
||||
data.writeDouble(radians);
|
||||
|
||||
data.writeBoolean( hasResult );
|
||||
data.writeBoolean( spin );
|
||||
data.writeDouble( radians );
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
CompassManager.INSTANCE.postResult( this.attunement, this.cx << 4, this.cdy << 5, this.cz << 4, this.cr );
|
||||
}
|
||||
@Override
|
||||
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
|
||||
CompassManager.INSTANCE.postResult(this.attunement, this.cx << 4, this.cdy << 5, this.cz << 4, this.cr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -27,7 +26,6 @@ import java.io.OutputStream;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import appeng.client.gui.implementations.GuiInterfaceTerminal;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -39,83 +37,70 @@ import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.client.gui.implementations.GuiInterfaceTerminal;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
|
||||
|
||||
//TODO, this is pointless, NBT is already compressed when written to a PacketBuffer.
|
||||
public class PacketCompressedNBT extends AppEngPacket
|
||||
{
|
||||
public class PacketCompressedNBT extends AppEngPacket {
|
||||
|
||||
// input.
|
||||
private final CompoundNBT in;
|
||||
// output...
|
||||
private final PacketBuffer data;
|
||||
private final GZIPOutputStream compressFrame;
|
||||
// input.
|
||||
private final CompoundNBT in;
|
||||
// output...
|
||||
private final PacketBuffer data;
|
||||
private final GZIPOutputStream compressFrame;
|
||||
|
||||
public PacketCompressedNBT( final PacketBuffer stream )
|
||||
{
|
||||
this.data = null;
|
||||
this.compressFrame = null;
|
||||
public PacketCompressedNBT(final PacketBuffer stream) {
|
||||
this.data = null;
|
||||
this.compressFrame = null;
|
||||
|
||||
try( DataInputStream inStream = new DataInputStream( new GZIPInputStream( new InputStream()
|
||||
{
|
||||
try (DataInputStream inStream = new DataInputStream(new GZIPInputStream(new InputStream() {
|
||||
|
||||
@Override
|
||||
public int read()
|
||||
{
|
||||
if( stream.readableBytes() <= 0 )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@Override
|
||||
public int read() {
|
||||
if (stream.readableBytes() <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return stream.readByte() & 0xff;
|
||||
}
|
||||
} ) ) )
|
||||
{
|
||||
this.in = CompressedStreamTools.read( inStream );
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
throw new RuntimeException( "Failed to decompress packet.", e );
|
||||
}
|
||||
}
|
||||
return stream.readByte() & 0xff;
|
||||
}
|
||||
}))) {
|
||||
this.in = CompressedStreamTools.read(inStream);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to decompress packet.", e);
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: this is pointless, PacketBuffer.writeNBT will already compress
|
||||
// api
|
||||
public PacketCompressedNBT( final CompoundNBT din ) throws IOException
|
||||
{
|
||||
// FIXME: this is pointless, PacketBuffer.writeNBT will already compress
|
||||
// api
|
||||
public PacketCompressedNBT(final CompoundNBT din) throws IOException {
|
||||
|
||||
this.data = new PacketBuffer( Unpooled.buffer( 2048 ) );
|
||||
this.data.writeInt( this.getPacketID() );
|
||||
this.data = new PacketBuffer(Unpooled.buffer(2048));
|
||||
this.data.writeInt(this.getPacketID());
|
||||
|
||||
this.in = din;
|
||||
this.in = din;
|
||||
|
||||
this.compressFrame = new GZIPOutputStream( new OutputStream()
|
||||
{
|
||||
this.compressFrame = new GZIPOutputStream(new OutputStream() {
|
||||
|
||||
@Override
|
||||
public void write( final int value )
|
||||
{
|
||||
PacketCompressedNBT.this.data.writeByte( value );
|
||||
}
|
||||
} );
|
||||
@Override
|
||||
public void write(final int value) {
|
||||
PacketCompressedNBT.this.data.writeByte(value);
|
||||
}
|
||||
});
|
||||
|
||||
CompressedStreamTools.write( din, new DataOutputStream( this.compressFrame ) );
|
||||
this.compressFrame.close();
|
||||
CompressedStreamTools.write(din, new DataOutputStream(this.compressFrame));
|
||||
this.compressFrame.close();
|
||||
|
||||
this.configureWrite( this.data );
|
||||
}
|
||||
this.configureWrite(this.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
final Screen gs = Minecraft.getInstance().currentScreen;
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
|
||||
final Screen gs = Minecraft.getInstance().currentScreen;
|
||||
|
||||
if( gs instanceof GuiInterfaceTerminal)
|
||||
{
|
||||
( (GuiInterfaceTerminal) gs ).postUpdate( this.in );
|
||||
}
|
||||
}
|
||||
if (gs instanceof GuiInterfaceTerminal) {
|
||||
((GuiInterfaceTerminal) gs).postUpdate(this.in);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -32,46 +31,44 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public final class PacketConfigButton extends AppEngPacket {
|
||||
private final Settings option;
|
||||
private final boolean rotationDirection;
|
||||
|
||||
public final class PacketConfigButton extends AppEngPacket
|
||||
{
|
||||
private final Settings option;
|
||||
private final boolean rotationDirection;
|
||||
public PacketConfigButton(final PacketBuffer stream) {
|
||||
this.option = Settings.values()[stream.readInt()];
|
||||
this.rotationDirection = stream.readBoolean();
|
||||
}
|
||||
|
||||
public PacketConfigButton( final PacketBuffer stream )
|
||||
{
|
||||
this.option = Settings.values()[stream.readInt()];
|
||||
this.rotationDirection = stream.readBoolean();
|
||||
}
|
||||
// api
|
||||
public PacketConfigButton(final Settings option, final boolean rotationDirection) {
|
||||
this.option = option;
|
||||
this.rotationDirection = rotationDirection;
|
||||
|
||||
// api
|
||||
public PacketConfigButton( final Settings option, final boolean rotationDirection )
|
||||
{
|
||||
this.option = option;
|
||||
this.rotationDirection = rotationDirection;
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeInt(option.ordinal());
|
||||
data.writeBoolean(rotationDirection);
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( option.ordinal() );
|
||||
data.writeBoolean( rotationDirection );
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final ServerPlayerEntity sender = (ServerPlayerEntity) player;
|
||||
// FIXME if( sender.openContainer instanceof AEBaseContainer )
|
||||
// FIXME {
|
||||
// FIXME final AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer;
|
||||
// FIXME if( baseContainer.getTarget() instanceof IConfigurableObject )
|
||||
// FIXME {
|
||||
// FIXME final IConfigManager cm = ( (IConfigurableObject) baseContainer.getTarget() ).getConfigManager();
|
||||
// FIXME final Enum<?> newState = EnumCycler.rotateEnum( cm.getSetting( this.option ), this.rotationDirection, this.option.getPossibleValues() );
|
||||
// FIXME cm.putSetting( this.option, newState );
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
}
|
||||
@Override
|
||||
public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) {
|
||||
final ServerPlayerEntity sender = (ServerPlayerEntity) player;
|
||||
// FIXME if( sender.openContainer instanceof AEBaseContainer )
|
||||
// FIXME {
|
||||
// FIXME final AEBaseContainer baseContainer = (AEBaseContainer)
|
||||
// sender.openContainer;
|
||||
// FIXME if( baseContainer.getTarget() instanceof IConfigurableObject )
|
||||
// FIXME {
|
||||
// FIXME final IConfigManager cm = ( (IConfigurableObject)
|
||||
// baseContainer.getTarget() ).getConfigManager();
|
||||
// FIXME final Enum<?> newState = EnumCycler.rotateEnum( cm.getSetting(
|
||||
// this.option ), this.rotationDirection, this.option.getPossibleValues() );
|
||||
// FIXME cm.putSetting( this.option, newState );
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,8 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerInscriber;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -35,92 +32,80 @@ import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.crafting.ICraftingJob;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import appeng.container.implementations.ContainerCraftConfirm;
|
||||
import appeng.container.implementations.ContainerInscriber;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
|
||||
public class PacketCraftRequest extends AppEngPacket {
|
||||
|
||||
public class PacketCraftRequest extends AppEngPacket
|
||||
{
|
||||
private final long amount;
|
||||
private final boolean heldShift;
|
||||
|
||||
private final long amount;
|
||||
private final boolean heldShift;
|
||||
public PacketCraftRequest(final PacketBuffer stream) {
|
||||
this.heldShift = stream.readBoolean();
|
||||
this.amount = stream.readLong();
|
||||
}
|
||||
|
||||
public PacketCraftRequest( final PacketBuffer stream )
|
||||
{
|
||||
this.heldShift = stream.readBoolean();
|
||||
this.amount = stream.readLong();
|
||||
}
|
||||
public PacketCraftRequest(final int craftAmt, final boolean shift) {
|
||||
this.amount = craftAmt;
|
||||
this.heldShift = shift;
|
||||
|
||||
public PacketCraftRequest( final int craftAmt, final boolean shift )
|
||||
{
|
||||
this.amount = craftAmt;
|
||||
this.heldShift = shift;
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeBoolean(shift);
|
||||
data.writeLong(this.amount);
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeBoolean( shift );
|
||||
data.writeLong( this.amount );
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
@Override
|
||||
public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) {
|
||||
if (player.openContainer instanceof ContainerCraftAmount) {
|
||||
final ContainerCraftAmount cca = (ContainerCraftAmount) player.openContainer;
|
||||
final Object target = cca.getTarget();
|
||||
if (target instanceof IActionHost) {
|
||||
final IActionHost ah = (IActionHost) target;
|
||||
final IGridNode gn = ah.getActionableNode();
|
||||
if (gn == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
if( player.openContainer instanceof ContainerCraftAmount )
|
||||
{
|
||||
final ContainerCraftAmount cca = (ContainerCraftAmount) player.openContainer;
|
||||
final Object target = cca.getTarget();
|
||||
if( target instanceof IActionHost )
|
||||
{
|
||||
final IActionHost ah = (IActionHost) target;
|
||||
final IGridNode gn = ah.getActionableNode();
|
||||
if( gn == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final IGrid g = gn.getGrid();
|
||||
if (g == null || cca.getItemToCraft() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final IGrid g = gn.getGrid();
|
||||
if( g == null || cca.getItemToCraft() == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
cca.getItemToCraft().setStackSize(this.amount);
|
||||
|
||||
cca.getItemToCraft().setStackSize( this.amount );
|
||||
Future<ICraftingJob> futureJob = null;
|
||||
try {
|
||||
final ICraftingGrid cg = g.getCache(ICraftingGrid.class);
|
||||
futureJob = cg.beginCraftingJob(cca.getWorld(), cca.getGrid(), cca.getActionSrc(),
|
||||
cca.getItemToCraft(), null);
|
||||
|
||||
Future<ICraftingJob> futureJob = null;
|
||||
try
|
||||
{
|
||||
final ICraftingGrid cg = g.getCache( ICraftingGrid.class );
|
||||
futureJob = cg.beginCraftingJob( cca.getWorld(), cca.getGrid(), cca.getActionSrc(), cca.getItemToCraft(), null );
|
||||
final ContainerLocator locator = cca.getLocator();
|
||||
if (locator != null) {
|
||||
ContainerOpener.openContainer(ContainerCraftConfirm.TYPE, player, locator);
|
||||
|
||||
final ContainerLocator locator = cca.getLocator();
|
||||
if( locator != null )
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerCraftConfirm.TYPE, player, locator);
|
||||
|
||||
if( player.openContainer instanceof ContainerCraftConfirm )
|
||||
{
|
||||
final ContainerCraftConfirm ccc = (ContainerCraftConfirm) player.openContainer;
|
||||
ccc.setAutoStart( this.heldShift );
|
||||
ccc.setJob( futureJob );
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( final Throwable e )
|
||||
{
|
||||
if( futureJob != null )
|
||||
{
|
||||
futureJob.cancel( true );
|
||||
}
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (player.openContainer instanceof ContainerCraftConfirm) {
|
||||
final ContainerCraftConfirm ccc = (ContainerCraftConfirm) player.openContainer;
|
||||
ccc.setAutoStart(this.heldShift);
|
||||
ccc.setJob(futureJob);
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
} catch (final Throwable e) {
|
||||
if (futureJob != null) {
|
||||
futureJob.cancel(true);
|
||||
}
|
||||
AELog.debug(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -35,60 +34,49 @@ import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.fluids.container.IFluidSyncContainer;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
|
||||
public class PacketFluidSlot extends AppEngPacket {
|
||||
private final Map<Integer, IAEFluidStack> list;
|
||||
|
||||
public class PacketFluidSlot extends AppEngPacket
|
||||
{
|
||||
private final Map<Integer, IAEFluidStack> list;
|
||||
public PacketFluidSlot(final PacketBuffer stream) {
|
||||
this.list = new HashMap<>();
|
||||
CompoundNBT tag = stream.readCompoundTag();
|
||||
|
||||
public PacketFluidSlot( final PacketBuffer stream )
|
||||
{
|
||||
this.list = new HashMap<>();
|
||||
CompoundNBT tag = stream.readCompoundTag();
|
||||
for (final String key : tag.keySet()) {
|
||||
this.list.put(Integer.parseInt(key), AEFluidStack.fromNBT(tag.getCompound(key)));
|
||||
}
|
||||
}
|
||||
|
||||
for( final String key : tag.keySet() )
|
||||
{
|
||||
this.list.put( Integer.parseInt( key ), AEFluidStack.fromNBT( tag.getCompound( key ) ) );
|
||||
}
|
||||
}
|
||||
// api
|
||||
public PacketFluidSlot(final Map<Integer, IAEFluidStack> list) {
|
||||
this.list = list;
|
||||
final CompoundNBT sendTag = new CompoundNBT();
|
||||
for (Map.Entry<Integer, IAEFluidStack> fs : list.entrySet()) {
|
||||
final CompoundNBT tag = new CompoundNBT();
|
||||
if (fs.getValue() != null) {
|
||||
fs.getValue().writeToNBT(tag);
|
||||
}
|
||||
sendTag.put(fs.getKey().toString(), tag);
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketFluidSlot( final Map<Integer, IAEFluidStack> list )
|
||||
{
|
||||
this.list = list;
|
||||
final CompoundNBT sendTag = new CompoundNBT();
|
||||
for( Map.Entry<Integer, IAEFluidStack> fs : list.entrySet() )
|
||||
{
|
||||
final CompoundNBT tag = new CompoundNBT();
|
||||
if( fs.getValue() != null )
|
||||
{
|
||||
fs.getValue().writeToNBT( tag );
|
||||
}
|
||||
sendTag.put( fs.getKey().toString(), tag );
|
||||
}
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeCompoundTag(sendTag);
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeCompoundTag( sendTag );
|
||||
this.configureWrite( data );
|
||||
}
|
||||
@Override
|
||||
public void clientPacketData(final INetworkInfo manager, final PlayerEntity player) {
|
||||
final Container c = player.openContainer;
|
||||
if (c instanceof IFluidSyncContainer) {
|
||||
((IFluidSyncContainer) c).receiveFluidSlots(this.list);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final Container c = player.openContainer;
|
||||
if( c instanceof IFluidSyncContainer )
|
||||
{
|
||||
( (IFluidSyncContainer) c ).receiveFluidSlots( this.list );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( INetworkInfo manager, PlayerEntity player )
|
||||
{
|
||||
final Container c = player.openContainer;
|
||||
if( c instanceof IFluidSyncContainer )
|
||||
{
|
||||
( (IFluidSyncContainer) c ).receiveFluidSlots( this.list );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, PlayerEntity player) {
|
||||
final Container c = player.openContainer;
|
||||
if (c instanceof IFluidSyncContainer) {
|
||||
((IFluidSyncContainer) c).receiveFluidSlots(this.list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,12 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.AEBaseContainer;
|
||||
@@ -30,139 +36,109 @@ import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
public class PacketInventoryAction extends AppEngPacket {
|
||||
|
||||
public class PacketInventoryAction extends AppEngPacket
|
||||
{
|
||||
private final InventoryAction action;
|
||||
private final int slot;
|
||||
private final long id;
|
||||
private final IAEItemStack slotItem;
|
||||
|
||||
private final InventoryAction action;
|
||||
private final int slot;
|
||||
private final long id;
|
||||
private final IAEItemStack slotItem;
|
||||
public PacketInventoryAction(final PacketBuffer stream) {
|
||||
this.action = InventoryAction.values()[stream.readInt()];
|
||||
this.slot = stream.readInt();
|
||||
this.id = stream.readLong();
|
||||
final boolean hasItem = stream.readBoolean();
|
||||
if (hasItem) {
|
||||
this.slotItem = AEItemStack.fromPacket(stream);
|
||||
} else {
|
||||
this.slotItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
public PacketInventoryAction( final PacketBuffer stream )
|
||||
{
|
||||
this.action = InventoryAction.values()[stream.readInt()];
|
||||
this.slot = stream.readInt();
|
||||
this.id = stream.readLong();
|
||||
final boolean hasItem = stream.readBoolean();
|
||||
if( hasItem )
|
||||
{
|
||||
this.slotItem = AEItemStack.fromPacket( stream );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.slotItem = null;
|
||||
}
|
||||
}
|
||||
// api
|
||||
public PacketInventoryAction(final InventoryAction action, final int slot, final IAEItemStack slotItem) {
|
||||
|
||||
// api
|
||||
public PacketInventoryAction( final InventoryAction action, final int slot, final IAEItemStack slotItem )
|
||||
{
|
||||
if (Platform.isClient()) {
|
||||
throw new IllegalStateException("invalid packet, client cannot post inv actions with stacks.");
|
||||
}
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
throw new IllegalStateException( "invalid packet, client cannot post inv actions with stacks." );
|
||||
}
|
||||
this.action = action;
|
||||
this.slot = slot;
|
||||
this.id = 0;
|
||||
this.slotItem = slotItem;
|
||||
|
||||
this.action = action;
|
||||
this.slot = slot;
|
||||
this.id = 0;
|
||||
this.slotItem = slotItem;
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeInt(action.ordinal());
|
||||
data.writeInt(slot);
|
||||
data.writeLong(this.id);
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( action.ordinal() );
|
||||
data.writeInt( slot );
|
||||
data.writeLong( this.id );
|
||||
if (slotItem == null) {
|
||||
data.writeBoolean(false);
|
||||
} else {
|
||||
data.writeBoolean(true);
|
||||
slotItem.writeToPacket(data);
|
||||
}
|
||||
|
||||
if( slotItem == null )
|
||||
{
|
||||
data.writeBoolean( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
data.writeBoolean( true );
|
||||
slotItem.writeToPacket( data );
|
||||
}
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
// api
|
||||
public PacketInventoryAction(final InventoryAction action, final int slot, final long id) {
|
||||
this.action = action;
|
||||
this.slot = slot;
|
||||
this.id = id;
|
||||
this.slotItem = null;
|
||||
|
||||
// api
|
||||
public PacketInventoryAction( final InventoryAction action, final int slot, final long id )
|
||||
{
|
||||
this.action = action;
|
||||
this.slot = slot;
|
||||
this.id = id;
|
||||
this.slotItem = null;
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeInt(action.ordinal());
|
||||
data.writeInt(slot);
|
||||
data.writeLong(id);
|
||||
data.writeBoolean(false);
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( action.ordinal() );
|
||||
data.writeInt( slot );
|
||||
data.writeLong( id );
|
||||
data.writeBoolean( false );
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
@Override
|
||||
public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) {
|
||||
final ServerPlayerEntity sender = (ServerPlayerEntity) player;
|
||||
if (sender.openContainer instanceof AEBaseContainer) {
|
||||
final AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer;
|
||||
if (this.action == InventoryAction.AUTO_CRAFT) {
|
||||
final ContainerLocator locator = baseContainer.getLocator();
|
||||
if (locator != null) {
|
||||
ContainerOpener.openContainer(ContainerCraftAmount.TYPE, player, locator);
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final ServerPlayerEntity sender = (ServerPlayerEntity) player;
|
||||
if( sender.openContainer instanceof AEBaseContainer )
|
||||
{
|
||||
final AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer;
|
||||
if( this.action == InventoryAction.AUTO_CRAFT )
|
||||
{
|
||||
final ContainerLocator locator = baseContainer.getLocator();
|
||||
if( locator != null )
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerCraftAmount.TYPE, player, locator);
|
||||
if (sender.openContainer instanceof ContainerCraftAmount) {
|
||||
final ContainerCraftAmount cca = (ContainerCraftAmount) sender.openContainer;
|
||||
|
||||
if( sender.openContainer instanceof ContainerCraftAmount )
|
||||
{
|
||||
final ContainerCraftAmount cca = (ContainerCraftAmount) sender.openContainer;
|
||||
if (baseContainer.getTargetStack() != null) {
|
||||
cca.getCraftingItem().putStack(baseContainer.getTargetStack().asItemStackRepresentation());
|
||||
// This is the *actual* item that matters, not the display item above
|
||||
cca.setItemToCraft(baseContainer.getTargetStack());
|
||||
}
|
||||
|
||||
if( baseContainer.getTargetStack() != null )
|
||||
{
|
||||
cca.getCraftingItem().putStack( baseContainer.getTargetStack().asItemStackRepresentation() );
|
||||
// This is the *actual* item that matters, not the display item above
|
||||
cca.setItemToCraft( baseContainer.getTargetStack() );
|
||||
}
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
baseContainer.doAction(sender, this.action, this.slot, this.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
baseContainer.doAction( sender, this.action, this.slot, this.id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
if( this.action == InventoryAction.UPDATE_HAND )
|
||||
{
|
||||
if( this.slotItem == null )
|
||||
{
|
||||
AppEng.proxy.getPlayers().get( 0 ).inventory.setItemStack( ItemStack.EMPTY );
|
||||
}
|
||||
else
|
||||
{
|
||||
AppEng.proxy.getPlayers().get( 0 ).inventory.setItemStack( this.slotItem.createItemStack() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
|
||||
if (this.action == InventoryAction.UPDATE_HAND) {
|
||||
if (this.slotItem == null) {
|
||||
AppEng.proxy.getPlayers().get(0).inventory.setItemStack(ItemStack.EMPTY);
|
||||
} else {
|
||||
AppEng.proxy.getPlayers().get(0).inventory.setItemStack(this.slotItem.createItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
@@ -55,188 +54,154 @@ import appeng.util.inv.WrapperInvItemHandler;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import appeng.util.prioritylist.IPartitionList;
|
||||
|
||||
public class PacketJEIRecipe extends AppEngPacket {
|
||||
|
||||
public class PacketJEIRecipe extends AppEngPacket
|
||||
{
|
||||
private ItemStack[][] recipe;
|
||||
|
||||
private ItemStack[][] recipe;
|
||||
public PacketJEIRecipe(final PacketBuffer stream) {
|
||||
final CompoundNBT comp = stream.readCompoundTag();
|
||||
if (comp != null) {
|
||||
this.recipe = new ItemStack[9][];
|
||||
for (int x = 0; x < this.recipe.length; x++) {
|
||||
final ListNBT list = comp.getList("#" + x, 10);
|
||||
if (list.size() > 0) {
|
||||
this.recipe[x] = new ItemStack[list.size()];
|
||||
for (int y = 0; y < list.size(); y++) {
|
||||
this.recipe[x][y] = ItemStack.read(list.getCompound(y));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PacketJEIRecipe( final PacketBuffer stream )
|
||||
{
|
||||
final CompoundNBT comp = stream.readCompoundTag();
|
||||
if( comp != null )
|
||||
{
|
||||
this.recipe = new ItemStack[9][];
|
||||
for( int x = 0; x < this.recipe.length; x++ )
|
||||
{
|
||||
final ListNBT list = comp.getList( "#" + x, 10 );
|
||||
if( list.size() > 0 )
|
||||
{
|
||||
this.recipe[x] = new ItemStack[list.size()];
|
||||
for( int y = 0; y < list.size(); y++ )
|
||||
{
|
||||
this.recipe[x][y] = ItemStack.read( list.getCompound( y ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// api
|
||||
public PacketJEIRecipe(final CompoundNBT recipe) {
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
// api
|
||||
public PacketJEIRecipe( final CompoundNBT recipe )
|
||||
{
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
data.writeInt(this.getPacketID());
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeCompoundTag(recipe);
|
||||
|
||||
data.writeCompoundTag( recipe );
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
@Override
|
||||
public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) {
|
||||
final ServerPlayerEntity pmp = (ServerPlayerEntity) player;
|
||||
final Container con = pmp.openContainer;
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final ServerPlayerEntity pmp = (ServerPlayerEntity) player;
|
||||
final Container con = pmp.openContainer;
|
||||
if (!(con instanceof IContainerCraftingPacket)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( !( con instanceof IContainerCraftingPacket ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final IContainerCraftingPacket cct = (IContainerCraftingPacket) con;
|
||||
final IGridNode node = cct.getNetworkNode();
|
||||
|
||||
final IContainerCraftingPacket cct = (IContainerCraftingPacket) con;
|
||||
final IGridNode node = cct.getNetworkNode();
|
||||
if (node == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( node == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final IGrid grid = node.getGrid();
|
||||
if (grid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final IGrid grid = node.getGrid();
|
||||
if( grid == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final IStorageGrid inv = grid.getCache(IStorageGrid.class);
|
||||
final IEnergyGrid energy = grid.getCache(IEnergyGrid.class);
|
||||
final ISecurityGrid security = grid.getCache(ISecurityGrid.class);
|
||||
final ICraftingGrid crafting = grid.getCache(ICraftingGrid.class);
|
||||
final IItemHandler craftMatrix = cct.getInventoryByName("crafting");
|
||||
final IItemHandler playerInventory = cct.getInventoryByName("player");
|
||||
|
||||
final IStorageGrid inv = grid.getCache( IStorageGrid.class );
|
||||
final IEnergyGrid energy = grid.getCache( IEnergyGrid.class );
|
||||
final ISecurityGrid security = grid.getCache( ISecurityGrid.class );
|
||||
final ICraftingGrid crafting = grid.getCache( ICraftingGrid.class );
|
||||
final IItemHandler craftMatrix = cct.getInventoryByName( "crafting" );
|
||||
final IItemHandler playerInventory = cct.getInventoryByName( "player" );
|
||||
if (inv != null && this.recipe != null && security != null) {
|
||||
final IMEMonitor<IAEItemStack> storage = inv
|
||||
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
final IPartitionList<IAEItemStack> filter = ItemViewCell.createFilter(cct.getViewCells());
|
||||
|
||||
if( inv != null && this.recipe != null && security != null )
|
||||
{
|
||||
final IMEMonitor<IAEItemStack> storage = inv.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
final IPartitionList<IAEItemStack> filter = ItemViewCell.createFilter( cct.getViewCells() );
|
||||
for (int x = 0; x < craftMatrix.getSlots(); x++) {
|
||||
ItemStack currentItem = craftMatrix.getStackInSlot(x);
|
||||
|
||||
for( int x = 0; x < craftMatrix.getSlots(); x++ )
|
||||
{
|
||||
ItemStack currentItem = craftMatrix.getStackInSlot( x );
|
||||
// prepare slots
|
||||
if (!currentItem.isEmpty()) {
|
||||
// already the correct item?
|
||||
ItemStack newItem = this.canUseInSlot(x, currentItem);
|
||||
|
||||
// prepare slots
|
||||
if( !currentItem.isEmpty() )
|
||||
{
|
||||
// already the correct item?
|
||||
ItemStack newItem = this.canUseInSlot( x, currentItem );
|
||||
// put away old item
|
||||
if (newItem != currentItem && security.hasPermission(player, SecurityPermissions.INJECT)) {
|
||||
final IAEItemStack in = AEItemStack.fromItemStack(currentItem);
|
||||
final IAEItemStack out = cct.useRealItems()
|
||||
? Platform.poweredInsert(energy, storage, in, cct.getActionSource())
|
||||
: null;
|
||||
if (out != null) {
|
||||
currentItem = out.createItemStack();
|
||||
} else {
|
||||
currentItem = ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// put away old item
|
||||
if( newItem != currentItem && security.hasPermission( player, SecurityPermissions.INJECT ) )
|
||||
{
|
||||
final IAEItemStack in = AEItemStack.fromItemStack( currentItem );
|
||||
final IAEItemStack out = cct.useRealItems() ? Platform.poweredInsert( energy, storage, in, cct.getActionSource() ) : null;
|
||||
if( out != null )
|
||||
{
|
||||
currentItem = out.createItemStack();
|
||||
}
|
||||
else
|
||||
{
|
||||
currentItem = ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentItem.isEmpty() && this.recipe[x] != null) {
|
||||
// for each variant
|
||||
for (int y = 0; y < this.recipe[x].length && currentItem.isEmpty(); y++) {
|
||||
final IAEItemStack request = AEItemStack.fromItemStack(this.recipe[x][y]);
|
||||
if (request != null) {
|
||||
// try ae
|
||||
if ((filter == null || filter.isListed(request))
|
||||
&& security.hasPermission(player, SecurityPermissions.EXTRACT)) {
|
||||
request.setStackSize(1);
|
||||
IAEItemStack out;
|
||||
|
||||
if( currentItem.isEmpty() && this.recipe[x] != null )
|
||||
{
|
||||
// for each variant
|
||||
for( int y = 0; y < this.recipe[x].length && currentItem.isEmpty(); y++ )
|
||||
{
|
||||
final IAEItemStack request = AEItemStack.fromItemStack( this.recipe[x][y] );
|
||||
if( request != null )
|
||||
{
|
||||
// try ae
|
||||
if( ( filter == null || filter.isListed( request ) ) && security.hasPermission( player, SecurityPermissions.EXTRACT ) )
|
||||
{
|
||||
request.setStackSize( 1 );
|
||||
IAEItemStack out;
|
||||
if (cct.useRealItems()) {
|
||||
out = Platform.poweredExtraction(energy, storage, request, cct.getActionSource());
|
||||
} else {
|
||||
// Query the crafting grid if there is a pattern providing the item
|
||||
if (!crafting.getCraftingFor(request, null, 0, null).isEmpty()) {
|
||||
out = request;
|
||||
} else {
|
||||
// Fall back using an existing item
|
||||
out = storage.extractItems(request, Actionable.SIMULATE, cct.getActionSource());
|
||||
}
|
||||
}
|
||||
|
||||
if( cct.useRealItems() )
|
||||
{
|
||||
out = Platform.poweredExtraction( energy, storage, request, cct.getActionSource() );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Query the crafting grid if there is a pattern providing the item
|
||||
if( !crafting.getCraftingFor( request, null, 0, null ).isEmpty() )
|
||||
{
|
||||
out = request;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fall back using an existing item
|
||||
out = storage.extractItems( request, Actionable.SIMULATE, cct.getActionSource() );
|
||||
}
|
||||
}
|
||||
if (out != null) {
|
||||
currentItem = out.createItemStack();
|
||||
}
|
||||
}
|
||||
|
||||
if( out != null )
|
||||
{
|
||||
currentItem = out.createItemStack();
|
||||
}
|
||||
}
|
||||
// try inventory
|
||||
if (currentItem.isEmpty()) {
|
||||
AdaptorItemHandler ad = new AdaptorItemHandler(playerInventory);
|
||||
|
||||
// try inventory
|
||||
if( currentItem.isEmpty() )
|
||||
{
|
||||
AdaptorItemHandler ad = new AdaptorItemHandler( playerInventory );
|
||||
if (cct.useRealItems()) {
|
||||
currentItem = ad.removeItems(1, this.recipe[x][y], null);
|
||||
} else {
|
||||
currentItem = ad.simulateRemove(1, this.recipe[x][y], null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ItemHandlerUtil.setStackInSlot(craftMatrix, x, currentItem);
|
||||
}
|
||||
con.onCraftMatrixChanged(new WrapperInvItemHandler(craftMatrix));
|
||||
}
|
||||
}
|
||||
|
||||
if( cct.useRealItems() )
|
||||
{
|
||||
currentItem = ad.removeItems( 1, this.recipe[x][y], null );
|
||||
}
|
||||
else
|
||||
{
|
||||
currentItem = ad.simulateRemove( 1, this.recipe[x][y], null );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ItemHandlerUtil.setStackInSlot( craftMatrix, x, currentItem );
|
||||
}
|
||||
con.onCraftMatrixChanged( new WrapperInvItemHandler( craftMatrix ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param slot
|
||||
* @param is itemstack
|
||||
* @return is if it can be used, else EMPTY
|
||||
*/
|
||||
private ItemStack canUseInSlot( int slot, ItemStack is )
|
||||
{
|
||||
if( this.recipe[slot] != null )
|
||||
{
|
||||
for( ItemStack option : this.recipe[slot] )
|
||||
{
|
||||
if( is.isItemEqual( option ) )
|
||||
{
|
||||
return is;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param slot
|
||||
* @param is itemstack
|
||||
* @return is if it can be used, else EMPTY
|
||||
*/
|
||||
private ItemStack canUseInSlot(int slot, ItemStack is) {
|
||||
if (this.recipe[slot] != null) {
|
||||
for (ItemStack option : this.recipe[slot]) {
|
||||
if (is.isItemEqual(option)) {
|
||||
return is;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -33,51 +32,42 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PacketLightning extends AppEngPacket {
|
||||
|
||||
public class PacketLightning extends AppEngPacket
|
||||
{
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
public PacketLightning(final PacketBuffer stream) {
|
||||
this.x = stream.readFloat();
|
||||
this.y = stream.readFloat();
|
||||
this.z = stream.readFloat();
|
||||
}
|
||||
|
||||
public PacketLightning( final PacketBuffer stream )
|
||||
{
|
||||
this.x = stream.readFloat();
|
||||
this.y = stream.readFloat();
|
||||
this.z = stream.readFloat();
|
||||
}
|
||||
// api
|
||||
public PacketLightning(final double x, final double y, final double z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
// api
|
||||
public PacketLightning( final double x, final double y, final double z )
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeFloat((float) x);
|
||||
data.writeFloat((float) y);
|
||||
data.writeFloat((float) z);
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeFloat( (float) x );
|
||||
data.writeFloat( (float) y );
|
||||
data.writeFloat( (float) z );
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( Platform.isClient() && AEConfig.instance().isEnableEffects() )
|
||||
{
|
||||
Minecraft.getInstance().world.addParticle( LightningFX.TYPE, this.x, this.y, this.z, 0.0f, 0.0f, 0.0f );
|
||||
}
|
||||
}
|
||||
catch( final Exception ignored )
|
||||
{
|
||||
}
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
|
||||
try {
|
||||
if (Platform.isClient() && AEConfig.instance().isEnableEffects()) {
|
||||
Minecraft.getInstance().world.addParticle(LightningFX.TYPE, this.x, this.y, this.z, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
} catch (final Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -27,6 +26,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
@@ -46,163 +46,136 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv6 - 22/05/2018
|
||||
* @since rv6 22/05/2018
|
||||
*/
|
||||
public class PacketMEFluidInventoryUpdate extends AppEngPacket
|
||||
{
|
||||
private static final int UNCOMPRESSED_PACKET_BYTE_LIMIT = 16 * 1024 * 1024;
|
||||
private static final int OPERATION_BYTE_LIMIT = 2 * 1024;
|
||||
private static final int TEMP_BUFFER_SIZE = 1024;
|
||||
private static final int STREAM_MASK = 0xff;
|
||||
public class PacketMEFluidInventoryUpdate extends AppEngPacket {
|
||||
private static final int UNCOMPRESSED_PACKET_BYTE_LIMIT = 16 * 1024 * 1024;
|
||||
private static final int OPERATION_BYTE_LIMIT = 2 * 1024;
|
||||
private static final int TEMP_BUFFER_SIZE = 1024;
|
||||
private static final int STREAM_MASK = 0xff;
|
||||
|
||||
// input.
|
||||
@Nullable
|
||||
private final List<IAEFluidStack> list;
|
||||
// output...
|
||||
private final byte ref;
|
||||
// input.
|
||||
@Nullable
|
||||
private final List<IAEFluidStack> list;
|
||||
// output...
|
||||
private final byte ref;
|
||||
|
||||
@Nullable
|
||||
private final PacketBuffer data;
|
||||
@Nullable
|
||||
private final GZIPOutputStream compressFrame;
|
||||
@Nullable
|
||||
private final PacketBuffer data;
|
||||
@Nullable
|
||||
private final GZIPOutputStream compressFrame;
|
||||
|
||||
private int writtenBytes = 0;
|
||||
private boolean empty = true;
|
||||
private int writtenBytes = 0;
|
||||
private boolean empty = true;
|
||||
|
||||
public PacketMEFluidInventoryUpdate( final PacketBuffer stream )
|
||||
{
|
||||
this.data = null;
|
||||
this.compressFrame = null;
|
||||
this.list = new LinkedList<>();
|
||||
this.ref = stream.readByte();
|
||||
public PacketMEFluidInventoryUpdate(final PacketBuffer stream) {
|
||||
this.data = null;
|
||||
this.compressFrame = null;
|
||||
this.list = new LinkedList<>();
|
||||
this.ref = stream.readByte();
|
||||
|
||||
try( final GZIPInputStream gzReader = new GZIPInputStream( new InputStream()
|
||||
{
|
||||
@Override
|
||||
public int read()
|
||||
{
|
||||
if( stream.readableBytes() <= 0 )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
try (final GZIPInputStream gzReader = new GZIPInputStream(new InputStream() {
|
||||
@Override
|
||||
public int read() {
|
||||
if (stream.readableBytes() <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return stream.readByte() & STREAM_MASK;
|
||||
}
|
||||
} ) )
|
||||
{
|
||||
return stream.readByte() & STREAM_MASK;
|
||||
}
|
||||
})) {
|
||||
|
||||
final PacketBuffer uncompressed = new PacketBuffer( Unpooled.buffer( stream.readableBytes() ) );
|
||||
final byte[] tmp = new byte[TEMP_BUFFER_SIZE];
|
||||
final PacketBuffer uncompressed = new PacketBuffer(Unpooled.buffer(stream.readableBytes()));
|
||||
final byte[] tmp = new byte[TEMP_BUFFER_SIZE];
|
||||
|
||||
while( gzReader.available() != 0 )
|
||||
{
|
||||
final int bytes = gzReader.read( tmp );
|
||||
while (gzReader.available() != 0) {
|
||||
final int bytes = gzReader.read(tmp);
|
||||
|
||||
if( bytes > 0 )
|
||||
{
|
||||
uncompressed.writeBytes( tmp, 0, bytes );
|
||||
}
|
||||
}
|
||||
if (bytes > 0) {
|
||||
uncompressed.writeBytes(tmp, 0, bytes);
|
||||
}
|
||||
}
|
||||
|
||||
while( uncompressed.readableBytes() > 0 )
|
||||
{
|
||||
this.list.add( AEFluidStack.fromPacket( uncompressed ) );
|
||||
}
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
throw new RuntimeException( "Failed to decompress packet.", e );
|
||||
}
|
||||
while (uncompressed.readableBytes() > 0) {
|
||||
this.list.add(AEFluidStack.fromPacket(uncompressed));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to decompress packet.", e);
|
||||
}
|
||||
|
||||
this.empty = this.list.isEmpty();
|
||||
}
|
||||
this.empty = this.list.isEmpty();
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketMEFluidInventoryUpdate() throws IOException
|
||||
{
|
||||
this( (byte) 0 );
|
||||
}
|
||||
// api
|
||||
public PacketMEFluidInventoryUpdate() throws IOException {
|
||||
this((byte) 0);
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketMEFluidInventoryUpdate( final byte ref ) throws IOException
|
||||
{
|
||||
this.ref = ref;
|
||||
this.data = new PacketBuffer( Unpooled.buffer( OPERATION_BYTE_LIMIT ) );
|
||||
this.data.writeInt( this.getPacketID() );
|
||||
this.data.writeByte( this.ref );
|
||||
// api
|
||||
public PacketMEFluidInventoryUpdate(final byte ref) throws IOException {
|
||||
this.ref = ref;
|
||||
this.data = new PacketBuffer(Unpooled.buffer(OPERATION_BYTE_LIMIT));
|
||||
this.data.writeInt(this.getPacketID());
|
||||
this.data.writeByte(this.ref);
|
||||
|
||||
this.compressFrame = new GZIPOutputStream( new OutputStream()
|
||||
{
|
||||
@Override
|
||||
public void write( final int value )
|
||||
{
|
||||
PacketMEFluidInventoryUpdate.this.data.writeByte( value );
|
||||
}
|
||||
} );
|
||||
this.compressFrame = new GZIPOutputStream(new OutputStream() {
|
||||
@Override
|
||||
public void write(final int value) {
|
||||
PacketMEFluidInventoryUpdate.this.data.writeByte(value);
|
||||
}
|
||||
});
|
||||
|
||||
this.list = null;
|
||||
}
|
||||
this.list = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
final Screen gs = Minecraft.getInstance().currentScreen;
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
|
||||
final Screen gs = Minecraft.getInstance().currentScreen;
|
||||
|
||||
// FIXME if( gs instanceof GuiFluidTerminal )
|
||||
// FIXME {
|
||||
// FIXME ( (GuiFluidTerminal) gs ).postUpdate( this.list );
|
||||
// FIXME }
|
||||
}
|
||||
// FIXME if( gs instanceof GuiFluidTerminal )
|
||||
// FIXME {
|
||||
// FIXME ( (GuiFluidTerminal) gs ).postUpdate( this.list );
|
||||
// FIXME }
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IPacket<?> toPacket( NetworkDirection direction )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.compressFrame.close();
|
||||
@Nullable
|
||||
@Override
|
||||
public IPacket<?> toPacket(NetworkDirection direction) {
|
||||
try {
|
||||
this.compressFrame.close();
|
||||
|
||||
this.configureWrite( this.data );
|
||||
return super.toPacket( direction );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
this.configureWrite(this.data);
|
||||
return super.toPacket(direction);
|
||||
} catch (final IOException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void appendFluid( final IAEFluidStack fs ) throws IOException, BufferOverflowException
|
||||
{
|
||||
final PacketBuffer tmp = new PacketBuffer( Unpooled.buffer( OPERATION_BYTE_LIMIT ) );
|
||||
fs.writeToPacket( tmp );
|
||||
public void appendFluid(final IAEFluidStack fs) throws IOException, BufferOverflowException {
|
||||
final PacketBuffer tmp = new PacketBuffer(Unpooled.buffer(OPERATION_BYTE_LIMIT));
|
||||
fs.writeToPacket(tmp);
|
||||
|
||||
this.compressFrame.flush();
|
||||
if( this.writtenBytes + tmp.readableBytes() > UNCOMPRESSED_PACKET_BYTE_LIMIT )
|
||||
{
|
||||
throw new BufferOverflowException();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.writtenBytes += tmp.readableBytes();
|
||||
this.compressFrame.write( tmp.array(), 0, tmp.readableBytes() );
|
||||
this.empty = false;
|
||||
}
|
||||
}
|
||||
this.compressFrame.flush();
|
||||
if (this.writtenBytes + tmp.readableBytes() > UNCOMPRESSED_PACKET_BYTE_LIMIT) {
|
||||
throw new BufferOverflowException();
|
||||
} else {
|
||||
this.writtenBytes += tmp.readableBytes();
|
||||
this.compressFrame.write(tmp.array(), 0, tmp.readableBytes());
|
||||
this.empty = false;
|
||||
}
|
||||
}
|
||||
|
||||
public int getLength()
|
||||
{
|
||||
return this.data.readableBytes();
|
||||
}
|
||||
public int getLength() {
|
||||
return this.data.readableBytes();
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return this.empty;
|
||||
}
|
||||
public boolean isEmpty() {
|
||||
return this.empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -27,12 +26,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.client.gui.implementations.GuiCraftConfirm;
|
||||
import appeng.client.gui.implementations.GuiCraftingCPU;
|
||||
import appeng.client.gui.implementations.GuiMEMonitorable;
|
||||
import appeng.client.gui.implementations.GuiNetworkStatus;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -45,179 +41,152 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.network.NetworkDirection;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.implementations.GuiCraftConfirm;
|
||||
import appeng.client.gui.implementations.GuiCraftingCPU;
|
||||
import appeng.client.gui.implementations.GuiMEMonitorable;
|
||||
import appeng.client.gui.implementations.GuiNetworkStatus;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class PacketMEInventoryUpdate extends AppEngPacket {
|
||||
private static final int UNCOMPRESSED_PACKET_BYTE_LIMIT = 16 * 1024 * 1024;
|
||||
private static final int OPERATION_BYTE_LIMIT = 2 * 1024;
|
||||
private static final int TEMP_BUFFER_SIZE = 1024;
|
||||
private static final int STREAM_MASK = 0xff;
|
||||
|
||||
public class PacketMEInventoryUpdate extends AppEngPacket
|
||||
{
|
||||
private static final int UNCOMPRESSED_PACKET_BYTE_LIMIT = 16 * 1024 * 1024;
|
||||
private static final int OPERATION_BYTE_LIMIT = 2 * 1024;
|
||||
private static final int TEMP_BUFFER_SIZE = 1024;
|
||||
private static final int STREAM_MASK = 0xff;
|
||||
// input.
|
||||
@Nullable
|
||||
private final List<IAEItemStack> list;
|
||||
// output...
|
||||
private final byte ref;
|
||||
|
||||
// input.
|
||||
@Nullable
|
||||
private final List<IAEItemStack> list;
|
||||
// output...
|
||||
private final byte ref;
|
||||
@Nullable
|
||||
private final PacketBuffer data;
|
||||
@Nullable
|
||||
private final GZIPOutputStream compressFrame;
|
||||
|
||||
@Nullable
|
||||
private final PacketBuffer data;
|
||||
@Nullable
|
||||
private final GZIPOutputStream compressFrame;
|
||||
private int writtenBytes = 0;
|
||||
private boolean empty = true;
|
||||
|
||||
private int writtenBytes = 0;
|
||||
private boolean empty = true;
|
||||
public PacketMEInventoryUpdate(final PacketBuffer stream) {
|
||||
this.data = null;
|
||||
this.compressFrame = null;
|
||||
this.list = new ArrayList<>();
|
||||
this.ref = stream.readByte();
|
||||
|
||||
public PacketMEInventoryUpdate( final PacketBuffer stream )
|
||||
{
|
||||
this.data = null;
|
||||
this.compressFrame = null;
|
||||
this.list = new ArrayList<>();
|
||||
this.ref = stream.readByte();
|
||||
// int originalBytes = stream.readableBytes();
|
||||
|
||||
// int originalBytes = stream.readableBytes();
|
||||
try (GZIPInputStream gzReader = new GZIPInputStream(new InputStream() {
|
||||
@Override
|
||||
public int read() {
|
||||
if (stream.readableBytes() <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
try( GZIPInputStream gzReader = new GZIPInputStream( new InputStream()
|
||||
{
|
||||
@Override
|
||||
public int read()
|
||||
{
|
||||
if( stream.readableBytes() <= 0 )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return stream.readByte() & STREAM_MASK;
|
||||
}
|
||||
})) {
|
||||
final PacketBuffer uncompressed = new PacketBuffer(Unpooled.buffer(stream.readableBytes()));
|
||||
final byte[] tmp = new byte[TEMP_BUFFER_SIZE];
|
||||
|
||||
return stream.readByte() & STREAM_MASK;
|
||||
}
|
||||
} ) )
|
||||
{
|
||||
final PacketBuffer uncompressed = new PacketBuffer( Unpooled.buffer( stream.readableBytes() ) );
|
||||
final byte[] tmp = new byte[TEMP_BUFFER_SIZE];
|
||||
while (gzReader.available() != 0) {
|
||||
final int bytes = gzReader.read(tmp);
|
||||
|
||||
while( gzReader.available() != 0 )
|
||||
{
|
||||
final int bytes = gzReader.read( tmp );
|
||||
if (bytes > 0) {
|
||||
uncompressed.writeBytes(tmp, 0, bytes);
|
||||
}
|
||||
}
|
||||
|
||||
if( bytes > 0 )
|
||||
{
|
||||
uncompressed.writeBytes( tmp, 0, bytes );
|
||||
}
|
||||
}
|
||||
while (uncompressed.readableBytes() > 0) {
|
||||
this.list.add(AEItemStack.fromPacket(uncompressed));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to decompress packet.", e);
|
||||
}
|
||||
|
||||
while( uncompressed.readableBytes() > 0 )
|
||||
{
|
||||
this.list.add( AEItemStack.fromPacket( uncompressed ) );
|
||||
}
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
throw new RuntimeException( "Failed to decompress packet.", e );
|
||||
}
|
||||
this.empty = this.list.isEmpty();
|
||||
}
|
||||
|
||||
this.empty = this.list.isEmpty();
|
||||
}
|
||||
// api
|
||||
public PacketMEInventoryUpdate() throws IOException {
|
||||
this((byte) 0);
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketMEInventoryUpdate() throws IOException
|
||||
{
|
||||
this( (byte) 0 );
|
||||
}
|
||||
// api
|
||||
public PacketMEInventoryUpdate(final byte ref) throws IOException {
|
||||
this.ref = ref;
|
||||
this.data = new PacketBuffer(Unpooled.buffer(OPERATION_BYTE_LIMIT));
|
||||
this.data.writeInt(this.getPacketID());
|
||||
this.data.writeByte(this.ref);
|
||||
|
||||
// api
|
||||
public PacketMEInventoryUpdate( final byte ref ) throws IOException
|
||||
{
|
||||
this.ref = ref;
|
||||
this.data = new PacketBuffer( Unpooled.buffer( OPERATION_BYTE_LIMIT ) );
|
||||
this.data.writeInt( this.getPacketID() );
|
||||
this.data.writeByte( this.ref );
|
||||
this.compressFrame = new GZIPOutputStream(new OutputStream() {
|
||||
@Override
|
||||
public void write(final int value) {
|
||||
PacketMEInventoryUpdate.this.data.writeByte(value);
|
||||
}
|
||||
});
|
||||
|
||||
this.compressFrame = new GZIPOutputStream( new OutputStream()
|
||||
{
|
||||
@Override
|
||||
public void write( final int value )
|
||||
{
|
||||
PacketMEInventoryUpdate.this.data.writeByte( value );
|
||||
}
|
||||
} );
|
||||
this.list = null;
|
||||
}
|
||||
|
||||
this.list = null;
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
|
||||
final Screen gs = Minecraft.getInstance().currentScreen;
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
final Screen gs = Minecraft.getInstance().currentScreen;
|
||||
if (gs instanceof GuiCraftConfirm) {
|
||||
((GuiCraftConfirm) gs).postUpdate(this.list, this.ref);
|
||||
}
|
||||
|
||||
if( gs instanceof GuiCraftConfirm)
|
||||
{
|
||||
( (GuiCraftConfirm) gs ).postUpdate( this.list, this.ref );
|
||||
}
|
||||
if (gs instanceof GuiCraftingCPU) {
|
||||
((GuiCraftingCPU<?>) gs).postUpdate(this.list, this.ref);
|
||||
}
|
||||
|
||||
if( gs instanceof GuiCraftingCPU)
|
||||
{
|
||||
( (GuiCraftingCPU<?>) gs ).postUpdate( this.list, this.ref );
|
||||
}
|
||||
if (gs instanceof GuiMEMonitorable) {
|
||||
((GuiMEMonitorable<?>) gs).postUpdate(this.list);
|
||||
}
|
||||
|
||||
if( gs instanceof GuiMEMonitorable)
|
||||
{
|
||||
( (GuiMEMonitorable<?>) gs ).postUpdate( this.list );
|
||||
}
|
||||
if (gs instanceof GuiNetworkStatus) {
|
||||
((GuiNetworkStatus) gs).postUpdate(this.list);
|
||||
}
|
||||
}
|
||||
|
||||
if( gs instanceof GuiNetworkStatus)
|
||||
{
|
||||
( (GuiNetworkStatus) gs ).postUpdate( this.list );
|
||||
}
|
||||
}
|
||||
@Nullable
|
||||
@Override
|
||||
public IPacket<?> toPacket(NetworkDirection direction) {
|
||||
try {
|
||||
this.compressFrame.close();
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IPacket<?> toPacket( NetworkDirection direction )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.compressFrame.close();
|
||||
this.configureWrite(this.data);
|
||||
return super.toPacket(direction);
|
||||
} catch (final IOException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
|
||||
this.configureWrite( this.data );
|
||||
return super.toPacket( direction );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public void appendItem(final IAEItemStack is) throws IOException, BufferOverflowException {
|
||||
final PacketBuffer tmp = new PacketBuffer(Unpooled.buffer(OPERATION_BYTE_LIMIT));
|
||||
is.writeToPacket(tmp);
|
||||
|
||||
public void appendItem( final IAEItemStack is ) throws IOException, BufferOverflowException
|
||||
{
|
||||
final PacketBuffer tmp = new PacketBuffer( Unpooled.buffer( OPERATION_BYTE_LIMIT ) );
|
||||
is.writeToPacket( tmp );
|
||||
this.compressFrame.flush();
|
||||
if (this.writtenBytes + tmp.readableBytes() > UNCOMPRESSED_PACKET_BYTE_LIMIT) {
|
||||
throw new BufferOverflowException();
|
||||
} else {
|
||||
this.writtenBytes += tmp.readableBytes();
|
||||
this.compressFrame.write(tmp.array(), 0, tmp.readableBytes());
|
||||
this.empty = false;
|
||||
}
|
||||
}
|
||||
|
||||
this.compressFrame.flush();
|
||||
if( this.writtenBytes + tmp.readableBytes() > UNCOMPRESSED_PACKET_BYTE_LIMIT )
|
||||
{
|
||||
throw new BufferOverflowException();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.writtenBytes += tmp.readableBytes();
|
||||
this.compressFrame.write( tmp.array(), 0, tmp.readableBytes() );
|
||||
this.empty = false;
|
||||
}
|
||||
}
|
||||
public int getLength() {
|
||||
return this.data.readableBytes();
|
||||
}
|
||||
|
||||
public int getLength()
|
||||
{
|
||||
return this.data.readableBytes();
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return this.empty;
|
||||
}
|
||||
public boolean isEmpty() {
|
||||
return this.empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -31,74 +30,68 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
|
||||
public class PacketMatterCannon extends AppEngPacket {
|
||||
|
||||
public class PacketMatterCannon extends AppEngPacket
|
||||
{
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
private final double dx;
|
||||
private final double dy;
|
||||
private final double dz;
|
||||
private final byte len;
|
||||
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
private final double dx;
|
||||
private final double dy;
|
||||
private final double dz;
|
||||
private final byte len;
|
||||
public PacketMatterCannon(final PacketBuffer stream) {
|
||||
this.x = stream.readFloat();
|
||||
this.y = stream.readFloat();
|
||||
this.z = stream.readFloat();
|
||||
this.dx = stream.readFloat();
|
||||
this.dy = stream.readFloat();
|
||||
this.dz = stream.readFloat();
|
||||
this.len = stream.readByte();
|
||||
}
|
||||
|
||||
public PacketMatterCannon( final PacketBuffer stream )
|
||||
{
|
||||
this.x = stream.readFloat();
|
||||
this.y = stream.readFloat();
|
||||
this.z = stream.readFloat();
|
||||
this.dx = stream.readFloat();
|
||||
this.dy = stream.readFloat();
|
||||
this.dz = stream.readFloat();
|
||||
this.len = stream.readByte();
|
||||
}
|
||||
// api
|
||||
public PacketMatterCannon(final double x, final double y, final double z, final float dx, final float dy,
|
||||
final float dz, final byte len) {
|
||||
final float dl = dx * dx + dy * dy + dz * dz;
|
||||
final float dlz = (float) Math.sqrt(dl);
|
||||
|
||||
// api
|
||||
public PacketMatterCannon( final double x, final double y, final double z, final float dx, final float dy, final float dz, final byte len )
|
||||
{
|
||||
final float dl = dx * dx + dy * dy + dz * dz;
|
||||
final float dlz = (float) Math.sqrt( dl );
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.dx = dx / dlz;
|
||||
this.dy = dy / dlz;
|
||||
this.dz = dz / dlz;
|
||||
this.len = len;
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.dx = dx / dlz;
|
||||
this.dy = dy / dlz;
|
||||
this.dz = dz / dlz;
|
||||
this.len = len;
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeFloat((float) x);
|
||||
data.writeFloat((float) y);
|
||||
data.writeFloat((float) z);
|
||||
data.writeFloat((float) this.dx);
|
||||
data.writeFloat((float) this.dy);
|
||||
data.writeFloat((float) this.dz);
|
||||
data.writeByte(len);
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeFloat( (float) x );
|
||||
data.writeFloat( (float) y );
|
||||
data.writeFloat( (float) z );
|
||||
data.writeFloat( (float) this.dx );
|
||||
data.writeFloat( (float) this.dy );
|
||||
data.writeFloat( (float) this.dz );
|
||||
data.writeByte( len );
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
|
||||
try {
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
try
|
||||
{
|
||||
final World world = Minecraft.getInstance().world;
|
||||
for (int a = 1; a < this.len; a++) {
|
||||
// FIXME final MatterCannonFX fx = new MatterCannonFX( world, this.x + this.dx *
|
||||
// a, this.y + this.dy * a, this.z + this.dz * a, new ItemStack( Items.DIAMOND )
|
||||
// );
|
||||
|
||||
final World world = Minecraft.getInstance().world;
|
||||
for( int a = 1; a < this.len; a++ )
|
||||
{
|
||||
// FIXME final MatterCannonFX fx = new MatterCannonFX( world, this.x + this.dx * a, this.y + this.dy * a, this.z + this.dz * a, new ItemStack( Items.DIAMOND ) );
|
||||
|
||||
// FIXME Minecraft.getInstance().particles.addEffect( fx );
|
||||
}
|
||||
}
|
||||
catch( final Exception ignored )
|
||||
{
|
||||
}
|
||||
}
|
||||
// FIXME Minecraft.getInstance().particles.addEffect( fx );
|
||||
}
|
||||
} catch (final Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -32,43 +31,38 @@ import appeng.core.AppEng;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
|
||||
public class PacketMockExplosion extends AppEngPacket {
|
||||
|
||||
public class PacketMockExplosion extends AppEngPacket
|
||||
{
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
public PacketMockExplosion(final PacketBuffer stream) {
|
||||
this.x = stream.readDouble();
|
||||
this.y = stream.readDouble();
|
||||
this.z = stream.readDouble();
|
||||
}
|
||||
|
||||
public PacketMockExplosion( final PacketBuffer stream )
|
||||
{
|
||||
this.x = stream.readDouble();
|
||||
this.y = stream.readDouble();
|
||||
this.z = stream.readDouble();
|
||||
}
|
||||
// api
|
||||
public PacketMockExplosion(final double x, final double y, final double z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
// api
|
||||
public PacketMockExplosion( final double x, final double y, final double z )
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeDouble(x);
|
||||
data.writeDouble(y);
|
||||
data.writeDouble(z);
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeDouble( x );
|
||||
data.writeDouble( y );
|
||||
data.writeDouble( z );
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
final World world = AppEng.proxy.getWorld();
|
||||
world.addParticle( ParticleTypes.EXPLOSION, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D );
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
|
||||
final World world = AppEng.proxy.getWorld();
|
||||
world.addParticle(ParticleTypes.EXPLOSION, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -30,39 +29,34 @@ import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.hooks.TickHandler.PlayerColor;
|
||||
|
||||
public class PacketPaintedEntity extends AppEngPacket {
|
||||
|
||||
public class PacketPaintedEntity extends AppEngPacket
|
||||
{
|
||||
private final AEColor myColor;
|
||||
private final int entityId;
|
||||
private int ticks;
|
||||
|
||||
private final AEColor myColor;
|
||||
private final int entityId;
|
||||
private int ticks;
|
||||
public PacketPaintedEntity(final PacketBuffer stream) {
|
||||
this.entityId = stream.readInt();
|
||||
this.myColor = AEColor.values()[stream.readByte()];
|
||||
this.ticks = stream.readInt();
|
||||
}
|
||||
|
||||
public PacketPaintedEntity( final PacketBuffer stream )
|
||||
{
|
||||
this.entityId = stream.readInt();
|
||||
this.myColor = AEColor.values()[stream.readByte()];
|
||||
this.ticks = stream.readInt();
|
||||
}
|
||||
// api
|
||||
public PacketPaintedEntity(final int myEntity, final AEColor myColor, final int ticksLeft) {
|
||||
|
||||
// api
|
||||
public PacketPaintedEntity( final int myEntity, final AEColor myColor, final int ticksLeft )
|
||||
{
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeInt(this.entityId = myEntity);
|
||||
data.writeByte((this.myColor = myColor).ordinal());
|
||||
data.writeInt(ticksLeft);
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( this.entityId = myEntity );
|
||||
data.writeByte( ( this.myColor = myColor ).ordinal() );
|
||||
data.writeInt( ticksLeft );
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
final PlayerColor pc = new PlayerColor( this.entityId, this.myColor, this.ticks );
|
||||
TickHandler.INSTANCE.getPlayerColors().put( this.entityId, pc );
|
||||
}
|
||||
@Override
|
||||
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
|
||||
final PlayerColor pc = new PlayerColor(this.entityId, this.myColor, this.ticks);
|
||||
TickHandler.INSTANCE.getPlayerColors().put(this.entityId, pc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -33,52 +32,47 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.parts.PartPlacement;
|
||||
|
||||
public class PacketPartPlacement extends AppEngPacket {
|
||||
|
||||
public class PacketPartPlacement extends AppEngPacket
|
||||
{
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private int face;
|
||||
private float eyeHeight;
|
||||
private Hand hand;
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private int face;
|
||||
private float eyeHeight;
|
||||
private Hand hand;
|
||||
public PacketPartPlacement(final PacketBuffer stream) {
|
||||
this.x = stream.readInt();
|
||||
this.y = stream.readInt();
|
||||
this.z = stream.readInt();
|
||||
this.face = stream.readByte();
|
||||
this.eyeHeight = stream.readFloat();
|
||||
this.hand = Hand.values()[stream.readByte()];
|
||||
}
|
||||
|
||||
public PacketPartPlacement( final PacketBuffer stream )
|
||||
{
|
||||
this.x = stream.readInt();
|
||||
this.y = stream.readInt();
|
||||
this.z = stream.readInt();
|
||||
this.face = stream.readByte();
|
||||
this.eyeHeight = stream.readFloat();
|
||||
this.hand = Hand.values()[stream.readByte()];
|
||||
}
|
||||
// api
|
||||
public PacketPartPlacement(final BlockPos pos, final Direction face, final float eyeHeight, final Hand hand) {
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
// api
|
||||
public PacketPartPlacement( final BlockPos pos, final Direction face, final float eyeHeight, final Hand hand )
|
||||
{
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeInt(pos.getX());
|
||||
data.writeInt(pos.getY());
|
||||
data.writeInt(pos.getZ());
|
||||
data.writeByte(face.ordinal());
|
||||
data.writeFloat(eyeHeight);
|
||||
data.writeByte(hand.ordinal());
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( pos.getX() );
|
||||
data.writeInt( pos.getY() );
|
||||
data.writeInt( pos.getZ() );
|
||||
data.writeByte( face.ordinal() );
|
||||
data.writeFloat( eyeHeight );
|
||||
data.writeByte( hand.ordinal() );
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final ServerPlayerEntity sender = (ServerPlayerEntity) player;
|
||||
AppEng.proxy.updateRenderMode( sender );
|
||||
PartPlacement.setEyeHeight( this.eyeHeight );
|
||||
PartPlacement.place( sender.getHeldItem( this.hand ), new BlockPos( this.x, this.y, this.z ), Direction.values()[this.face], sender, this.hand,
|
||||
sender.world,
|
||||
PartPlacement.PlaceType.INTERACT_FIRST_PASS, 0 );
|
||||
AppEng.proxy.updateRenderMode( null );
|
||||
}
|
||||
@Override
|
||||
public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) {
|
||||
final ServerPlayerEntity sender = (ServerPlayerEntity) player;
|
||||
AppEng.proxy.updateRenderMode(sender);
|
||||
PartPlacement.setEyeHeight(this.eyeHeight);
|
||||
PartPlacement.place(sender.getHeldItem(this.hand), new BlockPos(this.x, this.y, this.z),
|
||||
Direction.values()[this.face], sender, this.hand, sender.world,
|
||||
PartPlacement.PlaceType.INTERACT_FIRST_PASS, 0);
|
||||
AppEng.proxy.updateRenderMode(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
@@ -36,85 +35,72 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class PacketPatternSlot extends AppEngPacket {
|
||||
|
||||
public class PacketPatternSlot extends AppEngPacket
|
||||
{
|
||||
public final IAEItemStack slotItem;
|
||||
|
||||
public final IAEItemStack slotItem;
|
||||
public final IAEItemStack[] pattern = new IAEItemStack[9];
|
||||
|
||||
public final IAEItemStack[] pattern = new IAEItemStack[9];
|
||||
public final boolean shift;
|
||||
|
||||
public final boolean shift;
|
||||
public PacketPatternSlot(final PacketBuffer stream) {
|
||||
|
||||
public PacketPatternSlot( final PacketBuffer stream )
|
||||
{
|
||||
this.shift = stream.readBoolean();
|
||||
|
||||
this.shift = stream.readBoolean();
|
||||
this.slotItem = this.readItem(stream);
|
||||
|
||||
this.slotItem = this.readItem( stream );
|
||||
for (int x = 0; x < 9; x++) {
|
||||
this.pattern[x] = this.readItem(stream);
|
||||
}
|
||||
}
|
||||
|
||||
for( int x = 0; x < 9; x++ )
|
||||
{
|
||||
this.pattern[x] = this.readItem( stream );
|
||||
}
|
||||
}
|
||||
private IAEItemStack readItem(final PacketBuffer stream) {
|
||||
final boolean hasItem = stream.readBoolean();
|
||||
|
||||
private IAEItemStack readItem( final PacketBuffer stream )
|
||||
{
|
||||
final boolean hasItem = stream.readBoolean();
|
||||
if (hasItem) {
|
||||
return AEItemStack.fromPacket(stream);
|
||||
}
|
||||
|
||||
if( hasItem )
|
||||
{
|
||||
return AEItemStack.fromPacket( stream );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
// api
|
||||
public PacketPatternSlot(final IItemHandler pat, final IAEItemStack slotItem, final boolean shift) {
|
||||
|
||||
// api
|
||||
public PacketPatternSlot( final IItemHandler pat, final IAEItemStack slotItem, final boolean shift )
|
||||
{
|
||||
this.slotItem = slotItem;
|
||||
this.shift = shift;
|
||||
|
||||
this.slotItem = slotItem;
|
||||
this.shift = shift;
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt(this.getPacketID());
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeBoolean(shift);
|
||||
|
||||
data.writeBoolean( shift );
|
||||
this.writeItem(slotItem, data);
|
||||
for (int x = 0; x < 9; x++) {
|
||||
this.pattern[x] = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
.createStack(pat.getStackInSlot(x));
|
||||
this.writeItem(this.pattern[x], data);
|
||||
}
|
||||
|
||||
this.writeItem( slotItem, data );
|
||||
for( int x = 0; x < 9; x++ )
|
||||
{
|
||||
this.pattern[x] = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( pat.getStackInSlot( x ) );
|
||||
this.writeItem( this.pattern[x], data );
|
||||
}
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
private void writeItem(final IAEItemStack slotItem, final PacketBuffer data) {
|
||||
if (slotItem == null) {
|
||||
data.writeBoolean(false);
|
||||
} else {
|
||||
data.writeBoolean(true);
|
||||
slotItem.writeToPacket(data);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeItem( final IAEItemStack slotItem, final PacketBuffer data )
|
||||
{
|
||||
if( slotItem == null )
|
||||
{
|
||||
data.writeBoolean( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
data.writeBoolean( true );
|
||||
slotItem.writeToPacket( data );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final ServerPlayerEntity sender = (ServerPlayerEntity) player;
|
||||
if( sender.openContainer instanceof ContainerPatternTerm )
|
||||
{
|
||||
final ContainerPatternTerm patternTerminal = (ContainerPatternTerm) sender.openContainer;
|
||||
patternTerminal.craftOrGetItem( this );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) {
|
||||
final ServerPlayerEntity sender = (ServerPlayerEntity) player;
|
||||
if (sender.openContainer instanceof ContainerPatternTerm) {
|
||||
final ContainerPatternTerm patternTerminal = (ContainerPatternTerm) sender.openContainer;
|
||||
patternTerminal.craftOrGetItem(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -29,51 +28,43 @@ import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
|
||||
public class PacketProgressBar extends AppEngPacket {
|
||||
|
||||
public class PacketProgressBar extends AppEngPacket
|
||||
{
|
||||
private final short id;
|
||||
private final long value;
|
||||
|
||||
private final short id;
|
||||
private final long value;
|
||||
public PacketProgressBar(final PacketBuffer stream) {
|
||||
this.id = stream.readShort();
|
||||
this.value = stream.readLong();
|
||||
}
|
||||
|
||||
public PacketProgressBar( final PacketBuffer stream )
|
||||
{
|
||||
this.id = stream.readShort();
|
||||
this.value = stream.readLong();
|
||||
}
|
||||
// api
|
||||
public PacketProgressBar(final int shortID, final long value) {
|
||||
this.id = (short) shortID;
|
||||
this.value = value;
|
||||
|
||||
// api
|
||||
public PacketProgressBar( final int shortID, final long value )
|
||||
{
|
||||
this.id = (short) shortID;
|
||||
this.value = value;
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeShort(shortID);
|
||||
data.writeLong(value);
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeShort( shortID );
|
||||
data.writeLong( value );
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
@Override
|
||||
public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) {
|
||||
final Container c = player.openContainer;
|
||||
if (c instanceof AEBaseContainer) {
|
||||
((AEBaseContainer) c).updateFullProgressBar(this.id, this.value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final Container c = player.openContainer;
|
||||
if( c instanceof AEBaseContainer )
|
||||
{
|
||||
( (AEBaseContainer) c ).updateFullProgressBar( this.id, this.value );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
final Container c = player.openContainer;
|
||||
if( c instanceof AEBaseContainer )
|
||||
{
|
||||
( (AEBaseContainer) c ).updateFullProgressBar( this.id, this.value );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
|
||||
final Container c = player.openContainer;
|
||||
if (c instanceof AEBaseContainer) {
|
||||
((AEBaseContainer) c).updateFullProgressBar(this.id, this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -28,37 +27,31 @@ import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
|
||||
public class PacketSwapSlots extends AppEngPacket {
|
||||
|
||||
public class PacketSwapSlots extends AppEngPacket
|
||||
{
|
||||
private final int slotA;
|
||||
private final int slotB;
|
||||
|
||||
private final int slotA;
|
||||
private final int slotB;
|
||||
public PacketSwapSlots(final PacketBuffer stream) {
|
||||
this.slotA = stream.readInt();
|
||||
this.slotB = stream.readInt();
|
||||
}
|
||||
|
||||
public PacketSwapSlots( final PacketBuffer stream )
|
||||
{
|
||||
this.slotA = stream.readInt();
|
||||
this.slotB = stream.readInt();
|
||||
}
|
||||
// api
|
||||
public PacketSwapSlots(final int slotA, final int slotB) {
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
// api
|
||||
public PacketSwapSlots( final int slotA, final int slotB )
|
||||
{
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeInt(this.slotA = slotA);
|
||||
data.writeInt(this.slotB = slotB);
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( this.slotA = slotA );
|
||||
data.writeInt( this.slotB = slotB );
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
if( player != null && player.openContainer instanceof AEBaseContainer )
|
||||
{
|
||||
( (AEBaseContainer) player.openContainer ).swapSlotContents( this.slotA, this.slotB );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) {
|
||||
if (player != null && player.openContainer instanceof AEBaseContainer) {
|
||||
((AEBaseContainer) player.openContainer).swapSlotContents(this.slotA, this.slotB);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import appeng.container.ContainerOpener;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -27,51 +25,44 @@ import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class PacketSwitchGuis extends AppEngPacket {
|
||||
|
||||
public class PacketSwitchGuis extends AppEngPacket
|
||||
{
|
||||
private final ContainerType<?> newGui;
|
||||
|
||||
private final ContainerType<?> newGui;
|
||||
public PacketSwitchGuis(final PacketBuffer stream) {
|
||||
this.newGui = ForgeRegistries.CONTAINERS.getValue(stream.readResourceLocation());
|
||||
}
|
||||
|
||||
public PacketSwitchGuis( final PacketBuffer stream )
|
||||
{
|
||||
this.newGui = ForgeRegistries.CONTAINERS.getValue(stream.readResourceLocation());
|
||||
}
|
||||
// api
|
||||
public PacketSwitchGuis(final ContainerType<?> newGui) {
|
||||
this.newGui = newGui;
|
||||
|
||||
// api
|
||||
public PacketSwitchGuis( final ContainerType<?> newGui )
|
||||
{
|
||||
this.newGui = newGui;
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeResourceLocation(newGui.getRegistryName());
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeResourceLocation(newGui.getRegistryName());
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final Container c = player.openContainer;
|
||||
if( c instanceof AEBaseContainer )
|
||||
{
|
||||
final AEBaseContainer bc = (AEBaseContainer) c;
|
||||
final ContainerLocator locator = bc.getLocator();
|
||||
if( locator != null )
|
||||
{
|
||||
ContainerOpener.openContainer(newGui, player, locator);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) {
|
||||
final Container c = player.openContainer;
|
||||
if (c instanceof AEBaseContainer) {
|
||||
final AEBaseContainer bc = (AEBaseContainer) c;
|
||||
final ContainerLocator locator = bc.getLocator();
|
||||
if (locator != null) {
|
||||
ContainerOpener.openContainer(newGui, player, locator);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,93 +1,76 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2018, 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.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.fluids.container.ContainerFluidTerminal;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv6 - 23/05/2018
|
||||
* @since rv6 23/05/2018
|
||||
*/
|
||||
public class PacketTargetFluidStack extends AppEngPacket
|
||||
{
|
||||
private AEFluidStack stack;
|
||||
|
||||
public PacketTargetFluidStack( final PacketBuffer stream )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( stream.readableBytes() > 0 )
|
||||
{
|
||||
this.stack = (AEFluidStack) AEFluidStack.fromPacket( stream );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.stack = null;
|
||||
}
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
AELog.debug( ex );
|
||||
this.stack = null;
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketTargetFluidStack( AEFluidStack stack )
|
||||
{
|
||||
|
||||
this.stack = stack;
|
||||
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt( this.getPacketID() );
|
||||
if( stack != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
stack.writeToPacket( data );
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
AELog.debug( ex );
|
||||
}
|
||||
}
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
if( player.openContainer instanceof ContainerFluidTerminal )
|
||||
{
|
||||
( (ContainerFluidTerminal) player.openContainer ).setTargetStack( this.stack );
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2018, 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.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.fluids.container.ContainerFluidTerminal;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv6 - 23/05/2018
|
||||
* @since rv6 23/05/2018
|
||||
*/
|
||||
public class PacketTargetFluidStack extends AppEngPacket {
|
||||
private AEFluidStack stack;
|
||||
|
||||
public PacketTargetFluidStack(final PacketBuffer stream) {
|
||||
try {
|
||||
if (stream.readableBytes() > 0) {
|
||||
this.stack = (AEFluidStack) AEFluidStack.fromPacket(stream);
|
||||
} else {
|
||||
this.stack = null;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
AELog.debug(ex);
|
||||
this.stack = null;
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketTargetFluidStack(AEFluidStack stack) {
|
||||
|
||||
this.stack = stack;
|
||||
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
data.writeInt(this.getPacketID());
|
||||
if (stack != null) {
|
||||
try {
|
||||
stack.writeToPacket(data);
|
||||
} catch (Exception ex) {
|
||||
AELog.debug(ex);
|
||||
}
|
||||
}
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) {
|
||||
if (player.openContainer instanceof ContainerFluidTerminal) {
|
||||
((ContainerFluidTerminal) player.openContainer).setTargetStack(this.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -30,59 +29,43 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class PacketTargetItemStack extends AppEngPacket {
|
||||
private AEItemStack stack;
|
||||
|
||||
public class PacketTargetItemStack extends AppEngPacket
|
||||
{
|
||||
private AEItemStack stack;
|
||||
public PacketTargetItemStack(final PacketBuffer stream) {
|
||||
try {
|
||||
if (stream.readableBytes() > 0) {
|
||||
this.stack = AEItemStack.fromPacket(stream);
|
||||
} else {
|
||||
this.stack = null;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
AELog.debug(ex);
|
||||
this.stack = null;
|
||||
}
|
||||
}
|
||||
|
||||
public PacketTargetItemStack( final PacketBuffer stream )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( stream.readableBytes() > 0 )
|
||||
{
|
||||
this.stack = AEItemStack.fromPacket( stream );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.stack = null;
|
||||
}
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
AELog.debug( ex );
|
||||
this.stack = null;
|
||||
}
|
||||
}
|
||||
// api
|
||||
public PacketTargetItemStack(AEItemStack stack) {
|
||||
|
||||
// api
|
||||
public PacketTargetItemStack( AEItemStack stack )
|
||||
{
|
||||
this.stack = stack;
|
||||
|
||||
this.stack = stack;
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
data.writeInt(this.getPacketID());
|
||||
if (stack != null) {
|
||||
try {
|
||||
stack.writeToPacket(data);
|
||||
} catch (Exception ex) {
|
||||
AELog.debug(ex);
|
||||
}
|
||||
}
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt( this.getPacketID() );
|
||||
if( stack != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
stack.writeToPacket( data );
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
AELog.debug( ex );
|
||||
}
|
||||
}
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
if( player.openContainer instanceof AEBaseContainer )
|
||||
{
|
||||
( (AEBaseContainer) player.openContainer ).setTargetStack( this.stack );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) {
|
||||
if (player.openContainer instanceof AEBaseContainer) {
|
||||
((AEBaseContainer) player.openContainer).setTargetStack(this.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -43,83 +42,78 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PacketTransitionEffect extends AppEngPacket {
|
||||
|
||||
public class PacketTransitionEffect extends AppEngPacket
|
||||
{
|
||||
private final boolean mode;
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
private final AEPartLocation d;
|
||||
|
||||
private final boolean mode;
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
private final AEPartLocation d;
|
||||
public PacketTransitionEffect(final PacketBuffer stream) {
|
||||
this.x = stream.readFloat();
|
||||
this.y = stream.readFloat();
|
||||
this.z = stream.readFloat();
|
||||
this.d = AEPartLocation.fromOrdinal(stream.readByte());
|
||||
this.mode = stream.readBoolean();
|
||||
}
|
||||
|
||||
public PacketTransitionEffect( final PacketBuffer stream )
|
||||
{
|
||||
this.x = stream.readFloat();
|
||||
this.y = stream.readFloat();
|
||||
this.z = stream.readFloat();
|
||||
this.d = AEPartLocation.fromOrdinal( stream.readByte() );
|
||||
this.mode = stream.readBoolean();
|
||||
}
|
||||
// api
|
||||
public PacketTransitionEffect(final double x, final double y, final double z, final AEPartLocation dir,
|
||||
final boolean wasBlock) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.d = dir;
|
||||
this.mode = wasBlock;
|
||||
|
||||
// api
|
||||
public PacketTransitionEffect( final double x, final double y, final double z, final AEPartLocation dir, final boolean wasBlock )
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.d = dir;
|
||||
this.mode = wasBlock;
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeFloat((float) x);
|
||||
data.writeFloat((float) y);
|
||||
data.writeFloat((float) z);
|
||||
data.writeByte(this.d.ordinal());
|
||||
data.writeBoolean(wasBlock);
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeFloat( (float) x );
|
||||
data.writeFloat( (float) y );
|
||||
data.writeFloat( (float) z );
|
||||
data.writeByte( this.d.ordinal() );
|
||||
data.writeBoolean( wasBlock );
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
|
||||
final World world = AppEng.proxy.getWorld();
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
final World world = AppEng.proxy.getWorld();
|
||||
for (int zz = 0; zz < (this.mode ? 32 : 8); zz++) {
|
||||
if (AppEng.proxy.shouldAddParticles(Platform.getRandom())) {
|
||||
double x = this.x + (this.mode ? (Platform.getRandomInt() % 100) * 0.01
|
||||
: (Platform.getRandomInt() % 100) * 0.005 - 0.25);
|
||||
double y = this.y + (this.mode ? (Platform.getRandomInt() % 100) * 0.01
|
||||
: (Platform.getRandomInt() % 100) * 0.005 - 0.25);
|
||||
double z = this.z + (this.mode ? (Platform.getRandomInt() % 100) * 0.01
|
||||
: (Platform.getRandomInt() % 100) * 0.005 - 0.25);
|
||||
double speedX = -0.1f * this.d.xOffset;
|
||||
double speedY = -0.1f * this.d.yOffset;
|
||||
double speedZ = -0.1f * this.d.zOffset;
|
||||
|
||||
for( int zz = 0; zz < ( this.mode ? 32 : 8 ); zz++ )
|
||||
{
|
||||
if( AppEng.proxy.shouldAddParticles( Platform.getRandom() ) )
|
||||
{
|
||||
double x = this.x + ( this.mode ? ( Platform.getRandomInt() % 100 ) * 0.01 : ( Platform.getRandomInt() % 100 ) * 0.005 - 0.25 );
|
||||
double y = this.y + ( this.mode ? ( Platform.getRandomInt() % 100 ) * 0.01 : ( Platform.getRandomInt() % 100 ) * 0.005 - 0.25 );
|
||||
double z = this.z + ( this.mode ? ( Platform.getRandomInt() % 100 ) * 0.01 : ( Platform.getRandomInt() % 100 ) * 0.005 - 0.25 );
|
||||
double speedX = -0.1f * this.d.xOffset;
|
||||
double speedY = -0.1f * this.d.yOffset;
|
||||
double speedZ = -0.1f * this.d.zOffset;
|
||||
EnergyFx fx = (EnergyFx) Minecraft.getInstance().particles.addParticle(EnergyFx.TYPE, x, y, z, speedX,
|
||||
speedY, speedZ);
|
||||
// FIXME: *sigh* custom particle data for this one thing :|
|
||||
if (!this.mode) {
|
||||
fx.fromItem(this.d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EnergyFx fx = (EnergyFx) Minecraft.getInstance().particles.addParticle(EnergyFx.TYPE, x, y, z, speedX, speedY, speedZ);
|
||||
// FIXME: *sigh* custom particle data for this one thing :|
|
||||
if( !this.mode )
|
||||
{
|
||||
fx.fromItem( this.d );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.mode) {
|
||||
final BlockPos pos = new BlockPos((int) this.x, (int) this.y, (int) this.z);
|
||||
final BlockState state = world.getBlockState(pos);
|
||||
final SoundType sound = state.getSoundType(world, pos, null);
|
||||
|
||||
if( this.mode )
|
||||
{
|
||||
final BlockPos pos = new BlockPos( (int) this.x, (int) this.y, (int) this.z );
|
||||
final BlockState state = world.getBlockState( pos );
|
||||
final SoundType sound = state.getSoundType( world, pos, null );
|
||||
|
||||
Minecraft.getInstance()
|
||||
.getSoundHandler()
|
||||
.play( new SimpleSound( sound
|
||||
.getBreakSound(), SoundCategory.BLOCKS, ( sound.getVolume() + 1.0F ) / 2.0F, sound
|
||||
.getPitch() * 0.8F, (float) this.x + 0.5F, (float) this.y + 0.5F, (float) this.z + 0.5F ) );
|
||||
}
|
||||
}
|
||||
Minecraft.getInstance().getSoundHandler()
|
||||
.play(new SimpleSound(sound.getBreakSound(), SoundCategory.BLOCKS,
|
||||
(sound.getVolume() + 1.0F) / 2.0F, sound.getPitch() * 0.8F, (float) this.x + 0.5F,
|
||||
(float) this.y + 0.5F, (float) this.z + 0.5F));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,17 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.Hand;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
@@ -41,263 +52,174 @@ import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.fluids.container.ContainerFluidLevelEmitter;
|
||||
import appeng.fluids.container.ContainerFluidStorageBus;
|
||||
import appeng.helpers.IMouseWheelItem;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.Hand;
|
||||
|
||||
import java.io.IOException;
|
||||
public class PacketValueConfig extends AppEngPacket {
|
||||
|
||||
private final String Name;
|
||||
private final String Value;
|
||||
|
||||
public class PacketValueConfig extends AppEngPacket
|
||||
{
|
||||
public PacketValueConfig(final PacketBuffer stream) {
|
||||
this.Name = stream.readString();
|
||||
this.Value = stream.readString();
|
||||
// dis.close();
|
||||
}
|
||||
|
||||
private final String Name;
|
||||
private final String Value;
|
||||
// api
|
||||
public PacketValueConfig(final String name, final String value) {
|
||||
this.Name = name;
|
||||
this.Value = value;
|
||||
|
||||
public PacketValueConfig( final PacketBuffer stream )
|
||||
{
|
||||
this.Name = stream.readString();
|
||||
this.Value = stream.readString();
|
||||
// dis.close();
|
||||
}
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
// api
|
||||
public PacketValueConfig( final String name, final String value )
|
||||
{
|
||||
this.Name = name;
|
||||
this.Value = value;
|
||||
data.writeInt(this.getPacketID());
|
||||
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
data.writeString(name);
|
||||
data.writeString(value);
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
data.writeString( name );
|
||||
data.writeString( value );
|
||||
@Override
|
||||
public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) {
|
||||
final Container c = player.openContainer;
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
if (this.Name.equals("Item") && ((!player.getHeldItem(Hand.MAIN_HAND).isEmpty()
|
||||
&& player.getHeldItem(Hand.MAIN_HAND).getItem() instanceof IMouseWheelItem)
|
||||
|| (!player.getHeldItem(Hand.OFF_HAND).isEmpty()
|
||||
&& player.getHeldItem(Hand.OFF_HAND).getItem() instanceof IMouseWheelItem))) {
|
||||
final Hand hand;
|
||||
if (!player.getHeldItem(Hand.MAIN_HAND).isEmpty()
|
||||
&& player.getHeldItem(Hand.MAIN_HAND).getItem() instanceof IMouseWheelItem) {
|
||||
hand = Hand.MAIN_HAND;
|
||||
} else if (!player.getHeldItem(Hand.OFF_HAND).isEmpty()
|
||||
&& player.getHeldItem(Hand.OFF_HAND).getItem() instanceof IMouseWheelItem) {
|
||||
hand = Hand.OFF_HAND;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final Container c = player.openContainer;
|
||||
final ItemStack is = player.getHeldItem(hand);
|
||||
final IMouseWheelItem si = (IMouseWheelItem) is.getItem();
|
||||
si.onWheel(is, this.Value.equals("WheelUp"));
|
||||
} else if (this.Name.equals("Terminal.Cpu") && c instanceof ContainerCraftingStatus) {
|
||||
final ContainerCraftingStatus qk = (ContainerCraftingStatus) c;
|
||||
qk.cycleCpu(this.Value.equals("Next"));
|
||||
} else if (this.Name.equals("Terminal.Cpu") && c instanceof ContainerCraftConfirm) {
|
||||
final ContainerCraftConfirm qk = (ContainerCraftConfirm) c;
|
||||
qk.cycleCpu(this.Value.equals("Next"));
|
||||
} else if (this.Name.equals("Terminal.Start") && c instanceof ContainerCraftConfirm) {
|
||||
final ContainerCraftConfirm qk = (ContainerCraftConfirm) c;
|
||||
qk.startJob();
|
||||
} else if (this.Name.equals("TileCrafting.Cancel") && c instanceof ContainerCraftingCPU) {
|
||||
final ContainerCraftingCPU qk = (ContainerCraftingCPU) c;
|
||||
qk.cancelCrafting();
|
||||
} else if (this.Name.equals("QuartzKnife.Name") && c instanceof ContainerQuartzKnife) {
|
||||
final ContainerQuartzKnife qk = (ContainerQuartzKnife) c;
|
||||
qk.setName(this.Value);
|
||||
} else if (this.Name.equals("TileSecurityStation.ToggleOption") && c instanceof ContainerSecurityStation) {
|
||||
final ContainerSecurityStation sc = (ContainerSecurityStation) c;
|
||||
sc.toggleSetting(this.Value, player);
|
||||
} else if (this.Name.equals("PriorityHost.Priority") && c instanceof ContainerPriority) {
|
||||
final ContainerPriority pc = (ContainerPriority) c;
|
||||
pc.setPriority(Integer.parseInt(this.Value), player);
|
||||
} else if (this.Name.equals("LevelEmitter.Value") && c instanceof ContainerLevelEmitter) {
|
||||
final ContainerLevelEmitter lvc = (ContainerLevelEmitter) c;
|
||||
lvc.setLevel(Long.parseLong(this.Value), player);
|
||||
} else if (this.Name.equals("FluidLevelEmitter.Value") && c instanceof ContainerFluidLevelEmitter) {
|
||||
final ContainerFluidLevelEmitter lvc = (ContainerFluidLevelEmitter) c;
|
||||
lvc.setLevel(Long.parseLong(this.Value), player);
|
||||
} else if (this.Name.startsWith("PatternTerminal.") && c instanceof ContainerPatternTerm) {
|
||||
final ContainerPatternTerm cpt = (ContainerPatternTerm) c;
|
||||
if (this.Name.equals("PatternTerminal.CraftMode")) {
|
||||
cpt.getPatternTerminal().setCraftingRecipe(this.Value.equals("1"));
|
||||
} else if (this.Name.equals("PatternTerminal.Encode")) {
|
||||
cpt.encode();
|
||||
} else if (this.Name.equals("PatternTerminal.Clear")) {
|
||||
cpt.clear();
|
||||
} else if (this.Name.equals("PatternTerminal.Substitute")) {
|
||||
cpt.getPatternTerminal().setSubstitution(this.Value.equals("1"));
|
||||
}
|
||||
} else if (this.Name.startsWith("StorageBus.")) {
|
||||
if (this.Name.equals("StorageBus.Action")) {
|
||||
if (this.Value.equals("Partition")) {
|
||||
if (c instanceof ContainerStorageBus) {
|
||||
((ContainerStorageBus) c).partition();
|
||||
} else if (c instanceof ContainerFluidStorageBus) {
|
||||
((ContainerFluidStorageBus) c).partition();
|
||||
}
|
||||
} else if (this.Value.equals("Clear")) {
|
||||
if (c instanceof ContainerStorageBus) {
|
||||
((ContainerStorageBus) c).clear();
|
||||
} else if (c instanceof ContainerFluidStorageBus) {
|
||||
((ContainerFluidStorageBus) c).clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (this.Name.startsWith("CellWorkbench.") && c instanceof ContainerCellWorkbench) {
|
||||
final ContainerCellWorkbench ccw = (ContainerCellWorkbench) c;
|
||||
if (this.Name.equals("CellWorkbench.Action")) {
|
||||
if (this.Value.equals("CopyMode")) {
|
||||
ccw.nextWorkBenchCopyMode();
|
||||
} else if (this.Value.equals("Partition")) {
|
||||
ccw.partition();
|
||||
} else if (this.Value.equals("Clear")) {
|
||||
ccw.clear();
|
||||
}
|
||||
} else if (this.Name.equals("CellWorkbench.Fuzzy")) {
|
||||
ccw.setFuzzy(FuzzyMode.valueOf(this.Value));
|
||||
}
|
||||
} else if (c instanceof ContainerNetworkTool) {
|
||||
if (this.Name.equals("NetworkTool") && this.Value.equals("Toggle")) {
|
||||
((ContainerNetworkTool) c).toggleFacadeMode();
|
||||
}
|
||||
} else if (c instanceof IConfigurableObject) {
|
||||
final IConfigManager cm = ((IConfigurableObject) c).getConfigManager();
|
||||
|
||||
if( this.Name.equals( "Item" ) && ( ( !player.getHeldItem( Hand.MAIN_HAND ).isEmpty() && player.getHeldItem( Hand.MAIN_HAND ).getItem() instanceof IMouseWheelItem) || ( !player.getHeldItem( Hand.OFF_HAND ).isEmpty() && player.getHeldItem( Hand.OFF_HAND ).getItem() instanceof IMouseWheelItem ) ) )
|
||||
{
|
||||
final Hand hand;
|
||||
if( !player.getHeldItem( Hand.MAIN_HAND ).isEmpty() && player.getHeldItem( Hand.MAIN_HAND ).getItem() instanceof IMouseWheelItem )
|
||||
{
|
||||
hand = Hand.MAIN_HAND;
|
||||
}
|
||||
else if( !player.getHeldItem( Hand.OFF_HAND ).isEmpty() && player.getHeldItem( Hand.OFF_HAND ).getItem() instanceof IMouseWheelItem )
|
||||
{
|
||||
hand = Hand.OFF_HAND;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (final Settings e : cm.getSettings()) {
|
||||
if (e.name().equals(this.Name)) {
|
||||
final Enum<?> def = cm.getSetting(e);
|
||||
|
||||
final ItemStack is = player.getHeldItem( hand );
|
||||
final IMouseWheelItem si = (IMouseWheelItem) is.getItem();
|
||||
si.onWheel( is, this.Value.equals( "WheelUp" ) );
|
||||
}
|
||||
else if( this.Name.equals( "Terminal.Cpu" ) && c instanceof ContainerCraftingStatus)
|
||||
{
|
||||
final ContainerCraftingStatus qk = (ContainerCraftingStatus) c;
|
||||
qk.cycleCpu( this.Value.equals( "Next" ) );
|
||||
}
|
||||
else if( this.Name.equals( "Terminal.Cpu" ) && c instanceof ContainerCraftConfirm )
|
||||
{
|
||||
final ContainerCraftConfirm qk = (ContainerCraftConfirm) c;
|
||||
qk.cycleCpu( this.Value.equals( "Next" ) );
|
||||
}
|
||||
else if( this.Name.equals( "Terminal.Start" ) && c instanceof ContainerCraftConfirm )
|
||||
{
|
||||
final ContainerCraftConfirm qk = (ContainerCraftConfirm) c;
|
||||
qk.startJob();
|
||||
}
|
||||
else if( this.Name.equals( "TileCrafting.Cancel" ) && c instanceof ContainerCraftingCPU )
|
||||
{
|
||||
final ContainerCraftingCPU qk = (ContainerCraftingCPU) c;
|
||||
qk.cancelCrafting();
|
||||
}
|
||||
else if( this.Name.equals( "QuartzKnife.Name" ) && c instanceof ContainerQuartzKnife )
|
||||
{
|
||||
final ContainerQuartzKnife qk = (ContainerQuartzKnife) c;
|
||||
qk.setName( this.Value );
|
||||
}
|
||||
else if( this.Name.equals( "TileSecurityStation.ToggleOption" ) && c instanceof ContainerSecurityStation )
|
||||
{
|
||||
final ContainerSecurityStation sc = (ContainerSecurityStation) c;
|
||||
sc.toggleSetting( this.Value, player );
|
||||
}
|
||||
else if( this.Name.equals( "PriorityHost.Priority" ) && c instanceof ContainerPriority )
|
||||
{
|
||||
final ContainerPriority pc = (ContainerPriority) c;
|
||||
pc.setPriority( Integer.parseInt( this.Value ), player );
|
||||
}
|
||||
else if( this.Name.equals( "LevelEmitter.Value" ) && c instanceof ContainerLevelEmitter )
|
||||
{
|
||||
final ContainerLevelEmitter lvc = (ContainerLevelEmitter) c;
|
||||
lvc.setLevel( Long.parseLong( this.Value ), player );
|
||||
}
|
||||
else if( this.Name.equals( "FluidLevelEmitter.Value" ) && c instanceof ContainerFluidLevelEmitter)
|
||||
{
|
||||
final ContainerFluidLevelEmitter lvc = (ContainerFluidLevelEmitter) c;
|
||||
lvc.setLevel( Long.parseLong( this.Value ), player );
|
||||
}
|
||||
else if( this.Name.startsWith( "PatternTerminal." ) && c instanceof ContainerPatternTerm )
|
||||
{
|
||||
final ContainerPatternTerm cpt = (ContainerPatternTerm) c;
|
||||
if( this.Name.equals( "PatternTerminal.CraftMode" ) )
|
||||
{
|
||||
cpt.getPatternTerminal().setCraftingRecipe( this.Value.equals( "1" ) );
|
||||
}
|
||||
else if( this.Name.equals( "PatternTerminal.Encode" ) )
|
||||
{
|
||||
cpt.encode();
|
||||
}
|
||||
else if( this.Name.equals( "PatternTerminal.Clear" ) )
|
||||
{
|
||||
cpt.clear();
|
||||
}
|
||||
else if( this.Name.equals( "PatternTerminal.Substitute" ) )
|
||||
{
|
||||
cpt.getPatternTerminal().setSubstitution( this.Value.equals( "1" ) );
|
||||
}
|
||||
}
|
||||
else if( this.Name.startsWith( "StorageBus." ) )
|
||||
{
|
||||
if( this.Name.equals( "StorageBus.Action" ) )
|
||||
{
|
||||
if( this.Value.equals( "Partition" ) )
|
||||
{
|
||||
if( c instanceof ContainerStorageBus )
|
||||
{
|
||||
( (ContainerStorageBus) c ).partition();
|
||||
}
|
||||
else if( c instanceof ContainerFluidStorageBus)
|
||||
{
|
||||
( (ContainerFluidStorageBus) c ).partition();
|
||||
}
|
||||
}
|
||||
else if( this.Value.equals( "Clear" ) )
|
||||
{
|
||||
if( c instanceof ContainerStorageBus )
|
||||
{
|
||||
( (ContainerStorageBus) c ).clear();
|
||||
}
|
||||
else if( c instanceof ContainerFluidStorageBus )
|
||||
{
|
||||
( (ContainerFluidStorageBus) c ).clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( this.Name.startsWith( "CellWorkbench." ) && c instanceof ContainerCellWorkbench )
|
||||
{
|
||||
final ContainerCellWorkbench ccw = (ContainerCellWorkbench) c;
|
||||
if( this.Name.equals( "CellWorkbench.Action" ) )
|
||||
{
|
||||
if( this.Value.equals( "CopyMode" ) )
|
||||
{
|
||||
ccw.nextWorkBenchCopyMode();
|
||||
}
|
||||
else if( this.Value.equals( "Partition" ) )
|
||||
{
|
||||
ccw.partition();
|
||||
}
|
||||
else if( this.Value.equals( "Clear" ) )
|
||||
{
|
||||
ccw.clear();
|
||||
}
|
||||
}
|
||||
else if( this.Name.equals( "CellWorkbench.Fuzzy" ) )
|
||||
{
|
||||
ccw.setFuzzy( FuzzyMode.valueOf( this.Value ) );
|
||||
}
|
||||
}
|
||||
else if( c instanceof ContainerNetworkTool )
|
||||
{
|
||||
if( this.Name.equals( "NetworkTool" ) && this.Value.equals( "Toggle" ) )
|
||||
{
|
||||
( (ContainerNetworkTool) c ).toggleFacadeMode();
|
||||
}
|
||||
}
|
||||
else if( c instanceof IConfigurableObject)
|
||||
{
|
||||
final IConfigManager cm = ( (IConfigurableObject) c ).getConfigManager();
|
||||
try {
|
||||
cm.putSetting(e, Enum.valueOf(def.getClass(), this.Value));
|
||||
} catch (final IllegalArgumentException err) {
|
||||
// :P
|
||||
}
|
||||
|
||||
for( final Settings e : cm.getSettings() )
|
||||
{
|
||||
if( e.name().equals( this.Name ) )
|
||||
{
|
||||
final Enum<?> def = cm.getSetting( e );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
cm.putSetting( e, Enum.valueOf( def.getClass(), this.Value ) );
|
||||
}
|
||||
catch( final IllegalArgumentException err )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@Override
|
||||
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
|
||||
final Container c = player.openContainer;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.Name.equals("CustomName") && c instanceof AEBaseContainer) {
|
||||
((AEBaseContainer) c).setCustomName(this.Value);
|
||||
} else if (this.Name.startsWith("SyncDat.")) {
|
||||
((AEBaseContainer) c).stringSync(Integer.parseInt(this.Name.substring(8)), this.Value);
|
||||
} else if (this.Name.equals("CraftingStatus") && this.Value.equals("Clear")) {
|
||||
final Screen gs = Minecraft.getInstance().currentScreen;
|
||||
if (gs instanceof GuiCraftingCPU) {
|
||||
((GuiCraftingCPU) gs).clearItems();
|
||||
}
|
||||
} else if (c instanceof IConfigurableObject) {
|
||||
final IConfigManager cm = ((IConfigurableObject) c).getConfigManager();
|
||||
|
||||
@Override
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
final Container c = player.openContainer;
|
||||
for (final Settings e : cm.getSettings()) {
|
||||
if (e.name().equals(this.Name)) {
|
||||
final Enum<?> def = cm.getSetting(e);
|
||||
|
||||
if( this.Name.equals( "CustomName" ) && c instanceof AEBaseContainer)
|
||||
{
|
||||
( (AEBaseContainer) c ).setCustomName( this.Value );
|
||||
}
|
||||
else if( this.Name.startsWith( "SyncDat." ) )
|
||||
{
|
||||
( (AEBaseContainer) c ).stringSync( Integer.parseInt( this.Name.substring( 8 ) ), this.Value );
|
||||
}
|
||||
else if( this.Name.equals( "CraftingStatus" ) && this.Value.equals( "Clear" ) )
|
||||
{
|
||||
final Screen gs = Minecraft.getInstance().currentScreen;
|
||||
if( gs instanceof GuiCraftingCPU)
|
||||
{
|
||||
( (GuiCraftingCPU) gs ).clearItems();
|
||||
}
|
||||
}
|
||||
else if( c instanceof IConfigurableObject )
|
||||
{
|
||||
final IConfigManager cm = ( (IConfigurableObject) c ).getConfigManager();
|
||||
try {
|
||||
cm.putSetting(e, Enum.valueOf(def.getClass(), this.Value));
|
||||
} catch (final IllegalArgumentException err) {
|
||||
// :P
|
||||
}
|
||||
|
||||
for( final Settings e : cm.getSettings() )
|
||||
{
|
||||
if( e.name().equals( this.Name ) )
|
||||
{
|
||||
final Enum<?> def = cm.getSetting( e );
|
||||
|
||||
try
|
||||
{
|
||||
cm.putSetting( e, Enum.valueOf( def.getClass(), this.Value ) );
|
||||
}
|
||||
catch( final IllegalArgumentException err )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.core.worlddata;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -27,28 +26,24 @@ import com.google.common.base.Preconditions;
|
||||
|
||||
import appeng.services.CompassService;
|
||||
|
||||
|
||||
/**
|
||||
* @author thatsIch
|
||||
* @version rv3 - 30.05.2015
|
||||
* @since rv3 30.05.2015
|
||||
*/
|
||||
final class CompassData implements IWorldCompassData
|
||||
{
|
||||
@Nonnull
|
||||
private final CompassService service;
|
||||
final class CompassData implements IWorldCompassData {
|
||||
@Nonnull
|
||||
private final CompassService service;
|
||||
|
||||
public CompassData( @Nonnull final CompassService service )
|
||||
{
|
||||
Preconditions.checkNotNull( service );
|
||||
public CompassData(@Nonnull final CompassService service) {
|
||||
Preconditions.checkNotNull(service);
|
||||
|
||||
this.service = service;
|
||||
}
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompassService service()
|
||||
{
|
||||
return this.service;
|
||||
}
|
||||
@Override
|
||||
public CompassService service() {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,16 +18,13 @@
|
||||
|
||||
package appeng.core.worlddata;
|
||||
|
||||
|
||||
import appeng.services.CompassService;
|
||||
|
||||
|
||||
/**
|
||||
* @author thatsIch
|
||||
* @version rv3 - 30.05.2015
|
||||
* @since rv3 30.05.2015
|
||||
*/
|
||||
public interface IWorldCompassData
|
||||
{
|
||||
CompassService service();
|
||||
public interface IWorldCompassData {
|
||||
CompassService service();
|
||||
}
|
||||
|
||||
@@ -18,27 +18,24 @@
|
||||
|
||||
package appeng.core.worlddata;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
/**
|
||||
* @author thatsIch
|
||||
* @version rv3 - 02.11.2015
|
||||
* @since rv3 30.05.2015
|
||||
*/
|
||||
public interface IWorldData
|
||||
{
|
||||
void onServerStopping();
|
||||
public interface IWorldData {
|
||||
void onServerStopping();
|
||||
|
||||
void onServerStoppped();
|
||||
void onServerStoppped();
|
||||
|
||||
@Nonnull
|
||||
IWorldGridStorageData storageData();
|
||||
@Nonnull
|
||||
IWorldGridStorageData storageData();
|
||||
|
||||
@Nonnull
|
||||
IWorldPlayerData playerData();
|
||||
@Nonnull
|
||||
IWorldPlayerData playerData();
|
||||
|
||||
@Nonnull
|
||||
IWorldCompassData compassData();
|
||||
@Nonnull
|
||||
IWorldCompassData compassData();
|
||||
}
|
||||
|
||||
@@ -18,26 +18,23 @@
|
||||
|
||||
package appeng.core.worlddata;
|
||||
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.network.NetworkManager;
|
||||
|
||||
import appeng.api.util.WorldCoord;
|
||||
|
||||
|
||||
/**
|
||||
* @author thatsIch
|
||||
* @version rv3 - 30.05.2015
|
||||
* @since rv3 30.05.2015
|
||||
*/
|
||||
public interface IWorldDimensionData
|
||||
{
|
||||
void addStorageCell( int newStorageCellID );
|
||||
public interface IWorldDimensionData {
|
||||
void addStorageCell(int newStorageCellID);
|
||||
|
||||
WorldCoord getStoredSize( int dim );
|
||||
WorldCoord getStoredSize(int dim);
|
||||
|
||||
void setStoredSize( int dim, int targetX, int targetY, int targetZ );
|
||||
void setStoredSize(int dim, int targetX, int targetY, int targetZ);
|
||||
|
||||
void sendToPlayer( @Nullable NetworkManager manager );
|
||||
void sendToPlayer(@Nullable NetworkManager manager);
|
||||
}
|
||||
|
||||
@@ -18,26 +18,23 @@
|
||||
|
||||
package appeng.core.worlddata;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.me.GridStorage;
|
||||
|
||||
|
||||
/**
|
||||
* @author thatsIch
|
||||
* @version rv3 - 30.05.2015
|
||||
* @since rv3 30.05.2015
|
||||
*/
|
||||
public interface IWorldGridStorageData
|
||||
{
|
||||
GridStorage getGridStorage( long storageID );
|
||||
public interface IWorldGridStorageData {
|
||||
GridStorage getGridStorage(long storageID);
|
||||
|
||||
@Nonnull
|
||||
GridStorage getNewGridStorage();
|
||||
@Nonnull
|
||||
GridStorage getNewGridStorage();
|
||||
|
||||
void destroyGridStorage( long id );
|
||||
void destroyGridStorage(long id);
|
||||
|
||||
int getNextOrderedValue( String name, int firstValue );
|
||||
int getNextOrderedValue(String name, int firstValue);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.worlddata;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -25,23 +26,22 @@ import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
/**
|
||||
* @author thatsIch
|
||||
* @version rv3 - 30.05.2015
|
||||
* @since rv3 30.05.2015
|
||||
*/
|
||||
public interface IWorldPlayerData
|
||||
{
|
||||
/**
|
||||
* Gets the UUID of the Minecraft profile associated with the given ME player id.
|
||||
* @param playerID An ME player id.
|
||||
* @return Null if the ME player id is unknown, otherwise the unique id of the Minecraft profile it originates from.
|
||||
*/
|
||||
@Nullable
|
||||
UUID getProfileId(int playerID );
|
||||
public interface IWorldPlayerData {
|
||||
/**
|
||||
* Gets the UUID of the Minecraft profile associated with the given ME player
|
||||
* id.
|
||||
*
|
||||
* @param playerID An ME player id.
|
||||
* @return Null if the ME player id is unknown, otherwise the unique id of the
|
||||
* Minecraft profile it originates from.
|
||||
*/
|
||||
@Nullable
|
||||
UUID getProfileId(int playerID);
|
||||
|
||||
int getMePlayerId(GameProfile profile );
|
||||
int getMePlayerId(GameProfile profile);
|
||||
}
|
||||
|
||||
@@ -18,25 +18,22 @@
|
||||
|
||||
package appeng.core.worlddata;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.world.dimension.Dimension;
|
||||
|
||||
|
||||
/**
|
||||
* @author thatsIch
|
||||
* @version rv3 - 30.05.2015
|
||||
* @since rv3 30.05.2015
|
||||
*/
|
||||
public interface IWorldSpawnData
|
||||
{
|
||||
void setGenerated( Dimension dim, int chunkX, int chunkZ );
|
||||
public interface IWorldSpawnData {
|
||||
void setGenerated(Dimension dim, int chunkX, int chunkZ);
|
||||
|
||||
boolean hasGenerated( Dimension dim, int chunkX, int chunkZ );
|
||||
boolean hasGenerated(Dimension dim, int chunkX, int chunkZ);
|
||||
|
||||
boolean addNearByMeteorites( Dimension dim, int chunkX, int chunkZ, CompoundNBT newData );
|
||||
boolean addNearByMeteorites(Dimension dim, int chunkX, int chunkZ, CompoundNBT newData);
|
||||
|
||||
Collection<CompoundNBT> getNearByMeteorites( Dimension dim, int chunkX, int chunkZ );
|
||||
Collection<CompoundNBT> getNearByMeteorites(Dimension dim, int chunkX, int chunkZ);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user