### Mod compatibility : my 3 rules ###
Normally, it is compatible with mods that don't modify the same class that I modify.
BUT, the modder must have anticipated the possibility to use more than 256 blocks.
This can be done in respecting these 3 rules:
- First, when processing the following tables of the Block class, in a loop for example, don't use 256 :
Block.blocksList[]
Block.tickOnLoad[]
Block.opaqueCubeLookup[]
Block.isBlockContainer[]
Block.lightOpacity[]
Block.canBlockGrass[]
Block.lightValue[]
Block.requiresSelfNotify[]
Block.useNeighborBrightness[]
//Wrong
for(int i = 0; i < 256; i++)
//Right
for(int i = 0; i < Block.blocksList.length; i++)
- Second, when declaring a ItemBlock, don't use "myBlockID - 256" but "myBlockID - Block.blocksList.length"
//Wrong
Item.itemsList[Block13incID] = new Item13inc(Block13incID - 256);
//Right
Item.itemsList[Block13incID] = new Item13inc(Block13incID - Block.blocksList.length);
The reason is that the first 256 Items are reserved to be the item version of the 256 blocks. So if I change the max number of Block, the max number of Items reserved for the blocks changed too.
- Third, when using function that return the BlockID, use an integer to save the data. Doesn't use variable byte, byte casting ("(byte)") and mask ( "& 0xff" )
Example from minecraft code :
Class Chunk
public boolean setBlockID(int i, int j, int k, int l)
//Wrong
byte byte0 = (byte)l;
...
blocks[i << worldObj.field_35471_b | k << worldObj.field_35473_a | j] = (byte)(byte0 & 0xff);
//Right
blocks[i << worldObj.field_35471_b | k << worldObj.field_35473_a | j] = l;
=> So you must BAN most of the "256" and the "byte" in our code and it will, probably, work !!!
The advantage of these 3 rules is that the mod will work with and without my mod: without my mod, the "Block.blocksList.length" will stay at 256. Even if you think it is useless, don't forget that the day Mojang will remove the limitation directly in the code of Minecraft, these sorts of error will appear and it will be the same fix that I propose. So better take the good resolution sooner when you have time. Instead of waiting the last minute when a new version of minecraft will appear with the same modification that I made and that you will need more time to update your mod to the new version !!!