2016-08-03 04:01:47 +02:00
|
|
|
/*
|
|
|
|
* This file ("EmpowererRecipe.java") is part of the Actually Additions mod for Minecraft.
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
|
|
|
* http://ellpeck.de/actaddlicense
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2017-01-01 16:23:26 +01:00
|
|
|
* © 2015-2017 Ellpeck
|
2016-08-03 04:01:47 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
package de.ellpeck.actuallyadditions.api.recipe;
|
|
|
|
|
2018-06-24 20:35:50 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2016-08-03 04:01:47 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
2018-06-24 02:44:47 +02:00
|
|
|
import net.minecraft.item.crafting.Ingredient;
|
2016-08-03 04:01:47 +02:00
|
|
|
|
2018-06-24 02:44:47 +02:00
|
|
|
public class EmpowererRecipe {
|
2016-08-03 04:01:47 +02:00
|
|
|
|
2018-06-24 02:44:47 +02:00
|
|
|
protected final Ingredient input;
|
|
|
|
protected final ItemStack output;
|
2016-08-03 04:01:47 +02:00
|
|
|
|
2018-06-24 02:44:47 +02:00
|
|
|
protected final Ingredient modifier1;
|
|
|
|
protected final Ingredient modifier2;
|
|
|
|
protected final Ingredient modifier3;
|
|
|
|
protected final Ingredient modifier4;
|
2016-08-03 04:01:47 +02:00
|
|
|
|
2018-06-24 02:44:47 +02:00
|
|
|
protected final int energyPerStand;
|
|
|
|
protected final float[] particleColor;
|
|
|
|
protected final int time;
|
2016-08-03 04:01:47 +02:00
|
|
|
|
2018-06-24 02:44:47 +02:00
|
|
|
@Deprecated
|
|
|
|
public EmpowererRecipe(ItemStack input, ItemStack output, ItemStack modifier1, ItemStack modifier2, ItemStack modifier3, ItemStack modifier4, int energyPerStand, int time, float[] particleColor) {
|
|
|
|
this(Ingredient.fromStacks(input), output, Ingredient.fromStacks(modifier1), Ingredient.fromStacks(modifier2), Ingredient.fromStacks(modifier3), Ingredient.fromStacks(modifier4), energyPerStand, time, particleColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
public EmpowererRecipe(Ingredient input, ItemStack output, Ingredient modifier1, Ingredient modifier2, Ingredient modifier3, Ingredient modifier4, int energyPerStand, int time, float[] particleColor) {
|
2016-08-03 04:01:47 +02:00
|
|
|
this.input = input;
|
|
|
|
this.output = output;
|
|
|
|
this.modifier1 = modifier1;
|
|
|
|
this.modifier2 = modifier2;
|
|
|
|
this.modifier3 = modifier3;
|
|
|
|
this.modifier4 = modifier4;
|
|
|
|
this.energyPerStand = energyPerStand;
|
|
|
|
this.particleColor = particleColor;
|
2016-08-03 17:59:27 +02:00
|
|
|
this.time = time;
|
2016-08-03 04:01:47 +02:00
|
|
|
}
|
2018-06-24 02:44:47 +02:00
|
|
|
|
|
|
|
public boolean matches(ItemStack base, ItemStack stand1, ItemStack stand2, ItemStack stand3, ItemStack stand4) {
|
2019-02-27 19:53:05 +01:00
|
|
|
if (!this.input.apply(base)) return false;
|
2018-06-24 20:35:50 +02:00
|
|
|
List<Ingredient> matches = new ArrayList<>();
|
|
|
|
ItemStack[] stacks = { stand1, stand2, stand3, stand4 };
|
2018-07-10 05:40:41 +02:00
|
|
|
boolean[] unused = { true, true, true, true };
|
2018-06-24 20:35:50 +02:00
|
|
|
for (ItemStack s : stacks) {
|
2019-02-27 19:53:05 +01:00
|
|
|
if (unused[0] && this.modifier1.apply(s)) {
|
|
|
|
matches.add(this.modifier1);
|
2018-07-10 05:40:41 +02:00
|
|
|
unused[0] = false;
|
2019-02-27 19:53:05 +01:00
|
|
|
} else if (unused[1] && this.modifier2.apply(s)) {
|
|
|
|
matches.add(this.modifier2);
|
2018-07-10 05:40:41 +02:00
|
|
|
unused[1] = false;
|
2019-02-27 19:53:05 +01:00
|
|
|
} else if (unused[2] && this.modifier3.apply(s)) {
|
|
|
|
matches.add(this.modifier3);
|
2018-07-10 05:40:41 +02:00
|
|
|
unused[2] = false;
|
2019-02-27 19:53:05 +01:00
|
|
|
} else if (unused[3] && this.modifier4.apply(s)) {
|
|
|
|
matches.add(this.modifier4);
|
2018-07-10 05:40:41 +02:00
|
|
|
unused[3] = false;
|
|
|
|
}
|
2018-06-24 20:35:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return matches.size() == 4;
|
2018-06-24 02:44:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Ingredient getInput() {
|
2019-02-27 19:53:05 +01:00
|
|
|
return this.input;
|
2018-06-24 02:44:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public ItemStack getOutput() {
|
2019-02-27 19:53:05 +01:00
|
|
|
return this.output;
|
2018-06-24 02:44:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Ingredient getStandOne() {
|
2019-02-27 19:53:05 +01:00
|
|
|
return this.modifier1;
|
2018-06-24 02:44:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Ingredient getStandTwo() {
|
2019-02-27 19:53:05 +01:00
|
|
|
return this.modifier2;
|
2018-06-24 02:44:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Ingredient getStandThree() {
|
2019-02-27 19:53:05 +01:00
|
|
|
return this.modifier3;
|
2018-06-24 02:44:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Ingredient getStandFour() {
|
2019-02-27 19:53:05 +01:00
|
|
|
return this.modifier4;
|
2018-06-24 02:44:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getTime() {
|
2019-02-27 19:53:05 +01:00
|
|
|
return this.time;
|
2018-06-24 02:44:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getEnergyPerStand() {
|
2019-02-27 19:53:05 +01:00
|
|
|
return this.energyPerStand;
|
2018-06-24 02:44:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public float[] getParticleColors() {
|
2019-02-27 19:53:05 +01:00
|
|
|
return this.particleColor;
|
2018-06-24 02:44:47 +02:00
|
|
|
}
|
2016-08-03 04:01:47 +02:00
|
|
|
}
|