Skip to content

Instantly share code, notes, and snippets.

@MajsterTynek
MajsterTynek / snf-convert.cpp
Created September 11, 2022 15:33
Program that demonstrates conversion of SNF file into a WAV file. SNF file format comes from Dispel game. Visit our [reddit](https://www.reddit.com/r/DispelRPG/) and [discord](https://discord.gg/Kz23q2qb7c) server!
// PROTOTYPE PROGRAM THAT DEMONSTRATES
// CONVERTING SNF TO WAV FORMAT
#include <string>
#include <fstream>
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
typedef unsigned char BYTE; // 1 byte
@MajsterTynek
MajsterTynek / JavaRandom.h
Last active May 5, 2022 12:51
C implementation of 'java.lang.Random' using preprocessor macros, without using structures or classes. Use-cases were [tested](imgur.com/a/SN9ZP0B) with C++.
#ifndef java_util_Random
#define java_util_Random
/// this mimics the java.util.Random class using C language
/// ensure thread safety on your own as there is no synchronization
/// JavaRandom rand = MAKESEED(seed); //
typedef long long JavaRandom; // no need for classes!
/// for default constructor feed it millis since epoch
#define MAKESEED(seed) (((seed) ^ 0x5DEECE66DLL) & ((1LL << 48) - 1))
#define UPDATESEED(seed) (((seed) * 0x5DEECE66DLL + 0xBLL) & ((1LL << 48) - 1))
@MajsterTynek
MajsterTynek / BARITONE.cxx
Created March 31, 2022 21:50
Unofficial specification of Baritone Cache Region file format. (*.bcr) Check 'BcrFileFormatSpec.txt' as it explains the layout and meaning of values. Included example programs in C++20 that unpack ('bcr-gun') and parse ('bcr-parse') data contained within a single 'bcr' file. I had to port some things to mimic Java and Baritone behaviours. Those …
/* Here are stored functions that
* mimic Baritone and Java internals
* just to simplify the converter*/
// baritone.utils.pathing.PathingBlockType
enum PathingBlockType {AIR, WATER, AVOID, SOLID};
// Base values used you need to know:
#define CACHED_REGION_MAGIC 0x1B2E5B7E // 456022910 BE!
#define CHUNK_NOT_PRESENT 0
@MajsterTynek
MajsterTynek / gallop.lua
Created May 22, 2021 23:17
HorseAutoGallop - requires AdvancedMacros 7.10.0wd_pre136 from WD_fix fork build. (Find it in AM's #creations or `gradlew build` it yourself from my repo)
-- bind to keypress MOSE:4
-- halts movement till sound comes back
-- prevents kicking caused by outrunning server
-- basically waits for getting sound packets back
local player, horse, last_gallop, action, x, y, z, a, b, c, hi, lo, last
local unpack, format, sqrt = table.unpack, string.format, math.sqrt
local waitTick, runOnMC, getPlayer = waitTick, runOnMC, getPlayer
local logdel, gal = logdel, 420780262
@MajsterTynek
MajsterTynek / obby_craft.lua
Last active August 26, 2020 22:31
Script for crafting enchanted items on Hypixel (a Minecraft server). Script written in Lua for supposed use with Advanced Macros mod.
-- event container open
local _, _, controls, name = ...
if name ~= "chest" then return end
if not craft_sync then return end -- craft script not invoked
if not craft_type then craft_type = "minecraft:cobblestone" end
if craft_type == "minecraft:ender_pearl" then craft_stack = 16 end
if not craft_stack then craft_stack = 64 end
-- making these local for efficiency
local clock, push, pop = os.clock, table.insert, table.remove
@MajsterTynek
MajsterTynek / reverse_double_linked_list.cpp
Last active February 25, 2017 15:15 — forked from anneomcl/reverse_linked_list.cpp
TheHappieCat: Reversing Double Linked Lists
// Example program
#include <iostream> // std::cout
#include <utility> // std::swap
using std::cout;
using std::swap;
struct Node {
int data;
Node* next;
Node* prev;
@MajsterTynek
MajsterTynek / bootsect.asm
Created February 21, 2017 19:17
bootsector [NASM]
[bits 16]
[org 0x7c00]
; BIOS loads it at ... or ... :
; CS:IP = 07c0:0000
; CS:IP = 0000:7c00
jmp word 0x0000:start
start: ; just to be sure it has proper origin
; loading machine code from floppy
mov ah, 2 ; int 13h service: read sectors