Difference between revisions of "Plugin channels/WorldEditCUI"

From wiki.vg
Jump to navigation Jump to search
(→‎Cuboid: Add example of the creating it)
(Add samples for each type of selection)
Line 40: Line 40:
  
 
An ellipsoid point with id 0 is sent for the center, and an ellipsoid point with id 1 is sent to set the radii (these are distances, not coordinates).
 
An ellipsoid point with id 0 is sent for the center, and an ellipsoid point with id 1 is sent to set the radii (these are distances, not coordinates).
 +
 +
; Current version example
 +
 +
Creates an ellipsoid at 64, 72, 48 with radii of 2, 4, and 8.
 +
 +
<pre>
 +
s|ellipsoid
 +
e|0|64|72|48
 +
e|1|2|4|8
 +
</pre>
 +
 +
Creates a sphere with a radius of 24 at 128, 128, 128.
 +
 +
<pre>
 +
s|ellipsoid
 +
e|0|128|128|128
 +
e|1|24|24|24
 +
</pre>
  
 
; Legacy versions
 
; Legacy versions
Line 56: Line 74:
  
 
A cylinder packet is sent with the center and radius, and then a min/max packet is sent to set the bottom and top of the selection.
 
A cylinder packet is sent with the center and radius, and then a min/max packet is sent to set the bottom and top of the selection.
 +
 +
; Current version example
 +
 +
Creates a cylinder centered on 24, 24 with radii of 8 and 4 starting at y=32 and ending at y=64.
 +
 +
<pre>
 +
s|cylinder
 +
cyl|24|48|24|8|4
 +
mm|32|64
 +
</pre>
  
 
; Legacy versions
 
; Legacy versions
Line 72: Line 100:
  
 
For all of the points in the selection, a Point 2D packet is sent with the point's x and z coordinates.  Then, a min/max packet is sent to set the bottom and top of the selection.
 
For all of the points in the selection, a Point 2D packet is sent with the point's x and z coordinates.  Then, a min/max packet is sent to set the bottom and top of the selection.
 +
 +
; Current version example
 +
 +
Creates a rotated square around 0, 0 that starts at y=32 and ends at y=70.
 +
 +
<pre>
 +
s|polygon2d
 +
p2|0|0|25|1
 +
p2|1|25|0|25
 +
p2|2|0|-25|625
 +
p2|3|-25|0|1250
 +
mm|32|70
 +
</pre>
  
 
=== 3D Polyhedron ===
 
=== 3D Polyhedron ===
Line 85: Line 126:
 
For each point in the polyhedron, a Point packet is sent with the x, y, and z coordinates.  Then, for each triangle in the selection, a Polygon packet is sent with vertices set to the index of each point that makes up the triangle.
 
For each point in the polyhedron, a Point packet is sent with the x, y, and z coordinates.  Then, for each triangle in the selection, a Polygon packet is sent with vertices set to the index of each point that makes up the triangle.
  
 +
; Current version example
 +
 +
Creates a [[Wikipedia:tetrahedron|tetrahedron]] around 9, 9, 9.
 +
 +
<pre>
 +
s|polyhedron
 +
p|0|8|8|8|1
 +
p|1|8|8|10|3
 +
p|2|10|8|9|6
 +
p|3|9|10|9|10
 +
poly|0|1|2
 +
poly|0|1|3
 +
poly|0|2|3
 +
poly|1|2|3
 +
</pre>
 
; Legacy versions
 
; Legacy versions
  

Revision as of 16:22, 3 March 2016

WorldEdit uses plugin channels to communicate with the clientside WorldEditCUI mod to display selections. Client-side source code: https://github.com/Mumfrey/WorldEditCUI/

This is a (very) rough documentation of those channels that I'll improve.

Selection types

There are several types of selections. Each type has a format used with current versions of WorldEditCUI and a second format used in older versions (usually a cube with similar edges).

Cuboid

A basic rectangular selection, with minimum and maximum points.

Minimum protocol version: 0

Current version and legacy versions

Shape ID is cuboid.

If the selection has a position one (left click), it is sent with as a Point with an id of 0. If the selection has a position two (right click), it is sent with as a Point with an id of 1.

Current version example

Creating a cuboid from (9, 25, 32) to (19, 26, 45):

s|cuboid
p|0|9|25|32|1
p|1|19|26|45|308

Ellipsoid

Ellipsoid selections form 3-dimensional ellipses and spheres. They have a center, and then x, y, and z radii (measured from the center).

Minimum protocol version: 1

Current version

Shape ID is ellipsoid.

An ellipsoid point with id 0 is sent for the center, and an ellipsoid point with id 1 is sent to set the radii (these are distances, not coordinates).

Current version example

Creates an ellipsoid at 64, 72, 48 with radii of 2, 4, and 8.

s|ellipsoid
e|0|64|72|48
e|1|2|4|8

Creates a sphere with a radius of 24 at 128, 128, 128.

s|ellipsoid
e|0|128|128|128
e|1|24|24|24
Legacy versions

Ellipsoid regions are sent as cuboids with their minimum and maximum positions in legacy versions.

