simon816 / ComcraftModLoader

Comcraft Mod Loader is a mod to Comcraft that allows multiple mods to be installed at once
http://www.simon816.com/project/comcraftml/downloads/
GNU General Public License v3.0
15 stars 4 forks source link

If x,y,z on block do something #16

Closed michal5575 closed 10 years ago

michal5575 commented 10 years ago

Can you make possiblity to make action if click on some block (for example change sky color if click on bed) to your mod(and make it useable in mods)?

simon816 commented 10 years ago

You can do already using the blockActivated event. Example:

blockActivated: function(world, x, y, z, entityplayer, itemStack) {
    // do something here
    return true
}

This goes in the options when creating a block using Block(id).create(options)

michal5575 commented 10 years ago

Okay, and how to do it with already existing blocks?

simon816 commented 10 years ago

There is no way of doing that currently, I thought initially there should be no modification of built in blocks as it could cause unintentional damage to worlds. Also because the built in blocks are coded in the 'native' Java code, they perform better with less lag, and enabling mods to change these blocks would make game-play more laggy.
Though I could try some tests but it's unlikely to perform well. You'll have to create a new block to customize its properties

michal5575 commented 10 years ago

Okay

michal5575 commented 10 years ago

And can I print text on screen (for example if will someone mine/place block it will change number) I do not know how it looks in java so there is c++ example (Sorry for "mWorld", this code is from my Lamecraft mod):

int IronNumber;
mWorld->player.IronNumber = 0;
    if (mWorld->GetBlock(testPos.x, testPos.y, testPos.z) == 41)
                         {

                                 if(mWorld->player.IronNumber -= 1);
                 else if(mWorld->player.IronNumber <= 0)
                 {
                 mWorld->player.health = 0;
                 mWorld->player.hunger = 0;
                 mWorld->player.gamemode = 2;

                 }

                         }
 if (mWorld->GetBlock(testPos.x, testPos.y, testPos.z) == 41)
                         {

                                 mWorld->player.IronNumber += 1;

                         }
mRender->DebugPrint(255,110,"Iron: %i", mWorld->player.IronNumber - 1);
simon816 commented 10 years ago

There is Console.log which prints to stdout (use emulator) but there is no on-screen printing

michal5575 commented 10 years ago

Okay