Skip to content

Instantly share code, notes, and snippets.

View IllusionTheDev's full-sized avatar
💥

ImIllusion IllusionTheDev

💥
View GitHub Profile
@IllusionTheDev
IllusionTheDev / GlassColor.java
Created October 11, 2024 02:27
Beacon color glass calculation
import org.bukkit.Color;
import org.bukkit.Material;
public enum GlassColor {
RED(Material.RED_STAINED_GLASS_PANE, Color.fromARGB(0x00FF0000)),
ORANGE(Material.ORANGE_STAINED_GLASS_PANE, Color.fromARGB(0x00FFA500)),
YELLOW(Material.YELLOW_STAINED_GLASS_PANE, Color.fromARGB(0x00FFFF00)),
LIME(Material.LIME_STAINED_GLASS_PANE, Color.fromARGB(0x0000FF00)),
GREEN(Material.GREEN_STAINED_GLASS_PANE, Color.fromARGB(0x00008000)),
CYAN(Material.CYAN_STAINED_GLASS_PANE, Color.fromARGB(0x0000FFFF)),
@IllusionTheDev
IllusionTheDev / BlockStorage.java
Created February 6, 2024 23:47
World storage example
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
public interface BlockStorage<T extends WorldBlock> extends Storage {
CompletableFuture<List<T>> fetchChunkData(UUID worldId, Long chunkId);
CompletableFuture<Void> insertData(UUID worldId, Long chunkId, T data);
CompletableFuture<Void> deleteChunkData(UUID worldId, Long chunkId);
@IllusionTheDev
IllusionTheDev / Reflect.java
Created December 8, 2023 16:28
Reflection Helper
public final class Reflect {
private Reflect() {
}
public static <T> ReflectedClass<T> aClass(Class<T> clazz) {
return new ReflectedClass<>(clazz);
}
@IllusionTheDev
IllusionTheDev / BasicEuclideanComparator.java
Created May 16, 2023 15:42
Minecraft map color matching
import java.awt.*;
import java.util.Comparator;
/**
* The basic euclidean comparator is a simple comparator that compares two colors
* based on their euclidean distance.
*
* @author Illusion
*/
public class BasicEuclideanComparator implements Comparator<Color> {
@IllusionTheDev
IllusionTheDev / CachedEditSession.java
Created July 29, 2022 23:18
Fancy client-sided blocks
// EditSession but made to cache packets
public class CachedEditSession {
private final Location origin;
private final Location offset;
private final FakeBlockTracker tracker;
private final Map<Vector, BlockData> cachedData = new ConcurrentHashMap<>();
@IllusionTheDev
IllusionTheDev / BodyPart.java
Created July 5, 2022 11:30
Obtain a raytraced body part for a minecraft entity
public enum BodyPart {
RIGHT_LEG,
LEFT_LEG,
HEAD,
BODY;
public static BodyPart rayTrace(RayTraceResult result) {
Entity entity = result.getHitEntity();
@IllusionTheDev
IllusionTheDev / EasyMetadataPacket.java
Created April 2, 2022 23:46
Easy client-side entity metadata
import com.comphenix.protocol.reflect.accessors.Accessors;
import com.comphenix.protocol.reflect.accessors.ConstructorAccessor;
import com.comphenix.protocol.utility.MinecraftReflection;
import com.comphenix.protocol.wrappers.WrappedBlockData;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
@IllusionTheDev
IllusionTheDev / I'm a night 🦉
Last active February 7, 2022 01:09
Commit activity
🌞 Morning 18 commits ██▊░░░░░░░░░░░░░░░░░░ 13.2%
🌆 Daytime 27 commits ████▏░░░░░░░░░░░░░░░░ 19.9%
🌃 Evening 49 commits ███████▌░░░░░░░░░░░░░ 36.0%
🌙 Night 42 commits ██████▍░░░░░░░░░░░░░░ 30.9%
@IllusionTheDev
IllusionTheDev / KnockbackUtil.java
Last active August 18, 2024 00:33
Simulate realistic player knockback
// Ported from Exerosis' kotlin example
public class KnockbackUtil {
private static final double FRICTION = 1.0;
private static final double HORIZONTAL = 0.40;
private static final double VERTICAL = 0.36075;
private static final double EXTRA_VERTICAL = 0.1;
private static final double EXTRA_HORIZONTAL = 1.5;
public static Vector getKnockback(Location entityLoc, Entity attacker) {
@IllusionTheDev
IllusionTheDev / EasyMetadataPacket.java
Last active June 1, 2023 08:50
Test client-side entity
package me.illusion.test;
import com.comphenix.protocol.reflect.accessors.Accessors;
import com.comphenix.protocol.reflect.accessors.ConstructorAccessor;
import com.comphenix.protocol.utility.MinecraftReflection;
import com.comphenix.protocol.wrappers.WrappedBlockData;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
import org.bukkit.inventory.ItemStack;