What did I miss?

Discussion in 'Plugin Development' started by Pr07o7yp3, Mar 16, 2014.

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

    Pr07o7yp3

    Code:java
    1. for (int x = 1982; x <= 1985; x++)
    2. {
    3. for (int z = 1750; z <= 1751; z++)
    4. {
    5. Block block = getServer().getWorld(mainWorld).getBlockAt(x, 20, z);
    6. if (block != null && block.getType().equals(Material.POWERED_RAIL))
    7. {
    8. PoweredRail rail = (PoweredRail) block.getState();
    9. rail.setPowered(true);
    10. }
    11. }
    12. }


    Logs:
    Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_7_R1.block.CraftBlockState cannot be cast to org.bukkit.material.PoweredRail

    So, how can I activate powered rails via plugin and without any redstone?

    EDIT: I tried with PoweredRail rail = (PoweredRail) block.getState().getData();
    and there are no errors now but rails still doesn't activate...
     
  2. Offline

    mrkirby153

    Pr07o7yp3

    I don't think you can. You can try manually setting the block to powered rails but as soon as the block receives an update of any kind, it will revert back into its unpowered state
     
Thread Status:
Not open for further replies.

Share This Page