Reorganized the AlchemyArrayEffects so it is easier to make more unique arrays. Also fixed an NPE when crafting sigils.
This commit is contained in:
parent
587e94d197
commit
c5f0333aac
6 changed files with 138 additions and 25 deletions
|
@ -1,8 +1,21 @@
|
|||
package WayofTime.bloodmagic.api.alchemyCrafting;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public abstract class AlchemyArrayEffect
|
||||
{
|
||||
@Getter
|
||||
public final String key;
|
||||
|
||||
public abstract boolean update(TileEntity tile, int ticksActive);
|
||||
|
||||
public abstract void writeToNBT(NBTTagCompound tag);
|
||||
|
||||
public abstract void readFromNBT(NBTTagCompound tag);
|
||||
|
||||
public abstract AlchemyArrayEffect getNewCopy();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package WayofTime.bloodmagic.api.alchemyCrafting;
|
|||
import lombok.Getter;
|
||||
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;
|
||||
|
||||
|
@ -19,6 +20,12 @@ public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect
|
|||
|
||||
public AlchemyArrayEffectCrafting(ItemStack outputStack, int tickLimit)
|
||||
{
|
||||
this(outputStack.toString() + tickLimit, outputStack, tickLimit);
|
||||
}
|
||||
|
||||
public AlchemyArrayEffectCrafting(String key, ItemStack outputStack, int tickLimit)
|
||||
{
|
||||
super(key);
|
||||
this.outputStack = outputStack;
|
||||
this.tickLimit = tickLimit;
|
||||
}
|
||||
|
@ -37,7 +44,7 @@ public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect
|
|||
BlockPos pos = tile.getPos();
|
||||
|
||||
ItemStack output = outputStack.copy();
|
||||
output.onCrafting(tile.getWorld(), null, output.stackSize);
|
||||
|
||||
EntityItem outputEntity = new EntityItem(tile.getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output);
|
||||
|
||||
tile.getWorld().spawnEntityInWorld(outputEntity);
|
||||
|
@ -47,4 +54,22 @@ public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlchemyArrayEffect getNewCopy()
|
||||
{
|
||||
return new AlchemyArrayEffectCrafting(key, outputStack, tickLimit);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,32 @@
|
|||
package WayofTime.bloodmagic.api.registry;
|
||||
|
||||
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting;
|
||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting;
|
||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
|
||||
public class AlchemyArrayRecipeRegistry
|
||||
{
|
||||
public static final AlchemyCircleRenderer defaultRenderer = 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>();
|
||||
|
||||
/**
|
||||
* General case for creating an AlchemyArrayEffect for a given input.
|
||||
|
@ -41,6 +45,8 @@ public class AlchemyArrayRecipeRegistry
|
|||
*/
|
||||
public static void registerRecipe(List<ItemStack> input, @Nullable ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer)
|
||||
{
|
||||
effectMap.put(arrayEffect.getKey(), arrayEffect);
|
||||
|
||||
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet())
|
||||
{
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
|
@ -67,8 +73,11 @@ public class AlchemyArrayRecipeRegistry
|
|||
{
|
||||
recipes.put(input, new AlchemyArrayRecipe(input, catalystStack, arrayEffect, circleRenderer));
|
||||
}
|
||||
}
|
||||
|
||||
recipes.put(input, new AlchemyArrayRecipe(input, catalystStack, arrayEffect, circleRenderer));
|
||||
public static AlchemyArrayEffect getAlchemyArrayEffect(String key)
|
||||
{
|
||||
return effectMap.get(key);
|
||||
}
|
||||
|
||||
public static void registerCraftingRecipe(ItemStack input, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue