Skip to content

Instantly share code, notes, and snippets.

View unascribed's full-sized avatar

Una unascribed

View GitHub Profile
@unascribed
unascribed / BrokenHash.java
Last active March 28, 2024 16:10
How to generate a (correct) Minecraft-style hex digest. Tested.
package com.unascribed.brokenhash;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.nio.charset.StandardCharsets;
/**
* Generates a broken Minecraft-style twos-complement signed
@unascribed
unascribed / BOTS.md
Last active January 25, 2024 14:25

Sleeping Town Bot Policy

Bot accounts are welcmoe, provided they follow these rules:

  1. All Markov bots or other generative bots that may output nonsense must always post unlisted, or with a CW.
  2. If a bot will post public posts, it must not post any more frequently than once an hour and must be clearly marked as a bot in its display name.
  3. Bots must never mention other users unless the mentioned user has initiated it. For such user-initiated posts, any rate limits may be ignored.
  4. The bot's operator must be included in its description or a pinned post.
  5. Top-level unlisted or followers-only posts must not be made any more frequently than every 15 minutes.
    • Exception: Now-playing or scrobble bots may post as frequently as once a minute.
  6. If a bot incorporates data from posts made by another user that are not directed at the bot, the bot must be following that user.
@unascribed
unascribed / mcpbot archive.md
Last active October 24, 2023 02:54
Fixing "Etag download for http://export.mcpbot.bspk.rs/versions.json failed with code 522" in old ForgeGradle

MCPBot is finally dead, and so goes with it every old version of ForgeGradle. Hope you're not maintaining any 1.7-1.12 mods anymore (or, god forbid, 1.6)! Because if you do, nobody will help you, and if you ask you will be banned from all official Forge channels. Fun fun fun. Game over.

...Or not. Someone asked ArchiveBot to rescue the MCPBot exports, and a WARC file containing a seemingly complete archive is available for download. And, these old ForgeGradle versions download mappings over plain HTTP, not HTTPS!

Some context

I maintain Ears, a mod available for too many versions of Minecraft, and it uses old versions of ForgeGradle to build the 1.6, 1.7, 1.8, 1.9-1.11, and 1.12 ports. Because reengineering these old versions of ForgeGradle is a huge goddamn wa

@unascribed
unascribed / randomUUID.js
Last active October 5, 2023 11:35
A simple and readable way to generate valid v4 UUIDs in JavaScript. CC0 https://creativecommons.org/publicdomain/zero/1.0/
function randomUUID() {
return randhex(8) + "-" + randhex(4) + "-4" + randhex(3) + "-" + choice(["8", "9", "a", "b"]) + randhex(3) + "-" + randhex(12);
}
let scratchTarr = new Uint32Array(1);
function choice(arr) {
crypto.getRandomValues(scratchTarr);
return arr[Math.floor(scratchTarr[0]%arr.length)]
}
function randhex(count) {
crypto.getRandomValues(scratchTarr);
/*
* To the extent possible under law, the author has dedicated all copyright
* and related and neighboring rights to this software to the public domain
* worldwide. This software is distributed without any warranty.
*
* See <http://creativecommons.org/publicdomain/zero/1.0/>
*/
package com.unascribed;
/*
* To the extent possible under law, the author has dedicated all copyright
* and related and neighboring rights to this software to the public domain
* worldwide. This software is distributed without any warranty.
*
* See <http://creativecommons.org/publicdomain/zero/1.0/>
*/
package com.unascribed.random;
#!/bin/bash
if [[ "$1" == "-h" || "$1" == "-?" || "$1" == "--help" ]]; then
(
echo 'copycat: copy stdin or files specified on command line to Wayland and/or X clipboard'
echo 'performs automatic mimetype detection like wl-copy via file under X'
echo 'usage:'
echo ' copycat: copy stdin to clipboard'
echo ' copycat <-h|--help|-?>: display usage help'
echo ' copycat <files...>: concatenate each file, then copy to clipboard'
echo
package com.unascribed.chipper;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL43.*;
import static org.lwjgl.system.MemoryUtil.*;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

Common Sense Balancing Standard (CSBS)

  • No ore tripling, quadrupling, quintupling, etc. Ever.
    • The absolute limit on ore multiplication is 2.6 ingots per ore block, with typical gains being closer to 1.6.
  • A single block can never store more than 36 stacks of items, even when it's part of a multiblock structure.
  • Furnace-burning fuels should produce no more than 30RF per furnace fuel tick.
    • It can produce this as slowly or as quickly as you want.
  • Wireless interactions are permissible, and a trivial wireless implementation generally performs well.
    • However, well-designed network-topography-aware systems (i.e. wires) often outstrip the performance of wireless systems, and occasionally even dumb cellular systems do. More importantly, wireless is unsatisfying gameplay.
  • Time is not a balancing mechanic.