Added documentation for ITranformation API

Deprecated explicit use of TileEntity during transformation
This commit is contained in:
Unknown 2019-06-10 13:03:37 +02:00 committed by unknown
parent 501de39652
commit 42d54cf830
2 changed files with 20 additions and 1 deletions

View file

@ -7,21 +7,40 @@ import net.minecraft.world.World;
public interface ITransformation { public interface ITransformation {
// Return the World where the block or entity will be deployed.
World getTargetWorld(); World getTargetWorld();
// Return the number of 90 deg rotations to the right.
// Possible values are 0 (forward), 1 (turn right), 2 (turn back) and 3 (turning left).
byte getRotationSteps(); byte getRotationSteps();
// reserved
float getRotationYaw(); float getRotationYaw();
// Return true if the provided coordinates are strictly inside the ship.
// Use this to keep connections with a remote location, or break the related links.
boolean isInside(final double x, final double y, final double z); boolean isInside(final double x, final double y, final double z);
// Return true if the provided coordinates are strictly inside the ship.
// Use this to keep connections with a remote location, or break the related links.
boolean isInside(final int x, final int y, final int z); boolean isInside(final int x, final int y, final int z);
// Translate then rotate the provided world coordinates.
// Rotation is always relative to the Ship core.
// Use this to transform floating coordinates, notably sub-components of a block.
Vec3d apply(final double sourceX, final double sourceY, final double sourceZ); Vec3d apply(final double sourceX, final double sourceY, final double sourceZ);
// Translate then rotate the provided world coordinates.
// Rotation is always relative to the Ship core.
// Use this to transform a block aligned coordinate.
BlockPos apply(final int sourceX, final int sourceY, final int sourceZ); BlockPos apply(final int sourceX, final int sourceY, final int sourceZ);
// Return the new coordinates for the provided TileEntity.
// Deprecated: use apply(tileEntity.getPos()) instead.
@Deprecated
BlockPos apply(final TileEntity tileEntity); BlockPos apply(final TileEntity tileEntity);
// Translate then rotate the provided world coordinates.
// Rotation is always relative to the Ship core.
BlockPos apply(final BlockPos blockPos); BlockPos apply(final BlockPos blockPos);
} }

View file

@ -178,7 +178,7 @@ public class CompatArsMagica2 implements IBlockTransformer {
} }
final World targetWorld = transformation.getTargetWorld(); final World targetWorld = transformation.getTargetWorld();
final BlockPos target = transformation.apply(tileEntity); final BlockPos target = transformation.apply(tileEntity.getPos());
final TileEntity tileEntityTarget = targetWorld.getTileEntity(target); final TileEntity tileEntityTarget = targetWorld.getTileEntity(target);
if (tileEntityTarget == null) { if (tileEntityTarget == null) {
WarpDrive.logger.error(String.format("ArsMagica2 compat: No tile entity found at target location %s. We might loose mana network %s.", target, nbtBase)); WarpDrive.logger.error(String.format("ArsMagica2 compat: No tile entity found at target location %s. We might loose mana network %s.", target, nbtBase));