Skip to content

Commit

Permalink
fix: not being able existing world
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunekaer committed Feb 6, 2024
1 parent 4a93368 commit baea5f8
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 29 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
## [84.0.0]
- Ported to 1.20.4
## [84.0.1]
### Fixed
- not being able existing world
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.4-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.5-SNAPSHOT" apply false
id "me.modmuss50.mod-publish-plugin" version "0.4.5"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"mixins": [
],
"client": [
"CreateWorldScreenMixin",
"WorldOpenFlowsMixin"

],
"injectors": {
"defaultRequire": 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.sunekaer.yeetusexperimentus.mixin;
package com.sunekaer.yeetusexperimentus.fabric.mixin;

import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen;
import net.minecraft.server.packs.repository.PackRepository;
import net.minecraft.world.level.WorldDataConfiguration;
import org.spongepowered.asm.mixin.Debug;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -14,7 +13,6 @@
import java.util.List;
import java.util.function.Consumer;

@Debug(export = true)
@Mixin(CreateWorldScreen.class)
public abstract class CreateWorldScreenMixin {

Expand All @@ -29,5 +27,4 @@ public void onTryApplyNewDataPacks(PackRepository packRepository, boolean bo, Co
applyNewPackConfig(packRepository, worldDataConfiguration, consumer);
callbackInfo.cancel();
}

}
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
package com.sunekaer.yeetusexperimentus.mixin;
package com.sunekaer.yeetusexperimentus.fabric.mixin;

import com.mojang.serialization.Dynamic;
import com.mojang.serialization.Lifecycle;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen;
import net.minecraft.client.gui.screens.worldselection.WorldOpenFlows;
import net.minecraft.world.level.storage.LevelStorageSource;
import org.spongepowered.asm.mixin.Debug;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Debug(export = true)

@Mixin(WorldOpenFlows.class)
public abstract class WorldOpenFlowsMixin {

@Shadow protected abstract void loadLevel(LevelStorageSource.LevelStorageAccess arg, Dynamic<?> dynamic, boolean bl, boolean bl2, Runnable runnable);

@Inject(
method = "confirmWorldCreation",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;setScreen(Lnet/minecraft/client/gui/screens/Screen;)V", ordinal = 0),
Expand All @@ -30,10 +24,12 @@ private static void beGone(Minecraft client, CreateWorldScreen parent, Lifecycle
ci.cancel();
}


@Inject(method = "loadLevel", at = @At("HEAD"), cancellable = true)
private void onLoadLevel(LevelStorageSource.LevelStorageAccess levelStorageAccess, Dynamic<?> dynamic, boolean bl, boolean bl2, Runnable runnable, CallbackInfo callbackInfo) {
loadLevel(levelStorageAccess, dynamic, false, false, runnable);
callbackInfo.cancel();
@ModifyVariable(
method = "loadLevel(Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;Lcom/mojang/serialization/Dynamic;ZZLjava/lang/Runnable;)V",
at = @At("STORE"),
ordinal = 3
)
public boolean no(boolean a) {
return false;
}
}
3 changes: 2 additions & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"environment": "*",
"entrypoints": {},
"mixins": [
"yeetusexperimentus-common.mixins.json"
"yeetusexperimentus-common.mixins.json",
"yeetusexperimentus-fabric.mixins.json"
],
"depends": {
"fabricloader": ">=0.14",
Expand Down
15 changes: 15 additions & 0 deletions fabric/src/main/resources/yeetusexperimentus-fabric.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"required": true,
"package": "com.sunekaer.yeetusexperimentus.fabric.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"client": [
"CreateWorldScreenMixin",
"WorldOpenFlowsMixin"
],
"injectors": {
"defaultRequire": 1
},
"minVersion": "0.8"
}
7 changes: 4 additions & 3 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ loom {
forge {
convertAccessWideners = true
extraAccessWideners.add loom.accessWidenerPath.get().asFile.name
mixinConfigs = [
"yeetusexperimentus-common.mixins.json"
]

mixinConfigs "yeetusexperimentus-forge.mixins.json"
mixinConfigs "yeetusexperimentus-common.mixins.json"
}
}

Expand All @@ -35,6 +35,7 @@ dependencies {
}

processResources {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
inputs.property "version", project.version

filesMatching("META-INF/mods.toml") {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.sunekaer.yeetusexperimentus.forge.mixin;

import net.minecraft.world.level.storage.PrimaryLevelData;
import org.spongepowered.asm.mixin.Debug;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(value = PrimaryLevelData.class, remap = false)
public class PrimaryLevelDataMixinForge {

@Inject(method = "hasConfirmedExperimentalWarning", at =@At("HEAD"), cancellable = true)
public void hasConfirmedExperimentalWarning(CallbackInfoReturnable<Boolean> cir) {
cir.setReturnValue(true);
}
}
14 changes: 14 additions & 0 deletions forge/src/main/resources/yeetusexperimentus-forge.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"required": true,
"package": "com.sunekaer.yeetusexperimentus.forge.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"client": [
"PrimaryLevelDataMixinForge"
],
"injectors": {
"defaultRequire": 1
},
"minVersion": "0.8"
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ org.gradle.daemon=false
enabled_platforms=fabric,neoforge,forge

# Project
mod_version=84.0.0
mod_version=84.0.1
maven_group=com.sunekaer.mods
mod_name=YeetusExperimentus
mod_author=Sunekaer
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.sunekaer.yeetusexperimentus.neo.mixin;

import net.minecraft.world.level.storage.PrimaryLevelData;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(value = PrimaryLevelData.class, remap = false)
public class PrimaryLevelDataMixinNeo {

@Inject(method = "hasConfirmedExperimentalWarning", at =@At("HEAD"), cancellable = true)
public void hasConfirmedExperimentalWarning(CallbackInfoReturnable<Boolean> cir) {
cir.setReturnValue(true);
}
}
5 changes: 4 additions & 1 deletion neoforge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ ordering="NONE"
side="BOTH"

[[mixins]]
config = "yeetusexperimentus-common.mixins.json"
config = "yeetusexperimentus-common.mixins.json"

[[mixins]]
config = "yeetusexperimentus-neo.mixins.json"
14 changes: 14 additions & 0 deletions neoforge/src/main/resources/yeetusexperimentus-neo.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"required": true,
"package": "com.sunekaer.yeetusexperimentus.neo.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"client": [
"PrimaryLevelDataMixinNeo"
],
"injectors": {
"defaultRequire": 1
},
"minVersion": "0.8"
}

0 comments on commit baea5f8

Please sign in to comment.