@@ -261,36 +261,6 @@ default void scale(PoseStack pose, float scaleFactor) {
261261 pose .scale (scaleFactor , scaleFactor , scaleFactor );
262262 }
263263
264- /**
265- * Transforms and scales a pose so that 1 block in world space == 1 pixel in radar space.
266- *
267- * @param poseStack The {@link PoseStack} to transform
268- * @param rrd The {@link RadarRenderData}
269- * @since 0.16.1.0-rc2
270- */
271- default void poseToRadarSpace (PoseStack poseStack , RadarRenderData rrd ) {
272- float wtrRatio = (rrd .sizeRenderDiameter () / 2.0F ) / rrd .simSize ();
273-
274- poseStack .translate (0 , 0.055f , 0 );
275- poseStack .scale (wtrRatio , 1 , wtrRatio );
276- poseStack .translate (-rrd .radarX () - 0.5f , 0f , -rrd .radarZ () - 0.5f );
277- }
278-
279- /**
280- * Goes to the given {@link Vec3} relative to the radar's position.
281- * Uses {@link #poseToRadarSpace(PoseStack, RadarRenderData)} and {@link #poseToWorldSpace(PoseStack, RadarRenderData)}
282- *
283- * @param location The {@link Vec3} of the absolute location
284- * @param poseStack The {@link PoseStack}
285- * @param rrd The {@link RadarRenderData}
286- * @since 0.16.1.0-rc2
287- */
288- default void placeOnRadar (Vec3 location , PoseStack poseStack , RadarRenderData rrd ) {
289- poseToRadarSpace (poseStack , rrd );
290- poseStack .translate (location .x , 0 , location .z );
291- poseToWorldSpace (poseStack , rrd );
292- }
293-
294264 /**
295265 * Orients a {@link PoseStack} to face upwards.
296266 * May not work if other rotations are present!
@@ -324,6 +294,42 @@ default void flipPose(PoseStack poseStack, Axis axis) {
324294 poseStack .mulPose (axis .rotationDegrees (180 ));
325295 }
326296
297+ /**
298+ * Goes to the given {@link Vec3} relative to the radar's position.
299+ * Uses {@link #poseToRadarSpace(PoseStack, RadarRenderData)} and {@link #poseToWorldSpace(PoseStack, RadarRenderData)}
300+ *
301+ * @param location The {@link Vec3} of the absolute location
302+ * @param poseStack The {@link PoseStack}
303+ * @param rrd The {@link RadarRenderData}
304+ * @since 0.16.1.0-rc2
305+ */
306+ default void placeOnRadar (Vec3 location , PoseStack poseStack , RadarRenderData rrd ) {
307+ double dx = location .x - (rrd .radarX () + 0.5D );
308+ double dz = location .z - (rrd .radarZ () + 0.5D );
309+
310+ float ratio = (rrd .sizeRenderDiameter () / 2.0F ) / rrd .simSize ();
311+ poseStack .translate (dx * ratio , 0.01f , dz * ratio );
312+ //
313+ // poseToRadarSpace(poseStack, rrd);
314+ // poseStack.translate(location.x, 0, location.z);
315+ // poseToWorldSpace(poseStack, rrd);
316+ }
317+
318+ /**
319+ * Transforms and scales a pose so that 1 block in world space == 1 pixel in radar space.
320+ *
321+ * @param poseStack The {@link PoseStack} to transform
322+ * @param rrd The {@link RadarRenderData}
323+ * @since 0.16.1.0-rc2
324+ */
325+ default void poseToRadarSpace (PoseStack poseStack , RadarRenderData rrd ) {
326+ float wtrRatio = (rrd .sizeRenderDiameter () / 2.0F ) / rrd .simSize ();
327+
328+ poseStack .translate (0 , 0.055f , 0 );
329+ poseStack .scale (wtrRatio , 1 , wtrRatio );
330+ poseStack .translate (-rrd .radarX () - 0.5f , 0f , -rrd .radarZ () - 0.5f );
331+ }
332+
327333 /**
328334 * Translates a {@link Vec3} of absolute coordinates to a {@link Vec3} of radar coordinates
329335 *
@@ -336,7 +342,6 @@ default Vec3 worldToRadarCoords(Vec3 pos, RadarRenderData rrd) {
336342 return worldToRadarCoords (pos , rrd .blockEntity ().getBlockPos (), rrd .sizeRenderDiameter (), rrd .simSize ());
337343 }
338344
339-
340345 /**
341346 * Translates a {@link Vec3} of absolute coordinates to a {@link Vec3} of radar coordinates
342347 *
@@ -351,7 +356,6 @@ default Vec3 worldToRadarCoords(Vec3 pos, BlockPos radarPos, float sizeRenderDia
351356 return worldToRadarCoords (pos .x , pos .z , radarPos , sizeRenderDiameter , simSize );
352357 }
353358
354-
355359 /**
356360 * Translates absolute coordinates to a {@link Vec3} of radar coordinates
357361 *
@@ -365,7 +369,6 @@ default Vec3 worldToRadarCoords(double x, double z, RadarRenderData rrd) {
365369 return worldToRadarCoords (x , z , rrd .blockEntity ().getBlockPos (), rrd .sizeRenderDiameter (), rrd .simSize ());
366370 }
367371
368-
369372 /**
370373 * Translates a {@link Vec3} of absolute coordinates to a {@link Vec3} of radar coordinates
371374 *
@@ -403,7 +406,6 @@ default void poseToWorldSpace(PoseStack poseStack, RadarRenderData rrd) {
403406 poseStack .translate (0 , -0.05f , 0 );
404407 }
405408
406-
407409 /**
408410 * Translates a {@link Vec3} of radar coordinates to a {@link Vec3} of absolute coordinates
409411 *
@@ -413,10 +415,9 @@ default void poseToWorldSpace(PoseStack poseStack, RadarRenderData rrd) {
413415 * @since 0.16.1.0-rc2
414416 */
415417 default Vec3 radarToWorldCoords (Vec3 pos , RadarRenderData rrd ) {
416- return worldToRadarCoords (pos , rrd .blockEntity ().getBlockPos (), rrd .sizeRenderDiameter (), rrd .simSize ());
418+ return radarToWorldCoords (pos , rrd .blockEntity ().getBlockPos (), rrd .sizeRenderDiameter (), rrd .simSize ());
417419 }
418420
419-
420421 /**
421422 * Translates a {@link Vec3} of radar coordinates to a {@link Vec3} of absolute coordinates
422423 *
@@ -427,10 +428,9 @@ default Vec3 radarToWorldCoords(Vec3 pos, RadarRenderData rrd) {
427428 * @since 0.16.1.0-rc2
428429 */
429430 default Vec3 radarToWorldCoords (Vec3 pos , BlockPos radarPos , float sizeRenderDiameter , float simSize ) {
430- return worldToRadarCoords (pos .x , pos .z , radarPos , sizeRenderDiameter , simSize );
431+ return radarToWorldCoords (pos .x , pos .z , radarPos , sizeRenderDiameter , simSize );
431432 }
432433
433-
434434 /**
435435 * Translates a {@link Vec3} of radar coordinates to a {@link Vec3} of absolute coordinates
436436 *
@@ -441,7 +441,7 @@ default Vec3 radarToWorldCoords(Vec3 pos, BlockPos radarPos, float sizeRenderDia
441441 * @since 0.16.1.0-rc2
442442 */
443443 default Vec3 radarToWorldCoords (double x , double z , RadarRenderData rrd ) {
444- return worldToRadarCoords (x , z , rrd .blockEntity ().getBlockPos (), rrd .sizeRenderDiameter (), rrd .simSize ());
444+ return radarToWorldCoords (x , z , rrd .blockEntity ().getBlockPos (), rrd .sizeRenderDiameter (), rrd .simSize ());
445445 }
446446
447447 /**
@@ -457,8 +457,8 @@ default Vec3 radarToWorldCoords(double x, double z, RadarRenderData rrd) {
457457 default Vec3 radarToWorldCoords (double x , double z , BlockPos radarPos , float sizeRenderDiameter , float simSize ) {
458458 double rtwRatio = simSize / (sizeRenderDiameter / 2.0 );
459459
460- double centerX = radarPos .getX () + 0.5D ;
461- double centerZ = radarPos .getZ () + 0.5D ;
460+ double centerX = radarPos .getX ();
461+ double centerZ = radarPos .getZ ();
462462
463463 double worldX = centerX + (x * rtwRatio );
464464 double worldZ = centerZ + (z * rtwRatio );
0 commit comments