Vswe's Summer Courses | You're not logged in. Sign up or log in | Server time: | Donate
One can now see other persons' badge hunts. Simply head over to their profiles to access them.

Go back to course page

Climbing the interface ladder

From basic graphical interfaces to very advanced ones

2 quick questions

  • 2013-09-14 17:18:04
    Hello people, i would like to ask 2 quick questions.

    Firstly, is it possible that one can determine where the machine faces like eg, deployers from Redpower, where it faces is determined by the face of the front side.

    Secondly, i am having problems understanding the activation and disable code of the machine, thanks

    int meta = world.getBlockMetadata(x, y, z);
    int type = meta / 2;
    int disabled = meta % 2 == 0 ? 1 : 0;
    int newMeta = type * 2 + disabled;        
    world.setBlockMetadataWithNotify(x, y, z, newMeta, 3);

    Thanks, GuacheSuede
  • 2013-09-15 01:47:52
    first you have to remember that VSWE stores the disabled by adding one to the mode
    i'll comment what it does to you
    int meta = world.getBlockMetadata(x, y, z); //gets the meta data
    int type = meta / 2; //it divides by 2 to get the mode
    int disabled = meta % 2 == 0 ? 1 : 0; //toggles the disabled state via ternary operator
    int newMeta = type * 2 + disabled; //sets the disabled type
    world.setBlockMetadataWithNotify(x, y, z, newMeta, 3); //sets the block metadata again
  • 2013-09-15 02:50:17
    Firstly, it is possible to determine which side for the machine to face. In fact, Vswe already taught us everything we need to know to make it happen.

    What you need to do is save the block's orientation in the metadata and then use that data in getIcon(int side, int meta) to return the respective icons. You can then change the metadata whenever someone right click and the texture will update automatically, making it look like its being rotated.

    If you want to make it face you when you place it, then you can override onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta) and set your block's metadata according to "side".

    For you second question, you might want to go back to Course 3 Lecture 3 part 2 and watch the part from 17:25. Vswe explained it pretty well. If you are still confused, you should watch that whole lecture.
  • 2013-09-15 02:53:27
    Thanks for the help guys :)
  • 2013-09-15 03:03:15
    Ex - Noob, would u like to elaborate it for me ?
  • Log in or sign up to reply to this thread