From 8667bbd3c9ad7443cb7df6ceb72490f061abff4f Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Mon, 7 Jan 2019 21:02:22 +0000 Subject: [PATCH] Fix #987 --- .../apocalypse/common/FlansModLootGenerator.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/flansmod/apocalypse/common/FlansModLootGenerator.java b/src/main/java/com/flansmod/apocalypse/common/FlansModLootGenerator.java index 191d001d3..930cc743d 100644 --- a/src/main/java/com/flansmod/apocalypse/common/FlansModLootGenerator.java +++ b/src/main/java/com/flansmod/apocalypse/common/FlansModLootGenerator.java @@ -6,6 +6,7 @@ import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; @@ -279,13 +280,21 @@ public Block getRandomWeaponBox(Random rand) if(rand.nextInt(4) == 0) { //Get armour box - return ArmourBoxType.boxes.get(new ArrayList<>(ArmourBoxType.boxes.keySet()).get(rand.nextInt(ArmourBoxType.boxes.size()))).block; + if(ArmourBoxType.boxes.size() > 0) + { + return ArmourBoxType.boxes.get(new ArrayList<>(ArmourBoxType.boxes.keySet()).get(rand.nextInt(ArmourBoxType.boxes.size()))).block; + } } else { //Get weapon box - return GunBoxType.gunBoxMap.get(new ArrayList<>(GunBoxType.gunBoxMap.keySet()).get(rand.nextInt(GunBoxType.gunBoxMap.size()))).block; + if(GunBoxType.gunBoxMap.size() > 0) + { + return GunBoxType.gunBoxMap.get(new ArrayList<>(GunBoxType.gunBoxMap.keySet()).get(rand.nextInt(GunBoxType.gunBoxMap.size()))).block; + } } + + return Blocks.AIR; } public DriveableType getRandomDriveable(Random rand)