Skip to content

Commit

Permalink
Gracefully reject ItemStacks with null items. Avoids crashing if a br…
Browse files Browse the repository at this point in the history
…oken mod is installed.
  • Loading branch information
gigaherz committed Jul 30, 2016
1 parent 7ae7441 commit 2ad05fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ repositories {

apply plugin: 'net.minecraftforge.gradle.forge'

version = "1.6.3"
version = "1.6.4"
group= "gigaherz.survivalist" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "Survivalist-1.10.2"

Expand Down
26 changes: 16 additions & 10 deletions src/main/java/gigaherz/survivalist/Survivalist.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,6 @@ private void registerNetwork()
logger.debug("Final message number: " + messageNumber);
}

public static boolean hasOreName(ItemStack stack, String oreName)
{
int id = OreDictionary.getOreID(oreName);
for (int i : OreDictionary.getOreIDs(stack))
{
if (i == id) return true;
}
return false;
}

@Mod.EventHandler
public void init(FMLInitializationEvent event)
{
Expand Down Expand Up @@ -560,6 +550,22 @@ else if (oreInput != null)
}
}

public static boolean hasOreName(ItemStack stack, String oreName)
{
if (stack.getItem() == null)
{
logger.warn("Detected ItemStack with null item inside!");
return false;
}

int id = OreDictionary.getOreID(oreName);
for (int i : OreDictionary.getOreIDs(stack))
{
if (i == id) return true;
}
return false;
}

private void addIngotToNuggets(String oreIngot, String oreNugget)
{
List<ItemStack> matches1 = OreDictionary.getOres(oreIngot);
Expand Down

0 comments on commit 2ad05fd

Please sign in to comment.