allow for discrete snapping of drawn shapes
This commit is contained in:
1 parent
bd397ae772
commit
ca0ddbb9e2
3 files changed
+21
-6
No files matched your search
@@ -3405,7 +3405,8 @@ Optional shared shape attributes:
|
|||||||
* `snap` - if `follow` is present, indicated on which axis the snapping to entity coordinates occurs, and which axis
|
* `snap` - if `follow` is present, indicated on which axis the snapping to entity coordinates occurs, and which axis
|
||||||
will be treated statically, i.e. the coordinate passed in a coord triple is the actual value in the world. Default
|
will be treated statically, i.e. the coordinate passed in a coord triple is the actual value in the world. Default
|
||||||
value is `'xyz'`, meaning the shape will be drawn relatively to the entity in all three directions. Using `xz` for
|
value is `'xyz'`, meaning the shape will be drawn relatively to the entity in all three directions. Using `xz` for
|
||||||
instance makes so that the shape follows the entity, but stays at the same, absolute Y coordinate.
|
instance makes so that the shape follows the entity, but stays at the same, absolute Y coordinate. Preceeding an axis
|
||||||
|
with `d`, like `dxdydz` would make so that entity position is treated discretely (rounded down).
|
||||||
|
|
||||||
Available shapes:
|
Available shapes:
|
||||||
* `'line'` - draws a straight line between two points.
|
* `'line'` - draws a straight line between two points.
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ Optional shared shape attributes:
|
|||||||
* `snap` - if `follow` is present, indicated on which axis the snapping to entity coordinates occurs, and which axis
|
* `snap` - if `follow` is present, indicated on which axis the snapping to entity coordinates occurs, and which axis
|
||||||
will be treated statically, i.e. the coordinate passed in a coord triple is the actual value in the world. Default
|
will be treated statically, i.e. the coordinate passed in a coord triple is the actual value in the world. Default
|
||||||
value is `'xyz'`, meaning the shape will be drawn relatively to the entity in all three directions. Using `xz` for
|
value is `'xyz'`, meaning the shape will be drawn relatively to the entity in all three directions. Using `xz` for
|
||||||
instance makes so that the shape follows the entity, but stays at the same, absolute Y coordinate.
|
instance makes so that the shape follows the entity, but stays at the same, absolute Y coordinate. Preceeding an axis
|
||||||
|
with `d`, like `dxdydz` would make so that entity position is treated discretely (rounded down).
|
||||||
|
|
||||||
Available shapes:
|
Available shapes:
|
||||||
* `'line'` - draws a straight line between two points.
|
* `'line'` - draws a straight line between two points.
|
||||||
|
|||||||
@@ -256,6 +256,7 @@ public class ShapeDispatcher
|
|||||||
protected int followEntity;
|
protected int followEntity;
|
||||||
protected String snapTo;
|
protected String snapTo;
|
||||||
protected boolean snapX, snapY, snapZ;
|
protected boolean snapX, snapY, snapZ;
|
||||||
|
protected boolean discreteX, discreteY, discreteZ;
|
||||||
public DimensionType shapeDimension;
|
public DimensionType shapeDimension;
|
||||||
|
|
||||||
|
|
||||||
@@ -318,15 +319,18 @@ public class ShapeDispatcher
|
|||||||
snapX = snapTo.contains("x");
|
snapX = snapTo.contains("x");
|
||||||
snapY = snapTo.contains("y");
|
snapY = snapTo.contains("y");
|
||||||
snapZ = snapTo.contains("z");
|
snapZ = snapTo.contains("z");
|
||||||
|
discreteX = snapTo.contains("dx");
|
||||||
|
discreteY = snapTo.contains("dy");
|
||||||
|
discreteZ = snapTo.contains("dz");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public int getExpiry() { return duration; }
|
public int getExpiry() { return duration; }
|
||||||
public Vec3d toAbsolute(Entity e, Vec3d vec, float partialTick)
|
public Vec3d toAbsolute(Entity e, Vec3d vec, float partialTick)
|
||||||
{
|
{
|
||||||
return vec.add(
|
return vec.add(
|
||||||
snapX?MathHelper.lerp(partialTick, e.prevX, e.getX()):0.0,
|
snapX?(discreteX ?MathHelper.floor(e.getX()):MathHelper.lerp(partialTick, e.prevX, e.getX())):0.0,
|
||||||
snapY?MathHelper.lerp(partialTick, e.prevY, e.getY()):0.0,
|
snapY?(discreteY ?MathHelper.floor(e.getY()):MathHelper.lerp(partialTick, e.prevY, e.getY())):0.0,
|
||||||
snapZ?MathHelper.lerp(partialTick, e.prevZ, e.getZ()):0.0
|
snapZ?(discreteZ ?MathHelper.floor(e.getZ()):MathHelper.lerp(partialTick, e.prevZ, e.getZ())):0.0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
public Vec3d relativiseRender(World world, Vec3d vec, float partialTick)
|
public Vec3d relativiseRender(World world, Vec3d vec, float partialTick)
|
||||||
@@ -369,6 +373,10 @@ public class ShapeDispatcher
|
|||||||
hash ^= shapeDimension.hashCode(); hash *= 1099511628211L;
|
hash ^= shapeDimension.hashCode(); hash *= 1099511628211L;
|
||||||
hash ^= color; hash *= 1099511628211L;
|
hash ^= color; hash *= 1099511628211L;
|
||||||
hash ^= followEntity; hash *= 1099511628211L;
|
hash ^= followEntity; hash *= 1099511628211L;
|
||||||
|
if (followEntity >= 0)
|
||||||
|
{
|
||||||
|
hash ^= snapTo.hashCode(); hash *= 1099511628211L;
|
||||||
|
}
|
||||||
hash ^= Float.hashCode(lineWidth); hash *= 1099511628211L;
|
hash ^= Float.hashCode(lineWidth); hash *= 1099511628211L;
|
||||||
if (fa != 0.0) { hash = 31*hash + fillColor; hash *= 1099511628211L; }
|
if (fa != 0.0) { hash = 31*hash + fillColor; hash *= 1099511628211L; }
|
||||||
return hash;
|
return hash;
|
||||||
@@ -829,7 +837,12 @@ public class ShapeDispatcher
|
|||||||
put("duration", new NonNegativeIntParam("duration"));
|
put("duration", new NonNegativeIntParam("duration"));
|
||||||
put("color", new ColorParam("color"));
|
put("color", new ColorParam("color"));
|
||||||
put("follow", new EntityParam("follow"));
|
put("follow", new EntityParam("follow"));
|
||||||
put("snap", new StringChoiceParam("snap", "xyz", "xz", "yz", "xy", "x", "y", "z"));
|
put("snap", new StringChoiceParam("snap",
|
||||||
|
"xyz", "xz", "yz", "xy", "x", "y", "z",
|
||||||
|
"dxdydz", "dxdz", "dydz", "dxdy", "dx", "dy", "dz",
|
||||||
|
"xdz", "dxz", "ydz", "dyz", "xdy", "dxy",
|
||||||
|
"xydz", "xdyz", "xdydz", "dxyz", "dxydz", "dxdyz"
|
||||||
|
));
|
||||||
put("line", new PositiveFloatParam("line"));
|
put("line", new PositiveFloatParam("line"));
|
||||||
put("fill", new ColorParam("fill"));
|
put("fill", new ColorParam("fill"));
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user