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