Search in sources :

Example 21 with Vector3

use of hellfirepvp.fracture.common.util.Vector3 in project Fracture by HellFirePvP.

the class TileFissureDevice method setupCube.

@SideOnly(Side.CLIENT)
private Object setupCube(float baseScale, float scaleGrow) {
    EntityFXFloatingCube cube = new EntityFXFloatingCube(10, AssetLibrary.loadTexture(AssetLoader.TextureLocation.BLOCKS, "core_edge"));
    cube.setRefreshFunction(() -> Minecraft.getMinecraft().player != null && Minecraft.getMinecraft().player.world.provider.getDimension() == this.world.provider.getDimension() && Minecraft.getMinecraft().world.getTileEntity(getPos()) instanceof TileFissureDevice && !Minecraft.getMinecraft().world.getTileEntity(getPos()).isInvalid() && ((TileFissureDevice) Minecraft.getMinecraft().world.getTileEntity(getPos())).getStructureDepth() > 0 && Minecraft.getMinecraft().world.getTileEntity(getPos()) == TileFissureDevice.this);
    cube.setPosition(new Vector3(this).add(0.5, 0.8, 0.5));
    cube.setPositionController((fx, position, motionToBeMoved) -> {
        Vector3 base = new Vector3(TileFissureDevice.this).add(0.5, 0.8, 0.5);
        base.addY(percActive * 0.5);
        return base;
    });
    cube.setScaleFunction((fx, pTicks, scaleIn) -> baseScale + baseScale * (percActive * scaleGrow));
    cube.tumble();
    EffectHandler.getInstance().registerFX(cube);
    return cube;
}
Also used : EntityFXFloatingCube(hellfirepvp.fracture.client.effect.fx.EntityFXFloatingCube) Vector3(hellfirepvp.fracture.common.util.Vector3) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 22 with Vector3

use of hellfirepvp.fracture.common.util.Vector3 in project Fracture by HellFirePvP.

the class TileFissureDevice method playEffects.

