Skip to content

Instantly share code, notes, and snippets.

Avatar

Joseph Burton Earthcomputer

  • Sheffield, UK
View GitHub Profile
@Earthcomputer
Earthcomputer / sideonly-rework.md
Created Aug 23, 2020
Rework of SideOnly inspections
View sideonly-rework.md

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 Jul 4, 2021
Template readme for alpha fabric mods
View README.md

$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 Jul 4, 2021
Fabric Mod README Template
View README.md

$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 Apr 27, 2019
Comparison of whether CarpetMod should be a Jar Mod or a Fabric Mod
View Jar vs Fabric.md

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

View sodoku_solver.py
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 Aug 13, 2018
Compares to JARs and filters out modified classes
View get_changed.py
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():
View MethodsReturnNonnullByDefault.java
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
View reverse_tsrg.py
classMap = {}
def mapDescriptor(desc):
global classMap
newDesc = "("
index = 1
while index < len(desc):
if desc[index] == "L":
endIndex = index + 1
while desc[endIndex] != ";":
View how_to_make_mods_for_1.13.md

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
View 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: