Search in sources :

Example 11 with FissureData

use of hellfirepvp.fracture.common.fissure.FissureData 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 12 with FissureData

use of hellfirepvp.fracture.common.fissure.FissureData in project Fracture by HellFirePvP.

the class DataFissures method writeAllDataToPacket.

@Override
public void writeAllDataToPacket(NBTTagCompound compound) {
    Map<Integer, Map<BlockPos, FissureData>> fissures = FissureDataController.getFissures();
    NBTTagList dimFissures = new NBTTagList();
    for (int dim : fissures.keySet()) {
        NBTTagCompound dimFissure = new NBTTagCompound();
        dimFissure.setInteger("dim", dim);
        NBTTagList listFissures = new NBTTagList();
        for (Map.Entry<BlockPos, FissureData> fissure : fissures.get(dim).entrySet()) {
            NBTTagCompound cmp = new NBTTagCompound();
            cmp.setInteger("x", fissure.getKey().getX());
            cmp.setInteger("y", fissure.getKey().getY());
            cmp.setInteger("z", fissure.getKey().getZ());
            NBTTagCompound tagFissure = new NBTTagCompound();
            fissure.getValue().writeToNBT(tagFissure);
            cmp.setTag("fissure", tagFissure);
            listFissures.appendTag(cmp);
        }
        dimFissure.setTag("list", listFissures);
        dimFissures.appendTag(dimFissure);
    }
    compound.setTag("update", dimFissures);
    compound.setTag("remove", new NBTTagList());
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) FissureData(hellfirepvp.fracture.common.fissure.FissureData) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) BlockPos(net.minecraft.util.math.BlockPos) Map(java.util.Map) HashMap(java.util.HashMap)

Example 13 with FissureData

use of hellfirepvp.fracture.common.fissure.FissureData in project Fracture by HellFirePvP.

the class DataFissures method writeToPacket.

@Override
public void writeToPacket(NBTTagCompound compound) {
    NBTTagList dimFissures = new NBTTagList();
    for (int dim : updateRequested.keySet()) {
        NBTTagCompound dimFissure = new NBTTagCompound();
        dimFissure.setInteger("dim", dim);
        NBTTagList listFissures = new NBTTagList();
        for (Map.Entry<BlockPos, FissureData> fissure : updateRequested.get(dim).entrySet()) {
            NBTTagCompound cmp = new NBTTagCompound();
            cmp.setInteger("x", fissure.getKey().getX());
            cmp.setInteger("y", fissure.getKey().getY());
            cmp.setInteger("z", fissure.getKey().getZ());
            NBTTagCompound tagFissure = new NBTTagCompound();
            fissure.getValue().writeToNBT(tagFissure);
            cmp.setTag("fissure", tagFissure);
            listFissures.appendTag(cmp);
        }
        dimFissure.setTag("list", listFissures);
        dimFissures.appendTag(dimFissure);
    }
    compound.setTag("update", dimFissures);
    NBTTagList listRemovals = new NBTTagList();
    for (int dim : removalRequested.keySet()) {
        NBTTagCompound dimRemove = new NBTTagCompound();
        dimRemove.setInteger("dim", dim);
        NBTTagList listRemove = new NBTTagList();
        for (BlockPos remove : removalRequested.get(dim)) {
            NBTTagCompound tagRemove = new NBTTagCompound();
            tagRemove.setInteger("x", remove.getX());
            tagRemove.setInteger("y", remove.getY());
            tagRemove.setInteger("z", remove.getZ());
            listRemove.appendTag(tagRemove);
        }
        dimRemove.setTag("list", listRemove);
        listRemovals.appendTag(dimRemove);
    }
    compound.setTag("remove", listRemovals);
    updateRequested.clear();
    removalRequested.clear();
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) FissureData(hellfirepvp.fracture.common.fissure.FissureData) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) BlockPos(net.minecraft.util.math.BlockPos) Map(java.util.Map) HashMap(java.util.HashMap)

Example 14 with FissureData

use of hellfirepvp.fracture.common.fissure.FissureData in project Fracture by HellFirePvP.

the class DataFissures method readRawFromPacket.

@Override
public void readRawFromPacket(NBTTagCompound compound) {
    NBTTagList listUpdate = compound.getTagList("update", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < listUpdate.tagCount(); i++) {
        NBTTagCompound dimFissure = listUpdate.getCompoundTagAt(i);
        int dim = dimFissure.getInteger("dim");
        Map<BlockPos, FissureData> fissures = new HashMap<>();
        clientUpdateRequested.put(dim, fissures);
        NBTTagList listFissures = dimFissure.getTagList("list", Constants.NBT.TAG_COMPOUND);
        for (int j = 0; j < listFissures.tagCount(); j++) {
            NBTTagCompound tagFissure = listFissures.getCompoundTagAt(j);
            BlockPos pos = new BlockPos(tagFissure.getInteger("x"), tagFissure.getInteger("y"), tagFissure.getInteger("z"));
            NBTTagCompound tagFissureData = tagFissure.getCompoundTag("fissure");
            FissureData data = FissureData.readFromNBT(tagFissureData);
            fissures.put(pos, data);
        }
    }
    NBTTagList listRemoval = compound.getTagList("remove", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < listRemoval.tagCount(); i++) {
        NBTTagCompound dimRemove = listRemoval.getCompoundTagAt(i);
        int dim = dimRemove.getInteger("dim");
        List<BlockPos> removals = new LinkedList<>();
        clientRemovalRequested.put(dim, removals);
        NBTTagList listRemovals = dimRemove.getTagList("list", Constants.NBT.TAG_COMPOUND);
        for (int j = 0; j < listRemovals.tagCount(); j++) {
            NBTTagCompound tagRemove = listRemovals.getCompoundTagAt(j);
            BlockPos pos = new BlockPos(tagRemove.getInteger("x"), tagRemove.getInteger("y"), tagRemove.getInteger("z"));
            removals.add(pos);
        }
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) FissureData(hellfirepvp.fracture.common.fissure.FissureData) HashMap(java.util.HashMap) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) BlockPos(net.minecraft.util.math.BlockPos) LinkedList(java.util.LinkedList)

Aggregations

FissureData (hellfirepvp.fracture.common.fissure.FissureData)14 BlockPos (net.minecraft.util.math.BlockPos)12 HashMap (java.util.HashMap)7 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 NBTTagList (net.minecraft.nbt.NBTTagList)6 Map (java.util.Map)5 Vector3 (hellfirepvp.fracture.common.util.Vector3)3 LinkedList (java.util.LinkedList)3 IBlockState (net.minecraft.block.state.IBlockState)3 EffectLightning (hellfirepvp.fracture.client.effect.fx.EffectLightning)2 EntityFXFacingParticle (hellfirepvp.fracture.client.effect.fx.EntityFXFacingParticle)2 BlockAir (net.minecraft.block.BlockAir)2 Tuple (net.minecraft.util.Tuple)2 Vec3i (net.minecraft.util.math.Vec3i)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 World (net.minecraft.world.World)1