Search in sources :

Example 16 with InterpFloatInOut

use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut in project Wizardry by TeamWizardry.

the class EntitySpiritBlight method onDeath.

@Override
public void onDeath(DamageSource cause) {
    ClientRunnable.run(new ClientRunnable() {

        @Override
        @SideOnly(Side.CLIENT)
        public void runIfClient() {
            ParticleBuilder glitter = new ParticleBuilder(RandUtil.nextInt(100, 150));
            glitter.setColor(Color.WHITE);
            glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
            glitter.setAlphaFunction(new InterpFloatInOut(0.1f, 0.1f));
            glitter.setAcceleration(Vec3d.ZERO);
            ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector().add(0, height, 0)), 1000, 0, (i, build) -> {
                double radius = 0.2;
                build.setDeceleration(new Vec3d(RandUtil.nextDouble(0.8, 0.95), RandUtil.nextDouble(0.8, 0.95), RandUtil.nextDouble(0.8, 0.95)));
                build.addMotion(new Vec3d(RandUtil.nextDouble(-radius, radius), RandUtil.nextDouble(-radius, radius), RandUtil.nextDouble(-radius, radius)));
                build.setLifetime(RandUtil.nextInt(200, 250));
                build.setScaleFunction(new InterpScale(RandUtil.nextFloat(0.6f, 1.5f), 0));
                if (RandUtil.nextBoolean())
                    build.setColor(Color.WHITE);
                else
                    build.setColor(new Color(0xf404d4));
            });
        }
    });
    playSound(ModSounds.BASS_BOOM, 3, 0.5f);
    playSound(ModSounds.BASS_BOOM, 1, RandUtil.nextFloat(1, 1.5f));
    super.onDeath(cause);
}
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) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d) Side(net.minecraftforge.fml.relauncher.Side) RandUtilSeed(com.teamwizardry.wizardry.api.util.RandUtilSeed) ModSounds(com.teamwizardry.wizardry.init.ModSounds) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) 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) Wizardry(com.teamwizardry.wizardry.Wizardry) DataParameter(net.minecraft.network.datasync.DataParameter) DamageSource(net.minecraft.util.DamageSource) SharedMonsterAttributes(net.minecraft.entity.SharedMonsterAttributes) java.awt(java.awt) DataSerializers(net.minecraft.network.datasync.DataSerializers) EntityMob(net.minecraft.entity.monster.EntityMob) LibParticles(com.teamwizardry.wizardry.client.fx.LibParticles) EntityPlayer(net.minecraft.entity.player.EntityPlayer) MathHelper(net.minecraft.util.math.MathHelper) ResourceLocation(net.minecraft.util.ResourceLocation) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) NBTConstants(com.teamwizardry.wizardry.api.NBTConstants) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) ResourceLocation(net.minecraft.util.ResourceLocation) 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) Vec3d(net.minecraft.util.math.Vec3d)

Example 17 with InterpFloatInOut

use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut in project Wizardry by TeamWizardry.

the class EntitySpiritWight method onDeath.

@Override
public void onDeath(DamageSource cause) {
    ClientRunnable.run(new ClientRunnable() {

        @Override
        @SideOnly(Side.CLIENT)
        public void runIfClient() {
            ParticleBuilder glitter = new ParticleBuilder(RandUtil.nextInt(100, 150));
            glitter.setColor(Color.WHITE);
            glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
            glitter.setAlphaFunction(new InterpFloatInOut(0.1f, 0.1f));
            glitter.setAcceleration(Vec3d.ZERO);
            ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector().add(0, height, 0)), 1000, 0, (i, build) -> {
                double radius = 0.2;
                build.setDeceleration(new Vec3d(RandUtil.nextDouble(0.8, 0.95), RandUtil.nextDouble(0.8, 0.95), RandUtil.nextDouble(0.8, 0.95)));
                build.addMotion(new Vec3d(RandUtil.nextDouble(-radius, radius), RandUtil.nextDouble(-radius, radius), RandUtil.nextDouble(-radius, radius)));
                build.setLifetime(RandUtil.nextInt(200, 250));
                build.setScaleFunction(new InterpScale(RandUtil.nextFloat(0.6f, 1.5f), 0));
                if (RandUtil.nextBoolean())
                    build.setColor(Color.WHITE);
                else
                    build.setColor(Color.YELLOW);
            });
        }
    });
    playSound(ModSounds.BASS_BOOM, 3, 0.5f);
    playSound(ModSounds.BASS_BOOM, 1, RandUtil.nextFloat(1, 1.5f));
    super.onDeath(cause);
}
Also used : InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) EntityAIWatchClosest(net.minecraft.entity.ai.EntityAIWatchClosest) StaticInterp(com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp) ParticleSpawner(com.teamwizardry.librarianlib.features.particle.ParticleSpawner) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d) Side(net.minecraftforge.fml.relauncher.Side) ModSounds(com.teamwizardry.wizardry.init.ModSounds) EntityAINearestAttackableTarget(net.minecraft.entity.ai.EntityAINearestAttackableTarget) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) 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) Wizardry(com.teamwizardry.wizardry.Wizardry) DamageSource(net.minecraft.util.DamageSource) SharedMonsterAttributes(net.minecraft.entity.SharedMonsterAttributes) java.awt(java.awt) EntityMob(net.minecraft.entity.monster.EntityMob) EntityLivingBase(net.minecraft.entity.EntityLivingBase) LibParticles(com.teamwizardry.wizardry.client.fx.LibParticles) EntityPlayer(net.minecraft.entity.player.EntityPlayer) MathHelper(net.minecraft.util.math.MathHelper) ResourceLocation(net.minecraft.util.ResourceLocation) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) NBTConstants(com.teamwizardry.wizardry.api.NBTConstants) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) ResourceLocation(net.minecraft.util.ResourceLocation) 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) Vec3d(net.minecraft.util.math.Vec3d)

Example 18 with InterpFloatInOut

use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut in project Wizardry by TeamWizardry.

the class ModuleEffectPhase method renderSpell.

@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    EnumFacing faceHit = spell.getFaceHit();
    Set<BlockPos> blockSet = spell.getDataWithFallback(SpellData.DefaultKeys.BLOCK_SET, new BlockSet(new HashSet<>())).getBlockSet();
    Map<BlockPos, IBlockState> blockStateCache = spell.getDataWithFallback(SpellData.DefaultKeys.BLOCKSTATE_CACHE, new BlockStateCache(new HashMap<>())).getBlockStateCache();
    HashMap<BlockPos, IBlockState> tmpCache = new HashMap<>(blockStateCache);
    double duration = spellRing.getAttributeValue(world, AttributeRegistry.DURATION, spell) * 20;
    PhasedBlockRenderer.addPhase(world, blockSet, (int) duration);
    if (faceHit != null) {
        for (Map.Entry<BlockPos, IBlockState> entry : tmpCache.entrySet()) {
            IBlockState thisState = entry.getValue();
            if (thisState.getBlock() != ModBlocks.FAKE_AIR)
                continue;
            ParticleBuilder glitter2 = new ParticleBuilder(10);
            glitter2.setRenderNormalLayer(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
            glitter2.disableRandom();
            ParticleSpawner.spawn(glitter2, world, new StaticInterp<>(new Vec3d(entry.getKey()).add(0.5, 0.5, 0.5)), 5, (int) duration, (aFloat, build) -> {
                build.setColor(Color.CYAN);
                // build.setAlphaFunction(new InterpFloatInOut(1f, 0.1f));
                build.setAlpha(RandUtil.nextFloat(0.05f, 0.2f));
                build.setPositionOffset(new Vec3d(RandUtil.nextDouble(-0.5, 0.5), RandUtil.nextDouble(-0.5, 0.5), RandUtil.nextDouble(-0.5, 0.5)));
                build.setMotion(new Vec3d(RandUtil.nextDouble(-0.001, 0.001), RandUtil.nextDouble(-0.001, 0.001), RandUtil.nextDouble(-0.001, 0.001)));
                build.setLifetime(RandUtil.nextInt(20, 40));
                build.setScaleFunction(new InterpFloatInOut(0.9f, 0.9f));
                build.setScale(RandUtil.nextFloat(0.1f, 0.3f));
            });
            BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(entry.getKey());
            for (EnumFacing facing : EnumFacing.VALUES) {
                mutable.move(facing);
                IBlockState adjState;
                if (!blockStateCache.containsKey(mutable)) {
                    adjState = world.getBlockState(mutable);
                    blockStateCache.put(mutable.toImmutable(), adjState);
                } else
                    adjState = blockStateCache.get(mutable);
                if (adjState.getBlock() != Blocks.AIR && adjState.getBlock() != ModBlocks.FAKE_AIR) {
                    Vec3d directionOffsetVec = new Vec3d(facing.getOpposite().getDirectionVec()).scale(0.5);
                    Vec3d adjPos = new Vec3d(mutable).add(0.5, 0.5, 0.5).add(directionOffsetVec);
                    for (EnumFacing subFacing : getPerpendicularFacings(facing)) {
                        mutable.move(subFacing);
                        IBlockState subState;
                        if (!blockStateCache.containsKey(mutable)) {
                            subState = world.getBlockState(mutable);
                            blockStateCache.put(mutable.toImmutable(), subState);
                        } else
                            subState = blockStateCache.get(mutable);
                        if (BlockUtils.isAnyAir(subState)) {
                            Vec3d subPos = new Vec3d(mutable).add(0.5, 0.5, 0.5).add(directionOffsetVec);
                            Vec3d midPointVec = new Vec3d((adjPos.x + subPos.x) / 2.0, (adjPos.y + subPos.y) / 2.0, (adjPos.z + subPos.z) / 2.0);
                            Vec3d sub = subPos.subtract(adjPos);
                            EnumFacing adjSubFacing = EnumFacing.getFacingFromVector((float) sub.x, (float) sub.y, (float) sub.z);
                            Vec3d cross = new Vec3d(adjSubFacing.getDirectionVec()).crossProduct(new Vec3d(facing.getDirectionVec())).normalize().scale(0.5);
                            ParticleBuilder glitter = new ParticleBuilder(10);
                            glitter.setRenderNormalLayer(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
                            glitter.disableRandom();
                            ParticleSpawner.spawn(glitter, world, new StaticInterp<>(midPointVec), 50, (int) duration, (aFloat, build) -> {
                                build.setColor(Color.CYAN);
                                // build.setAlphaFunction(new InterpFloatInOut(1f, 0.1f));
                                build.setAlpha(RandUtil.nextFloat(0.3f, 0.7f));
                                build.setPositionOffset(cross.scale(RandUtil.nextFloat(-1, 1)));
                                build.setLifetime(RandUtil.nextInt(20, 40));
                                build.setScaleFunction(new InterpFloatInOut(0.9f, 0.9f));
                                build.setScale(RandUtil.nextFloat(0.2f, 0.5f));
                            });
                        }
                        mutable.move(subFacing.getOpposite());
                    }
                }
                mutable.move(facing.getOpposite());
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) HashMap(java.util.HashMap) EnumFacing(net.minecraft.util.EnumFacing) BlockSet(com.teamwizardry.wizardry.api.spell.SpellDataTypes.BlockSet) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) BlockStateCache(com.teamwizardry.wizardry.api.spell.SpellDataTypes.BlockStateCache) ResourceLocation(net.minecraft.util.ResourceLocation) BlockPos(net.minecraft.util.math.BlockPos) Map(java.util.Map) HashMap(java.util.HashMap) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 19 with InterpFloatInOut

use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut in project Wizardry by TeamWizardry.

the class ModuleShapeTouch 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.onRenderTouch(world, spell, spellRing))
        return;
    Entity targetEntity = spell.getVictim(world);
    if (targetEntity == null)
        return;
    ParticleBuilder glitter = new ParticleBuilder(1);
    glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
    ParticleSpawner.spawn(glitter, world, new InterpCircle(targetEntity.getPositionVector().add(0, targetEntity.height / 2.0, 0), new Vec3d(0, 1, 0), 1, 10), 50, RandUtil.nextInt(10, 15), (aFloat, particleBuilder) -> {
        if (RandUtil.nextBoolean()) {
            glitter.setColor(spellRing.getPrimaryColor());
            glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(0.01, 0.1), 0));
        } else {
            glitter.setColor(spellRing.getSecondaryColor());
            glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(-0.1, -0.01), 0));
        }
        glitter.setLifetime(RandUtil.nextInt(20, 30));
        glitter.setScale((float) RandUtil.nextDouble(0.3, 1));
        glitter.setAlphaFunction(new InterpFloatInOut(0.3f, (float) RandUtil.nextDouble(0.6, 1)));
        glitter.setLifetime(RandUtil.nextInt(10, 20));
        glitter.setScaleFunction(new InterpScale(1, 0));
    });
}
Also used : Entity(net.minecraft.entity.Entity) InterpCircle(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) ResourceLocation(net.minecraft.util.ResourceLocation) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)

