Fix a couple of JEI issues

- Don't treat turtles/pocket computers with no upgrades as an "any"
   turtle. Otherwise getting the recipe of a crafty turtle shows the
   recipe of a normal turtle too.
 - Fix "get usage" of upgrade items not returning their recipes.
 - Fix NPEs inside JEI (closes #719)
This commit is contained in:
Jonathan Coates 2021-04-03 14:08:58 +01:00
parent e8f5531a8c
commit b17ff6daf0
2 changed files with 7 additions and 14 deletions

View File

@ -114,10 +114,10 @@ public void onRuntimeAvailable( IJeiRuntime runtime )
*/
private static final ISubtypeInterpreter turtleSubtype = stack -> {
Item item = stack.getItem();
if( !(item instanceof ITurtleItem) ) return "";
if( !(item instanceof ITurtleItem) ) return ISubtypeInterpreter.NONE;
ITurtleItem turtle = (ITurtleItem) item;
StringBuilder name = new StringBuilder();
StringBuilder name = new StringBuilder("turtle:");
// Add left and right upgrades to the identifier
ITurtleUpgrade left = turtle.getUpgrade( stack, TurtleSide.LEFT );
@ -134,9 +134,9 @@ public void onRuntimeAvailable( IJeiRuntime runtime )
*/
private static final ISubtypeInterpreter pocketSubtype = stack -> {
Item item = stack.getItem();
if( !(item instanceof ItemPocketComputer) ) return "";
if( !(item instanceof ItemPocketComputer) ) return ISubtypeInterpreter.NONE;
StringBuilder name = new StringBuilder();
StringBuilder name = new StringBuilder("pocket:");
// Add the upgrade to the identifier
IPocketUpgrade upgrade = ItemPocketComputer.getUpgrade( stack );
@ -150,11 +150,11 @@ public void onRuntimeAvailable( IJeiRuntime runtime )
*/
private static final ISubtypeInterpreter diskSubtype = stack -> {
Item item = stack.getItem();
if( !(item instanceof ItemDisk) ) return "";
if( !(item instanceof ItemDisk) ) return ISubtypeInterpreter.NONE;
ItemDisk disk = (ItemDisk) item;
int colour = disk.getColour( stack );
return colour == -1 ? "" : String.format( "%06x", colour );
return colour == -1 ? ISubtypeInterpreter.NONE : String.format( "%06x", colour );
};
}

View File

@ -200,7 +200,7 @@ else if( stack.getItem() instanceof ItemPocketComputer )
for( UpgradeInfo upgrade : upgrades )
{
ItemStack craftingStack = upgrade.stack;
if( !craftingStack.isEmpty() && craftingStack.getItem() == stack.getItem() && upgrade.upgrade.isItemSuitable( stack ) )
if( craftingStack.isEmpty() || craftingStack.getItem() != stack.getItem() || !upgrade.upgrade.isItemSuitable( stack ) )
{
continue;
}
@ -319,13 +319,6 @@ private static class Shaped extends ShapedRecipe
super( ID, null, width, height, input, output );
}
@Nonnull
@Override
public ResourceLocation getId()
{
return null;
}
@Nonnull
@Override
public IRecipeSerializer<?> getSerializer()