Search in sources :

Example 31 with Vec3i

use of net.minecraft.util.math.Vec3i in project OreSpawn by MinecraftModDevelopmentMods.

the class PrecisionGenerator method spawnOreNode.

private int spawnOreNode(final BlockPos loc, final ChunkPos pos, final ISpawnEntry spawnData, final World world, final int nodeSize, final HeightRange heightRange) {
    int count = nodeSize;
    final int lutType = (nodeSize < 8) ? offsetIndexRef_small.length : offsetIndexRef.length;
    final int[] lut = (nodeSize < 8) ? offsetIndexRef_small : offsetIndexRef;
    final Vec3i[] offs = new Vec3i[lutType];
    System.arraycopy((nodeSize < 8) ? offsets_small : offsets, 0, offs, 0, lutType);
    if (nodeSize < 27) {
        final int[] scrambledLUT = new int[lutType];
        System.arraycopy(lut, 0, scrambledLUT, 0, scrambledLUT.length);
        scramble(scrambledLUT, this.random);
        int nc = 0;
        for (; count > 0 && nc <= nodeSize; count--) {
            final IBlockState oreBlock = spawnData.getBlocks().getRandomBlock(this.random);
            final Vec3i offset = offs[scrambledLUT[--count]];
            final BlockPos p = fixMungeOffset(offset, loc, heightRange, pos);
            final int dimension = world.provider.getDimension();
            if (spawn(oreBlock, world, p, dimension, true, spawnData)) {
                nc++;
            }
        }
        return nc;
    }
    return spawnFill(spawnData, world, pos, loc, nodeSize, heightRange);
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos)

Example 32 with Vec3i

use of net.minecraft.util.math.Vec3i in project OreSpawn by MinecraftModDevelopmentMods.

the class PrecisionGenerator method doCheckSpawn.

private int doCheckSpawn(final int dx, final int dy, final int dz, final int rSqr, final HeightRange heightRange, final ISpawnEntry spawnData, final World world, final ChunkPos pos, final BlockPos loc) {
    if (getABC(dx, dy, dz) <= rSqr) {
        final BlockPos p = fixMungeOffset(new Vec3i(dx, dy, dz), loc, heightRange, pos);
        final IBlockState bl = spawnData.getBlocks().getRandomBlock(this.random);
        if (bl.getBlock().equals(net.minecraft.init.Blocks.AIR))
            return -1;
        return spawn(bl, world, p, world.provider.getDimension(), true, spawnData) ? 1 : 0;
    }
    return -1;
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos)

Example 33 with Vec3i

use of net.minecraft.util.math.Vec3i in project OreSpawn by MinecraftModDevelopmentMods.

the class VeinGenerator method spawnOre.

private void spawnOre(final World world, final ISpawnEntry spawnData, final BlockPos pos, final int quantity) {
    int count = quantity;
    final int lutType = (quantity < 8) ? offsetIndexRef_small.length : offsetIndexRef.length;
    final int[] lut = (quantity < 8) ? offsetIndexRef_small : offsetIndexRef;
    final Vec3i[] offs = new Vec3i[lutType];
    System.arraycopy((quantity < 8) ? offsets_small : offsets, 0, offs, 0, lutType);
    if (quantity < 27) {
        final int[] scrambledLUT = new int[lutType];
        System.arraycopy(lut, 0, scrambledLUT, 0, scrambledLUT.length);
        scramble(scrambledLUT, this.random);
        while (count > 0) {
            final IBlockState oreBlock = spawnData.getBlocks().getRandomBlock(random);
            if (oreBlock.getBlock().equals(net.minecraft.init.Blocks.AIR))
                return;
            final BlockPos target = pos.add(offs[scrambledLUT[--count]]);
            spawn(oreBlock, world, target, world.provider.getDimension(), true, spawnData);
        }
        return;
    }
    doSpawnFill(this.random.nextBoolean(), count, world, spawnData, pos);
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos)

Example 34 with Vec3i

use of net.minecraft.util.math.Vec3i in project OreSpawn by MinecraftModDevelopmentMods.

the class ClusterGenerator method spawnChunk.

private void spawnChunk(final World world, final BlockPos pos, final ISpawnEntry spawnData, final int quantity) {
    int count = quantity;
    final int lutType = (quantity < 8) ? offsetIndexRef_small.length : offsetIndexRef.length;
    final int[] lut = (quantity < 8) ? offsetIndexRef_small : offsetIndexRef;
    final Vec3i[] offs = new Vec3i[lutType];
    System.arraycopy((quantity < 8) ? offsets_small : offsets, 0, offs, 0, lutType);
    final int dimension = world.provider.getDimension();
    if (quantity < 27) {
        final int[] scrambledLUT = new int[lutType];
        System.arraycopy(lut, 0, scrambledLUT, 0, scrambledLUT.length);
        scramble(scrambledLUT, this.random);
        int z = 0;
        while (count > 0) {
            final IBlockState oreBlock = spawnData.getBlocks().getRandomBlock(random);
            if (oreBlock.getBlock().equals(net.minecraft.init.Blocks.AIR))
                return;
            if (!spawn(oreBlock, world, pos.add(offs[scrambledLUT[--count]]), dimension, true, spawnData)) {
                count++;
                z++;
                // rescramble the LUT
                scramble(scrambledLUT, this.random);
            } else {
                z = 0;
            }
            if (z > 5) {
                count--;
                z = 0;
                OreSpawn.LOGGER.warn("Unable to place block for chunk after 5 tries");
            }
        }
        return;
    }
    doSpawnFill(this.random.nextBoolean(), count, spawnData, world, pos);
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) IBlockState(net.minecraft.block.state.IBlockState)

Example 35 with Vec3i

use of net.minecraft.util.math.Vec3i in project OreSpawn by MinecraftModDevelopmentMods.

the class FeatureBase method runCache.

protected void runCache(final int chunkX, final int chunkZ, final World world, final ISpawnEntry spawnData) {
    final Vec3i chunkCoord = new Vec3i(chunkX, chunkZ, world.provider.getDimension());
    final Map<BlockPos, IBlockState> cache = retrieveCache(chunkCoord);
    if (!cache.isEmpty()) {
        // if there is something in the cache, try to spawn it
        for (final Entry<BlockPos, IBlockState> ent : cache.entrySet()) {
            spawnNoCheck(cache.get(ent.getKey()), world, ent.getKey(), world.provider.getDimension(), spawnData);
        }
    }
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos)

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