Search in sources :

Example 1 with InterpFloatInOut

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

the class FairyData method render.

@SideOnly(Side.CLIENT)
public void render(World world, Vec3d pos, Vec3d prevPos, float partialTicks) {
    if (!wasTamperedWith && !isDepressed) {
        LibParticles.FAIRY_HEAD(world, pos.add(0, 0.25, 0), primaryColor);
        ParticleBuilder glitter = new ParticleBuilder(age / 2);
        glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
        glitter.setAlphaFunction(new InterpFloatInOut(0.2f, 1f));
        if (RandUtil.nextInt(3) == 0)
            ParticleSpawner.spawn(glitter, world, new StaticInterp<>(pos), 1, 0, (i, build) -> {
                build.setMotion(new Vec3d(RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(-0.01, 0.01)));
                if (RandUtil.nextBoolean())
                    build.setColor(primaryColor);
                else
                    build.setColor(secondaryColor);
                if (isDepressed) {
                    build.setCollision(true);
                    build.enableMotionCalculation();
                    build.setAcceleration(new Vec3d(0, -0.005, 0));
                }
            });
    } else {
        {
            GlStateManager.pushMatrix();
            EntityPlayer player = Minecraft.getMinecraft().player;
            if (player == null)
                return;
            double interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
            double interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
            double interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
            GlStateManager.translate(-interpPosX, -interpPosY, -interpPosZ);
            GlStateManager.translate(pos.x, pos.y, pos.z);
            Minecraft.getMinecraft().entityRenderer.disableLightmap();
            GlStateManager.enableDepth();
            GlStateManager.disableCull();
            GlStateManager.enableAlpha();
            GlStateManager.enableBlend();
            GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE);
            GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
            GlStateManager.color(1, 1, 1, 1);
            GlStateManager.disableTexture2D();
            GlStateManager.enableColorMaterial();
            GlStateManager.disableLighting();
            GlStateManager.shadeModel(GL11.GL_SMOOTH);
            int alphaFunc = GL11.glGetInteger(GL11.GL_ALPHA_TEST_FUNC);
            float alphaTest = GL11.glGetFloat(GL11.GL_ALPHA_TEST_REF);
            GlStateManager.alphaFunc(GL11.GL_ALWAYS, 1);
            GlStateManager.pushMatrix();
            GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
            GlStateManager.rotate((float) (Minecraft.getMinecraft().getRenderManager().options.thirdPersonView == 2 ? -1 : 1) * Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
            Tessellator tessellator = Tessellator.getInstance();
            BufferBuilder bb = tessellator.getBuffer();
            double radius = 0.1;
            Color color = primaryColor;
            bb.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
            for (int i = 0; i <= 50; i++) {
                double x = radius * MathHelper.cos((float) ((i / 50.0) * Math.PI * 2));
                double z = radius * MathHelper.sin((float) ((i / 50.0) * Math.PI * 2));
                bb.pos(x, z, 0).color(color.getRed(), color.getGreen(), color.getBlue(), 255).endVertex();
            }
            tessellator.draw();
            GlStateManager.popMatrix();
            bb.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_COLOR);
            Vec3d sub = pos.subtract(prevPos).scale(-1).add(0, 0.2, 0).scale(3);
            Vec3d posCross = sub.crossProduct(new Vec3d(0, 1, 0)).normalize();
            Vec3d posPerp = posCross.crossProduct(sub).normalize().scale(radius - 0.2);
            Vec3d vec1 = posPerp;
            Vec3d vec2 = posPerp.scale(-1);
            bb.pos(sub.x, sub.y, sub.z).color(color.getRed(), color.getGreen(), color.getBlue(), 255).endVertex();
            bb.pos(vec1.x, vec1.y, vec1.z).color(color.getRed(), color.getGreen(), color.getBlue(), 255).endVertex();
            bb.pos(vec2.x, vec2.y, vec2.z).color(color.getRed(), color.getGreen(), color.getBlue(), 255).endVertex();
            Vec3d vec3 = posCross.scale(radius);
            Vec3d vec4 = posCross.scale(-1).scale(radius);
            bb.pos(sub.x, sub.y, sub.z).color(color.getRed(), color.getGreen(), color.getBlue(), 255).endVertex();
            bb.pos(vec3.x, vec3.y, vec3.z).color(color.getRed(), color.getGreen(), color.getBlue(), 255).endVertex();
            bb.pos(vec4.x, vec4.y, vec4.z).color(color.getRed(), color.getGreen(), color.getBlue(), 255).endVertex();
            tessellator.draw();
            GlStateManager.pushMatrix();
            GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
            GlStateManager.rotate((float) (Minecraft.getMinecraft().getRenderManager().options.thirdPersonView == 2 ? -1 : 1) * Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
            int sections = 50;
            float epsilon = 2 * (float) Math.PI / sections;
            double innerRadius = radius;
            double outerRadius = radius + 0.01;
            Color inner = primaryColor;
            Color outer = new Color(primaryColor.getRed(), primaryColor.getGreen(), primaryColor.getBlue(), 0);
            bb.begin(GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION_COLOR);
            for (int i = 0; i <= sections; i++) {
                float angle = i * epsilon;
                float nextAngle = (i + 1) * epsilon;
                float x1 = (float) (MathHelper.cos(angle) * innerRadius);
                float y1 = (float) (MathHelper.sin(angle) * innerRadius);
                float x2 = (float) (MathHelper.cos(nextAngle) * outerRadius);
                float y2 = (float) (MathHelper.sin(nextAngle) * outerRadius);
                bb.pos(x1, y1, 0).color(inner.getRed(), inner.getGreen(), inner.getBlue(), inner.getAlpha()).endVertex();
                bb.pos(x2, y2, 0).color(outer.getRed(), outer.getGreen(), outer.getBlue(), outer.getAlpha()).endVertex();
            }
            tessellator.draw();
            radius = 0.2;
            color = secondaryColor;
            GlStateManager.translate(0, 0, 0.01);
            bb.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
            bb.pos(0, 0, 0).color(color.getRed(), color.getGreen(), color.getBlue(), 100).endVertex();
            for (int i = 0; i <= 50; i++) {
                double x = radius * MathHelper.cos((float) ((i / 50.0) * Math.PI * 2));
                double z = radius * MathHelper.sin((float) ((i / 50.0) * Math.PI * 2));
                bb.pos(x, z, 0).color(color.getRed(), color.getGreen(), color.getBlue(), 0).endVertex();
            }
            tessellator.draw();
            GlStateManager.translate(0, 0, -0.01);
            GlStateManager.alphaFunc(alphaFunc, alphaTest);
            GlStateManager.disableBlend();
            GlStateManager.enableAlpha();
            GlStateManager.enableTexture2D();
            GlStateManager.disableColorMaterial();
            Minecraft.getMinecraft().entityRenderer.enableLightmap();
            GlStateManager.enableDepth();
            GlStateManager.popMatrix();
            GlStateManager.popMatrix();
        }
    }
}
Also used : StaticInterp(com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp) CustomManaCapability(com.teamwizardry.wizardry.api.capability.player.mana.CustomManaCapability) ICapabilityProvider(net.minecraftforge.common.capabilities.ICapabilityProvider) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) Constants(net.minecraftforge.common.util.Constants) GL_ONE(org.lwjgl.opengl.GL11.GL_ONE) ParticleSpawner(com.teamwizardry.librarianlib.features.particle.ParticleSpawner) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) ArrayList(java.util.ArrayList) DefaultVertexFormats(net.minecraft.client.renderer.vertex.DefaultVertexFormats) NBTTagList(net.minecraft.nbt.NBTTagList) Vec3d(net.minecraft.util.math.Vec3d) Minecraft(net.minecraft.client.Minecraft) Side(net.minecraftforge.fml.relauncher.Side) ManaCapabilityProvider(com.teamwizardry.wizardry.api.capability.player.mana.ManaCapabilityProvider) GL11(org.lwjgl.opengl.GL11) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) GL_SRC_ALPHA(org.lwjgl.opengl.GL11.GL_SRC_ALPHA) World(net.minecraft.world.World) GlStateManager(net.minecraft.client.renderer.GlStateManager) NBTBase(net.minecraft.nbt.NBTBase) Wizardry(com.teamwizardry.wizardry.Wizardry) EnumFacing(net.minecraft.util.EnumFacing) ColorUtils(com.teamwizardry.wizardry.api.util.ColorUtils) UUID(java.util.UUID) Capability(net.minecraftforge.common.capabilities.Capability) java.awt(java.awt) IManaCapability(com.teamwizardry.wizardry.api.capability.player.mana.IManaCapability) List(java.util.List) Tessellator(net.minecraft.client.renderer.Tessellator) LibParticles(com.teamwizardry.wizardry.client.fx.LibParticles) EntityPlayer(net.minecraft.entity.player.EntityPlayer) MathHelper(net.minecraft.util.math.MathHelper) NBTHelper(com.teamwizardry.librarianlib.features.helpers.NBTHelper) ResourceLocation(net.minecraft.util.ResourceLocation) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) NBTConstants(com.teamwizardry.wizardry.api.NBTConstants) NotNull(org.jetbrains.annotations.NotNull) INBTSerializable(net.minecraftforge.common.util.INBTSerializable) Tessellator(net.minecraft.client.renderer.Tessellator) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) ResourceLocation(net.minecraft.util.ResourceLocation) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) StaticInterp(com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with InterpFloatInOut

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

the class Arena method tick.

public void tick(long timeMillis) {
    if (timeMillis % 500 == 0)
        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.setAlphaFunction(new InterpFloatInOut(0.3f, 0.3f));
                glitter.setCollision(true);
                glitter.enableMotionCalculation();
                ParticleSpawner.spawn(glitter, getWorld(), new InterpCircle(new Vec3d(getCenter()).add(0.5, getHeight(), 0.5), new Vec3d(0, 1, 0), (float) getRadius(), 1, RandUtil.nextFloat()), 10, RandUtil.nextInt(10), (aFloat, particleBuilder) -> {
                    particleBuilder.setColor(ColorUtils.changeColorAlpha(new Color(0x0097FF), RandUtil.nextInt(100, 255)));
                    particleBuilder.setScale(RandUtil.nextFloat(0.5f, 1));
                    particleBuilder.addMotion(new Vec3d(RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(-0.01, 0.01)));
                    particleBuilder.setLifetime(RandUtil.nextInt(30, 60));
                });
                glitter.disableMotionCalculation();
                ParticleSpawner.spawn(glitter, getWorld(), new InterpCircle(new Vec3d(getCenter()).add(0.5, 0, 0.5), new Vec3d(0, 1, 0), (float) getRadius(), 1, RandUtil.nextFloat()), 10, RandUtil.nextInt(10), (aFloat, particleBuilder) -> {
                    particleBuilder.setColor(ColorUtils.changeColorAlpha(new Color(0x0097FF), RandUtil.nextInt(100, 255)));
                    particleBuilder.setScale(RandUtil.nextFloat(0.5f, 1));
                    particleBuilder.addMotion(new Vec3d(RandUtil.nextDouble(-0.01, 0.01), RandUtil.nextDouble(0.01, 0.02), RandUtil.nextDouble(-0.01, 0.01)));
                    particleBuilder.setLifetime(RandUtil.nextInt(30, 60));
                });
            }
        });
}
Also used : InterpCircle(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) ResourceLocation(net.minecraft.util.ResourceLocation) ClientRunnable(com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d)

