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);
}
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;
}
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);
}
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);
}
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);
}
}
}
Aggregations