Skip to content

Instantly share code, notes, and snippets.

@WizardlyBump17
WizardlyBump17 / Coord.java
Created August 9, 2024 21:36
Some methods to compress coordinates
import java.util.Arrays;
public class Coord {
public static void main(String[] args) {
int x = (int) -Math.pow(2, 32);
int y = (int) Math.pow(2, 23) - 1;
int z = (int) Math.pow(2, 32);
int chunkX = x >> 4;
@WizardlyBump17
WizardlyBump17 / Bomba1e2.java
Last active July 16, 2024 02:05
Some bombastic code to apply placeholders, parse strings (input: "test 123" a b, output: [test 123, a, b] and trim strings (input: a b, output: a b)
package com.wizardlybump17.tests.generic;
import lombok.NonNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Bomba1e2 {
@WizardlyBump17
WizardlyBump17 / basic.ini
Created May 23, 2024 19:43
Profile for Linux, 2160x1080, mpeg2video, bitrate 150M, pcm_s32le 192Kbps. Works on Davinci Resolve
[General]
Name=Profile name
[Output]
Mode=Advanced
FilenameFormatting=%CCYY-%MM-%DD %hh-%mm-%ss
DelayEnable=false
DelaySec=20
DelayPreserve=true
Reconnect=true
@WizardlyBump17
WizardlyBump17 / Main.java
Created February 11, 2024 01:22
a command parser sytem
import lombok.NonNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
@WizardlyBump17
WizardlyBump17 / Main.java
Created October 12, 2023 19:04
Getting the inventory after the InventoryClickEvent
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this, ListenerPriority.HIGHEST, List.of(PacketType.fromClass(ServerboundContainerClickPacket.class)), ListenerOptions.SYNC) {
@Override
public void onPacketReceiving(PacketEvent event) {
ServerboundContainerClickPacket packet = (ServerboundContainerClickPacket) event.getPacket().getHandle();
ServerPlayer serverPlayer = ((CraftPlayer) event.getPlayer()).getHandle();
PacketUtil.handleContainerClick(packet, serverPlayer);
event.setCancelled(true);
@WizardlyBump17
WizardlyBump17 / buildtools.sh
Created September 23, 2023 19:50
Utility script to easily run the BuildTools provided by Spigot
#!/bin/bash
# checks if this script was executed correctly
if (( $# == 0 )); then
echo -e "Usage: $0 <version> [Java path]"
exit 2
fi
digit_regex="^[0-9]+$"
@WizardlyBump17
WizardlyBump17 / SuperBigWorld2023WorkingVersion.java
Created March 24, 2023 22:09
change world height (client only)
@Override
public void onPacketSending(PacketEvent event) {
ClientboundLoginPacket packet = (ClientboundLoginPacket) event.getPacket().getHandle();
Holder.Reference<DimensionType> dimensionType = (Holder.Reference<DimensionType>) clone((Holder.Reference<?>) packet.dimensionType(), clone(packet.dimensionType().value()));
event.setPacket(new PacketContainer(
PacketType.fromClass(packet.getClass()),
new ClientboundLoginPacket(
packet.playerId(),
packet.hardcore(),
packet.gameType(),
@WizardlyBump17
WizardlyBump17 / BuildToolsRunner.java
Created October 21, 2022 22:18
Simple Java utility class to download and run BuildTools
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
public class BuildToolsExecutor {
//java -Dversion=1.19.2 BuildToolsExecutor.java
//java -Djava=custom_path -Dversion=1.19.2 BuildToolsExecutor.java
@WizardlyBump17
WizardlyBump17 / Example.java
Created September 20, 2022 20:02
makes it possible to use almost any object in the PersistentDataContainer API
PersistentDataContainer container = /*your container*/;
container.set(KEY, SerializableDataType.INSTANCE, new Location(Bukkit.getWorld("world"), 0, 64, 0));
container.set(KEY, SerializableDataType.INSTANCE, Map.of("test key", "test value"));
@WizardlyBump17
WizardlyBump17 / InventoryFit.java
Created July 6, 2022 18:17
simple method to check if the given items can fully fit in the given inventory
// Method copied from CraftInventory#addItem, but I removed the code that adds items to the inventory
public static boolean canFit(Inventory inventory, ItemStack... items) {
Validate.noNullElements(items, "Item cannot be null");
ItemStack[] inventoryItems = getContents(inventory);
for (ItemStack item : items) {
while (true) {
int firstPartial = firstPartial(inventoryItems, item);