Example 3 with InterpFloatInOut

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

the class FairyBindingRenderer method clientTick.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void clientTick(TickEvent.ClientTickEvent event) {
    if (Minecraft.getMinecraft().world == null)
        return;
    if (Minecraft.getMinecraft().player == null)
        return;
    if (event.side == Side.SERVER)
        return;
    if (event.phase != TickEvent.Phase.END)
        return;
    EntityPlayer player = Minecraft.getMinecraft().player;
    World world = Minecraft.getMinecraft().world;
    ItemStack stack = player.getHeldItemMainhand();
    if (stack.getItem() != ModItems.FAIRY_BELL)
        return;
    for (EntityFairy entityFairy : world.getEntities(EntityFairy.class, input -> {
        if (input == null)
            return false;
        FairyData dataFairy = input.getDataFairy();
        if (dataFairy == null)
            return false;
        return dataFairy.isDepressed;
    })) {
        Vec3d look = entityFairy.getLookTarget();
        if (look == null)
            continue;
        ParticleBuilder glitter = new ParticleBuilder(10);
        glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
        glitter.setAlphaFunction(new InterpFloatInOut(0.3f, 1f));
        glitter.setColor(Color.ORANGE);
        glitter.setCollision(true);
        glitter.disableRandom();
        glitter.disableMotionCalculation();
        if (ClientTickHandler.getTicks() % 10 == 0)
            ParticleSpawner.spawn(glitter, world, new StaticInterp<>(entityFairy.getPositionVector().add(0, entityFairy.height, 0)), 1, 0, (aFloat, particleBuilder) -> {
                particleBuilder.setScaleFunction(new InterpFloatInOut(0, 1f));
                particleBuilder.setAlphaFunction(new InterpFloatInOut(0.3f, 1f));
                particleBuilder.setScale(RandUtil.nextFloat(0.2f, 0.5f));
                particleBuilder.setLifetime(RandUtil.nextInt(10, 20));
                particleBuilder.setPositionFunction(new InterpLine(Vec3d.ZERO, look));
            });
    }
}
Also used : RenderUtils(com.teamwizardry.wizardry.api.util.RenderUtils) PathNavigate(net.minecraft.pathfinding.PathNavigate) Path(net.minecraft.pathfinding.Path) StaticInterp(com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) GL_ONE(org.lwjgl.opengl.GL11.GL_ONE) MiscCapabilityProvider(com.teamwizardry.wizardry.api.capability.player.miscdata.MiscCapabilityProvider) ParticleSpawner(com.teamwizardry.librarianlib.features.particle.ParticleSpawner) RenderWorldLastEvent(net.minecraftforge.client.event.RenderWorldLastEvent) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) DefaultVertexFormats(net.minecraft.client.renderer.vertex.DefaultVertexFormats) ItemStack(net.minecraft.item.ItemStack) RayTraceResult(net.minecraft.util.math.RayTraceResult) InterpLine(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpLine) EntityFairy(com.teamwizardry.wizardry.common.entity.EntityFairy) Vec3d(net.minecraft.util.math.Vec3d) Minecraft(net.minecraft.client.Minecraft) Side(net.minecraftforge.fml.relauncher.Side) Mod(net.minecraftforge.fml.common.Mod) GL11(org.lwjgl.opengl.GL11) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) FairyData(com.teamwizardry.wizardry.api.entity.fairy.FairyData) Entity(net.minecraft.entity.Entity) InterpBezier3D(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpBezier3D) GL_SRC_ALPHA(org.lwjgl.opengl.GL11.GL_SRC_ALPHA) World(net.minecraft.world.World) GlStateManager(net.minecraft.client.renderer.GlStateManager) Wizardry(com.teamwizardry.wizardry.Wizardry) ClientTickHandler(com.teamwizardry.librarianlib.core.client.ClientTickHandler) BlockPos(net.minecraft.util.math.BlockPos) UUID(java.util.UUID) java.awt(java.awt) IMiscCapability(com.teamwizardry.wizardry.api.capability.player.miscdata.IMiscCapability) Tessellator(net.minecraft.client.renderer.Tessellator) EntityPlayer(net.minecraft.entity.player.EntityPlayer) MathHelper(net.minecraft.util.math.MathHelper) NBTHelper(com.teamwizardry.librarianlib.features.helpers.NBTHelper) ResourceLocation(net.minecraft.util.ResourceLocation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) NBTConstants(com.teamwizardry.wizardry.api.NBTConstants) TickEvent(net.minecraftforge.fml.common.gameevent.TickEvent) ModItems(com.teamwizardry.wizardry.init.ModItems) InterpLine(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpLine) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) EntityFairy(com.teamwizardry.wizardry.common.entity.EntityFairy) FairyData(com.teamwizardry.wizardry.api.entity.fairy.FairyData) ResourceLocation(net.minecraft.util.ResourceLocation) StaticInterp(com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp) EntityPlayer(net.minecraft.entity.player.EntityPlayer) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with InterpFloatInOut

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

