use of com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK in project Wizardry by TeamWizardry.
the class EntityLightningProjectile method onUpdate.
@Override
public void onUpdate() {
super.onUpdate();
if (isDead)
return;
SpellData data = getSpellData();
SpellRing spellRing = getSpellRing();
SpellRing childRing = getChildRing();
double range = childRing.getAttributeValue(world, AttributeRegistry.RANGE, data);
double potency = childRing.getAttributeValue(world, AttributeRegistry.POTENCY, data);
double duration = childRing.getAttributeValue(world, AttributeRegistry.DURATION, data);
double maxPotency = childRing.getModule() != null ? childRing.getModule().getAttributeRanges().get(AttributeRegistry.POTENCY).max : 0;
if (data == null || spellRing == null) {
setDead();
world.removeEntity(this);
return;
}
if (world.isRemote) {
ClientRunnable.run(new ClientRunnable() {
@Override
@SideOnly(Side.CLIENT)
public void runIfClient() {
ParticleBuilder glitter = new ParticleBuilder(10);
glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
glitter.enableMotionCalculation();
glitter.setCollision(true);
glitter.setCanBounce(true);
glitter.setColorFunction(new InterpColorHSV(spellRing.getPrimaryColor(), spellRing.getSecondaryColor()));
ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector().add(new Vec3d(motionX, motionY, motionZ))), 10, 0, (aFloat, particleBuilder) -> {
particleBuilder.setScaleFunction(new InterpScale((float) RandUtil.nextDouble(0.3, 0.8), 0));
particleBuilder.setLifetime(RandUtil.nextInt(30, 40));
particleBuilder.setMotion(new Vec3d(RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(-0.01, 0.01)));
particleBuilder.setAcceleration(new Vec3d(0, RandUtil.nextDouble(0.0005, 0.003), 0));
});
glitter.disableMotionCalculation();
glitter.setMotion(Vec3d.ZERO);
ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector()), 2, 0, (aFloat, particleBuilder) -> {
particleBuilder.setScaleFunction(new InterpScale(RandUtil.nextFloat(2f, 3), 0));
particleBuilder.setLifetime(RandUtil.nextInt(5, 10));
});
}
});
} else {
Vec3d dir = data.getData(LOOK);
if (dir == null)
return;
RandUtilSeed rand = new RandUtilSeed(RandUtil.nextLong(100, 100000));
float u = rand.nextFloat();
float v = rand.nextFloat();
float pitch = (float) (180 * Math.acos(2 * u - 1) / Math.PI);
float yaw = (float) (2 * Math.PI * v);
Vec3d to = dir.rotatePitch(pitch).rotateYaw(yaw).normalize().scale(rand.nextDouble(maxPotency * 5) < potency ? range : 1.0 / 2.0).add(getPositionVector());
ModuleEffectLightning.doLightning(rand.nextLong(100, 100000), world, data.getCaster(world), getPositionVector(), to, range, potency, duration);
}
}
use of com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK in project Wizardry by TeamWizardry.
the class ModuleShapeBeam method renderSpell.
@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceShape instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
IShapeOverrides overrides = spellRing.getOverrideHandler().getConsumerInterface(IShapeOverrides.class);
if (overrides.onRenderBeam(world, spell, spellRing))
return;
Vec3d look = spell.getData(LOOK);
Vec3d position = spell.getOrigin(world);
Entity caster = spell.getCaster(world);
if (look == null || position == null || caster == null)
return;
ItemStack stack = ((EntityLivingBase) caster).getHeldItemMainhand();
if (stack.isEmpty())
return;
double range = spellRing.getAttributeValue(world, AttributeRegistry.RANGE, spell);
RayTraceResult trace = new RayTrace(world, look, position, range).setEntityFilter(input -> input != caster).setReturnLastUncollidableBlock(true).setIgnoreBlocksWithoutBoundingBoxes(true).trace();
Vec3d target = trace.hitVec;
if (target == null)
return;
LibParticles.SHAPE_BEAM(world, target, spell.getOriginHand(world), RandUtil.nextBoolean() ? spellRing.getPrimaryColor() : spellRing.getSecondaryColor());
}
use of com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK in project Wizardry by TeamWizardry.
the class ModuleShapeProjectile method renderVisualization.
/**
* {@inheritDoc}
*/
@NotNull
@Override
public SpellData renderVisualization(@Nonnull World world, ModuleInstanceShape instance, @Nonnull SpellData data, @Nonnull SpellRing ring, float partialTicks) {
Vec3d look = data.getData(LOOK);
Entity caster = data.getCaster(world);
Vec3d origin = data.getOrigin(world);
Vec3d target;
if (look == null)
return data;
if (caster == null)
return data;
if (origin == null)
return data;
double dist = ring.getAttributeValue(world, AttributeRegistry.RANGE, data);
double interpPosX = caster.lastTickPosX + (caster.posX - caster.lastTickPosX) * partialTicks;
double interpPosY = caster.lastTickPosY + (caster.posY - caster.lastTickPosY) * partialTicks;
double interpPosZ = caster.lastTickPosZ + (caster.posZ - caster.lastTickPosZ) * partialTicks;
RayTraceResult result = new RayTrace(world, look, new Vec3d(interpPosX, interpPosY + caster.getEyeHeight(), interpPosZ), dist).setEntityFilter(input -> input != caster).setReturnLastUncollidableBlock(true).setIgnoreBlocksWithoutBoundingBoxes(true).trace();
data.processTrace(result);
target = data.getTarget(world);
if (target == null)
return data;
RenderUtils.drawCircle(target, 0.3, true, false);
return data;
}
use of com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK in project Wizardry by TeamWizardry.
the class ModuleShapeTouch method run.
@Override
public boolean run(@NotNull World world, ModuleInstanceShape instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
Wizardry.LOGGER.warn("TOUCH: " + world.isRemote);
Vec3d look = spell.getData(LOOK);
Entity caster = spell.getCaster(world);
Vec3d origin = spell.getOrigin(world);
if (look == null)
return false;
if (caster == null)
return false;
if (origin == null)
return false;
if (!spellRing.taxCaster(world, spell, true))
return false;
IShapeOverrides overrides = spellRing.getOverrideHandler().getConsumerInterface(IShapeOverrides.class);
overrides.onRunTouch(world, spell, spellRing);
RayTraceResult result = new RayTrace(world, look, origin, caster instanceof EntityLivingBase && ((EntityLivingBase) caster).getAttributeMap().getAllAttributes().contains(EntityPlayer.REACH_DISTANCE) ? ((EntityLivingBase) caster).getEntityAttribute(EntityPlayer.REACH_DISTANCE).getAttributeValue() : 5).setEntityFilter(input -> input != caster).setReturnLastUncollidableBlock(true).setIgnoreBlocksWithoutBoundingBoxes(false).trace();
spell.processTrace(result);
return true;
}
use of com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK in project Wizardry by TeamWizardry.
the class ModuleShapeTouch method renderVisualization.
@NotNull
@Override
public SpellData renderVisualization(@Nonnull World world, ModuleInstanceShape instance, @Nonnull SpellData data, @Nonnull SpellRing ring, float partialTicks) {
Vec3d look = data.getData(LOOK);
Entity caster = data.getCaster(world);
Vec3d origin = data.getOrigin(world);
if (look == null)
return data;
if (caster == null)
return data;
if (origin == null)
return data;
double interpPosX = caster.lastTickPosX + (caster.posX - caster.lastTickPosX) * partialTicks;
double interpPosY = caster.lastTickPosY + (caster.posY - caster.lastTickPosY) * partialTicks;
double interpPosZ = caster.lastTickPosZ + (caster.posZ - caster.lastTickPosZ) * partialTicks;
RayTraceResult result = new RayTrace(world, look, new Vec3d(interpPosX, interpPosY + caster.getEyeHeight(), interpPosZ), caster instanceof EntityLivingBase ? ((EntityLivingBase) caster).getEntityAttribute(EntityPlayer.REACH_DISTANCE).getAttributeValue() : 5).setEntityFilter(input -> input != caster).setReturnLastUncollidableBlock(true).setIgnoreBlocksWithoutBoundingBoxes(false).trace();
data.processTrace(result);
BlockPos pos = data.getTargetPos();
EnumFacing facing = data.getFaceHit();
Vec3d target = data.getTarget(world);
if (pos == null)
return data;
if (facing != null && !world.isAirBlock(pos))
RenderUtils.drawFaceOutline(pos, facing);
else if (target != null) {
RenderUtils.drawCircle(target, 0.3, true, false);
}
data.processTrace(result);
return data;
}
Aggregations