use of com.enderio.core.common.util.NNList in project EnderIO by SleepyTrousers.
the class BlockPaintedStone method getDrops.
@Override
public void getDrops(@Nonnull NonNullList<ItemStack> drops, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull IBlockState state, int fortune) {
NNList<ItemStack> drops2 = new NNList<>();
super.getDrops(drops2, world, pos, state, fortune);
for (ItemStack drop : drops2) {
PaintUtil.setSourceBlock(NullHelper.notnullM(drop, "null stack from getDrops()"), getPaintSource(state, world, pos));
}
drops.addAll(drops2);
}
use of com.enderio.core.common.util.NNList in project EnderIO by SleepyTrousers.
the class DarkSteelUpgradeRecipeCategory method register.
public static void register(IModRegistry registry) {
long start = System.nanoTime();
registry.addRecipeCatalyst(new ItemStack(blockDarkSteelAnvil.getBlockNN()), VanillaRecipeCategoryUid.ANVIL);
NNList<ItemStack> blacklist = new NNList<>();
for (UpgradePath rec : allRecipes) {
rec.getOutput().getItem().getSubItems(getCreativeTab(rec), blacklist);
}
NNList<ItemStack> seen = new NNList<>();
for (UpgradePath rec : allRecipes) {
if (!inList(blacklist, rec.getOutput()) && !inList(seen, rec.getOutput())) {
seen.add(rec.getOutput());
}
}
int enchantmentRecipes = registerBookEnchantmentRecipes(registry, seen);
final IVanillaRecipeFactory factory = registry.getJeiHelpers().getVanillaRecipeFactory();
Collection<IRecipeWrapper> anvilRecipes = NullHelper.notnullJ(allRecipes.stream().map(rec -> factory.createAnvilRecipe(rec.getInput(), Collections.singletonList(rec.getUpgrade()), Collections.singletonList(rec.getOutput()))).collect(Collectors.toList()), "Stream#collect");
registry.addRecipes(anvilRecipes, VanillaRecipeCategoryUid.ANVIL);
Log.info(String.format("DarkSteelUpgradeRecipeCategory: Added %d dark steel upgrade recipes and %d enchantment recipes for upgradable items to JEI in %.3f seconds.", allRecipes.size(), enchantmentRecipes, (System.nanoTime() - start) / 1000000000d));
}
use of com.enderio.core.common.util.NNList in project EnderIO by SleepyTrousers.
the class DarkSteelUpgradeSubtypeInterpreter method apply.
@Override
@Nonnull
public String apply(ItemStack itemStack) {
if (itemStack == null) {
throw new NullPointerException("You want me to return something Nonnull for a null ItemStack? F.U.");
}
String result = DarkSteelRecipeManager.getUpgradesAsString(itemStack);
Map<Enchantment, Integer> enchantments = EnchantmentHelper.getEnchantments(itemStack);
final List<Enchantment> keyList = new NNList<>(enchantments.keySet());
keyList.sort(new Comparator<Enchantment>() {
@Override
public int compare(Enchantment o1, Enchantment o2) {
return safeString(o1).compareTo(safeString(o2));
}
});
for (Enchantment enchantment : keyList) {
result += "/" + safeString(enchantment);
}
return "DS:" + result;
}
use of com.enderio.core.common.util.NNList in project EnderIO by SleepyTrousers.
the class SoulBinderRecipeManager method addRecipeFromNBT.
// @formatter:off
/**
* Example of how to add a recipe:
*
* <pre> NBTTagCompound root = new NBTTagCompound();
* root.setString(SoulBinderRecipeManager.KEY_RECIPE_UID, "diamondToWood");
* root.setInteger(SoulBinderRecipeManager.KEY_REQUIRED_ENERGY, 50000);
* root.setInteger(SoulBinderRecipeManager.KEY_REQUIRED_XP, 7);
* root.setString(SoulBinderRecipeManager.KEY_SOUL_TYPES, "minecraft:zombie|specialmobs:specialzombie|minecraft:villager");
* ItemStack is = new ItemStack(Items.diamond);
* NBTTagCompound stackRoot = new NBTTagCompound();
* is.writeToNBT(stackRoot);
* root.setTag(SoulBinderRecipeManager.KEY_INPUT_STACK, stackRoot);
* is = new ItemStack(Blocks.planks);
* stackRoot = new NBTTagCompound();
* is.writeToNBT(stackRoot);
* root.setTag(SoulBinderRecipeManager.KEY_OUTPUT_STACK, stackRoot);
*
* SoulBinderRecipeManager.getInstance().addRecipeFromNBT(root);
* FMLInterModComms.sendMessage("EnderIO", "recipe:soulbinder", root);</pre>
*
* @param root
* @return
*/
// @formatter:on
public boolean addRecipeFromNBT(@Nonnull NBTTagCompound root) {
try {
String recipeUid = root.getString(KEY_RECIPE_UID);
if (recipeUid.trim().length() == 0) {
Log.error("SoulBinderRecipeManager: Could not add custom soul binder recipe from IMC as recipe UID not set: " + root);
return false;
}
ItemStack inputStack = getStackFromRoot(root, KEY_INPUT_STACK);
if (Prep.isInvalid(inputStack)) {
Log.error("SoulBinderRecipeManager: Could not add custom soul binder recipe from IMC as no input stack defined: " + root);
return false;
}
ItemStack outputStack = getStackFromRoot(root, KEY_OUTPUT_STACK);
if (Prep.isInvalid(outputStack)) {
Log.error("SoulBinderRecipeManager: Could not add custom soul binder recipe from IMC as no output stack defined: " + root);
return false;
}
int energyRequired = root.getInteger(KEY_REQUIRED_ENERGY);
if (energyRequired <= 0) {
Log.error("SoulBinderRecipeManager: Could not add custom soul binder recipe from IMC as energy required was <= 0: " + root);
return false;
}
int xpLevelsRequired = root.getInteger(KEY_REQUIRED_XP);
if (xpLevelsRequired <= 0) {
Log.error("SoulBinderRecipeManager: Could not add custom soul binder recipe from IMC as XP required was <= 0: " + root);
return false;
}
String str = root.getString(KEY_SOUL_TYPES);
if (str.trim().length() == 0) {
Log.error("SoulBinderRecipeManager: Could not add custom soul binder recipe from IMC as no soul types defined: " + root);
return false;
}
String[] entityNames = str.split("\\|");
NNList<ResourceLocation> entityRLs = new NNList<>();
for (String string : entityNames) {
if (string == null || string.trim().isEmpty()) {
Log.error("SoulBinderRecipeManager: Could not add custom soul binder recipe from IMC as no soul types contains emtpty entry: " + root);
return false;
}
entityRLs.add(new ResourceLocation(string));
}
if (entityRLs.isEmpty()) {
Log.error("SoulBinderRecipeManager: Could not add custom soul binder recipe from IMC as no soul types defined: " + root);
return false;
}
BasicSoulBinderRecipe recipe = new BasicSoulBinderRecipe(inputStack, outputStack, energyRequired, xpLevelsRequired, recipeUid, entityRLs.toArray(new ResourceLocation[0]));
MachineRecipeRegistry.instance.registerRecipe(MachineRecipeRegistry.SOULBINDER, recipe);
return true;
} catch (Exception e) {
Log.error("SoulBinderRecipeManager: Could not add custom soul binder exception thrown when parsing message: " + e);
return false;
}
}
use of com.enderio.core.common.util.NNList in project EnderIO by SleepyTrousers.
the class FarmLogic method endUsingItem.
@Override
@Nonnull
public NNList<ItemStack> endUsingItem(boolean trashHandItem) {
NNList<ItemStack> result = new NNList<>();
for (int i = 0; i < farmerJoe.inventory.getSizeInventory(); i++) {
ItemStack stack = farmerJoe.inventory.removeStackFromSlot(i);
if (Prep.isValid(stack)) {
result.add(stack);
}
}
joeInUse = false;
return result;
}
Aggregations