Rework ContainerInscriber validation (#3238)
* Correctly handle metadata wildcard for inscriber inputs
This commit is contained in:
parent
5fa2c0ab27
commit
f0d807f0a2
|
@ -120,28 +120,23 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
|
||||||
|
|
||||||
if( s == this.middle )
|
if( s == this.middle )
|
||||||
{
|
{
|
||||||
for( final ItemStack optional : AEApi.instance().registries().inscriber().getOptionals() )
|
IItemDefinition press = AEApi.instance().definitions().materials().namePress();
|
||||||
|
if( press.isSameAs( top ) || press.isSameAs( bot ) )
|
||||||
{
|
{
|
||||||
if( Platform.itemComparisons().isSameItem( optional, is ) )
|
return !press.isSameAs( is );
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean matches = false;
|
boolean matches = false;
|
||||||
boolean found = false;
|
|
||||||
|
|
||||||
for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() )
|
for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() )
|
||||||
{
|
{
|
||||||
final boolean matchA = ( top.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( top,
|
final boolean matchA = !top
|
||||||
recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and...
|
.isEmpty() && ( Platform.itemComparisons().isSameItem( top, recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) || Platform
|
||||||
( ( bot.isEmpty() && !recipe.getBottomOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( bot,
|
.itemComparisons()
|
||||||
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) ) );
|
.isSameItem( top, recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) );
|
||||||
|
final boolean matchB = !bot
|
||||||
final boolean matchB = ( bot.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( bot,
|
.isEmpty() && ( Platform.itemComparisons().isSameItem( bot, recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) || Platform
|
||||||
recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and...
|
.itemComparisons()
|
||||||
( ( top.isEmpty() && !recipe.getBottomOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( top,
|
.isSameItem( bot, recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) );
|
||||||
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) ) );
|
|
||||||
|
|
||||||
if( matchA || matchB )
|
if( matchA || matchB )
|
||||||
{
|
{
|
||||||
|
@ -150,21 +145,19 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
|
||||||
{
|
{
|
||||||
if( Platform.itemComparisons().isSameItem( is, option ) )
|
if( Platform.itemComparisons().isSameItem( is, option ) )
|
||||||
{
|
{
|
||||||
found = true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if( matches )
|
||||||
if( matches && !found )
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if( ( s == this.top && !bot.isEmpty() ) || ( s == this.bottom && !top.isEmpty() ) )
|
||||||
if( ( s == this.top && !bot.isEmpty() ) || ( s == this.bottom && !top.isEmpty() ) )
|
|
||||||
{
|
{
|
||||||
ItemStack otherSlot = ItemStack.EMPTY;
|
ItemStack otherSlot;
|
||||||
if( s == this.top )
|
if( s == this.top )
|
||||||
{
|
{
|
||||||
otherSlot = this.bottom.getStack();
|
otherSlot = this.bottom.getStack();
|
||||||
|
@ -182,28 +175,24 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
|
||||||
}
|
}
|
||||||
|
|
||||||
// everything else
|
// everything else
|
||||||
boolean isValid = false;
|
|
||||||
for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() )
|
for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() )
|
||||||
{
|
{
|
||||||
if( Platform.itemComparisons().isSameItem( recipe.getTopOptional().orElse( ItemStack.EMPTY ), otherSlot ) )
|
boolean isValid = false;
|
||||||
|
if( Platform.itemComparisons().isSameItem( otherSlot, recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) )
|
||||||
{
|
{
|
||||||
isValid = Platform.itemComparisons().isSameItem( is, recipe.getBottomOptional().orElse( ItemStack.EMPTY ) );
|
isValid = Platform.itemComparisons().isSameItem( is, recipe.getBottomOptional().orElse( ItemStack.EMPTY ) );
|
||||||
}
|
}
|
||||||
else if( Platform.itemComparisons().isSameItem( recipe.getBottomOptional().orElse( ItemStack.EMPTY ), otherSlot ) )
|
else if( Platform.itemComparisons().isSameItem( otherSlot, recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) )
|
||||||
{
|
{
|
||||||
isValid = Platform.itemComparisons().isSameItem( is, recipe.getTopOptional().orElse( ItemStack.EMPTY ) );
|
isValid = Platform.itemComparisons().isSameItem( is, recipe.getTopOptional().orElse( ItemStack.EMPTY ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( isValid )
|
if( isValid )
|
||||||
{
|
{
|
||||||
break;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
if( !isValid )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -172,7 +172,7 @@ public class SlotRestrictedInput extends AppEngSlot
|
||||||
|
|
||||||
for( final ItemStack optional : AEApi.instance().registries().inscriber().getOptionals() )
|
for( final ItemStack optional : AEApi.instance().registries().inscriber().getOptionals() )
|
||||||
{
|
{
|
||||||
if( Platform.itemComparisons().isSameItem( optional, i ) )
|
if( Platform.itemComparisons().isSameItem( i, optional ) )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -281,9 +281,13 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||||
@Nullable
|
@Nullable
|
||||||
public IInscriberRecipe getTask()
|
public IInscriberRecipe getTask()
|
||||||
{
|
{
|
||||||
final ItemStack plateA = this.topItemHandler.getStackInSlot( 0 );
|
return getTask( this.sideItemHandler.getStackInSlot( 0 ), this.topItemHandler.getStackInSlot( 0 ), this.bottomItemHandler.getStackInSlot( 0 ) );
|
||||||
final ItemStack plateB = this.bottomItemHandler.getStackInSlot( 0 );
|
}
|
||||||
ItemStack renamedItem = this.sideItemHandler.getStackInSlot( 0 );
|
|
||||||
|
@Nullable
|
||||||
|
private IInscriberRecipe getTask( final ItemStack input, final ItemStack plateA, final ItemStack plateB )
|
||||||
|
{
|
||||||
|
ItemStack renamedItem = input;
|
||||||
|
|
||||||
if( !plateA.isEmpty() && plateA.getCount() > 1 )
|
if( !plateA.isEmpty() && plateA.getCount() > 1 )
|
||||||
{
|
{
|
||||||
|
@ -379,7 +383,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||||
{
|
{
|
||||||
for( final ItemStack option : recipe.getInputs() )
|
for( final ItemStack option : recipe.getInputs() )
|
||||||
{
|
{
|
||||||
if( Platform.itemComparisons().isSameItem( option, this.sideItemHandler.getStackInSlot( 0 ) ) )
|
if( Platform.itemComparisons().isSameItem( input, option ) )
|
||||||
{
|
{
|
||||||
return recipe;
|
return recipe;
|
||||||
}
|
}
|
||||||
|
@ -606,7 +610,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||||
}
|
}
|
||||||
for( final ItemStack optionals : AEApi.instance().registries().inscriber().getOptionals() )
|
for( final ItemStack optionals : AEApi.instance().registries().inscriber().getOptionals() )
|
||||||
{
|
{
|
||||||
if( Platform.itemComparisons().isSameItem( optionals, stack ) )
|
if( Platform.itemComparisons().isSameItem( stack, optionals ) )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue