Alchemy arrays should mostly function now (#1202)

Rewrites the crafting recipe portion of alchemy arrays. Currently the rewritten
portion is wrapped in the old stuff. Ideally the remaining old stuff will
be rewritten as well.

Mods who wish to do custom array effects still need to depend on internal
classes and I think this is fine.
This commit is contained in:
Nicholas Ignoffo 2018-02-11 11:40:13 -08:00
parent 4b5f8a9685
commit 123b06c288
10 changed files with 239 additions and 34 deletions

View file

@ -0,0 +1,58 @@
package WayofTime.bloodmagic.apibutnotreally.alchemyCrafting;
import WayofTime.bloodmagic.api.impl.recipe.RecipeAlchemyArray;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
public class AlchemyArrayEffectCraftingNew extends AlchemyArrayEffect {
private final RecipeAlchemyArray recipe;
public AlchemyArrayEffectCraftingNew(RecipeAlchemyArray recipe) {
this(recipe.getOutput().toString() + 200, recipe);
}
public AlchemyArrayEffectCraftingNew(String key, RecipeAlchemyArray recipeAlchemyArray) {
super(key);
this.recipe = recipeAlchemyArray;
}
@Override
public boolean update(TileEntity tile, int ticksActive) {
if (tile.getWorld().isRemote)
return false;
if (ticksActive >= 200) {
BlockPos pos = tile.getPos();
ItemStack output = recipe.getOutput().copy();
EntityItem outputEntity = new EntityItem(tile.getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output);
tile.getWorld().spawnEntity(outputEntity);
return true;
}
return false;
}
@Override
public void writeToNBT(NBTTagCompound tag) {
}
@Override
public void readFromNBT(NBTTagCompound tag) {
}
@Override
public AlchemyArrayEffect getNewCopy() {
return new AlchemyArrayEffectCraftingNew(key, recipe);
}
}

View file

@ -17,7 +17,7 @@ import java.util.List;
import java.util.Map.Entry;
public class AlchemyArrayRecipeRegistry {
public static final AlchemyCircleRenderer defaultRenderer = new AlchemyCircleRenderer(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BaseArray.png"));
public static final AlchemyCircleRenderer DEFAULT_RENDERER = new AlchemyCircleRenderer(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BaseArray.png"));
private static BiMap<List<ItemStack>, AlchemyArrayRecipe> recipes = HashBiMap.create();
private static HashMap<String, AlchemyArrayEffect> effectMap = new HashMap<String, AlchemyArrayEffect>();
@ -56,7 +56,7 @@ public class AlchemyArrayRecipeRegistry {
}
}
recipes.put(input, new AlchemyArrayRecipe(input, catalystStack, arrayEffect, circleRenderer == null ? defaultRenderer : circleRenderer));
recipes.put(input, new AlchemyArrayRecipe(input, catalystStack, arrayEffect, circleRenderer == null ? DEFAULT_RENDERER : circleRenderer));
}
public static AlchemyArrayEffect getAlchemyArrayEffect(String key) {
@ -136,7 +136,7 @@ public class AlchemyArrayRecipeRegistry {
}
public static void registerRecipe(ItemStack inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource) {
AlchemyCircleRenderer circleRenderer = arrayResource == null ? defaultRenderer : new AlchemyCircleRenderer(arrayResource);
AlchemyCircleRenderer circleRenderer = arrayResource == null ? DEFAULT_RENDERER : new AlchemyCircleRenderer(arrayResource);
registerRecipe(Collections.singletonList(inputStacks), catalystStack, arrayEffect, circleRenderer);
}
@ -145,12 +145,12 @@ public class AlchemyArrayRecipeRegistry {
}
public static void registerRecipe(List<ItemStack> inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource) {
AlchemyCircleRenderer circleRenderer = arrayResource == null ? defaultRenderer : new AlchemyCircleRenderer(arrayResource);
AlchemyCircleRenderer circleRenderer = arrayResource == null ? DEFAULT_RENDERER : new AlchemyCircleRenderer(arrayResource);
registerRecipe(inputStacks, catalystStack, arrayEffect, circleRenderer);
}
public static void registerRecipe(String inputOreDict, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource) {
AlchemyCircleRenderer circleRenderer = arrayResource == null ? defaultRenderer : new AlchemyCircleRenderer(arrayResource);
AlchemyCircleRenderer circleRenderer = arrayResource == null ? DEFAULT_RENDERER : new AlchemyCircleRenderer(arrayResource);
registerRecipe(OreDictionary.doesOreNameExist(inputOreDict) && OreDictionary.getOres(inputOreDict).size() > 0 ? OreDictionary.getOres(inputOreDict) : Collections.<ItemStack>emptyList(), catalystStack, arrayEffect, circleRenderer);
}
@ -185,7 +185,7 @@ public class AlchemyArrayRecipeRegistry {
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet()) {
AlchemyArrayRecipe arrayRecipe = entry.getValue();
if (input.size() == 1 && arrayRecipe.getInput().size() == 1) {
if (ItemStackWrapper.getHolder(arrayRecipe.getInput().get(0)).equals(ItemStackWrapper.getHolder(input.get(0)))) {
if (ItemStack.areItemsEqual(input.get(0), arrayRecipe.input.get(0))) {
AlchemyArrayEffect effect = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
if (effect != null) {
return effect.getNewCopy();
@ -220,7 +220,7 @@ public class AlchemyArrayRecipeRegistry {
}
}
return defaultRenderer;
return DEFAULT_RENDERER;
}
public static AlchemyCircleRenderer getAlchemyCircleRenderer(ItemStack itemStack, @Nullable ItemStack catalystStack) {