Search in sources :

Example 11 with StructureWorldAccess

use of net.minecraft.world.StructureWorldAccess in project Rug by RubixDev.

the class SlimeChunkCommand method register.

public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
    LiteralArgumentBuilder<ServerCommandSource> command = CommandManager.literal("slimechunk").requires((player) -> SettingsManager.canUseCommand(player, RugSettings.commandSlimeChunk)).executes(c -> {
        ServerPlayerEntity playerEntity = c.getSource().getPlayer();
        ChunkPos chunkPos = new ChunkPos(playerEntity.getBlockPos());
        StructureWorldAccess worldAccess = c.getSource().getWorld();
        boolean isSlimeChunk = ChunkRandom.getSlimeRandom(chunkPos.x, chunkPos.z, worldAccess.getSeed(), 987234911L).nextInt(10) < RugSettings.slimeChunkPercentage / 10;
        playerEntity.sendSystemMessage(new LiteralText("You are " + (isSlimeChunk ? "" : "not ") + "in a Slime Chunk"), Util.NIL_UUID);
        return 1;
    });
    dispatcher.register(command);
}
Also used : StructureWorldAccess(net.minecraft.world.StructureWorldAccess) LiteralText(net.minecraft.text.LiteralText) CommandDispatcher(com.mojang.brigadier.CommandDispatcher) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) ChunkRandom(net.minecraft.world.gen.random.ChunkRandom) Util(net.minecraft.util.Util) SettingsManager(carpet.settings.SettingsManager) ChunkPos(net.minecraft.util.math.ChunkPos) RugSettings(de.rubixdev.rug.RugSettings) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) CommandManager(net.minecraft.server.command.CommandManager) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ChunkPos(net.minecraft.util.math.ChunkPos) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) StructureWorldAccess(net.minecraft.world.StructureWorldAccess) LiteralText(net.minecraft.text.LiteralText)

Example 12 with StructureWorldAccess

use of net.minecraft.world.StructureWorldAccess in project Primeval by devs-immortal.

the class OreClusterFeature method generate.

@Override
public boolean generate(FeatureContext<OreClusterFeatureConfig> context) {
    BlockPos blockPos = context.getOrigin();
    StructureWorldAccess structureWorldAccess = context.getWorld();
    Random random = context.getRandom();
    OreClusterFeatureConfig config = context.getConfig();
    BlockStateProvider largeState = config.largeState();
    BlockStateProvider mediumState = config.mediumState();
    BlockStateProvider smallState = config.smallState();
    int radius = config.radius().get(random);
    int height = config.height().get(random);
    float density = config.density().get(random);
    float richness = config.richness().get(random);
    IntPoint2D[] circleCoords = ShapesUtil.getCoordinatesInCircle(radius);
    float oreRichness;
    for (IntPoint2D point : circleCoords) {
        // for each height step
        for (int y = 0; y < height; y++) {
            // for each coord in circle
            if (random.nextFloat() < density) {
                // density check
                oreRichness = (richness + ((random.nextFloat() * 2.0f) - 1.0f) * richness);
                if (oreRichness > 0.75) {
                    setBlockIfAble(structureWorldAccess, point.getOffsetBlockPos(blockPos).up(y), largeState, random);
                } else if (oreRichness > 0.3) {
                    setBlockIfAble(structureWorldAccess, point.getOffsetBlockPos(blockPos).up(y), mediumState, random);
                } else {
                    setBlockIfAble(structureWorldAccess, point.getOffsetBlockPos(blockPos).up(y), smallState, random);
                }
            }
        }
    }
    return true;
}
Also used : Random(java.util.Random) BlockPos(net.minecraft.util.math.BlockPos) IntPoint2D(net.cr24.primeval.util.IntPoint2D) BlockStateProvider(net.minecraft.world.gen.stateprovider.BlockStateProvider) StructureWorldAccess(net.minecraft.world.StructureWorldAccess)

Example 13 with StructureWorldAccess

use of net.minecraft.world.StructureWorldAccess in project Neutrino by FrostWizard4.

the class DesertWellMixin method addTerracottaPot.

@Inject(at = @At("RETURN"), method = "generate")
public void addTerracottaPot(FeatureContext<DefaultFeatureConfig> context, CallbackInfoReturnable<Boolean> cir) {
    StructureWorldAccess structureWorldAccess = context.getWorld();
    BlockPos blockPos = context.getOrigin();
    structureWorldAccess.setBlockState(blockPos.add(0, -2, 0), BlockRegistry.SWORD_SHRINE.getDefaultState(), Block.NOTIFY_LISTENERS);
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) StructureWorldAccess(net.minecraft.world.StructureWorldAccess) Inject(org.spongepowered.asm.mixin.injection.Inject)

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