fixed more orientation errors when placing from other directions
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package eu.mhsl.minecraft.pixelblocks.pixelblock;
|
||||
|
||||
import eu.mhsl.minecraft.pixelblocks.Main;
|
||||
import eu.mhsl.minecraft.pixelblocks.utils.Direction;
|
||||
import eu.mhsl.minecraft.pixelblocks.utils.ListUtil;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.NamespacedKey;
|
||||
@ -76,6 +77,15 @@ public class Pixels {
|
||||
}
|
||||
|
||||
private void setEntityRotation(Entity entity, @Nullable Directional direction) {
|
||||
Direction blockDirection = parentBlock.getFacingDirection();
|
||||
float angle = switch (blockDirection) {
|
||||
case Direction.north -> 180;
|
||||
case Direction.south -> 0;
|
||||
case Direction.west -> 90;
|
||||
case Direction.east -> -90;
|
||||
};
|
||||
entity.setRotation(entity.getYaw()+angle, entity.getPitch());
|
||||
|
||||
if(!(direction instanceof EnderChest || direction instanceof Chest)) return;
|
||||
BlockFace blockFace = direction.getFacing();
|
||||
float yaw = switch (blockFace) {
|
||||
@ -91,6 +101,6 @@ public class Pixels {
|
||||
case DOWN -> -90;
|
||||
default -> 0;
|
||||
};
|
||||
entity.setRotation(yaw, pitch);
|
||||
entity.setRotation(entity.getYaw()+yaw, entity.getPitch()+pitch);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user