Skip to content

Instantly share code, notes, and snippets.

@Choonster
Created September 25, 2016 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Choonster/eceb85787f5937f851f01974573577c5 to your computer and use it in GitHub Desktop.
Save Choonster/eceb85787f5937f851f01974573577c5 to your computer and use it in GitHub Desktop.
Minecraft Forge - A pseudocode example of how to correctly calculate slot IDs in Containers - http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/modification-development/2743463-game-crashes-due-to-inventory
SLOTS_PER_ROW = 10 // Constant field
ContainerExample() { // Constructor
numRows = inventory.getSize() / SLOTS_PER_ROW;
for (row = 0; row < numRows; row++) {
for (col = 0; col < SLOTS_PER_ROW; col++) {
addSlot(new Slot(inventory, col + row * SLOTS_PER_ROW, ...));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment