Fandom

Minecraft Mod Custom Stuff Wiki

Intelligent Block

175pages on
this wiki
Add New Page
Comments2 Share


Monster block

Bored Monster Block example

Information

Unfourtunately, there is no current way to create a mob in custom stuff 2 or 1. However, there is something close, intelligent blocks! These are blocks that move around, jumping and performing actions, similar to mobs but with jolty movement!

Your block file (in /blocks)

Add these two lines to the end of your block file:

tickrate = 10;
onUpdate[0] = "mod.loadScript('behaviour.js');";

Both the tickrate and the item metadata for onUpdate may be edited to suit your needs.

The tickrate defines how quickly the block will move.

Your behaviour script (in /scripts)

This script must be named behaviour.js to work! (Or whatever the name specified in mod.loadScript() was)

// blockmeta = item metadata
blockmeta = world.getBlockMetadata(position); // Get the metadata of the source block without using arguments. Lazy XD
blockname = world.getBlockName(position); // Get the Name of the source block
xo = Math.round(Math.random()); // Randomly generate either 1 or 0
yo = Math.round(Math.random()); // Randomly generate either 1 or 0
zo = Math.round(Math.random()-.1); //Randomly generate either 1 or 0

// Falling is highest priority
if( world.getBlockName(position.x ,position.y-1, position.z) == "minecraft:air" ) { // Check that the space is air
	world.setBlockAndMetadata(position.x, position.y-1, position.z, blockname, blockmeta);
	world.setBlock(position, "minecraft:air"); // Remove the source block
} else {
	var rnd = Math.random();
	if( rnd = .001 ) {
		if( world.getBlockName(position.x+xo, position.y+yo, position.z+zo) == "minecraft:air" ) { // Check the space is air
			world.setBlockAndMetadata(position.x+xo, position.y+yo, position.z+zo, blockname, blockmeta);
			world.setBlock(position, "minecraft:air"); // Remove the source block
		} // then right at the end
	} else if( rnd = .001 ) { //If it doesn't want to move in a positive direction, try a negative direction
		if( world.getBlockName(position.x-xo, position.y-yo, position.z-zo) == "minecraft:air" ) { // Check that the space is air
			world.setBlockAndMetadata(position.x-xo, position.y-yo, position.z-zo, blockname, blockmeta);
			world.setBlock(position, "minecraft:air"); // Remove the source block
		} // then right at the end
	} // end of if statement
} // End of function

Notes

If you are not using a custom model it is recommended that you use the gravity block type so that the movement is more fluid when falling.

Download

You may try custom example Bored Monster Block.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.