Fixed regression in potion based recipes

This commit is contained in:
Unknown 2019-05-12 19:53:28 +02:00 committed by unknown
parent f6df891976
commit 6dbc8e200a
2 changed files with 72 additions and 42 deletions

View file

@ -5,11 +5,16 @@ import cr0s.warpdrive.api.ParticleStack;
import javax.annotation.Nonnull;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemPotion;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.potion.PotionEffect;
import net.minecraft.potion.PotionUtils;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.crafting.CraftingHelper;
@ -51,23 +56,48 @@ public class RecipeParticleShapedOre extends ShapedOreRecipe {
if (itemStackTargets.length == 1) {// simple ingredient
final ItemStack itemStackTarget = itemStackTargets[0];
if ( !itemStackSlot.isEmpty()
&& itemStackSlot.hasTagCompound()
&& itemStackSlot.getItem() instanceof IParticleContainerItem
&& itemStackTarget.getItem() instanceof IParticleContainerItem ) {
final IParticleContainerItem particleContainerItemSlot = (IParticleContainerItem) itemStackSlot.getItem();
final ParticleStack particleStackSlot = particleContainerItemSlot.getParticleStack(itemStackSlot);
final IParticleContainerItem particleContainerItemTarget = (IParticleContainerItem) itemStackTarget.getItem();
final ParticleStack particleStackTarget = particleContainerItemTarget.getParticleStack(itemStackTarget);
// reject different particles or insufficient quantity
if (!particleStackSlot.containsParticle(particleStackTarget)) {
return false;
&& itemStackSlot.hasTagCompound() ) {
if ( itemStackSlot.getItem() instanceof IParticleContainerItem
&& itemStackTarget.getItem() instanceof IParticleContainerItem ) {
final IParticleContainerItem particleContainerItemSlot = (IParticleContainerItem) itemStackSlot.getItem();
final ParticleStack particleStackSlot = particleContainerItemSlot.getParticleStack(itemStackSlot);
final IParticleContainerItem particleContainerItemTarget = (IParticleContainerItem) itemStackTarget.getItem();
final ParticleStack particleStackTarget = particleContainerItemTarget.getParticleStack(itemStackTarget);
// reject different particles or insufficient quantity
if (!particleStackSlot.containsParticle(particleStackTarget)) {
return false;
}
// it's a match! => mark quantity to consume
particleContainerItemSlot.setAmountToConsume(itemStackSlot, particleStackTarget.getAmount());
continue;
} else if ( itemStackSlot.getItem() instanceof ItemPotion
&& itemStackTarget.getItem() instanceof ItemPotion ) {
final List<PotionEffect> potionEffectsSlot = PotionUtils.getEffectsFromStack(itemStackSlot);
final List<PotionEffect> potionEffectsTarget = PotionUtils.getEffectsFromStack(itemStackTarget);
// reject different amount of potion effects
if (potionEffectsSlot.size() != potionEffectsTarget.size()) {
return false;
}
// verify matching effects
for (final PotionEffect potionEffectTarget : potionEffectsTarget) {
if (!potionEffectsSlot.contains(potionEffectTarget)) {
return false;
}
}
// it's a match!
continue;
}
// mark quantity otherwise
particleContainerItemSlot.setAmountToConsume(itemStackSlot, particleStackTarget.getAmount());
} else if (!OreDictionary.itemMatches(itemStackTarget, itemStackSlot, false)) {
// (single item stack but neither particle nor potion => default to ore dictionary matching)
}
if (!OreDictionary.itemMatches(itemStackTarget, itemStackSlot, false)) {
return false;
}

View file

@ -305,20 +305,20 @@ public class Recipes {
// superior is 1 laser medium (empty), 4 redstone blocks, 4 lapis blocks
final ItemStack itemStackWaterBottle = WarpDriveConfig.getItemStackOrFire("minecraft:potion", 0, "{Potion: \"minecraft:water\"}");
final ItemStack itemStackAwkwardPotion = WarpDriveConfig.getItemStackOrFire("minecraft:potion", 0, "{Potion: \"minecraft:awkward\"}");
WarpDrive.register(new ShapedOreRecipe(groupMachines,
new ItemStack(WarpDrive.blockLaserMediums[EnumTier.BASIC.getIndex()]), false, " ", "dwd", "pm ",
'd', "dye",
'w', itemStackWaterBottle,
'p', ItemComponent.getItemStack(EnumComponentType.POWER_INTERFACE),
'm', itemStackMachineCasings[0] ));
WarpDrive.register(new ShapedOreRecipe(groupMachines,
new ItemStack(WarpDrive.blockLaserMediums[EnumTier.ADVANCED.getIndex()]), false, "rAr", "lBl", "pm ",
'r', "dustRedstone",
'A', itemStackAwkwardPotion,
'l', "gemLapis",
'B', ItemComponent.getItemStack(EnumComponentType.GLASS_TANK),
'p', ItemComponent.getItemStack(EnumComponentType.POWER_INTERFACE),
'm', itemStackMachineCasings[1] ));
WarpDrive.register(new RecipeParticleShapedOre(groupMachines,
new ItemStack(WarpDrive.blockLaserMediums[EnumTier.BASIC.getIndex()]), false, " ", "dwd", "pm ",
'd', "dye",
'w', itemStackWaterBottle,
'p', ItemComponent.getItemStack(EnumComponentType.POWER_INTERFACE),
'm', itemStackMachineCasings[0] ));
WarpDrive.register(new RecipeParticleShapedOre(groupMachines,
new ItemStack(WarpDrive.blockLaserMediums[EnumTier.ADVANCED.getIndex()]), false, "rAr", "lBl", "pm ",
'r', "dustRedstone",
'A', itemStackAwkwardPotion,
'l', "gemLapis",
'B', ItemComponent.getItemStack(EnumComponentType.GLASS_TANK),
'p', ItemComponent.getItemStack(EnumComponentType.POWER_INTERFACE),
'm', itemStackMachineCasings[1] ));
WarpDrive.register(new ShapedOreRecipe(groupMachines,
new ItemStack(WarpDrive.blockLaserMediums[EnumTier.SUPERIOR.getIndex()]), false, "lrl", "rmr", "lrl",
'm', ItemComponent.getItemStack(EnumComponentType.LASER_MEDIUM_EMPTY),
@ -375,12 +375,12 @@ public class Recipes {
// (IC2 Experimental is 1 Lithium dust from 18 nether quartz)
// Regeneration II (ghast tear + glowstone)
final ItemStack itemStackStrongRegeneration = WarpDriveConfig.getItemStackOrFire("minecraft:potion", 0, "{Potion: \"minecraft:strong_regeneration\"}");
WarpDrive.register(new ShapedOreRecipe(groupComponents,
ItemComponent.getItemStackNoCache(EnumComponentType.CAPACITIVE_CRYSTAL, 2), false, "prp", "lRl", "prp",
'R', itemStackStrongRegeneration,
'r', "blockRedstone",
'l', lithiumOrElectrum,
'p', Items.PAPER ));
WarpDrive.register(new RecipeParticleShapedOre(groupComponents,
ItemComponent.getItemStackNoCache(EnumComponentType.CAPACITIVE_CRYSTAL, 2), false, "prp", "lRl", "prp",
'R', itemStackStrongRegeneration,
'r', "blockRedstone",
'l', lithiumOrElectrum,
'p', Items.PAPER ));
WarpDrive.register(new ShapelessOreRecipe(groupComponents,
ItemComponent.getItemStack(EnumComponentType.CAPACITIVE_CLUSTER),
ItemComponent.getItemStack(EnumComponentType.CAPACITIVE_CRYSTAL),
@ -572,12 +572,12 @@ public class Recipes {
// *** crafting components
// Laser medium (empty) is 3 Glass tanks, 1 Power interface, 1 Computer interface, 1 MV Machine casing
final ItemStack itemStackAwkwardPotion = WarpDriveConfig.getItemStackOrFire("minecraft:potion", 0, "{Potion: \"minecraft:awkward\"}");
WarpDrive.register(new ShapedOreRecipe(groupMachines,
ItemComponent.getItemStack(EnumComponentType.LASER_MEDIUM_EMPTY), false, " ", "gBg", "pm ",
'B', itemStackAwkwardPotion,
'g', ItemComponent.getItemStack(EnumComponentType.GLASS_TANK),
'p', ItemComponent.getItemStack(EnumComponentType.POWER_INTERFACE),
'm', itemStackMachineCasings[2] ));
WarpDrive.register(new RecipeParticleShapedOre(groupMachines,
ItemComponent.getItemStack(EnumComponentType.LASER_MEDIUM_EMPTY), false, " ", "gBg", "pm ",
'B', itemStackAwkwardPotion,
'g', ItemComponent.getItemStack(EnumComponentType.GLASS_TANK),
'p', ItemComponent.getItemStack(EnumComponentType.POWER_INTERFACE),
'm', itemStackMachineCasings[2] ));
// Electromagnetic Projector is 5 Coil crystals, 1 Power interface, 1 Computer interface, 2 Motors
WarpDrive.register(new ShapedOreRecipe(groupMachines,