Skip to content

Commit

Permalink
Support Minecraft 1.20.1 (#88)
Browse files Browse the repository at this point in the history
- Update zh_cn translation
- Update Gradle to 8.2
- Fix wrong enhancement book render in Singleplayer (MC 1.19.2+) (#80)
- Minecraft version check on wrapper (#7)

Signed-off-by: Hendrix-Shen <[email protected]>
  • Loading branch information
Forgot-Dream authored and Hendrix-Shen committed Jul 2, 2023
1 parent 2c7a07f commit 75a7dc7
Show file tree
Hide file tree
Showing 24 changed files with 2,236 additions and 1,970 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
1.19.2
1.19.3
1.19.4
1.20
1.20.1
version-resolver: exact

Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@

❗在报告问题前,请务必尝试最新[测试版](https://github.com/plusls/MasaGadget/actions),检查问题是否依然存在。

♻注意: Minecraft 1.20 需要使用第三方的 [Malilib](https://github.com/Nyan-Work/malilib/releases/tag/1.20), [Tweakeroo](https://github.com/Nyan-Work/tweakeroo/releases/tag/1.20),
[Litematica](https://github.com/Nyan-Work/litematica/releases/tag/1.20), [MiniHud](https://github.com/Nyan-Work/minihud/releases/tag/1.20), [ItemScroller](https://github.com/Nyan-Work/itemscroller/releases/tag/1.20).

为 Masa 系列模组添加了一些特性。

默认使用 **G + C** 打开设置界面。
Expand Down Expand Up @@ -403,7 +400,7 @@ ItemScroller 存储的配方编号,只支持 2x2 配方

### 支持

当前主开发版本:1.20
当前主开发版本:1.20.1

并且使用 `预处理` 来兼容各版本。

Expand All @@ -417,7 +414,7 @@ ItemScroller 存储的配方编号,只支持 2x2 配方
- Minecraft 1.19.2
- Minecraft 1.19.3
- Minecraft 1.19.4
- Minecraft 1.20
- Minecraft 1.20.1

### 混淆映射表

Expand Down
7 changes: 2 additions & 5 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@

❗Before reporting a problem, be sure to try the latest [beta version](https://github.com/plusls/MasaGadget/actions) to check if the problem still exists.

♻️Note: Minecraft 1.20 requires the use of a third-party port [Malilib](https://github.com/Nyan-Work/malilib/releases/tag/1.20), [Tweakeroo](https://github.com/Nyan-Work/tweakeroo/releases/tag/1.20),
[Litematica](https://github.com/Nyan-Work/litematica/releases/tag/1.20), [MiniHud](https://github.com/Nyan-Work/minihud/releases/tag/1.20), [ItemScroller](https://github.com/Nyan-Work/itemscroller/releases/tag/1.20).

Added some features to the Masa collection of mods.

The default hotkey to open the in-game config GUI is **G + C**.
Expand Down Expand Up @@ -403,7 +400,7 @@ Recipe indexes in ItemScroller recipe storage. Note: only 2x2 recipes are suppor

### Support

Current main development for Minecraft version: 1.20
Current main development for Minecraft version: 1.20.1

And use `preprocess` to be compatible with all versions.

Expand All @@ -417,7 +414,7 @@ And use `preprocess` to be compatible with all versions.
- Minecraft 1.19.2
- Minecraft 1.19.3
- Minecraft 1.19.4
- Minecraft 1.20
- Minecraft 1.20.1

### Mappings

Expand Down
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("fabric-loom").version("1.2-SNAPSHOT").apply(false)
id("fabric-loom").version("1.3-SNAPSHOT").apply(false)
id("io.github.juuxel.loom-quiltflower").version("1.10.0").apply(false)
id("maven-publish")
id("net.kyori.blossom").version("1.3.1").apply(false)
Expand All @@ -15,8 +15,8 @@ preprocess {
def mc1182 = createNode("1.18.2", 1_18_02, "mojang")
def mc1192 = createNode("1.19.2", 1_19_02, "mojang")
def mc1193 = createNode("1.19.3", 1_19_03, "mojang")
def mc1194 = createNode("1.19.4", 1_19_04, "mojang") // root
def mc1200 = createNode("1.20" , 1_20_00, "mojang")
def mc1194 = createNode("1.19.4", 1_19_04, "mojang")
def mc1201 = createNode("1.20.1", 1_20_01, "mojang") // root

mc1144.link(mc1152, null)
mc1152.link(mc1165, null)
Expand All @@ -25,11 +25,11 @@ preprocess {
mc1182.link(mc1192, null)
mc1192.link(mc1193, file("versions/mapping-1.19.2-1.19.3.txt"))
mc1193.link(mc1194, null)
mc1194.link(mc1200, null)
mc1194.link(mc1201, null)
}

ext {
environmentMap = System.getenv()
def environmentMap = System.getenv()

getVersionGit = { List paths ->
if (grgit == null) {
Expand All @@ -41,11 +41,11 @@ ext {
}

getBuildNumber = {
return ext.environmentMap.GITHUB_RUN_NUMBER ? ext.environmentMap.GITHUB_RUN_NUMBER : Integer.MAX_VALUE
return environmentMap.GITHUB_RUN_NUMBER ? environmentMap.GITHUB_RUN_NUMBER : Integer.MAX_VALUE
}

getVersionType = {
switch (ext.environmentMap.BUILD_TYPE) {
switch (environmentMap.BUILD_TYPE) {
case "RELEASE":
return "stable"
case "BETA":
Expand Down
30 changes: 12 additions & 18 deletions common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ repositories {
}
}

maven {
name("Nyan Maven")
url("https://maven.hendrixshen.top")
}

mavenCentral()
}

Expand All @@ -42,14 +37,10 @@ preprocess {

// Module, Property prefix, Resolve condition, Transitive dependencies.
def apiDependencies = [
["curse.maven:itemscroller-242064" , "itemscroller", mcVersion < 12000, false],
["curse.maven:litematica-308892" , "litematica" , mcVersion < 12000, false],
["curse.maven:minihud-244260" , "minihud" , mcVersion < 12000, false],
["curse.maven:tweakeroo-297344" , "tweakeroo" , mcVersion < 12000, false],
["fi.dy.masa.itemscroller:itemscroller-fabric-1.20.0", "itemscroller", mcVersion > 11904, false],
["fi.dy.masa.litematica:litematica-fabric-1.20.0" , "litematica" , mcVersion > 11904, false],
["fi.dy.masa.minihud:minihud-fabric-1.20.0" , "minihud" , mcVersion > 11904, false],
["fi.dy.masa.tweakeroo:tweakeroo-fabric-1.20.0" , "tweakeroo" , mcVersion > 11904, false],
["curse.maven:itemscroller-242064" , "itemscroller", true, false],
["curse.maven:litematica-308892" , "litematica" , true, false],
["curse.maven:minihud-244260" , "minihud" , true, false],
["curse.maven:tweakeroo-297344" , "tweakeroo" , true, false],
]

// Module, Property prefix, Resolve condition, Transitive dependencies.
Expand All @@ -67,8 +58,8 @@ dependencies {
annotationProcessor("org.projectlombok:lombok:${project.lombok_version}")

// Dependency
modImplementation("top.hendrixshen:magiclib-${project.minecraft_version.replace(".", "_")}:${project.magiclib_version}") {
exclude(group: "curse.maven", module: "carpet-349239")
modImplementation("top.hendrixshen.magiclib:magiclib-${project.minecraft_version.replace(".", "_")}:${project.magiclib_version}") {
exclude(group: "carpet", module: "fabric-carpet")
}

// API
Expand Down Expand Up @@ -103,12 +94,13 @@ dependencies {
runtimeOnly(project(path: ":fabricWrapper"))
}

archivesBaseName("${project.mod_archives_base_name}-${project.minecraft_version}")
group(project.mod_maven_group)
sourceCompatibility(JavaVersion.VERSION_1_8)
targetCompatibility(JavaVersion.VERSION_1_8)
version(project.parent.version)

base {
archivesBaseName("${project.mod_archives_base_name}-${project.minecraft_version}")
}

loom {
interfaceInjection {
enableDependencyInterfaceInjection.set(true)
Expand Down Expand Up @@ -235,6 +227,8 @@ blossom {
}

java {
sourceCompatibility(JavaVersion.VERSION_1_8)
targetCompatibility(JavaVersion.VERSION_1_8)
withSourcesJar()
}

Expand Down
17 changes: 13 additions & 4 deletions fabricWrapper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ plugins {
id("maven-publish")
}

archivesBaseName("${project.mod_archives_base_name}")
group(project.mod_maven_group)
sourceCompatibility(JavaVersion.VERSION_1_8)
targetCompatibility(JavaVersion.VERSION_1_8)
version(project.parent.version)

base {
archivesBaseName("${project.mod_archives_base_name}-all")
}

def fabric_subprojects = project.parent.subprojects.findAll({
it.name != "fabricWrapper"
})
Expand Down Expand Up @@ -48,9 +49,11 @@ jar {
processResources {
// disable cache
outputs.upToDateWhen { false }
var jars = []
ArrayList<?> mc_condition = []
ArrayList<?> jars = []

fabric_subprojects.each({
mc_condition.add("${it.minecraft_dependency}")
jars.add(["file": "META-INF/jars/${project.mod_archives_base_name}-${it.minecraft_version}-${project.version}.jar"])
})

Expand All @@ -60,6 +63,7 @@ processResources {

filesMatching("fabric.mod.json") {
expand([
"minecraft_dependency": new JsonBuilder(mc_condition),
"magiclib_dependency" : project.magiclib_dependency,
"mod_description" : project.mod_description,
"mod_homepage" : project.mod_homepage,
Expand All @@ -73,6 +77,11 @@ processResources {
}
}

java {
sourceCompatibility(JavaVersion.VERSION_1_8)
targetCompatibility(JavaVersion.VERSION_1_8)
}

publishing {
publications {
register("mavenJava", MavenPublication) {
Expand Down
1 change: 1 addition & 0 deletions fabricWrapper/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
},
"depends": {
"magiclib": ">=${magiclib_dependency}",
"minecraft": ${minecraft_dependency},
"malilib": "*"
},
"custom": {
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ mod_version=3.2
mod_license=LGPL-3.0

# Required Libraries
# MagicLib - 0.7.336
magiclib_dependency=0.7.336
magiclib_version=0.7.336
# MagicLib - 0.7.345
magiclib_dependency=0.7.345
magiclib_version=0.7.345

# Annotation processor
lombok_version=1.18.28
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
5 changes: 4 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def versions = Arrays.asList(
"1.19.2",
"1.19.3",
"1.19.4",
"1.20",
"1.20.1",
)

for (String version : versions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import com.google.common.collect.Lists;
import com.plusls.MasaGadget.config.Configs;
import net.minecraft.client.Minecraft;
import net.minecraft.client.server.IntegratedServer;
import net.minecraft.core.Position;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.monster.ZombieVillager;
Expand Down Expand Up @@ -35,7 +37,7 @@ private static void collect(Entity entity, RenderContext context, float tickDelt
public static void render(Level level, RenderContext context, float tickDelta) {
for (Entity entity : EntityInfoRenderer.list) {
if (entity instanceof Villager) {
Villager villager = ((Villager) entity);
Villager villager = (Villager) EntityInfoRenderer.getEntityDataFromIntegratedServer(entity);
TextRenderer renderer = TextRenderer.create();

if (Configs.renderNextRestockTime) {
Expand All @@ -51,7 +53,7 @@ public static void render(Level level, RenderContext context, float tickDelta) {
.fontScale(0.015F)
.render(context);
} else if (entity instanceof ZombieVillager) {
ZombieVillager zombieVillager = (ZombieVillager) entity;
ZombieVillager zombieVillager = (ZombieVillager) EntityInfoRenderer.getEntityDataFromIntegratedServer(entity);
EntityInfoRenderer.rotationAround(TextRenderer.create(), zombieVillager.getEyePosition(tickDelta), 0.6)
.text(ZombieVillagerConvertTimeInfo.getInfo(zombieVillager))
.bgColor((int) (Minecraft.getInstance().options.getBackgroundOpacity(0.25F) * 255.0F) << 24)
Expand All @@ -69,4 +71,19 @@ private static TextRenderer rotationAround(@NotNull TextRenderer renderer, @NotN
float yAngle = (float) Mth.atan2(camPos.x() - centerPos.x(), camPos.z() - centerPos.z());
return renderer.pos(range * Mth.cos(xAngle) + centerPos.x(), centerPos.y(), range * Mth.cos(yAngle) + centerPos.z());
}

private static Entity getEntityDataFromIntegratedServer(Entity entity) {
IntegratedServer server = Minecraft.getInstance().getSingleplayerServer();

if (server == null) {
return entity;
}

//#if MC > 11502
ServerLevel level = server.getLevel(entity.getLevelCompat().dimension());
//#else
//$$ ServerLevel level = server.getLevel(entity.dimension);
//#endif
return level == null ? entity : level.getEntity(entity.getId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public class MixinClientPlayNetworkHandler {

@Inject(method = "handleSoundEvent", at = @At(value = "RETURN"))
private void syncVillagerData(ClientboundSoundPacket packet, CallbackInfo ci) {
if (!Configs.autoSyncEntityData || Minecraft.getInstance().hasSingleplayerServer() || !PcaSyncProtocol.enable) {
if (!Configs.autoSyncEntityData ||
Minecraft.getInstance().hasSingleplayerServer() ||
!PcaSyncProtocol.enable) {
return;
}
ClientLevel clientWorld = Minecraft.getInstance().level;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public abstract class MixinVillagerEntity {
@SuppressWarnings("ConstantConditions")
@Inject(method = "tick", at = @At(value = "RETURN"))
private void syncVillagerData(CallbackInfo ci) {
if (!Configs.autoSyncEntityData || Minecraft.getInstance().hasSingleplayerServer() || !PcaSyncProtocol.enable) {
if (!Configs.autoSyncEntityData ||
Minecraft.getInstance().hasSingleplayerServer() ||
!PcaSyncProtocol.enable) {
return;
}
VillagerProfession currentVillagerProfession = ((Villager) (Object) this).getVillagerData().getProfession();
Expand All @@ -32,7 +34,9 @@ private void syncVillagerData(CallbackInfo ci) {
@SuppressWarnings("ConstantConditions")
@Inject(method = "handleEntityEvent", at = @At(value = "RETURN"))
private void syncVillagerData(byte status, CallbackInfo ci) {
if (!Configs.autoSyncEntityData || Minecraft.getInstance().hasSingleplayerServer() || !PcaSyncProtocol.enable) {
if (!Configs.autoSyncEntityData ||
Minecraft.getInstance().hasSingleplayerServer() ||
!PcaSyncProtocol.enable) {
return;
}
if (status == 14) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public MixinZombieVillagerEntity(EntityType<? extends Zombie> entityType, Level

@Inject(method = "handleEntityEvent", at = @At(value = "RETURN"))
private void syncVillagerData(byte status, CallbackInfo ci) {
if (!Configs.autoSyncEntityData || Minecraft.getInstance().hasSingleplayerServer() || !PcaSyncProtocol.enable) {
if (!Configs.autoSyncEntityData ||
Minecraft.getInstance().hasSingleplayerServer() ||
!PcaSyncProtocol.enable) {
return;
}
if (status == 16) {
Expand Down
Loading

0 comments on commit 75a7dc7

Please sign in to comment.