Moving floating blocks

Discussion in 'Plugin Development' started by Kartufle, Mar 8, 2017.

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

    Kartufle

    So i have been trying to make a block that when you place it, it should slowly begin to rise while turning and 3 blocks up it should become solid.

    I have been trying to do it with falling sand blocks, armor stands, and blocks riding witherskulls but i can't seem to get any of it to work... the armor stand makes the block too small and doesn't seem to wanna teleport. And for some reason the setVelocity() has seemed to be doing nothing for any of the method... i'm surely doing something wrong here but could anyone help me with this?
     
  2. Offline

    Zombie_Striker

    @Kartufle
    1. Falling sand blocks cannot be rotated
    2. Armor stands cannot move. They can ride other entities, and the other entity can move (causing the AS to move), but you can't make the armor stand move on it's own. The actual size cannot change (unless you use custom resourcepacks and use Json editing to make the block larger)
    3. Unless you meant falling sand riding withers (which has the same problem as #1), you can't make actual blocks ride entities.
     
  3. Euhm I thought you can just move an armorstand on its own, why can't you its just a regular entity. Teleporting doesn't work indeed when it has an passenger but setting velocity works (Velocity doesn't work when noGravity is on) . You can just spawn a falling block and continuously set its velocity so it doesn't fall down.
     
  4. Offline

    Zombie_Striker

    Armorstands are not meant to move. They can fall, but when I tested it, armorstands do not react to velocity changes.
     
  5. I've did it many times before its definitely possible, you can just move it anywhere you want with velocity or teleport (teleport ejects the passenger).
     
  6. @Kartufle
    What if you spawned an invisible armorstand wearing the block in its head slot, then teleport it to where you want it to go?
     
  7. Then it will be smaller then the original block, you could fix that by using an texturepack.
     
  8. Offline

    Kartufle

    This is not impossible without a textture pack as it has been done and i have a vid here...



    As you can see the block floats up while rotating. I am NOT looking to replicate the crate, im just looking to recreate the effect of floating blocks being moved around as i would be able to do alot of awesome stuff.

    So if anyone could help me it would be much appreciated :)

    EDIT: Is it available now?
     
    Last edited: Mar 9, 2017
  9. Video is not available

    EDIT: you can see that while its rotating it is smaller then a normal block
     
  10. Offline

    Kartufle

    @stijntje)_jacobs I know. Its still pretty big thoe and thats the effect i wan't. You can also see the items coming out of the chest... they are pretty decent sized aswell as rotating
     
  11. Then you can just put the block you want on an armorstand's head, teleport or use velocity to move it up.
     
  12. Offline

    Kartufle

    @stijntje)_jacobs I already tryed that... could not get it to work thats why im here
     
    Last edited: Mar 9, 2017
  13. Can we see you're code?
     
  14. Offline

    Kartufle

    This is just some of all the crap i have tryed together in 1
    Code:
    public static void blockEffect(Player p, Vector v, ItemStack item) {
           
            if(!t){
                p.getLocation().setY(p.getLocation().getY() + height);
                t = true;
            }
    
            armorstand = (ArmorStand)p.getWorld().spawn(p.getLocation(), ArmorStand.class);
            armorstand.setGravity(false);
            armorstand.setVisible(false);
            Item i = p.getWorld().dropItem(p.getLocation(), item);
            i.setPickupDelay(999999);
            if(text != null){
                i.setCustomName(text);
                i.setCustomNameVisible(true);
            }
            armorstand.setVelocity(new Vector(0, 1, 0));
           
            armorstand.setPassenger(i);
           
            byte blockData = 0x0;
           
            Entity block = p.getWorld().spawnFallingBlock(p.getLocation().add(0, 1, 0), item.getType(), blockData);
           
            WitherSkull skull = (WitherSkull) p.getWorld().spawn(p.getLocation(), WitherSkull.class);
           
            block.setGravity(false);
    
            block.setVelocity(new Vector(0, 1, 0));
            block.setInvulnerable(true);
           
            skull.setDirection(new Vector(0, 1, 0));
            skull.setVelocity(new Vector(0, 1, 0));
            skull.setGravity(false);
            skull.setInvulnerable(true);
           
            skull.setPassenger(block);
        }
     
  15. The problem is that you are setting the gravity of the armorstand to false then you can't teleport or set velocity to it anymore
     
  16. Offline

    Kartufle

    But dropping a item on a armorstands head still doesn't make it as big as in the vid
     
  17. Offline

    Zombie_Striker

    @Kartufle
    That is because the big block is an actual block. While rotating, it is an armor stand with a chest as the helmet. When it stops and opens, it is an actual block.
     
  18. Offline

    Kartufle

    @Zombie_Striker I know that but it is still bigger while rotating then when it is just a dropped block. But how would i achieve this effect? could you give me any help on this? also the rotating items in the air? just some basics would be nice to go off from
     
  19. armorstand.setHelmet(ItemStack) When I tried for some reason I've had to set the itemstack to an amount of 2.
     
  20. Offline

    Kartufle

    @stijntje)_jacobs Ty ;) but for some reason the block gets offset

    EDIT: Nvm, fixed it

    Now i have this weird problem where everytime i place a armorstand it teleports even more than the last one i placed ;/
     
    Last edited: Mar 9, 2017
  21. Its on top of the armorstand yes so 1.5 block higher.
     
  22. Offline

    Zombie_Striker

    @Kartufle
    If your problem has been solved, mark this thread as solved.
     
  23. Offline

    Kartufle

    Now i have 1 last question because i wanted the block to rotate... so how do i rotate the head? i have tryed by setting head pos with yaws and all sorta stuff, and i wanna make the chest face the player, so the block should face opposite of the player so the front of the chest would be face to the player. And then i wanna be able to rotate the head around...
     
  24. Offline

    Zombie_Striker

    @Kartufle
    To rotate the head, you will have to change the head position. Use ArmorStand#setHeadPose(EulerAngle) to rotate the head. Using a little trig, you can convert angles to X/Z coordinates for the EulerAngle.

    Here's a method that converts degrees/radians to an euler angle
     
    Last edited: Mar 9, 2017
  25. Offline

    Kartufle

    @Zombie_Striker I have to teleport the armor stand to update the head position right?
     
  26. Offline

    Zombie_Striker

    @Kartufle
    You should not have to. Setting the head position should automatically change the head's position for the client.
     
  27. Offline

    Kartufle

    @Zombie_Striker So x and z is for rotating it around right? and y is for up and down? but its just doing some weird stuff when i rotate the head

    EDIT: Nvm, figured it out... for some reason y is rotating the head? hmm
     
    Last edited: Mar 9, 2017
Thread Status:
Not open for further replies.

Share This Page