Solved Log2 data values throwing errors.

Discussion in 'Plugin Development' started by Zombie_Striker, Jun 21, 2017.

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

    Zombie_Striker

    Code:.
    Code:
    block.setData(0);
    //block is a log2 block
    Problem:. It seems, as of 1.12, you cannot set dark-oak blocks. When trying to set the data equal to 0 (which used to mean the dark oak block will be upright), it will throw the error below.

    Also, a side problem, as of 1.12, setting the logs data to 4 (which used to mean the block was all bark, no top or bottom textures) will not do anything. Has the data values for logs changed?

    What you can do to recreate the problem:. Get a 1.12 server, set a block equal to Log_2, and set its type to 0.

    The FULL Error log:
    .
    Code:
    [15:50:43] [Server thread/WARN]: java.lang.IllegalArgumentException: Cannot set property BlockStateEnum{name=variant, clazz=class net.minecraft.server.v1_12_R1.BlockWood$EnumLogVariant, values=[acacia, dark_oak]} to oak on block minecraft:log2, it is not an allowed value
    [15:50:43] [Server thread/WARN]:     at net.minecraft.server.v1_12_R1.BlockStateList$BlockData.set(SourceFile:184)
    [15:50:43] [Server thread/WARN]:     at net.minecraft.server.v1_12_R1.BlockLog2.fromLegacyData(SourceFile:58)
    [15:50:43] [Server thread/WARN]:     at org.bukkit.craftbukkit.v1_12_R1.block.CraftBlock.setData(CraftBlock.java:105)
    [15:50:43] [Server thread/WARN]:     at org.bukkit.craftbukkit.v1_12_R1.block.CraftBlock.setData(CraftBlock.java:90)
    [15:50:43] [Server thread/WARN]:     at me.zombie_striker.pixelprinter.util.GifHolder.loadFrame(GifHolder.java:199)
    [15:50:43] [Server thread/WARN]:     at me.zombie_striker.pixelprinter.PixelPrinter$5.run(PixelPrinter.java:162)
    [15:50:43] [Server thread/WARN]:     at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftTask.run(CraftTask.java:71)
    [15:50:43] [Server thread/WARN]:     at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:353)
    [15:50:43] [Server thread/WARN]:     at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:738)
    [15:50:43] [Server thread/WARN]:     at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:405)
    [15:50:43] [Server thread/WARN]:     at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:678)
    [15:50:43] [Server thread/WARN]:     at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:576)
    [15:50:43] [Server thread/WARN]:     at java.lang.Thread.run(Unknown Source)

    What you have tried:
    . Changing the data value, but that still throws the same error.
     
  2. Offline

    Iran

    Did this work with 1.11? Maybe try a earlier snapshot of 1.12, they might have messed something up.
     
  3. Offline

    Horsey

    I believe to get dark oak, the data value needs to be 1, not 0.
     
  4. Offline

    Zombie_Striker

    @Iran
    Yes, it used to work. There is no earlier version of 1.12. Also, I need it to stay on the newest version of 1.12 is because the code should work for all versions, as I am intending to release the plugin for all versions.

    @Horsey
    I just updated the code, changing the 0 to 1, however the error still persists.
     
  5. @Zombie_Striker
    I dug into it for ya, and here's how it works.

    The datavalue is a bitfield (see BlockLog2.fromLegacyData()). The first two bits signify type (with 00 being acacia and 01 being dark oak), and the 3rd and 4th bits signify direction (where 00 = along the Y axis, 01 = along the X axis, 10 = along the Z axis and 11 = bark on all faces).

    So in theory, to get a dark oak block facing upwards, you should input a data value of 0b0001 (or just 1 in decimal), and an upwards facing acacia wood block should be 0b0000 (0 in decimal). And an all-bark dark oak block should be ob1101 (13).

    The error you're getting should only occur if you put in either 10 or 11 as the lower bits (IE 3 or 4, because those are invalid log types). Are you 100% sure you put in 0 when getting that error?
     
  6. Offline

    Zombie_Striker

    @AlvinB
    Well, it turns out the reason it was not working was actually because it wasn't using the code above. It turns out the value for the data was not 0 and instead was 2 (The code I set up for turning wood types into their corresponding data values was set to the wrong value). That was a few hours of debugging wasted.
     
Thread Status:
Not open for further replies.

Share This Page