Search in sources :

Example 1 with InterpCircle

use of com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle in project Wizardry by TeamWizardry.

the class ModuleShapeSelf method render.

@Override
@SideOnly(Side.CLIENT)
public void render(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    Entity caster = spell.getCaster();
    if (caster == null)
        return;
    ParticleBuilder glitter = new ParticleBuilder(1);
    glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
    ParticleSpawner.spawn(glitter, spell.world, new InterpCircle(caster.getPositionVector().addVector(0, caster.height / 2.0, 0), new Vec3d(0, 1, 0), 1, 10), 50, RandUtil.nextInt(10, 15), (aFloat, particleBuilder) -> {
        if (RandUtil.nextBoolean()) {
            glitter.setColor(getPrimaryColor());
            glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(0.01, 0.1), 0));
        } else {
            glitter.setColor(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 InterpFadeInOut(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) ResourceLocation(net.minecraft.util.ResourceLocation) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with InterpCircle

use of com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle in project Wizardry by TeamWizardry.

the class ModuleShapeTouch method render.

@Override
@SideOnly(Side.CLIENT)
public void render(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    Entity targetEntity = spell.getVictim();
    if (targetEntity == null)
        return;
    ParticleBuilder glitter = new ParticleBuilder(1);
    glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
    ParticleSpawner.spawn(glitter, spell.world, new InterpCircle(targetEntity.getPositionVector().addVector(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(getPrimaryColor());
            glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(0.01, 0.1), 0));
        } else {
            glitter.setColor(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 InterpFadeInOut(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) ResourceLocation(net.minecraft.util.ResourceLocation) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with InterpCircle

use of com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle 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, Constants.MISC.SPARKLE_BLURRED));
                glitter.setAlphaFunction(new InterpFadeInOut(0.3f, 0.3f));
                glitter.setCollision(true);
                glitter.enableMotionCalculation();
                ParticleSpawner.spawn(glitter, getWorld(), new InterpCircle(new Vec3d(getCenter()).addVector(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()).addVector(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) ResourceLocation(net.minecraft.util.ResourceLocation) ClientRunnable(com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d)

Example 4 with InterpCircle

use of com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle in project Wizardry by TeamWizardry.

the class TileManaBatteryRenderer method render.

@Override
public void render(float partialTicks, int destroyStage, float alpha) {
    super.render(partialTicks, destroyStage, 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);
    CapManager manager = new CapManager(tile.getWizardryCap());
    float fill = (float) (manager.getMana() / manager.getMaxMana()) / 50.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((tile.getWorld().getTotalWorldTime() + 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(tile.getWorld().getTotalWorldTime() + 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(tile.getWorld().getTotalWorldTime() + ClientTickHandler.getPartialTicks(), 0, -1, 0);
    GlStateManager.rotate(tile.getWorld().getTotalWorldTime() + 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();
    HashSet<BlockPos> errors = ((IStructure) tile.getBlockType()).getErroredBlocks(tile.getWorld(), tile.getPos());
    if (tile.revealStructure && tile.getBlockType() instanceof IStructure && !errors.isEmpty()) {
        IStructure structure = ((IStructure) tile.getBlockType());
        GlStateManager.pushMatrix();
        GlStateManager.enableBlend();
        GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GlStateManager.enablePolygonOffset();
        GlStateManager.doPolygonOffset(1f, -0.05f);
        GlStateManager.translate(-structure.offsetToCenter().getX(), -structure.offsetToCenter().getY(), -structure.offsetToCenter().getZ());
        Minecraft mc = Minecraft.getMinecraft();
        Tessellator tes = Tessellator.getInstance();
        BufferBuilder buffer = tes.getBuffer();
        mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        for (BlockRenderLayer layer : cachedStructure.blocks.keySet()) {
            buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
            buffer.addVertexData(cachedStructure.vboCaches.get(layer));
            for (int i = 0; i < buffer.getVertexCount(); i++) {
                int idx = buffer.getColorIndex(i + 1);
                buffer.putColorRGBA(idx, 255, 255, 255, 200);
            }
            tes.draw();
        }
        GlStateManager.disablePolygonOffset();
        GlStateManager.color(1F, 1F, 1F, 1F);
        GlStateManager.enableDepth();
        GlStateManager.popMatrix();
    } else if (!tile.revealStructure && !errors.isEmpty()) {
        for (BlockPos error : errors) StructureErrorRenderer.INSTANCE.addError(error);
    }
    if (tile.getBlockType() == ModBlocks.CREATIVE_MANA_BATTERY) {
        double angle = tile.getWorld().getTotalWorldTime() / 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, Constants.MISC.SPARKLE_BLURRED));
        builder.setCollision(true);
        builder.disableRandom();
        builder.disableMotionCalculation();
        ParticleSpawner.spawn(builder, tile.getWorld(), new InterpCircle(new Vec3d(tile.getPos()).addVector(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 InterpFadeInOut(1, 1));
            particleBuilder.setLifetime(RandUtil.nextInt(5, 10));
        });
    }
}
Also used : InterpCircle(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle) Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) IStructure(com.teamwizardry.wizardry.api.block.IStructure) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) Minecraft(net.minecraft.client.Minecraft) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d) CapManager(com.teamwizardry.wizardry.api.capability.CapManager) TextureManager(net.minecraft.client.renderer.texture.TextureManager) ResourceLocation(net.minecraft.util.ResourceLocation) BlockPos(net.minecraft.util.math.BlockPos) BlockRenderLayer(net.minecraft.util.BlockRenderLayer)

Example 5 with InterpCircle

use of com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle in project Wizardry by TeamWizardry.

the class RenderHaloEntity method doRenderLayer.

@Override
public void doRenderLayer(@Nonnull EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
    if (BaublesSupport.getItem(entitylivingbaseIn, ModItems.FAKE_HALO, ModItems.CREATIVE_HALO, ModItems.REAL_HALO).isEmpty())
        return;
    ItemStack halo = BaublesSupport.getItem(entitylivingbaseIn, ModItems.FAKE_HALO, ModItems.CREATIVE_HALO, ModItems.REAL_HALO);
    // TODO: Remove these once we have a cosmetics system
    if (halo.getItem() == ModItems.FAKE_HALO && !ConfigValues.renderCrudeHalo)
        return;
    if (halo.getItem() == ModItems.REAL_HALO && !ConfigValues.renderRealHalo)
        return;
    if (halo.getItem() == ModItems.CREATIVE_HALO && !ConfigValues.renderCreativeHalo)
        return;
    if (halo.getItem() == ModItems.FAKE_HALO) {
        GlStateManager.pushMatrix();
        if (entitylivingbaseIn.isSneaking())
            GlStateManager.translate(0.0f, 0.2f, 0.0f);
        boolean flag = entitylivingbaseIn instanceof EntityVillager || entitylivingbaseIn instanceof EntityZombieVillager;
        if (entitylivingbaseIn.isChild() && !(entitylivingbaseIn instanceof EntityVillager)) {
            GlStateManager.translate(0.0f, 0.5f * scale, 0.0f);
            GlStateManager.scale(0.7f, 0.7f, 0.7f);
            GlStateManager.translate(0.0f, 16.0f * scale, 0.0f);
        }
        if (flag)
            GlStateManager.translate(0.0f, 0.1875f, 0.0f);
        this.modelRenderer.postRender(0.0625f);
        GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
        GlStateManager.translate(0.0f, -0.25f, 0.0f);
        GlStateManager.rotate(180.0f, 0.0f, 1.0f, 0.0f);
        GlStateManager.scale(0.625f, -0.625f, -0.625f);
        Minecraft.getMinecraft().getItemRenderer().renderItem(entitylivingbaseIn, halo, ItemCameraTransforms.TransformType.HEAD);
        GlStateManager.popMatrix();
    } else {
        ParticleBuilder glitter = new ParticleBuilder(3);
        glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
        glitter.setAlphaFunction(new InterpFadeInOut(1f, 1f));
        glitter.disableMotionCalculation();
        glitter.disableRandom();
        ParticleSpawner.spawn(glitter, entitylivingbaseIn.world, new InterpCircle(entitylivingbaseIn.getPositionVector().addVector(0, entitylivingbaseIn.height + (entitylivingbaseIn.isSneaking() ? 0.2 : 0.4), 0), new Vec3d(0, 1, 0), 0.3f, RandUtil.nextFloat(), RandUtil.nextFloat()), 10, 0, (aFloat, particleBuilder) -> {
            if (RandUtil.nextInt(10) != 0)
                if (halo.getItem() == ModItems.CREATIVE_HALO)
                    glitter.setColor(ColorUtils.changeColorAlpha(new Color(0xd600d2), RandUtil.nextInt(60, 100)));
                else
                    glitter.setColor(ColorUtils.changeColorAlpha(Color.YELLOW, RandUtil.nextInt(60, 100)));
            else
                glitter.setColor(ColorUtils.changeColorAlpha(Color.WHITE, RandUtil.nextInt(60, 100)));
            glitter.setAlphaFunction(new InterpFadeInOut(1f, 1f));
            glitter.setLifetime(10);
            glitter.setScaleFunction(new InterpFadeInOut(0.5f, 0.5f));
            glitter.setMotion(new Vec3d(entitylivingbaseIn.motionX / 2.0, (entitylivingbaseIn.motionY + 0.0784) / 2.0, entitylivingbaseIn.motionZ / 2.0));
        });
    }
}
Also used : EntityZombieVillager(net.minecraft.entity.monster.EntityZombieVillager) InterpCircle(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle) EntityVillager(net.minecraft.entity.passive.EntityVillager) ResourceLocation(net.minecraft.util.ResourceLocation) ItemStack(net.minecraft.item.ItemStack) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

InterpCircle (com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle)7 ParticleBuilder (com.teamwizardry.librarianlib.features.particle.ParticleBuilder)7 InterpFadeInOut (com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut)7 ResourceLocation (net.minecraft.util.ResourceLocation)7 Vec3d (net.minecraft.util.math.Vec3d)7 InterpScale (com.teamwizardry.wizardry.api.util.interp.InterpScale)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 Entity (net.minecraft.entity.Entity)2 ItemStack (net.minecraft.item.ItemStack)2 ClientRunnable (com.teamwizardry.librarianlib.features.utilities.client.ClientRunnable)1 IStructure (com.teamwizardry.wizardry.api.block.IStructure)1 CapManager (com.teamwizardry.wizardry.api.capability.CapManager)1 Minecraft (net.minecraft.client.Minecraft)1 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 TextureManager (net.minecraft.client.renderer.texture.TextureManager)1 EntityZombieVillager (net.minecraft.entity.monster.EntityZombieVillager)1 EntityVillager (net.minecraft.entity.passive.EntityVillager)1 BlockRenderLayer (net.minecraft.util.BlockRenderLayer)1 BlockPos (net.minecraft.util.math.BlockPos)1