Skip to content

Instantly share code, notes, and snippets.

View robere2's full-sized avatar
🏒

Erik Roberts robere2

🏒
View GitHub Profile
@robere2
robere2 / fetchAllAuctionPages.js
Last active May 3, 2024 15:28
Fetching auction data from the Hypixel API
/**
* Robust function to fetch all auction pages from https://api.hypixel.net/v2/skyblock/auctions. If the auctions update during the time that
* this function is executing, then it will restart in order to fetch the latest data.
* @returns {Promise<Object[], Error>} Array of JSON responses from the API, with each entry being a page of auction results. The results are not necessarily in order.
* @reject {Error} Network error
* @reject {Error} If the function restarts more than five times due to updates or an API response with "success" set to false.
* @license MIT
* @author https://github.com/robere2
* @see {@link https://gist.github.com/robere2/232691590952b1f1c3de1993b291b6eb} Source
*/
@robere2
robere2 / index.html
Last active August 27, 2023 14:20
Vite & PrismarineNBT Example
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>body { white-space: pre ; display: block; unicode-bidi: embed }</style>
</head>
<body>
<div id="app"></div>
<script type="module" src="/main.js"></script>
@robere2
robere2 / parse_nbt.js
Created August 9, 2019 03:53
Example on how to parse compressed or uncompressed Minecraft NBT data in Javascript
let fs = require('fs');
let nbt = require('prismarine-nbt');
let invData = [31, -117, 8, 0, 0, 0, 0, 0, 0, 0, -29, 98, 96, -32, 100, 96, -52, -28, 98, 96, 96, 80, 97, 98, 96, -54, 76, 97, 100, 98, 100, 96,
117, -50, 47, -51, 43, 97, -28, 98, 96, 46, 73, 76, 103, 100, -32, 14, -51, 75, 42, 74, 77, -52, 78, 76, -54, 73, 101, 100, 102, -32, -12,
-56, 76, 73, 117, -53, 73, 76, 47, 6, 106, -6, -57, -59, -64, -98, -110, 89, 92, -112, -109, 88, -55, -55, -64, -30, -109, 95, -108, -54, 1,
20, 101, 97, -32, 57, -76, -36, 60, 32, -75, 40, 91, 33, -77, 36, 53, 23, 40, 34, 124, 104, -71, -91, -74, -71, -126, 99, 73, 73, 98, 114,
-74, -126, 75, 98, 110, 98, 122, 42, 3, 31, 80, 16, -55, 108, 6, 6, 38, 6, 54, -88, 20, -120, 13, 114, 13, 43, 126, -41, -96, -24, -128, 0,
-120, 62, 54, -104, 62, 5, 76, 21, -40, 1, 0, 111, 21, -87, 83, 10, 1, 0, 0];
let buf = Buffer.from(invData);
@robere2
robere2 / unzip_nbt.js
Last active March 12, 2020 10:03
Example on how to unzip (but not parse) compressed NBT data in Javascript
let fs = require('fs');
let zlib = require('zlib');
let invData = [31, -117, 8, 0, 0, 0, 0, 0, 0, 0, -29, 98, 96, -32, 100, 96, -52, -28, 98, 96, 96, 80, 97, 98, 96, -54, 76, 97, 100, 98, 100, 96,
117, -50, 47, -51, 43, 97, -28, 98, 96, 46, 73, 76, 103, 100, -32, 14, -51, 75, 42, 74, 77, -52, 78, 76, -54, 73, 101, 100, 102, -32, -12,
-56, 76, 73, 117, -53, 73, 76, 47, 6, 106, -6, -57, -59, -64, -98, -110, 89, 92, -112, -109, 88, -55, -55, -64, -30, -109, 95, -108, -54, 1,
20, 101, 97, -32, 57, -76, -36, 60, 32, -75, 40, 91, 33, -77, 36, 53, 23, 40, 34, 124, 104, -71, -91, -74, -71, -126, 99, 73, 73, 98, 114,
-74, -126, 75, 98, 110, 98, 122, 42, 3, 31, 80, 16, -55, 108, 6, 6, 38, 6, 54, -88, 20, -120, 13, 114, 13, 43, 126, -41, -96, -24, -128, 0,
-120, 62, 54, -104, 62, 5, 76, 21, -40, 1, 0, 111, 21, -87, 83, 10, 1, 0, 0];
@robere2
robere2 / scrollableGuiExample.java
Last active March 28, 2019 17:46
Example of how to set up a very simple scrollable GUI in Minecraft
class ScrollableGui extends GuiScreen {
int scrollDistance = 0;
final int x = 10;
final int y = 10;
@Override
public void handleMouseInput() throws IOException {
super.handleMouseInput();
@robere2
robere2 / hypixel-tag-calculator.js
Last active November 29, 2023 03:18
Calculates the currently displayed player tag on the Hypixel Network, given a response from the API
const ranks = {
"ADMIN": [
[
'c',
"[ADMIN]"
]
],
"MODERATOR": [
[
'2',
@robere2
robere2 / Shotgun.java
Last active April 14, 2018 00:45
1.8.9 Sounds System Example
public void playFireSound() {
playSound("gun.shotgun.fire");
}
public void playReloadSound() {
playSound("gun.shotgun.reload");
}
/**
* Play sound