How to make this furnace burn as if there was coal in it?

Discussion in 'Plugin Development' started by colony88, Jun 7, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    colony88

    Code:java
    1. @EventHandler
    2. public void onBlockRedstoneChange(BlockRedstoneEvent e)
    3. {
    4. Block b = e.getBlock();
    5. Material bm = b.getType();
    6. System.out.println("1");
    7. if(bm == Material.FURNACE)
    8. {
    9. System.out.println("2");
    10. if(b.isBlockPowered() || b.isBlockIndirectlyPowered())
    11. {
    12. System.out.println("3");
    13. Furnace f = (Furnace)b;
    14. f.setBurnTime((short) 10000);
    15. f.setCookTime((short) 10000);
    16. }
    17. }
    18. }


    As you can see, I tried to search for the problem using system.out.println("1") etc., but it just doesn't seem to react to the BlockRedstoneEvent... Anyone has an idea?
     
  2. Offline

    wouter0100

    You have included it?
     
  3. Offline

    colony88

    what?
     
  4. Offline

    wouter0100

    The BlockHandler (If you uses another file for this)
     
  5. Offline

    colony88

    Yes, I registered the listener class
     
  6. Offline

    McLuke500

  7. Offline

    colony88

  8. Offline

    McLuke500

    I was thinking the get block is the red stone or the furnace? As it might be the red stone. Try debugging by printing the block
     
  9. Offline

    colony88

    okay, I'll try

    Okay tnx, that was it :D but now I have another prob... I cannot cast the block to a furnace with this code:
    Code:java
    1. if(isFurnace(bs))
    2. {
    3. f = (Furnace)bs;
    4. f.setBurnTime((short)1000);
    5. f.setCookTime((short)1000);
    6. }

    Code:java
    1. Block bs = b.getRelative(BlockFace.SOUTH);

    Code:java
    1. private boolean isFurnace(Block b){
    2. if(b.getType() == Material.FURNACE){
    3. return true;
    4. }
    5. return false;
    6. }


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  10. an block can never be an furnace, only an blockstate can be an furnace
     
  11. Offline

    colony88

    OH! But how do you make it cook things etc.?

    Bump, anyone?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  12. If you set setBurnTime() it will make the furnace burn as if it was fed fuel and it will use smelt recipes if a item that is a furnace recipe is placed inside...

    The setCookTime() method sets the percentage for cooking the recipe... it doesn't set the time it takes to cook it. Values are from 0 (0%) to 200 (bar filled 100% and trigger result of recipe)... so you might want to avoid it for now.

    If you want to add more furnace recipes, you'll need to use new FurnaceRecipe( ... ) and add that to server using getServer().addRecipe(...);
     
  13. Offline

    colony88

    Code:java
    1. private boolean isFurnace(Block b){
    2. if(b.getType() == Material.FURNACE){
    3. return true;
    4. }
    5. return false;
    6. }
    7.  
    8. @EventHandler
    9. public void onBlockRedstoneChange(BlockRedstoneEvent e)
    10. {
    11. Block b = e.getBlock();
    12. Block[] ba =
    13. {
    14. b.getRelative(BlockFace.NORTH),
    15. b.getRelative(BlockFace.EAST),
    16. b.getRelative(BlockFace.SOUTH),
    17. b.getRelative(BlockFace.WEST)
    18. };
    19.  
    20. for(i=0; i<4; i++){
    21. if(isFurnace(ba[i])){
    22. System.out.println(ba[i].getType().toString());
    23. f = (Furnace)ba[i].getState();
    24. f.setBurnTime((short)100000);
    25. }
    26. }
    27. }[/i][/i][/i]


    Do you know what's wrong with that code?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
Thread Status:
Not open for further replies.

Share This Page