Simple block recolouring API: closes #525

Fix up documentation on "rotation" API: it is up to the mod to decide interpretation of "rotation" for the mod/block.
This commit is contained in:
Christian 2013-04-18 16:49:14 -04:00
parent cb9e944257
commit cf90eb37f7

View file

@ -155,7 +155,7 @@
} }
/** /**
@@ -1439,4 +1459,917 @@ @@ -1439,4 +1459,944 @@
canBlockGrass[0] = true; canBlockGrass[0] = true;
StatList.initBreakableStats(); StatList.initBreakableStats();
} }
@ -1027,7 +1027,10 @@
+ } + }
+ +
+ /** + /**
+ * Rotate the block around the specified axis by one rotation + * Rotate the block. For vanilla blocks this rotates around the axis passed in (generally, it should be the "face" that was hit).
+ * Note: for mod blocks, this is up to the block and modder to decide. It is not mandated that it be a rotation around the
+ * face, but could be a rotation to orient *to* that face, or a visiting of possible rotations.
+ * The method should return true if the rotation was successful though.
+ * + *
+ * @param worldObj The world + * @param worldObj The world
+ * @param x X position + * @param x X position
@ -1043,6 +1046,7 @@
+ +
+ /** + /**
+ * Get the rotations that can apply to the block at the specified coordinates. Null means no rotations are possible. + * Get the rotations that can apply to the block at the specified coordinates. Null means no rotations are possible.
+ * Note, this is up to the block to decide. It may not be accurate or representative.
+ * @param worldObj The world + * @param worldObj The world
+ * @param x X position + * @param x X position
+ * @param y Y position + * @param y Y position
@ -1071,5 +1075,28 @@
+ public int getEnchantPower(World world, int x, int y, int z) + public int getEnchantPower(World world, int x, int y, int z)
+ { + {
+ return blockID == bookShelf.blockID ? 1 : 0; + return blockID == bookShelf.blockID ? 1 : 0;
+ }
+ /**
+ * Common way to recolour a block with an external tool
+ * @param world The world
+ * @param x X
+ * @param y Y
+ * @param z Z
+ * @param side The side hit with the colouring tool
+ * @param colour The colour to change to
+ * @return If the recolouring was successful
+ */
+ public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour)
+ {
+ if (blockID == cloth.blockID)
+ {
+ int meta = world.getBlockMetadata(x, y, z);
+ if (meta != colour)
+ {
+ world.setBlockMetadataWithNotify(x, y, z, colour, 3);
+ return true;
+ }
+ }
+ return false;
+ } + }
} }