Created
June 11, 2020 04:46
-
-
Save fadookie/e43fb6e874729f70e06ee3d363a57f5e to your computer and use it in GitHub Desktop.
MC mixin test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Mixin(ServerWorld.class) | |
public class ServerWorldMixin extends World { | |
// I had to implement this to make the compiler happy but I'm hoping it's not actually going to be called | |
private ServerWorldMixin() { | |
super(null, null, null, null, false); | |
} | |
// This was working before I tried to access this.dimension | |
@Inject(at = @At("RETURN"), method = "<init>(Lnet/minecraft/server/MinecraftServer;Ljava/util/concurrent/Executor;Lnet/minecraft/world/WorldSaveHandler;Lnet/minecraft/world/level/LevelProperties;Lnet/minecraft/world/dimension/DimensionType;Lnet/minecraft/util/profiler/Profiler;Lnet/minecraft/server/WorldGenerationProgressListener;)V") | |
private void constructor(MinecraftServer server, Executor workerExecutor, WorldSaveHandler worldSaveHandler, LevelProperties properties, DimensionType dimensionType, Profiler profiler, WorldGenerationProgressListener worldGenerationProgressListener, CallbackInfo info) { | |
System.out.println("Hello server world ctor! CallBack:" +info + ", properties:" + properties + " levelName:" + properties.getLevelName() + " version:" + properties.getVersion() + " thunderTime:" + properties.getThunderTime() + " dimension:" + dimensionType); | |
if (dimensionType == DimensionType.OVERWORLD) { | |
CompoundTag worldData = properties.getWorldData(dimensionType); | |
System.out.println("In overworld! :D worldData:" + worldData.toString()); | |
} | |
} | |
// I never observed this get called | |
@Inject(at = @At("RETURN"), method = "init(Lnet/minecraft/world/level/LevelInfo;)V") | |
private void init(LevelInfo levelInfo, CallbackInfo info) { | |
System.out.println("Hello server world! CallBack:" +info + " level:" + levelInfo); | |
} | |
// I just tried to add this and not sure if it works yet | |
@Inject(at = @At("RETURN"), method = "tick(Ljava/util/function/BooleanSupplier;)V") | |
private void tick(BooleanSupplier shouldKeepTicking, CallbackInfo info) { | |
System.out.println("ServerWorldMixin.tick shouldKeepTicking:" +shouldKeepTicking + " dimension:" + this.dimension.getType()); | |
} | |
// Implement a bunch of methods from world to make compiler happy below | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment