2015-12-26 14:40:51 -05:00
|
|
|
package WayofTime.bloodmagic.alchemyArray;
|
|
|
|
|
2015-12-27 21:11:42 -05:00
|
|
|
import net.minecraft.entity.effect.EntityLightningBolt;
|
|
|
|
import net.minecraft.entity.item.EntityItem;
|
2015-12-26 14:40:51 -05:00
|
|
|
import net.minecraft.item.ItemStack;
|
2016-06-27 11:21:37 -04:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2015-12-27 21:11:42 -05:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2016-03-17 13:00:44 -07:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2015-12-27 21:11:42 -05:00
|
|
|
import net.minecraft.world.World;
|
2016-08-08 16:50:02 -04:00
|
|
|
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
|
|
|
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting;
|
|
|
|
import WayofTime.bloodmagic.client.render.alchemyArray.BindingAlchemyCircleRenderer;
|
2015-12-26 14:40:51 -05:00
|
|
|
|
2016-08-08 16:50:02 -04:00
|
|
|
public class AlchemyArrayEffectBinding extends AlchemyArrayEffectCrafting
|
2015-12-30 15:34:40 -05:00
|
|
|
{
|
2016-06-27 11:21:37 -04:00
|
|
|
public AlchemyArrayEffectBinding(String key, ItemStack outputStack)
|
2015-12-30 15:34:40 -05:00
|
|
|
{
|
2016-08-08 16:50:02 -04:00
|
|
|
super(key, outputStack, 200);
|
2015-12-30 15:34:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean update(TileEntity tile, int ticksActive)
|
|
|
|
{
|
|
|
|
if (ticksActive >= 50 && ticksActive <= 250)
|
|
|
|
{
|
|
|
|
// TODO: Find a way to spawn lightning from only the server side -
|
|
|
|
// does not render when just spawned on server, not client.
|
|
|
|
this.spawnLightningOnCircle(tile.getWorld(), tile.getPos(), ticksActive);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tile.getWorld().isRemote)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ticksActive >= 300)
|
|
|
|
{
|
|
|
|
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-02-04 22:43:18 -08:00
|
|
|
tile.getWorld().spawnEntity(outputEntity);
|
2015-12-30 15:34:40 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void spawnLightningOnCircle(World world, BlockPos pos, int ticksActive)
|
|
|
|
{
|
|
|
|
if (ticksActive % 50 == 0)
|
|
|
|
{
|
|
|
|
int circle = ticksActive / 50 - 1;
|
|
|
|
float distance = BindingAlchemyCircleRenderer.getDistanceOfCircle(circle, ticksActive);
|
|
|
|
float angle = BindingAlchemyCircleRenderer.getAngleOfCircle(circle, ticksActive);
|
|
|
|
|
|
|
|
double dispX = distance * Math.sin(angle);
|
|
|
|
double dispZ = -distance * Math.cos(angle);
|
|
|
|
|
2016-03-17 13:00:44 -07:00
|
|
|
EntityLightningBolt lightning = new EntityLightningBolt(world, pos.getX() + dispX, pos.getY(), pos.getZ() + dispZ, true);
|
2017-02-04 22:43:18 -08:00
|
|
|
world.spawnEntity(lightning);
|
2015-12-30 15:34:40 -05:00
|
|
|
}
|
|
|
|
}
|
2016-06-27 11:21:37 -04:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeToNBT(NBTTagCompound tag)
|
|
|
|
{
|
|
|
|
//EMPTY
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void readFromNBT(NBTTagCompound tag)
|
|
|
|
{
|
|
|
|
//EMPTY
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public AlchemyArrayEffect getNewCopy()
|
|
|
|
{
|
|
|
|
return new AlchemyArrayEffectBinding(key, outputStack);
|
|
|
|
}
|
2015-12-26 14:40:51 -05:00
|
|
|
}
|