Search in sources :

Example 1 with LOOK

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);
    }
}
Also used : EntityDataManager(net.minecraft.network.datasync.EntityDataManager) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) StaticInterp(com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp) ParticleSpawner(com.teamwizardry.librarianlib.features.particle.ParticleSpawner) PosUtils(com.teamwizardry.wizardry.api.util.PosUtils) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) Vec3d(net.minecraft.util.math.Vec3d) Side(net.minecraftforge.fml.relauncher.Side) RandUtilSeed(com.teamwizardry.wizardry.api.util.RandUtilSeed) SpellData(com.teamwizardry.wizardry.api.spell.SpellData) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nonnull(javax.annotation.Nonnull) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Entity(net.minecraft.entity.Entity) ClientRunnable(com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable) World(net.minecraft.world.World) LOOK(com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK) Wizardry(com.teamwizardry.wizardry.Wizardry) ModuleEffectLightning(com.teamwizardry.wizardry.common.module.effects.lightning.ModuleEffectLightning) DataParameter(net.minecraft.network.datasync.DataParameter) InterpColorHSV(com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV) AttributeRange(com.teamwizardry.wizardry.api.spell.attribute.AttributeRange) AttributeRegistry(com.teamwizardry.wizardry.api.spell.attribute.AttributeRegistry) DataSerializers(net.minecraft.network.datasync.DataSerializers) ResourceLocation(net.minecraft.util.ResourceLocation) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) NBTConstants(com.teamwizardry.wizardry.api.NBTConstants) StaticInterp(com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) ClientRunnable(com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) RandUtilSeed(com.teamwizardry.wizardry.api.util.RandUtilSeed) Vec3d(net.minecraft.util.math.Vec3d) SpellData(com.teamwizardry.wizardry.api.spell.SpellData) InterpColorHSV(com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 2 with LOOK

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());
}
Also used : RenderUtils(com.teamwizardry.wizardry.api.util.RenderUtils) HashMap(java.util.HashMap) ModuleOverrideSuper(com.teamwizardry.wizardry.api.spell.module.ModuleOverrideSuper) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) ItemStack(net.minecraft.item.ItemStack) RayTraceResult(net.minecraft.util.math.RayTraceResult) Vec3d(net.minecraft.util.math.Vec3d) Side(net.minecraftforge.fml.relauncher.Side) Mod(net.minecraftforge.fml.common.Mod) SpellData(com.teamwizardry.wizardry.api.spell.SpellData) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nonnull(javax.annotation.Nonnull) ConfigValues(com.teamwizardry.wizardry.api.ConfigValues) Entity(net.minecraft.entity.Entity) World(net.minecraft.world.World) ContextSuper(com.teamwizardry.wizardry.api.spell.annotation.ContextSuper) LOOK(com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK) Wizardry(com.teamwizardry.wizardry.Wizardry) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) ModuleInstanceShape(com.teamwizardry.wizardry.api.spell.module.ModuleInstanceShape) IContinuousModule(com.teamwizardry.wizardry.api.spell.IContinuousModule) AttributeRegistry(com.teamwizardry.wizardry.api.spell.attribute.AttributeRegistry) EntityLivingBase(net.minecraft.entity.EntityLivingBase) LibParticles(com.teamwizardry.wizardry.client.fx.LibParticles) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) RegisterModule(com.teamwizardry.wizardry.api.spell.annotation.RegisterModule) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) TickEvent(net.minecraftforge.fml.common.gameevent.TickEvent) NotNull(org.jetbrains.annotations.NotNull) IModuleShape(com.teamwizardry.wizardry.api.spell.module.IModuleShape) Entity(net.minecraft.entity.Entity) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) EntityLivingBase(net.minecraft.entity.EntityLivingBase) RayTraceResult(net.minecraft.util.math.RayTraceResult) ItemStack(net.minecraft.item.ItemStack) Vec3d(net.minecraft.util.math.Vec3d) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)

Example 3 with LOOK

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;
}
Also used : Entity(net.minecraft.entity.Entity) RenderUtils(com.teamwizardry.wizardry.api.util.RenderUtils) World(net.minecraft.world.World) LOOK(com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) BlockPos(net.minecraft.util.math.BlockPos) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) ModuleInstanceShape(com.teamwizardry.wizardry.api.spell.module.ModuleInstanceShape) RayTraceResult(net.minecraft.util.math.RayTraceResult) EntitySpellProjectile(com.teamwizardry.wizardry.common.entity.projectile.EntitySpellProjectile) AttributeRegistry(com.teamwizardry.wizardry.api.spell.attribute.AttributeRegistry) Vec3d(net.minecraft.util.math.Vec3d) Side(net.minecraftforge.fml.relauncher.Side) RegisterModule(com.teamwizardry.wizardry.api.spell.annotation.RegisterModule) ModSounds(com.teamwizardry.wizardry.init.ModSounds) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) SpellData(com.teamwizardry.wizardry.api.spell.SpellData) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) NotNull(org.jetbrains.annotations.NotNull) SoundCategory(net.minecraft.util.SoundCategory) Nonnull(javax.annotation.Nonnull) IModuleShape(com.teamwizardry.wizardry.api.spell.module.IModuleShape) Entity(net.minecraft.entity.Entity) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) RayTraceResult(net.minecraft.util.math.RayTraceResult) Vec3d(net.minecraft.util.math.Vec3d) NotNull(org.jetbrains.annotations.NotNull) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)

