[ABANDONED] How to display a virtual furnace?

Discussion in 'Plugin Development' started by NeatMonster, Aug 14, 2011.

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

    NeatMonster

    Hello,

    I'm the actual developer of SpoutBackpack. For the next version, I want to add virtual workbench and furnace. I've done with the workbench, but I'm blocked with the furnace. The GUI opens and close, but the furnace isn't working. This is my actual code :
    Code:java
    1. SpoutPlayer player = event.getPlayer();
    2. final EntityPlayer entityPlayer = ((CraftPlayer) player)
    3. .getHandle();
    4. TileEntityFurnace titleentityfurnace = new TileEntityFurnace();
    5. entityPlayer.netServerHandler
    6. .sendPacket(new Packet100OpenWindow(windowNumber, 2,
    7. titleentityfurnace.getName(), titleentityfurnace.getSize()));
    8. entityPlayer.activeContainer = new SBFurnace(entityPlayer,
    9. windowNumber, titleentityfurnace);
    Code:java
    1. package me.neatmonster.spoutbackpack;
    2.  
    3. import net.minecraft.server.ContainerFurnace;
    4. import net.minecraft.server.EntityHuman;
    5. import net.minecraft.server.EntityPlayer;
    6. import net.minecraft.server.ICrafting;
    7. import net.minecraft.server.TileEntityFurnace;
    8.  
    9. public class SBFurnace extends ContainerFurnace {
    10.  
    11. public SBFurnace(EntityPlayer entityPlayer, int windowNumber, TileEntityFurnace tileentityfurnace) {
    12. super(entityPlayer.inventory, tileentityfurnace);
    13. super.windowId = windowNumber;
    14. super.a((ICrafting) entityPlayer);
    15. }
    16.  
    17. @Override
    18. public boolean b(EntityHuman entityhuman) {
    19. return true;
    20. }
    21. }

    Can you tell me what's wrong with my code? Thanks in advance, NeatMonster.

    *bump*

    Nobody know?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 18, 2016
  2. Perhaps since it's a virtual furnace, the smelting code isn't being run?
     
  3. Offline

    NeatMonster

    Yes, so I need it to run it manually? There is no other solutions?
     
  4. Offline

    NeatMonster

    Help. Nobody know the answer?
     
  5. Offline

    NeatMonster

  6. Offline

    Jacek

    Have some patience !
     
  7. Offline

    NeatMonster

    I have patience.

    Do you think it's better to let this topic go to the 856424 page or to bump it some days?
     
  8. Offline

    Crash

    You can try tileentityfurnace
     
  9. Offline

    NeatMonster

    I'm already using it. Maybe I made a mistake in my code. Can you check it for me please?
     
  10. Offline

    NeatMonster

    Nobody else? (13 days up.)
     
  11. Offline

    Afforess

    You said you were using Spout, right?

    Have you tried the obvious:

    player.openInventoryWindow(furnaceInventory);
     
  12. Offline

    NeatMonster

    Yep, I already tried. Because it's a virtual furnace, I don't have any inventory.
     
  13. Offline

    Afforess

    TileEntities ARE inventories, albiet not Bukkit inventories. Just create a new CraftInventory.

    Inventory inv = new CraftInventory(tileentityfurnace).
     
  14. Offline

    NeatMonster

    I tried this code:
    Code:
                Inventory furnaceInventory = new CraftInventory(new TileEntityFurnace());
                event.getPlayer().openInventoryWindow(furnaceInventory);
    But I got a null pointer exception:
    Code:
    18:55:53 [WARNING] Failed to handle packet: java.lang.NullPointerException
    java.lang.NullPointerException
            at net.minecraft.server.TileEntityFurnace.a_(TileEntityFurnace.java:246)
    
            at net.minecraft.server.ContainerFurnace.b(SourceFile:77)
            at net.minecraft.server.EntityHuman.m_(EntityHuman.java:98)
            at net.minecraft.server.EntityPlayer.a(EntityPlayer.java:193)
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:299)
            at org.getspout.spout.SpoutNetServerHandler.a(SpoutNetServerHandler.java
    :592)
            at net.minecraft.server.Packet10Flying.a(SourceFile:126)
            at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:89)
            at org.getspout.spout.SpoutNetServerHandler.a(SpoutNetServerHandler.java
    :478)
            at net.minecraft.server.NetworkListenThread.a(SourceFile:105)
            at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:454)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:363)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    Probably because the TileEntityFurnace is null, how to initialize it?

    Amicably, NeatMonster.
     
  15. Offline

    desmin88

    @NeatMonster
    Make a class that extends tilentityfurnace, ovveride a_() to just return true.
    Then do new CustomFurnace();
     
  16. Offline

    NeatMonster

    The GUI is showed, but the furnace isn't working. I would like the furnace to work.

    Amicably, NeatMonster.
     
  17. Offline

    desmin88

    Possibly make the custom tilentityfurnace extend or implement containerfurnace?
     
  18. Offline

    NeatMonster

    Thank you for your reply, but you can't extend two classed, also can't implement it:
    Code:
    The type ContainerFurnace cannot be a superinterface of SBTileEntityFurnace; a superinterface must be an interface.
    Any other idea?
     
  19. Offline

    desmin88

    No idea, I tryed myself, it would never smelt.
     
  20. Offline

    geekygenius

    I'm no expert with stuff like this, but as a guess, aren't furnaces normal blocks? I thought entity was for all the non block things.
     
  21. Offline

    Perdog

    Exactly, he's using spout to create something just like the players inventory, which is a non block because all it is is a pop-up screen, but instead appears (and acts like) a furnace.
     
  22. Offline

    NeatMonster

    Ok, thank you for your help.
     
  23. Offline

    NeatMonster

    @Afforess

    Is what I want possible with the new Spout updates?
    (I want user to be able to open a fake working furnace inventory.)
     
  24. Offline

    Afforess

    No way to do it in Spout. I'm pretty sure the problem is that the furnace is not updated each tick. In MC, each tick furnaces get updated, or something like that. You will need to do it manually since it's not a real furnace.
     
  25. Offline

    NeatMonster

    Thank you for your answer. I think I'll give up the idea to display a virtual furnace. Too much complicated!
     
Thread Status:
Not open for further replies.

Share This Page