fix NPE with ae2fc and blocking mode

This commit is contained in:
PrototypeTrousers
2022-03-25 23:27:02 -03:00
parent f30f334a23
commit 3b94e9420d
4 changed files with 63 additions and 52 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ aebuild=7
aegroup=appeng aegroup=appeng
aebasename=appliedenergistics2 aebasename=appliedenergistics2
extended=extended_life extended=extended_life
extendedversion=v51e extendedversion=v51f
######################################################### #########################################################
# Versions # # Versions #
######################################################### #########################################################
+3
View File
@@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import appeng.helpers.NonBlockingItems;
import com.google.common.base.Stopwatch; import com.google.common.base.Stopwatch;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@@ -238,6 +239,8 @@ public final class AppEng
AppEng.proxy.postInit(); AppEng.proxy.postInit();
AEConfig.instance().save(); AEConfig.instance().save();
NonBlockingItems.INSTANCE.init();
NetworkRegistry.INSTANCE.registerGuiHandler( this, GuiBridge.GUI_Handler ); NetworkRegistry.INSTANCE.registerGuiHandler( this, GuiBridge.GUI_Handler );
NetworkHandler.init( "AE2" ); NetworkHandler.init( "AE2" );
@@ -1154,38 +1154,37 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
} }
} }
if( this.isBlocking() ) InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() );
if( ad != null )
{ {
IPhantomTile phantomTE; if( this.isBlocking() )
if( Loader.isModLoaded( "actuallyadditions" ) && te instanceof IPhantomTile )
{ {
phantomTE = ( (IPhantomTile) te ); IPhantomTile phantomTE;
if( phantomTE.hasBoundPosition() ) if( Loader.isModLoaded( "actuallyadditions" ) && te instanceof IPhantomTile )
{ {
TileEntity phantom = w.getTileEntity( phantomTE.getBoundPosition() ); phantomTE = ( (IPhantomTile) te );
if( NonBlockingItems.INSTANCE.getMap().containsKey( phantom.getBlockType().getRegistryName().getResourceDomain() ) ) if( phantomTE.hasBoundPosition() )
{ {
if( isCustomInvBlocking( phantom, s ) ) TileEntity phantom = w.getTileEntity( phantomTE.getBoundPosition() );
if( NonBlockingItems.INSTANCE.getMap().containsKey( w.getBlockState( phantomTE.getBoundPosition() ).getBlock().getRegistryName().getResourceDomain() ) )
{ {
visitedFaces.remove( s ); if( isCustomInvBlocking( phantom, s ) )
continue; {
visitedFaces.remove( s );
continue;
}
} }
} }
} }
} else if( NonBlockingItems.INSTANCE.getMap().containsKey( w.getBlockState( tile.getPos().offset( s ) ).getBlock().getRegistryName().getResourceDomain() ) )
else if( NonBlockingItems.INSTANCE.getMap().containsKey( te.getBlockType().getRegistryName().getResourceDomain() ) )
{
if( isCustomInvBlocking( te, s ) )
{ {
visitedFaces.remove( s ); if( isCustomInvBlocking( te, s ) )
continue; {
visitedFaces.remove( s );
continue;
}
} }
} else if( invIsBlocked( ad ) )
final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() );
if( ad != null )
{
if( invIsBlocked( ad ) )
{ {
visitedFaces.remove( s ); visitedFaces.remove( s );
continue; continue;
@@ -1235,34 +1234,34 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
final TileEntity te = w.getTileEntity( tile.getPos().offset( s ) ); final TileEntity te = w.getTileEntity( tile.getPos().offset( s ) );
IPhantomTile phantomTE; IPhantomTile phantomTE;
if( Loader.isModLoaded( "actuallyadditions" ) && Loader.isModLoaded( "gregtech" ) && te instanceof IPhantomTile ) final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() );
if( ad != null )
{ {
phantomTE = ( (IPhantomTile) te ); if( Loader.isModLoaded( "actuallyadditions" ) && Loader.isModLoaded( "gregtech" ) && te instanceof IPhantomTile )
if( phantomTE.hasBoundPosition() )
{ {
TileEntity phantom = w.getTileEntity( phantomTE.getBoundPosition() ); phantomTE = ( (IPhantomTile) te );
if( NonBlockingItems.INSTANCE.getMap().containsKey( phantom.getBlockType().getRegistryName().getResourceDomain() ) ) if( phantomTE.hasBoundPosition() )
{ {
if( !isCustomInvBlocking( phantom, s ) ) TileEntity phantom = w.getTileEntity( phantomTE.getBoundPosition() );
if( NonBlockingItems.INSTANCE.getMap().containsKey( w.getBlockState( phantomTE.getBoundPosition() ).getBlock().getRegistryName().getResourceDomain() ) )
{ {
allAreBusy = false; if( !isCustomInvBlocking( phantom, s ) )
break; {
allAreBusy = false;
break;
}
} }
} }
} }
} else if( NonBlockingItems.INSTANCE.getMap().containsKey( w.getBlockState( tile.getPos().offset( s ) ).getBlock().getRegistryName().getResourceDomain() ) )
else if( NonBlockingItems.INSTANCE.getMap().containsKey( te.getBlockType().getRegistryName().getResourceDomain() ) )
{
if( !isCustomInvBlocking( te, s ) )
{ {
allAreBusy = false; if( !isCustomInvBlocking( te, s ) )
break; {
allAreBusy = false;
break;
}
} }
} else
else
{
final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() );
if( ad != null )
{ {
if( !invIsBlocked( ad ) ) if( !invIsBlocked( ad ) )
{ {
@@ -61,7 +61,8 @@ public class NonBlockingItems
found = true; found = true;
ItemStack itemStack = metaItem2.getStackForm(); ItemStack itemStack = metaItem2.getStackForm();
NON_BLOCKING_MAP.get( modid ).putIfAbsent( itemStack.getItem(), new IntOpenHashSet() ); NON_BLOCKING_MAP.get( modid ).putIfAbsent( itemStack.getItem(), new IntOpenHashSet() );
NON_BLOCKING_MAP.get( modid ).computeIfPresent( itemStack.getItem(), ( item, intSet ) -> { NON_BLOCKING_MAP.get( modid ).computeIfPresent( itemStack.getItem(), ( item, intSet ) ->
{
intSet.add( itemStack.getItemDamage() ); intSet.add( itemStack.getItemDamage() );
return intSet; return intSet;
} ); } );
@@ -72,7 +73,8 @@ public class NonBlockingItems
if( !itemStack.isEmpty() ) if( !itemStack.isEmpty() )
{ {
NON_BLOCKING_MAP.get( modid ).putIfAbsent( itemStack.getItem(), new IntOpenHashSet() ); NON_BLOCKING_MAP.get( modid ).putIfAbsent( itemStack.getItem(), new IntOpenHashSet() );
NON_BLOCKING_MAP.get( modid ).computeIfPresent( itemStack.getItem(), ( item, intSet ) -> { NON_BLOCKING_MAP.get( modid ).computeIfPresent( itemStack.getItem(), ( item, intSet ) ->
{
intSet.add( itemStack.getItemDamage() ); intSet.add( itemStack.getItemDamage() );
return intSet; return intSet;
} ); } );
@@ -86,13 +88,15 @@ public class NonBlockingItems
} }
else if( ModItemMeta[0].equals( "ore" ) ) else if( ModItemMeta[0].equals( "ore" ) )
{ {
OreDictionary.getOres( ModItemMeta[1] ).forEach( itemStack -> { OreDictionary.getOres( ModItemMeta[1] ).forEach( itemStack ->
NON_BLOCKING_MAP.get( modid ).putIfAbsent( itemStack.getItem(), new IntOpenHashSet() ); {
NON_BLOCKING_MAP.get( modid ).computeIfPresent( itemStack.getItem(), ( item, intSet ) -> { NON_BLOCKING_MAP.get( modid ).putIfAbsent( itemStack.getItem(), new IntOpenHashSet() );
intSet.add( itemStack.getItemDamage() ); NON_BLOCKING_MAP.get( modid ).computeIfPresent( itemStack.getItem(), ( item, intSet ) ->
return intSet; {
} ); intSet.add( itemStack.getItemDamage() );
} ); return intSet;
} );
} );
} }
else else
{ {
@@ -100,7 +104,8 @@ public class NonBlockingItems
if( !itemStack.isEmpty() ) if( !itemStack.isEmpty() )
{ {
NON_BLOCKING_MAP.get( modid ).putIfAbsent( itemStack.getItem(), new IntOpenHashSet() ); NON_BLOCKING_MAP.get( modid ).putIfAbsent( itemStack.getItem(), new IntOpenHashSet() );
NON_BLOCKING_MAP.get( modid ).computeIfPresent( itemStack.getItem(), ( item, intSet ) -> { NON_BLOCKING_MAP.get( modid ).computeIfPresent( itemStack.getItem(), ( item, intSet ) ->
{
intSet.add( itemStack.getItemDamage() ); intSet.add( itemStack.getItemDamage() );
return intSet; return intSet;
} ); } );
@@ -120,4 +125,8 @@ public class NonBlockingItems
{ {
return NON_BLOCKING_MAP; return NON_BLOCKING_MAP;
} }
public void init()
{
}
} }