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
@EventHandler
void onPreCommand(PlayerCommandPreprocessEvent e) {
if (e.getMessage().startsWith("//")) {
return;
}
String cmdName; // obtain command name
if (!e.getMessage().contains(" ")) {
cmdName = e.getMessage().substring(1);
@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<>();
@jarcode-foss
jarcode-foss / gist:e1fac61e20b76276d848
Created June 26, 2014 04:31
Get entities in radius
public static List<LivingEntity> getEntitiesInRadius(Location origin, double radius, LivingEntity... ignore) {
World w = origin.getWorld();
int blocks = (int) Math.ceil(radius);
int chunkRadius = (blocks / 16) + (blocks % 16 == 0 ? 0 : 1);
int ox = origin.getChunk().getX();
int oz = origin.getChunk().getZ();
ArrayList<Chunk> chunks = new ArrayList<>();
for (int x = -chunkRadius; x <= chunkRadius; x++)
@jarcode-foss
jarcode-foss / gist:e59936d475266eae402a
Created June 26, 2014 04:35
Determine if given location is directed at an entity
public static boolean isLookingAt(Entity entity, Location eye) {
double yaw = eye.getYaw() > 0 ? eye.getYaw() : 360 - Math.abs(eye.getYaw()); // remove negative degrees
yaw += 90; // rotate +90 degrees
if (yaw > 360)
yaw -= 360;
yaw = (yaw * Math.PI) / 180;
double pitch = ((eye.getPitch() + 90) * Math.PI) / 180;
AxisAlignedBB box = ((CraftLivingEntity) entity).getHandle().boundingBox;
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="/">Wacos</a>
<div class="nav-collapse collapse">
@jarcode-foss
jarcode-foss / gist:6c8bf0ed518327bab5ee
Created January 7, 2015 02:11
Simple Java Macros (with examples for POE)
import com.sun.jna.Library;
import com.sun.jna.Native;
import org.jnativehook.GlobalScreen;
import org.jnativehook.NativeHookException;
import org.jnativehook.keyboard.NativeKeyEvent;
import org.jnativehook.keyboard.NativeKeyListener;
import org.jnativehook.mouse.NativeMouseEvent;
import org.jnativehook.mouse.NativeMouseInputListener;
import java.awt.*;
@jarcode-foss
jarcode-foss / JavaMacro
Created January 7, 2015 02:13
Simple Java Macros (with examples for POE)
import com.sun.jna.Library;
import com.sun.jna.Native;
import org.jnativehook.GlobalScreen;
import org.jnativehook.NativeHookException;
import org.jnativehook.keyboard.NativeKeyEvent;
import org.jnativehook.keyboard.NativeKeyListener;
import org.jnativehook.mouse.NativeMouseEvent;
import org.jnativehook.mouse.NativeMouseInputListener;
import java.awt.*;
@jarcode-foss
jarcode-foss / JavaMacro
Created January 7, 2015 02:13
Simple Java Macros (with examples for POE)
import com.sun.jna.Library;
import com.sun.jna.Native;
import org.jnativehook.GlobalScreen;
import org.jnativehook.NativeHookException;
import org.jnativehook.keyboard.NativeKeyEvent;
import org.jnativehook.keyboard.NativeKeyListener;
import org.jnativehook.mouse.NativeMouseEvent;
import org.jnativehook.mouse.NativeMouseInputListener;
import java.awt.*;
@jarcode-foss
jarcode-foss / JavaMacro
Created January 7, 2015 02:13
Simple Java Macros (with examples for POE)
import com.sun.jna.Library;
import com.sun.jna.Native;
import org.jnativehook.GlobalScreen;
import org.jnativehook.NativeHookException;
import org.jnativehook.keyboard.NativeKeyEvent;
import org.jnativehook.keyboard.NativeKeyListener;
import org.jnativehook.mouse.NativeMouseEvent;
import org.jnativehook.mouse.NativeMouseInputListener;
import java.awt.*;
@jarcode-foss
jarcode-foss / JavaMacro
Created January 7, 2015 02:15
Simple Java Macros (with examples for POE)
import com.sun.jna.Library;
import com.sun.jna.Native;
import org.jnativehook.GlobalScreen;
import org.jnativehook.NativeHookException;
import org.jnativehook.keyboard.NativeKeyEvent;
import org.jnativehook.keyboard.NativeKeyListener;
import org.jnativehook.mouse.NativeMouseEvent;
import org.jnativehook.mouse.NativeMouseInputListener;
import java.awt.*;