Search in sources :

Example 1 with FeaturePhaseContext

use of org.spongepowered.common.event.tracking.phase.generation.FeaturePhaseContext in project SpongeCommon by SpongePowered.

the class EndDragonFightMixin_Tracker method tracker$switchToFeatureState.

// @formatter:on
@Redirect(method = "spawnNewGateway(Lnet/minecraft/core/BlockPos;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/levelgen/feature/ConfiguredFeature;place(Lnet/minecraft/world/level/WorldGenLevel;Lnet/minecraft/world/level/chunk/ChunkGenerator;Ljava/util/Random;Lnet/minecraft/core/BlockPos;)Z"))
private boolean tracker$switchToFeatureState(final ConfiguredFeature configuredFeature, final WorldGenLevel worldIn, final ChunkGenerator generator, final Random rand, final BlockPos pos) {
    try (final FeaturePhaseContext context = GenerationPhase.State.FEATURE_PLACEMENT.createPhaseContext(PhaseTracker.SERVER)) {
        context.world((ServerLevel) worldIn).generator(generator).feature(configuredFeature.feature).origin(pos);
        context.buildAndSwitch();
        return configuredFeature.place(worldIn, generator, rand, pos);
    }
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) FeaturePhaseContext(org.spongepowered.common.event.tracking.phase.generation.FeaturePhaseContext) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Aggregations

ServerLevel (net.minecraft.server.level.ServerLevel)1 Redirect (org.spongepowered.asm.mixin.injection.Redirect)1 FeaturePhaseContext (org.spongepowered.common.event.tracking.phase.generation.FeaturePhaseContext)1