Search in sources :

Example 1 with PointOfInterestManager

use of net.minecraft.village.PointOfInterestManager in project Arclight by IzzelAliz.

the class TeleporterMixin_1_15 method findPortal.

public BlockPattern.PortalInfo findPortal(BlockPos p_222272_1_, Vec3d p_222272_2_, Direction directionIn, double p_222272_4_, double p_222272_6_, boolean p_222272_8_, int searchRadius) {
    PointOfInterestManager pointofinterestmanager = this.world.getPointOfInterestManager();
    pointofinterestmanager.ensureLoadedAndValid(this.world, p_222272_1_, 128);
    List<PointOfInterest> list = pointofinterestmanager.getInSquare((p_226705_0_) -> {
        return p_226705_0_ == PointOfInterestType.NETHER_PORTAL;
    }, p_222272_1_, searchRadius, PointOfInterestManager.Status.ANY).collect(Collectors.toList());
    Optional<PointOfInterest> optional = list.stream().min(Comparator.<PointOfInterest>comparingDouble((p_226706_1_) -> {
        return p_226706_1_.getPos().distanceSq(p_222272_1_);
    }).thenComparingInt((p_226704_0_) -> {
        return p_226704_0_.getPos().getY();
    }));
    return optional.map((p_226707_7_) -> {
        BlockPos blockpos = p_226707_7_.getPos();
        this.world.getChunkProvider().registerTicket(TicketType.PORTAL, new ChunkPos(blockpos), 3, blockpos);
        BlockPattern.PatternHelper blockpattern$patternhelper = NetherPortalBlock.createPatternHelper(this.world, blockpos);
        return blockpattern$patternhelper.getPortalInfo(directionIn, blockpos, p_222272_6_, p_222272_2_, p_222272_4_);
    }).orElse(null);
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) PortalCreateEvent(org.bukkit.event.world.PortalCreateEvent) Inject(org.spongepowered.asm.mixin.injection.Inject) WorldBridge(io.izzel.arclight.common.bridge.world.WorldBridge) Random(java.util.Random) Direction(net.minecraft.util.Direction) PointOfInterestManager(net.minecraft.village.PointOfInterestManager) PointOfInterestType(net.minecraft.village.PointOfInterestType) CallbackInfoReturnable(org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable) Vec3d(net.minecraft.util.math.Vec3d) Mixin(org.spongepowered.asm.mixin.Mixin) TicketType(net.minecraft.world.server.TicketType) BlockStateListPopulator(org.bukkit.craftbukkit.v.util.BlockStateListPopulator) BlockState(net.minecraft.block.BlockState) Bukkit(org.bukkit.Bukkit) At(org.spongepowered.asm.mixin.injection.At) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Redirect(org.spongepowered.asm.mixin.injection.Redirect) ChunkPos(net.minecraft.util.math.ChunkPos) BlockPos(net.minecraft.util.math.BlockPos) Final(org.spongepowered.asm.mixin.Final) PointOfInterest(net.minecraft.village.PointOfInterest) Collectors(java.util.stream.Collectors) Blocks(net.minecraft.block.Blocks) EntityBridge(io.izzel.arclight.common.bridge.entity.EntityBridge) BlockPattern(net.minecraft.block.pattern.BlockPattern) Teleporter(net.minecraft.world.Teleporter) List(java.util.List) NetherPortalBlock(net.minecraft.block.NetherPortalBlock) MathHelper(net.minecraft.util.math.MathHelper) Shadow(org.spongepowered.asm.mixin.Shadow) Optional(java.util.Optional) Comparator(java.util.Comparator) TeleporterBridge(io.izzel.arclight.common.bridge.world.TeleporterBridge) PointOfInterest(net.minecraft.village.PointOfInterest) PointOfInterestManager(net.minecraft.village.PointOfInterestManager) BlockPos(net.minecraft.util.math.BlockPos) ChunkPos(net.minecraft.util.math.ChunkPos)

Aggregations

EntityBridge (io.izzel.arclight.common.bridge.entity.EntityBridge)1 TeleporterBridge (io.izzel.arclight.common.bridge.world.TeleporterBridge)1 WorldBridge (io.izzel.arclight.common.bridge.world.WorldBridge)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Optional (java.util.Optional)1 Random (java.util.Random)1 Collectors (java.util.stream.Collectors)1 BlockState (net.minecraft.block.BlockState)1 Blocks (net.minecraft.block.Blocks)1 NetherPortalBlock (net.minecraft.block.NetherPortalBlock)1 BlockPattern (net.minecraft.block.pattern.BlockPattern)1 Entity (net.minecraft.entity.Entity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 Direction (net.minecraft.util.Direction)1 BlockPos (net.minecraft.util.math.BlockPos)1 ChunkPos (net.minecraft.util.math.ChunkPos)1 MathHelper (net.minecraft.util.math.MathHelper)1 Vec3d (net.minecraft.util.math.Vec3d)1 PointOfInterest (net.minecraft.village.PointOfInterest)1