the class TileManaBatteryRenderer method render.

@Override
public void render(float partialTicks, int destroyStage, float alpha) {
    if (!getBakedModels())
        return;
    GlStateManager.pushMatrix();
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    TextureManager texturemanager = Minecraft.getMinecraft().renderEngine;
    if (texturemanager != null) {
        texturemanager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    }
    if (Minecraft.isAmbientOcclusionEnabled())
        GlStateManager.shadeModel(GL11.GL_SMOOTH);
    else
        GlStateManager.shadeModel(GL11.GL_FLAT);
    float fill = (float) (ManaManager.getMana(tile.getWizardryCap()) / ManaManager.getMaxMana(tile.getWizardryCap())) / 40.0f;
    GlStateManager.translate(0, 0.5, 0);
    GlStateManager.disableRescaleNormal();
    {
        double x = RandUtil.nextDouble(-fill, fill), y = RandUtil.nextDouble(-fill, fill), z = RandUtil.nextDouble(-fill, fill);
        GlStateManager.translate(0, Math.sin((ClientTickHandler.getTicks() + ClientTickHandler.getPartialTicks()) / 40) / 8, 0);
        GlStateManager.translate(x, y, z);
        Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightnessColor(modelCrystal, 1.0F, 1, 1, 1);
        GlStateManager.translate(-x, -y, -z);
    }
    GlStateManager.translate(0.5, 0, 0.5);
    GlStateManager.rotate(ClientTickHandler.getTicks() + ClientTickHandler.getPartialTicks(), 0, 1, 0);
    GlStateManager.translate(-0.5, 0, -0.5);
    Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightnessColor(modelRing, 1.0F, 1, 1, 1);
    GlStateManager.translate(0.5, 0, 0.5);
    GlStateManager.rotate(ClientTickHandler.getTicks() + ClientTickHandler.getPartialTicks(), 0, -1, 0);
    GlStateManager.rotate(ClientTickHandler.getTicks() + ClientTickHandler.getPartialTicks(), 0, -1, 0);
    GlStateManager.translate(-0.5, 0, -0.5);
    Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightnessColor(modelRingOuter, 1.0F, 1, 1, 1);
    GlStateManager.disableBlend();
    GlStateManager.popMatrix();
    ArrayList<BlockPos> errors = new ArrayList<>(((IStructure) tile.getBlockType()).testStructure(tile.getWorld(), tile.getPos()));
    errors.sort(Vec3i::compareTo);
    if (!errors.isEmpty()) {
        for (BlockPos error : errors) {
            StructureErrorRenderer.addError(error);
        }
    }
    if (!errors.isEmpty() && tile.revealStructure && tile.getBlockType() instanceof IStructure) {
        ModStructures.structureManager.draw(ModStructures.MANA_BATTERY, (float) (Math.sin(ClientTickHandler.getTicks() / 10.0) + 1) / 10.0f + 0.3f);
        return;
    }
    if (tile.getBlockType() == ModBlocks.CREATIVE_MANA_BATTERY) {
        double angle = ClientTickHandler.getTicks() / 10.0;
        double x1 = Math.cos((float) angle);
        double y1 = Math.sin((float) angle);
        ParticleBuilder builder = new ParticleBuilder(10);
        builder.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
        builder.setCollision(true);
        builder.disableRandom();
        builder.disableMotionCalculation();
        ParticleSpawner.spawn(builder, tile.getWorld(), new InterpCircle(new Vec3d(tile.getPos()).add(0.5, 0.5, 0.5), new Vec3d(x1, x1, y1), 1.5f), 20, 0, (aFloat, particleBuilder) -> {
            particleBuilder.setScale(0.5f);
            particleBuilder.setColor(new Color(0xd600d2));
            particleBuilder.setAlphaFunction(new InterpFloatInOut(1, 1));
            particleBuilder.setLifetime(RandUtil.nextInt(5, 10));
        });
    } else if (ClientTickHandler.getTicks() % 10 == 0 && ManaManager.forObject(tile.getWizardryCap()).isManaFull()) {
        double radius = 1;
        double theta = 2.0f * (float) Math.PI * RandUtil.nextFloat();
        double r = radius * RandUtil.nextFloat();
        double x = r * MathHelper.cos((float) theta);
        double z = r * MathHelper.sin((float) theta);
        ParticleBuilder helix = new ParticleBuilder(20);
        helix.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
        helix.setAlphaFunction(new InterpFloatInOut(0.1f, 0.4f));
        ParticleSpawner.spawn(helix, tile.getWorld(), new StaticInterp<>(new Vec3d(tile.getPos()).add(0.5, 0.5, 0.5)), 1, 0, (someFloat, particleBuilder) -> {
            particleBuilder.setColor(ColorUtils.changeColorAlpha(new Color(0x0097FF), RandUtil.nextInt(50, 200)));
            particleBuilder.setScale(RandUtil.nextFloat(0.5f, 1.2f));
            particleBuilder.setMotion(new Vec3d(x, RandUtil.nextDouble(-1, 1), z).scale(0.05));
            particleBuilder.setLifetime(RandUtil.nextInt(20, 40));
        });
    }
}
Also used : IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) InterpCircle(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle) IStructure(com.teamwizardry.wizardry.api.block.IStructure) StaticInterp(com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp) ParticleSpawner(com.teamwizardry.librarianlib.features.particle.ParticleSpawner) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) ModBlocks(com.teamwizardry.wizardry.init.ModBlocks) ArrayList(java.util.ArrayList) ManaManager(com.teamwizardry.wizardry.api.capability.player.mana.ManaManager) DefaultVertexFormats(net.minecraft.client.renderer.vertex.DefaultVertexFormats) Vec3i(net.minecraft.util.math.Vec3i) Vec3d(net.minecraft.util.math.Vec3d) Minecraft(net.minecraft.client.Minecraft) Side(net.minecraftforge.fml.relauncher.Side) ModStructures(com.teamwizardry.wizardry.init.ModStructures) Mod(net.minecraftforge.fml.common.Mod) GL11(org.lwjgl.opengl.GL11) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nonnull(javax.annotation.Nonnull) TileRenderHandler(com.teamwizardry.librarianlib.features.tesr.TileRenderHandler) ClientRunnable(com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable) GlStateManager(net.minecraft.client.renderer.GlStateManager) Wizardry(com.teamwizardry.wizardry.Wizardry) TextureMap(net.minecraft.client.renderer.texture.TextureMap) ModelLoaderRegistry(net.minecraftforge.client.model.ModelLoaderRegistry) ClientTickHandler(com.teamwizardry.librarianlib.core.client.ClientTickHandler) BlockPos(net.minecraft.util.math.BlockPos) ColorUtils(com.teamwizardry.wizardry.api.util.ColorUtils) TextureManager(net.minecraft.client.renderer.texture.TextureManager) IModel(net.minecraftforge.client.model.IModel) java.awt(java.awt) TileManaBattery(com.teamwizardry.wizardry.common.tile.TileManaBattery) StructureErrorRenderer(com.teamwizardry.wizardry.client.core.renderer.StructureErrorRenderer) MathHelper(net.minecraft.util.math.MathHelper) ResourceLocation(net.minecraft.util.ResourceLocation) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) NBTConstants(com.teamwizardry.wizardry.api.NBTConstants) Vec3i(net.minecraft.util.math.Vec3i) InterpCircle(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle) ArrayList(java.util.ArrayList) StaticInterp(com.teamwizardry.librarianlib.features.math.interpolate.StaticInterp) IStructure(com.teamwizardry.wizardry.api.block.IStructure) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d) TextureManager(net.minecraft.client.renderer.texture.TextureManager) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) ResourceLocation(net.minecraft.util.ResourceLocation) BlockPos(net.minecraft.util.math.BlockPos)

Example 5 with InterpFloatInOut

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

the class LibParticles method FAIRY_HEAD.

public static void FAIRY_HEAD(World world, Vec3d pos, Color color) {
    ParticleBuilder glitter = new ParticleBuilder(3);
    glitter.setColor(color);
    glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
    glitter.setAlphaFunction(new InterpFloatInOut(0.2f, 1f));
    glitter.setScale(3.5f);
    ParticleSpawner.spawn(glitter, world, new StaticInterp<>(pos), 2);
    ParticleBuilder glitter2 = new ParticleBuilder(5);
    glitter2.setColor(color);
    glitter2.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
    glitter2.setAlphaFunction(new InterpFloatInOut(0.2f, 1f));
    glitter2.setScale(1);
    ParticleSpawner.spawn(glitter2, world, new StaticInterp<>(pos), 3);
}
Also used : InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) ResourceLocation(net.minecraft.util.ResourceLocation) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder)

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