Skip to content

Instantly share code, notes, and snippets.

View TheGlitch76's full-sized avatar

glitch TheGlitch76

  • United States
  • 22:12 (UTC -05:00)
View GitHub Profile
2e664a88ff499689d61d4cafd3ea5a3a80b2702864c11e8d7e2475e13296a839
public interface Duck {
@AutoImplement(Helper.class) // allowed at class or method level
void shim(Bar someArg);
@ManualImplement // to opt out in the case of class-level annotation, assumed by default otherwise
void implementedByMixin();
}
// thank HalfOfTwo for this monstrosity
public class Scanner implements PreLaunchEntrypoint {
private static final Field ACTIVE_TRANSFORMER, MIXIN_TRANSFORMER;
static {
Transformer.init();
System.out.println("I am become Mass ASM, destroyer of LexManos");
try {
@TheGlitch76
TheGlitch76 / a_1.16.4.txt
Last active January 2, 2021 03:29
SpecialBunny statistics
collected 2021-01-02 at 02:30 UTC
Total mods: 2781
Total mods using MCreator: 97 (5.0% of Forge mods)
Total mods with core mods: 56 (2.9% of Forge mods, 3.0% excluding MCreator)
Total mods with access transformers: 471 (24.5% of Forge mods, 25.9% excluding MCreator)
Forge mods using Mixins: 220 (11.4% of Forge mods, 12.1% excluding MCreator)
Fabric mods using Mixins: 728 (85.9% of Fabric mods)
Fabric: 847 (30.4%) Forge: 1915 (68.8%) Both: 14 (0.5%) Forge 1.12 or below: 1 (0.0%) Neither: 4 (0.1%)

Mixin style proposals

Mixin is a powerful bytecode manipluation tool, but despite Mumfrey's best attmepts to not let you shoot yourself in the foot, Mixin's defaults can cause all sorts of tiny, hard to catch problems to crop up in the kind of transformations common in Minecraft modding.

Ordinals

By default, Mixin has an ordinal of -1. This means that every instance of an @At injection point is matched.

Unless you are explicitly trying to target every instance, an ordinal must be provided.

If your ordinal is greater than 1 you must use a slice. The slice may have a higher ordinal than 1, but should use a point that is both as close to your injection point as possible and has the smallest ordinal.

@TheGlitch76
TheGlitch76 / Dockerfile
Created October 1, 2020 01:54
Distcc daemon for running gentoo on a raspberry pi
FROM gentoo/portage:latest as portage
FROM gentoo/stage3-amd64:latest as gentoo
COPY --from=portage /var/db/repos/gentoo /var/db/repos/gentoo
RUN emerge -1q crossdev
RUN USE="${USE} crossdev" emerge -1q distcc
RUN mkdir -p /var/db/repos/localrepo-crossdev/{profiles,metadata} && \
echo 'crossdev' > /var/db/repos/localrepo-crossdev/profiles/repo_name && \
echo "masters = gentoo" > /var/db/repos/localrepo-crossdev/metadata/layout.conf && \
chown -R portage:portage /var/db/repos/localrepo-crossdev
RUN mkdir -p /etc/portage/repos.conf
public class PatchworkModProvider implements ModProvider {
@Override
public void acceptCanidate(ProvidedModCanidateRepresentation representation) {
ModManifest manifest;
try {
manifest = Patchwork.parseManifest(representation.getPath());
} catch (ManifestParseException ex) {
//if its a bad manifest, fail hard
// else:
@TheGlitch76
TheGlitch76 / ModProvider.java
Last active April 20, 2020 03:03
interfaces
import java.nio.file.Path;
import net.fabricmc.loader.api.ModContainer;
public interface ModProvider {
/**
* This stage is for scanning a jar and optionally choosing to provide this jar as a /todo link/ ProvidedModContainer.
* No transformations should occur during this stage. This allows Loader to fail hard if two {@link ModProvider}s
* attempt to provide the same modid for a jar.
- Forge mods are remapped, patched, and loaded as full-class Fabric mods.
- Forge mods can be placed in the "mods" folder directly without any issues.
- Forge mods are not replaced, but instead the patched mods are kept in a cache somewhere else.
What we need:
- Two new stages that happen before mixins are applied: "discovery" and "addition" (todo better name for the latter)
discovery:
- Happens after all valid Fabric mods are put on the classpath, but before non-fabric mods are added to the classpath
- Patchwork specifically needs an option to exclude certain jars from being added to the classpath.
- Called "discovery" because this is the stage both Patchwork and Spungbric will use to find the jar files they need to do something with.
addition:
@Mixin(StatusEffectInstance.class)
public abstract class MixinStatusEffectInstance implements UpdateDurationSuperShim {
@Unique
private static final Object BLANK = new Object();
@Shadow
protected abstract int updateDuration();
@Unique
private ThreadLocal<Object> updateDurationLocal = new ThreadLocal<>();
@Inject(method = "updateDuration", at = @At("HEAD"), cancellable = true)