
Tree-Growing Blocks in Minecraft
Learn how to use the Block.onBlockAdded() method in Minecraft to create blocks that grow different types of trees like cube, cylinder, cone, and sphere. Follow step-by-step instructions and work out the math and algorithms on paper first for a smoother coding experience.
Uploaded on | 0 Views
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
TEALS MINECRAFT PROJECT Lecture 5: Block.onBlockAdded()
MINECRAFT COORDINATES Recall the Following Minecraft blocks all have a unique location x, y, and z. X and Z are parallel to the horizon, and Y is up. To place a block at an arbitrary location, use this: world.setBlock(x,y,z, blockType);
Block.onBlockAdded We'll be using (overriding) a new Block method today: public void onBlockAdded (World world, int locX, int locY, int locZ) The Block.onBlockAdded() method is called when a new block is added to the world, at the given location. In lab 4, we used a crystal-growing block to be the seed for a block, and a crystal-growing item to trigger the placement of more blocks to grow the crystal. For lab 5, we'll use the Block.onBlockAdded()method to build a tree from a block as soon as it is placed in the world.
LAB 5: TREE-GROWING BLOCKS For today's lab, we'll be creating four different kinds of blocks, that grow four different types of trees: cube, cylinder, cone, and sphere (in increasing difficulty). A BIG WORD OF ADVICE: work out the math & algorithm on paper first before diving into the code! If you have a clear idea on paper, the coding will be much easier. Everything else you need to know is in the lab write-up.