Really frustrating.

Discussion in 'Plugin Development' started by lolboy397, Oct 19, 2014.

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

    lolboy397

    Hi guys. I'm trying to make a plugin that is like a portable brewing stand. I have got it to update and almost brew. But when the brew is finished it will reset not giving the player the potion and throwing a error.

    EntityBrewingStand.java
    Code:java
    1. import java.lang.reflect.Field;
    2. import java.lang.reflect.Modifier;
    3.  
    4. import org.bukkit.block.BrewingStand;
    5. import org.bukkit.craftbukkit.v1_7_R4.block.CraftBrewingStand;
    6. import org.bukkit.inventory.InventoryHolder;
    7.  
    8. import net.minecraft.server.v1_7_R4.Block;
    9. import net.minecraft.server.v1_7_R4.Blocks;
    10. import net.minecraft.server.v1_7_R4.EntityHuman;
    11. import net.minecraft.server.v1_7_R4.TileEntityBrewingStand;
    12.  
    13. public class EntityBrewingStand extends TileEntityBrewingStand {
    14.  
    15. public EntityBrewingStand(EntityHuman entity) {
    16. this.world = entity.world;
    17. }
    18.  
    19. @Override
    20. public boolean a(EntityHuman entityhuman) {
    21. return true;
    22. }
    23.  
    24. @Override
    25. public int p() {
    26. return 0;
    27. }
    28.  
    29. @Override
    30. public void update() {
    31.  
    32. }
    33.  
    34. @Override
    35. public Block q() {
    36. return Blocks.BREWING_STAND;
    37. }
    38.  
    39. @Override
    40. public InventoryHolder getOwner() {
    41. BrewingStand brew = new CraftBrewingStand(this.world.getWorld().getBlockAt(0, 0, 0));
    42.  
    43. /**
    44.   * Setting the tile we will use, this is the only good way!
    45.   */
    46. try {
    47. Field field = CraftBrewingStand.class.getDeclaredField("brewingStand");
    48. field.setAccessible(true);
    49.  
    50. Field mfield = Field.class.getDeclaredField("modifiers");
    51. mfield.setAccessible(true);
    52. mfield.set(field, field.getModifiers() & Modifier.FINAL);
    53.  
    54. field.set(brew, this);
    55. } catch (Exception e) {
    56. e.printStackTrace();
    57. }
    58.  
    59. return brew;
    60. }
    61. }


    Here is also the Error


    Code:
    [17:21:45] [Server thread/WARN]: [DS9Vip] Task #39 for DS9Vip v1.0.1 generated an exception
    java.lang.ClassCastException: net.minecraft.server.v1_7_R4.TileEntityFurnace cannot be cast to net.minecraft.server.v1_7_R4.TileEntityBrewingStand
        at org.bukkit.craftbukkit.v1_7_R4.block.CraftBrewingStand.<init>(CraftBrewingStand.java:16) ~[spigot.jar:git-Spigot-1.7.9-R0.2-204-g534549b]
        at me.lolboy.DS9Vip.MobileData.EntityBrewingStand.getOwner(EntityBrewingStand.java:43) ~[?:?]
        at net.minecraft.server.v1_7_R4.TileEntityBrewingStand.l(TileEntityBrewingStand.java:143) ~[spigot.jar:git-Spigot-1.7.9-R0.2-204-g534549b]
        at net.minecraft.server.v1_7_R4.TileEntityBrewingStand.h(TileEntityBrewingStand.java:74) ~[spigot.jar:git-Spigot-1.7.9-R0.2-204-g534549b]
        at me.lolboy.DS9Vip.Runnables.MobilePlayerTask.run(MobilePlayerTask.java:32) ~[?:?]
        at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot.jar:git-Spigot-1.7.9-R0.2-204-g534549b]
        at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:350) [spigot.jar:git-Spigot-1.7.9-R0.2-204-g534549b]
        at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:641) [spigot.jar:git-Spigot-1.7.9-R0.2-204-g534549b]
        at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:289) [spigot.jar:git-Spigot-1.7.9-R0.2-204-g534549b]
        at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:584) [spigot.jar:git-Spigot-1.7.9-R0.2-204-g534549b]
        at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:490) [spigot.jar:git-Spigot-1.7.9-R0.2-204-g534549b]
        at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [spigot.jar:git-Spigot-1.7.9-R0.2-204-g534549b]
    
     
  2. Offline

    Dudemister1999

    lolboy397 Can I see line 43 of EntityBrewingStand, and line 32 of MobilePlayerTask, please?
     
    VG.Developments likes this.
  3. Offline

    FerusGrim

    Issue seems pretty clear, to me:
    Code:
    java.lang.ClassCastException: net.minecraft.server.v1_7_R4.TileEntityFurnace cannot be cast to net.minecraft.server.v1_7_R4.TileEntityBrewingStand
    Whatever you're interacting with is a Furnace, and you're attempting to cast it as a BrewingStand.
     
  4. Offline

    lolboy397

    Dudemister1999 FerusGrim

    Here is MobilePlayerTask.java : Line 32
    Code:java
    1. mp.getBrewingStand().h();


    Here is EntityBrewingStand.java : Line 43
    Code:java
    1. BrewingStand brew = new CraftBrewingStand(this.world.getWorld().getBlockAt(0, 0, 0));
     
  5. Offline

    Gater12

    lolboy397
    You sure block 0,0,0 is a brewing stand? Stack trace says otherwise...
     
  6. Offline

    stoneminer02

    1. This is help for CraftBukkit and not spigot. [spigot.jar:git-Spigot-1.7.9-R0.2-204-g534549b]
    2. You set a Furnace to a Brewing Stand.
     
  7. Offline

    Nateb1121


    Alright, there's no need for you to be pedantic here, the issue is obviously Bukkit API, it would be different if OP was using Spigot method calls.

    Anyway, you might want to add some info() calls to check what type of block you're dealing with, because as Gater12 said it might not actually be what you think it is (a brewing stand)
     
  8. Offline

    lolboy397

    stoneminer02 Gater12

    I've got it to work with a furnace. I have pretty much the exact same code. And then I changed it to a brewing stand. After that it still says I'm casting the brewing stand as a furnace and I don't see where I am casting the brewing stand as a furnace.

    asdas
    I don't quite understand what you mean. Since for my furnace that works 100% correctly. I pretty much used the same code.

    Code:java
    1. Furnace furnace = new CraftFurnace(this.world.getWorld().getBlockAt(0, 0, 0));


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

    Rocoty

    You are not explicitly casting a furnace to brewing stand. The CraftBrewingStand constructor that you are calling is. Probably because the block at 0 0 0 is a furnace and in fact not a Brewing Stand. Which is why calling new CraftFurnace works.
     
  10. Offline

    lolboy397

    Rocoty

    Oh so its because of bukkits API?
     
  11. Offline

    jpjunho

    lolboy397
    It's because the block at 0 0 is probably a furnace
     
  12. Offline

    lolboy397

    jpjunho I've checked at there is nothing there I broke the block there and did the furnace command and it still worked. But the brewing command still does not work :/
     
  13. Offline

    croc122

    Does an actual brewing stand HAVE to be in the world somewhere in order for plugins to be able to use the interface? If yes, that doesn't make much since to me. lolboy397
     
  14. Offline

    lolboy397

    Nope the brewing stand still throws a big fat error... Idk what to do
     
Thread Status:
Not open for further replies.

Share This Page