Search in sources :

Example 6 with FissureData

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

the class TranslucentFissureFX method batchRender.

private static void batchRender(float pTicks, Map<BlockPos, Tuple<FissureData, FissureData>> fissures, IBlockAccess iba) {
    BlockRendererDispatcher brd = Minecraft.getMinecraft().getBlockRendererDispatcher();
    batchDList = GLAllocation.generateDisplayLists(1);
    GlStateManager.enableBlend();
    Blending.OVERLAYDARK.applyStateManager();
    Blending.OVERLAYDARK.apply();
    GlStateManager.glNewList(batchDList, GL11.GL_COMPILE);
    Tessellator tes = Tessellator.getInstance();
    BufferBuilder vb = tes.getBuffer();
    vb.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    // Overlap....
    List<BlockPos> rendered = new ArrayList<>();
    for (Map.Entry<BlockPos, Tuple<FissureData, FissureData>> fissureData : fissures.entrySet()) {
        FissureData limiter = fissureData.getValue().getSecond();
        for (BlockPos offset : BlockPos.getAllInBox(limiter.getMin().add(fissureData.getKey()), limiter.getMax().add(fissureData.getKey()))) {
            if (offset.equals(fissureData.getKey()))
                continue;
            IBlockState real = Minecraft.getMinecraft().world.getBlockState(offset);
            IBlockState state = iba.getBlockState(offset);
            if (real.getBlock() instanceof BlockAir) {
                rendered.add(offset);
            } else if ((state.getBlock() instanceof BlockAir) && !rendered.contains(offset)) {
                rendered.add(offset);
                brd.renderBlock(real, offset, Minecraft.getMinecraft().world, vb);
            }
        }
    }
    vb.sortVertexData((float) TileEntityRendererDispatcher.staticPlayerX, (float) TileEntityRendererDispatcher.staticPlayerY, (float) TileEntityRendererDispatcher.staticPlayerZ);
    tes.draw();
    GlStateManager.glEndList();
    Blending.DEFAULT.applyStateManager();
    Blending.DEFAULT.apply();
    GlStateManager.color(1F, 1F, 1F, 1F);
    GL11.glColor4f(1F, 1F, 1F, 1F);
}
Also used : BlockAir(net.minecraft.block.BlockAir) FissureData(hellfirepvp.fracture.common.fissure.FissureData) IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos) Tuple(net.minecraft.util.Tuple)

Example 7 with FissureData

use of hellfirepvp.fracture.common.fissure.FissureData in project SomeModjam5Mod 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());
        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(-15);
                        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 8 with FissureData

use of hellfirepvp.fracture.common.fissure.FissureData in project SomeModjam5Mod 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 9 with FissureData

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

the class TileFissureDevice method update.

