2015-12-23 18:45:47 -05:00
|
|
|
package WayofTime.bloodmagic.api.alchemyCrafting;
|
|
|
|
|
|
|
|
import lombok.Getter;
|
|
|
|
import net.minecraft.entity.item.EntityItem;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.BlockPos;
|
|
|
|
|
|
|
|
public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect {
|
|
|
|
|
|
|
|
@Getter
|
|
|
|
public final ItemStack outputStack;
|
2015-12-26 14:40:51 -05:00
|
|
|
public int tickLimit;
|
2015-12-23 18:45:47 -05:00
|
|
|
|
|
|
|
public AlchemyArrayEffectCrafting(ItemStack outputStack) {
|
2015-12-26 14:40:51 -05:00
|
|
|
this(outputStack, 200);
|
|
|
|
}
|
|
|
|
|
|
|
|
public AlchemyArrayEffectCrafting(ItemStack outputStack, int tickLimit) {
|
2015-12-23 18:45:47 -05:00
|
|
|
this.outputStack = outputStack;
|
2015-12-26 14:40:51 -05:00
|
|
|
this.tickLimit = tickLimit;
|
2015-12-23 18:45:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean update(TileEntity tile, int ticksActive) {
|
|
|
|
//TODO: Add recipe rechecking to verify nothing screwy is going on.
|
2015-12-23 20:19:06 -05:00
|
|
|
if(tile.getWorld().isRemote) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-12-23 22:30:13 -05:00
|
|
|
|
2015-12-26 14:40:51 -05:00
|
|
|
if(ticksActive >= tickLimit){
|
2015-12-23 22:30:13 -05:00
|
|
|
BlockPos pos = tile.getPos();
|
2015-12-23 18:45:47 -05:00
|
|
|
|
2015-12-23 22:30:13 -05:00
|
|
|
ItemStack output = outputStack.copy();
|
|
|
|
EntityItem outputEntity = new EntityItem(tile.getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output);
|
2015-12-23 18:45:47 -05:00
|
|
|
|
2015-12-23 22:30:13 -05:00
|
|
|
tile.getWorld().spawnEntityInWorld(outputEntity);
|
2015-12-23 18:45:47 -05:00
|
|
|
|
2015-12-23 22:30:13 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2015-12-23 18:45:47 -05:00
|
|
|
}
|
|
|
|
}
|