Search in sources :

Example 6 with IntegerAABBInclusive

use of com.qouteall.immersive_portals.my_util.IntegerAABBInclusive in project ImmersivePortalsMod by qouteall.

the class NetherPortalMatcher method findHorizontalPortalPlacementWithVerticalSpaceReserved.

private static IntegerAABBInclusive findHorizontalPortalPlacementWithVerticalSpaceReserved(BlockPos areaSize, IWorld world, BlockPos searchingCenter, IntegerAABBInclusive heightLimit, int verticalSpaceReserve) {
    BlockPos growVertically = new BlockPos(areaSize.getX(), verticalSpaceReserve, areaSize.getZ());
    IntegerAABBInclusive foundCubeArea = findCubeAirAreaAtAnywhere(growVertically, world, searchingCenter, heightLimit, findingRadius);
    if (foundCubeArea == null) {
        return null;
    }
    return foundCubeArea.getSubBoxInCenter(areaSize);
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) IntegerAABBInclusive(com.qouteall.immersive_portals.my_util.IntegerAABBInclusive)

Example 7 with IntegerAABBInclusive

use of com.qouteall.immersive_portals.my_util.IntegerAABBInclusive in project ImmersivePortalsMod by qouteall.

the class BorderPortal method setBorderPortal.

public static void setBorderPortal(ServerWorld world, int x1, int y1, int x2, int y2) {
    GlobalPortalStorage storage = GlobalPortalStorage.get(world);
    storage.data.removeIf(portal -> portal instanceof BorderPortal);
    IntegerAABBInclusive box = new IntegerAABBInclusive(new BlockPos(x1, 0, y1), new BlockPos(x2, 256, y2)).getSorted();
    Box area = box.toRealNumberBox();
    storage.data.add(createWrappingPortal(world, area, Direction.NORTH));
    storage.data.add(createWrappingPortal(world, area, Direction.SOUTH));
    storage.data.add(createWrappingPortal(world, area, Direction.WEST));
    storage.data.add(createWrappingPortal(world, area, Direction.EAST));
    storage.onDataChanged();
}
Also used : IntegerAABBInclusive(com.qouteall.immersive_portals.my_util.IntegerAABBInclusive) BlockPos(net.minecraft.util.math.BlockPos) Box(net.minecraft.util.math.Box)

Example 8 with IntegerAABBInclusive

use of com.qouteall.immersive_portals.my_util.IntegerAABBInclusive in project ImmersivePortalsMod by qouteall.

the class NetherPortalGenerator method generateObsidianFrame.

private static void generateObsidianFrame(ServerWorld world, ObsidianFrame obsidianFrame) {
    Direction.Axis axisOfNormal = obsidianFrame.normalAxis;
    IntegerAABBInclusive boxIncludingObsidianFrame = ObsidianFrame.expandToIncludeObsidianBlocks(axisOfNormal, obsidianFrame.boxWithoutObsidian);
    Arrays.stream(Helper.getAnotherFourDirections(axisOfNormal)).forEach(facing -> boxIncludingObsidianFrame.getSurfaceLayer(facing).stream().forEach(blockPos -> setObsidian(world, blockPos)));
}
Also used : MyNetwork(com.qouteall.immersive_portals.MyNetwork) Arrays(java.util.Arrays) ServerWorld(net.minecraft.server.world.ServerWorld) BlockPos(net.minecraft.util.math.BlockPos) Random(java.util.Random) Helper(com.qouteall.immersive_portals.Helper) IntegerAABBInclusive(com.qouteall.immersive_portals.my_util.IntegerAABBInclusive) Blocks(net.minecraft.block.Blocks) Direction(net.minecraft.util.math.Direction) Objects(java.util.Objects) McHelper(com.qouteall.immersive_portals.McHelper) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) Vec3d(net.minecraft.util.math.Vec3d) DimensionType(net.minecraft.world.dimension.DimensionType) Portal(com.qouteall.immersive_portals.portal.Portal) PortalPlaceholderBlock(com.qouteall.immersive_portals.portal.PortalPlaceholderBlock) SignalArged(com.qouteall.immersive_portals.my_util.SignalArged) CustomPayloadS2CPacket(net.minecraft.client.network.packet.CustomPayloadS2CPacket) IntegerAABBInclusive(com.qouteall.immersive_portals.my_util.IntegerAABBInclusive) Direction(net.minecraft.util.math.Direction)

