Skip to content

Instantly share code, notes, and snippets.

View Earthcomputer's full-sized avatar

Joseph Burton Earthcomputer

View GitHub Profile
@Earthcomputer
Earthcomputer / main.cu
Created January 15, 2024 21:20
Amethyst cluster finder
#include <algorithm>
#include <chrono>
#include <iostream>
#include <sstream>
#include <thread>
#include <vector>
#ifdef _MSC_VER
#include <immintrin.h>
#endif
@Earthcomputer
Earthcomputer / make_server.py
Last active February 3, 2023 14:50
A simple python script to download a Minecraft server of any version
#!/usr/bin/python
import datetime
import json
import pathlib
import shutil
import sys
import urllib.request
date_13w39a = datetime.datetime(2013, 9, 26, 15, 11, 19, tzinfo = datetime.timezone.utc)
@Earthcomputer
Earthcomputer / sideonly-rework.md
Created August 23, 2020 20:25
Rework of SideOnly inspections

Rework of SideOnly inspections

MinecraftDev's SideOnly inspections gave an error when you tried to access client-only code from common code, helping to prevent a common cause of crashes on the dedicated server.

Motivation

While they were very useful in the right circumstances, the old SideOnly inspections have a number of flaws which ultimately meant they didn't see the widespread use that was originally hoped for. The problems I'm about to outline led to them being disabled by default, so not everyone even knew they existed. While I was maintaining a fork of MinecraftDev with Fabric support (now merged upstream), I randomly came across them when scrolling through my inspections list, hacked together a fix so it would work with Fabric's @Environment annotation, and enabled them by default in my fork. This was a partial success, but still shared some of the issues as before. So, what are these issues? They can be broken down into 5 key problems with the old inspections:

  1. Litter. In order to use
@Earthcomputer
Earthcomputer / README.md
Last active July 4, 2021 13:15
Template readme for alpha fabric mods

$mod_name

$mod_description

Installation

  1. Download and install MultiMC if you haven't already.
  2. If you haven't already, press "create instance", and press "import from zip", and paste the following URL into the text field: https://cdn.discordapp.com/attachments/666758878813487136/699323306637262928/fabric-alpha.zip
  3. Download $mod_name from the releases page.
  4. Click on your new MultiMC instance and click "edit instance" on the right. Click "loader mods" then "add", and navigate to the mod you just downloaded, and press OK.

Contributing

@Earthcomputer
Earthcomputer / README.md
Last active July 4, 2021 13:16
Fabric Mod README Template

$mod_name

$mod_description

Installation

  1. Download and run the Fabric installer.
    • Note: this step may vary if you aren't using the vanilla launcher or an old version of Minecraft.
  2. Download the Fabric API and move it to the mods folder (.minecraft/mods).
  3. Download $mod_name from the releases page
@Earthcomputer
Earthcomputer / Jar vs Fabric.md
Created April 27, 2019 14:34
Comparison of whether CarpetMod should be a Jar Mod or a Fabric Mod

I'm going to attempt to give a fair comparison of how well CarpetMod would work as a Jar Mod vs a Fabric Mod in the future, then give my opinion at the end.

Jar Mods

Jar Mods are what the 1.12 and 1.13 versions of CarpetMod currently are. They basically work by us directly modifying vanilla classes directly. Quick rundown of the process that isn't too in-depth: in order for us to do this, we must first translate the bytecode which Java executes into readable source code that we can understand and edit. This process is called "decompilation". Then, after we have edited the classes, we translate the code back into back into bytecode which Java can execute ("recompilation"). We then distribute parts of the code we have made changes to. Recompilation is very trivial and is unlikely to contain any errors at all. Although we use the best decompiler that exists (ForgeFlower), decompilation is still not 100% accurate.

Fabric Mods

QuickCarpet for 1.14 is a Fabric Mod. Fabric Mods are loaded by a mod loader cal

grid = [-1] * 81
print("Input sudoku, spaces for blank:")
for y in range(9):
print("-" * 9)
row = input()
if len(row) > 9:
print("Invalid input")
exit()
@Earthcomputer
Earthcomputer / get_changed.py
Created August 13, 2018 04:12
Compares to JARs and filters out modified classes
from zipfile import ZipFile
import sys
if len(sys.argv) < 4:
print("python " + sys.argv[0] + " <unchanged.jar> <changed.jar> <output.jar>")
else:
with ZipFile(sys.argv[1]) as unchanged:
with ZipFile(sys.argv[2]) as changed:
with ZipFile(sys.argv[3], "w") as output:
for name in changed.namelist():
package mcp;
import javax.annotation.Nonnull;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import javax.annotation.meta.TypeQualifierDefault;
@Documented
@Earthcomputer
Earthcomputer / reverse_tsrg.py
Created August 13, 2018 00:10
Reverses a TSRG file
classMap = {}
def mapDescriptor(desc):
global classMap
newDesc = "("
index = 1
while index < len(desc):
if desc[index] == "L":
endIndex = index + 1
while desc[endIndex] != ";":