@SideOnly(Side.CLIENT)
private void playEffects() {
    int depth = getStructureDepth();
    if (depth > 0) {
        if (headFloatingCube1 == null || ((EntityFXFloatingCube) headFloatingCube1).isRemoved()) {
            headFloatingCube1 = setupCube(0.35F, 0.3F);
        }
        if (headFloatingCube2 == null || ((EntityFXFloatingCube) headFloatingCube2).isRemoved()) {
            headFloatingCube2 = setupCube(0.3F, 0.2F);
        }
        if (headFloatingCube3 == null || ((EntityFXFloatingCube) headFloatingCube3).isRemoved()) {
            headFloatingCube3 = setupCube(0.25F, 0.04F);
        }
        handleAnimations(headFloatingCube1);
        handleAnimations(headFloatingCube2);
        handleAnimations(headFloatingCube3);
        if (this.percActive >= 1F && rand.nextFloat() >= 0.8F) {
            EffectLightning lightning = EffectHandler.getInstance().lightning(new Vector3(0.4 + rand.nextFloat() * 0.2, 0.1 - depth, 0.4 + rand.nextFloat() * 0.2).add(getPos()), new Vector3(0.4 + rand.nextFloat() * 0.2, 0.4, 0.4 + rand.nextFloat() * 0.2).add(getPos()));
            lightning.setOverlayColor(new Color(0x2DE400));
        }
        if (this.percActive > 0) {
            for (int i = 0; i < depth * 6; i++) {
                if (rand.nextFloat() <= this.percActive) {
                    EntityFXFacingParticle p = new EntityFXFacingParticle(30);
                    p.setAlphaFunction(EntityFX.AlphaFunction.FADE_OUT);
                    p.setColor(new Color(0x2DE400));
                    p.setPosition(new Vector3(getPos()).add(0.4 + rand.nextFloat() * 0.2, 0.4, 0.4 + rand.nextFloat() * 0.2).addY(-rand.nextFloat() * (0.3 + depth)));
                    p.setScale(0.05F + rand.nextFloat() * 0.05F);
                    p.setAlphaMultiplier(0.75F);
                    p.setMotion(Vector3.random().multiply(0.006F));
                    EffectHandler.getInstance().registerFX(p);
                }
            }
        }
        FissureData otherData = FissureDataController.getFissureData(this.getLinkedDimension(), this.getLinkedPos());
        if (this.swapPerc > 0F) {
            for (int i = 0; i < 40; i++) {
                if (rand.nextFloat() < this.swapPerc) {
                    Vector3 offset = Vector3.random().multiply(2.5);
                    if (rand.nextBoolean()) {
                        offset = Vector3.random();
                    }
                    Vector3 particlePos = new Vector3(getPos()).add(0.5, 0.5, 0.5).add(offset).addY(1.3);
                    Vector3 dir = particlePos.clone().subtract(pos.getX() + 0.5, pos.getY() + 1.3, pos.getZ() + 0.5).normalize().divide(-20);
                    EntityFXFacingParticle p = new EntityFXFacingParticle(30);
                    p.setAlphaFunction(EntityFX.AlphaFunction.PYRAMID);
                    p.setColor(new Color(0x2DE400));
                    p.setPosition(particlePos);
                    p.setScale(0.03F + rand.nextFloat() * 0.03F);
                    p.setAlphaMultiplier(0.85F);
                    p.setMotion(dir);
                    EffectHandler.getInstance().registerFX(p);
                }
            }
            for (int i = 0; i < 2; i++) {
                if (rand.nextFloat() < this.swapPerc && otherData != null) {
                    Vec3i vecSub = otherData.getMax().subtract(otherData.getMin());
                    Vector3 randFrom = new Vector3(otherData.getMin());
                    randFrom.addX(vecSub.getX() * rand.nextFloat());
                    randFrom.addY(vecSub.getY() * rand.nextFloat());
                    randFrom.addZ(vecSub.getZ() * rand.nextFloat());
                    randFrom.add(getPos());
                    Vector3 randTo = new Vector3(otherData.getMin());
                    randTo.addX(vecSub.getX() * rand.nextFloat());
                    randTo.addY(vecSub.getY() * rand.nextFloat());
                    randTo.addZ(vecSub.getZ() * rand.nextFloat());
                    randTo.add(getPos());
                    Vector3 dst = randTo.clone().subtract(randFrom);
                    if (dst.length() > 6) {
                        dst.normalize().multiply(6);
                    }
                    EffectLightning eff = EffectHandler.getInstance().lightning(randFrom, randFrom.clone().add(dst));
                    eff.setOverlayColor(new Color(0x2DE400));
                }
            }
        }
        playOuterCube(otherData);
        if (this.percDrawFissure > 0 && otherData != null) {
            if (percDrawFissure < 1F) {
                float chance = 1F - Math.abs((percDrawFissure - 0.5F) * 1.6F);
                for (int i = 0; i < 19; i++) {
                    if (rand.nextFloat() < chance) {
                        Vector3 particlePos = new Vector3(getPos()).add(0.5, 0.5, 0.5).add(Vector3.random().multiply(2.5)).addY(1.3);
                        Vector3 dir = particlePos.clone().subtract(pos.getX() + 0.5, pos.getY() + 1.3, pos.getZ() + 0.5).normalize().divide(-20);
                        EntityFXFacingParticle p = new EntityFXFacingParticle(30);
                        p.setAlphaFunction(EntityFX.AlphaFunction.PYRAMID);
                        p.setColor(new Color(0x2DE400));
                        p.setPosition(particlePos);
                        p.setScale(0.03F + rand.nextFloat() * 0.03F);
                        p.setAlphaMultiplier(0.85F);
                        p.setMotion(dir);
                        EffectHandler.getInstance().registerFX(p);
                    }
                }
            } else {
                Vec3i vecSub = otherData.getMax().subtract(otherData.getMin());
                Vector3 randPos = new Vector3(otherData.getMin());
                randPos.addX(vecSub.getX() * rand.nextFloat());
                randPos.addY(vecSub.getY() * rand.nextFloat());
                randPos.addZ(vecSub.getZ() * rand.nextFloat());
                randPos.add(getPos());
                EntityFXFacingParticle p = new EntityFXFacingParticle(60);
                p.setAlphaFunction(EntityFX.AlphaFunction.PYRAMID);
                p.setColor(new Color(0x2DE400));
                p.setPosition(randPos);
                p.setScale(0.02F + rand.nextFloat() * 0.03F);
                p.setAlphaMultiplier(0.75F);
                p.setMotion(Vector3.random().multiply(0.01F));
                EffectHandler.getInstance().registerFX(p);
                for (int i = 0; i < 4; i++) {
                    p = new EntityFXFacingParticle(40);
                    p.setAlphaFunction(EntityFX.AlphaFunction.FADE_OUT);
                    p.setColor(new Color(0x2DE400));
                    p.setPosition(new Vector3(getPos()).add(0.5, 1.3, 0.5));
                    p.setScale(0.015F + rand.nextFloat() * 0.02F);
                    p.setAlphaMultiplier(0.75F);
                    p.setMotion(Vector3.random().multiply(0.015F));
                    EffectHandler.getInstance().registerFX(p);
                }
                if (rand.nextInt(6) == 0) {
                    Vector3 randFrom = new Vector3(otherData.getMin());
                    randFrom.addX(vecSub.getX() * rand.nextFloat());
                    randFrom.addY(vecSub.getY() * rand.nextFloat());
                    randFrom.addZ(vecSub.getZ() * rand.nextFloat());
                    randFrom.add(getPos());
                    Vector3 randTo = new Vector3(otherData.getMin());
                    randTo.addX(vecSub.getX() * rand.nextFloat());
                    randTo.addY(vecSub.getY() * rand.nextFloat());
                    randTo.addZ(vecSub.getZ() * rand.nextFloat());
                    randTo.add(getPos());
                    Vector3 dst = randTo.clone().subtract(randFrom);
                    if (dst.length() > 6) {
                        dst.normalize().multiply(6);
                    }
                    EffectLightning eff = EffectHandler.getInstance().lightning(randFrom, randFrom.clone().add(dst));
                    eff.setOverlayColor(new Color(0x2DE400));
                }
            }
        }
    }
}
Also used : FissureData(hellfirepvp.fracture.common.fissure.FissureData) Vec3i(net.minecraft.util.math.Vec3i) EffectLightning(hellfirepvp.fracture.client.effect.fx.EffectLightning) Vector3(hellfirepvp.fracture.common.util.Vector3) EntityFXFacingParticle(hellfirepvp.fracture.client.effect.fx.EntityFXFacingParticle) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 23 with Vector3

