Compare commits

...

33 Commits

Author SHA1 Message Date
yueh e0bf7223e0 Refactors grid connections (#3219)
Extracted all checks and subsequent updates to a factory method from the constructor.
Reordered checks to check for nulls before anything else.
Also existing connections before security breaks.
Fixes TileController#checkController() using the wrong position.
Added debug logging for failed connections.
Improved logging.
Inversed boolean so false no longer means security check passed.
Only issue a security break on SecurityConnectionException.
2017-11-12 18:13:59 +01:00
fscan ba9af94228 Fix StorageBus not updating item count correctly (#3218)
* Queue tick instead of ticking immediatley
2017-11-12 18:12:56 +01:00
yueh 122b6163dc Fixes #3209: Reset stack to prevent leaking meaningful ones (#3210) 2017-11-12 12:53:40 +01:00
yueh fab42ccc75 Use craftinggrid to check existing patterns for JEI recipe transfer. (#3202) 2017-11-12 12:48:18 +01:00
yueh f5dd2c8b0a Fixes tooltips for ME Slots (#3205)
No longer strips colors from names, lore, etc.
Now uses the translation again for "Items Stored:" instead of a hardcoded string.
Removed obsolete methods.
2017-11-12 12:35:05 +01:00
fscan a126112a2d Rework ImportBus (#3206)
Fixes #3201
2017-11-11 19:59:11 +01:00
fscan 99cda5f5a3 Cleanup recipe factories (#3207)
Fixes #3200
2017-11-11 17:51:20 +01:00
Florian Scandella 56a5363528 Fix NetworkToolViewer stack overflow, saveguard against markDirty recursion.
fixes #3199
2017-11-08 13:17:34 +01:00
fscan be65edbd5b Set base biome to "void" to shut up warning. (#3194)
Fixes #3118
2017-11-05 03:12:20 +01:00
fscan fe5d9251eb Spatial IO fixes (#3195)
* fix warning when transfering entities
* clean removed TileEntities from the ITickable list.
2017-11-04 23:12:17 +01:00
yueh 3cf48b2291 Remove channels per side from non smart cable states. (#3192)
These are unnecessary for these cable types and their rendering, but are
actually causing the cache to add duplicate models.
2017-11-04 13:24:57 +01:00
yueh cc4599b5fc Add a basic cache for cable models to avoid constant regeneration. (#3185)
* Add a basic cache for cable models to avoid constant regeneration.
* Improved equals/hashCode to ignore cable unrelated parts or facades.
2017-10-31 21:02:03 +01:00
yueh c1fa77df51 Fixes #3189: Formation plane unable to place special items. (#3190) 2017-10-31 16:12:08 +01:00
yueh 725fa491e6 Fixes #2611: Limit the adaptor to the main player inv. (#3188)
This prevents the result from various inventory actions to be placed into
the offhand or armor slots.
2017-10-31 14:05:05 +01:00
fscan e2a6cd1d57 Fix SkyChest bounding box (#3187)
fixes #3149
2017-10-31 01:40:17 +01:00
fscan 6ddf60fab8 Improve Facade rendering (#3182)
UV fix based on #2941 by @MoreThanHidden
fixes #2679, fixes #2625
2017-10-29 16:47:26 +01:00
fscan 2c07acfe81 Allow extraction for Condenser (#3179)
fixes #2960, fixes #2017, fixes #2602
2017-10-27 15:49:40 +02:00
fscan 3749742231 Fix handling of ItemStacks using getShareTag or Capabilites (#3171)
Temporary fix, ideally we would have a way to reference the original ItemStack so we don't need to send the full NBT data to the client.
2017-10-26 17:59:55 +02:00
yueh 74b9610b45 JSON resource cleanup (#3178)
Unified formatting
Added missing new lines at end of file
Removed superfluous spaces
Removed channel texture from dense covered cables.
2017-10-26 12:47:08 +02:00
yueh a725779ff6 Fixes #3175: Return the correct used amount. (#3176) 2017-10-26 12:46:49 +02:00
Flithor b82df25c75 Update zh_cn.lang (#3137) 2017-10-21 00:47:07 +02:00
fscan cc9b33b473 Implement Advancements (#3160)
Improvements welcome.
2017-10-20 23:54:18 +02:00
fscan 5496b746ea Fix Tiny TNT (#3162) 2017-10-20 23:52:55 +02:00
fscan f80f623ccf Fix AESharedItemStack#compareNBT to get consistent ordering. (#3169) 2017-10-20 23:25:18 +02:00
yueh cba6c5500f Fixes inscriber crash with name presses. 2017-10-16 21:41:44 +02:00
Florian Scandella bc8268af94 readd the non-fortune version 2017-10-15 16:07:12 +02:00
Florian Scandella 297cd16702 cleanup BlockQuartzOre and circumvent Forge bug 2017-10-15 15:53:31 +02:00
Florian Scandella 41711e50b9 Check for null in UpgradeInventory#saveChanges. Fixes #3159 2017-10-14 23:53:34 +02:00
Florian Scandella 2bfb8b75e8 Return correct item defintion. 2017-10-14 19:06:57 +02:00
yueh 58e96aa3de Fixes new modes not being considered JEI modes. 2017-10-14 14:39:05 +02:00
fscan 4f07b63b13 API cleanups (#3155)
* Remove obsolete api and fix some warning
* Move MEMonitorHandler to internal code and fix some warnings
* Rename exceptions to conform to naming scheme
2017-10-14 14:15:28 +02:00
yueh 905dd6c888 Added a clientside config to keep or clear the search filter when opening. (#3154)
Closes #3153.
2017-10-14 14:13:18 +02:00
yueh ab7f35a9ee Further StorageChannel refactoring (#3152)
Updated Drives to support more than Item and Fluid cells.
Use Collections.emptyList() instead of creating empty ArrayLists.
Fixes a NPE with uninitialized ME Chests.

Fixes #3150
2017-10-14 14:12:24 +02:00
751 changed files with 19277 additions and 11467 deletions
+1 -1
View File
@@ -26,8 +26,8 @@ package appeng.api;
import appeng.api.definitions.IDefinitions; import appeng.api.definitions.IDefinitions;
import appeng.api.features.IRegistryContainer; import appeng.api.features.IRegistryContainer;
import appeng.api.networking.IGridNode;
import appeng.api.networking.IGridHelper; import appeng.api.networking.IGridHelper;
import appeng.api.networking.IGridNode;
import appeng.api.parts.IPartHelper; import appeng.api.parts.IPartHelper;
import appeng.api.storage.IStorageHelper; import appeng.api.storage.IStorageHelper;
@@ -1,64 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.client;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.util.EnumFacing;
/**
* TODO: Needs to be moved to an internal class. API is only allowed to contain interfaces and/or data.
*
* @deprecated
*/
@Deprecated
public class BakingPipeline<F, T> implements BakingPipelineElement<F, T>
{
private final ImmutableList<BakingPipelineElement<?, ?>> pipeline;
public BakingPipeline( BakingPipelineElement<?, ?>... pipeline )
{
this.pipeline = ImmutableList.copyOf( pipeline );
}
/**
* TODO: fix generics
*/
@Override
public List pipe( List things, IBakedModel parent, IBlockState state, EnumFacing side, long rand )
{
for( BakingPipelineElement pipe : this.pipeline )
{
things = pipe.pipe( things, parent, state, side, rand );
}
return things;
}
}
@@ -1,39 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.client;
import java.util.List;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.util.EnumFacing;
public interface BakingPipelineElement<F, T>
{
public List<T> pipe( List<F> elements, IBakedModel parent, IBlockState state, EnumFacing side, long rand );
}
@@ -26,5 +26,5 @@ package appeng.api.config;
public enum SearchBoxMode public enum SearchBoxMode
{ {
AUTOSEARCH, MANUAL_SEARCH, JEI_AUTOSEARCH, JEI_MANUAL_SEARCH AUTOSEARCH, AUTOSEARCH_KEEP, MANUAL_SEARCH, MANUAL_SEARCH_KEEP, JEI_AUTOSEARCH, JEI_AUTOSEARCH_KEEP, JEI_MANUAL_SEARCH, JEI_MANUAL_SEARCH_KEEP
} }
+35 -11
View File
@@ -33,29 +33,53 @@ public enum Settings
{ {
LEVEL_EMITTER_MODE( EnumSet.allOf( LevelEmitterMode.class ) ), LEVEL_EMITTER_MODE( EnumSet.allOf( LevelEmitterMode.class ) ),
REDSTONE_EMITTER( EnumSet.of( RedstoneMode.HIGH_SIGNAL, RedstoneMode.LOW_SIGNAL ) ), REDSTONE_CONTROLLED( EnumSet.allOf( RedstoneMode.class ) ), REDSTONE_EMITTER( EnumSet.of( RedstoneMode.HIGH_SIGNAL, RedstoneMode.LOW_SIGNAL ) ),
REDSTONE_CONTROLLED( EnumSet.allOf( RedstoneMode.class ) ),
CONDENSER_OUTPUT( EnumSet.allOf( CondenserOutput.class ) ), CONDENSER_OUTPUT( EnumSet.allOf( CondenserOutput.class ) ),
POWER_UNITS( EnumSet.allOf( PowerUnits.class ) ), ACCESS( EnumSet.of( AccessRestriction.READ_WRITE, AccessRestriction.READ, AccessRestriction.WRITE ) ), POWER_UNITS( EnumSet.allOf( PowerUnits.class ) ),
SORT_DIRECTION( EnumSet.allOf( SortDir.class ) ), SORT_BY( EnumSet.allOf( SortOrder.class ) ), ACCESS( EnumSet.of( AccessRestriction.READ_WRITE, AccessRestriction.READ, AccessRestriction.WRITE ) ),
SEARCH_TOOLTIPS( EnumSet.of( YesNo.YES, YesNo.NO ) ), VIEW_MODE( EnumSet.allOf( ViewItems.class ) ), SEARCH_MODE( EnumSet.allOf( SearchBoxMode.class ) ), SORT_DIRECTION( EnumSet.allOf( SortDir.class ) ),
ACTIONS( EnumSet.allOf( ActionItems.class ) ), IO_DIRECTION( EnumSet.of( RelativeDirection.LEFT, RelativeDirection.RIGHT ) ), SORT_BY( EnumSet.allOf( SortOrder.class ) ),
BLOCK( EnumSet.of( YesNo.YES, YesNo.NO ) ), OPERATION_MODE( EnumSet.allOf( OperationMode.class ) ), SEARCH_TOOLTIPS( EnumSet.of( YesNo.YES, YesNo.NO ) ),
FULLNESS_MODE( EnumSet.allOf( FullnessMode.class ) ), CRAFT_ONLY( EnumSet.of( YesNo.YES, YesNo.NO ) ), VIEW_MODE( EnumSet.allOf( ViewItems.class ) ),
FUZZY_MODE( EnumSet.allOf( FuzzyMode.class ) ), LEVEL_TYPE( EnumSet.allOf( LevelType.class ) ), SEARCH_MODE( EnumSet.allOf( SearchBoxMode.class ) ),
TERMINAL_STYLE( EnumSet.of( TerminalStyle.TALL, TerminalStyle.SMALL ) ), COPY_MODE( EnumSet.allOf( CopyMode.class ) ), ACTIONS( EnumSet.allOf( ActionItems.class ) ),
INTERFACE_TERMINAL( EnumSet.of( YesNo.YES, YesNo.NO ) ), CRAFT_VIA_REDSTONE( EnumSet.of( YesNo.YES, YesNo.NO ) ), IO_DIRECTION( EnumSet.of( RelativeDirection.LEFT, RelativeDirection.RIGHT ) ),
STORAGE_FILTER( EnumSet.allOf( StorageFilter.class ) ), PLACE_BLOCK( EnumSet.of( YesNo.YES, YesNo.NO ) ), BLOCK( EnumSet.of( YesNo.YES, YesNo.NO ) ),
OPERATION_MODE( EnumSet.allOf( OperationMode.class ) ),
FULLNESS_MODE( EnumSet.allOf( FullnessMode.class ) ),
CRAFT_ONLY( EnumSet.of( YesNo.YES, YesNo.NO ) ),
FUZZY_MODE( EnumSet.allOf( FuzzyMode.class ) ),
LEVEL_TYPE( EnumSet.allOf( LevelType.class ) ),
TERMINAL_STYLE( EnumSet.of( TerminalStyle.TALL, TerminalStyle.SMALL ) ),
COPY_MODE( EnumSet.allOf( CopyMode.class ) ),
INTERFACE_TERMINAL( EnumSet.of( YesNo.YES, YesNo.NO ) ),
CRAFT_VIA_REDSTONE( EnumSet.of( YesNo.YES, YesNo.NO ) ),
STORAGE_FILTER( EnumSet.allOf( StorageFilter.class ) ),
PLACE_BLOCK( EnumSet.of( YesNo.YES, YesNo.NO ) ),
SCHEDULING_MODE( EnumSet.allOf( SchedulingMode.class ) ); SCHEDULING_MODE( EnumSet.allOf( SchedulingMode.class ) );
@@ -21,6 +21,8 @@ package appeng.api.exceptions;
public class CoreInaccessibleException extends RuntimeException public class CoreInaccessibleException extends RuntimeException
{ {
private static final long serialVersionUID = -7434641554655517242L;
public CoreInaccessibleException( final String message ) public CoreInaccessibleException( final String message )
{ {
super( message ); super( message );
@@ -37,7 +37,7 @@ import appeng.api.networking.IGridNode;
* @version rv3 * @version rv3
* @since rv3 * @since rv3
*/ */
public class ExistingConnectionException extends FailedConnection public class ExistingConnectionException extends FailedConnectionException
{ {
private static final long serialVersionUID = 2975450379720353182L; private static final long serialVersionUID = 2975450379720353182L;
@@ -40,16 +40,16 @@ import appeng.api.networking.IGridNode;
* @version rv3 * @version rv3
* @since rv0 * @since rv0
*/ */
public class FailedConnection extends Exception public class FailedConnectionException extends Exception
{ {
private static final long serialVersionUID = -2544208090248293753L; private static final long serialVersionUID = -2544208090248293753L;
public FailedConnection() public FailedConnectionException()
{ {
} }
public FailedConnection( String message ) public FailedConnectionException( String message )
{ {
super( message ); super( message );
} }
@@ -19,9 +19,11 @@
package appeng.api.exceptions; package appeng.api.exceptions;
public class MissingDefinition extends RuntimeException public class MissingDefinitionException extends RuntimeException
{ {
public MissingDefinition( final String message ) private static final long serialVersionUID = -6547396584255825761L;
public MissingDefinitionException( final String message )
{ {
super( message ); super( message );
} }
@@ -24,12 +24,12 @@
package appeng.api.exceptions; package appeng.api.exceptions;
public class MissingIngredientError extends Exception public class MissingIngredientException extends Exception
{ {
private static final long serialVersionUID = -998858343831371697L; private static final long serialVersionUID = -998858343831371697L;
public MissingIngredientError( final String n ) public MissingIngredientException( final String n )
{ {
super( n ); super( n );
} }
@@ -24,12 +24,12 @@
package appeng.api.exceptions; package appeng.api.exceptions;
public class ModNotInstalled extends Exception public class ModNotInstalledException extends Exception
{ {
private static final long serialVersionUID = -9052435206368425494L; private static final long serialVersionUID = -9052435206368425494L;
public ModNotInstalled( final String t ) public ModNotInstalledException( final String t )
{ {
super( t ); super( t );
} }
@@ -34,7 +34,7 @@ package appeng.api.exceptions;
* @version rv3 * @version rv3
* @since rv3 * @since rv3
*/ */
public class NullNodeConnectionException extends FailedConnection public class NullNodeConnectionException extends FailedConnectionException
{ {
private static final long serialVersionUID = -2143719383495321764L; private static final long serialVersionUID = -2143719383495321764L;
@@ -24,12 +24,12 @@
package appeng.api.exceptions; package appeng.api.exceptions;
public class RecipeError extends Exception public class RecipeException extends Exception
{ {
private static final long serialVersionUID = -6602870588617670262L; private static final long serialVersionUID = -6602870588617670262L;
public RecipeError( final String n ) public RecipeException( final String n )
{ {
super( n ); super( n );
} }
@@ -24,12 +24,12 @@
package appeng.api.exceptions; package appeng.api.exceptions;
public class RegistrationError extends Exception public class RegistrationException extends Exception
{ {
private static final long serialVersionUID = -6602870588617670263L; private static final long serialVersionUID = -6602870588617670263L;
public RegistrationError( final String n ) public RegistrationException( final String n )
{ {
super( n ); super( n );
} }
@@ -34,7 +34,7 @@ package appeng.api.exceptions;
* @version rv3 * @version rv3
* @since rv3 * @since rv3
*/ */
public class SecurityConnectionException extends FailedConnection public class SecurityConnectionException extends FailedConnectionException
{ {
private static final long serialVersionUID = 5048714900434215426L; private static final long serialVersionUID = 5048714900434215426L;
private static final String DEFAULT_MESSAGE = "Connection failed due to different security realms."; private static final String DEFAULT_MESSAGE = "Connection failed due to different security realms.";
@@ -24,7 +24,7 @@
package appeng.api.networking; package appeng.api.networking;
import appeng.api.exceptions.FailedConnection; import appeng.api.exceptions.FailedConnectionException;
/** /**
@@ -57,8 +57,8 @@ public interface IGridHelper
* @param a to be connected gridnode * @param a to be connected gridnode
* @param b to be connected gridnode * @param b to be connected gridnode
* *
* @throws appeng.api.exceptions.FailedConnection * @throws appeng.api.exceptions.FailedConnectionException
*/ */
IGridConnection createGridConnection( IGridNode a, IGridNode b ) throws FailedConnection; IGridConnection createGridConnection( IGridNode a, IGridNode b ) throws FailedConnectionException;
} }
@@ -28,7 +28,7 @@ import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAEStack;
public interface IBaseMonitor<T extends IAEStack> public interface IBaseMonitor<T extends IAEStack<T>>
{ {
/** /**
@@ -50,5 +50,5 @@ public interface IStackWatcherHost
* @param src action source * @param src action source
* @param chan storage channel * @param chan storage channel
*/ */
void onStackChange( IItemList o, IAEStack fullStack, IAEStack diffStack, IActionSource src, IStorageChannel chan ); void onStackChange( IItemList<?> o, IAEStack<?> fullStack, IAEStack<?> diffStack, IActionSource src, IStorageChannel<?> chan );
} }
@@ -29,8 +29,8 @@ import appeng.api.networking.IGridHost;
import appeng.api.networking.security.IActionSource; import appeng.api.networking.security.IActionSource;
import appeng.api.storage.ICellContainer; import appeng.api.storage.ICellContainer;
import appeng.api.storage.ICellProvider; import appeng.api.storage.ICellProvider;
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageChannel;
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAEStack;
@@ -50,7 +50,7 @@ public interface IStorageGrid extends IGridCache, IStorageMonitorable
* *
* @param input injected items * @param input injected items
*/ */
void postAlterationOfStoredItems( IStorageChannel chan, Iterable<? extends IAEStack> input, IActionSource src ); void postAlterationOfStoredItems( IStorageChannel<?> chan, Iterable<? extends IAEStack<?>> input, IActionSource src );
/** /**
* Used to add a cell provider to the storage system * Used to add a cell provider to the storage system
@@ -26,9 +26,9 @@ package appeng.api.recipes;
import java.util.List; import java.util.List;
import appeng.api.exceptions.MissingIngredientError; import appeng.api.exceptions.MissingIngredientException;
import appeng.api.exceptions.RecipeError; import appeng.api.exceptions.RecipeException;
import appeng.api.exceptions.RegistrationError; import appeng.api.exceptions.RegistrationException;
public interface ICraftHandler public interface ICraftHandler
@@ -40,15 +40,15 @@ public interface ICraftHandler
* @param input parsed inputs * @param input parsed inputs
* @param output parsed outputs * @param output parsed outputs
* *
* @throws RecipeError * @throws RecipeException
*/ */
void setup( List<List<IIngredient>> input, List<List<IIngredient>> output ) throws RecipeError; void setup( List<List<IIngredient>> input, List<List<IIngredient>> output ) throws RecipeException;
/** /**
* called when all recipes are parsed, and your required to register your recipe. * called when all recipes are parsed, and your required to register your recipe.
* *
* @throws RegistrationError * @throws RegistrationException
* @throws MissingIngredientError * @throws MissingIngredientException
*/ */
void register() throws RegistrationError, MissingIngredientError; void register() throws RegistrationException, MissingIngredientException;
} }
@@ -26,8 +26,8 @@ package appeng.api.recipes;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.exceptions.MissingIngredientError; import appeng.api.exceptions.MissingIngredientException;
import appeng.api.exceptions.RegistrationError; import appeng.api.exceptions.RegistrationException;
public interface IIngredient public interface IIngredient
@@ -39,10 +39,10 @@ public interface IIngredient
* *
* @return a single ItemStack for the recipe handler. * @return a single ItemStack for the recipe handler.
* *
* @throws RegistrationError * @throws RegistrationException
* @throws MissingIngredientError * @throws MissingIngredientException
*/ */
ItemStack getItemStack() throws RegistrationError, MissingIngredientError; ItemStack getItemStack() throws RegistrationException, MissingIngredientException;
/** /**
* Acquire a list of all the input stacks for the current recipe, this is for handlers that support * Acquire a list of all the input stacks for the current recipe, this is for handlers that support
@@ -50,10 +50,10 @@ public interface IIngredient
* *
* @return an array of ItemStacks for the recipe handler. * @return an array of ItemStacks for the recipe handler.
* *
* @throws RegistrationError * @throws RegistrationException
* @throws MissingIngredientError * @throws MissingIngredientException
*/ */
ItemStack[] getItemStackSet() throws RegistrationError, MissingIngredientError; ItemStack[] getItemStackSet() throws RegistrationException, MissingIngredientException;
/** /**
* If you wish to support air, you must test before getting the ItemStack, or ItemStackSet * If you wish to support air, you must test before getting the ItemStack, or ItemStackSet
@@ -85,8 +85,8 @@ public interface IIngredient
/** /**
* Bakes the lists in for faster runtime look-ups. * Bakes the lists in for faster runtime look-ups.
* *
* @throws MissingIngredientError * @throws MissingIngredientException
* @throws RegistrationError * @throws RegistrationException
*/ */
void bake() throws RegistrationError, MissingIngredientError; void bake() throws RegistrationException, MissingIngredientException;
} }
@@ -42,7 +42,7 @@ public interface ICellProvider
* *
* @return a valid list of handlers, NEVER NULL * @return a valid list of handlers, NEVER NULL
*/ */
List<IMEInventoryHandler> getCellArray( IStorageChannel channel ); List<IMEInventoryHandler> getCellArray( IStorageChannel<?> channel );
/** /**
* the storage's priority. * the storage's priority.
@@ -29,7 +29,7 @@ import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAEStack;
public interface IMEMonitorHandlerReceiver<StackType extends IAEStack> public interface IMEMonitorHandlerReceiver<T extends IAEStack<T>>
{ {
/** /**
@@ -46,7 +46,7 @@ public interface IMEMonitorHandlerReceiver<StackType extends IAEStack>
* *
* @param change done change * @param change done change
*/ */
void postChange( IBaseMonitor<StackType> monitor, Iterable<StackType> change, IActionSource actionSource ); void postChange( IBaseMonitor<T> monitor, Iterable<T> change, IActionSource actionSource );
/** /**
* called when the list updates its contents, this is mostly for handling power events. * called when the list updates its contents, this is mostly for handling power events.
@@ -27,5 +27,5 @@ package appeng.api.storage;
public interface ISaveProvider public interface ISaveProvider
{ {
void saveChanges( IMEInventory cellInventory ); void saveChanges( IMEInventory<?> cellInventory );
} }
@@ -35,7 +35,7 @@ import appeng.api.config.FuzzyMode;
import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageChannel;
public interface IAEStack<StackType extends IAEStack<StackType>> public interface IAEStack<T extends IAEStack<T>>
{ {
/** /**
@@ -43,7 +43,7 @@ public interface IAEStack<StackType extends IAEStack<StackType>>
* *
* @param is added item * @param is added item
*/ */
void add( StackType is ); void add( T is );
/** /**
* number of items in the stack. * number of items in the stack.
@@ -57,7 +57,7 @@ public interface IAEStack<StackType extends IAEStack<StackType>>
* *
* @param stackSize , ItemStack.stackSize = N * @param stackSize , ItemStack.stackSize = N
*/ */
StackType setStackSize( long stackSize ); T setStackSize( long stackSize );
/** /**
* Same as getStackSize, but for requestable items. ( LP ) * Same as getStackSize, but for requestable items. ( LP )
@@ -71,7 +71,7 @@ public interface IAEStack<StackType extends IAEStack<StackType>>
* *
* @return basically itemStack.stackSize = N but for setStackSize items. * @return basically itemStack.stackSize = N but for setStackSize items.
*/ */
StackType setCountRequestable( long countRequestable ); T setCountRequestable( long countRequestable );
/** /**
* true, if the item can be crafted. * true, if the item can be crafted.
@@ -85,12 +85,12 @@ public interface IAEStack<StackType extends IAEStack<StackType>>
* *
* @param isCraftable can item be crafted * @param isCraftable can item be crafted
*/ */
StackType setCraftable( boolean isCraftable ); T setCraftable( boolean isCraftable );
/** /**
* clears, requestable, craftable, and stack sizes. * clears, requestable, craftable, and stack sizes.
*/ */
StackType reset(); T reset();
/** /**
* returns true, if the item can be crafted, requested, or extracted. * returns true, if the item can be crafted, requested, or extracted.
@@ -174,14 +174,14 @@ public interface IAEStack<StackType extends IAEStack<StackType>>
* *
* @return a new Stack, which is copied from the original. * @return a new Stack, which is copied from the original.
*/ */
StackType copy(); T copy();
/** /**
* create an empty stack. * create an empty stack.
* *
* @return a new stack, which represents an empty copy of the original. * @return a new stack, which represents an empty copy of the original.
*/ */
StackType empty(); T empty();
/** /**
* @return true if the stack is a {@link IAEItemStack} * @return true if the stack is a {@link IAEItemStack}
@@ -196,7 +196,7 @@ public interface IAEStack<StackType extends IAEStack<StackType>>
/** /**
* @return ITEM or FLUID * @return ITEM or FLUID
*/ */
IStorageChannel getChannel(); IStorageChannel<T> getChannel();
/** /**
* Returns itemstack for display and similar purposes. Always has a count of 1. * Returns itemstack for display and similar purposes. Always has a count of 1.
@@ -100,14 +100,12 @@ public abstract class AEBaseBlock extends Block
return new BlockStateContainer( this, this.getAEStates() ); return new BlockStateContainer( this, this.getAEStates() );
} }
@SuppressWarnings( "deprecation" )
@Override @Override
public final boolean isNormalCube( IBlockState state ) public final boolean isNormalCube( IBlockState state )
{ {
return this.isFullSize() && this.isOpaque(); return this.isFullSize() && this.isOpaque();
} }
@SuppressWarnings( "deprecation" )
@Override @Override
public AxisAlignedBB getBoundingBox( IBlockState state, IBlockAccess source, BlockPos pos ) public AxisAlignedBB getBoundingBox( IBlockState state, IBlockAccess source, BlockPos pos )
{ {
@@ -226,7 +224,6 @@ public abstract class AEBaseBlock extends Block
return super.getSelectedBoundingBox( state, w, pos ); return super.getSelectedBoundingBox( state, w, pos );
} }
@SuppressWarnings( "deprecation" )
@Override @Override
public final boolean isOpaqueCube( IBlockState state ) public final boolean isOpaqueCube( IBlockState state )
{ {
@@ -281,14 +278,12 @@ public abstract class AEBaseBlock extends Block
return super.collisionRayTrace( state, w, pos, a, b ); return super.collisionRayTrace( state, w, pos, a, b );
} }
@SuppressWarnings( "deprecation" )
@Override @Override
public boolean hasComparatorInputOverride( IBlockState state ) public boolean hasComparatorInputOverride( IBlockState state )
{ {
return this.isInventory(); return this.isInventory();
} }
@SuppressWarnings( "deprecation" )
@Override @Override
public int getComparatorInputOverride( IBlockState state, final World worldIn, final BlockPos pos ) public int getComparatorInputOverride( IBlockState state, final World worldIn, final BlockPos pos )
{ {
@@ -67,7 +67,6 @@ public class AEBaseItemBlock extends ItemBlock
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly( Side.CLIENT )
@SuppressWarnings( "unchecked" )
public final void addInformation( final ItemStack itemStack, final World world, final List<String> toolTip, final ITooltipFlag advancedTooltips ) public final void addInformation( final ItemStack itemStack, final World world, final List<String> toolTip, final ITooltipFlag advancedTooltips )
{ {
this.addCheckedInformation( itemStack, world, toolTip, advancedTooltips ); this.addCheckedInformation( itemStack, world, toolTip, advancedTooltips );
@@ -37,13 +37,17 @@ import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.Explosion; import net.minecraft.world.Explosion;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import appeng.block.AEBaseBlock; import appeng.block.AEBaseBlock;
import appeng.core.AppEng;
import appeng.entity.EntityIds;
import appeng.entity.EntityTinyTNTPrimed; import appeng.entity.EntityTinyTNTPrimed;
import appeng.helpers.ICustomCollision; import appeng.helpers.ICustomCollision;
@@ -54,15 +58,24 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
public BlockTinyTNT() public BlockTinyTNT()
{ {
super( Material.TNT ); super( Material.TNT );
this.setLightOpacity( 1 );
this.boundingBox = new AxisAlignedBB( 0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f ); this.boundingBox = new AxisAlignedBB( 0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f );
this.setFullSize( this.setOpaque( false ) );
this.setLightOpacity( 2 );
this.setFullSize( false );
this.setOpaque( false );
this.setSoundType( SoundType.GROUND ); this.setSoundType( SoundType.GROUND );
this.setHardness( 0F ); this.setHardness( 0F );
// TODO: 1.11 EntityRegistry.registerModEntity( new ResourceLocation( AppEng.MOD_ID, EntityTinyTNTPrimed.class.getName() ), EntityTinyTNTPrimed.class,
// EntityRegistry.registerModEntity( EntityTinyTNTPrimed.class, "EntityTinyTNTPrimed", EntityIds.get( "EntityTinyTNTPrimed", EntityIds.get( EntityTinyTNTPrimed.class ), AppEng.instance(), 16, 4, true );
// EntityTinyTNTPrimed.class ), AppEng.instance(), 16, 4, true ); }
@Override
public boolean isFullCube( IBlockState state )
{
return false;
} }
@Override @Override
@@ -101,7 +101,6 @@ public class BlockCableBus extends AEBaseTileBlock
// this will actually be overwritten later through setupTile and the // this will actually be overwritten later through setupTile and the
// combined layers // combined layers
this.setTileEntity( TileCableBus.class ); this.setTileEntity( TileCableBus.class );
this.useNeighborBrightness = true;
} }
@Override @Override
@@ -97,7 +97,6 @@ public class BlockController extends AEBaseTileBlock
* controllers and the network state of this controller (offline, online, conflicted). This is used to * controllers and the network state of this controller (offline, online, conflicted). This is used to
* get a rudimentary connected texture feel for the controller based on how it is placed. * get a rudimentary connected texture feel for the controller based on how it is placed.
*/ */
@SuppressWarnings( "deprecation" )
@Override @Override
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos ) public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos )
{ {
@@ -160,7 +159,6 @@ public class BlockController extends AEBaseTileBlock
return state.getValue( CONTROLLER_STATE ).ordinal(); return state.getValue( CONTROLLER_STATE ).ordinal();
} }
@SuppressWarnings( "deprecation" )
@Override @Override
public IBlockState getStateFromMeta( final int meta ) public IBlockState getStateFromMeta( final int meta )
{ {
@@ -174,7 +172,6 @@ public class BlockController extends AEBaseTileBlock
return BlockRenderLayer.CUTOUT; return BlockRenderLayer.CUTOUT;
} }
@SuppressWarnings( "deprecation" )
@Override @Override
public void neighborChanged( IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos ) public void neighborChanged( IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos )
{ {
@@ -47,9 +47,9 @@ import appeng.util.Platform;
public class BlockSkyChest extends AEBaseTileBlock implements ICustomCollision public class BlockSkyChest extends AEBaseTileBlock implements ICustomCollision
{ {
private static final double AABB_OFFSET_BOTTOM = .0625d; private static final double AABB_OFFSET_BOTTOM = 0.00;
private static final double AABB_OFFSET_SIDES = 0; private static final double AABB_OFFSET_SIDES = 0.06;
private static final double AABB_OFFSET_TOP = .125d; private static final double AABB_OFFSET_TOP = 0.125;
public enum SkyChestType public enum SkyChestType
{ {
@@ -111,18 +111,18 @@ public class BlockSkyChest extends AEBaseTileBlock implements ICustomCollision
o = sk.getUp(); o = sk.getUp();
} }
final double offsetX = o.getFrontOffsetX() == 0 ? AABB_OFFSET_BOTTOM : AABB_OFFSET_SIDES; final double offsetX = o.getFrontOffsetX() == 0 ? AABB_OFFSET_SIDES : 0.0;
final double offsetY = o.getFrontOffsetY() == 0 ? AABB_OFFSET_BOTTOM : AABB_OFFSET_SIDES; final double offsetY = o.getFrontOffsetY() == 0 ? AABB_OFFSET_SIDES : 0.0;
final double offsetZ = o.getFrontOffsetZ() == 0 ? AABB_OFFSET_BOTTOM : AABB_OFFSET_SIDES; final double offsetZ = o.getFrontOffsetZ() == 0 ? AABB_OFFSET_SIDES : 0.0;
// x/z needs to be multiplied by -1, thus we simply add not substract. // for x/z top and bottom is swapped
final double minX = Math.max( 0.0, offsetX + o.getFrontOffsetX() * AABB_OFFSET_TOP ); final double minX = Math.max( 0.0, offsetX + ( o.getFrontOffsetX() < 0 ? AABB_OFFSET_BOTTOM : ( o.getFrontOffsetX() * AABB_OFFSET_TOP ) ) );
final double minY = Math.max( 0.0, offsetY - o.getFrontOffsetY() * AABB_OFFSET_TOP ); final double minY = Math.max( 0.0, offsetY + ( o.getFrontOffsetY() < 0 ? AABB_OFFSET_TOP : ( o.getFrontOffsetY() * AABB_OFFSET_BOTTOM ) ) );
final double minZ = Math.max( 0.0, offsetZ + o.getFrontOffsetZ() * AABB_OFFSET_TOP ); final double minZ = Math.max( 0.0, offsetZ + ( o.getFrontOffsetZ() < 0 ? AABB_OFFSET_BOTTOM : ( o.getFrontOffsetZ() * AABB_OFFSET_TOP ) ) );
final double maxX = Math.min( 1.0, ( 1.0 - offsetX ) + o.getFrontOffsetX() * AABB_OFFSET_TOP ); final double maxX = Math.min( 1.0, 1.0 - offsetX - ( o.getFrontOffsetX() < 0 ? AABB_OFFSET_TOP : ( o.getFrontOffsetX() * AABB_OFFSET_BOTTOM ) ) );
final double maxY = Math.min( 1.0, ( 1.0 - offsetY ) - o.getFrontOffsetY() * AABB_OFFSET_TOP ); final double maxY = Math.min( 1.0, 1.0 - offsetY - ( o.getFrontOffsetY() < 0 ? AABB_OFFSET_BOTTOM : ( o.getFrontOffsetY() * AABB_OFFSET_TOP ) ) );
final double maxZ = Math.min( 1.0, ( 1.0 - offsetZ ) + o.getFrontOffsetZ() * AABB_OFFSET_TOP ); final double maxZ = Math.min( 1.0, 1.0 - offsetZ - ( o.getFrontOffsetZ() < 0 ? AABB_OFFSET_TOP : ( o.getFrontOffsetZ() * AABB_OFFSET_BOTTOM ) ) );
return new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ); return new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ );
} }
@@ -0,0 +1,30 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2017, 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.bootstrap;
import net.minecraft.advancements.ICriterionInstance;
import net.minecraft.advancements.ICriterionTrigger;
@FunctionalInterface
public interface ICriterionTriggerRegistry
{
void register( ICriterionTrigger<? extends ICriterionInstance> trigger );
}
@@ -140,7 +140,6 @@ public abstract class AEBaseGui extends GuiContainer
} }
} }
@SuppressWarnings( "unchecked" )
private List<Slot> getInventorySlots() private List<Slot> getInventorySlots()
{ {
return this.inventorySlots.inventorySlots; return this.inventorySlots.inventorySlots;
@@ -23,7 +23,6 @@ import java.text.NumberFormat;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -43,70 +42,17 @@ public abstract class AEBaseMEGui extends AEBaseGui
super( container ); super( container );
} }
public List<String> handleItemTooltip( final ItemStack stack, final int mouseX, final int mouseY, final List<String> currentToolTip )
{
if( !stack.isEmpty() )
{
final Slot s = this.getSlot( mouseX, mouseY );
if( s instanceof SlotME )
{
final int BigNumber = AEConfig.instance().useTerminalUseLargeFont() ? 999 : 9999;
IAEItemStack myStack = null;
try
{
final SlotME theSlotField = (SlotME) s;
myStack = theSlotField.getAEStack();
}
catch( final Throwable ignore )
{
}
if( myStack != null )
{
if( myStack.getStackSize() > BigNumber || ( myStack.getStackSize() > 1 && stack.isItemDamaged() ) )
{
final String local = ButtonToolTips.ItemsStored.getLocal();
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( myStack.getStackSize() );
final String format = String.format( local, formattedAmount );
currentToolTip.add( TextFormatting.GRAY + format );
}
if( myStack.getCountRequestable() > 0 )
{
final String local = ButtonToolTips.ItemsRequestable.getLocal();
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( myStack.getCountRequestable() );
final String format = String.format( local, formattedAmount );
currentToolTip.add( TextFormatting.GRAY + format );
}
}
else if( stack.getCount() > BigNumber || ( stack.getCount() > 1 && stack.isItemDamaged() ) )
{
final String local = ButtonToolTips.ItemsStored.getLocal();
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( stack.getCount() );
final String format = String.format( local, formattedAmount );
currentToolTip.add( TextFormatting.GRAY + format );
}
}
}
return currentToolTip;
}
// Vanilla version...
// protected void drawItemStackTooltip(ItemStack stack, int x, int y)
@Override @Override
protected void renderToolTip( final ItemStack stack, final int x, final int y ) protected void renderToolTip( final ItemStack stack, final int x, final int y )
{ {
final Slot s = this.getSlot( x, y ); final Slot s = this.getSlot( x, y );
if( s instanceof SlotME && !stack.isEmpty() ) if( s instanceof SlotME && !stack.isEmpty() )
{ {
final int BigNumber = AEConfig.instance().useTerminalUseLargeFont() ? 999 : 9999; final int bigNumber = AEConfig.instance().useTerminalUseLargeFont() ? 999 : 9999;
IAEItemStack myStack = null; IAEItemStack myStack = null;
final List<String> currentToolTip = this.getItemToolTip( stack );
try try
{ {
@@ -117,34 +63,44 @@ public abstract class AEBaseMEGui extends AEBaseGui
{ {
} }
ITooltipFlag.TooltipFlags tooltipFlag = this.mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL;
if( myStack != null ) if( myStack != null )
{ {
@SuppressWarnings( "unchecked" ) if( myStack.getStackSize() > bigNumber || ( myStack.getStackSize() > 1 && stack.isItemDamaged() ) )
final List<String> currentToolTip = stack.getTooltip( this.mc.player, tooltipFlag );
if( myStack.getStackSize() > BigNumber || ( myStack.getStackSize() > 1 && stack.isItemDamaged() ) )
{ {
currentToolTip.add( "Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getStackSize() ) ); final String local = ButtonToolTips.ItemsStored.getLocal();
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( myStack.getStackSize() );
final String format = String.format( local, formattedAmount );
currentToolTip.add( TextFormatting.GRAY + format );
} }
if( myStack.getCountRequestable() > 0 ) if( myStack.getCountRequestable() > 0 )
{ {
currentToolTip.add( "Items Requestable: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getCountRequestable() ) ); final String local = ButtonToolTips.ItemsRequestable.getLocal();
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( myStack.getCountRequestable() );
final String format = String.format( local, formattedAmount );
currentToolTip.add( format );
} }
this.drawTooltip( x, y, currentToolTip ); this.drawHoveringText( currentToolTip, x, y, this.fontRenderer );
return; return;
} }
else if( stack.getCount() > BigNumber ) else if( stack.getCount() > bigNumber )
{ {
List<String> var4 = stack.getTooltip( this.mc.player, tooltipFlag ); final String local = ButtonToolTips.ItemsStored.getLocal();
var4.add( "Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( stack.getCount() ) ); final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( stack.getCount() );
this.drawTooltip( x, y, var4 ); final String format = String.format( local, formattedAmount );
currentToolTip.add( TextFormatting.GRAY + format );
this.drawHoveringText( currentToolTip, x, y, this.fontRenderer );
return; return;
} }
} }
super.renderToolTip( stack, x, y ); super.renderToolTip( stack, x, y );
// super.drawItemStackTooltip( stack, x, y );
} }
} }
@@ -292,6 +292,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
this.buttonList.add( this.buttonList.add(
this.searchBoxSettings = new GuiImgButton( this.guiLeft - 18, offset, Settings.SEARCH_MODE, AEConfig.instance().getConfigManager().getSetting( this.searchBoxSettings = new GuiImgButton( this.guiLeft - 18, offset, Settings.SEARCH_MODE, AEConfig.instance().getConfigManager().getSetting(
Settings.SEARCH_MODE ) ) ); Settings.SEARCH_MODE ) ) );
offset += 20; offset += 20;
if( !( this instanceof GuiMEPortableCell ) || this instanceof GuiWirelessTerm ) if( !( this instanceof GuiMEPortableCell ) || this instanceof GuiWirelessTerm )
@@ -315,16 +316,22 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
this.craftingStatusBtn.setHideEdge( 13 ); this.craftingStatusBtn.setHideEdge( 13 );
} }
final Enum setting = AEConfig.instance().getConfigManager().getSetting( Settings.SEARCH_MODE ); final Enum searchModeSetting = AEConfig.instance().getConfigManager().getSetting( Settings.SEARCH_MODE );
this.searchField.setFocused( SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.JEI_AUTOSEARCH == setting );
this.searchField.setCanLoseFocus( SearchBoxMode.MANUAL_SEARCH == setting || SearchBoxMode.JEI_MANUAL_SEARCH == setting );
if( setting == SearchBoxMode.JEI_AUTOSEARCH || setting == SearchBoxMode.JEI_MANUAL_SEARCH ) final boolean isAutoFocus = SearchBoxMode.AUTOSEARCH == searchModeSetting || SearchBoxMode.JEI_AUTOSEARCH == searchModeSetting || SearchBoxMode.AUTOSEARCH_KEEP == searchModeSetting || SearchBoxMode.JEI_AUTOSEARCH_KEEP == searchModeSetting;
final boolean isManualFocus = SearchBoxMode.MANUAL_SEARCH == searchModeSetting || SearchBoxMode.JEI_MANUAL_SEARCH == searchModeSetting || SearchBoxMode.MANUAL_SEARCH_KEEP == searchModeSetting || SearchBoxMode.JEI_MANUAL_SEARCH_KEEP == searchModeSetting;
final boolean isKeepFilter = SearchBoxMode.AUTOSEARCH_KEEP == searchModeSetting || SearchBoxMode.JEI_AUTOSEARCH_KEEP == searchModeSetting || SearchBoxMode.MANUAL_SEARCH_KEEP == searchModeSetting || SearchBoxMode.JEI_MANUAL_SEARCH_KEEP == searchModeSetting;
final boolean isJEIEnabled = SearchBoxMode.JEI_AUTOSEARCH == searchModeSetting || SearchBoxMode.JEI_MANUAL_SEARCH == searchModeSetting;
this.searchField.setFocused( isAutoFocus );
this.searchField.setCanLoseFocus( isManualFocus );
if( isJEIEnabled )
{ {
memoryText = Integrations.jei().getSearchText(); memoryText = Integrations.jei().getSearchText();
} }
if( memoryText != null && !memoryText.isEmpty() ) if( isKeepFilter && memoryText != null && !memoryText.isEmpty() )
{ {
this.searchField.setText( memoryText ); this.searchField.setText( memoryText );
this.searchField.selectAll(); this.searchField.selectAll();
@@ -359,6 +366,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
craftingGridOffsetX -= 25; craftingGridOffsetX -= 25;
craftingGridOffsetY -= 6; craftingGridOffsetY -= 6;
} }
@Override @Override
@@ -237,10 +237,11 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
this.getScrollBar().setRange( 0, ( size + 4 ) / 5 - this.rows, 1 ); this.getScrollBar().setRange( 0, ( size + 4 ) / 5 - this.rows, 1 );
} }
// Vanilla version... @Override
protected void drawItemStackTooltip( final ItemStack stack, final int x, final int y ) protected void renderToolTip( final ItemStack stack, final int x, final int y )
{ {
final Slot s = this.getSlot( x, y ); final Slot s = this.getSlot( x, y );
if( s instanceof SlotME && stack != null ) if( s instanceof SlotME && stack != null )
{ {
IAEItemStack myStack = null; IAEItemStack myStack = null;
@@ -270,7 +271,8 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
this.drawTooltip( x, y, currentToolTip ); this.drawTooltip( x, y, currentToolTip );
} }
} }
// super.drawItemStackTooltip( stack, x, y );
super.renderToolTip( stack, x, y );
} }
@Override @Override
@@ -110,6 +110,13 @@ public class GuiImgButton extends GuiButton implements ITooltip
this.registerApp( 16 * 2 + 5, Settings.SEARCH_MODE, SearchBoxMode.JEI_AUTOSEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_JEIAuto ); this.registerApp( 16 * 2 + 5, Settings.SEARCH_MODE, SearchBoxMode.JEI_AUTOSEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_JEIAuto );
this.registerApp( 16 * 2 + 6, Settings.SEARCH_MODE, SearchBoxMode.JEI_MANUAL_SEARCH, ButtonToolTips.SearchMode, this.registerApp( 16 * 2 + 6, Settings.SEARCH_MODE, SearchBoxMode.JEI_MANUAL_SEARCH, ButtonToolTips.SearchMode,
ButtonToolTips.SearchMode_JEIStandard ); ButtonToolTips.SearchMode_JEIStandard );
this.registerApp( 16 * 2 + 7, Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH_KEEP, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_AutoKeep );
this.registerApp( 16 * 2 + 8, Settings.SEARCH_MODE, SearchBoxMode.MANUAL_SEARCH_KEEP, ButtonToolTips.SearchMode,
ButtonToolTips.SearchMode_StandardKeep );
this.registerApp( 16 * 2 + 9, Settings.SEARCH_MODE, SearchBoxMode.JEI_AUTOSEARCH_KEEP, ButtonToolTips.SearchMode,
ButtonToolTips.SearchMode_JEIAutoKeep );
this.registerApp( 16 * 2 + 10, Settings.SEARCH_MODE, SearchBoxMode.JEI_MANUAL_SEARCH_KEEP, ButtonToolTips.SearchMode,
ButtonToolTips.SearchMode_JEIStandardKeep );
this.registerApp( 16 * 5 + 3, Settings.LEVEL_TYPE, LevelType.ENERGY_LEVEL, ButtonToolTips.LevelType, ButtonToolTips.LevelType_Energy ); this.registerApp( 16 * 5 + 3, Settings.LEVEL_TYPE, LevelType.ENERGY_LEVEL, ButtonToolTips.LevelType, ButtonToolTips.LevelType_Energy );
this.registerApp( 16 * 4 + 3, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL, ButtonToolTips.LevelType, ButtonToolTips.LevelType_Item ); this.registerApp( 16 * 4 + 3, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL, ButtonToolTips.LevelType, ButtonToolTips.LevelType_Item );
+1 -2
View File
@@ -112,14 +112,13 @@ public class ItemRepo
final Enum viewMode = this.sortSrc.getSortDisplay(); final Enum viewMode = this.sortSrc.getSortDisplay();
final Enum searchMode = AEConfig.instance().getConfigManager().getSetting( Settings.SEARCH_MODE ); final Enum searchMode = AEConfig.instance().getConfigManager().getSetting( Settings.SEARCH_MODE );
if( searchMode == SearchBoxMode.JEI_AUTOSEARCH || searchMode == SearchBoxMode.JEI_MANUAL_SEARCH ) if( searchMode == SearchBoxMode.JEI_AUTOSEARCH || searchMode == SearchBoxMode.JEI_MANUAL_SEARCH || searchMode == SearchBoxMode.JEI_AUTOSEARCH_KEEP || searchMode == SearchBoxMode.JEI_MANUAL_SEARCH_KEEP )
{ {
this.updateJEI( this.searchString ); this.updateJEI( this.searchString );
} }
this.innerSearch = this.searchString; this.innerSearch = this.searchString;
final boolean terminalSearchToolTips = AEConfig.instance().getConfigManager().getSetting( Settings.SEARCH_TOOLTIPS ) != YesNo.NO; final boolean terminalSearchToolTips = AEConfig.instance().getConfigManager().getSetting( Settings.SEARCH_TOOLTIPS ) != YesNo.NO;
// boolean terminalSearchMods = Configuration.INSTANCE.settings.getSetting( Settings.SEARCH_MODS ) != YesNo.NO;
boolean searchMod = false; boolean searchMod = false;
if( this.innerSearch.startsWith( "@" ) ) if( this.innerSearch.startsWith( "@" ) )
@@ -0,0 +1,69 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2017, 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.client.render;
import javax.vecmath.Matrix4f;
import org.apache.commons.lang3.tuple.Pair;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
public abstract class DelegateBakedModel implements IBakedModel
{
private IBakedModel baseModel;
protected DelegateBakedModel( IBakedModel base )
{
this.baseModel = base;
}
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective( ItemCameraTransforms.TransformType type )
{
Pair<? extends IBakedModel, Matrix4f> pair = this.baseModel.handlePerspective( type );
return Pair.of( this, pair.getValue() );
}
@Override
public TextureAtlasSprite getParticleTexture()
{
return this.baseModel.getParticleTexture();
}
@Override
public ItemCameraTransforms getItemCameraTransforms()
{
return this.baseModel.getItemCameraTransforms();
}
@Override
public boolean isAmbientOcclusion()
{
return this.baseModel.isAmbientOcclusion();
}
public IBakedModel getBaseModel()
{
return this.baseModel;
}
}
@@ -27,9 +27,7 @@ import javax.annotation.Nullable;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -44,16 +42,13 @@ import appeng.items.parts.ItemFacade;
* on the item stack. * on the item stack.
* A custom Item Override List is used to accomplish this. * A custom Item Override List is used to accomplish this.
*/ */
public class FacadeDispatcherBakedModel implements IBakedModel public class FacadeDispatcherBakedModel extends DelegateBakedModel
{ {
private final IBakedModel baseModel;
private final VertexFormat format; private final VertexFormat format;
public FacadeDispatcherBakedModel( IBakedModel baseModel, VertexFormat format ) public FacadeDispatcherBakedModel( IBakedModel baseModel, VertexFormat format )
{ {
this.baseModel = baseModel; super( baseModel );
this.format = format; this.format = format;
} }
@@ -64,16 +59,10 @@ public class FacadeDispatcherBakedModel implements IBakedModel
return Collections.emptyList(); return Collections.emptyList();
} }
@Override
public boolean isAmbientOcclusion()
{
return this.baseModel.isAmbientOcclusion();
}
@Override @Override
public boolean isGui3d() public boolean isGui3d()
{ {
return this.baseModel.isGui3d(); return this.getBaseModel().isGui3d();
} }
@Override @Override
@@ -82,18 +71,6 @@ public class FacadeDispatcherBakedModel implements IBakedModel
return false; return false;
} }
@Override
public TextureAtlasSprite getParticleTexture()
{
return this.baseModel.getParticleTexture();
}
@Override
public ItemCameraTransforms getItemCameraTransforms()
{
return this.baseModel.getItemCameraTransforms();
}
@Override @Override
public ItemOverrideList getOverrides() public ItemOverrideList getOverrides()
{ {
@@ -112,7 +89,8 @@ public class FacadeDispatcherBakedModel implements IBakedModel
IBlockState state = itemFacade.getTextureBlockState( stack ); IBlockState state = itemFacade.getTextureBlockState( stack );
ItemStack textureItem = itemFacade.getTextureItem( stack ); ItemStack textureItem = itemFacade.getTextureItem( stack );
return new FacadeWithBlockBakedModel( FacadeDispatcherBakedModel.this.baseModel, state, textureItem, FacadeDispatcherBakedModel.this.format ); return new FacadeWithBlockBakedModel( FacadeDispatcherBakedModel.this
.getBaseModel(), state, textureItem, FacadeDispatcherBakedModel.this.format );
} }
}; };
} }
@@ -30,7 +30,6 @@ import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModel; import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ModelLoaderRegistry; import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.common.model.IModelState; import net.minecraftforge.common.model.IModelState;
import net.minecraftforge.common.model.TRSRTransformation;
import appeng.core.AppEng; import appeng.core.AppEng;
@@ -41,10 +40,27 @@ import appeng.core.AppEng;
*/ */
public class FacadeItemModel implements IModel public class FacadeItemModel implements IModel
{ {
// We use this to get the default item transforms and make our lives easier // We use this to get the default item transforms and make our lives easier
private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/facade_base" ); private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/facade_base" );
private IModel baseModel = null;
private IModel getBaseModel()
{
if( this.baseModel == null )
{
try
{
baseModel = ModelLoaderRegistry.getModel( MODEL_BASE );
}
catch( Exception e )
{
throw new RuntimeException( e );
}
}
return this.baseModel;
}
@Override @Override
public Collection<ResourceLocation> getDependencies() public Collection<ResourceLocation> getDependencies()
{ {
@@ -60,17 +76,7 @@ public class FacadeItemModel implements IModel
@Override @Override
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter ) public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
{ {
IModel baseModel; IBakedModel bakedBaseModel = this.getBaseModel().bake( state, format, bakedTextureGetter );
try
{
baseModel = ModelLoaderRegistry.getModel( MODEL_BASE );
}
catch( Exception e )
{
throw new RuntimeException( e );
}
IBakedModel bakedBaseModel = baseModel.bake( state, format, bakedTextureGetter );
return new FacadeDispatcherBakedModel( bakedBaseModel, format ); return new FacadeDispatcherBakedModel( bakedBaseModel, format );
} }
@@ -78,6 +84,6 @@ public class FacadeItemModel implements IModel
@Override @Override
public IModelState getDefaultState() public IModelState getDefaultState()
{ {
return TRSRTransformation.identity(); return getBaseModel().getDefaultState();
} }
} }
@@ -29,9 +29,7 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
@@ -44,11 +42,8 @@ import appeng.client.render.cablebus.FacadeBuilder;
* This is the actual baked model that will combine the north face of a given block state * This is the actual baked model that will combine the north face of a given block state
* with the base facade item model to achieve what is then actually rendered on screen. * with the base facade item model to achieve what is then actually rendered on screen.
*/ */
public class FacadeWithBlockBakedModel implements IBakedModel public class FacadeWithBlockBakedModel extends DelegateBakedModel
{ {
private final IBakedModel baseModel;
private final IBlockState blockState; private final IBlockState blockState;
private final IBakedModel textureModel; private final IBakedModel textureModel;
@@ -59,7 +54,7 @@ public class FacadeWithBlockBakedModel implements IBakedModel
public FacadeWithBlockBakedModel( IBakedModel baseModel, IBlockState blockState, ItemStack textureItem, VertexFormat format ) public FacadeWithBlockBakedModel( IBakedModel baseModel, IBlockState blockState, ItemStack textureItem, VertexFormat format )
{ {
this.baseModel = baseModel; super( baseModel );
this.blockState = blockState; this.blockState = blockState;
this.textureItem = textureItem; this.textureItem = textureItem;
this.textureModel = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState( blockState ); this.textureModel = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState( blockState );
@@ -88,13 +83,7 @@ public class FacadeWithBlockBakedModel implements IBakedModel
} }
} }
return this.baseModel.getQuads( state, side, rand ); return this.getBaseModel().getQuads( state, side, rand );
}
@Override
public boolean isAmbientOcclusion()
{
return this.baseModel.isAmbientOcclusion();
} }
@Override @Override
@@ -109,18 +98,6 @@ public class FacadeWithBlockBakedModel implements IBakedModel
return false; return false;
} }
@Override
public TextureAtlasSprite getParticleTexture()
{
return this.baseModel.getParticleTexture();
}
@Override
public ItemCameraTransforms getItemCameraTransforms()
{
return this.baseModel.getItemCameraTransforms();
}
@Override @Override
public ItemOverrideList getOverrides() public ItemOverrideList getOverrides()
{ {
@@ -22,6 +22,7 @@ package appeng.client.render.cablebus;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -52,6 +53,8 @@ import appeng.block.networking.BlockCableBus;
public class CableBusBakedModel implements IBakedModel public class CableBusBakedModel implements IBakedModel
{ {
private static final Map<CableBusRenderState, List<BakedQuad>> CABLE_MODEL_CACHE = new HashMap<>();
private final CableBuilder cableBuilder; private final CableBuilder cableBuilder;
private final FacadeBuilder facadeBuilder; private final FacadeBuilder facadeBuilder;
@@ -88,8 +91,15 @@ public class CableBusBakedModel implements IBakedModel
// translucent facades further down below. // translucent facades further down below.
if( layer == BlockRenderLayer.CUTOUT ) if( layer == BlockRenderLayer.CUTOUT )
{ {
// First, handle the cable at the center of the cable bus // First, handle the cable at the center of the cable bus
this.addCableQuads( renderState, quads ); final List<BakedQuad> cableModel = CABLE_MODEL_CACHE.computeIfAbsent( renderState, k ->
{
final List<BakedQuad> model = new ArrayList<>();
this.addCableQuads( renderState, model );
return model;
} );
quads.addAll( cableModel );
// Then handle attachments // Then handle attachments
for( EnumFacing facing : EnumFacing.values() ) for( EnumFacing facing : EnumFacing.values() )
@@ -168,6 +178,8 @@ public class CableBusBakedModel implements IBakedModel
return firstType == AECableType.DENSE_COVERED && secondType == AECableType.DENSE_COVERED; return firstType == AECableType.DENSE_COVERED && secondType == AECableType.DENSE_COVERED;
case DENSE_SMART: case DENSE_SMART:
return firstType == AECableType.DENSE_SMART && secondType == AECableType.DENSE_SMART; return firstType == AECableType.DENSE_SMART && secondType == AECableType.DENSE_SMART;
default:
break;
} }
return true; return true;
@@ -208,6 +220,8 @@ public class CableBusBakedModel implements IBakedModel
case DENSE_SMART: case DENSE_SMART:
this.cableBuilder.addStraightDenseSmartConnection( facing, cableColor, renderState.getChannelsOnSide().get( facing ), quadsOut ); this.cableBuilder.addStraightDenseSmartConnection( facing, cableColor, renderState.getChannelsOnSide().get( facing ), quadsOut );
break; break;
default:
break;
} }
return; // Don't render the other form of connection return; // Don't render the other form of connection
@@ -237,6 +251,8 @@ public class CableBusBakedModel implements IBakedModel
case DENSE_SMART: case DENSE_SMART:
// Dense cables do not render connections to parts since none can be attached // Dense cables do not render connections to parts since none can be attached
break; break;
default:
break;
} }
} }
@@ -265,6 +281,8 @@ public class CableBusBakedModel implements IBakedModel
case DENSE_SMART: case DENSE_SMART:
this.cableBuilder.addDenseSmartConnection( facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut ); this.cableBuilder.addDenseSmartConnection( facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut );
break; break;
default:
break;
} }
} }
} }
@@ -300,10 +318,8 @@ public class CableBusBakedModel implements IBakedModel
TextureAtlasSprite particleTexture = bakedModel.getParticleTexture(); TextureAtlasSprite particleTexture = bakedModel.getParticleTexture();
// If a part sub-model has no particle texture (indicated by it being the missing texture), don't // If a part sub-model has no particle texture (indicated by it being the missing texture),
// add // don't add it, so we don't get ugly missing texture break particles.
// it,
// so we don't get ugly missing texture break particles.
if( this.textureMap.getMissingSprite() != particleTexture ) if( this.textureMap.getMissingSprite() != particleTexture )
{ {
result.add( particleTexture ); result.add( particleTexture );
@@ -328,7 +344,7 @@ public class CableBusBakedModel implements IBakedModel
@Override @Override
public boolean isAmbientOcclusion() public boolean isAmbientOcclusion()
{ {
return false; return true;
} }
@Override @Override
@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.Objects;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
@@ -153,4 +154,43 @@ public class CableBusRenderState
return this.boundingBoxes; return this.boundingBoxes;
} }
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ( ( this.attachmentConnections == null ) ? 0 : this.attachmentConnections.hashCode() );
result = prime * result + ( ( this.cableBusAdjacent == null ) ? 0 : this.cableBusAdjacent.hashCode() );
result = prime * result + ( ( this.cableColor == null ) ? 0 : this.cableColor.hashCode() );
result = prime * result + ( ( this.cableType == null ) ? 0 : this.cableType.hashCode() );
result = prime * result + ( ( this.channelsOnSide == null ) ? 0 : this.channelsOnSide.hashCode() );
result = prime * result + ( ( this.connectionTypes == null ) ? 0 : this.connectionTypes.hashCode() );
result = prime * result + ( ( this.coreType == null ) ? 0 : this.coreType.hashCode() );
return result;
}
@Override
public boolean equals( Object obj )
{
if( this == obj )
{
return true;
}
if( obj == null )
{
return false;
}
if( getClass() != obj.getClass() )
{
return false;
}
final CableBusRenderState other = (CableBusRenderState) obj;
return this.cableColor == other.cableColor && this.cableType == other.cableType && this.coreType == other.coreType && Objects
.equals( this.attachmentConnections, other.attachmentConnections ) && Objects.equals( this.cableBusAdjacent,
other.cableBusAdjacent ) && Objects.equals( this.channelsOnSide, other.channelsOnSide ) && Objects.equals( this.connectionTypes,
other.connectionTypes );
}
} }
@@ -59,6 +59,8 @@ public class CubeBuilder
private int color = 0xFFFFFFFF; private int color = 0xFFFFFFFF;
private boolean useStandardUV = false;
private boolean renderFullBright; private boolean renderFullBright;
public CubeBuilder( VertexFormat format, List<BakedQuad> output ) public CubeBuilder( VertexFormat format, List<BakedQuad> output )
@@ -142,6 +144,8 @@ public class CubeBuilder
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder( this.format ); UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder( this.format );
builder.setTexture( texture ); builder.setTexture( texture );
builder.setQuadOrientation( face ); builder.setQuadOrientation( face );
builder.setQuadTint( -1 );
builder.setApplyDiffuseLighting( true );
UvVector uv = new UvVector(); UvVector uv = new UvVector();
@@ -154,6 +158,10 @@ public class CubeBuilder
uv.u2 = texture.getInterpolatedU( customUv.z ); uv.u2 = texture.getInterpolatedU( customUv.z );
uv.v2 = texture.getInterpolatedV( customUv.w ); uv.v2 = texture.getInterpolatedV( customUv.w );
} }
else if( this.useStandardUV )
{
uv = this.getStandardUv( face, texture, x1, y1, z1, x2, y2, z2 );
}
else else
{ {
uv = this.getDefaultUv( face, texture, x1, y1, z1, x2, y2, z2 ); uv = this.getDefaultUv( face, texture, x1, y1, z1, x2, y2, z2 );
@@ -199,8 +207,7 @@ public class CubeBuilder
break; break;
} }
int[] vertexData = builder.build().getVertexData(); this.output.add( builder.build() );
this.output.add( new BakedQuad( vertexData, -1, face, texture, true, this.format ) );
} }
private UvVector getDefaultUv( EnumFacing face, TextureAtlasSprite texture, float x1, float y1, float z1, float x2, float y2, float z2 ) private UvVector getDefaultUv( EnumFacing face, TextureAtlasSprite texture, float x1, float y1, float z1, float x2, float y2, float z2 )
@@ -251,6 +258,51 @@ public class CubeBuilder
return uv; return uv;
} }
private UvVector getStandardUv( EnumFacing face, TextureAtlasSprite texture, float x1, float y1, float z1, float x2, float y2, float z2 )
{
UvVector uv = new UvVector();
switch( face )
{
case DOWN:
uv.u1 = texture.getInterpolatedU( x1 * 16 );
uv.v1 = texture.getInterpolatedV( 16 - z1 * 16 );
uv.u2 = texture.getInterpolatedU( x2 * 16 );
uv.v2 = texture.getInterpolatedV( 16 - z2 * 16 );
break;
case UP:
uv.u1 = texture.getInterpolatedU( x1 * 16 );
uv.v1 = texture.getInterpolatedV( z1 * 16 );
uv.u2 = texture.getInterpolatedU( x2 * 16 );
uv.v2 = texture.getInterpolatedV( z2 * 16 );
break;
case NORTH:
uv.u1 = texture.getInterpolatedU( 16 - x1 * 16 );
uv.v1 = texture.getInterpolatedV( 16 - y1 * 16 );
uv.u2 = texture.getInterpolatedU( 16 - x2 * 16 );
uv.v2 = texture.getInterpolatedV( 16 - y2 * 16 );
break;
case SOUTH:
uv.u1 = texture.getInterpolatedU( x1 * 16 );
uv.v1 = texture.getInterpolatedV( 16 - y1 * 16 );
uv.u2 = texture.getInterpolatedU( x2 * 16 );
uv.v2 = texture.getInterpolatedV( 16 - y2 * 16 );
break;
case WEST:
uv.u1 = texture.getInterpolatedU( z1 * 16 );
uv.v1 = texture.getInterpolatedV( 16 - y1 * 16 );
uv.u2 = texture.getInterpolatedU( z2 * 16 );
uv.v2 = texture.getInterpolatedV( 16 - y2 * 16 );
break;
case EAST:
uv.u1 = texture.getInterpolatedU( 16 - z2 * 16 );
uv.v1 = texture.getInterpolatedV( 16 - y1 * 16 );
uv.u2 = texture.getInterpolatedU( 16 - z1 * 16 );
uv.v2 = texture.getInterpolatedV( 16 - y2 * 16 );
break;
}
return uv;
}
// uv.u1, uv.v1 // uv.u1, uv.v1
private void putVertexTL( UnpackedBakedQuad.Builder builder, EnumFacing face, float x, float y, float z, UvVector uv ) private void putVertexTL( UnpackedBakedQuad.Builder builder, EnumFacing face, float x, float y, float z, UvVector uv )
{ {
@@ -484,6 +536,15 @@ public class CubeBuilder
this.uvRotations[facing.ordinal()] = (byte) rotation; this.uvRotations[facing.ordinal()] = (byte) rotation;
} }
/**
* CubeBuilder uses UV optimized for cables by default.
* This switches to standard UV coordinates.
*/
public void useStandardUV()
{
this.useStandardUV = true;
}
public List<BakedQuad> getOutput() public List<BakedQuad> getOutput()
{ {
return this.output; return this.output;
@@ -175,6 +175,7 @@ public class FacadeBuilder
// Reset to no color multiplicator // Reset to no color multiplicator
builder.setColorRGB( 0xFFFFFF ); builder.setColorRGB( 0xFFFFFF );
builder.useStandardUV();
// We only render the stilt if we don't intersect with any part directly, and if there's no part on our side // We only render the stilt if we don't intersect with any part directly, and if there's no part on our side
if( renderStilt && busBounds == null && layer == BlockRenderLayer.CUTOUT ) if( renderStilt && busBounds == null && layer == BlockRenderLayer.CUTOUT )
@@ -438,22 +439,22 @@ public class FacadeBuilder
private static AxisAlignedBB getFacadeBox( EnumFacing side, boolean thinFacades ) private static AxisAlignedBB getFacadeBox( EnumFacing side, boolean thinFacades )
{ {
int thickness = thinFacades ? 1 : 2; double thickness = ( thinFacades ? 1 : 2 ) / 16.0;
switch( side ) switch( side )
{ {
case DOWN: case DOWN:
return new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, ( thickness ) / 16.0, 1.0 ); return new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, thickness, 1.0 );
case EAST: case EAST:
return new AxisAlignedBB( ( 16.0 - thickness ) / 16.0, 0.0, 0.0, 1.0, 1.0, 1.0 ); return new AxisAlignedBB( 1.0 - thickness, 0.0, 0.0, 1.0, 1.0, 1.0 );
case NORTH: case NORTH:
return new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, 1.0, ( thickness ) / 16.0 ); return new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, 1.0, thickness );
case SOUTH: case SOUTH:
return new AxisAlignedBB( 0.0, 0.0, ( 16.0 - thickness ) / 16.0, 1.0, 1.0, 1.0 ); return new AxisAlignedBB( 0.0, 0.0, 1.0 - thickness, 1.0, 1.0, 1.0 );
case UP: case UP:
return new AxisAlignedBB( 0.0, ( 16.0 - thickness ) / 16.0, 0.0, 1.0, 1.0, 1.0 ); return new AxisAlignedBB( 0.0, 1.0 - thickness, 0.0, 1.0, 1.0, 1.0 );
case WEST: case WEST:
return new AxisAlignedBB( 0.0, 0.0, 0.0, ( thickness ) / 16.0, 1.0, 1.0 ); return new AxisAlignedBB( 0.0, 0.0, 0.0, thickness, 1.0, 1.0 );
default: default:
throw new IllegalArgumentException( "Unsupported face: " + side ); throw new IllegalArgumentException( "Unsupported face: " + side );
} }
@@ -19,14 +19,11 @@
package appeng.container; package appeng.container;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@@ -37,8 +34,6 @@ import net.minecraft.inventory.IContainerListener;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.PlayerInvWrapper; import net.minecraftforge.items.wrapper.PlayerInvWrapper;
@@ -73,7 +68,7 @@ import appeng.container.slot.SlotPlayerInv;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction; import appeng.core.sync.packets.PacketInventoryAction;
import appeng.core.sync.packets.PacketPartialItem; import appeng.core.sync.packets.PacketTargetItemStack;
import appeng.core.sync.packets.PacketValueConfig; import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.ICustomNameObject; import appeng.helpers.ICustomNameObject;
import appeng.helpers.InventoryAction; import appeng.helpers.InventoryAction;
@@ -93,7 +88,6 @@ public abstract class AEBaseContainer extends Container
private final TileEntity tileEntity; private final TileEntity tileEntity;
private final IPart part; private final IPart part;
private final IGuiItemObject obj; private final IGuiItemObject obj;
private final List<PacketPartialItem> dataChunks = new LinkedList<>();
private final HashMap<Integer, SyncData> syncData = new HashMap<>(); private final HashMap<Integer, SyncData> syncData = new HashMap<>();
private boolean isContainerValid = true; private boolean isContainerValid = true;
private String customName; private String customName;
@@ -175,47 +169,6 @@ public abstract class AEBaseContainer extends Container
this.prepareSync(); this.prepareSync();
} }
public void postPartial( final PacketPartialItem packetPartialItem )
{
this.dataChunks.add( packetPartialItem );
if( packetPartialItem.getPageCount() == this.dataChunks.size() )
{
this.parsePartials();
}
}
private void parsePartials()
{
int total = 0;
for( final PacketPartialItem ppi : this.dataChunks )
{
total += ppi.getSize();
}
final byte[] buffer = new byte[total];
int cursor = 0;
for( final PacketPartialItem ppi : this.dataChunks )
{
cursor = ppi.write( buffer, cursor );
}
try
{
final NBTTagCompound data = CompressedStreamTools.readCompressed( new ByteArrayInputStream( buffer ) );
if( data != null )
{
this.setTargetStack( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( new ItemStack( data ) ) );
}
}
catch( final IOException e )
{
AELog.debug( e );
}
this.dataChunks.clear();
}
public IAEItemStack getTargetStack() public IAEItemStack getTargetStack()
{ {
return this.clientRequestedTargetItem; return this.clientRequestedTargetItem;
@@ -235,47 +188,7 @@ public abstract class AEBaseContainer extends Container
return; return;
} }
final ByteArrayOutputStream stream = new ByteArrayOutputStream(); NetworkHandler.instance().sendToServer( new PacketTargetItemStack( (AEItemStack) stack ) );
final NBTTagCompound item = new NBTTagCompound();
if( stack != null )
{
stack.writeToNBT( item );
}
try
{
CompressedStreamTools.writeCompressed( item, stream );
final int maxChunkSize = 30000;
final List<byte[]> miniPackets = new LinkedList<>();
final byte[] data = stream.toByteArray();
final ByteArrayInputStream bis = new ByteArrayInputStream( data, 0, stream.size() );
while( bis.available() > 0 )
{
final int nextBLock = bis.available() > maxChunkSize ? maxChunkSize : bis.available();
final byte[] nextSegment = new byte[nextBLock];
bis.read( nextSegment );
miniPackets.add( nextSegment );
}
bis.close();
stream.close();
int page = 0;
for( final byte[] packet : miniPackets )
{
final PacketPartialItem ppi = new PacketPartialItem( page, miniPackets.size(), packet );
page++;
NetworkHandler.instance().sendToServer( ppi );
}
}
catch( final IOException e )
{
AELog.debug( e );
return;
}
} }
this.clientRequestedTargetItem = stack == null ? null : stack.copy(); this.clientRequestedTargetItem = stack == null ? null : stack.copy();
@@ -1108,7 +1021,8 @@ public abstract class AEBaseContainer extends Container
{ {
try try
{ {
NetworkHandler.instance().sendTo( new PacketInventoryAction( InventoryAction.UPDATE_HAND, 0, AEItemStack.fromItemStack( p.inventory.getItemStack() ) ), NetworkHandler.instance().sendTo(
new PacketInventoryAction( InventoryAction.UPDATE_HAND, 0, AEItemStack.fromItemStack( p.inventory.getItemStack() ) ),
p ); p );
} }
catch( final IOException e ) catch( final IOException e )
+6
View File
@@ -51,6 +51,7 @@ import appeng.core.crash.CrashInfo;
import appeng.core.crash.IntegrationCrashEnhancement; import appeng.core.crash.IntegrationCrashEnhancement;
import appeng.core.crash.ModCrashEnhancement; import appeng.core.crash.ModCrashEnhancement;
import appeng.core.features.AEFeature; import appeng.core.features.AEFeature;
import appeng.core.stats.AdvancementTriggers;
import appeng.core.sync.GuiBridge; import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.worlddata.WorldData; import appeng.core.worlddata.WorldData;
@@ -141,6 +142,11 @@ public final class AppEng
return this.registration.storageDimensionID; return this.registration.storageDimensionID;
} }
public AdvancementTriggers getAdvancementTriggers()
{
return this.registration.advancementTriggers;
}
@EventHandler @EventHandler
private void preInit( final FMLPreInitializationEvent event ) private void preInit( final FMLPreInitializationEvent event )
{ {
+39 -4
View File
@@ -20,6 +20,8 @@ package appeng.core;
import java.io.File; import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@@ -27,6 +29,9 @@ import javax.annotation.Nonnull;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.advancements.ICriterionInstance;
import net.minecraft.advancements.ICriterionTrigger;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.model.ModelResourceLocation;
@@ -49,6 +54,7 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistry;
@@ -72,6 +78,7 @@ import appeng.api.networking.storage.IStorageGrid;
import appeng.api.networking.ticking.ITickManager; import appeng.api.networking.ticking.ITickManager;
import appeng.api.parts.IPartHelper; import appeng.api.parts.IPartHelper;
import appeng.api.recipes.IRecipeHandler; import appeng.api.recipes.IRecipeHandler;
import appeng.bootstrap.ICriterionTriggerRegistry;
import appeng.bootstrap.IModelRegistry; import appeng.bootstrap.IModelRegistry;
import appeng.bootstrap.components.IBlockRegistrationComponent; import appeng.bootstrap.components.IBlockRegistrationComponent;
import appeng.bootstrap.components.IInitComponent; import appeng.bootstrap.components.IInitComponent;
@@ -88,7 +95,9 @@ import appeng.core.features.registries.cell.BasicCellHandler;
import appeng.core.features.registries.cell.CreativeCellHandler; import appeng.core.features.registries.cell.CreativeCellHandler;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.core.localization.PlayerMessages; import appeng.core.localization.PlayerMessages;
import appeng.core.stats.PlayerStatsRegistration; import appeng.core.stats.AdvancementTriggers;
import appeng.core.stats.PartItemPredicate;
import appeng.core.stats.Stats;
import appeng.core.worlddata.SpatialDimensionManager; import appeng.core.worlddata.SpatialDimensionManager;
import appeng.hooks.TickHandler; import appeng.hooks.TickHandler;
import appeng.items.materials.ItemMaterial; import appeng.items.materials.ItemMaterial;
@@ -131,6 +140,7 @@ final class Registration
DimensionType storageDimensionType; DimensionType storageDimensionType;
int storageDimensionID; int storageDimensionID;
Biome storageBiome; Biome storageBiome;
AdvancementTriggers advancementTriggers;
private File recipeDirectory; private File recipeDirectory;
private CustomRecipeConfig customRecipeConfig; private CustomRecipeConfig customRecipeConfig;
@@ -286,9 +296,9 @@ final class Registration
registries.matterCannon().registerAmmo( ammoStack, weight ); registries.matterCannon().registerAmmo( ammoStack, weight );
} ); } );
final PlayerStatsRegistration registration = new PlayerStatsRegistration( MinecraftForge.EVENT_BUS, AEConfig.instance() ); PartItemPredicate.register();
registration.registerAchievementHandlers(); Stats.register();
registration.registerAchievements(); this.advancementTriggers = new AdvancementTriggers( new CriterionTrigggerRegistry() );
} }
@SubscribeEvent @SubscribeEvent
@@ -581,4 +591,29 @@ final class Registration
} }
} }
private static class CriterionTrigggerRegistry implements ICriterionTriggerRegistry
{
private Method method;
CriterionTrigggerRegistry()
{
this.method = ReflectionHelper.findMethod( CriteriaTriggers.class, "register", "func_192118_a", ICriterionTrigger.class );
method.setAccessible( true );
}
@Override
public void register( ICriterionTrigger<? extends ICriterionInstance> trigger )
{
try
{
method.invoke( null, trigger );
}
catch( IllegalAccessException | IllegalArgumentException | InvocationTargetException e )
{
AELog.debug( e );
}
}
}
} }
+3 -3
View File
@@ -21,7 +21,7 @@ package appeng.core.api;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import appeng.api.exceptions.FailedConnection; import appeng.api.exceptions.FailedConnectionException;
import appeng.api.networking.IGridBlock; import appeng.api.networking.IGridBlock;
import appeng.api.networking.IGridConnection; import appeng.api.networking.IGridConnection;
import appeng.api.networking.IGridHelper; import appeng.api.networking.IGridHelper;
@@ -54,12 +54,12 @@ public class ApiGrid implements IGridHelper
} }
@Override @Override
public IGridConnection createGridConnection( final IGridNode a, final IGridNode b ) throws FailedConnection public IGridConnection createGridConnection( final IGridNode a, final IGridNode b ) throws FailedConnectionException
{ {
Preconditions.checkNotNull( a ); Preconditions.checkNotNull( a );
Preconditions.checkNotNull( b ); Preconditions.checkNotNull( b );
return new GridConnection( a, b, AEPartLocation.INTERNAL ); return GridConnection.create( a, b, AEPartLocation.INTERNAL );
} }
} }
@@ -343,7 +343,7 @@ public final class ApiItems implements IItems
@Override @Override
public IItemDefinition chargedStaff() public IItemDefinition chargedStaff()
{ {
return this.memoryCard; return this.chargedStaff;
} }
@Override @Override
@@ -21,7 +21,7 @@ package appeng.core.api.definitions;
import appeng.api.definitions.IItemDefinition; import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IParts; import appeng.api.definitions.IParts;
import appeng.api.exceptions.MissingDefinition; import appeng.api.exceptions.MissingDefinitionException;
import appeng.api.util.AEColor; import appeng.api.util.AEColor;
import appeng.api.util.AEColoredItemDefinition; import appeng.api.util.AEColoredItemDefinition;
import appeng.bootstrap.FeatureFactory; import appeng.bootstrap.FeatureFactory;
@@ -180,28 +180,28 @@ public final class ApiParts implements IParts
@Override @Override
public AEColoredItemDefinition lumenCableSmart() public AEColoredItemDefinition lumenCableSmart()
{ {
throw new MissingDefinition( "Lumen Smart Cable has yet to be implemented." ); throw new MissingDefinitionException( "Lumen Smart Cable has yet to be implemented." );
// return this.lumenCableSmart; // return this.lumenCableSmart;
} }
@Override @Override
public AEColoredItemDefinition lumenCableCovered() public AEColoredItemDefinition lumenCableCovered()
{ {
throw new MissingDefinition( "Lumen Covered Cable has yet to be implemented." ); throw new MissingDefinitionException( "Lumen Covered Cable has yet to be implemented." );
// return this.lumenCableCovered; // return this.lumenCableCovered;
} }
@Override @Override
public AEColoredItemDefinition lumenCableGlass() public AEColoredItemDefinition lumenCableGlass()
{ {
throw new MissingDefinition( "Lumen Glass Cable has yet to be implemented." ); throw new MissingDefinitionException( "Lumen Glass Cable has yet to be implemented." );
// return this.lumenCableGlass; // return this.lumenCableGlass;
} }
@Override @Override
public AEColoredItemDefinition lumenDenseCableSmart() public AEColoredItemDefinition lumenDenseCableSmart()
{ {
throw new MissingDefinition( "Lumen Dense Cable has yet to be implemented." ); throw new MissingDefinitionException( "Lumen Dense Cable has yet to be implemented." );
// return this.lumenCableDense; // return this.lumenCableDense;
} }
@@ -33,6 +33,7 @@ import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.ISaveProvider; import appeng.api.storage.ISaveProvider;
import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEStack;
import appeng.api.util.AEPartLocation; import appeng.api.util.AEPartLocation;
import appeng.core.sync.GuiBridge; import appeng.core.sync.GuiBridge;
import appeng.me.storage.CellInventory; import appeng.me.storage.CellInventory;
@@ -50,7 +51,7 @@ public class BasicCellHandler implements ICellHandler
} }
@Override @Override
public IMEInventoryHandler getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel channel ) public <T extends IAEStack<T>> IMEInventoryHandler<T> getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel<T> channel )
{ {
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
{ {
@@ -29,6 +29,7 @@ import appeng.api.storage.ICellRegistry;
import appeng.api.storage.IMEInventoryHandler; import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.ISaveProvider; import appeng.api.storage.ISaveProvider;
import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageChannel;
import appeng.api.storage.data.IAEStack;
public class CellRegistry implements ICellRegistry public class CellRegistry implements ICellRegistry
@@ -85,7 +86,7 @@ public class CellRegistry implements ICellRegistry
} }
@Override @Override
public IMEInventoryHandler getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel chan ) public <T extends IAEStack<T>> IMEInventoryHandler<T> getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel<T> chan )
{ {
if( is.isEmpty() ) if( is.isEmpty() )
{ {
@@ -64,11 +64,15 @@ public enum ButtonToolTips
TransferToStorageCell, TransferToStorageCell,
ToggleSortDirection, ToggleSortDirection,
SearchMode_Auto,
SearchMode_Auto,
SearchMode_Standard, SearchMode_Standard,
SearchMode_JEIAuto, SearchMode_JEIAuto,
SearchMode_JEIStandard, SearchMode_JEIStandard,
SearchMode_AutoKeep,
SearchMode_StandardKeep,
SearchMode_JEIAutoKeep,
SearchMode_JEIStandardKeep,
SearchMode, SearchMode,
ItemName, ItemName,
@@ -137,7 +141,11 @@ public enum ButtonToolTips
SchedulingMode, SchedulingMode,
SchedulingModeDefault, SchedulingModeDefault,
SchedulingModeRoundRobin, SchedulingModeRoundRobin,
SchedulingModeRandom; SchedulingModeRandom,
FilterMode,
FilterModeKeep,
FilterModeClear;
private final String root; private final String root;
@@ -1,73 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.stats;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
import appeng.util.Platform;
/**
* handles the achievement when an {@link net.minecraft.item.Item} is crafted by a player.
* The achievement is only added if its a real {@link net.minecraft.entity.player.EntityPlayer}.
*
* @author thatsIch
* @since rv2
*/
public class AchievementCraftingHandler
{
private final PlayerDifferentiator differentiator;
public AchievementCraftingHandler( final PlayerDifferentiator differentiator )
{
this.differentiator = differentiator;
}
@SubscribeEvent
public void onPlayerCraftingEvent( final PlayerEvent.ItemCraftedEvent event )
{
if( this.differentiator.isNoPlayer( event.player ) || event.crafting.isEmpty() )
{
return;
}
for( final Achievements achievement : Achievements.values() )
{
switch( achievement.getType() )
{
case Craft:
if( Platform.itemComparisons().isSameItem( achievement.getStack(), event.crafting ) )
{
achievement.addToPlayer( event.player );
return;
}
break;
case CraftItem:
if( achievement.getStack() != null && achievement.getStack().getItem().getClass() == event.crafting.getItem().getClass() )
{
achievement.addToPlayer( event.player );
return;
}
default:
}
}
}
}
@@ -1,61 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.stats;
/**
* Hierarchy of the AE2 achievements
*
* @author thatsIch
* @since rv2
*/
public class AchievementHierarchy
{
/**
* Setup hierarchy through assigning parents.
*/
void registerAchievementHierarchy()
{
// Achievements.Presses.setParent( Achievements.Compass );
//
// Achievements.Fluix.setParent( Achievements.ChargedQuartz );
//
// Achievements.Charger.setParent( Achievements.Fluix );
//
// Achievements.CrystalGrowthAccelerator.setParent( Achievements.Charger );
//
// Achievements.GlassCable.setParent( Achievements.Charger );
//
// Achievements.SpatialIOExplorer.setParent( Achievements.SpatialIO );
//
// Achievements.IOPort.setParent( Achievements.StorageCell );
//
// Achievements.PatternTerminal.setParent( Achievements.CraftingTerminal );
//
// Achievements.Controller.setParent( Achievements.Networking1 );
//
// Achievements.Networking2.setParent( Achievements.Controller );
//
// Achievements.Networking3.setParent( Achievements.Networking2 );
//
// Achievements.P2P.setParent( Achievements.Controller );
//
// Achievements.Recursive.setParent( Achievements.Controller );
}
}
@@ -1,64 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.stats;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
import appeng.util.Platform;
/**
* handles the achievement when an {@link net.minecraft.item.Item} is picked up by a player.
* The achievement is only added if its a real {@link net.minecraft.entity.player.EntityPlayer}.
*
* @author thatsIch
* @since rv2
*/
public class AchievementPickupHandler
{
private final PlayerDifferentiator differentiator;
public AchievementPickupHandler( final PlayerDifferentiator differentiator )
{
this.differentiator = differentiator;
}
@SubscribeEvent
public void onItemPickUp( final PlayerEvent.ItemPickupEvent event )
{
if( this.differentiator.isNoPlayer( event.player ) || event.pickedUp == null || event.pickedUp.getItem().isEmpty() )
{
return;
}
final ItemStack is = event.pickedUp.getItem();
for( final Achievements achievement : Achievements.values() )
{
if( achievement.getType() == AchievementType.Pickup && Platform.itemComparisons().isSameItem( achievement.getStack(), is ) )
{
achievement.addToPlayer( event.player );
return;
}
}
}
}
@@ -1,173 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.stats;
import net.minecraft.advancements.Advancement;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.definitions.IItemDefinition;
import appeng.api.util.AEColor;
import appeng.api.util.AEColoredItemDefinition;
public enum Achievements
{
// done
Compass( -2, -4, AEApi.instance().definitions().blocks().skyCompass(), AchievementType.Craft ),
// done
Presses( -2, -2, AEApi.instance().definitions().materials().logicProcessorPress(), AchievementType.Custom ),
// done
SpatialIO( -4, -4, AEApi.instance().definitions().blocks().spatialIOPort(), AchievementType.Craft ),
// done
SpatialIOExplorer( -4, -2, AEApi.instance().definitions().items().spatialCell128(), AchievementType.Custom ),
// done
StorageCell( -6, -4, AEApi.instance().definitions().items().cell64k(), AchievementType.CraftItem ),
// done
IOPort( -6, -2, AEApi.instance().definitions().blocks().iOPort(), AchievementType.Craft ),
// done
CraftingTerminal( -8, -4, AEApi.instance().definitions().parts().craftingTerminal(), AchievementType.Craft ),
// done
PatternTerminal( -8, -2, AEApi.instance().definitions().parts().patternTerminal(), AchievementType.Craft ),
// done
ChargedQuartz( 0, -4, AEApi.instance().definitions().materials().certusQuartzCrystalCharged(), AchievementType.Pickup ),
// done
Fluix( 0, -2, AEApi.instance().definitions().materials().fluixCrystal(), AchievementType.Pickup ),
// done
Charger( 0, 0, AEApi.instance().definitions().blocks().charger(), AchievementType.Craft ),
// done
CrystalGrowthAccelerator( -2, 0, AEApi.instance().definitions().blocks().quartzGrowthAccelerator(), AchievementType.Craft ),
// done
GlassCable( 2, 0, AEApi.instance().definitions().parts().cableGlass(), AchievementType.Craft ),
// done
Networking1( 4, -6, AEApi.instance().definitions().parts().cableCovered(), AchievementType.Custom ),
// done
Controller( 4, -4, AEApi.instance().definitions().blocks().controller(), AchievementType.Craft ),
// done
Networking2( 4, 0, AEApi.instance().definitions().parts().cableSmart(), AchievementType.Custom ),
// done
Networking3( 4, 2, AEApi.instance().definitions().parts().cableDenseSmart(), AchievementType.Custom ),
// done
P2P( 2, -2, AEApi.instance().definitions().parts().p2PTunnelME(), AchievementType.Craft ),
// done
Recursive( 6, -2, AEApi.instance().definitions().blocks().iface(), AchievementType.Craft ),
// done
CraftingCPU( 6, 0, AEApi.instance().definitions().blocks().craftingStorage64k(), AchievementType.CraftItem ),
// done
Facade( 6, 2, AEApi.instance().definitions().items().facade(), AchievementType.CraftItem ),
// done
NetworkTool( 8, 0, AEApi.instance().definitions().items().networkTool(), AchievementType.Craft ),
// done
PortableCell( 8, 2, AEApi.instance().definitions().items().portableCell(), AchievementType.Craft ),
// done
StorageBus( 10, 0, AEApi.instance().definitions().parts().storageBus(), AchievementType.Craft ),
// done
QNB( 10, 2, AEApi.instance().definitions().blocks().quantumLink(), AchievementType.Craft );
private final ItemStack stack;
private final AchievementType type;
private final int x;
private final int y;
private Advancement parent;
private Advancement stat;
Achievements( final int x, final int y, final AEColoredItemDefinition which, final AchievementType type )
{
this.stack = ( which != null ) ? which.stack( AEColor.TRANSPARENT, 1 ) : ItemStack.EMPTY;
this.type = type;
this.x = x;
this.y = y;
}
Achievements( final int x, final int y, final IItemDefinition which, final AchievementType type )
{
this.stack = which.maybeStack( 1 ).orElse( ItemStack.EMPTY );
this.type = type;
this.x = x;
this.y = y;
}
Achievements( final int x, final int y, final ItemStack which, final AchievementType type )
{
this.stack = which;
this.type = type;
this.x = x;
this.y = y;
}
void setParent( final Achievements parent )
{
this.parent = parent.getAchievement();
}
public Advancement getAchievement()
{
// if( this.stat == null && !this.getStack().isEmpty() )
// {
// this.stat = new Advancement( "achievement.ae2." + this.name(), "ae2." + this.name(), this.x, this.y,
// this.getStack(), this.parent );
// this.stat.registerStat();
// }
return this.stat;
}
public void addToPlayer( final EntityPlayer player )
{
// player.addStat( this.getAchievement(), 1 );
}
AchievementType getType()
{
return this.type;
}
ItemStack getStack()
{
return this.stack;
}
}
@@ -0,0 +1,59 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2017, 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.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 AdvancementTriggers( ICriterionTriggerRegistry registry )
{
registry.register( networkApprentice );
registry.register( networkEngineer );
registry.register( networkAdmin );
registry.register( spatialExplorer );
}
public IAdvancementTrigger getNetworkApprentice()
{
return this.networkApprentice;
}
public IAdvancementTrigger getNetworkEngineer()
{
return this.networkEngineer;
}
public IAdvancementTrigger getNetworkAdmin()
{
return this.networkAdmin;
}
public IAdvancementTrigger getSpatialExplorer()
{
return this.spatialExplorer;
}
}
@@ -0,0 +1,174 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2017, 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.stats;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import net.minecraft.advancements.ICriterionTrigger;
import net.minecraft.advancements.PlayerAdvancements;
import net.minecraft.advancements.critereon.AbstractCriterionInstance;
import net.minecraft.entity.player.EntityPlayerMP;
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 AppEngAdvancementTrigger( String parString )
{
super();
ID = new ResourceLocation( AppEng.MOD_ID, parString );
}
@Override
public ResourceLocation getId()
{
return ID;
}
@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 );
}
l.add( listener );
}
@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.isEmpty() )
{
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() );
}
public void trigger( EntityPlayerMP parPlayer )
{
AppEngAdvancementTrigger.Listeners l = this.listeners.get( parPlayer.getAdvancements() );
if( l != null )
{
l.trigger( parPlayer );
}
}
public static class Instance extends AbstractCriterionInstance
{
public Instance( ResourceLocation parID )
{
super( parID );
}
public boolean test()
{
return true;
}
}
static class Listeners
{
private final PlayerAdvancements playerAdvancements;
private final Set<ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance>> listeners = new HashSet<>();
Listeners( PlayerAdvancements playerAdvancementsIn )
{
this.playerAdvancements = playerAdvancementsIn;
}
public boolean isEmpty()
{
return this.listeners.isEmpty();
}
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 trigger( EntityPlayerMP 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<>();
}
list.add( listener );
}
}
if( list != null )
{
for( ICriterionTrigger.Listener<AppEngAdvancementTrigger.Instance> l : list )
{
l.grantCriterion( this.playerAdvancements );
}
}
}
}
}
@@ -1,6 +1,6 @@
/* /*
* This file is part of Applied Energistics 2. * This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. * Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
* *
* Applied Energistics 2 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU Lesser General Public License as published by
@@ -19,9 +19,11 @@
package appeng.core.stats; package appeng.core.stats;
public enum AchievementType import net.minecraft.entity.player.EntityPlayerMP;
@FunctionalInterface
public interface IAdvancementTrigger
{ {
void trigger( EntityPlayerMP parPlayer );
Craft, CraftItem, Pickup, Custom
} }
@@ -0,0 +1,70 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2017, 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.stats;
import com.google.gson.JsonObject;
import net.minecraft.advancements.critereon.ItemPredicate;
import net.minecraft.item.ItemStack;
import net.minecraft.util.JsonUtils;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.advancements.critereon.ItemPredicates;
import appeng.core.AppEng;
import appeng.items.parts.ItemPart;
import appeng.items.parts.PartType;
public class PartItemPredicate extends ItemPredicate
{
private final PartType partType;
public PartItemPredicate( String partName )
{
this.partType = PartType.valueOf( partName.toUpperCase() );
}
@Override
public boolean test( ItemStack item )
{
if( ItemPart.instance != null && item.getItem() == ItemPart.instance )
{
return ItemPart.instance.getTypeByStack( item ) == this.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 void register()
{
ItemPredicates.register( new ResourceLocation( AppEng.MOD_ID, "part" ), PartItemPredicate::deserialize );
}
}
@@ -1,52 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.stats;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.util.FakePlayer;
/**
* Can differentiate if a {@link net.minecraft.entity.player.EntityPlayer} is a real player or not
*
* @author thatsIch
* @since rv2
*/
public class PlayerDifferentiator
{
/**
* Can determine if an {@link net.minecraft.entity.player.EntityPlayer} is not a real player.
* This is based on if the
*
* @param player is:
* - null
* - dead
* - fake
*
* @param player to be checked player
*
* @return true if
* @param player is not a real player
*/
boolean isNoPlayer( final EntityPlayer player )
{
return player == null || player.isDead || player instanceof FakePlayer;
}
}
@@ -1,115 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.core.stats;
import net.minecraftforge.fml.common.eventhandler.EventBus;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
/**
* Registers any items a player is picking up or is crafting.
* Registered items are added to the player stats.
* This will only happen if the {@link AEFeature#ACHIEVEMENTS} feature is enabled.
*/
public class PlayerStatsRegistration
{
/**
* {@link net.minecraftforge.fml.common.eventhandler.EventBus} to which the handlers might get posted to depending
* if the feature is enabled
*/
private final EventBus bus;
/**
* is true if the {@link appeng.core.features.AEFeature#ACHIEVEMENTS} is enabled in the
*
* @param config
*/
private final boolean isAchievementFeatureEnabled;
/**
* Constructs this with an {@link net.minecraftforge.fml.common.eventhandler.EventBus} and
* {@link appeng.core.AEConfig}.
*
* @param bus {@see #bus}
* @param config {@link appeng.core.AEConfig} which is used to determine if the
* {@link appeng.core.features.AEFeature#ACHIEVEMENTS} is enabled
*/
public PlayerStatsRegistration( final EventBus bus, final AEConfig config )
{
this.bus = bus;
this.isAchievementFeatureEnabled = config.isFeatureEnabled( AEFeature.ACHIEVEMENTS );
}
/**
* Registers the {@link appeng.core.stats.AchievementCraftingHandler} and
* {@link appeng.core.stats.AchievementPickupHandler} to the {@link #bus} if {@link #isAchievementFeatureEnabled} is
* true.
*/
public void registerAchievementHandlers()
{
if( this.isAchievementFeatureEnabled )
{
final PlayerDifferentiator differentiator = new PlayerDifferentiator();
final AchievementCraftingHandler craftingHandler = new AchievementCraftingHandler( differentiator );
final AchievementPickupHandler pickupHandler = new AchievementPickupHandler( differentiator );
this.bus.register( craftingHandler );
this.bus.register( pickupHandler );
}
}
/**
* Registers the {@link appeng.core.stats.AchievementHierarchy} and adds all {@link appeng.core.stats.Achievements}
* to a new {@link net.minecraft.advancements.Advancement}.
*/
public void registerAchievements()
{
if( this.isAchievementFeatureEnabled )
{
final AchievementHierarchy hierarchy = new AchievementHierarchy();
hierarchy.registerAchievementHierarchy();
for( final Stats s : Stats.values() )
{
s.getStat();
}
/**
* register
*/
// final ArrayList<Achievement> list = new ArrayList<Achievement>();
//
// for( final Achievements a : Achievements.values() )
// {
// final Achievement ach = a.getAchievement();
// if( ach != null )
// {
// list.add( ach );
// }
// }
//
// final AchievementPage ae2AchievementPage = new AchievementPage( "Applied Energistics 2", list.toArray(
// new Achievement[list.size()] ) );
// AchievementPage.registerAchievementPage( ae2AchievementPage );
}
}
}
+8 -8
View File
@@ -44,18 +44,18 @@ public enum Stats
public void addToPlayer( final EntityPlayer player, final int howMany ) public void addToPlayer( final EntityPlayer player, final int howMany )
{ {
player.addStat( this.getStat(), howMany ); player.addStat( this.stat, howMany );
} }
StatBasic getStat() public static void register()
{ {
if( this.stat == null ) for( final Stats s : Stats.values() )
{ {
this.stat = new StatBasic( "stat.ae2." + this.name(), new TextComponentTranslation( "stat.ae2." + this.name() ) ); if( s.stat == null )
this.stat.registerStat(); {
s.stat = new StatBasic( "stat.ae2." + s.name(), new TextComponentTranslation( "stat.ae2." + s.name() ) );
s.stat.registerStat();
}
} }
return this.stat;
} }
} }
@@ -41,11 +41,11 @@ import appeng.core.sync.packets.PacketMatterCannon;
import appeng.core.sync.packets.PacketMockExplosion; import appeng.core.sync.packets.PacketMockExplosion;
import appeng.core.sync.packets.PacketPaintedEntity; import appeng.core.sync.packets.PacketPaintedEntity;
import appeng.core.sync.packets.PacketPartPlacement; import appeng.core.sync.packets.PacketPartPlacement;
import appeng.core.sync.packets.PacketPartialItem;
import appeng.core.sync.packets.PacketPatternSlot; import appeng.core.sync.packets.PacketPatternSlot;
import appeng.core.sync.packets.PacketProgressBar; import appeng.core.sync.packets.PacketProgressBar;
import appeng.core.sync.packets.PacketSwapSlots; import appeng.core.sync.packets.PacketSwapSlots;
import appeng.core.sync.packets.PacketSwitchGuis; import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketTargetItemStack;
import appeng.core.sync.packets.PacketTransitionEffect; import appeng.core.sync.packets.PacketTransitionEffect;
import appeng.core.sync.packets.PacketValueConfig; import appeng.core.sync.packets.PacketValueConfig;
@@ -90,7 +90,7 @@ public class AppEngPacketHandlerBase
PACKET_RECIPE_JEI( PacketJEIRecipe.class ), PACKET_RECIPE_JEI( PacketJEIRecipe.class ),
PACKET_PARTIAL_ITEM( PacketPartialItem.class ), PACKET_TARGET_ITEM( PacketTargetItemStack.class ),
PACKET_CRAFTING_REQUEST( PacketCraftRequest.class ), PACKET_CRAFTING_REQUEST( PacketCraftRequest.class ),
+1 -48
View File
@@ -20,13 +20,9 @@ package appeng.core.sync;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.util.List;
import com.google.common.collect.Lists;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@@ -36,8 +32,6 @@ import net.minecraftforge.fml.relauncher.ReflectionHelper;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
import appeng.api.definitions.IComparableDefinition;
import appeng.api.definitions.IMaterials;
import appeng.api.exceptions.AppEngException; import appeng.api.exceptions.AppEngException;
import appeng.api.features.IWirelessTermHandler; import appeng.api.features.IWirelessTermHandler;
import appeng.api.implementations.IUpgradeableHost; import appeng.api.implementations.IUpgradeableHost;
@@ -92,7 +86,6 @@ import appeng.container.implementations.ContainerUpgradeable;
import appeng.container.implementations.ContainerVibrationChamber; import appeng.container.implementations.ContainerVibrationChamber;
import appeng.container.implementations.ContainerWireless; import appeng.container.implementations.ContainerWireless;
import appeng.container.implementations.ContainerWirelessTerm; import appeng.container.implementations.ContainerWirelessTerm;
import appeng.core.stats.Achievements;
import appeng.helpers.IInterfaceHost; import appeng.helpers.IInterfaceHost;
import appeng.helpers.IPriorityHost; import appeng.helpers.IPriorityHost;
import appeng.helpers.WirelessTerminalGuiObject; import appeng.helpers.WirelessTerminalGuiObject;
@@ -356,27 +349,7 @@ public enum GuiBridge implements IGuiHandler
.typeName( tE ) + " )" ); .typeName( tE ) + " )" );
} }
final Object o = target.newInstance( inventory, tE ); return target.newInstance( inventory, tE );
/**
* triggers achievement when the player sees presses.
*/
if( o instanceof AEBaseContainer )
{
final AEBaseContainer bc = (AEBaseContainer) o;
for( final Object so : bc.inventorySlots )
{
if( so instanceof Slot )
{
final ItemStack is = ( (Slot) so ).getStack();
final IMaterials materials = AEApi.instance().definitions().materials();
this.addPressAchievementToPlayer( is, materials, inventory.player );
}
}
}
return o;
} }
catch( final Throwable t ) catch( final Throwable t )
{ {
@@ -410,26 +383,6 @@ public enum GuiBridge implements IGuiHandler
return inventory.getClass().getName(); return inventory.getClass().getName();
} }
private void addPressAchievementToPlayer( final ItemStack newItem, final IMaterials possibleMaterials, final EntityPlayer player )
{
final IComparableDefinition logic = possibleMaterials.logicProcessorPress();
final IComparableDefinition eng = possibleMaterials.engProcessorPress();
final IComparableDefinition calc = possibleMaterials.calcProcessorPress();
final IComparableDefinition silicon = possibleMaterials.siliconPress();
final List<IComparableDefinition> presses = Lists.newArrayList( logic, eng, calc, silicon );
for( final IComparableDefinition press : presses )
{
if( press.isSameAs( newItem ) )
{
Achievements.Presses.addToPlayer( player );
return;
}
}
}
@Override @Override
public Object getClientGuiElement( final int ordinal, final EntityPlayer player, final World w, final int x, final int y, final int z ) public Object getClientGuiElement( final int ordinal, final EntityPlayer player, final World w, final int x, final int y, final int z )
{ {
@@ -41,6 +41,7 @@ import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGrid; import appeng.api.networking.IGrid;
import appeng.api.networking.IGridNode; import appeng.api.networking.IGridNode;
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.energy.IEnergyGrid; import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.security.ISecurityGrid; import appeng.api.networking.security.ISecurityGrid;
import appeng.api.networking.storage.IStorageGrid; import appeng.api.networking.storage.IStorageGrid;
@@ -132,6 +133,7 @@ public class PacketJEIRecipe extends AppEngPacket
final IStorageGrid inv = grid.getCache( IStorageGrid.class ); final IStorageGrid inv = grid.getCache( IStorageGrid.class );
final IEnergyGrid energy = grid.getCache( IEnergyGrid.class ); final IEnergyGrid energy = grid.getCache( IEnergyGrid.class );
final ISecurityGrid security = grid.getCache( ISecurityGrid.class ); final ISecurityGrid security = grid.getCache( ISecurityGrid.class );
final ICraftingGrid crafting = grid.getCache( ICraftingGrid.class );
final IItemHandler craftMatrix = cct.getInventoryByName( "crafting" ); final IItemHandler craftMatrix = cct.getInventoryByName( "crafting" );
final IItemHandler playerInventory = cct.getInventoryByName( "player" ); final IItemHandler playerInventory = cct.getInventoryByName( "player" );
@@ -179,13 +181,23 @@ public class PacketJEIRecipe extends AppEngPacket
{ {
request.setStackSize( 1 ); request.setStackSize( 1 );
IAEItemStack out; IAEItemStack out;
if( cct.useRealItems() ) if( cct.useRealItems() )
{ {
out = Platform.poweredExtraction( energy, storage, request, cct.getActionSource() ); out = Platform.poweredExtraction( energy, storage, request, cct.getActionSource() );
} }
else else
{ {
out = storage.extractItems( request, Actionable.SIMULATE, cct.getActionSource() ); // 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 ) if( out != null )
@@ -25,35 +25,56 @@ import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import appeng.container.AEBaseContainer; import appeng.container.AEBaseContainer;
import appeng.core.AELog;
import appeng.core.sync.AppEngPacket; import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo; import appeng.core.sync.network.INetworkInfo;
import appeng.util.item.AEItemStack;
public class PacketPartialItem extends AppEngPacket public class PacketTargetItemStack extends AppEngPacket
{ {
private AEItemStack stack;
private final short pageNum;
private final byte[] data;
// automatic. // automatic.
public PacketPartialItem( final ByteBuf stream ) public PacketTargetItemStack( final ByteBuf stream )
{ {
this.pageNum = stream.readShort(); try
stream.readBytes( this.data = new byte[stream.readableBytes()] ); {
if( stream.readableBytes() > 0 )
{
this.stack = AEItemStack.fromPacket( stream );
}
else
{
this.stack = null;
}
}
catch( Exception ex )
{
AELog.debug( ex );
this.stack = null;
}
} }
// api // api
public PacketPartialItem( final int page, final int maxPages, final byte[] buf ) public PacketTargetItemStack( AEItemStack stack )
{ {
this.stack = stack;
final ByteBuf data = Unpooled.buffer(); final ByteBuf data = Unpooled.buffer();
this.pageNum = (short) ( page | ( maxPages << 8 ) );
this.data = buf;
data.writeInt( this.getPacketID() ); data.writeInt( this.getPacketID() );
data.writeShort( this.pageNum ); if( stack != null )
data.writeBytes( buf ); {
try
{
stack.writeToPacket( data );
}
catch( Exception ex )
{
AELog.debug( ex );
}
}
this.configureWrite( data ); this.configureWrite( data );
} }
@@ -62,23 +83,8 @@ public class PacketPartialItem extends AppEngPacket
{ {
if( player.openContainer instanceof AEBaseContainer ) if( player.openContainer instanceof AEBaseContainer )
{ {
( (AEBaseContainer) player.openContainer ).postPartial( this ); ( (AEBaseContainer) player.openContainer ).setTargetStack( this.stack );
} }
} }
public int getPageCount()
{
return this.pageNum >> 8;
}
public int getSize()
{
return this.data.length;
}
public int write( final byte[] buffer, final int cursor )
{
System.arraycopy( this.data, 0, buffer, cursor, this.data.length );
return cursor + this.data.length;
}
} }
@@ -363,7 +363,7 @@ public class CraftingTreeNode
if( this.howManyEmitted > 0 ) if( this.howManyEmitted > 0 )
{ {
final IAEItemStack i = this.what.copy(); final IAEItemStack i = this.what.copy().reset();
i.setStackSize( this.howManyEmitted ); i.setStackSize( this.howManyEmitted );
craftingCPUCluster.addEmitable( i ); craftingCPUCluster.addEmitable( i );
} }
@@ -23,28 +23,24 @@ import java.util.Random;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.exceptions.MissingDefinition; import appeng.api.exceptions.MissingDefinitionException;
import appeng.client.render.effects.ChargedOreFX; import appeng.client.render.effects.ChargedOreFX;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.AppEng; import appeng.core.AppEng;
public final class BlockChargedQuartzOre extends BlockQuartzOre public class BlockChargedQuartzOre extends BlockQuartzOre
{ {
public BlockChargedQuartzOre()
{
this.setBoostBrightnessLow( 2 );
this.setBoostBrightnessHigh( 5 );
}
@Override @Override
public Item getItemDropped( final IBlockState state, final Random rand, final int fortune ) public Item getItemDropped( final IBlockState state, final Random rand, final int fortune )
{ {
@@ -53,7 +49,7 @@ public final class BlockChargedQuartzOre extends BlockQuartzOre
.materials() .materials()
.certusQuartzCrystalCharged() .certusQuartzCrystalCharged()
.maybeItem() .maybeItem()
.orElseThrow( () -> new MissingDefinition( "Tried to access charged certus quartz crystal, even though they are disabled" ) ); .orElseThrow( () -> new MissingDefinitionException( "Tried to access charged certus quartz crystal, even though they are disabled" ) );
} }
@Override @Override
@@ -64,10 +60,21 @@ public final class BlockChargedQuartzOre extends BlockQuartzOre
.materials() .materials()
.certusQuartzCrystalCharged() .certusQuartzCrystalCharged()
.maybeStack( 1 ) .maybeStack( 1 )
.orElseThrow( () -> new MissingDefinition( "Tried to access charged certus quartz crystal, even though they are disabled" ) ) .orElseThrow( () -> new MissingDefinitionException( "Tried to access charged certus quartz crystal, even though they are disabled" ) )
.getItemDamage(); .getItemDamage();
} }
@Override
public ItemStack getPickBlock( IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player )
{
return AEApi.instance()
.definitions()
.blocks()
.quartzOreCharged()
.maybeStack( 1 )
.orElseThrow( () -> new MissingDefinitionException( "Tried to access charged certus quartz ore, even though they are disabled" ) );
}
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly( Side.CLIENT )
public void randomDisplayTick( final IBlockState state, final World w, final BlockPos pos, final Random r ) public void randomDisplayTick( final IBlockState state, final World w, final BlockPos pos, final Random r )
@@ -27,28 +27,20 @@ import net.minecraft.item.Item;
import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.exceptions.MissingDefinition; import appeng.api.exceptions.MissingDefinitionException;
import appeng.block.AEBaseBlock; import appeng.block.AEBaseBlock;
public class BlockQuartzOre extends AEBaseBlock public class BlockQuartzOre extends AEBaseBlock
{ {
private int boostBrightnessLow;
private int boostBrightnessHigh;
private boolean enhanceBrightness;
public BlockQuartzOre() public BlockQuartzOre()
{ {
super( Material.ROCK ); super( Material.ROCK );
this.setHardness( 3.0F ); this.setHardness( 3.0F );
this.setResistance( 5.0F ); this.setResistance( 5.0F );
this.boostBrightnessLow = 0;
this.boostBrightnessHigh = 1;
this.enhanceBrightness = false;
} }
@Override @Override
@@ -58,76 +50,7 @@ public class BlockQuartzOre extends AEBaseBlock
} }
@Override @Override
public int getLightValue( final IBlockState state, final IBlockAccess worldIn, final BlockPos pos ) public int quantityDropped( IBlockState state, int fortune, Random rand )
{
int j1 = super.getLightValue( state, worldIn, pos );
if( this.enhanceBrightness )
{
j1 = Math.max( j1 >> 20, j1 >> 4 );
if( j1 > 4 )
{
j1 += this.boostBrightnessHigh;
}
else
{
j1 += this.boostBrightnessLow;
}
if( j1 > 15 )
{
j1 = 15;
}
return j1 << 20 | j1 << 4;
}
return j1;
}
@Override
public int quantityDropped( final Random rand )
{
return 1 + rand.nextInt( 2 );
}
@Override
public Item getItemDropped( final IBlockState state, /* is null */
final Random rand, final int fortune )
{
return AEApi.instance()
.definitions()
.materials()
.certusQuartzCrystal()
.maybeItem()
.orElseThrow( () -> new MissingDefinition( "Tried to access certus quartz crystal, even though they are disabled" ) );
}
@Override
public void dropBlockAsItemWithChance( final World w, final BlockPos pos, final IBlockState state, final float chance, final int fortune )
{
super.dropBlockAsItemWithChance( w, pos, state, chance, fortune );
if( this.getItemDropped( state, w.rand, fortune ) != Item.getItemFromBlock( this ) )
{
final int xp = MathHelper.getInt( w.rand, 2, 5 );
this.dropXpOnBlockBreak( w, pos, xp );
}
}
@Override
public int damageDropped( final IBlockState state )
{
return AEApi.instance()
.definitions()
.materials()
.certusQuartzCrystal()
.maybeStack( 1 )
.orElseThrow( () -> new MissingDefinition( "Tried to access certus quartz crystal, even though they are disabled" ) )
.getItemDamage();
}
@Override
public int quantityDroppedWithBonus( final int fortune, final Random rand )
{ {
if( fortune > 0 && Item.getItemFromBlock( this ) != this.getItemDropped( null, rand, fortune ) ) if( fortune > 0 && Item.getItemFromBlock( this ) != this.getItemDropped( null, rand, fortune ) )
{ {
@@ -146,18 +69,45 @@ public class BlockQuartzOre extends AEBaseBlock
} }
} }
void setBoostBrightnessLow( final int boostBrightnessLow ) @Override
public int quantityDropped( final Random rand )
{ {
this.boostBrightnessLow = boostBrightnessLow; return 1 + rand.nextInt( 2 );
} }
void setBoostBrightnessHigh( final int boostBrightnessHigh ) @Override
public void dropBlockAsItemWithChance( final World w, final BlockPos pos, final IBlockState state, final float chance, final int fortune )
{ {
this.boostBrightnessHigh = boostBrightnessHigh; super.dropBlockAsItemWithChance( w, pos, state, chance, fortune );
if( this.getItemDropped( state, w.rand, fortune ) != Item.getItemFromBlock( this ) )
{
final int xp = MathHelper.getInt( w.rand, 2, 5 );
this.dropXpOnBlockBreak( w, pos, xp );
}
} }
public void setEnhanceBrightness( final boolean enhanceBrightness ) @Override
public Item getItemDropped( final IBlockState state, final Random rand, final int fortune )
{ {
this.enhanceBrightness = enhanceBrightness; return AEApi.instance()
.definitions()
.materials()
.certusQuartzCrystal()
.maybeItem()
.orElseThrow( () -> new MissingDefinitionException( "Tried to access certus quartz crystal, even though they are disabled" ) );
}
@Override
public int damageDropped( final IBlockState state )
{
return AEApi.instance()
.definitions()
.materials()
.certusQuartzCrystal()
.maybeStack( 1 )
.orElseThrow( () -> new MissingDefinitionException( "Tried to access certus quartz crystal, even though they are disabled" ) )
.getItemDamage();
} }
} }
@@ -40,7 +40,6 @@ public abstract class AEBaseEntityItem extends EntityItem
super( world, x, y, z, stack ); super( world, x, y, z, stack );
} }
@SuppressWarnings( "unchecked" )
protected List<Entity> getCheckedEntitiesWithinAABBExcludingEntity( final AxisAlignedBB region ) protected List<Entity> getCheckedEntitiesWithinAABBExcludingEntity( final AxisAlignedBB region )
{ {
return this.world.getEntitiesWithinAABBExcludingEntity( this, region ); return this.world.getEntitiesWithinAABBExcludingEntity( this, region );
@@ -22,7 +22,7 @@ package appeng.integration;
import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModAPIManager; import net.minecraftforge.fml.common.ModAPIManager;
import appeng.api.exceptions.ModNotInstalled; import appeng.api.exceptions.ModNotInstalledException;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.AELog; import appeng.core.AELog;
@@ -96,7 +96,7 @@ final class IntegrationNode
} }
else else
{ {
throw new ModNotInstalled( this.modID ); throw new ModNotInstalledException( this.modID );
} }
this.mod.preInit(); this.mod.preInit();
@@ -130,7 +130,7 @@ final class IntegrationNode
if( this.getState() == IntegrationStage.FAILED ) if( this.getState() == IntegrationStage.FAILED )
{ {
AELog.info( this.displayName + " - Integration Disabled" ); AELog.info( this.displayName + " - Integration Disabled" );
if( !( this.exception instanceof ModNotInstalled ) ) if( !( this.exception instanceof ModNotInstalledException ) )
{ {
AELog.integration( this.exception ); AELog.integration( this.exception );
} }
@@ -29,8 +29,8 @@ import net.minecraft.item.ItemStack;
import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper; import mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper;
import appeng.api.exceptions.MissingIngredientError; import appeng.api.exceptions.MissingIngredientException;
import appeng.api.exceptions.RegistrationError; import appeng.api.exceptions.RegistrationException;
import appeng.api.recipes.IIngredient; import appeng.api.recipes.IIngredient;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.recipes.game.ShapedRecipe; import appeng.recipes.game.ShapedRecipe;
@@ -72,7 +72,7 @@ class ShapedRecipeWrapper implements IShapedCraftingRecipeWrapper
ItemStack[] is = ing.getItemStackSet(); ItemStack[] is = ing.getItemStackSet();
slotList = useSingleItems ? Platform.findPreferred( is ) : Arrays.asList( is ); slotList = useSingleItems ? Platform.findPreferred( is ) : Arrays.asList( is );
} }
catch( final RegistrationError | MissingIngredientError ignored ) catch( final RegistrationException | MissingIngredientException ignored )
{ {
} }
in.add( slotList ); in.add( slotList );
@@ -29,8 +29,8 @@ import net.minecraft.item.ItemStack;
import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jei.api.recipe.IRecipeWrapper;
import appeng.api.exceptions.MissingIngredientError; import appeng.api.exceptions.MissingIngredientException;
import appeng.api.exceptions.RegistrationError; import appeng.api.exceptions.RegistrationException;
import appeng.api.recipes.IIngredient; import appeng.api.recipes.IIngredient;
import appeng.recipes.game.ShapelessRecipe; import appeng.recipes.game.ShapelessRecipe;
@@ -60,7 +60,7 @@ class ShapelessRecipeWrapper implements IRecipeWrapper
{ {
inputs.add( Lists.newArrayList( ingredient.getItemStackSet() ) ); inputs.add( Lists.newArrayList( ingredient.getItemStackSet() ) );
} }
catch( RegistrationError | MissingIngredientError registrationError ) catch( RegistrationException | MissingIngredientException registrationError )
{ {
throw new RuntimeException( "Unable to register recipe with JEI" ); throw new RuntimeException( "Unable to register recipe with JEI" );
} }
@@ -55,7 +55,6 @@ public abstract class AEBaseItem extends Item
} }
@Override @Override
@SuppressWarnings( "unchecked" )
public final void getSubItems( final CreativeTabs creativeTab, final NonNullList<ItemStack> itemStacks ) public final void getSubItems( final CreativeTabs creativeTab, final NonNullList<ItemStack> itemStacks )
{ {
if( this.isInCreativeTab( creativeTab ) ) if( this.isInCreativeTab( creativeTab ) )
@@ -54,13 +54,12 @@ public class NetworkToolViewer implements INetworkTool, IAEAppEngInventory
@Override @Override
public void saveChanges() public void saveChanges()
{ {
this.inv.markDirty( -1 ); this.inv.writeToNBT( Platform.openNbtData( this.is ), "inv" );
} }
@Override @Override
public void onChangeInventory( IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack ) public void onChangeInventory( IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
{ {
this.inv.writeToNBT( Platform.openNbtData( this.is ), "inv" );
} }
@Override @Override
@@ -33,12 +33,12 @@ import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.implementations.items.IAEItemPowerStorage; import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.api.storage.IMEMonitor; import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageChannel;
import appeng.api.storage.MEMonitorHandler;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAEStack;
import appeng.api.util.IConfigManager; import appeng.api.util.IConfigManager;
import appeng.container.interfaces.IInventorySlotAware; import appeng.container.interfaces.IInventorySlotAware;
import appeng.me.helpers.MEMonitorHandler;
import appeng.me.storage.CellInventory; import appeng.me.storage.CellInventory;
import appeng.util.ConfigManager; import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost; import appeng.util.IConfigManagerHost;
@@ -45,7 +45,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.IExtendedBlockState;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.exceptions.MissingDefinition; import appeng.api.exceptions.MissingDefinitionException;
import appeng.api.parts.IAlphaPassItem; import appeng.api.parts.IAlphaPassItem;
import appeng.api.util.AEPartLocation; import appeng.api.util.AEPartLocation;
import appeng.core.AELog; import appeng.core.AELog;
@@ -318,7 +318,7 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
.items() .items()
.facade() .facade()
.maybeStack( 1 ) .maybeStack( 1 )
.orElseThrow( () -> new MissingDefinition( "Tried to create a facade, while facades are being deactivated." ) ); .orElseThrow( () -> new MissingDefinitionException( "Tried to create a facade, while facades are being deactivated." ) );
// Convert back to a registry name... // Convert back to a registry name...
Item item = Item.REGISTRY.getObjectById( ids[0] ); Item item = Item.REGISTRY.getObjectById( ids[0] );
@@ -39,7 +39,7 @@ import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
import appeng.api.config.IncludeExclude; import appeng.api.config.IncludeExclude;
import appeng.api.exceptions.MissingDefinition; import appeng.api.exceptions.MissingDefinitionException;
import appeng.api.implementations.items.IItemGroup; import appeng.api.implementations.items.IItemGroup;
import appeng.api.implementations.items.IStorageCell; import appeng.api.implementations.items.IStorageCell;
import appeng.api.implementations.items.IUpgradeModule; import appeng.api.implementations.items.IUpgradeModule;
@@ -303,7 +303,7 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe
.materials() .materials()
.emptyStorageCell() .emptyStorageCell()
.maybeStack( 1 ) .maybeStack( 1 )
.orElseThrow( () -> new MissingDefinition( "Tried to use empty storage cells while basic storage cells are defined." ) ); .orElseThrow( () -> new MissingDefinitionException( "Tried to use empty storage cells while basic storage cells are defined." ) );
} }
@Override @Override
@@ -85,21 +85,10 @@ class PoweredItemCapabilities implements ICapabilityProvider, IEnergyStorage
@Override @Override
public int receiveEnergy( int maxReceive, boolean simulate ) public int receiveEnergy( int maxReceive, boolean simulate )
{ {
if( simulate ) final double convertedOffer = PowerUnits.RF.convertTo( PowerUnits.AE, maxReceive );
{ final double overflow = this.item.injectAEPower( this.is, convertedOffer, simulate ? Actionable.SIMULATE : Actionable.MODULATE );
final int required = (int) PowerUnits.AE.convertTo( PowerUnits.RF, this.item.getAEMaxPower( this.is ) - this.item.getAECurrentPower( this.is ) );
if( maxReceive < required ) return maxReceive - (int) PowerUnits.AE.convertTo( PowerUnits.RF, overflow );
{
return 0;
}
return maxReceive - required;
}
else
{
final double powerRemainder = this.item.injectAEPower( this.is, PowerUnits.RF.convertTo( PowerUnits.AE, maxReceive ), Actionable.MODULATE );
return maxReceive - (int) PowerUnits.AE.convertTo( PowerUnits.RF, powerRemainder );
}
} }
@Override @Override
+81 -73
View File
@@ -23,7 +23,7 @@ import java.util.Arrays;
import java.util.EnumSet; import java.util.EnumSet;
import appeng.api.exceptions.ExistingConnectionException; import appeng.api.exceptions.ExistingConnectionException;
import appeng.api.exceptions.FailedConnection; import appeng.api.exceptions.FailedConnectionException;
import appeng.api.exceptions.NullNodeConnectionException; import appeng.api.exceptions.NullNodeConnectionException;
import appeng.api.exceptions.SecurityConnectionException; import appeng.api.exceptions.SecurityConnectionException;
import appeng.api.networking.GridFlags; import appeng.api.networking.GridFlags;
@@ -54,80 +54,11 @@ public class GridConnection implements IGridConnection, IPathItem
private AEPartLocation fromAtoB; private AEPartLocation fromAtoB;
private GridNode sideB; private GridNode sideB;
public GridConnection( final IGridNode aNode, final IGridNode bNode, final AEPartLocation fromAtoB ) throws FailedConnection private GridConnection( final GridNode aNode, final GridNode bNode, final AEPartLocation fromAtoB )
{ {
this.sideA = aNode;
final GridNode a = (GridNode) aNode;
final GridNode b = (GridNode) bNode;
if( Platform.securityCheck( a, b ) )
{
if( AEConfig.instance().isFeatureEnabled( AEFeature.LOG_SECURITY_AUDITS ) )
{
final DimensionalCoord aCoordinates = a.getGridBlock().getLocation();
final DimensionalCoord bCoordinates = b.getGridBlock().getLocation();
AELog.info( "Security audit 1 failed at [%s] belonging to player [id=%d]", aCoordinates.toString(), a.getPlayerID() );
AELog.info( "Security audit 2 failed at [%s] belonging to player [id=%d]", bCoordinates.toString(), b.getPlayerID() );
}
throw new SecurityConnectionException();
}
if( a == null || b == null )
{
throw new NullNodeConnectionException();
}
if( a.hasConnection( b ) || b.hasConnection( a ) )
{
final String aMachineClass = a.getGridBlock().getMachine().getClass().getSimpleName();
final String bMachineClass = b.getGridBlock().getMachine().getClass().getSimpleName();
final String aCoordinates = a.getGridBlock().getLocation().toString();
final String bCoordinates = b.getGridBlock().getLocation().toString();
throw new ExistingConnectionException( String.format( EXISTING_CONNECTION_MESSAGE, aMachineClass, aCoordinates, bMachineClass, bCoordinates,
fromAtoB ) );
}
this.sideA = a;
this.fromAtoB = fromAtoB; this.fromAtoB = fromAtoB;
this.sideB = b; this.sideB = bNode;
if( b.getMyGrid() == null )
{
b.setGrid( a.getInternalGrid() );
}
else
{
if( a.getMyGrid() == null )
{
final GridPropagator gp = new GridPropagator( b.getInternalGrid() );
a.beginVisit( gp );
}
else if( b.getMyGrid() == null )
{
final GridPropagator gp = new GridPropagator( a.getInternalGrid() );
b.beginVisit( gp );
}
else if( this.isNetworkABetter( a, b ) )
{
final GridPropagator gp = new GridPropagator( a.getInternalGrid() );
b.beginVisit( gp );
}
else
{
final GridPropagator gp = new GridPropagator( b.getInternalGrid() );
a.beginVisit( gp );
}
}
// a connection was destroyed RE-PATH!!
final IPathingGrid p = this.sideA.getInternalGrid().getCache( IPathingGrid.class );
p.repath();
this.sideA.addConnection( this );
this.sideB.addConnection( this );
} }
private boolean isNetworkABetter( final GridNode a, final GridNode b ) private boolean isNetworkABetter( final GridNode a, final GridNode b )
@@ -291,4 +222,81 @@ public class GridConnection implements IGridConnection, IPathItem
{ {
this.visitorIterationNumber = visitorIterationNumber; this.visitorIterationNumber = visitorIterationNumber;
} }
public static GridConnection create( final IGridNode aNode, final IGridNode bNode, final AEPartLocation fromAtoB ) throws FailedConnectionException
{
if( aNode == null || bNode == null )
{
throw new NullNodeConnectionException();
}
final GridNode a = (GridNode) aNode;
final GridNode b = (GridNode) bNode;
if( a.hasConnection( b ) || b.hasConnection( a ) )
{
final String aMachineClass = a.getGridBlock().getMachine().getClass().getSimpleName();
final String bMachineClass = b.getGridBlock().getMachine().getClass().getSimpleName();
final String aCoordinates = a.getGridBlock().getLocation().toString();
final String bCoordinates = b.getGridBlock().getLocation().toString();
throw new ExistingConnectionException( String.format( EXISTING_CONNECTION_MESSAGE, aMachineClass, aCoordinates, bMachineClass, bCoordinates,
fromAtoB ) );
}
if( !Platform.securityCheck( a, b ) )
{
if( AEConfig.instance().isFeatureEnabled( AEFeature.LOG_SECURITY_AUDITS ) )
{
final DimensionalCoord aCoordinates = a.getGridBlock().getLocation();
final DimensionalCoord bCoordinates = b.getGridBlock().getLocation();
AELog.info( "Security audit 1 failed at [%s] belonging to player [id=%d]", aCoordinates.toString(), a.getPlayerID() );
AELog.info( "Security audit 2 failed at [%s] belonging to player [id=%d]", bCoordinates.toString(), b.getPlayerID() );
}
throw new SecurityConnectionException();
}
// Create the actual connection
final GridConnection connection = new GridConnection( a, b, fromAtoB );
// Update both nodes with the new connection.
if( a.getMyGrid() == null )
{
b.setGrid( a.getInternalGrid() );
}
else
{
if( a.getMyGrid() == null )
{
final GridPropagator gp = new GridPropagator( b.getInternalGrid() );
aNode.beginVisit( gp );
}
else if( b.getMyGrid() == null )
{
final GridPropagator gp = new GridPropagator( a.getInternalGrid() );
bNode.beginVisit( gp );
}
else if( connection.isNetworkABetter( a, b ) )
{
final GridPropagator gp = new GridPropagator( a.getInternalGrid() );
b.beginVisit( gp );
}
else
{
final GridPropagator gp = new GridPropagator( b.getInternalGrid() );
a.beginVisit( gp );
}
}
// a connection was destroyed RE-PATH!!
final IPathingGrid p = connection.sideA.getInternalGrid().getCache( IPathingGrid.class );
p.repath();
connection.sideA.addConnection( connection );
connection.sideB.addConnection( connection );
return connection;
}
} }
+24 -7
View File
@@ -32,7 +32,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.exceptions.FailedConnection; import appeng.api.exceptions.FailedConnectionException;
import appeng.api.exceptions.SecurityConnectionException;
import appeng.api.networking.GridFlags; import appeng.api.networking.GridFlags;
import appeng.api.networking.GridNotification; import appeng.api.networking.GridNotification;
import appeng.api.networking.IGrid; import appeng.api.networking.IGrid;
@@ -50,6 +51,7 @@ import appeng.api.util.AEColor;
import appeng.api.util.AEPartLocation; import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord; import appeng.api.util.DimensionalCoord;
import appeng.api.util.IReadOnlyCollection; import appeng.api.util.IReadOnlyCollection;
import appeng.core.AELog;
import appeng.core.worlddata.WorldData; import appeng.core.worlddata.WorldData;
import appeng.hooks.TickHandler; import appeng.hooks.TickHandler;
import appeng.me.pathfinding.IPathItem; import appeng.me.pathfinding.IPathItem;
@@ -216,7 +218,7 @@ public class GridNode implements IGridNode, IPathItem
this.compressedData |= ( 1 << ( dir.ordinal() + 8 ) ); this.compressedData |= ( 1 << ( dir.ordinal() + 8 ) );
} }
this.FindConnections(); this.findConnections();
this.getInternalGrid(); this.getInternalGrid();
} }
@@ -393,7 +395,7 @@ public class GridNode implements IGridNode, IPathItem
return this.usedChannels; return this.usedChannels;
} }
private void FindConnections() private void findConnections()
{ {
if( !this.gridProxy.isWorldAccessible() ) if( !this.gridProxy.isWorldAccessible() )
{ {
@@ -455,12 +457,19 @@ public class GridNode implements IGridNode, IPathItem
// construct a new connection between these two nodes. // construct a new connection between these two nodes.
try try
{ {
new GridConnection( node, this, f.getOpposite() ); GridConnection.create( node, this, f.getOpposite() );
} }
catch( final FailedConnection e ) catch( SecurityConnectionException e )
{ {
AELog.debug( e );
TickHandler.INSTANCE.addCallable( node.getWorld(), new MachineSecurityBreak( this ) ); TickHandler.INSTANCE.addCallable( node.getWorld(), new MachineSecurityBreak( this ) );
return;
}
catch( final FailedConnectionException e )
{
AELog.debug( e );
return; return;
} }
} }
@@ -482,12 +491,20 @@ public class GridNode implements IGridNode, IPathItem
// construct a new connection between these two nodes. // construct a new connection between these two nodes.
try try
{ {
new GridConnection( node, this, f.getOpposite() ); GridConnection.create( node, this, f.getOpposite() );
} }
catch( final FailedConnection e ) catch( SecurityConnectionException e )
{ {
AELog.debug( e );
TickHandler.INSTANCE.addCallable( node.getWorld(), new MachineSecurityBreak( this ) ); TickHandler.INSTANCE.addCallable( node.getWorld(), new MachineSecurityBreak( this ) );
return;
}
catch( final FailedConnectionException e )
{
AELog.debug( e );
return; return;
} }
} }
+1 -1
View File
@@ -379,7 +379,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
} }
@Override @Override
public List<IMEInventoryHandler> getCellArray( final IStorageChannel channel ) public List<IMEInventoryHandler> getCellArray( final IStorageChannel<?> channel )
{ {
final List<IMEInventoryHandler> list = new ArrayList<>( 1 ); final List<IMEInventoryHandler> list = new ArrayList<>( 1 );
+1 -1
View File
@@ -276,7 +276,7 @@ public class GridStorageCache implements IStorageGrid
} }
@Override @Override
public void postAlterationOfStoredItems( final IStorageChannel chan, final Iterable<? extends IAEStack> input, final IActionSource src ) public void postAlterationOfStoredItems( final IStorageChannel<?> chan, final Iterable<? extends IAEStack<?>> input, final IActionSource src )
{ {
this.storageMonitors.get( chan ).postChange( true, (Iterable) input, src ); this.storageMonitors.get( chan ).postChange( true, (Iterable) input, src );
} }
+17 -14
View File
@@ -26,6 +26,10 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import appeng.api.AEApi;
import appeng.api.networking.GridFlags; import appeng.api.networking.GridFlags;
import appeng.api.networking.IGrid; import appeng.api.networking.IGrid;
import appeng.api.networking.IGridBlock; import appeng.api.networking.IGridBlock;
@@ -43,8 +47,9 @@ import appeng.api.networking.pathing.IPathingGrid;
import appeng.api.util.AEPartLocation; import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord; import appeng.api.util.DimensionalCoord;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.core.features.AEFeature; import appeng.core.features.AEFeature;
import appeng.core.stats.Achievements; import appeng.core.stats.IAdvancementTrigger;
import appeng.me.GridConnection; import appeng.me.GridConnection;
import appeng.me.GridNode; import appeng.me.GridNode;
import appeng.me.pathfinding.AdHocChannelUpdater; import appeng.me.pathfinding.AdHocChannelUpdater;
@@ -340,26 +345,24 @@ public class PathGridCache implements IPathingGrid
{ {
if( this.lastChannels != this.getChannelsInUse() && AEConfig.instance().isFeatureEnabled( AEFeature.CHANNELS ) ) if( this.lastChannels != this.getChannelsInUse() && AEConfig.instance().isFeatureEnabled( AEFeature.CHANNELS ) )
{ {
final Achievements currentBracket = this.getAchievementBracket( this.getChannelsInUse() ); final IAdvancementTrigger currentBracket = this.getAchievementBracket( this.getChannelsInUse() );
final Achievements lastBracket = this.getAchievementBracket( this.lastChannels ); final IAdvancementTrigger lastBracket = this.getAchievementBracket( this.lastChannels );
if( currentBracket != lastBracket && currentBracket != null ) if( currentBracket != lastBracket && currentBracket != null )
{ {
final Set<Integer> players = new HashSet<>();
for( final IGridNode n : this.requireChannels ) for( final IGridNode n : this.requireChannels )
{ {
players.add( n.getPlayerID() ); EntityPlayer player = AEApi.instance().registries().players().findPlayer( n.getPlayerID() );
if( player instanceof EntityPlayerMP )
{
currentBracket.trigger( (EntityPlayerMP) player );
}
} }
// for( final int id : players )
// {
// Platform.addStat( id, currentBracket.getAchievement() );
// }
} }
} }
this.lastChannels = this.getChannelsInUse(); this.lastChannels = this.getChannelsInUse();
} }
private Achievements getAchievementBracket( final int ch ) private IAdvancementTrigger getAchievementBracket( final int ch )
{ {
if( ch < 8 ) if( ch < 8 )
{ {
@@ -368,15 +371,15 @@ public class PathGridCache implements IPathingGrid
if( ch < 128 ) if( ch < 128 )
{ {
return Achievements.Networking1; return AppEng.instance().getAdvancementTriggers().getNetworkApprentice();
} }
if( ch < 2048 ) if( ch < 2048 )
{ {
return Achievements.Networking2; return AppEng.instance().getAdvancementTriggers().getNetworkEngineer();
} }
return Achievements.Networking3; return AppEng.instance().getAdvancementTriggers().getNetworkAdmin();
} }
@MENetworkEventSubscribe @MENetworkEventSubscribe
@@ -440,7 +440,6 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
this.lastTime = 0; this.lastTime = 0;
this.elapsedTime = 0; this.elapsedTime = 0;
this.isComplete = true; this.isComplete = true;
} }
private void updateCPU() private void updateCPU()
@@ -32,12 +32,13 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.events.LocatableEventAnnounce; import appeng.api.events.LocatableEventAnnounce;
import appeng.api.events.LocatableEventAnnounce.LocatableEvent; import appeng.api.events.LocatableEventAnnounce.LocatableEvent;
import appeng.api.exceptions.FailedConnection; import appeng.api.exceptions.FailedConnectionException;
import appeng.api.features.ILocatable; import appeng.api.features.ILocatable;
import appeng.api.networking.IGridHost; import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode; import appeng.api.networking.IGridNode;
import appeng.api.util.AEPartLocation; import appeng.api.util.AEPartLocation;
import appeng.api.util.WorldCoord; import appeng.api.util.WorldCoord;
import appeng.core.AELog;
import appeng.me.cache.helpers.ConnectionWrapper; import appeng.me.cache.helpers.ConnectionWrapper;
import appeng.me.cluster.IAECluster; import appeng.me.cluster.IAECluster;
import appeng.tile.qnb.TileQuantumBridge; import appeng.tile.qnb.TileQuantumBridge;
@@ -158,9 +159,10 @@ public class QuantumCluster implements ILocatable, IAECluster
sideA.connection = sideB.connection = new ConnectionWrapper( AEApi.instance().grid().createGridConnection( sideA.getNode(), sideA.connection = sideB.connection = new ConnectionWrapper( AEApi.instance().grid().createGridConnection( sideA.getNode(),
sideB.getNode() ) ); sideB.getNode() ) );
} }
catch( final FailedConnection e ) catch( final FailedConnectionException e )
{ {
// :( // :(
AELog.debug( e );
} }
} }
else else
@@ -21,7 +21,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
package appeng.api.storage; package appeng.me.helpers;
import java.util.HashMap; import java.util.HashMap;
@@ -33,6 +33,10 @@ import com.google.common.collect.ImmutableList;
import appeng.api.config.AccessRestriction; import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.networking.security.IActionSource; import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
@@ -42,11 +46,9 @@ import appeng.api.storage.data.IItemList;
* listeners. * listeners.
* *
* @param <T> * @param <T>
* @deprecated
* *
* TODO: Needs to be redesigned to solve performance issues. Also should not be part of the API as class. * TODO: Needs to be redesigned to solve performance issues.
*/ */
@Deprecated
public class MEMonitorHandler<T extends IAEStack<T>> implements IMEMonitor<T> public class MEMonitorHandler<T extends IAEStack<T>> implements IMEMonitor<T>
{ {
@@ -48,7 +48,7 @@ import net.minecraft.world.World;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.config.YesNo; import appeng.api.config.YesNo;
import appeng.api.exceptions.FailedConnection; import appeng.api.exceptions.FailedConnectionException;
import appeng.api.implementations.parts.IPartCable; import appeng.api.implementations.parts.IPartCable;
import appeng.api.networking.IGridHost; import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode; import appeng.api.networking.IGridNode;
@@ -241,11 +241,11 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
{ {
try try
{ {
new GridConnection( cn, sn, AEPartLocation.INTERNAL ); GridConnection.create( cn, sn, AEPartLocation.INTERNAL );
} }
catch( final FailedConnection e ) catch( final FailedConnectionException e )
{ {
// ekk! AELog.debug( e );
bp.removeFromWorld(); bp.removeFromWorld();
this.setCenter( null ); this.setCenter( null );
@@ -292,11 +292,11 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
{ {
try try
{ {
new GridConnection( cn, sn, AEPartLocation.INTERNAL ); GridConnection.create( cn, sn, AEPartLocation.INTERNAL );
} }
catch( final FailedConnection e ) catch( final FailedConnectionException e )
{ {
// ekk! AELog.debug( e );
bp.removeFromWorld(); bp.removeFromWorld();
this.setSide( side, null ); this.setSide( side, null );
@@ -634,9 +634,10 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
{ {
AEApi.instance().grid().createGridConnection( cn, sn ); AEApi.instance().grid().createGridConnection( cn, sn );
} }
catch( final FailedConnection e ) catch( final FailedConnectionException e )
{ {
// ekk // ekk
AELog.debug( e );
} }
} }
} }
@@ -1087,7 +1088,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
this.getFacadeContainer().readFromNBT( data ); this.getFacadeContainer().readFromNBT( data );
} }
public List getDrops( final List drops ) public List<ItemStack> getDrops( final List<ItemStack> drops )
{ {
for( final AEPartLocation s : AEPartLocation.values() ) for( final AEPartLocation s : AEPartLocation.values() )
{ {
@@ -1111,7 +1112,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
return drops; return drops;
} }
public List getNoDrops( final List drops ) public List<ItemStack> getNoDrops( final List<ItemStack> drops )
{ {
for( final AEPartLocation s : AEPartLocation.values() ) for( final AEPartLocation s : AEPartLocation.values() )
{ {
@@ -1150,12 +1151,15 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
@Override @Override
public CableBusRenderState getRenderState() public CableBusRenderState getRenderState()
{ {
PartCable cable = (PartCable) this.getCenter(); final PartCable cable = (PartCable) this.getCenter();
CableBusRenderState renderState = new CableBusRenderState(); final CableBusRenderState renderState = new CableBusRenderState();
if( cable != null ) if( cable != null )
{ {
final boolean isSmart = cable.getCableConnectionType() == AECableType.SMART || cable.getCableConnectionType() == AECableType.DENSE_SMART;
final boolean isDense = cable.getCableConnectionType() == AECableType.DENSE_COVERED || cable.getCableConnectionType() == AECableType.DENSE_SMART;
renderState.setCableColor( cable.getCableColor() ); renderState.setCableColor( cable.getCableColor() );
renderState.setCableType( cable.getCableConnectionType() ); renderState.setCableType( cable.getCableConnectionType() );
renderState.setCoreType( CableCoreType.fromCableType( cable.getCableConnectionType() ) ); renderState.setCoreType( CableCoreType.fromCableType( cable.getCableConnectionType() ) );
@@ -1175,12 +1179,12 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
// Only use the incoming cable-type of the adjacent block, if it's not a cable bus itself // Only use the incoming cable-type of the adjacent block, if it's not a cable bus itself
// Dense cables however also respect the adjacent cable-type since their outgoing connection // Dense cables however also respect the adjacent cable-type since their outgoing connection
// point would look too big for other cable types // point would look too big for other cable types
BlockPos adjacentPos = this.getTile().getPos().offset( facing ); final BlockPos adjacentPos = this.getTile().getPos().offset( facing );
TileEntity adjacentTe = this.getTile().getWorld().getTileEntity( adjacentPos ); final TileEntity adjacentTe = this.getTile().getWorld().getTileEntity( adjacentPos );
if( adjacentTe instanceof IGridHost ) if( adjacentTe instanceof IGridHost )
{ {
if( !( adjacentTe instanceof IPartHost ) || cable.getCableConnectionType() == AECableType.DENSE_SMART || cable if( !( adjacentTe instanceof IPartHost ) || isDense )
.getCableConnectionType() == AECableType.DENSE_COVERED )
{ {
IGridHost gridHost = (IGridHost) adjacentTe; IGridHost gridHost = (IGridHost) adjacentTe;
connectionType = gridHost.getCableConnectionType( AEPartLocation.fromFacing( facing.getOpposite() ) ); connectionType = gridHost.getCableConnectionType( AEPartLocation.fromFacing( facing.getOpposite() ) );
@@ -1201,7 +1205,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
// adjacent tile requires it // adjacent tile requires it
for( EnumFacing facing : EnumFacing.values() ) for( EnumFacing facing : EnumFacing.values() )
{ {
int channels = cable.getChannelsOnSide( facing ); int channels = isSmart ? cable.getChannelsOnSide( facing ) : 0;
renderState.getChannelsOnSide().put( facing, channels ); renderState.getChannelsOnSide().put( facing, channels );
} }
} }
@@ -1209,14 +1213,14 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
// Determine attachments and facades // Determine attachments and facades
for( EnumFacing facing : EnumFacing.values() ) for( EnumFacing facing : EnumFacing.values() )
{ {
final FacadeRenderState facadeState = this.getFacadeRenderState( facing );
FacadeRenderState facadeState = this.getFacadeRenderState( facing );
if( facadeState != null ) if( facadeState != null )
{ {
renderState.getFacades().put( facing, facadeState ); renderState.getFacades().put( facing, facadeState );
} }
IPart part = this.getPart( facing ); final IPart part = this.getPart( facing );
if( part == null ) if( part == null )
{ {
@@ -1224,15 +1228,17 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
} }
// This will add the part's bounding boxes to the render state, which is required for facades // This will add the part's bounding boxes to the render state, which is required for facades
AEPartLocation loc = AEPartLocation.fromFacing( facing ); final AEPartLocation loc = AEPartLocation.fromFacing( facing );
IPartCollisionHelper bch = new BusCollisionHelper( renderState.getBoundingBoxes(), loc, null, true ); final IPartCollisionHelper bch = new BusCollisionHelper( renderState.getBoundingBoxes(), loc, null, true );
part.getBoxes( bch ); part.getBoxes( bch );
if( part instanceof IGridHost ) if( part instanceof IGridHost )
{ {
// Some attachments want a thicker cable than glass, account for that // Some attachments want a thicker cable than glass, account for that
IGridHost gridHost = (IGridHost) part; final IGridHost gridHost = (IGridHost) part;
AECableType desiredType = gridHost.getCableConnectionType( AEPartLocation.INTERNAL ); final AECableType desiredType = gridHost.getCableConnectionType( AEPartLocation.INTERNAL );
if( renderState.getCoreType() == CableCoreType.GLASS && ( desiredType == AECableType.SMART || desiredType == AECableType.COVERED ) ) if( renderState.getCoreType() == CableCoreType.GLASS && ( desiredType == AECableType.SMART || desiredType == AECableType.COVERED ) )
{ {
renderState.setCoreType( CableCoreType.COVERED ); renderState.setCoreType( CableCoreType.COVERED );
@@ -1254,14 +1260,16 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
private FacadeRenderState getFacadeRenderState( EnumFacing side ) private FacadeRenderState getFacadeRenderState( EnumFacing side )
{ {
// Store the "masqueraded" itemstack for the given side, if there is a facade // Store the "masqueraded" itemstack for the given side, if there is a facade
IFacadePart facade = this.getFacade( side.ordinal() ); final IFacadePart facade = this.getFacade( side.ordinal() );
if( facade != null ) if( facade != null )
{ {
ItemStack textureItem = facade.getTextureItem(); final ItemStack textureItem = facade.getTextureItem();
IBlockState blockState = facade.getBlockState(); final IBlockState blockState = facade.getBlockState();
if( blockState != null && textureItem != null ) if( blockState != null && textureItem != null )
{ {
EnumSet<EnumFacing> openFaces = this.calculateFaceOpenFaces( side ); final EnumSet<EnumFacing> openFaces = this.calculateFaceOpenFaces( side );
return new FacadeRenderState( blockState, openFaces, textureItem ); return new FacadeRenderState( blockState, openFaces, textureItem );
} }
} }
@@ -1273,9 +1281,9 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
{ {
final EnumSet<EnumFacing> out = EnumSet.of( side, side.getOpposite() ); final EnumSet<EnumFacing> out = EnumSet.of( side, side.getOpposite() );
final IFacadePart facade = this.getFacade( side.ordinal() ); final IFacadePart facade = this.getFacade( side.ordinal() );
final IBlockAccess blockAccess = this.getTile().getWorld();
final BlockPos pos = this.getTile().getPos();
IBlockAccess blockAccess = this.getTile().getWorld();
BlockPos pos = this.getTile().getPos();
for( final EnumFacing it : EnumFacing.values() ) for( final EnumFacing it : EnumFacing.values() )
{ {
if( !out.contains( it ) && this.hasAlphaDiff( blockAccess.getTileEntity( pos.offset( it ) ), side, facade ) ) if( !out.contains( it ) && this.hasAlphaDiff( blockAccess.getTileEntity( pos.offset( it ) ), side, facade ) )
@@ -20,6 +20,7 @@ package appeng.parts.automation;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@@ -28,6 +29,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemBlockSpecial;
import net.minecraft.item.ItemFirework; import net.minecraft.item.ItemFirework;
import net.minecraft.item.ItemSkull; import net.minecraft.item.ItemSkull;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -400,11 +402,11 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
{ {
if( this.getProxy().isActive() && channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) if( this.getProxy().isActive() && channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
{ {
final List<IMEInventoryHandler> Handler = new ArrayList<>( 1 ); final List<IMEInventoryHandler> handler = new ArrayList<>( 1 );
Handler.add( this.myHandler ); handler.add( this.myHandler );
return Handler; return handler;
} }
return new ArrayList<>(); return Collections.emptyList();
} }
@Override @Override
@@ -451,32 +453,14 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
if( w.getBlockState( tePos ).getBlock().isReplaceable( w, tePos ) ) if( w.getBlockState( tePos ).getBlock().isReplaceable( w, tePos ) )
{ {
if( placeBlock == YesNo.YES && ( i instanceof ItemBlock || i instanceof IPlantable || i instanceof ItemSkull || i instanceof ItemFirework || i instanceof IPartItem || i == Item if( placeBlock == YesNo.YES && ( i instanceof ItemBlock || i instanceof ItemBlockSpecial || i instanceof IPlantable || i instanceof ItemSkull || i instanceof ItemFirework || i instanceof IPartItem || i == Item
.getItemFromBlock( .getItemFromBlock( Blocks.REEDS ) ) )
Blocks.REEDS ) ) )
{ {
final EntityPlayer player = Platform.getPlayer( (WorldServer) w ); final EntityPlayer player = Platform.getPlayer( (WorldServer) w );
Platform.configurePlayer( player, side, this.getTile() ); Platform.configurePlayer( player, side, this.getTile() );
EnumHand hand = player.getActiveHand(); EnumHand hand = player.getActiveHand();
player.setHeldItem( hand, is ); player.setHeldItem( hand, is );
// TODO: LIMIT FIREWORKS
/*
* if( i instanceof ItemFirework )
* {
* Chunk c = w.getChunkFromBlockCoords( tePos );
* int sum = 0;
* for( List Z : c.geten )
* {
* sum += Z.size();
* }
* if( sum > 32 )
* {
* return input;
* }
* }
*/
maxStorage = is.getCount(); maxStorage = is.getCount();
worked = true; worked = true;
if( type == Actionable.MODULATE ) if( type == Actionable.MODULATE )
@@ -29,7 +29,6 @@ import net.minecraft.util.math.Vec3d;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
import appeng.api.config.PowerMultiplier;
import appeng.api.config.RedstoneMode; import appeng.api.config.RedstoneMode;
import appeng.api.config.Settings; import appeng.api.config.Settings;
import appeng.api.config.Upgrades; import appeng.api.config.Upgrades;
@@ -41,7 +40,6 @@ import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest; import appeng.api.networking.ticking.TickingRequest;
import appeng.api.parts.IPartCollisionHelper; import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartModel; import appeng.api.parts.IPartModel;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEMonitor; import appeng.api.storage.IMEMonitor;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
@@ -72,9 +70,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/import_bus_has_channel" ) ); public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/import_bus_has_channel" ) );
private final IActionSource source; private final IActionSource source;
private IMEInventory<IAEItemStack> destination = null; private int itemsToSend; // used in tickingRequest
private IAEItemStack lastItemChecked = null;
private int itemToSend; // used in tickingRequest
private boolean worked; // used in tickingRequest private boolean worked; // used in tickingRequest
@Reflected @Reflected
@@ -95,14 +91,24 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
return false; return false;
} }
final IAEItemStack out = this.destination.injectItems( try
this.lastItemChecked = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( stack ), Actionable.SIMULATE,
this.source );
if( out == null )
{ {
return true; final IMEMonitor<IAEItemStack> inv = this.getProxy().getStorage().getInventory(
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IAEItemStack out = inv.injectItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( stack ),
Actionable.SIMULATE,
this.source );
if( out == null )
{
return true;
}
return out.getStackSize() != stack.getCount();
}
catch( GridAccessException ex )
{
return false;
} }
return out.getStackSize() != stack.getCount();
} }
@Override @Override
@@ -165,9 +171,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
{ {
try try
{ {
this.itemToSend = this.calculateItemsToSend(); this.itemsToSend = this.calculateItemsToSend();
this.itemToSend = Math.min( this.itemToSend,
(int) ( 0.01 + this.getProxy().getEnergy().extractAEPower( this.itemToSend, Actionable.SIMULATE, PowerMultiplier.CONFIG ) ) );
final IMEMonitor<IAEItemStack> inv = this.getProxy().getStorage().getInventory( final IMEMonitor<IAEItemStack> inv = this.getProxy().getStorage().getInventory(
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
@@ -177,10 +181,10 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
for( int x = 0; x < this.availableSlots(); x++ ) for( int x = 0; x < this.availableSlots(); x++ )
{ {
final IAEItemStack ais = this.getConfig().getAEStackInSlot( x ); final IAEItemStack ais = this.getConfig().getAEStackInSlot( x );
if( ais != null && this.itemToSend > 0 ) if( ais != null && itemsToSend > 0 )
{ {
Configured = true; Configured = true;
while( this.itemToSend > 0 ) while( itemsToSend > 0 )
{ {
if( this.importStuff( myAdaptor, ais, inv, energy, fzMode ) ) if( this.importStuff( myAdaptor, ais, inv, energy, fzMode ) )
{ {
@@ -192,7 +196,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
if( !Configured ) if( !Configured )
{ {
while( this.itemToSend > 0 ) while( itemsToSend > 0 )
{ {
if( this.importStuff( myAdaptor, null, inv, energy, fzMode ) ) if( this.importStuff( myAdaptor, null, inv, energy, fzMode ) )
{ {
@@ -221,38 +225,32 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
{ {
newItems = myAdaptor.removeSimilarItems( toSend, whatToImport == null ? ItemStack.EMPTY : whatToImport.getDefinition(), fzMode, newItems = myAdaptor.removeSimilarItems( toSend, whatToImport == null ? ItemStack.EMPTY : whatToImport.getDefinition(), fzMode, this );
this.configDestination( inv ) );
} }
else else
{ {
newItems = myAdaptor.removeItems( toSend, whatToImport == null ? ItemStack.EMPTY : whatToImport.getDefinition(), this.configDestination( inv ) ); newItems = myAdaptor.removeItems( toSend, whatToImport == null ? ItemStack.EMPTY : whatToImport.getDefinition(), this );
} }
if( !newItems.isEmpty() ) if( !newItems.isEmpty() )
{ {
newItems.setCount( (int) ( Math.min( newItems.getCount(), final IAEItemStack aeStack = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( newItems );
energy.extractAEPower( newItems.getCount(), Actionable.SIMULATE, PowerMultiplier.CONFIG ) ) + 0.01 ) ); final IAEItemStack failed = Platform.poweredInsert( energy, inv, aeStack, this.source );
this.itemToSend -= newItems.getCount();
if( this.lastItemChecked == null || !this.lastItemChecked.isSameType( newItems ) )
{
this.lastItemChecked = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( newItems );
}
else
{
this.lastItemChecked.setStackSize( newItems.getCount() );
}
final IAEItemStack failed = Platform.poweredInsert( energy, this.destination, this.lastItemChecked, this.source );
if( failed != null ) if( failed != null )
{ {
myAdaptor.addItems( failed.createItemStack() ); // try unpowered insert, better be a bit lenient then void items
final IAEItemStack spill = inv.injectItems( failed, Actionable.MODULATE, this.source );
if( spill != null )
{
// last resort try to put it back .. lets hope it's a chest type of thing
myAdaptor.addItems( spill.createItemStack() );
}
return true; return true;
} }
else else
{ {
this.itemsToSend -= newItems.getCount();
this.worked = true; this.worked = true;
} }
} }
@@ -266,7 +264,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
private int calculateMaximumAmountToImport( final InventoryAdaptor myAdaptor, final IAEItemStack whatToImport, final IMEMonitor<IAEItemStack> inv, final FuzzyMode fzMode ) private int calculateMaximumAmountToImport( final InventoryAdaptor myAdaptor, final IAEItemStack whatToImport, final IMEMonitor<IAEItemStack> inv, final FuzzyMode fzMode )
{ {
final int toSend = Math.min( this.itemToSend, 64 ); final int toSend = Math.min( this.itemsToSend, 64 );
final ItemStack itemStackToImport; final ItemStack itemStackToImport;
if( whatToImport == null ) if( whatToImport == null )
@@ -282,13 +280,13 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
final ItemStack simResult; final ItemStack simResult;
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
{ {
simResult = myAdaptor.simulateSimilarRemove( toSend, itemStackToImport, fzMode, this.configDestination( inv ) ); simResult = myAdaptor.simulateSimilarRemove( toSend, itemStackToImport, fzMode, this );
itemAmountNotStorable = this.destination.injectItems( AEItemStack.fromItemStack( simResult ), Actionable.SIMULATE, this.source ); itemAmountNotStorable = inv.injectItems( AEItemStack.fromItemStack( simResult ), Actionable.SIMULATE, this.source );
} }
else else
{ {
simResult = myAdaptor.simulateRemove( toSend, itemStackToImport, this.configDestination( inv ) ); simResult = myAdaptor.simulateRemove( toSend, itemStackToImport, this );
itemAmountNotStorable = this.destination.injectItems( AEItemStack.fromItemStack( simResult ), Actionable.SIMULATE, this.source ); itemAmountNotStorable = inv.injectItems( AEItemStack.fromItemStack( simResult ), Actionable.SIMULATE, this.source );
} }
if( itemAmountNotStorable != null ) if( itemAmountNotStorable != null )
@@ -299,12 +297,6 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
return toSend; return toSend;
} }
private IInventoryDestination configDestination( final IMEMonitor<IAEItemStack> itemInventory )
{
this.destination = itemInventory;
return this;
}
@Override @Override
protected boolean isSleeping() protected boolean isSleeping()
{ {
@@ -144,7 +144,10 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
@Override @Override
public void saveChanges() public void saveChanges()
{ {
this.parent.saveChanges(); if( this.parent != null )
{
this.parent.saveChanges();
}
} }
@Override @Override
@@ -19,10 +19,10 @@
package appeng.parts.misc; package appeng.parts.misc;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -36,11 +36,12 @@ import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.networking.ticking.TickRateModulation; import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.storage.IMEInventory; import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEMonitorHandlerReceiver; import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.me.GridAccessException;
import appeng.me.helpers.IGridProxyable;
import appeng.me.storage.ITickingMonitor; import appeng.me.storage.ITickingMonitor;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
@@ -51,20 +52,17 @@ import appeng.util.item.AEItemStack;
*/ */
class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAEItemStack>, ITickingMonitor class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAEItemStack>, ITickingMonitor
{ {
private final Map<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<>(); private final Map<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<>();
private IActionSource mySource; private IActionSource mySource;
private final IItemHandler itemHandler; private final IItemHandler itemHandler;
private final IGridProxyable proxyable;
private final InventoryCache cache;
private ItemStack[] cachedStacks = new ItemStack[0]; ItemHandlerAdapter( IItemHandler itemHandler, IGridProxyable proxy )
private IAEItemStack[] cachedAeStacks = new IAEItemStack[0];
ItemHandlerAdapter( IItemHandler itemHandler )
{ {
this.itemHandler = itemHandler; this.itemHandler = itemHandler;
this.proxyable = proxy;
this.cache = new InventoryCache( this.itemHandler );
} }
@Override @Override
@@ -91,7 +89,14 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
if( type == Actionable.MODULATE ) if( type == Actionable.MODULATE )
{ {
this.onTick(); try
{
this.proxyable.getProxy().getTick().alertDevice( this.proxyable.getProxy().getNode() );
}
catch( GridAccessException ex )
{
// meh
}
} }
return AEItemStack.fromItemStack( remaining ); return AEItemStack.fromItemStack( remaining );
@@ -167,7 +172,14 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
{ {
if( mode == Actionable.MODULATE ) if( mode == Actionable.MODULATE )
{ {
this.onTick(); try
{
this.proxyable.getProxy().getTick().alertDevice( this.proxyable.getProxy().getNode() );
}
catch( GridAccessException ex )
{
// meh
}
} }
return AEItemStack.fromItemStack( gathered ); return AEItemStack.fromItemStack( gathered );
@@ -176,72 +188,10 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
return null; return null;
} }
private ItemStack getItemStackInCachedSlot( int pos )
{
if( pos > this.cachedStacks.length )
{
return ItemStack.EMPTY;
}
if( this.cachedStacks[pos] == null )
{
return ItemStack.EMPTY;
}
return this.cachedStacks[pos];
}
@Override @Override
public TickRateModulation onTick() public TickRateModulation onTick()
{ {
LinkedList<IAEItemStack> changes = new LinkedList<>(); List<IAEItemStack> changes = this.cache.update();
int slots = this.itemHandler.getSlots();
// Make room for new slots
if( slots > this.cachedStacks.length )
{
this.cachedStacks = Arrays.copyOf( this.cachedStacks, slots );
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots );
}
for( int slot = 0; slot < slots; slot++ )
{
// Save the old stuff
ItemStack oldIS = this.getItemStackInCachedSlot( slot );
IAEItemStack oldAeIS = this.cachedAeStacks[slot];
ItemStack newIS = this.itemHandler.getStackInSlot( slot );
if( this.isDifferent( newIS, oldIS ) )
{
this.addItemChange( slot, oldAeIS, newIS, changes );
}
else if( !newIS.isEmpty() && !oldIS.isEmpty() )
{
this.addPossibleStackSizeChange( slot, oldAeIS, newIS, changes );
}
}
// Handle cases where the number of slots actually is lower now than before
if( slots < this.cachedStacks.length )
{
for( int slot = slots; slot < this.cachedStacks.length; slot++ )
{
IAEItemStack aeStack = this.cachedAeStacks[slot];
if( aeStack != null )
{
IAEItemStack a = aeStack.copy();
a.setStackSize( -a.getStackSize() );
changes.add( a );
}
}
// Reduce the cache size
this.cachedStacks = Arrays.copyOf( this.cachedStacks, slots );
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots );
}
if( !changes.isEmpty() ) if( !changes.isEmpty() )
{ {
this.postDifference( changes ); this.postDifference( changes );
@@ -253,73 +203,6 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
} }
} }
private void addItemChange( int slot, IAEItemStack oldAeIS, ItemStack newIS, List<IAEItemStack> changes )
{
// Completely different item
this.cachedStacks[slot] = newIS;
this.cachedAeStacks[slot] = AEItemStack.fromItemStack( newIS );
// If we had a stack previously in this slot, notify the newtork about its disappearance
if( oldAeIS != null )
{
oldAeIS.setStackSize( -oldAeIS.getStackSize() );
changes.add( oldAeIS );
}
// Notify the network about the new stack. Note that this is null if newIS was null
if( this.cachedAeStacks[slot] != null )
{
changes.add( this.cachedAeStacks[slot] );
}
}
private void addPossibleStackSizeChange( int slot, IAEItemStack oldAeIS, ItemStack newIS, List<IAEItemStack> changes )
{
// Still the same item, but amount might have changed
long diff = newIS.getCount() - oldAeIS.getStackSize();
if( diff != 0 )
{
IAEItemStack stack = oldAeIS.copy();
stack.setStackSize( newIS.getCount() );
this.cachedStacks[slot] = newIS;
this.cachedAeStacks[slot] = stack;
final IAEItemStack a = stack.copy();
a.setStackSize( diff );
changes.add( a );
}
}
private boolean isDifferent( final ItemStack a, final ItemStack b )
{
if( a == b && b.isEmpty() )
{
return false;
}
return a.isEmpty() || b.isEmpty() || !Platform.itemComparisons().isSameItem( a, b );
}
private void postDifference( Iterable<IAEItemStack> a )
{
final Iterator<Map.Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> i = this.listeners.entrySet().iterator();
while( i.hasNext() )
{
final Map.Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object> l = i.next();
final IMEMonitorHandlerReceiver<IAEItemStack> key = l.getKey();
if( key.isValid( l.getValue() ) )
{
key.postChange( this, a, this.mySource );
}
else
{
i.remove();
}
}
}
@Override @Override
public void setActionSource( final IActionSource mySource ) public void setActionSource( final IActionSource mySource )
{ {
@@ -339,7 +222,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
} }
@Override @Override
public IStorageChannel getChannel() public IItemStorageChannel getChannel()
{ {
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ); return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
} }
@@ -355,4 +238,152 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
{ {
this.listeners.remove( l ); this.listeners.remove( l );
} }
private void postDifference( Iterable<IAEItemStack> a )
{
final Iterator<Map.Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> i = this.listeners.entrySet().iterator();
while( i.hasNext() )
{
final Map.Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object> l = i.next();
final IMEMonitorHandlerReceiver<IAEItemStack> key = l.getKey();
if( key.isValid( l.getValue() ) )
{
key.postChange( this, a, this.mySource );
}
else
{
i.remove();
}
}
}
private static class InventoryCache
{
private ItemStack[] cachedStacks = new ItemStack[0];
private IAEItemStack[] cachedAeStacks = new IAEItemStack[0];
private final IItemHandler itemHandler;
public InventoryCache( IItemHandler itemHandler )
{
this.itemHandler = itemHandler;
}
public List<IAEItemStack> update()
{
List<IAEItemStack> changes = new ArrayList<>();
int slots = this.itemHandler.getSlots();
// Make room for new slots
if( slots > this.cachedStacks.length )
{
this.cachedStacks = Arrays.copyOf( this.cachedStacks, slots );
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots );
}
for( int slot = 0; slot < slots; slot++ )
{
// Save the old stuff
ItemStack oldIS = this.getItemStackInCachedSlot( slot );
IAEItemStack oldAeIS = this.cachedAeStacks[slot];
ItemStack newIS = this.itemHandler.getStackInSlot( slot );
if( isDifferent( newIS, oldIS ) )
{
this.addItemChange( slot, oldAeIS, newIS, changes );
}
else if( !newIS.isEmpty() && !oldIS.isEmpty() )
{
this.addPossibleStackSizeChange( slot, oldAeIS, newIS, changes );
}
}
// Handle cases where the number of slots actually is lower now than before
if( slots < this.cachedStacks.length )
{
for( int slot = slots; slot < this.cachedStacks.length; slot++ )
{
IAEItemStack aeStack = this.cachedAeStacks[slot];
if( aeStack != null )
{
IAEItemStack a = aeStack.copy();
a.setStackSize( -a.getStackSize() );
changes.add( a );
}
}
// Reduce the cache size
this.cachedStacks = Arrays.copyOf( this.cachedStacks, slots );
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots );
}
return changes;
}
private void addPossibleStackSizeChange( int slot, IAEItemStack oldAeIS, ItemStack newIS, List<IAEItemStack> changes )
{
// Still the same item, but amount might have changed
long diff = newIS.getCount() - oldAeIS.getStackSize();
if( diff != 0 )
{
IAEItemStack stack = oldAeIS.copy();
stack.setStackSize( newIS.getCount() );
this.cachedStacks[slot] = newIS;
this.cachedAeStacks[slot] = stack;
final IAEItemStack a = stack.copy();
a.setStackSize( diff );
changes.add( a );
}
}
private ItemStack getItemStackInCachedSlot( int pos )
{
if( pos > this.cachedStacks.length )
{
return ItemStack.EMPTY;
}
if( this.cachedStacks[pos] == null )
{
return ItemStack.EMPTY;
}
return this.cachedStacks[pos];
}
private void addItemChange( int slot, IAEItemStack oldAeIS, ItemStack newIS, List<IAEItemStack> changes )
{
// Completely different item
this.cachedStacks[slot] = newIS;
this.cachedAeStacks[slot] = AEItemStack.fromItemStack( newIS );
// If we had a stack previously in this slot, notify the newtork about its disappearance
if( oldAeIS != null )
{
oldAeIS.setStackSize( -oldAeIS.getStackSize() );
changes.add( oldAeIS );
}
// Notify the network about the new stack. Note that this is null if newIS was null
if( this.cachedAeStacks[slot] != null )
{
changes.add( this.cachedAeStacks[slot] );
}
}
private static boolean isDifferent( final ItemStack a, final ItemStack b )
{
if( a == b && b.isEmpty() )
{
return false;
}
return a.isEmpty() || b.isEmpty() || !Platform.itemComparisons().isSameItem( a, b );
}
}
} }
@@ -19,7 +19,6 @@
package appeng.parts.misc; package appeng.parts.misc;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@@ -67,7 +66,6 @@ import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.IStorageMonitorableAccessor; import appeng.api.storage.IStorageMonitorableAccessor;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.api.util.AECableType; import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation; import appeng.api.util.AEPartLocation;
@@ -113,7 +111,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
private int priority = 0; private int priority = 0;
private boolean cached = false; private boolean cached = false;
private ITickingMonitor monitor = null; private ITickingMonitor monitor = null;
private MEInventoryHandler<? extends IAEStack> handler = null; private MEInventoryHandler<IAEItemStack> handler = null;
private int handlerHash = 0; private int handlerHash = 0;
private boolean wasActive = false; private boolean wasActive = false;
private byte resetCacheLogic = 0; private byte resetCacheLogic = 0;
@@ -356,22 +354,18 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
final IMEInventory<IAEItemStack> out = this.getInternalHandler(); final IMEInventory<IAEItemStack> out = this.getInternalHandler();
if( this.monitor != null ) if( in != out )
{ {
this.monitor.onTick(); IItemList<IAEItemStack> after = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
if( out != null )
{
after = out.getAvailableItems( after );
}
Platform.postListChanges( before, after, this, this.mySrc );
} }
IItemList<IAEItemStack> after = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
if( out != null )
{
after = out.getAvailableItems( after );
}
Platform.postListChanges( before, after, this, this.mySrc );
} }
@SuppressWarnings( "unchecked" ) private IMEInventory<IAEItemStack> getInventoryWrapper( TileEntity target )
private IMEInventory<? extends IAEItemStack> getInventoryWrapper( TileEntity target )
{ {
EnumFacing targetSide = this.getSide().getFacing().getOpposite(); EnumFacing targetSide = this.getSide().getFacing().getOpposite();
@@ -398,7 +392,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
IItemHandler handlerExt = target.getCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, targetSide ); IItemHandler handlerExt = target.getCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, targetSide );
if( handlerExt != null ) if( handlerExt != null )
{ {
return new ItemHandlerAdapter( handlerExt ); return new ItemHandlerAdapter( handlerExt, this );
} }
return null; return null;
@@ -429,7 +423,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
return 0; return 0;
} }
public MEInventoryHandler getInternalHandler() public MEInventoryHandler<IAEItemStack> getInternalHandler()
{ {
if( this.cached ) if( this.cached )
{ {
@@ -453,7 +447,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
this.monitor = null; this.monitor = null;
if( target != null ) if( target != null )
{ {
IMEInventory<? extends IAEStack> inv = this.getInventoryWrapper( target ); IMEInventory<IAEItemStack> inv = this.getInventoryWrapper( target );
if( inv instanceof MEMonitorIInventory ) if( inv instanceof MEMonitorIInventory )
{ {
@@ -471,7 +465,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
{ {
this.checkInterfaceVsStorageBus( target, this.getSide().getOpposite() ); this.checkInterfaceVsStorageBus( target, this.getSide().getOpposite() );
this.handler = new MEInventoryHandler( inv, AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ); this.handler = new MEInventoryHandler<IAEItemStack>( inv, AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
this.handler.setBaseAccess( (AccessRestriction) this.getConfigManager().getSetting( Settings.ACCESS ) ); this.handler.setBaseAccess( (AccessRestriction) this.getConfigManager().getSetting( Settings.ACCESS ) );
this.handler.setWhitelist( this.getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST ); this.handler.setWhitelist( this.getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST );
@@ -492,16 +486,17 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
{ {
this.handler this.handler
.setPartitionList( new FuzzyPriorityList( priorityList, (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) ); .setPartitionList( new FuzzyPriorityList<IAEItemStack>( priorityList, (FuzzyMode) this.getConfigManager()
.getSetting( Settings.FUZZY_MODE ) ) );
} }
else else
{ {
this.handler.setPartitionList( new PrecisePriorityList( priorityList ) ); this.handler.setPartitionList( new PrecisePriorityList<IAEItemStack>( priorityList ) );
} }
if( inv instanceof IBaseMonitor ) if( inv instanceof IBaseMonitor )
{ {
( (IBaseMonitor) inv ).addListener( this, this.handler ); ( (IBaseMonitor<IAEItemStack>) inv ).addListener( this, this.handler );
} }
} }
} }
@@ -571,13 +566,13 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
{ {
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
{ {
final IMEInventoryHandler out = this.getProxy().isActive() ? this.getInternalHandler() : null; final IMEInventoryHandler<IAEItemStack> out = this.getProxy().isActive() ? this.getInternalHandler() : null;
if( out != null ) if( out != null )
{ {
return Collections.singletonList( out ); return Collections.singletonList( out );
} }
} }
return Arrays.asList( new IMEInventoryHandler[] {} ); return Collections.emptyList();
} }
@Override @Override
@@ -33,7 +33,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.exceptions.FailedConnection; import appeng.api.exceptions.FailedConnectionException;
import appeng.api.networking.IGridConnection; import appeng.api.networking.IGridConnection;
import appeng.api.networking.IGridNode; import appeng.api.networking.IGridNode;
import appeng.api.parts.IPartCollisionHelper; import appeng.api.parts.IPartCollisionHelper;
@@ -41,6 +41,7 @@ import appeng.api.parts.IPartHost;
import appeng.api.parts.IPartModel; import appeng.api.parts.IPartModel;
import appeng.api.util.AECableType; import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation; import appeng.api.util.AEPartLocation;
import appeng.core.AELog;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.helpers.Reflected; import appeng.helpers.Reflected;
import appeng.items.parts.PartModels; import appeng.items.parts.PartModels;
@@ -205,9 +206,10 @@ public class PartToggleBus extends PartBasicState
{ {
this.connection = AEApi.instance().grid().createGridConnection( this.getProxy().getNode(), this.getOuterProxy().getNode() ); this.connection = AEApi.instance().grid().createGridConnection( this.getProxy().getNode(), this.getOuterProxy().getNode() );
} }
catch( final FailedConnection e ) catch( final FailedConnectionException e )
{ {
// :( // :(
AELog.debug( e );
} }
} }
else else
@@ -31,7 +31,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.exceptions.FailedConnection; import appeng.api.exceptions.FailedConnectionException;
import appeng.api.networking.GridFlags; import appeng.api.networking.GridFlags;
import appeng.api.networking.IGridNode; import appeng.api.networking.IGridNode;
import appeng.api.networking.ticking.IGridTickable; import appeng.api.networking.ticking.IGridTickable;
@@ -243,11 +243,13 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
new TunnelConnection( me, AEApi.instance().grid().createGridConnection( this.outerProxy.getNode(), new TunnelConnection( me, AEApi.instance().grid().createGridConnection( this.outerProxy.getNode(),
me.outerProxy.getNode() ) ) ); me.outerProxy.getNode() ) ) );
} }
catch( final FailedConnection e ) catch( final FailedConnectionException e )
{ {
final TileEntity start = this.getTile(); final TileEntity start = this.getTile();
final TileEntity end = me.getTile(); final TileEntity end = me.getTile();
AELog.debug( e );
AELog.warn( "Failed to establish a ME P2P Tunnel between the tunnels at [x=%d, y=%d, z=%d] and [x=%d, y=%d, z=%d]", AELog.warn( "Failed to establish a ME P2P Tunnel between the tunnels at [x=%d, y=%d, z=%d] and [x=%d, y=%d, z=%d]",
start.getPos().getX(), start.getPos().getY(), start.getPos().getZ(), end.getPos().getX(), end.getPos().getY(), start.getPos().getX(), start.getPos().getY(), start.getPos().getZ(), end.getPos().getX(), end.getPos().getY(),
end.getPos().getZ() ); end.getPos().getZ() );
@@ -28,9 +28,9 @@ import com.google.common.base.Preconditions;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import appeng.api.exceptions.MissingIngredientError; import appeng.api.exceptions.MissingIngredientException;
import appeng.api.exceptions.RecipeError; import appeng.api.exceptions.RecipeException;
import appeng.api.exceptions.RegistrationError; import appeng.api.exceptions.RegistrationException;
import appeng.api.recipes.IIngredient; import appeng.api.recipes.IIngredient;
@@ -43,7 +43,7 @@ public class GroupIngredient implements IIngredient
private ItemStack[] baked; private ItemStack[] baked;
private boolean isInside = false; private boolean isInside = false;
public GroupIngredient( final String myName, final List<IIngredient> ingredients, final int qty ) throws RecipeError public GroupIngredient( final String myName, final List<IIngredient> ingredients, final int qty ) throws RecipeException
{ {
Preconditions.checkNotNull( myName ); Preconditions.checkNotNull( myName );
Preconditions.checkNotNull( ingredients ); Preconditions.checkNotNull( ingredients );
@@ -57,27 +57,27 @@ public class GroupIngredient implements IIngredient
{ {
if( ingredient.isAir() ) if( ingredient.isAir() )
{ {
throw new RecipeError( "Cannot include air in a group." ); throw new RecipeException( "Cannot include air in a group." );
} }
} }
this.ingredients = ingredients; this.ingredients = ingredients;
} }
IIngredient copy( final int qty ) throws RecipeError IIngredient copy( final int qty ) throws RecipeException
{ {
Preconditions.checkState( qty > 0 ); Preconditions.checkState( qty > 0 );
return new GroupIngredient( this.name, this.ingredients, qty ); return new GroupIngredient( this.name, this.ingredients, qty );
} }
@Override @Override
public ItemStack getItemStack() throws RegistrationError, MissingIngredientError public ItemStack getItemStack() throws RegistrationException, MissingIngredientException
{ {
throw new RegistrationError( "Cannot pass group of items to a recipe which desires a single recipe item." ); throw new RegistrationException( "Cannot pass group of items to a recipe which desires a single recipe item." );
} }
@Override @Override
public ItemStack[] getItemStackSet() throws RegistrationError, MissingIngredientError public ItemStack[] getItemStackSet() throws RegistrationException, MissingIngredientException
{ {
if( this.baked != null ) if( this.baked != null )
{ {
@@ -99,7 +99,7 @@ public class GroupIngredient implements IIngredient
{ {
out.addAll( Arrays.asList( i.getItemStackSet() ) ); out.addAll( Arrays.asList( i.getItemStackSet() ) );
} }
catch( final MissingIngredientError mir ) catch( final MissingIngredientException mir )
{ {
// oh well this is a group! // oh well this is a group!
} }
@@ -112,7 +112,7 @@ public class GroupIngredient implements IIngredient
if( out.isEmpty() ) if( out.isEmpty() )
{ {
throw new MissingIngredientError( this.toString() + " - group could not be resolved to any items." ); throw new MissingIngredientException( this.toString() + " - group could not be resolved to any items." );
} }
for( final ItemStack is : out ) for( final ItemStack is : out )
@@ -154,7 +154,7 @@ public class GroupIngredient implements IIngredient
} }
@Override @Override
public void bake() throws RegistrationError, MissingIngredientError public void bake() throws RegistrationException, MissingIngredientException
{ {
this.baked = null; this.baked = null;
this.baked = this.getItemStackSet(); this.baked = this.getItemStackSet();

Some files were not shown because too many files have changed in this diff Show More