Fandom

Minecraft Mod Custom Stuff Wiki

World

175pages on
this wiki
Add New Page
Comments17 Share
CS1 Custom Stuff 1

Information presented below this line is outdated syntax or information used for Custom Stuff 1. It will not work with Custom Stuff 2.

World functions can change blocks, create and modify entines.

Events that can call world functions

  • rightclick (items)
  • explode (items)
  • blockdestroyed (items)
  • clicked (blocks)
  • rightclicked (blocks)
  • activated (blocks)
  • deactivated (blocks)
  • neighborchanged (blocks)
  • added (blocks)
  • updated (blocks)
  • destroyed (blocks)

Functions

Function Description Arguments
setBlockId Sets the ID of the block Position pos, int id
setBlockMetadata Sets the metadata of the block Position pos, int metadata
setBlockIdAndMetadata Sets the ID and metadata of the block Position pos, int id, int metadata
harvestBlock Harvests the block Position pos
setTime Sets the time int time
createExplosion Rips angry creepers apart Position pos, float strength
createThunderbolt Creates thunderbolt Position pos
spawnMob Spawns mob Position pos, String name
spawnItem Spawns item Position pos, int id, int count, int damage
setWeather Sets weather int weather, int time
hoeBlock Hoes your block Position pos
fillContainer Fills container with x Position pos, int id, int damage
clearContainer Clears container from x Position pos
addToContainer Adds x to container Position pos, int id, int count, int damage
removeFromContainer Removes x to container Position pos, int id, int count, int damage
clearContainerSlot Clears container slot Position pos, int slotId
fillContainerSlot Fills container slot Position pos, int slotId
setContainerSlot Sets container slot to x Position pos, int slotId, int id, int count, int damage
setContainerIntData Sets an integer value in a container index Position pos, int index, int data
setContainerStringData Sets a string value in a container index Position pos, int index, string data
removeFromContainerSlot Removes x from the container slot Position pos, int slotId, int count
addToContainerSlot Adds x to the container slot Position pos, int slotId, int count
getBlockId Gets block ID Position pos
getBlockDamage Gets block damage Position pos
getContainerSlotId Gets container's slot Item ID Position pos, int slotId
getContainerSlotDamage Gets container's slot Item damage Position pos, int slotId
getContainerSlotCount Gets container's slot Item count Position pos, int slotId
getContainerItemCount Gets container's item count Position pos, int id, int damage
getContainerIntData Sets an Int value in a container index Position pos, int index
getContainerStringDat Sets a string value in a container index Position pos, int index
getBiome Gets biome value that position. Position pos
getBlockLightLevel Gets the light level of a block. Position pos
isFuelInContainerSlot Boolean value. Returns true when in container at specify slot is fuel. Position pos, int slotId

Examples

A few examples for how to use the world functions will be described below. Most functions that use a position variable will use origin as the location for events to simplify things. Although several of these scripts can be used in the same file the event that triggers them, it is usually a good idea to make a file in /config/customStuffFunctions folder. This file should end with .script as the file type.

rightclick = "customstuff.loadScript('yourcode.script');";

You can easily switch out the rightclick event or the script name with relatively no problems. Now on to a few examples using world functions.

world.harvestBlock(origin);

This is just a very simple bit of code that causes the block to be harvested as if the player had mined it themselves. For example, if used on ice, it will check to see if the block should become air or a water source block. But this method will only drop what the block would have dropped if you mined it normally, which in the case of ice is nothing.

var blockidvalue = world.getBlockId(origin);
var blockdamagevalue = world.getBlockDamage(origin);
world.setBlockIdAndMetadata(origin, 0, 0);
world.spawnItem(origin, blockidvalue, 1, blockdamagevalue);

This bit of code first finds what the id value of the block is and saves it to the blockidvalue variable. Then it finds the metavalue for the block incase the value is anything other than 0. The third line sets the block to air without checking what should be done to the block if broken. Finally, the last line drops 1 of that block. Although this is a bit more difficult than using harvestBlock, it has the advantage of allowing you to receive unobtainable blocks like ice and even to recollect misplaced glass blocks.&nbsp

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.