Skip to content

Instantly share code, notes, and snippets.

View bluelhf's full-sized avatar
🪖
in military service

Ilari Suhonen bluelhf

🪖
in military service
View GitHub Profile
@bluelhf
bluelhf / intersections.jsh
Last active June 4, 2022 18:18
JShell script that loads a method for finding intersections between a ray and a sphere given the origin of the sphere, the origin of the ray, the direction vector of the ray, and the radius of the sphere.
import static java.lang.Math.*;
double[][] intersections(double[] p, double[] o, double[] d, double r) {
double[] ip = inverse(p);
double a = dot(d, d);
double b = 2 * dot(o, d) + 2 * dot(ip, d);
double c = dot(o, o) + 2 * dot(ip, o) + dot(ip, ip) - pow(r, 2);
double dct = pow(b, 2) - 4 * a * c;
@bluelhf
bluelhf / ComponentUtils.java
Created September 11, 2021 15:23
Handles replacing printf-style format strings and named format strings in Adventure text components
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.TextReplacementConfig;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.MatchResult;
@bluelhf
bluelhf / Buffers.java
Created September 6, 2021 06:20
File Monitor with Apache DigestUtils
public class Buffers<T> {
private T previous = null, current;
public Buffers(T def) {
this.current = def;
this.previous = def;
}
public void swap() {
T temp = current;
current = previous;
@bluelhf
bluelhf / serializer.sk
Created February 21, 2020 14:52
Easy serialization utility for item types in skript-mirror (tested in 1.15.2)
option NMS:
get:
return 4th element out of ((class "org.bukkit.Bukkit").getServer().getClass().getPackage().getName() split at ".") # Yay NMS version!
import:
net.minecraft.server.{@NMS}.MojangsonParser # Used for String -> NBTTagCompound conversion
net.minecraft.server.{@NMS}.ItemStack as NMSItemStack # Used to generate an NMS ItemStack from an NBTTagCompound with the NMSItemStack#a(NBTTagCompound) method
plural expression serialized %itemtypes%:
return type: strings
get:
loop exprs-1:
@bluelhf
bluelhf / kits.sk
Created September 14, 2019 17:07
basic kit system for vanilla skript 2.4
command /kit [<text>]:
permission: kits.kit
trigger:
if arg-1 isn't set:
send "&6Kits: &e%all indices of {kitsystem.kits::*}%"
stop
set {_i::*} to all indices of {kitsystem.kits::*}
if {_i::*} doesn't contain uncoloured arg-1:
send "&cThat kit doesn't exist!"