"Block Position"

Discussion in 'Plugin Development' started by ExtendedHorizons, May 28, 2015.

Thread Status:
Not open for further replies.
  1. So im playing around with PlayOutBed packet but it requires a entity id which I got but it also requires a Block possition. I dont know how to get a block position and its not location.getBlock() or a location alone so I don't know what it is. It says I can cast it in the code but when I call the method the stack trace says I cant cast a block to a blockpossition. And if I try casting a location it wont let me in the code. Heres the code so far though:
    Code:
    public static void sendPacket2(Player player, Location loc){
            CraftPlayer p = (CraftPlayer) player;
            EntityHuman p1 = p.getHandle();
            BlockPosition blockpos = (BlockPosition) loc.getBlock();
            PacketPlayOutBed bed = new PacketPlayOutBed(p1, blockpos);
    
            p.getHandle().playerConnection.sendPacket(bed);
        }
     
  2. Offline

    N00BHUN73R

    @ExtendedHorizons
    Try doing this,
    Code:
    BlockPosition blockPos = new BlockPosition(loc.getBlock().getX(), loc.getBlock().getY(), loc.getBlock().getZ());
     
  3. Offline

    Agentleader1

    Instead of getting the location directly from the block;
    Code:
    block.getState().getLocation() //or getX,Y, or Z
     
  4. @N00BHUN73R Yeah I guess its just not the right packet I need to make a player lay down. I decided to make a bed invisible then force a fake npc with the players skin to sleep in it. Time to break my server a bit more xD
     
  5. Offline

    N00BHUN73R

    @ExtendedHorizons
    Lmfao sounds good to me xD, Last I heard I think you need a bed near the player in order to do that packet.. I could be wrong though!
     
Thread Status:
Not open for further replies.

Share This Page