That page was too big and I'm saving it for offline reading
Could you just copy and past just the parts ise posted here?
If so double thx
OkHere:
In BlockLauncher 1.5.5, scripts can now define custom blocks. Since there is some confusion with the new function calls, I've decided to write up a short tutorial.
If you just want the completed mod, https://raw.github.c...hantingbench.js type /enchanttable to get an enchantment table block. If you want to see how it's made, read on!
To define a block, use the new command
Block.defineBlock(id, name, texture, materialSourceId, opaque, renderType);
The last three parameters are optional: so the simplest call would be
Block.defineBlock(187, "Evil dirt", 2);
You can specify the texture in three ways.
Textures in Minecraft are specified by ID, starting from 0, which is the id on the first row and first column, to 255, on the last row of the last column. Since there are 16 textures per row, this means that, for example, sapling's texture coordinate is 15, and bedrock's is 17.
Here's the terrain.png for reference.
If your block has the same texture on all sides, just specify the number directly.
Block.defineBlock(187, "Evil dirt", 2);
If your block has different textures on each side, you can specify an array of values for each side, in the order [bottom, top, south, north, west, east].
Additionally, if you are using the array syntax, you can specify row-column coordinates as well. So, for example, if you have
Block.defineBlock(187, "Evil reactor", [[14, 10]])
, you'll have a block with all sides set to the nether reactor's texture. (row 14, column 10) This has the same effect as writing
Block.defineBlock(187, "Evil reactor", 234)
If your block has different textures on each side, you can specify an array of values for each side, in the order [bottom, top, south, north, west, east]
Block.defineBlock(187, "Enchantment table", [[2, 5], [10, 6], [11, 6], [11, 6], [11, 6], [11, 6]]);
Blocks, as you might know, have damage values. If you want to specify damage values, simply add more than 6 textures to the array: the first 6 textures will be used for data value 0, the second set of 6 for data value 1, and so on.
I highly recommend using damage values: instead of defining, for example, white wool, black wool, and purple wool, use damage value textures and save 2 block IDs.
So now we have an enchantment table: let's set the heights of it. For that, we can use Block.setShape.
Block.setShape takes 6 parameters: According to Minecraft Coder Pack's authors (from the Desktop edition), the function parameters are:
Sets the bounds of the block. minX, minY, minZ, maxX, maxY, maxZ
For example, if you want to have a block float off the ground, you can change its minimum y value, and if you want it to be half height, you can change its maximum y value.
For our block, we want it to be 1 block wide, one block deep, but only 3/4 the height of a normal block. So we can call
Block.setShape(187, 0, 0, 0, 1, 3/4, 1);
If you omit the setShape call, you'll just get a regular shaped block.
Let's take a look at the shaped block!
You'll notice that irregularly shaped blocks are extremely glitchy: if you put a block behind it, some faces won't render. This will be fixed.
Here's the full script for the enchantment table:
var initialized = false;
function selectLevelHook() { //This is called before the first world is loaded
if (!initialized) { //if we have not set up our custom block
// define a block with ID 187, name "Enchantment table", and the following textures
// in the order (bottom, top, south, north, west, east).
// in this case, the side textures are the same, and the top/bottom textures are different.
Block.defineBlock(187, "Enchantment table", [[2, 5], [10, 6], [11, 6], [11, 6], [11, 6], [11, 6]]);
// sets the block's boundaries.
// in this case, the block starts at y = 0, and stops at y = 0.75 - this is a block 3/4 m high.
Block.setShape(187, 0, 0, 0, 1, 3/4, 1);
initialized = true;
}
}
In the next part of this tutorial, I'll explain how to let the user interact with custom blocks.
Press the green up-arrow if this helped.
Here's part two:
The way you are doing it is perfectly fine - it might not be as clear, but if it works...
Anyways, part 2.
First, since we might need to change our block IDs, I decided to move the block ID into a variable.
var ENCHANTMENT_TABLE_ID = 187;
Block.defineBlock(ENCHANTMENT_TABLE_ID, "Enchantment table", [[2, 5], [10, 6], [11, 6], [11, 6], [11, 6], [11, 6]]);
Now, we need to make our enchantment table interactive. First, let's make it breakable. For that, we'll use the Block.setDestroyTime method.
Block.setDestroyTime(id, hardness);
Signs have a hardness of 1, so we can write
Block.setDestroyTime(ENCHANTMENT_TABLE_ID, 1);
to give our block the same strength as a sign.
You can also set the explosion resistance for the block with
Block.setExplosionResistance(id, amount).
setDestroyTime automatically sets up the explosion resistance value to a sane default, so you probably don't need to call this yourself.
Finally, let's make it do something!
Since it's just like any other block, the standard ModPE callbacks will work with it. Let's set it up so that it opens a workbench screen when called.
To do that, we need to change the block into a workbench when the user clicks on it, and change it back when the user stops using it.
We'll define three variables: currentWorkbenchX, currentWorkbenchY, currentWorkbenchZ.
Now, we can set the blocks in useItem, and change it back a tick later.
The final code is shown here:
var initialized = false;
var ENCHANTMENT_TABLE_ID = 187;
var currentWorkbenchX, currentWorkbenchY, currentWorkbenchZ;
var needToSwitchBack = false;
function selectLevelHook() { //This is called before the first world is loaded
if (!initialized) { //if we have not set up our custom block
// define a block with ID 187, name "Enchantment table", and the following textures
// in the order (bottom, top, south, north, west, east).
// in this case, the side textures are the same, and the top/bottom textures are different.
Block.defineBlock(ENCHANTMENT_TABLE_ID, "Enchantment table", [[2, 5], [10, 6], [11, 6], [11, 6], [11, 6], [11, 6]]);
// sets the block's boundaries.
// the order of parameters
// in this case, the block starts at y = 0, and stops at y = 0.75 - this is a block 3/4 m high.
Block.setShape(ENCHANTMENT_TABLE_ID, 0, 0, 0, 1, 3/4, 1);
Block.setDestroyTime(ENCHANTMENT_TABLE_ID, 1);
initialized = true;
}
}
function useItem(x, y, z, itemId, blockId, side) {
if (blockId == ENCHANTMENT_TABLE_ID) {
currentWorkbenchX = x;
currentWorkbenchY = y;
currentWorkbenchZ = z;
setTile(x, y, z, 58);
needToSwitchBack = true;
}
}
function modTick() {
if (needToSwitchBack) {
needToSwitchBack = false;
setTile(currentWorkbenchX, currentWorkbenchY, currentWorkbenchZ, ENCHANTMENT_TABLE_ID);
}
} https://raw.github.c...hantingbench.js
In part 3 of the tutorial, some more aspects of custom blocks are showcased, including the ability to recolour textures, and some stupid tricks you can use with custom blocks.
That up-arrow wants a click
Part 3. But what if you had one carpet texture, and you want to re-colour it for different carpet types?
Well, Block.setColor to the rescue!
Here's part 3 of the tutorial, where I explain some random stuff that's left over.
Block.setColor allows you to re-colour different textures - for example, I used it to re-colour the clay texture for the coloured clay mod.
Block.setColor(id, colours)
Colours is an array of colour values. the bottom 8 bits specify blue, the next 8 bits specify green, and so on: it's the same as HTML colour codes.
So, if I wanted to create a purple ore, I can do
Block.defineBlock(187, "Ore of evil", [[3, 2]]);
Block.setColor(187, [0xff00ff]);
If you put more elements in the array, those damage values will get different colours.
Block.setLightValue(id, level)
Sets the light level. Level is an integer from 0 to 15 - so if you want full brightness for our ore of evil,
Block.setLightValue(187, 15);
Our completed ore of evil:
Block.setRenderLayer(id, layer)
Some semitransparent blocks needs to render on a different layer to blend - for example, water renders on layer 2, glass renders on layer 1.
After overriding the breaking mechanic to drop purple dye, I now have purple ore of evil!
Here's the script. It also uses item ID 187, so don't activate it with the previous script. https://raw.github.c...0ise_evilore.js
Finally, abusing the custom block API. None of these ideas are recommended, of course. They may break in a future BlockLauncher release. (Some of these tricks were discovered by Byteandahalf - thanks)
- Custom blocks can overwrite existing blocks.
- Block.setShape, Block.setDestroyTime, Block.setExplosionResistance, and Block.setLightLevel will work on existing Minecraft PE blocks
- If you don't want your block to be placeable, use ModPE.setItem with the block's ID to override its item when held.
Future additions:
- Render Types - Minecraft has special shapes for some blocks, such as crosses for flowers. I've added render type setup to the latest beta: go to https://github.com/C...ki/Render-types for a list of block rendering types (scroll down).
If you want a demo script, grab the beta at http://tinyw.in/bl and run https://raw.github.c...e_rendertype.js (this uses ID 187 as well, so disable the other scripts)
Make a coustom block like define block
Like run through the steps and tell what the paremeters and stuff like
A chart with the functions and what you can fill into them
I hope some one understands that and can help me thx XD
Here it is!:
http://www.minecraftforum.net/topic/2139181-custom-blocks-tutorial/
Your welcome!
Could you just copy and past just the parts ise posted here?
If so double thx
OkHere:
In BlockLauncher 1.5.5, scripts can now define custom blocks. Since there is some confusion with the new function calls, I've decided to write up a short tutorial.
If you just want the completed mod, https://raw.github.c...hantingbench.js type /enchanttable to get an enchantment table block. If you want to see how it's made, read on!
To define a block, use the new command
Block.defineBlock(id, name, texture, materialSourceId, opaque, renderType);
The last three parameters are optional: so the simplest call would be
Block.defineBlock(187, "Evil dirt", 2);
You can specify the texture in three ways.
Textures in Minecraft are specified by ID, starting from 0, which is the id on the first row and first column, to 255, on the last row of the last column. Since there are 16 textures per row, this means that, for example, sapling's texture coordinate is 15, and bedrock's is 17.
Here's the terrain.png for reference.
If your block has the same texture on all sides, just specify the number directly.
Block.defineBlock(187, "Evil dirt", 2);
If your block has different textures on each side, you can specify an array of values for each side, in the order [bottom, top, south, north, west, east].
Additionally, if you are using the array syntax, you can specify row-column coordinates as well. So, for example, if you have
Block.defineBlock(187, "Evil reactor", [[14, 10]])
, you'll have a block with all sides set to the nether reactor's texture. (row 14, column 10) This has the same effect as writing
Block.defineBlock(187, "Evil reactor", 234)
If your block has different textures on each side, you can specify an array of values for each side, in the order [bottom, top, south, north, west, east]
Block.defineBlock(187, "Enchantment table", [[2, 5], [10, 6], [11, 6], [11, 6], [11, 6], [11, 6]]);
Blocks, as you might know, have damage values. If you want to specify damage values, simply add more than 6 textures to the array: the first 6 textures will be used for data value 0, the second set of 6 for data value 1, and so on.
I highly recommend using damage values: instead of defining, for example, white wool, black wool, and purple wool, use damage value textures and save 2 block IDs.
So now we have an enchantment table: let's set the heights of it. For that, we can use Block.setShape.
Block.setShape takes 6 parameters: According to Minecraft Coder Pack's authors (from the Desktop edition), the function parameters are:
Sets the bounds of the block. minX, minY, minZ, maxX, maxY, maxZ
For example, if you want to have a block float off the ground, you can change its minimum y value, and if you want it to be half height, you can change its maximum y value.
For our block, we want it to be 1 block wide, one block deep, but only 3/4 the height of a normal block. So we can call
Block.setShape(187, 0, 0, 0, 1, 3/4, 1);
If you omit the setShape call, you'll just get a regular shaped block.
Let's take a look at the shaped block!
You'll notice that irregularly shaped blocks are extremely glitchy: if you put a block behind it, some faces won't render. This will be fixed.
Here's the full script for the enchantment table:
var initialized = false;
function selectLevelHook() { //This is called before the first world is loaded
if (!initialized) { //if we have not set up our custom block
// define a block with ID 187, name "Enchantment table", and the following textures
// in the order (bottom, top, south, north, west, east).
// in this case, the side textures are the same, and the top/bottom textures are different.
Block.defineBlock(187, "Enchantment table", [[2, 5], [10, 6], [11, 6], [11, 6], [11, 6], [11, 6]]);
// sets the block's boundaries.
// in this case, the block starts at y = 0, and stops at y = 0.75 - this is a block 3/4 m high.
Block.setShape(187, 0, 0, 0, 1, 3/4, 1);
initialized = true;
}
}
In the next part of this tutorial, I'll explain how to let the user interact with custom blocks.
Press the green up-arrow if this helped.
Here's part two:
The way you are doing it is perfectly fine - it might not be as clear, but if it works...
Anyways, part 2.
First, since we might need to change our block IDs, I decided to move the block ID into a variable.
var ENCHANTMENT_TABLE_ID = 187;
Block.defineBlock(ENCHANTMENT_TABLE_ID, "Enchantment table", [[2, 5], [10, 6], [11, 6], [11, 6], [11, 6], [11, 6]]);
Now, we need to make our enchantment table interactive. First, let's make it breakable. For that, we'll use the Block.setDestroyTime method.
Block.setDestroyTime(id, hardness);
We'll make our table break at the same rate as signs: we'll consult the list of hardnesses from
http://minecraft.gam...cks_by_hardness
Signs have a hardness of 1, so we can write
Block.setDestroyTime(ENCHANTMENT_TABLE_ID, 1);
to give our block the same strength as a sign.
You can also set the explosion resistance for the block with
Block.setExplosionResistance(id, amount).
setDestroyTime automatically sets up the explosion resistance value to a sane default, so you probably don't need to call this yourself.
Finally, let's make it do something!
Since it's just like any other block, the standard ModPE callbacks will work with it. Let's set it up so that it opens a workbench screen when called.
To do that, we need to change the block into a workbench when the user clicks on it, and change it back when the user stops using it.
We'll define three variables: currentWorkbenchX, currentWorkbenchY, currentWorkbenchZ.
Now, we can set the blocks in useItem, and change it back a tick later.
The final code is shown here:
var initialized = false;
var ENCHANTMENT_TABLE_ID = 187;
var currentWorkbenchX, currentWorkbenchY, currentWorkbenchZ;
var needToSwitchBack = false;
function selectLevelHook() { //This is called before the first world is loaded
if (!initialized) { //if we have not set up our custom block
// define a block with ID 187, name "Enchantment table", and the following textures
// in the order (bottom, top, south, north, west, east).
// in this case, the side textures are the same, and the top/bottom textures are different.
Block.defineBlock(ENCHANTMENT_TABLE_ID, "Enchantment table", [[2, 5], [10, 6], [11, 6], [11, 6], [11, 6], [11, 6]]);
// sets the block's boundaries.
// the order of parameters
// in this case, the block starts at y = 0, and stops at y = 0.75 - this is a block 3/4 m high.
Block.setShape(ENCHANTMENT_TABLE_ID, 0, 0, 0, 1, 3/4, 1);
Block.setDestroyTime(ENCHANTMENT_TABLE_ID, 1);
initialized = true;
}
}
function useItem(x, y, z, itemId, blockId, side) {
if (blockId == ENCHANTMENT_TABLE_ID) {
currentWorkbenchX = x;
currentWorkbenchY = y;
currentWorkbenchZ = z;
setTile(x, y, z, 58);
needToSwitchBack = true;
}
}
function modTick() {
if (needToSwitchBack) {
needToSwitchBack = false;
setTile(currentWorkbenchX, currentWorkbenchY, currentWorkbenchZ, ENCHANTMENT_TABLE_ID);
}
}
https://raw.github.c...hantingbench.js
In part 3 of the tutorial, some more aspects of custom blocks are showcased, including the ability to recolour textures, and some stupid tricks you can use with custom blocks.
That up-arrow wants a click
Part 3. But what if you had one carpet texture, and you want to re-colour it for different carpet types?
Well, Block.setColor to the rescue!
Here's part 3 of the tutorial, where I explain some random stuff that's left over.
Block.setColor allows you to re-colour different textures - for example, I used it to re-colour the clay texture for the coloured clay mod.
Block.setColor(id, colours)
Colours is an array of colour values. the bottom 8 bits specify blue, the next 8 bits specify green, and so on: it's the same as HTML colour codes.
So, if I wanted to create a purple ore, I can do
Block.defineBlock(187, "Ore of evil", [[3, 2]]);
Block.setColor(187, [0xff00ff]);
If you put more elements in the array, those damage values will get different colours.
Block.setLightValue(id, level)
Sets the light level. Level is an integer from 0 to 15 - so if you want full brightness for our ore of evil,
Block.setLightValue(187, 15);
Our completed ore of evil:
Block.setRenderLayer(id, layer)
Some semitransparent blocks needs to render on a different layer to blend - for example, water renders on layer 2, glass renders on layer 1.
After overriding the breaking mechanic to drop purple dye, I now have purple ore of evil!
Here's the script. It also uses item ID 187, so don't activate it with the previous script.
https://raw.github.c...0ise_evilore.js
Finally, abusing the custom block API. None of these ideas are recommended, of course. They may break in a future BlockLauncher release. (Some of these tricks were discovered by Byteandahalf - thanks)
- Custom blocks can overwrite existing blocks.
- Block.setShape, Block.setDestroyTime, Block.setExplosionResistance, and Block.setLightLevel will work on existing Minecraft PE blocks
- If you don't want your block to be placeable, use ModPE.setItem with the block's ID to override its item when held.
Future additions:
- Render Types - Minecraft has special shapes for some blocks, such as crosses for flowers. I've added render type setup to the latest beta: go to https://github.com/C...ki/Render-types for a list of block rendering types (scroll down).
If you want a demo script, grab the beta at http://tinyw.in/bl and run https://raw.github.c...e_rendertype.js (this uses ID 187 as well, so disable the other scripts)
Thanks!
Modpe
Want GUI Templates? Done!
https://github.com/BeATz-UnKNoWN/ModPE_Scripts/wiki/ModPE-Script-Templates
P.S. Feel free to follow me so you know when I post "awesome" content and make the MCForums a brighter place (totally).
If you need to contact me you can either shoot a Kik message to beatz_unknown or send an email to [email protected]