Solved Cracked stone brick?

Discussion in 'Plugin Development' started by Josh014, Feb 7, 2014.

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

    Josh014

    Hey,
    Is there any way to check if there is cracked stone brick?

    I tried using this:
    Code:java
    1. if (b.getType() == Material.SMOOTH_BRICK (byte)1) {}

    But it didn't work. I get this error in eclipse:
    Code:
    Syntax error on token "SMOOTH_BRICK", / expected after this token
    Thank you,
     
  2. Josh014
    Create a new ItemStack with the correct type and data.
    Code:
    ItemStack stack = new ItemStack(material, amount, data);
     
  3. Offline

    Josh014

    Assist
    I already tried that and it says I have to make a material not an ItemStack. So I changed to a material variable and it just says it can't define it.
     
  4. Josh014
    Sorry, I didn't see what you were trying to do. Use Block#getData().
    Code:
    if(b.getType() == Material.SMOOTH_BRICK && b.getData() == (byte) 1) { }
     
    Josh014 likes this.
  5. Offline

    Josh014

    Assist
    Got it working thanks again mate!
     
  6. Offline

    supersonicsauce


    I'm having this exact same problem (except with colored wool) and getData() is deprecated and throws me a bunch of errors in the console. Is there another solution?
     
  7. supersonicsauce
    getData() should still work in the latest update, though I am not 100% sure about this as I have not touched anything related to MaterialData in a while.

    Would you mind posting the error here, so I can see what is causing it, and possibly figure out any fixes?

    For future cases, please post the error immediately, along with the line causing it. Thanks.
     
  8. Offline

    supersonicsauce


    Awesome, here's the error:

    Code:
    [12:35:52 ERROR]: Could not pass event BlockBreakEvent to Clans v1.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:320) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-17-g7d185fd-b2997jnks]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-17-g7d185fd-b2997jnks]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:481) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-17-g7d185fd-b2997jnks]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:466) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-17-g7d185fd-b2997jnks]
        at net.minecraft.server.v1_7_R1.PlayerInteractManager.breakBlock(PlayerInteractManager.java:263) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-17-g7d185fd-b2997jnks]
        at net.minecraft.server.v1_7_R1.PlayerInteractManager.dig(PlayerInteractManager.java:118) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-17-g7d185fd-b2997jnks]
        at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java:535) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-17-g7d185fd-b2997jnks]
        at net.minecraft.server.v1_7_R1.PacketPlayInBlockDig.a(SourceFile:53) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-17-g7d185fd-b2997jnks]
        at net.minecraft.server.v1_7_R1.PacketPlayInBlockDig.handle(SourceFile:8) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-17-g7d185fd-b2997jnks]
        at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-17-g7d185fd-b2997jnks]
        at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-17-g7d185fd-b2997jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:655) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-17-g7d185fd-b2997jnks]
        at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-17-g7d185fd-b2997jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-17-g7d185fd-b2997jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-17-g7d185fd-b2997jnks]
        at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-17-g7d185fd-b2997jnks]
    Caused by: java.lang.ClassCastException: org.bukkit.event.block.BlockBreakEvent cannot be cast to org.bukkit.block.Block
        at com.siekmann.jonah.sauceclans.Main.onBlockBreak(Main.java:73) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_65]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[?:1.6.0_65]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[?:1.6.0_65]
        at java.lang.reflect.Method.invoke(Method.java:597) ~[?:1.6.0_65]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:318) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-17-g7d185fd-b2997jnks]
        ... 15 more
    
    And here's the line that is causing it:

    Code:
                      if (event.getBlock().getType()==Material.WOOL && ((Block) event).getData() == (byte) 5){
                          if (player.getLocation().getWorld() == world && player.getLocation().distanceSquared(fishing1) <= distbreak){
                              
    Note that if I remove the && ((Block……….. it works fine.
     
  9. supersonicsauce
    Use event.getBlock() instead of ((Block) event), just like you did in the first statement.
     
Thread Status:
Not open for further replies.

Share This Page