Skip to content

Instantly share code, notes, and snippets.

View Earthcomputer's full-sized avatar

Joseph Burton Earthcomputer

View GitHub Profile
package test;
import java.util.Arrays;
import java.util.Random;
import java.util.stream.Collectors;
public class TestRandom extends Random {
private static final long serialVersionUID = 1L;
package test;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.server.MinecraftServer;
import test.TestRandom.DebugLevel;
public class CommandDebugRandom extends CommandBase {
@Earthcomputer
Earthcomputer / big oak tree growth.md
Last active October 2, 2021 17:48
A description of the big oak tree growth algorithm in Minecraft

Big Oak Tree Growth Algorithm

Outline

A big oak tree is made up of a main trunk and multiple branches. A "branch" always contains leaves, but may not always contain logs.

Parameters

  • heightLimit: The actual height of the tree, including leaf blocks at the top (between 5 and 16)
  • trunkHeight: The height of the trunk
  • leafDistanceLimit: The distance from a log that leaves can generate, set to 4 for sapling growth, though appears to be set to 5 for natural growth for some reason
@Earthcomputer
Earthcomputer / specialsource_fix.py
Created August 1, 2018 09:22
specialsource_fix.py
# EARTHCOMPUTER'S HACKFIX FOR SPECIALSOURCE FUCKING UP IN 1.13
from zipfile import ZipFile
import sys
def load_csrg(csrgf):
csrg = {}
for line in csrgf:
parts = line.rstrip().split(" ")
if len(parts) > 2:
@Earthcomputer
Earthcomputer / how_to_make_mods_for_1.13.md
Last active October 16, 2022 14:03
How to make mods for 1.13

Decompiling

  1. Clone MCPConfig from the GitHub repository.
  2. In the root project directory, run gradlew :1.13:projectClientApplyPatches if you want to make a client side mod, or gradlew :1.13:projectServerApplyPatches if you want to make a server side mod.
  3. Naviage into versions/1.13/projects/server (or client). There are a couple of fixes necessary to get the code to compile:
    1. There is a missing class mcp.MethodsReturnNonnullByDefault which you will have to manually add. A copy can be found here.
    2. If you're making a server-only mod, the anonymous classes in net.minecraft.item.ItemClock and net.minecraft.item.ItemCompass need to be modified to override the method in net.minecraft.item.IItemPropertyGetter. This is never actually called on the server so you can make a dummy implementation.
  4. Copy versions/1.13/projects/server (or client) into a separate
@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] != ";":
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 / 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():
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 / 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