use of com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK in project Wizardry by TeamWizardry.
the class EntitySpellProjectile method onUpdate.
@Override
public void onUpdate() {
super.onUpdate();
if (isDead)
return;
SpellRing spellRing = getSpellRing();
SpellData spellData = getSpellData();
if (spellRing == null || spellData == null) {
setDead();
world.removeEntity(this);
return;
}
if (world.isRemote && doesRender()) {
ClientRunnable.run(new ClientRunnable() {
@Override
@SideOnly(Side.CLIENT)
public void runIfClient() {
IShapeOverrides overrides = spellRing.getOverrideHandler().getConsumerInterface(IShapeOverrides.class);
if (overrides.onRenderProjectile(world, spellData, spellRing))
return;
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()));
glitter.setAcceleration(new Vec3d(0, -0.015, 0));
ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector().add(new Vec3d(motionX, motionY, motionZ))), 5, 0, (aFloat, particleBuilder) -> {
particleBuilder.setScaleFunction(new InterpScale((float) RandUtil.nextDouble(0.3, 0.8), 0));
particleBuilder.setLifetime(RandUtil.nextInt(40, 60));
particleBuilder.addMotion(new Vec3d(RandUtil.nextDouble(-0.03, 0.03), RandUtil.nextDouble(-0.01, 0.05), RandUtil.nextDouble(-0.03, 0.03)));
});
glitter.disableMotionCalculation();
glitter.setMotion(Vec3d.ZERO);
ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector()), 5, 0, (aFloat, particleBuilder) -> {
particleBuilder.setScaleFunction(new InterpScale(RandUtil.nextFloat(1f, 2), 0));
particleBuilder.setLifetime(RandUtil.nextInt(5, 10));
});
}
});
return;
}
Vec3d origin = spellData.getOrigin(world);
rotationPitch = spellData.getPitch();
rotationYaw = spellData.getYaw();
Vec3d look = spellData.getData(LOOK);
if (look == null) {
setDead();
world.removeEntity(this);
return;
}
if (origin == null || getDistance() < getDistance(origin.x, origin.y, origin.z)) {
spellData.processBlock(getPosition(), EnumFacing.getFacingFromVector((float) look.x, (float) look.y, (float) look.z), getPositionVector());
goBoom(spellRing, spellData);
return;
}
if (collided) {
RayTraceResult result = new RayTrace(world, look, getPositionVector(), 5).setEntityFilter(input -> input != this && !input.isEntityEqual(spellData.getCaster(world))).trace();
spellData.processTrace(result, getPositionVector());
goBoom(spellRing, spellData);
return;
}
float speed = getSpeed();
// MOVE //
motionX += ((look.x * speed) - motionX);
motionY += ((look.y * speed) - motionY);
motionZ += ((look.z * speed) - motionZ);
// GRAVITY
// if (getDistanceSq(origin.x, origin.y, origin.z) > 4)
// motionY -= gravity;
move(MoverType.SELF, motionX, motionY, motionZ);
List<Entity> entities = world.getEntitiesWithinAABBExcludingEntity(this, getEntityBoundingBox());
if (!entities.isEmpty()) {
Entity caster = spellData.getCaster(world);
// Don't collide with other spell projectiles
for (Entity entity : entities) {
if (entity == caster)
return;
if (entity instanceof EntitySpellProjectile)
return;
spellData.processEntity(entity, false);
}
RayTraceResult result = new RayTrace(world, look, getPositionVector(), 1).setEntityFilter(input -> input != this && !input.isEntityEqual(spellData.getCaster(world))).trace();
spellData.processTrace(result, getPositionVector());
goBoom(spellRing, spellData);
}
}
use of com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK in project Wizardry by TeamWizardry.
the class ModuleEffectZoom method run.
@Override
public boolean run(@NotNull World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
Entity entityHit = spell.getVictim(world);
Vec3d look = spell.getData(LOOK);
Vec3d origin = spell.getData(ORIGIN);
if (entityHit == null)
return true;
else {
if (!spellRing.taxCaster(world, spell, true))
return false;
if (look == null)
return true;
if (origin == null)
return true;
double range = spellRing.getAttributeValue(world, AttributeRegistry.RANGE, spell);
RayTraceResult trace = new RayTrace(world, look, origin, range).setEntityFilter(input -> input != entityHit).setIgnoreBlocksWithoutBoundingBoxes(true).setReturnLastUncollidableBlock(false).trace();
spell.addData(ORIGINAL_LOC, entityHit.getPositionVector());
entityHit.setPositionAndUpdate(trace.hitVec.x, trace.hitVec.y, trace.hitVec.z);
entityHit.motionX = 0;
entityHit.motionY = 0;
entityHit.motionZ = 0;
entityHit.velocityChanged = true;
}
if (entityHit instanceof EntityLivingBase) {
((EntityLivingBase) entityHit).addPotionEffect(new PotionEffect(ModPotions.NULLIFY_GRAVITY, 2, 1, true, false));
((EntityLivingBase) entityHit).addPotionEffect(new PotionEffect(ModPotions.NULL_MOVEMENT, 2, 1, true, false));
}
return true;
}
use of com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK in project Wizardry by TeamWizardry.
the class ModuleEffectLightning method onRunTouch.
@ModuleOverride("shape_touch_run")
public void onRunTouch(@ContextSuper ModuleOverrideSuper ovdSuper, World world, SpellData data, SpellRing shape, @ContextRing SpellRing childRing) {
if (ovdSuper.hasSuper())
ovdSuper.invoke(true, world, data, shape);
Vec3d look = data.getData(LOOK);
Entity caster = data.getCaster(world);
Vec3d origin = data.getOriginWithFallback(world);
if (look == null || caster == null || origin == null)
return;
if (!childRing.taxCaster(world, data, true))
return;
double range = childRing.getAttributeValue(world, AttributeRegistry.RANGE, data);
double potency = childRing.getAttributeValue(world, AttributeRegistry.POTENCY, data);
double duration = childRing.getAttributeValue(world, AttributeRegistry.DURATION, data);
RayTraceResult trace = new RayTrace(world, look, origin, caster instanceof EntityLivingBase ? ((EntityLivingBase) caster).getEntityAttribute(EntityPlayer.REACH_DISTANCE).getAttributeValue() : 5).setEntityFilter(input -> input != caster).setReturnLastUncollidableBlock(true).setIgnoreBlocksWithoutBoundingBoxes(true).trace();
doLightning(RandUtil.nextLong(100, 100000), world, caster, origin, trace.hitVec, range, potency, duration);
}
use of com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK in project Wizardry by TeamWizardry.
the class ModuleShapeBeam 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);
Vec3d position = data.getOrigin(world);
Entity caster = data.getCaster(world);
if (look == null || position == null || caster == null)
return data;
double range = 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), range).setEntityFilter(input -> input != caster).setReturnLastUncollidableBlock(true).setIgnoreBlocksWithoutBoundingBoxes(true).trace();
data.processTrace(result, look.scale(range));
Vec3d 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 ModuleShapeBeam method run.
/**
* {@inheritDoc}
*/
@Override
public boolean run(@NotNull World world, ModuleInstanceShape instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
Vec3d look = spell.getData(LOOK);
Vec3d position = spell.getOrigin(world);
Entity caster = spell.getCaster(world);
if (look == null || position == null || caster == null)
return false;
ItemStack stack = ((EntityLivingBase) caster).getHeldItemMainhand();
if (stack.isEmpty())
return true;
beamTickMap.putIfAbsent(stack, new BeamTicker());
BeamTicker ticker = beamTickMap.get(stack);
double range = spellRing.getAttributeValue(world, AttributeRegistry.RANGE, spell);
double potency = spellRing.getAttributeValue(world, AttributeRegistry.POTENCY, spell);
double beamOffset = ticker.ticks + potency;
ticker.cast = false;
if (beamOffset >= ConfigValues.beamTimer) {
beamOffset %= ConfigValues.beamTimer;
if (!spellRing.taxCaster(world, spell, true)) {
ticker.ticks = beamOffset;
return false;
}
IShapeOverrides overrides = spellRing.getOverrideHandler().getConsumerInterface(IShapeOverrides.class);
overrides.onRunBeam(world, spell, spellRing);
RayTraceResult trace = new RayTrace(world, look, position, range).setEntityFilter(input -> input != caster).setReturnLastUncollidableBlock(true).setIgnoreBlocksWithoutBoundingBoxes(true).trace();
spell.processTrace(trace, look.scale(range));
if (spellRing.getChildRing() != null)
spellRing.getChildRing().runSpellRing(world, spell, true);
ticker.cast = true;
// Is already executed via SpellRing.runSpellRing() ???
instance.sendRenderPacket(world, spell, spellRing);
}
ticker.ticks = beamOffset;
return true;
}
Aggregations