Solved Change block position not working

Discussion in 'Spigot Plugin Development' started by luigieai, Feb 4, 2017.

  1. Hey guys, what's up?

    I'm creating a plugin that has a machine, this machine digs tunnels, get ores and some other things, in minecraft, this machine is represented by a DISPENSER block, in my code, i created a object for the machine called 'Mineradora', and another class that manage to control all the machines on the world. the manager class, has a runnable that calls the act() method of all machines.
    On code below, you can see what the machine can do until now:

    Code (Text):
        public void act() {
            if ( hasCombustivel()) { //if has fuel
    What's my problem: Everything is working fine, but about 2 or 3 schedulers, the machine's block just diseappear, and when this happen, the machine don't dig anymore but continue to burning fuel:
    (ps: block moves position normally)
    After few schedules:

    This is the code where i change the machine position:

    Code (Text):
        private void changePosition(int x, int y, int z, BlockFace direction) {
            Block old = this.b; //the b variable is the machine block
            Block newB = this.b.getLocation().add(x, y, z).getBlock();
            this.b = newB;
            this.loc = newB.getLocation(); //the loc variable is the machine location

            // MaterialData d = newB.getState().getData();
            // org.bukkit.material.Dispenser disp = (org.bukkit.material.Dispenser)d;
            // disp.setFacingDirection(direction);


    (and if it's need, here is the all machines scheluders:)

    Code (Text):
    package com.master.skyMineradora.maquina;

    import java.util.Iterator;

    import org.bukkit.scheduler.BukkitRunnable;

    public class MaquinaRunnable extends BukkitRunnable {

        private MaquinaManager mm;

        public MaquinaRunnable(MaquinaManager mm) {
   = mm;

        public void run() {
            if (mm.getMaquinas().size() > 0) {
                Iterator<Maquina> it = mm.getMaquinas().listIterator();
                while (it.hasNext()) {
    I don't know why after some position changes the block just diseappear, can anyone please help me?
  2. NathanWolf


    Is it possibly trying to move into an unloaded chunk, or does it really disappear right in front of your eyes like in the screenshots?
  3. In front on my eyes, the block just move 2 or 3 times (and when move, it's like x+1 or z+1) and disappear.
  4. NathanWolf


    Hm, well that is puzzling then- assuming x,y,z and direction passed in there are something sane.
    • Like Like x 1
  5. Yes, as you can see, the direction actually does nothing, i made the code to move the block direction turns a comment, i was thinking that was the cause of the bug, but i was wrong haha. So the block just move from location to another location, i set the old location type to air and the new location no dispenser, and made the variables changes in my object aswell
  6. Is it possible that this happening because the block is trying to move to a negative coord?
    • Like Like x 1
  7. Feeling stupid guys

    The block is actually teleporting
    But err.... In a wrong location


    ty for the help, my bad!