Example 4 with LOOK

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;
}
Also used : InterpCircle(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle) RenderUtils(com.teamwizardry.wizardry.api.util.RenderUtils) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) ParticleSpawner(com.teamwizardry.librarianlib.features.particle.ParticleSpawner) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) RayTraceResult(net.minecraft.util.math.RayTraceResult) Vec3d(net.minecraft.util.math.Vec3d) Side(net.minecraftforge.fml.relauncher.Side) SpellData(com.teamwizardry.wizardry.api.spell.SpellData) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nonnull(javax.annotation.Nonnull) Entity(net.minecraft.entity.Entity) World(net.minecraft.world.World) LOOK(com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK) Wizardry(com.teamwizardry.wizardry.Wizardry) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) ModuleInstanceShape(com.teamwizardry.wizardry.api.spell.module.ModuleInstanceShape) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ResourceLocation(net.minecraft.util.ResourceLocation) RegisterModule(com.teamwizardry.wizardry.api.spell.annotation.RegisterModule) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) NBTConstants(com.teamwizardry.wizardry.api.NBTConstants) NotNull(org.jetbrains.annotations.NotNull) IModuleShape(com.teamwizardry.wizardry.api.spell.module.IModuleShape) Entity(net.minecraft.entity.Entity) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) RayTraceResult(net.minecraft.util.math.RayTraceResult) EntityLivingBase(net.minecraft.entity.EntityLivingBase) Vec3d(net.minecraft.util.math.Vec3d) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)

Example 5 with LOOK

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;
}
Also used : InterpCircle(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle) RenderUtils(com.teamwizardry.wizardry.api.util.RenderUtils) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) ParticleSpawner(com.teamwizardry.librarianlib.features.particle.ParticleSpawner) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) RayTraceResult(net.minecraft.util.math.RayTraceResult) Vec3d(net.minecraft.util.math.Vec3d) Side(net.minecraftforge.fml.relauncher.Side) SpellData(com.teamwizardry.wizardry.api.spell.SpellData) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nonnull(javax.annotation.Nonnull) Entity(net.minecraft.entity.Entity) World(net.minecraft.world.World) LOOK(com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK) Wizardry(com.teamwizardry.wizardry.Wizardry) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) ModuleInstanceShape(com.teamwizardry.wizardry.api.spell.module.ModuleInstanceShape) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ResourceLocation(net.minecraft.util.ResourceLocation) RegisterModule(com.teamwizardry.wizardry.api.spell.annotation.RegisterModule) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) NBTConstants(com.teamwizardry.wizardry.api.NBTConstants) NotNull(org.jetbrains.annotations.NotNull) IModuleShape(com.teamwizardry.wizardry.api.spell.module.IModuleShape) Entity(net.minecraft.entity.Entity) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) EnumFacing(net.minecraft.util.EnumFacing) RayTraceResult(net.minecraft.util.math.RayTraceResult) EntityLivingBase(net.minecraft.entity.EntityLivingBase) BlockPos(net.minecraft.util.math.BlockPos) Vec3d(net.minecraft.util.math.Vec3d) NotNull(org.jetbrains.annotations.NotNull) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)

Aggregations

SpellData (com.teamwizardry.wizardry.api.spell.SpellData)10 LOOK (com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK)10 SpellRing (com.teamwizardry.wizardry.api.spell.SpellRing)10 RandUtil (com.teamwizardry.wizardry.api.util.RandUtil)10 Nonnull (javax.annotation.Nonnull)10 Entity (net.minecraft.entity.Entity)10 Vec3d (net.minecraft.util.math.Vec3d)10 World (net.minecraft.world.World)10 Side (net.minecraftforge.fml.relauncher.Side)10 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)10 RayTrace (com.teamwizardry.wizardry.api.util.RayTrace)9 RayTraceResult (net.minecraft.util.math.RayTraceResult)9 Wizardry (com.teamwizardry.wizardry.Wizardry)8 RegisterModule (com.teamwizardry.wizardry.api.spell.annotation.RegisterModule)8 NotNull (org.jetbrains.annotations.NotNull)8 ModuleOverride (com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)7 AttributeRegistry (com.teamwizardry.wizardry.api.spell.attribute.AttributeRegistry)7 EntityLivingBase (net.minecraft.entity.EntityLivingBase)7 IModuleShape (com.teamwizardry.wizardry.api.spell.module.IModuleShape)6 ModuleInstanceShape (com.teamwizardry.wizardry.api.spell.module.ModuleInstanceShape)6