Skip to content

Instantly share code, notes, and snippets.

View bfu4's full-sized avatar
🌸

bfu4 bfu4

🌸
View GitHub Profile
@bfu4
bfu4 / modding_spigot.md
Last active May 13, 2021 16:26
Basis of Spigot Modding POC

Turning Spigot into Forge

A concept, that is seemingly not too far from reality.

Abstract

Plugin development is modding, though not really considered modding by a lot of Minecraft Forge developers. That is fine. I'm very well aware that Spigot development as well as plugin development is probably a joke, and it's probably not impressive unless you're modifying the server(.jar). The deeper you get into plugin development, the more you learn from it -- including being able to do more than you would normally be able to with the Spigot API, using NMS (net.minecraft.server).

Ideologically, most people want to work through an API anyways. When you want to access NMS in its true, "raw" self,

@bfu4
bfu4 / fix_smaller_int_size_cast.patch
Created April 4, 2021 19:26
really fucking stupid patch to get jdk17-internal to compile on m1
diff --git a/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_MidiUtils.c b/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_MidiUtils.c
index b139020c7b2..7f561db3bca 100644
--- a/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_MidiUtils.c
+++ b/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_MidiUtils.c
@@ -255,9 +255,9 @@ INT32 MIDI_Utils_GetDeviceVersion(int direction, INT32 deviceID, char *name, UIN
}
-static MIDIClientRef client = (MIDIClientRef) NULL;
-static MIDIPortRef inPort = (MIDIPortRef) NULL;
@bfu4
bfu4 / print.py
Created May 15, 2021 07:24
micropython example
# ==== PSEUDO translation for micropython
# ==== GIVEN:
print("hi")
# `dis` interprets this as
"""
2 0 LOAD_NAME 0 (print)
2 LOAD_CONST 0 ('hi')
@bfu4
bfu4 / viul
Last active May 25, 2021 17:59
./waifuapi <endpoint> (Mac)
#!/bin/bash
cd ~/.Trash
NAME=`echo "$1" | awk -F/ '{print $4}'`
wget "$1" -q
viu ~/.Trash/"$NAME"
rm ~/.Trash/"$NAME"
@bfu4
bfu4 / colors.py
Last active June 1, 2021 04:35
Colors
class Colors:
@staticmethod
def red() -> str:
"""
The color red
:return: red
"""
return Colors.__fmt(124)
@bfu4
bfu4 / color.cc
Last active June 4, 2021 17:12
I KEEP WRITING COLOR FORMATS, HELP
#define npos_v 18446744073709551615UL
static std::string color_format(int color) {
std::string formatted = "\u001b[38;5;" + std::to_string(color) + "m";
return formatted;
}
typedef struct color_t {
std::string color;
std::string escape;
import java.util.Arrays;
import java.util.stream.Stream;
public final class QuickSet<E> {
/**
* Maximum size of elements before beginning the rotation.
*/
private final int maxSize;
@bfu4
bfu4 / ObtuseReflection.java
Last active October 10, 2021 21:47
aids way to construct an object from a class and argument type fuck box types fr
public <T> T makeObject(Class<T> clazz, Object... args) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
Class<?>[] types = Arrays.stream(args).map(cls -> getPrimitiveType(cls.getClass())).toArray(Class[]::new);
Constructor<T> constr = getConstructor(clazz, types);
constr.setAccessible(true);
return constr.newInstance(args);
}
@SuppressWarnings("unchecked")
public <T> Constructor<T> getConstructor(Class<T> clazz, Class<?>... types) {
return (Constructor<T>) Arrays.stream(clazz.getDeclaredConstructors())
@bfu4
bfu4 / Entry.java
Created July 17, 2021 02:23
instance building utilizing generics (and bloat) to try to make any instance of a class as possible
/**
* Base abstraction of a pair.
*
* @param <K> key
* @param <V> value
*/
public interface Entry<K, V> {
/**
* Get key.
@bfu4
bfu4 / color.go
Created August 20, 2021 05:43
colors again
package colors
import "strconv"
type Color int
const (
Black Color = iota
Red
Green