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);
8 Replies
Thanks for asking your question!
Make sure to provide as much helpful information as possible such as logs/what you tried and what your exact issue is
Make sure to mark solved when issue is solved!!!
/close
!close
!solved
!answered
Requested by zedamc#0
bump
Tbh this feels like a #development question, maybe try there?
In normal channels it's hard to ask questions. It never gets noticed.
bump
bump
so are you saying when you spawn the pig, the pig itself moves down a bit?
like by itself?
Yeah
anyways now I use a fox and gave it some properties:
Fox entity = world.spawn(i, Fox.class);
entity.setAware(false);
entity.setInvisible(false);
entity.setGravity(false);
entity.setInvulnerable(true);
entity.setSilent(true);
entity.addPassenger(player);
entity.setLeashHolder(null);
why not
pig.setGravity(false)
ohI think I fixed the entity going a little down by using a smaller entity
I made some code to lead the entity and the player but the problem is that they can't move as they are in the blocks
I tried using vex but the problem is that when they are not aware that they go up and down
I can't use nms because of geyser
Any ideas how to fix it?