2015-12-26 19:40:51 +00:00
|
|
|
package WayofTime.bloodmagic.alchemyArray;
|
|
|
|
|
2016-03-17 20:00:44 +00:00
|
|
|
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
|
|
|
import WayofTime.bloodmagic.client.render.alchemyArray.BindingAlchemyCircleRenderer;
|
2015-12-30 00:11:34 +00:00
|
|
|
import lombok.Getter;
|
2015-12-28 02:11:42 +00:00
|
|
|
import net.minecraft.entity.effect.EntityLightningBolt;
|
|
|
|
import net.minecraft.entity.item.EntityItem;
|
2015-12-26 19:40:51 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
2015-12-28 02:11:42 +00:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2016-03-17 20:00:44 +00:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2015-12-28 02:11:42 +00:00
|
|
|
import net.minecraft.world.World;
|
2015-12-26 19:40:51 +00:00
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
public class AlchemyArrayEffectBinding extends AlchemyArrayEffect
|
|
|
|
{
|
|
|
|
@Getter
|
|
|
|
public final ItemStack outputStack;
|
|
|
|
|
|
|
|
public AlchemyArrayEffectBinding(ItemStack outputStack)
|
|
|
|
{
|
|
|
|
this.outputStack = outputStack;
|
|
|
|
}
|
|
|
|
|
|
|
|
@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);
|
|
|
|
|
|
|
|
tile.getWorld().spawnEntityInWorld(outputEntity);
|
|
|
|
|
|
|
|
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 20:00:44 +00:00
|
|
|
EntityLightningBolt lightning = new EntityLightningBolt(world, pos.getX() + dispX, pos.getY(), pos.getZ() + dispZ, true);
|
2015-12-30 20:34:40 +00:00
|
|
|
world.spawnEntityInWorld(lightning);
|
|
|
|
}
|
|
|
|
}
|
2015-12-26 19:40:51 +00:00
|
|
|
}
|