Skip to content

Instantly share code, notes, and snippets.

View jarcode-foss's full-sized avatar

Levi Webb jarcode-foss

  • Canada, BC
View GitHub Profile
@jarcode-foss
jarcode-foss / gist:8d4d3389baa314853475
Created June 26, 2014 03:09
Get entities given player is looking at
private static List<LivingEntity> getEntitiesLookingAt(Location p, Player player, double total, Timestamp.TimestampType type) {
double yaw = p.getYaw() > 0 ? p.getYaw() : 360 - Math.abs(p.getYaw()); // remove negative degrees
yaw += 90; // rotate +90 degrees
if (yaw > 360)
yaw -= 360;
yaw = (yaw * Math.PI) / 180;
double pitch = ((p.getPitch() + 90) * Math.PI) / 180;
ArrayList<LivingEntity> entities = new ArrayList<>();
@EventHandler
void onPreCommand(PlayerCommandPreprocessEvent e) {
if (e.getMessage().startsWith("//")) {
return;
}
String cmdName; // obtain command name
if (!e.getMessage().contains(" ")) {
cmdName = e.getMessage().substring(1);