@Override public boolean isValid() { if (damageMode != DamageMode.DISABLED) { return true; } for (ItemStack item : items) { if (item != null && Prep.isValid(item)) { return true; } } return false; }
@Override public @Nonnull ItemStack getUpgradeItem() { if (Prep.isValid(upgradeItem)) { return upgradeItem; } upgradeItem = getGoggles(); return upgradeItem; }
protected boolean hasInputStacks() { int fromSlot = slotDefinition.minInputSlot; for (int i = 0; i < slotDefinition.getNumInputSlots(); i++) { final ItemStack itemStack = inventory[fromSlot]; if (itemStack != null && Prep.isValid(itemStack)) { return true; } fromSlot++; } return false; }
@Override @Nullable public EntityItem entityDropItem(@Nonnull ItemStack stack, float offsetY) { if (Prep.isValid(dropStack)) { return super.entityDropItem(dropStack, offsetY); } else { return super.entityDropItem(stack, offsetY); } }
public static boolean hasItems(@Nonnull IItemHandler handler) { for (int i = 0; i < handler.getSlots(); i++) { ItemStack stack = handler.getStackInSlot(i); if (Prep.isValid(stack)) { return true; } } return false; }
public static @Nonnull ItemStack getInputForSlot(int slot, NNList<MachineRecipeInput> inputs) { ItemStack ret = Prep.getEmpty(); for (MachineRecipeInput ri : inputs) { ret = getInputForSlot(slot, ri); if (Prep.isValid(ret)) { return ret; } } return ret; }
@Override public boolean isEmpty() { for (int i = 0; i < getSizeInventory(); i++) { if (Prep.isValid(getStackInSlot(i))) { return false; } } return true; }
@SuppressWarnings("null") public static @Nonnull NBTTagCompound getReadOnlyRoot(@Nonnull ItemStack stack) { if (Prep.isValid(stack) && stack.hasTagCompound()) { return stack.getTagCompound(); } return new NBTTagCompound(); }
@Override public @Nonnull ItemStack getRecipeOutput() { if (result.isPotentiallyValid()) { ItemStack itemStack = result.getItemStack(); if (Prep.isValid(itemStack)) { return itemStack; } } // JEI doesn't like recipes with empty results return super.getRecipeOutput(); }
public boolean isValidInput(@Nonnull RecipeLevel machineLevel, @Nonnull MachineRecipeInput input) { for (IRecipe recipe : recipes) { if (machineLevel.canMake(recipe.getRecipeLevel())) { if (Prep.isValid(input.item) && recipe.isValidInput(input.slotNumber, input.item)) { return true; } else if (input.fluid != null && recipe.isValidInput(input.fluid)) { return true; } } } return false; }
@Override protected boolean plantFromInventory(@Nonnull IFarmer farm, @Nonnull BlockPos bc) { World world = farm.getWorld(); if (canPlant(farm, world, bc) && Prep.isValid(farm.takeSeedFromSupplies(seeds, bc))) { return plant(farm, world, bc); } return false; }
protected boolean plantFromInventory(@Nonnull IFarmer farm, @Nonnull BlockPos bc, @Nonnull IPlantable plantable) { World world = farm.getWorld(); if (canPlant(farm, world, bc, plantable) && Prep.isValid(farm.takeSeedFromSupplies(bc, true)) && plant(farm, world, bc, plantable)) { farm.takeSeedFromSupplies(bc, false); return true; } return false; }
@SuppressWarnings("null") public @Nonnull String getString(@Nonnull ItemStack stack, @Nonnull String _default) { if (Prep.isValid(stack) && stack.hasTagCompound() && stack.getTagCompound().hasKey(key)) { return stack.getTagCompound().getString(key); } return _default; }
@SubscribeEvent public void renderOverlay(@Nonnull RenderGameOverlayEvent.Post event) { ItemStack equippedProbe = getEquippedProbe(); if (event.getType() == ElementType.ALL && Prep.isValid(equippedProbe)) { doRenderOverlay(event, equippedProbe); } }
@Override protected @Nonnull NNList<MachineRecipeInput> getRecipeInputs() { NNList<MachineRecipeInput> res = new NNList<>(); for (int slot = slotDefinition.minInputSlot; slot <= slotDefinition.maxInputSlot - 2; slot++) { final ItemStack item = getStackInSlot(slot); if (Prep.isValid(item)) { res.add(new MachineRecipeInput(slot, item)); } } return res; }
@SuppressWarnings("null") public @Nonnull ItemStack setInt(@Nonnull ItemStack stack, int value) { if (Prep.isValid(stack)) { if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } stack.getTagCompound().setInteger(key, value); } return stack; }
@SuppressWarnings("null") public @Nonnull ItemStack setBoolean(@Nonnull ItemStack stack, boolean value) { if (Prep.isValid(stack)) { if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } stack.getTagCompound().setBoolean(key, value); } return stack; }
@SuppressWarnings("null") public static @Nonnull NBTTagCompound getOrCreateRoot(@Nonnull ItemStack stack) { if (Prep.isValid(stack)) { if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } return stack.getTagCompound(); } return new NBTTagCompound(); }
@SuppressWarnings("null") public @Nonnull ItemStack setString(@Nonnull ItemStack stack, String value) { if (Prep.isValid(stack) && value != null) { if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } stack.getTagCompound().setString(key, value); } else { removeTag(stack); } return stack; }
@Nonnull protected NNList<MachineRecipeInput> getRecipeInputs() { NNList<MachineRecipeInput> res = new NNList<>(); EnderInventory.View inputSlots = getInventory().getView(EnderInventory.Type.INPUT); for (int slot = 0; slot < inputSlots.getSlots(); slot++) { final ItemStack item = inputSlots.getStackInSlot(slot); if (Prep.isValid(item)) { res.add(new MachineRecipeInput(slot, item)); } } return res; }