Solved How to create a virtual furnace?

Discussion in 'Plugin Development' started by TheWolfBadger, Jun 11, 2014.

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

    TheWolfBadger

    I am wondering what the best way is to create a virtual furnace and update it. I want to use NMS, however I am not familiar with it at all. Please help me. Thank you. - Jack (TheWolfBadger)

    Anyone? Please! Thanks. - Jack

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  2. Offline

    MCForger

    TheWolfBadger
    This is how you would open a furnace view:
    Code:java
    1. public void openFurnaceView(Player player)
    2. {
    3. Inventory furnace = getServer().createInventory(null,
    4. InventoryType.FURNACE);
    5. player.openInventory(furnace);
    6. }

    What do you mean by update? Or what do you want to do with the inventory?
     
  3. Offline

    TheWolfBadger

    MCForger I want the furnace to be function able. What I mean is it opens a ender furnace basically. The furnace runs while the player does not have it open also. When a player clicks a furnace it opens their ender furnace. What I'm trying to figure out is how to do this stuff. Thanks for replying btw. - Jack

    MCForger Hello?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  4. Offline

    MCForger

  5. Offline

    TheWolfBadger

  6. Offline

    Tzeentchful

    TheWolfBadger
    Unless you handle all the cooking logic yourself you will have to make a custom tile entity through NMS.
    You can see the code for how virtual pack does it here.
     
  7. Offline

    MCForger

    TheWolfBadger
    The issue is you actually need a real furnace block to make an inventory were you could fake this....you cold do something where you execute the command and in a certain amount of time your stuff would be done smelting. So like you do /example put your stuff in the inventory and close it. You grab the items out of that furnace inventory and then say how long would that fuel burn for and how much would they have of what their smelting by then. Then when the player does the command again put back the items and whats been smelted or not so far.
     
  8. Offline

    Deleted user

  9. Offline

    TheWolfBadger

    Tzeentchful Where can I find what the methods do and such for the nms part of it though? Thanks! - Jack
     
  10. Offline

    Tzeentchful

    You can find the NMS code here.
     
  11. Offline

    TheWolfBadger

    Tzeentchful MCForger So I've never used NMS. What I want to do is create a class called "EntityFurnace". I want it to extend TileEntityFurnace. I need it to have the same functions and so that it's a working virtual furnace and works while it is not open. How can I do this? Thanks. - Jack
     
  12. Offline

    fireblast709

    TheWolfBadger afaik you would have to do the ticking yourself (just use a scheduler). Sadly enough the World ticking checks for chunks, so it wouldn't be that great to rely on imo.
     
  13. Offline

    TheWolfBadger

    fireblast709 Ik that. How would I make the EntityFurnace class tho? Do I have to have all the same variables as the TileEntityFurnace class.
     
  14. Offline

    LordVakar

    So your doing this for a plugin request when you're not at all familiar on how to even start? xD
    My suggestion would be to check for the Action Right Click in a PlayerInteractEvent and create a new inventory with the ownership of the player and serialize it to a file for each player. You can load it every time they right click.
    Just a suggestion, I think there are more efficient ways to carry this out. xP
     
    Zupsub likes this.
  15. Offline

    TheWolfBadger

    LordVakar The furnaces don't work properly or actually function. I need to make one that functions. I may just go ahead making furnaces at like 0,160,0 in the map and setting different furnaces for each furnace, however I don't think it would work the best

    MCForger Tzeentchful fireblast709 LordVakar This is what I have so far. I'm confused what it actually does and how it functions and/or how to use it. Please help me! Thank you! - Jack (TheWolfBadger)
    Code:java
    1. package com.core.wolfbadger.enderfurnace;
    2.  
    3. import net.minecraft.server.v1_7_R3.TileEntityFurnace;
    4. import org.bukkit.inventory.ItemStack;
    5.  
    6. /**
    7. * Created with IntelliJ IDEA.
    8. * User:
    9. * Date: 6/12/14
    10. * Time: 4:10 PM
    11. * To change this template use File | Settings | File Templates.
    12. */
    13. public class EntityFurnace extends TileEntityFurnace {
    14. private double boilingSpeed = 1D;
    15. private double fusionSpeed = 1D;
    16. private double jCookTime = 0D;
    17. private ItemStack[] contents = new ItemStack[3];
    18. public EntityFurnace() {}
    19. private Double getBoilingSpeed() {
    20. return boilingSpeed;
    21. }
    22. private Double getFusionSpeed() {
    23. return fusionSpeed;
    24. }
    25. public Double getCookTime() {
    26. return jCookTime;
    27. }
    28. public void tick() {
    29. this.jCookTime--;
    30. if(this.jCookTime == 0) {
    31. this.meltSpeed = 0D;
    32. this.burnSpeed = 0D;
    33. this.jCookTime = 0D;
    34. }
    35. }
    36. public void setItem(int i, ItemStack item) {
    37. this.contents[I] = item;[/I]
    38. [I] }[/I]
    39. [I] public ItemStack getItemAt(int i) {[/I]
    40. [I] return contents[I];[/I][/I]
    41. [I] }[/I]
    42. [I]}[/I]


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  16. Offline

    LordVakar

    I thought of a better way to do this and it's to mimic AntVenom's Hungry Games Portable Furnace
    You could open a furnace inventory menu (That works) when you place down a furnace and cancel the BlockPlaceEvent.
    And you would create the furnace menu on join and make it owned by the player who joined.
     
  17. Offline

    TheWolfBadger

    LordVakar Hmm, so you would open the inventory by placing a furnace block at like 0,0,0, then it would delete right after it was placed and I would save that FurnaceInventory to an HashMap with the player who opened it? Would that work?
     
  18. Offline

    LordVakar

    TheWolfBadger
    I guess that would work xD
    I see this is solved so I think you got it to work somehow but what I was saying is you listen for a player placing a block anywhere and you cancel the event so the block wasn't actually placed, meanwhile you open the inventory :O

    EDIT: You created a new thread
     
  19. Offline

    TheWolfBadger

    BorisTheTerrible. Would creating the furnace at 0, 0, 0 and then deleting the furnace, but opening it's furnaceInventory view. Would this work? Only problem I don't understand how I would fix is how to set it burning when it's not open. Any ideas? Thanks. - Jack
     
  20. TheWolfBadger
    You could try it, I don't think it will work though since the tileEntityFurnace is probably destroyed when the furnace is destroyed.

    I tried just creating a tileEntityFurnace then opening it on an entityPlayer. It caused a NullPointerException though.
    I will probably look into this more tonight.
     
Thread Status:
Not open for further replies.

Share This Page