Search in sources :

Example 1 with SpecialPortalShape

use of com.qouteall.immersive_portals.portal.SpecialPortalShape in project ImmersivePortalsMod by qouteall.

the class MyCommandServer method completeBiFacedPortal.

private static Portal completeBiFacedPortal(Portal portal, Consumer<Portal> removalInformer) {
    ServerWorld world = ((ServerWorld) portal.world);
    removeOverlappedPortals(world, portal.getPos(), portal.getNormal().multiply(-1), removalInformer);
    Portal newPortal = Portal.entityType.create(world);
    newPortal.dimensionTo = portal.dimensionTo;
    newPortal.setPosition(portal.x, portal.y, portal.z);
    newPortal.destination = portal.destination;
    newPortal.loadFewerChunks = portal.loadFewerChunks;
    newPortal.specificPlayer = portal.specificPlayer;
    newPortal.width = portal.width;
    newPortal.height = portal.height;
    newPortal.axisW = portal.axisW;
    newPortal.axisH = portal.axisH.multiply(-1);
    if (portal.specialShape != null) {
        newPortal.specialShape = new SpecialPortalShape();
        initFlippedShape(newPortal, portal.specialShape);
    }
    world.spawnEntity(newPortal);
    return newPortal;
}
Also used : ServerWorld(net.minecraft.server.world.ServerWorld) SpecialPortalShape(com.qouteall.immersive_portals.portal.SpecialPortalShape) VerticalConnectingPortal(com.qouteall.immersive_portals.portal.global_portals.VerticalConnectingPortal) Portal(com.qouteall.immersive_portals.portal.Portal) BorderPortal(com.qouteall.immersive_portals.portal.global_portals.BorderPortal)

Example 2 with SpecialPortalShape

use of com.qouteall.immersive_portals.portal.SpecialPortalShape in project ImmersivePortalsMod by qouteall.

the class NetherPortalShape method initPortalPosAxisShape.

public void initPortalPosAxisShape(Portal portal, boolean doInvert) {
    Vec3d center = innerAreaBox.getCenterVec();
    portal.setPosition(center.x, center.y, center.z);
    Direction[] anotherFourDirections = Helper.getAnotherFourDirections(axis);
    Direction wDirection;
    Direction hDirection;
    if (doInvert) {
        wDirection = anotherFourDirections[0];
        hDirection = anotherFourDirections[1];
    } else {
        wDirection = anotherFourDirections[1];
        hDirection = anotherFourDirections[0];
    }
    portal.axisW = new Vec3d(wDirection.getVector());
    portal.axisH = new Vec3d(hDirection.getVector());
    portal.width = Helper.getCoordinate(innerAreaBox.getSize(), wDirection.getAxis());
    portal.height = Helper.getCoordinate(innerAreaBox.getSize(), hDirection.getAxis());
    SpecialPortalShape shape = new SpecialPortalShape();
    Vec3d offset = new Vec3d(Direction.get(Direction.AxisDirection.POSITIVE, axis).getVector()).multiply(0.5);
    for (BlockPos blockPos : area) {
        Vec3d p1 = new Vec3d(blockPos).add(offset);
        Vec3d p2 = new Vec3d(blockPos).add(1, 1, 1).add(offset);
        double p1LocalX = p1.subtract(center).dotProduct(portal.axisW);
        double p1LocalY = p1.subtract(center).dotProduct(portal.axisH);
        double p2LocalX = p2.subtract(center).dotProduct(portal.axisW);
        double p2LocalY = p2.subtract(center).dotProduct(portal.axisH);
        shape.addTriangleForRectangle(p1LocalX, p1LocalY, p2LocalX, p2LocalY);
    }
    portal.specialShape = shape;
}
Also used : SpecialPortalShape(com.qouteall.immersive_portals.portal.SpecialPortalShape) BlockPos(net.minecraft.util.math.BlockPos) Direction(net.minecraft.util.math.Direction) Vec3d(net.minecraft.util.math.Vec3d)

Example 3 with SpecialPortalShape

use of com.qouteall.immersive_portals.portal.SpecialPortalShape in project ImmersivePortalsMod by qouteall.

the class ViewAreaRenderer method generateTriangleSpecialWithOffset.

private static void generateTriangleSpecialWithOffset(Consumer<Vec3d> vertexOutput, Portal portal, Vec3d posInPlayerCoordinate, Vec3d offset) {
    SpecialPortalShape specialShape = portal.specialShape;
    for (SpecialPortalShape.TriangleInPlane triangle : specialShape.triangles) {
        putIntoLocalVertex(vertexOutput, portal, offset, posInPlayerCoordinate, triangle.x1, triangle.y1);
        putIntoLocalVertex(vertexOutput, portal, offset, posInPlayerCoordinate, triangle.x3, triangle.y3);
        putIntoLocalVertex(vertexOutput, portal, offset, posInPlayerCoordinate, triangle.x2, triangle.y2);
    }
}
Also used : SpecialPortalShape(com.qouteall.immersive_portals.portal.SpecialPortalShape)

Example 4 with SpecialPortalShape

use of com.qouteall.immersive_portals.portal.SpecialPortalShape in project ImmersivePortalsMod by qouteall.

the class MyCommandServer method completeBiWayPortal.

private static Portal completeBiWayPortal(Portal portal, Consumer<Portal> removalInformer) {
    ServerWorld toWorld = McHelper.getServer().getWorld(portal.dimensionTo);
    removeOverlappedPortals(toWorld, portal.destination, portal.getNormal().multiply(-1), removalInformer);
    Portal newPortal = Portal.entityType.create(toWorld);
    newPortal.dimensionTo = portal.dimension;
    newPortal.setPosition(portal.destination.x, portal.destination.y, portal.destination.z);
    newPortal.destination = portal.getPos();
    newPortal.loadFewerChunks = portal.loadFewerChunks;
    newPortal.specificPlayer = portal.specificPlayer;
    newPortal.width = portal.width;
    newPortal.height = portal.height;
    newPortal.axisW = portal.axisW;
    newPortal.axisH = portal.axisH.multiply(-1);
    if (portal.specialShape != null) {
        newPortal.specialShape = new SpecialPortalShape();
        initFlippedShape(newPortal, portal.specialShape);
    }
    toWorld.spawnEntity(newPortal);
    return newPortal;
}
Also used : ServerWorld(net.minecraft.server.world.ServerWorld) SpecialPortalShape(com.qouteall.immersive_portals.portal.SpecialPortalShape) VerticalConnectingPortal(com.qouteall.immersive_portals.portal.global_portals.VerticalConnectingPortal) Portal(com.qouteall.immersive_portals.portal.Portal) BorderPortal(com.qouteall.immersive_portals.portal.global_portals.BorderPortal)

Aggregations

SpecialPortalShape (com.qouteall.immersive_portals.portal.SpecialPortalShape)4 Portal (com.qouteall.immersive_portals.portal.Portal)2 BorderPortal (com.qouteall.immersive_portals.portal.global_portals.BorderPortal)2 VerticalConnectingPortal (com.qouteall.immersive_portals.portal.global_portals.VerticalConnectingPortal)2 ServerWorld (net.minecraft.server.world.ServerWorld)2 BlockPos (net.minecraft.util.math.BlockPos)1 Direction (net.minecraft.util.math.Direction)1 Vec3d (net.minecraft.util.math.Vec3d)1