Search in sources :

Example 11 with IntegerAABBInclusive

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

the class BreakableMirror method readCustomDataFromTag.

@Override
protected void readCustomDataFromTag(CompoundTag tag) {
    super.readCustomDataFromTag(tag);
    wallArea = new IntegerAABBInclusive(new BlockPos(tag.getInt("boxXL"), tag.getInt("boxYL"), tag.getInt("boxZL")), new BlockPos(tag.getInt("boxXH"), tag.getInt("boxYH"), tag.getInt("boxZH")));
}
Also used : IntegerAABBInclusive(com.qouteall.immersive_portals.my_util.IntegerAABBInclusive) BlockPos(net.minecraft.util.math.BlockPos)

Example 12 with IntegerAABBInclusive

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

the class BreakableMirror method createMirror.

public static BreakableMirror createMirror(ServerWorld world, BlockPos glassPos, Direction facing) {
    if (!isGlass(world, glassPos)) {
        return null;
    }
    IntegerAABBInclusive wallArea = findGlassWallArea(world, glassPos, facing);
    BreakableMirror breakableMirror = BreakableMirror.entityType.create(world);
    Vec3d pos = new Vec3d((double) (wallArea.l.getX() + wallArea.h.getX()) / 2, (double) (wallArea.l.getY() + wallArea.h.getY()) / 2, (double) (wallArea.l.getZ() + wallArea.h.getZ()) / 2).add(0.5, 0.5, 0.5).add(new Vec3d(facing.getVector()).multiply(0.5));
    breakableMirror.setPosition(pos.x, pos.y, pos.z);
    breakableMirror.destination = pos;
    breakableMirror.dimensionTo = world.dimension.getType();
    Pair<Direction.Axis, Direction.Axis> axises = Helper.getPerpendicularAxis(facing);
    Direction.Axis wAxis = axises.getLeft();
    Direction.Axis hAxis = axises.getRight();
    float width = Helper.getCoordinate(wallArea.getSize(), wAxis);
    int height = Helper.getCoordinate(wallArea.getSize(), hAxis);
    breakableMirror.axisW = new Vec3d(Direction.get(Direction.AxisDirection.POSITIVE, wAxis).getVector());
    breakableMirror.axisH = new Vec3d(Direction.get(Direction.AxisDirection.POSITIVE, hAxis).getVector());
    breakableMirror.width = width;
    breakableMirror.height = height;
    breakableMirror.wallArea = wallArea;
    world.spawnEntity(breakableMirror);
    breakIntersectedMirror(breakableMirror);
    return breakableMirror;
}
Also used : IntegerAABBInclusive(com.qouteall.immersive_portals.my_util.IntegerAABBInclusive) Direction(net.minecraft.util.math.Direction) Vec3d(net.minecraft.util.math.Vec3d)

Example 13 with IntegerAABBInclusive

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

the class NetherPortalGenerator method onFireLit.

@Deprecated
public static NetherPortalGeneratedInformation onFireLit(ServerWorld fromWorld, BlockPos firePos) {
    DimensionType fromDimension = fromWorld.dimension.getType();
    DimensionType toDimension = getDestinationDimension(fromDimension);
    if (toDimension == null)
        return null;
    ObsidianFrame fromObsidianFrame = findTheObsidianFrameThatIsLighted(fromWorld, firePos);
    if (fromObsidianFrame == null)
        return null;
    ServerWorld toWorld = McHelper.getServer().getWorld(toDimension);
    assert toWorld != null;
    spawnLoadingIndicator(fromWorld, fromObsidianFrame);
    BlockPos posInOtherDimension = getPosInOtherDimension(firePos, fromDimension, toDimension);
    ObsidianFrame toObsidianFrame = findExistingEmptyObsidianFrameWithSameSizeInDestDimension(fromObsidianFrame, toWorld, posInOtherDimension, NetherPortalMatcher.findingRadius);
    IntegerAABBInclusive heightLimitInOtherDimension = NetherPortalMatcher.getHeightLimit(toDimension);
    if (toObsidianFrame == null) {
        BlockPos randomShift = getRandomShift(fromDimension);
        toObsidianFrame = createObsidianFrameInOtherDimension(fromObsidianFrame, toWorld, posInOtherDimension.add(randomShift), heightLimitInOtherDimension);
    }
    registerPortalAndGenerateContentBlocks(fromWorld, fromObsidianFrame, toWorld, toObsidianFrame);
    NetherPortalGeneratedInformation information = new NetherPortalGeneratedInformation(fromDimension, toDimension, fromObsidianFrame, toObsidianFrame);
    signalNetherPortalLit.emit(information);
    return information;
}
Also used : ServerWorld(net.minecraft.server.world.ServerWorld) DimensionType(net.minecraft.world.dimension.DimensionType) BlockPos(net.minecraft.util.math.BlockPos) IntegerAABBInclusive(com.qouteall.immersive_portals.my_util.IntegerAABBInclusive)

Example 14 with IntegerAABBInclusive

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

the class NetherPortalGenerator method spawnLoadingIndicator.

public static void spawnLoadingIndicator(ServerWorld world, ObsidianFrame obsidianFrame) {
    IntegerAABBInclusive box = obsidianFrame.boxWithoutObsidian;
    Vec3d center = new Vec3d((double) (box.h.getX() + box.l.getX() + 1) / 2, (double) (box.h.getY() + box.l.getY() + 1) / 2 - 1, (double) (box.h.getZ() + box.l.getZ() + 1) / 2);
    CustomPayloadS2CPacket packet = MyNetwork.createSpawnLoadingIndicator(world.dimension.getType(), center);
    McHelper.getEntitiesNearby(world, center, ServerPlayerEntity.class, 64).forEach(player -> player.networkHandler.sendPacket(packet));
}
Also used : CustomPayloadS2CPacket(net.minecraft.client.network.packet.CustomPayloadS2CPacket) IntegerAABBInclusive(com.qouteall.immersive_portals.my_util.IntegerAABBInclusive) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) Vec3d(net.minecraft.util.math.Vec3d)

Example 15 with IntegerAABBInclusive

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

the class NetherPortalGenerator method createObsidianFrameInOtherDimension.

// @NotNull
private static ObsidianFrame createObsidianFrameInOtherDimension(ObsidianFrame fromObsidianFrame, ServerWorld toWorld, BlockPos mappedPosInOtherDimension, IntegerAABBInclusive heightLimit) {
    Direction.Axis axis = fromObsidianFrame.normalAxis;
    BlockPos neededAreaSize = ObsidianFrame.expandToIncludeObsidianBlocks(axis, fromObsidianFrame.boxWithoutObsidian).getSize();
    IntegerAABBInclusive foundAirCube = findAirCubePlacement(toWorld, mappedPosInOtherDimension, heightLimit, axis, neededAreaSize);
    ObsidianFrame toObsidianFrame = new ObsidianFrame(axis, ObsidianFrame.shrinkToExcludeObsidianBlocks(axis, foundAirCube));
    generateObsidianFrame(toWorld, toObsidianFrame);
    return toObsidianFrame;
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) IntegerAABBInclusive(com.qouteall.immersive_portals.my_util.IntegerAABBInclusive) Direction(net.minecraft.util.math.Direction)

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