Example 20 with InterpFloatInOut

use of com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut in project Wizardry by TeamWizardry.

the class ModuleEffectGrace method renderSpell.

@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    Entity target = spell.getVictim(world);
    if (!(target instanceof EntityLivingBase))
        return;
    if (!((EntityLivingBase) target).isPotionActive(ModPotions.GRACE))
        return;
    ParticleBuilder glitter = new ParticleBuilder(30);
    glitter.setColorFunction(new InterpColorHSV(instance.getPrimaryColor(), instance.getSecondaryColor()));
    glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
    glitter.disableRandom();
    ParticleSpawner.spawn(glitter, world, new InterpCircle(target.getPositionVector().add(0, target.height / 2.0, 0), new Vec3d(Math.cos(world.getTotalWorldTime() / 10.0), 1, Math.cos(world.getTotalWorldTime() / 10.0)), 2), 15, 0, (aFloat, particleBuilder) -> {
        particleBuilder.setLifetime(RandUtil.nextInt(20, 25));
        particleBuilder.setScaleFunction(new InterpScale(RandUtil.nextFloat(1f, 1.5f), 0f));
        particleBuilder.setAlphaFunction(new InterpFloatInOut(aFloat, aFloat));
    });
}
Also used : Entity(net.minecraft.entity.Entity) InterpCircle(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle) InterpColorHSV(com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) ResourceLocation(net.minecraft.util.ResourceLocation) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

InterpFloatInOut (com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut)65 ParticleBuilder (com.teamwizardry.librarianlib.features.particle.ParticleBuilder)65 ResourceLocation (net.minecraft.util.ResourceLocation)65 Vec3d (net.minecraft.util.math.Vec3d)62 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)32 InterpScale (com.teamwizardry.wizardry.api.util.interp.InterpScale)30 InterpColorHSV (com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV)21 Entity (net.minecraft.entity.Entity)15 ClientRunnable (com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable)13 StaticInterp (com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp)11 ParticleSpawner (com.teamwizardry.librarianlib.features.particle.ParticleSpawner)11 Wizardry (com.teamwizardry.wizardry.Wizardry)11 NBTConstants (com.teamwizardry.wizardry.api.NBTConstants)11 RandUtil (com.teamwizardry.wizardry.api.util.RandUtil)11 Side (net.minecraftforge.fml.relauncher.Side)11 java.awt (java.awt)10 World (net.minecraft.world.World)10 MathHelper (net.minecraft.util.math.MathHelper)9 EntityLivingBase (net.minecraft.entity.EntityLivingBase)8 EntityPlayer (net.minecraft.entity.player.EntityPlayer)8