Cylinder

A vertical cylinder selection.

Minimum protocol version: 1

Current version

Shape ID is cylinder.

A cylinder packet is sent with the center and radius, and then a min/max packet is sent to set the bottom and top of the selection.

Current version example

Creates a cylinder centered on 24, 24 with radii of 8 and 4 starting at y=32 and ending at y=64.

s|cylinder
cyl|24|48|24|8|4
mm|32|64
Legacy versions

Sent as a cuboid with the minimum and maximum positions.

2D Polygon

A 2-dimensional, flat polygon.

Minimum protocol version: 0

Current and legacy versions

Shape ID: polygon2d

For all of the points in the selection, a Point 2D packet is sent with the point's x and z coordinates. Then, a min/max packet is sent to set the bottom and top of the selection.

Current version example

Creates a rotated square around 0, 0 that starts at y=32 and ends at y=70.

s|polygon2d
p2|0|0|25|1
p2|1|25|0|25
p2|2|0|-25|625
p2|3|-25|0|1250
mm|32|70

3D Polyhedron

A 3-dimensional polygonal selection.

Minimum protocol version: 3

Current version

Shape ID is polyhedron.

For each point in the polyhedron, a Point packet is sent with the x, y, and z coordinates. Then, for each triangle in the selection, a Polygon packet is sent with vertices set to the index of each point that makes up the triangle.

Current version example

Creates a tetrahedron around 9, 9, 9.

s|polyhedron
p|0|8|8|8|1
p|1|8|8|10|3
p|2|10|8|9|6
p|3|9|10|9|10
poly|0|1|2
poly|0|1|3
poly|0|2|3
poly|1|2|3
Legacy versions

Sent as a cuboid with the minimum and maximum positions.

Packet structure

All communication is performed over the WECUI plugin channel. The content sent on this channel is sent in the form of UTF8 strings, which are not length prefixed and take up the whole channel (length can be determined from the rest of the plugin channel packet's structure). In other words, the entire payload is a single string.

The content of the String is first an action, followed by a list of parameters separated by |. To enable this packet, the client must first REGISTER the channel and then send a version packet.

Version

Parsed in LocalSession.java

The version packet tells the server what types of selections it understands. The version is a single integer, currently ranging from 0 to 3. See the list of selection types for what various versions control.

v|{version}

Example:

v|3 tells the server that it is running the latest version.

Shape

The s packet tells the client the current selection shape. The shape is determined from the shape ID of the selection (or its legacy shape ID). Upon receiving this packet, all other data about the current selection is cleared by the client - the remaining data needs to be resent afterwards.

s|{shape}

Example:

s|cuboid sets the current shape to cuboid and clears the current points on the selection.

Point

The p packet sets the location of one of the points in the current selection. It has 5 fields, the ID, the x, y, and z coordinates, and the total area of the selection.

The significance of each ID is defined by the current selection shape; they may be corners or vertices.

p|{id}|{x}|{y}|{z}|{total area}

Example:

p|0|4|5|6|1 sets the first selection point to 4, 5, 6 in a cuboid selection. p|1|9|7|5|10 sets the second selection point to 9, 7, 5 in a cuboid selection, and (when following the previous selection) completes a cuboid from 4, 5, 6 to 9, 7, 5.

Ellipsoid Point

The e packet sets information about ellipsoids. It has 4 fields: the id, and x, y, and z values. If ID is 0, x, y, and z represent the center of the ellipsoid; if it's 1, x, y, and z are radii.

e|{id}|{x}|{y}|{z}

Example:

e|0|10|42|30 sets the center of the ellipsoid to 10, 42, 30. e|1|5|4|3 sets the radii to 5, 4, and 3. e|1|9|9|9 makes the ellipsoid a sphere with radius of 9.

Point 2D

The p2 packet sets the location of one of the points in the current selection, two-dimensionally. It has 4 fields: the id, the block x and z, and the total area. This packet is used with polygonal selections, so there is no cap on the maximum ID.

p2|{id}|{x}|{z}|{area}

Example:

p2|0|4|9|1 sets the first point to 4, 9.

Cylinder

The cyl packet sets info about a cylindrical selection. It has 5 fields: the x, y, and z of the center and then the radius x and z. The y coordinate is the center of the cylinder; the height is later set with min/max.

cyl|{centerX}|{centerY}|{centerZ}|{radX}|{radZ}

Example:

cyl|5|10|5|2|2 creates a cylinder centered on 5, 10, 5 with a radius of 2.

Min/Max

The mm packet sets minimum and maximum Y coordinates of a 2D selection. It has two fields, the minimum and the maximum.

mm|{min}|{max}

Example:

mm|7|20 sets the minimum Y coordinate to 7 and the maximum Y coordinate to 20.

Polygon

The poly packet sets polygons in a polyhedral selection. It has an array of 3 (although it may be possible to add more) values, which are indexes in the points list. Multiple poly packets do not overwrite the first one but instead add additional polygons.

poly|{vertex1}|{vertex2}|{vertex3}

Example:

poly|0|1|2 creates a triangle with vertices of point 0, point 1, and point 2.