BloodMagic/src/main/java/WayofTime/bloodmagic/alchemyArray/AlchemyArrayEffectCrafting.java

64 lines
1.7 KiB
Java
Raw Normal View History

package WayofTime.bloodmagic.alchemyArray;
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;
2017-08-15 21:30:48 -07:00
public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect {
public final ItemStack outputStack;
public int tickLimit;
2017-08-15 21:30:48 -07:00
public AlchemyArrayEffectCrafting(ItemStack outputStack) {
this(outputStack, 200);
}
2017-08-15 21:30:48 -07:00
public AlchemyArrayEffectCrafting(ItemStack outputStack, int tickLimit) {
this(outputStack.toString() + tickLimit, outputStack, tickLimit);
}
2017-08-15 21:30:48 -07:00
public AlchemyArrayEffectCrafting(String key, ItemStack outputStack, int tickLimit) {
super(key);
this.outputStack = outputStack;
this.tickLimit = tickLimit;
}
@Override
2017-08-15 21:30:48 -07:00
public boolean update(TileEntity tile, int ticksActive) {
// TODO: Add recipe rechecking to verify nothing screwy is going on.
2017-08-15 21:30:48 -07:00
if (tile.getWorld().isRemote) {
return false;
}
2017-08-15 21:30:48 -07:00
if (ticksActive >= tickLimit) {
BlockPos pos = tile.getPos();
ItemStack output = outputStack.copy();
EntityItem outputEntity = new EntityItem(tile.getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output);
2017-01-01 21:43:34 -08:00
tile.getWorld().spawnEntity(outputEntity);
return true;
}
return false;
}
@Override
2017-08-15 21:30:48 -07:00
public void writeToNBT(NBTTagCompound tag) {
}
@Override
2017-08-15 21:30:48 -07:00
public void readFromNBT(NBTTagCompound tag) {
}
@Override
2017-08-15 21:30:48 -07:00
public AlchemyArrayEffect getNewCopy() {
return new AlchemyArrayEffectCrafting(key, outputStack, tickLimit);
}
}