use of hellfirepvp.fracture.common.util.Vector3 in project Fracture by HellFirePvP.

the class TileFissureDevice method setupOuterCube.

@SideOnly(Side.CLIENT)
private Object setupOuterCube(int radius) {
    EntityFXFloatingCube cube = new EntityFXFloatingCube(10, AssetLibrary.loadTexture(AssetLoader.TextureLocation.BLOCKS, "core_edge"));
    cube.setRefreshFunction(() -> Minecraft.getMinecraft().player != null && Minecraft.getMinecraft().player.world.provider.getDimension() == this.world.provider.getDimension() && Minecraft.getMinecraft().world.getTileEntity(getPos()) instanceof TileFissureDevice && !Minecraft.getMinecraft().world.getTileEntity(getPos()).isInvalid() && ((TileFissureDevice) Minecraft.getMinecraft().world.getTileEntity(getPos())).getStructureDepth() > 0 && Minecraft.getMinecraft().world.getTileEntity(getPos()) == TileFissureDevice.this);
    cube.setAlphaMultiplier(0F);
    cube.setPosition(new Vector3(getPos()).add(0.5, 0.5, 0.5));
    cube.setScale(radius * 2);
    cube.setTumbleIntensityMultiplier(0.04F);
    cube.setColor(new Color(0x2DE400));
    cube.tumble();
    EffectHandler.getInstance().registerFX(cube);
    return cube;
}
Also used : EntityFXFloatingCube(hellfirepvp.fracture.client.effect.fx.EntityFXFloatingCube) Vector3(hellfirepvp.fracture.common.util.Vector3) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

Vector3 (hellfirepvp.fracture.common.util.Vector3)23 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 EffectLightning (hellfirepvp.fracture.client.effect.fx.EffectLightning)4 EntityFXFacingParticle (hellfirepvp.fracture.client.effect.fx.EntityFXFacingParticle)4 EntityFXFloatingCube (hellfirepvp.fracture.client.effect.fx.EntityFXFloatingCube)4 Entity (net.minecraft.entity.Entity)4 FissureData (hellfirepvp.fracture.common.fissure.FissureData)3 LinkedList (java.util.LinkedList)3 Random (java.util.Random)2 Vec3i (net.minecraft.util.math.Vec3i)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1