Better check

This commit is contained in:
Shadows_of_Fire 2017-12-06 16:25:10 -05:00
parent 213716fc46
commit 348b1eb92c
2 changed files with 9 additions and 1 deletions

View file

@ -74,7 +74,7 @@ public abstract class ExUPlantFarmerBehavior implements IFarmerBehavior{
if(block.getMetaFromState(state) >= this.getMaxStage()){
NonNullList<ItemStack> drops = NonNullList.create();
block.getDrops(drops, world, pos, state, 0);
if(drops.isEmpty()) return FarmerResult.FAIL;
if(StackUtil.isEmpty(drops)) return FarmerResult.FAIL;
for(ItemStack stack : drops){
if(StackUtil.isValid(stack)){
ResourceLocation itemReg = stack.getItem().getRegistryName();

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.mod.util;
import java.util.Collection;
import de.ellpeck.actuallyadditions.api.misc.IDisableableItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -93,6 +95,12 @@ public final class StackUtil{
public static NonNullList<ItemStack> createSlots(int size){
return NonNullList.withSize(size, getEmpty());
}
public static boolean isEmpty(Collection<ItemStack> stacks) {
if(stacks.isEmpty()) return true;
else for(ItemStack s : stacks) if (!s.isEmpty()) return false;
return true;
}
}