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;
}
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;
}
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);
}
}
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;
}
Aggregations