Search in sources :

Example 1 with StructureWorldAccess

use of net.minecraft.world.StructureWorldAccess in project wildmod by Osmiooo.

the class RandomVeinsFeature method placeVeins.

public void placeVeins(FeatureContext<DefaultFeatureConfig> context, BlockPos pos, double average) {
    StructureWorldAccess world = context.getWorld();
    int loop = random.nextInt(2, 14);
    for (int l = 0; l < loop; l++) {
        double a = random() * 2 * PI;
        double rad = sqrt(3) * sqrt(random());
        fourDirVeins(pos.add((int) (rad * sin(a)), 0, (int) (rad * cos(a))), world);
    }
}
Also used : StructureWorldAccess(net.minecraft.world.StructureWorldAccess)

Example 2 with StructureWorldAccess

use of net.minecraft.world.StructureWorldAccess in project wildmod by Osmiooo.

the class SculkPatchFeature method placePatch.

public void placePatch(FeatureContext<DefaultFeatureConfig> context, BlockPos pos, double average) {
    StructureWorldAccess world = context.getWorld();
    double otherSculkChance = Math.cos(((average) * Math.PI) / 12);
    // Place Sculk Blobs
    int timesFailed = 0;
    int groupsFailed = 1;
    int loop = random.nextInt(18, 50);
    for (int l = 0; l < loop; ) {
        double a = random() * 2 * PI;
        double rad = sqrt(2 + (groupsFailed - 1)) * sqrt(random());
        boolean succeed = placeSculk(pos.add((int) (rad * sin(a)), 0, (int) (rad * cos(a))), world);
        // Determine If Sculk Placement Was Successful And If Radius Should Be Increased
        if (!succeed) {
            ++timesFailed;
        } else {
            ++l;
            if (timesFailed > 0) {
                --timesFailed;
            }
        }
        if (timesFailed >= 10) {
            timesFailed = 0;
            groupsFailed = groupsFailed + 1;
        }
        if (sqrt(2 + (groupsFailed - 1)) > 10) {
            break;
        }
    }
    if (otherSculkChance >= 0) {
        ArrayList<BlockPos> poses = (blockTagsInSphere(pos, 14, SculkTags.BLOCK_REPLACEABLE, world));
        if (poses.size() > 2) {
            BlockPos pos1 = poses.get(random.nextInt(1, poses.size()));
            timesFailed = 0;
            groupsFailed = 1;
            int loop1 = random.nextInt(6, 14);
            for (int l = 0; l < loop1; ) {
                double a = random() * 2 * PI;
                double rad = sqrt(2 + (groupsFailed - 1)) * sqrt(random());
                boolean succeed = placeSculk(pos1.add((int) (rad * sin(a)), 0, (int) (rad * cos(a))), world);
                // Determine If Sculk Placement Was Successful And If Radius Should Be Increased
                if (!succeed) {
                    ++timesFailed;
                } else {
                    ++l;
                    if (timesFailed > 0) {
                        --timesFailed;
                    }
                }
                if (timesFailed >= 10) {
                    timesFailed = 0;
                    groupsFailed = groupsFailed + 1;
                }
                if (sqrt(2 + (groupsFailed - 1)) > 10) {
                    break;
                }
            }
        }
    }
    if (otherSculkChance >= 0.4) {
        ArrayList<BlockPos> poses = (blockTagsInSphere(pos, 12, SculkTags.BLOCK_REPLACEABLE, world));
        if (poses.size() > 2) {
            BlockPos pos1 = poses.get(random.nextInt(1, poses.size()));
            timesFailed = 0;
            groupsFailed = 1;
            int loop1 = random.nextInt(3, 10);
            for (int l = 0; l < loop1; ) {
                double a = random() * 2 * PI;
                double rad = sqrt(2 + (groupsFailed - 1)) * sqrt(random());
                boolean succeed = placeSculk(pos1.add((int) (rad * sin(a)), 0, (int) (rad * cos(a))), world);
                // Determine If Sculk Placement Was Successful And If Radius Should Be Increased
                if (!succeed) {
                    ++timesFailed;
                } else {
                    ++l;
                    if (timesFailed > 0) {
                        --timesFailed;
                    }
                }
                if (timesFailed >= 10) {
                    timesFailed = 0;
                    groupsFailed = groupsFailed + 1;
                }
                if (sqrt(2 + (groupsFailed - 1)) > 10) {
                    break;
                }
            }
        }
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) StructureWorldAccess(net.minecraft.world.StructureWorldAccess)

Example 3 with StructureWorldAccess

use of net.minecraft.world.StructureWorldAccess in project wildmod by Osmiooo.

the class RandomSculkFeature method placePatch.

public void placePatch(FeatureContext<DefaultFeatureConfig> context, BlockPos pos, double average) {
    StructureWorldAccess world = context.getWorld();
    double otherSculkChance = Math.cos(((average) * Math.PI) / 15);
    // Place Sculk Blobs
    int timesFailed = 0;
    int groupsFailed = 1;
    int loop = random.nextInt(7, 25);
    for (int l = 0; l < loop; ) {
        double a = random() * 2 * PI;
        double rad = sqrt(2 + (groupsFailed - 1)) * sqrt(random());
        boolean succeed = placeSculk(pos.add((int) (rad * sin(a)), 0, (int) (rad * cos(a))), world);
        // Determine If Sculk Placement Was Successful And If Radius Should Be Increased
        if (!succeed) {
            ++timesFailed;
        } else {
            ++l;
            if (timesFailed > 0) {
                --timesFailed;
            }
        }
        if (timesFailed >= 10) {
            timesFailed = 0;
            groupsFailed = groupsFailed + 1;
        }
        if (sqrt(2 + (groupsFailed - 1)) > 10) {
            break;
        }
    }
    if (otherSculkChance >= 0) {
        ArrayList<BlockPos> poses = (blockTagsInSphere(pos, 14, SculkTags.BLOCK_REPLACEABLE, world));
        if (poses.size() > 2) {
            BlockPos pos1 = poses.get(random.nextInt(1, poses.size()));
            timesFailed = 0;
            groupsFailed = 1;
            int loop1 = random.nextInt(6, 9);
            for (int l = 0; l < loop1; ) {
                double a = random() * 2 * PI;
                double rad = sqrt(2 + (groupsFailed - 1)) * sqrt(random());
                boolean succeed = placeSculk(pos1.add((int) (rad * sin(a)), 0, (int) (rad * cos(a))), world);
                // Determine If Sculk Placement Was Successful And If Radius Should Be Increased
                if (!succeed) {
                    ++timesFailed;
                } else {
                    ++l;
                    if (timesFailed > 0) {
                        --timesFailed;
                    }
                }
                if (timesFailed >= 10) {
                    timesFailed = 0;
                    groupsFailed = groupsFailed + 1;
                }
                if (sqrt(2 + (groupsFailed - 1)) > 10) {
                    break;
                }
            }
        }
    }
    if (otherSculkChance >= 0.4) {
        ArrayList<BlockPos> poses = (blockTagsInSphere(pos, 12, SculkTags.BLOCK_REPLACEABLE, world));
        if (poses.size() > 2) {
            BlockPos pos1 = poses.get(random.nextInt(1, poses.size()));
            timesFailed = 0;
            groupsFailed = 1;
            int loop1 = random.nextInt(1, 7);
            for (int l = 0; l < loop1; ) {
                double a = random() * 2 * PI;
                double rad = sqrt(2 + (groupsFailed - 1)) * sqrt(random());
                boolean succeed = placeSculk(pos1.add((int) (rad * sin(a)), 0, (int) (rad * cos(a))), world);
                // Determine If Sculk Placement Was Successful And If Radius Should Be Increased
                if (!succeed) {
                    ++timesFailed;
                } else {
                    ++l;
                    if (timesFailed > 0) {
                        --timesFailed;
                    }
                }
                if (timesFailed >= 10) {
                    timesFailed = 0;
                    groupsFailed = groupsFailed + 1;
                }
                if (sqrt(2 + (groupsFailed - 1)) > 10) {
                    break;
                }
            }
        }
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) StructureWorldAccess(net.minecraft.world.StructureWorldAccess)

Example 4 with StructureWorldAccess

use of net.minecraft.world.StructureWorldAccess in project winterly by tyap-lyap.

the class CryomarbleFeature method generate.

@Override
public boolean generate(FeatureContext<DefaultFeatureConfig> context) {
    StructureWorldAccess world = context.getWorld();
    BlockPos origin = context.getOrigin();
    for (int i = -20; i < 20; i++) {
        BlockPos newOrigin = new BlockPos(origin.getX(), i, origin.getZ());
        if (world.getBlockState(newOrigin).isAir()) {
            origin = newOrigin;
            break;
        }
    }
    if (context.getRandom().nextInt(16) != 0)
        return false;
    int spawned = 0;
    for (int x = -3; x < 3; x++) {
        for (int z = -3; z < 3; z++) {
            for (int y = -3; y < 3; y++) {
                int xPos = origin.getX() + x;
                int zPos = origin.getZ() + z;
                int yPos = origin.getY() + y;
                BlockPos pos = new BlockPos(xPos, yPos, zPos);
                if (context.getRandom().nextInt(Math.abs(x) + Math.abs(y) + Math.abs(z) + 1) == 0) {
                    if (world.isAir(pos) && isStone(world.getBlockState(pos.down()))) {
                        if (spawned < 3) {
                            world.setBlockState(pos, WinterlyBlocks.RAW_CRYOMARBLE_SHARD.getDefaultState().with(IcicleBlock.FACING, Direction.UP), Block.NOTIFY_ALL);
                            spawned++;
                        } else
                            return true;
                    }
                }
            }
        }
    }
    return true;
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) StructureWorldAccess(net.minecraft.world.StructureWorldAccess)

Example 5 with StructureWorldAccess

use of net.minecraft.world.StructureWorldAccess in project winterly by tyap-lyap.

the class UndergroundIcicleFeature method generate.

@Override
public boolean generate(FeatureContext context) {
    boolean generated = false;
    int randomY = context.getRandom().nextInt(100) - 50;
    for (int x = 0; x < 10; x++) {
        for (int z = 0; z < 10; z++) {
            for (int y = 0; y < 10; y++) {
                int xPos = context.getOrigin().getX() + x;
                int zPos = context.getOrigin().getZ() + z;
                int yPos = randomY + y;
                BlockPos pos = new BlockPos(xPos, yPos, zPos);
                StructureWorldAccess world = context.getWorld();
                if (context.getRandom().nextInt(4) == 0) {
                    if (world.isAir(pos)) {
                        if (isStone(world.getBlockState(pos.up()))) {
                            world.setBlockState(pos, WinterlyBlocks.ICICLE.getDefaultState(), Block.NOTIFY_ALL);
                            generated = true;
                        }
                    }
                }
            }
        }
    }
    return generated;
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) StructureWorldAccess(net.minecraft.world.StructureWorldAccess)

Aggregations

StructureWorldAccess (net.minecraft.world.StructureWorldAccess)13 BlockPos (net.minecraft.util.math.BlockPos)11 Random (java.util.Random)4 BlockState (net.minecraft.block.BlockState)4 Block (net.minecraft.block.Block)2 SettingsManager (carpet.settings.SettingsManager)1 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 CommandDispatcher (com.mojang.brigadier.CommandDispatcher)1 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)1 Codec (com.mojang.serialization.Codec)1 RugSettings (de.rubixdev.rug.RugSettings)1 SculkVeinBlock (frozenblock.wild.mod.blocks.SculkVeinBlock)1 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1 IntPoint2D (net.cr24.primeval.util.IntPoint2D)1 Blocks (net.minecraft.block.Blocks)1 CommandManager (net.minecraft.server.command.CommandManager)1 ServerCommandSource (net.minecraft.server.command.ServerCommandSource)1