Example 9 with IntegerAABBInclusive

use of com.qouteall.immersive_portals.my_util.IntegerAABBInclusive in project ImmersivePortalsMod by qouteall.

the class NetherPortalGenerator method findAirCubePlacement.

public static IntegerAABBInclusive findAirCubePlacement(ServerWorld toWorld, BlockPos mappedPosInOtherDimension, IntegerAABBInclusive heightLimit, Direction.Axis axis, BlockPos neededAreaSize) {
    IntegerAABBInclusive foundAirCube = axis == Direction.Axis.Y ? NetherPortalMatcher.findHorizontalPortalPlacement(neededAreaSize, toWorld, mappedPosInOtherDimension, heightLimit, NetherPortalMatcher.findingRadius) : NetherPortalMatcher.findVerticalPortalPlacement(neededAreaSize, toWorld, mappedPosInOtherDimension, heightLimit, NetherPortalMatcher.findingRadius);
    if (foundAirCube == null) {
        Helper.log("Cannot find normal portal placement");
        foundAirCube = NetherPortalMatcher.findCubeAirAreaAtAnywhere(neededAreaSize, toWorld, mappedPosInOtherDimension, heightLimit, NetherPortalMatcher.findingRadius);
    }
    if (foundAirCube == null) {
        Helper.err("No place to put portal? " + "Force placed portal. It will occupy normal blocks.");
        foundAirCube = IntegerAABBInclusive.getBoxByBasePointAndSize(neededAreaSize, mappedPosInOtherDimension);
    }
    return foundAirCube;
}
Also used : IntegerAABBInclusive(com.qouteall.immersive_portals.my_util.IntegerAABBInclusive)

Example 10 with IntegerAABBInclusive

use of com.qouteall.immersive_portals.my_util.IntegerAABBInclusive in project ImmersivePortalsMod by qouteall.

the class NetherPortalMatcher method findVerticalPortalPlacement.

// ------------------------------------------------------------
// detect air cube on ground
static IntegerAABBInclusive findVerticalPortalPlacement(BlockPos areaSize, IWorld world, BlockPos searchingCenter, IntegerAABBInclusive heightLimit, int findingRadius) {
    IntegerAABBInclusive aboveLavaLake = getAirCubeOnGround(areaSize.add(20, 20, 20), world, searchingCenter, heightLimit, findingRadius / 4, blockPos -> isLavaLake(world, blockPos));
    if (aboveLavaLake != null) {
        Helper.log("Generated Portal Above Lava Lake");
        return aboveLavaLake.getSubBoxInCenter(areaSize);
    }
    Helper.log("Generated Portal On Ground");
    IntegerAABBInclusive biggerArea = getAirCubeOnSolidGround(areaSize.add(6, 0, 6), world, searchingCenter, heightLimit, findingRadius);
    return pushDownBox(world, biggerArea.getSubBoxInCenter(areaSize));
}
Also used : IntegerAABBInclusive(com.qouteall.immersive_portals.my_util.IntegerAABBInclusive)

Aggregations

IntegerAABBInclusive (com.qouteall.immersive_portals.my_util.IntegerAABBInclusive)16 BlockPos (net.minecraft.util.math.BlockPos)10 Direction (net.minecraft.util.math.Direction)6 DimensionType (net.minecraft.world.dimension.DimensionType)5 Helper (com.qouteall.immersive_portals.Helper)4 Arrays (java.util.Arrays)4 Objects (java.util.Objects)4 Blocks (net.minecraft.block.Blocks)4 Vec3d (net.minecraft.util.math.Vec3d)4 ServerWorld (net.minecraft.server.world.ServerWorld)3 McHelper (com.qouteall.immersive_portals.McHelper)2 PortalPlaceholderBlock (com.qouteall.immersive_portals.portal.PortalPlaceholderBlock)2 Optional (java.util.Optional)2 Predicate (java.util.function.Predicate)2 IntStream (java.util.stream.IntStream)2 Stream (java.util.stream.Stream)2 CustomPayloadS2CPacket (net.minecraft.client.network.packet.CustomPayloadS2CPacket)2 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)2 Pair (net.minecraft.util.Pair)2 Vec3i (net.minecraft.util.math.Vec3i)2