Help with PoC: Rotating blocks spin erratically

Discussion in 'Plugin Development' started by blahsd101, Sep 11, 2014.

Thread Status:
Not open for further replies.
  1. Hello there, I'm working on a proof of concept that should be able to d demonstrate the possibility of creating structures that rotate in circular motion. This would apply to portcullises, windmills, raisable bridges, ferris wheels, whatever. However, it's not working at all. The cube that's supposed to rotate in a circle instead flips around erratically and does a circle there, then shifts a couple blocks, then does half a circle there, then shifts again, etc. There really isn't a good way to describe this, so here's my code, that I hope will speak more clear than my words.

    Code:java
    1. public void spawnRotationer (Location loc) { // Experimental. We'll see what use this has.
    2.  
    3. final FallingBlock rotationer = world.spawnFallingBlock(loc, Material.COBBLESTONE, (byte)0x0);
    4.  
    5. BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
    6. scheduler.runTaskTimer(this, new Runnable() {
    7. Vector velocity;
    8. int t = 0;
    9.  
    10. @Override
    11. public void run() {
    12. double vectX = Math.sin(t);
    13. double vectY = Math.cos(t);
    14.  
    15. velocity = new Vector(vectX, vectY+0.02, 0);
    16. // the 0.02 compensates for "minecraft gravity" otherwise the block constantly falls towards the ground (while erratically spinning mid-air)
    17.  
    18. rotationer.setVelocity(velocity);
    19. this.t += 1;
    20. }
    21. }, 0, 4);
    22.  
    23. }


    Does anybody have an idea of why it's not going in a circle? Also did anybody implement anything similar, using fallingBlockEntities to make something go around in a circle?
     
  2. Offline

    Mr_toaster111

    Basically i believe where the counter starts at is what changes the direction it starts moving try changing the int t = 0; to something else.
     
Thread Status:
Not open for further replies.

Share This Page