Leading entities through blocks

Hello, I am trying to make a plugin where you can make players unconscious and then you can drag them somewhere else(trap them). You have 2 minutes to do it.
I used pigs and leads for dragging players but as I want player to sit on the ground I have to make players a little above. I tried spawning a pig -0.5 y but the problem is that the pig goes a little down. This is a problem since the player then suffocates and the player isn't sitting on the ground. How would I fix this?
Code:
Location pigLocation = i; i.setY(pigLocation.getY() - 0.5); Pig pig = (Pig) world.spawn(location, Pig.class); pig.setAI(false); pig.setInvisible(true); pig.setInvulnerable(true); pig.setSilent(true); pig.addPassenger(player); pig.setLeashHolder(null);
Was this page helpful?