20. Take a Census of Mobs and Villages
In This Chapter
• Find all living mobs in the game world
• Store the mobs in a list data structure
• Learn the type of each mob
• Use a hash map to count mob types
• Work with enum
constants
• Calculate the distance between two things in (x,y,z) space
• Send a message to a player with a mod
A useful application of mods is to discover more about Minecraft in real time as the game is being played. This chapter’s mod takes a census of the mobs that are active in the world in the vicinity of the player.
Mobs are loaded and unloaded by the game as players explore the world. The world is divided into chunks that are 16 blocks long, 16 blocks wide, and 256 blocks deep. The chunks nearest the player are loaded ...
Get Absolute Beginner’s Guide to Minecraft® Mods Programming, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.