Search in sources :

Example 91 with Vec3i

use of net.minecraft.util.math.Vec3i in project Totemic by TeamTotemic.

the class ComponentTipi method placeTipi.

private void placeTipi(World world, int x, int y, int z, EnumFacing dir, StructureBoundingBox bb) {
    // Place dummy blocks
    for (int i = 0; i < 2; i++) {
        for (EnumFacing blockDir : EnumFacing.HORIZONTALS) {
            if (blockDir == dir)
                continue;
            Vec3i dirVec = blockDir.getDirectionVec();
            setBlockState(world, ModBlocks.dummy_tipi.getDefaultState(), x + dirVec.getX(), y + i, z + dirVec.getZ(), bb);
        }
    }
    setBlockState(world, ModBlocks.dummy_tipi.getDefaultState(), x, y + 3, z, bb);
    setBlockState(world, ModBlocks.dummy_tipi.getDefaultState(), x, y + 4, z, bb);
    setBlockState(world, ModBlocks.dummy_tipi.getDefaultState(), x, y + 5, z, bb);
    // Place Tipi block itself
    setBlockState(world, ModBlocks.tipi.getDefaultState().withProperty(BlockTipi.FACING, dir), x, y, z, bb);
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) EnumFacing(net.minecraft.util.EnumFacing)

Example 92 with Vec3i

use of net.minecraft.util.math.Vec3i in project Charset by CharsetMC.

the class CharsetTweakBlockCarrying method dropCarriedBlock.

protected static boolean dropCarriedBlock(EntityPlayer entity, boolean must, int maxRadius) {
    CarryHandler carryHandler = entity.getCapability(CAPABILITY, null);
    if (carryHandler != null && carryHandler.isCarrying()) {
        World world = entity.getEntityWorld();
        if (world.isRemote) {
            carryHandler.empty();
            return true;
        }
        BlockPos base = entity.getPosition();
        for (int method = 0; method <= (must ? 2 : 1); method++) {
            for (int radius = 0; radius <= maxRadius; radius++) {
                Vec3i radiusVec = new Vec3i(radius, radius, radius);
                for (BlockPos pos : BlockPos.getAllInBoxMutable(base.subtract(radiusVec), base.add(radiusVec))) {
                    if (world.getBlockState(pos).getBlock().isReplaceable(world, pos) && (method > 1 || !world.isAirBlock(pos.down())) && (method > 0 || world.isSideSolid(pos.down(), EnumFacing.UP))) {
                        carryHandler.place(world, pos.toImmutable(), EnumFacing.UP, entity);
                    }
                    if (!carryHandler.isCarrying())
                        break;
                }
                if (!carryHandler.isCarrying())
                    break;
            }
            if (!carryHandler.isCarrying())
                break;
        }
        if (carryHandler.isCarrying()) {
            if (must) {
                ModCharset.logger.error("Could not drop carried block from player " + entity.getName() + "! This is a bug!");
            }
            return false;
        } else {
            CharsetTweakBlockCarrying.syncCarryWithAllClients(entity);
            return true;
        }
    } else {
        return true;
    }
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World)

Example 93 with Vec3i

use of net.minecraft.util.math.Vec3i in project Fracture by HellFirePvP.

the class FissureData method recalcSize.

private void recalcSize() {
    int minX = MiscUtils.getMinEntry(stateOffsetMap.keySet(), Vec3i::getX);
    int minY = MiscUtils.getMinEntry(stateOffsetMap.keySet(), Vec3i::getY);
    int minZ = MiscUtils.getMinEntry(stateOffsetMap.keySet(), Vec3i::getZ);
    int maxX = MiscUtils.getMaxEntry(stateOffsetMap.keySet(), Vec3i::getX);
    int maxY = MiscUtils.getMaxEntry(stateOffsetMap.keySet(), Vec3i::getY);
    int maxZ = MiscUtils.getMaxEntry(stateOffsetMap.keySet(), Vec3i::getZ);
    this.min = new BlockPos(minX, minY, minZ);
    this.max = new BlockPos(maxX, maxY, maxZ);
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) BlockPos(net.minecraft.util.math.BlockPos)

Example 94 with Vec3i

use of net.minecraft.util.math.Vec3i 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 95 with Vec3i

use of net.minecraft.util.math.Vec3i in project Fracture by HellFirePvP.

the class TileFissureDevice method playOuterCube.

@SideOnly(Side.CLIENT)
private void playOuterCube(FissureData drawData) {
    if (drawData == null)
        return;
    int max = 0;
    Vec3i minV = drawData.getMin();
    Vec3i maxV = drawData.getMax();
    if (Math.abs(minV.getX()) > max) {
        max = Math.abs(minV.getX());
    }
    if (Math.abs(minV.getY()) > max) {
        max = Math.abs(minV.getY());
    }
    if (Math.abs(minV.getZ()) > max) {
        max = Math.abs(minV.getZ());
    }
    if (Math.abs(maxV.getX()) > max) {
        max = Math.abs(maxV.getX());
    }
    if (Math.abs(maxV.getY()) > max) {
        max = Math.abs(maxV.getY());
    }
    if (Math.abs(maxV.getZ()) > max) {
        max = Math.abs(maxV.getZ());
    }
    if (outerFloatingCube1 == null || ((EntityFXFloatingCube) outerFloatingCube1).isRemoved()) {
        outerFloatingCube1 = setupOuterCube(max);
    }
    if (outerFloatingCube2 == null || ((EntityFXFloatingCube) outerFloatingCube2).isRemoved()) {
        outerFloatingCube2 = setupOuterCube(max);
    }
    handleOuterAnimations(outerFloatingCube1, max);
    handleOuterAnimations(outerFloatingCube2, max);
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

Vec3i (net.minecraft.util.math.Vec3i)161 BlockPos (net.minecraft.util.math.BlockPos)88 IBlockState (net.minecraft.block.state.IBlockState)29 Vec3d (net.minecraft.util.math.Vec3d)25 EnumFacing (net.minecraft.util.EnumFacing)18 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)15 Block (net.minecraft.block.Block)12 Entity (net.minecraft.entity.Entity)11 ArrayList (java.util.ArrayList)10 World (net.minecraft.world.World)10 TileEntity (net.minecraft.tileentity.TileEntity)8 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)7 HashSet (java.util.HashSet)6 Tessellator (net.minecraft.client.renderer.Tessellator)6 EntityEnderCrystal (net.minecraft.entity.item.EntityEnderCrystal)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)6 HashMap (java.util.HashMap)5 Random (java.util.Random)5 Direction (net.minecraft.util.math.Direction)5