Skip to content

Commit

Permalink
Initial Commits
Browse files Browse the repository at this point in the history
  • Loading branch information
wendavid552 committed Sep 4, 2024
1 parent 528c76e commit cac5650
Show file tree
Hide file tree
Showing 40 changed files with 630 additions and 252 deletions.
22 changes: 2 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
## fabric-mod-template
## Carpet Patcher

[![License](https://img.shields.io/github/license/Fallen-Breath/fabric-mod-template.svg)](http://www.gnu.org/licenses/lgpl-3.0.html)
[![workflow](https://github.com/Fallen-Breath/fabric-mod-template/actions/workflows/gradle.yml/badge.svg)](https://github.com/Fallen-Breath/fabric-mod-template/actions/workflows/gradle.yml)

fallen's fabric mod template

If you find it helpful, a credit to this template in your project will be greatly appreciated

## To use

1. Clone / Use this template to get a new project
2. Search `[FEATURE]` in the project, delete or uncomment those addons
3. Setup the mod
- Edit java package name
- Edit [gradle.properties](gradle.properties) for mod id / name etc.
- Edit mod name in [bug_report.yml](.github/ISSUE_TEMPLATE/bug_report.yml)
- Edit [common.gradle](common.gradle) for mod file location constants
- Change the Minecraft versions in [settings.json](settings.json), [build.gradle](build.gradle), and files in the [versions](versions) folder
- Search `template` in the project to see if there are any missing unedited stuffs
4. Edit [README](README.md) for the new mod
This mod aims to backport some of the bug fixes from latest carpet mod.
38 changes: 22 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'maven-publish'
id 'com.github.hierynomus.license' version '0.16.1' apply false
// id 'com.github.hierynomus.license' version '0.16.1' apply false
id 'fabric-loom' version '1.7-SNAPSHOT' apply false

// https://github.com/ReplayMod/preprocessor
Expand All @@ -12,22 +12,28 @@ plugins {
}

preprocess {
def mc114 = createNode('1.14.4', 1_14_04, '')
def mc115 = createNode('1.15.2', 1_15_02, '')
def mc116 = createNode('1.16.5', 1_16_05, '')
def mc117 = createNode('1.17.1', 1_17_01, '')
def mc118 = createNode('1.18.2', 1_18_02, '')
def mc119 = createNode('1.19.4', 1_19_04, '')
def mc120 = createNode('1.20.6', 1_20_06, '')
def mc121 = createNode('1.21.1', 1_21_01, '')
def mc114 = createNode('1.14.4', 1_14_04, '')
def mc115 = createNode('1.15.2', 1_15_02, '')
def mc116 = createNode('1.16.5', 1_16_05, '')
def mc117 = createNode('1.17.1', 1_17_01, '')
def mc118 = createNode('1.18.2', 1_18_02, '')
def mc119 = createNode('1.19.4', 1_19_04, '')
def mc1201 = createNode('1.20.1', 1_20_01, '')
def mc1202 = createNode('1.20.2', 1_20_02, '')
def mc1204 = createNode('1.20.4', 1_20_04, '')
def mc1206 = createNode('1.20.6', 1_20_06, '')
def mc121 = createNode('1.21.1', 1_21_01, '')

mc115.link(mc114, null)
mc115.link(mc116, null)
mc116.link(mc117, null)
mc117.link(mc118, null)
mc118.link(mc119, null)
mc119.link(mc120, null)
mc120.link(mc121, null)
mc115 .link(mc114 , file('versions/mapping-1.15-1.14.txt'))
mc115 .link(mc116 , file('versions/mapping-1.15-1.16.txt'))
mc116 .link(mc117 , file('versions/mapping-1.16-1.17.txt'))
mc117 .link(mc118 , file('versions/mapping-1.17-1.18.txt'))
mc118 .link(mc119 , file('versions/mapping-1.18-1.19.txt'))
mc119 .link(mc1201, file('versions/mapping-1.19-1.20.1.txt'))
mc1201.link(mc1202, file('versions/mapping-1.20.1-1.20.2.txt'))
mc1202.link(mc1204, file('versions/mapping-1.20.2-1.20.4.txt'))
mc1204.link(mc1206, file('versions/mapping-1.20.4-1.20.6.txt'))
mc1206.link(mc121 , file('versions/mapping-1.20.6-1.21.1.txt'))
}

tasks.register('buildAndGather') {
Expand Down
135 changes: 80 additions & 55 deletions common.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apply plugin: 'maven-publish'
apply plugin: 'com.github.hierynomus.license'
//apply plugin: 'com.github.hierynomus.license'
apply plugin: 'fabric-loom'
apply plugin: 'com.replaymod.preprocess'
apply plugin: 'me.fallenbreath.yamlang'
Expand All @@ -12,11 +12,20 @@ preprocess {

repositories {
maven {
url 'https://jitpack.io'
url 'https://masa.dy.fi/maven'
}
maven {
url 'https://maven.fallenbreath.me/releases'
}
maven {
url 'https://maven.bawnorton.com/releases'
}
maven {
url 'https://jitpack.io'
}
maven {
url 'https://www.cursemaven.com'
}
}

// https://github.com/FabricMC/fabric-loader/issues/783
Expand All @@ -31,20 +40,29 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// runtime mods
// if (mcVersion < 11904) {
// modRuntimeOnly(mcVersion < 11900 ? "com.github.astei:lazydfu:0.1.2" : "com.github.Fallen-Breath:lazydfu:a7cfc44c0c")
// }
// // [FEATURE] MIXIN_AUDITOR
// modRuntimeOnly 'me.fallenbreath:mixin-auditor:0.1.0'
if (mcVersion < 11904) {
modRuntimeOnly(mcVersion < 11900 ? "com.github.astei:lazydfu:0.1.2" : "com.github.Fallen-Breath:lazydfu:a7cfc44c0c")
}
// [FEATURE] MIXIN_AUDITOR
modRuntimeOnly 'me.fallenbreath:mixin-auditor:0.1.0'

// dependencies
// include(modImplementation(fabricApi.module("fabric-resource-loader-v0", project.fabric_api_version)))
// include(modImplementation("me.fallenbreath:conditional-mixin-fabric:${project.conditionalmixin_version}"))
// include(annotationProcessor(implementation("io.github.llamalad7:mixinextras-fabric:${project.mixinextras_version}")))
if (project.carpet_core_version.startsWith('com.github.gnembon:fabric-carpet:')) {
modImplementation project.carpet_core_version // jitpack
} else {
modImplementation "carpet:fabric-carpet:${project.carpet_core_version}" // masa's maven
}
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"

//library mods

include(modImplementation("me.fallenbreath:conditional-mixin-fabric:${project.conditionalmixin_version}"))
include(annotationProcessor(implementation("io.github.llamalad7:mixinextras-fabric:${project.mixinextras_version}")))
include(implementation(annotationProcessor("com.bawnorton.mixinsquared:mixinsquared-fabric:${project.mixinsquared_version}")))
}

String MIXIN_CONFIG_PATH = 'template_mod.mixins.json'
String LANG_DIR = 'assets/template_mod/lang'
String MIXIN_CONFIG_PATH = 'carpetpatcher.mixins.json'
String LANG_DIR = 'assets/carpetpatcher/lang'
JavaVersion JAVA_COMPATIBILITY
if (mcVersion >= 12005) {
JAVA_COMPATIBILITY = JavaVersion.VERSION_21
Expand All @@ -58,22 +76,29 @@ if (mcVersion >= 12005) {
JavaVersion MIXIN_COMPATIBILITY_LEVEL = JAVA_COMPATIBILITY

loom {
def commonVmArgs = ['-Dmixin.debug.export=true', '-Dmixin.debug.countInjections=true']
def commonVmArgs = ['-Dmixin.debug.export=true']
if (mcVersion < 11904) {
// carpet 1.4.100+v230314 for mc1.19.4 and above
// fail to pass the check on at MinecraftServer_pingPlayerSampleLimit#modifyPlayerSampleLimit
// see https://github.com/gnembon/fabric-carpet/pull/1938

}
commonVmArgs.add('-Dmixin.debug.countInjections=true')
runConfigs.configureEach {
// to make sure it generates all "Minecraft Client (:subproject_name)" applications
ideConfigGenerated = true
runDir '../../run'
vmArgs commonVmArgs
}
// // [FEATURE] MIXIN_AUDITOR
// runs {
// def auditVmArgs = ['-DmixinAuditor.audit=true']
// serverMixinAudit {
// server()
// vmArgs auditVmArgs
// ideConfigGenerated false
// }
// }
// [FEATURE] MIXIN_AUDITOR
runs {
def auditVmArgs = ['-DmixinAuditor.audit=true']
serverMixinAudit {
server()
vmArgs auditVmArgs
ideConfigGenerated false
}
}
}

remapJar {
Expand Down Expand Up @@ -172,39 +197,39 @@ jar {
}

// https://github.com/hierynomus/license-gradle-plugin
license {
// use "gradle licenseFormat" to apply license headers
header = rootProject.file('HEADER.txt')
include '**/*.java'
skipExistingHeaders = true

headerDefinitions {
// ref: https://github.com/mathieucarbou/license-maven-plugin/blob/4c42374bb737378f5022a3a36849d5e23ac326ea/license-maven-plugin/src/main/java/com/mycila/maven/plugin/license/header/HeaderType.java#L48
// modification: add a newline at the end
SLASHSTAR_STYLE_NEWLINE {
firstLine = "/*"
beforeEachLine = " * "
endLine = " */" + System.lineSeparator()
afterEachLine = ""
skipLinePattern = null
firstLineDetectionPattern = "(\\s|\\t)*/\\*.*\$"
lastLineDetectionPattern = ".*\\*/(\\s|\\t)*\$"
allowBlankLines = false
isMultiline = true
padLines = false
}
}
mapping {
java = 'SLASHSTAR_STYLE_NEWLINE'
}
ext {
name = project.mod_name
author = 'Fallen_Breath'
year = Calendar.getInstance().get(Calendar.YEAR).toString()
}
}
classes.dependsOn licenseFormatMain
testClasses.dependsOn licenseFormatTest
//license {
// // use "gradle licenseFormat" to apply license headers
// header = rootProject.file('HEADER.txt')
// include '**/*.java'
// skipExistingHeaders = true
//
// headerDefinitions {
// // ref: https://github.com/mathieucarbou/license-maven-plugin/blob/4c42374bb737378f5022a3a36849d5e23ac326ea/license-maven-plugin/src/main/java/com/mycila/maven/plugin/license/header/HeaderType.java#L48
// // modification: add a newline at the end
// SLASHSTAR_STYLE_NEWLINE {
// firstLine = "/*"
// beforeEachLine = " * "
// endLine = " */" + System.lineSeparator()
// afterEachLine = ""
// skipLinePattern = null
// firstLineDetectionPattern = "(\\s|\\t)*/\\*.*\$"
// lastLineDetectionPattern = ".*\\*/(\\s|\\t)*\$"
// allowBlankLines = false
// isMultiline = true
// padLines = false
// }
// }
// mapping {
// java = 'SLASHSTAR_STYLE_NEWLINE'
// }
// ext {
// name = project.mod_name
// author = 'WenDavid'
// year = Calendar.getInstance().get(Calendar.YEAR).toString()
// }
//}
//classes.dependsOn licenseFormatMain
//testClasses.dependsOn licenseFormatTest

// configure the maven publication
publishing {
Expand Down
16 changes: 10 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
# Gradle Properties
org.gradle.jvmargs=-Xmx6G
org.gradle.parallel=true

# Fabric Basic Properties
# https://fabricmc.net/versions.html
loader_version=0.16.2

# Mod Properties
mod_id=template_mod
mod_name=TemplateMod
mod_id=carpetpatcher
mod_name=CarpetPatcher
mod_version=1.0.0
maven_group=me.fallenbreath
archives_base_name=template_mod
maven_group=club.mcams
archives_base_name=carpet_patcher

# Global Dependencies
# https://github.com/Fallen-Breath/conditional-mixin
# conditionalmixin_version=0.6.3
conditionalmixin_version=0.6.3

# https://github.com/LlamaLad7/MixinExtras
# mixinextras_version=0.3.6
mixinextras_version=0.3.6

# https://github.com/Bawnorton/MixinSquared
mixinsquared_version=0.2.0-beta.6
3 changes: 3 additions & 0 deletions settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"1.17.1",
"1.18.2",
"1.19.4",
"1.20.1",
"1.20.2",
"1.20.4",
"1.20.6",
"1.21.1"
]
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/club/mcams/carpetpatcher/CarpetPatcherMod.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* This file is part of the CarpetPatcher project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 WenDavid and contributors
*
* CarpetPatcher is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CarpetPatcher is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CarpetPatcher. If not, see <https://www.gnu.org/licenses/>.
*/

package club.mcams.carpetpatcher;

import net.fabricmc.api.ModInitializer;

public class CarpetPatcherMod implements ModInitializer {
@Override
public void onInitialize() {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* This file is part of the CarpetPatcher project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 WenDavid and contributors
*
* CarpetPatcher is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CarpetPatcher is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CarpetPatcher. If not, see <https://www.gnu.org/licenses/>.
*/

package club.mcams.carpetpatcher.impl.pingSampleListInjection;

import com.bawnorton.mixinsquared.adjuster.tools.AdjustableAnnotationNode;
import com.bawnorton.mixinsquared.adjuster.tools.AdjustableModifyConstantNode;
import com.bawnorton.mixinsquared.api.MixinAnnotationAdjuster;
import org.objectweb.asm.tree.MethodNode;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

import java.util.List;

public class PingSampleListMixinAdjuster implements MixinAnnotationAdjuster {
@Override
public AdjustableAnnotationNode adjust(List<String> targetClassNames, String mixinClassName, MethodNode handlerNode, AdjustableAnnotationNode annotation) {
//#if MC>=11904
if ("carpet.mixins.MinecraftServer_pingPlayerSampleLimit".equals(mixinClassName) && annotation.is(ModifyConstant.class)) {
AdjustableModifyConstantNode wrapOpNode = annotation.as(AdjustableModifyConstantNode.class);
List<String> methods = wrapOpNode.getMethod();
if ("tickServer".equals(methods.get(0))) {
methods.set(0, "createMetadataPlayers");
wrapOpNode.setMethod(methods);
return wrapOpNode;
}
}
//#endif
return annotation;
}
}
Loading

0 comments on commit cac5650

Please sign in to comment.