@Override
public void update() {
    ticksExisted++;
    if (!world.isRemote) {
        if ((ticksExisted % 20 == 0) && getStructureDepth() > 0) {
            FissureDataController.updateFissureServer(this);
        }
        if (!isLinked) {
            FissureData thisData = FissureDataController.getFissureData(this.world.provider.getDimension(), this.getPos());
            if (thisData != null && thisData.hasOtherLink()) {
                this.isLinked = true;
                this.linkedDimension = thisData.getOtherLinkDim();
                this.linkedPos = thisData.getOtherLinkPos();
                markForUpdate();
            } else {
                Tuple<Integer, BlockPos> linkPair = FissureDataController.getRandomFissureExcept(this);
                if (linkPair != null) {
                    this.isLinked = true;
                    this.linkedDimension = linkPair.getFirst();
                    this.linkedPos = linkPair.getSecond();
                    markForUpdate();
                }
            }
        } else {
            FissureData thisData = FissureDataController.getFissureData(this.world.provider.getDimension(), this.getPos());
            if (thisData != null) {
                // The other end died :(
                if (!thisData.hasOtherLink()) {
                    this.isLinked = false;
                    this.linkedDimension = -1;
                    this.linkedPos = BlockPos.ORIGIN;
                    markForUpdate();
                }
            }
        }
        if (activatedPlayer != null) {
            // 7.5 sq
            if (activatedPlayer.getDistanceSqToCenter(getPos()) >= 56.25) {
                this.active = false;
                this.activatedPlayer = null;
                markForUpdate();
            }
        }
    } else {
        float accel = 0.025F;
        if (this.active && this.getStructureDepth() > 0) {
            this.percActive = Math.min(1F, this.percActive + accel);
            if (percActive >= 1F) {
                float accelDraw = 0.01F;
                this.percDrawFissure = Math.min(1F, this.percDrawFissure + accelDraw);
            }
        } else {
            this.percActive = Math.max(0F, this.percActive - accel);
            this.percDrawFissure = 0F;
        }
        if (this.active && this.getStructureDepth() > 0 && this.isLinked) {
            FissureData otherLink = FissureDataController.getFissureData(this.getLinkedDimension(), this.getLinkedPos());
            if (otherLink != null && this.percDrawFissure >= 1F) {
                ClientFissureWorldHandler.activate(this);
            }
        } else {
            ClientFissureWorldHandler.deactivate(this);
            this.percDrawFissure = 0F;
        }
        playEffects();
    }
}
Also used : FissureData(hellfirepvp.fracture.common.fissure.FissureData) BlockPos(net.minecraft.util.math.BlockPos)

Example 10 with FissureData

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

the class TranslucentFissureFX method batchRender.

private static void batchRender(float pTicks, Map<BlockPos, Tuple<FissureData, FissureData>> fissures, IBlockAccess iba) {
    BlockRendererDispatcher brd = Minecraft.getMinecraft().getBlockRendererDispatcher();
    batchDList = GLAllocation.generateDisplayLists(1);
    GlStateManager.enableBlend();
    Blending.OVERLAYDARK.applyStateManager();
    Blending.OVERLAYDARK.apply();
    GlStateManager.glNewList(batchDList, GL11.GL_COMPILE);
    Tessellator tes = Tessellator.getInstance();
    BufferBuilder vb = tes.getBuffer();
    vb.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    // Overlap....
    List<BlockPos> rendered = new ArrayList<>();
    for (Map.Entry<BlockPos, Tuple<FissureData, FissureData>> fissureData : fissures.entrySet()) {
        FissureData limiter = fissureData.getValue().getSecond();
        for (BlockPos offset : BlockPos.getAllInBox(limiter.getMin().add(fissureData.getKey()), limiter.getMax().add(fissureData.getKey()))) {
            if (offset.equals(fissureData.getKey()))
                continue;
            IBlockState real = Minecraft.getMinecraft().world.getBlockState(offset);
            IBlockState state = iba.getBlockState(offset);
            if (real.getBlock() instanceof BlockAir) {
                rendered.add(offset);
            } else if ((state.getBlock() instanceof BlockAir) && !rendered.contains(offset)) {
                rendered.add(offset);
                try {
                    brd.renderBlock(real, offset, Minecraft.getMinecraft().world, vb);
                } catch (Exception ignored) {
                }
            }
        }
    }
    vb.sortVertexData((float) TileEntityRendererDispatcher.staticPlayerX, (float) TileEntityRendererDispatcher.staticPlayerY, (float) TileEntityRendererDispatcher.staticPlayerZ);
    tes.draw();
    GlStateManager.glEndList();
    Blending.DEFAULT.applyStateManager();
    Blending.DEFAULT.apply();
    GlStateManager.color(1F, 1F, 1F, 1F);
    GL11.glColor4f(1F, 1F, 1F, 1F);
}
Also used : BlockAir(net.minecraft.block.BlockAir) IBlockState(net.minecraft.block.state.IBlockState) FissureData(hellfirepvp.fracture.common.fissure.FissureData) BlockPos(net.minecraft.util.math.BlockPos) Tuple(net.minecraft.util.Tuple)

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