Reorganized the AlchemyArrayEffects so it is easier to make more unique arrays. Also fixed an NPE when crafting sigils.

This commit is contained in:
WayofTime 2016-06-27 11:21:37 -04:00
parent 587e94d197
commit c5f0333aac
6 changed files with 138 additions and 25 deletions

View file

@ -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();
}

View file

@ -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);
}
}