-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
230 additions
and
96 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,19 +56,95 @@ tasks.withType(JavaCompile).configureEach { | |
it.options.release = 21 | ||
} | ||
|
||
// Configure Maven publishing. | ||
|
||
|
||
|
||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
// Modified by TeaCon | ||
register('release', MavenPublication) { | ||
// noinspection GroovyAssignabilityCheck | ||
from components.java | ||
version = rootProject.mod_version | ||
groupId = rootProject.maven_group | ||
artifactId = "$mod_github_repo-$rootProject.minecraft_version" | ||
pom { | ||
name = mod_github_repo | ||
url = "https://github.com/$mod_github_owner/$mod_github_repo" | ||
licenses { | ||
license { | ||
name = mod_license | ||
url = "https://github.com/$mod_github_owner/$mod_github_repo/blob/HEAD/LICENSE" | ||
} | ||
} | ||
organization { | ||
name = 'TeaConMC' | ||
url = 'https://github.com/teaconmc' | ||
} | ||
developers { | ||
for (mod_author in "$mod_authors".split(',')) { | ||
developer { id = mod_author.trim(); name = mod_author.trim() } | ||
} | ||
} | ||
issueManagement { | ||
system = 'GitHub Issues' | ||
url = "https://github.com/$mod_github_owner/$mod_github_repo/issues" | ||
} | ||
scm { | ||
url = "https://github.com/$mod_github_owner/$mod_github_repo" | ||
connection = "scm:git:git://github.com/$mod_github_owner/${mod_github_repo}.git" | ||
developerConnection = "scm:git:[email protected]:$mod_github_owner/${mod_github_repo}.git" | ||
} | ||
} | ||
} | ||
} | ||
|
||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. | ||
repositories { | ||
// Add repositories to publish to here. | ||
// Notice: This block does NOT have the same function as the block in the top level. | ||
// The repositories here will be used for publishing your artifact, not for | ||
// retrieving dependencies. | ||
// Modified by TeaCon | ||
maven { | ||
name "teacon" | ||
url "s3://maven/" | ||
credentials(AwsCredentials) { | ||
accessKey = System.env.ARCHIVE_ACCESS_KEY | ||
secretKey = System.env.ARCHIVE_SECRET_KEY | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Added by TeaCon | ||
tasks.withType(PublishToMavenRepository).configureEach { | ||
if (repository && repository.name == "archive") { | ||
it.onlyIf { | ||
System.env.MAVEN_USERNAME && System.env.MAVEN_PASSWORD | ||
} | ||
} | ||
} | ||
|
||
abstract class TeaConDumpPathToGitHub extends DefaultTask { | ||
@Input | ||
abstract Property<String> getPublishName() | ||
@InputFile | ||
abstract RegularFileProperty getTargetFile() | ||
@TaskAction | ||
void dump() { | ||
if (System.env.GITHUB_ACTIONS) { | ||
File theFile = targetFile.getAsFile().get() | ||
|
||
def outputFile = new File(System.env.GITHUB_OUTPUT) | ||
// Use the env-specific line separator for maximally possible compatibility | ||
def newLine = System.getProperty('line.separator') | ||
|
||
// Write out new env variable for later usage | ||
outputFile << newLine << "artifact_name=${theFile.getName()}" | ||
outputFile << newLine << "artifact_publish_name=${publishName.get()}" | ||
outputFile << newLine << "artifact_path=${theFile.absolutePath}" | ||
} | ||
} | ||
} | ||
|
||
// Added by TeaCon | ||
tasks.register("githubActionOutput", TeaConDumpPathToGitHub) { task -> | ||
task.onlyIf { System.env.GITHUB_ACTIONS } | ||
task.getTargetFile().set(jar.archiveFile) | ||
task.getPublishName().set("${jar.archiveBaseName.get()}-${version}.jar") | ||
} |
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.teacon.gimmeman; | ||
|
||
import net.neoforged.fml.common.Mod; | ||
|
||
import java.util.List; | ||
|
||
@Mod(GimmeMan.MOD_ID) | ||
public final class GimmeMan { | ||
public static final String MOD_ID = "gimmeman"; | ||
|
||
public GimmeMan() { | ||
|
||
} | ||
|
||
public static final List<String> modsToRemoveAdvancements = List.of("l2backpack"); | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/org/teacon/gimmeman/mixin/AdvancementManagerMixin.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.teacon.gimmeman.mixin; | ||
|
||
import com.google.gson.JsonElement; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.server.ServerAdvancementManager; | ||
import net.minecraft.server.packs.resources.ResourceManager; | ||
import net.minecraft.util.profiling.ProfilerFiller; | ||
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.CallbackInfo; | ||
import org.teacon.gimmeman.GimmeMan; | ||
|
||
import java.util.Map; | ||
|
||
@Mixin(ServerAdvancementManager.class) | ||
public class AdvancementManagerMixin { | ||
|
||
@Inject( | ||
method = "apply(Ljava/util/Map;Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/util/profiling/ProfilerFiller;)V", | ||
at = @At("HEAD") | ||
) | ||
void preventAdvancementAddition(Map<ResourceLocation, JsonElement> map, ResourceManager resourceManager, ProfilerFiller profilerFiller, CallbackInfo ci) { | ||
map.entrySet().removeIf((entry) -> GimmeMan.modsToRemoveAdvancements.contains(entry.getKey().getNamespace())); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/org/teacon/gimmeman/mixin/AdvancementRewardsMixin.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.teacon.gimmeman.mixin; | ||
|
||
import net.minecraft.advancements.AdvancementRewards; | ||
import net.minecraft.commands.CacheableFunction; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.server.MinecraftServer; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.level.storage.loot.LootTable; | ||
import org.spongepowered.asm.mixin.Final; | ||
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.callback.CallbackInfo; | ||
import org.teacon.gimmeman.GimmeMan; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
@Mixin(AdvancementRewards.class) | ||
public class AdvancementRewardsMixin { | ||
|
||
@Shadow @Final private Optional<CacheableFunction> function; | ||
|
||
@Shadow @Final private List<ResourceKey<LootTable>> loot; | ||
|
||
@Inject(method = "grant", at = @At("HEAD"), cancellable = true) | ||
private void cancelGrant(ServerPlayer arg, CallbackInfo ci) { | ||
if (loot.stream().anyMatch(lootTableResourceKey -> lootTableResourceKey.location().getNamespace().equals(GimmeMan.MOD_ID))) | ||
return; | ||
|
||
MinecraftServer minecraftserver = arg.server; | ||
this.function | ||
.flatMap(argx -> argx.get(minecraftserver.getFunctions())) | ||
.ifPresent(arg2 -> minecraftserver.getFunctions().execute(arg2, arg.createCommandSourceStack().withSuppressedOutput().withPermission(2))); | ||
|
||
ci.cancel(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/org/teacon/gimmeman/mixin/DisplayInfoMixin.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.teacon.gimmeman.mixin; | ||
|
||
import net.minecraft.advancements.DisplayInfo; | ||
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(DisplayInfo.class) | ||
public class DisplayInfoMixin { | ||
|
||
@Inject(method = "shouldAnnounceChat", at = @At("HEAD"), cancellable = true) | ||
void shouldAnnounceChat(CallbackInfoReturnable<Boolean> cir) { | ||
cir.setReturnValue(false); | ||
} | ||
} |
23 changes: 0 additions & 23 deletions
23
src/main/java/org/teacon/mixin/MixinClientAdvancements.java
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
src/main/java/org/teacon/mixin/MixinPlayerAdvancements.java
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
src/main/resources/data/gimmeman/advancements/give_startup_items.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"criteria": { | ||
"tick": { | ||
"trigger": "minecraft:tick" | ||
} | ||
}, | ||
"rewards": { | ||
"loot": [ | ||
"gimmeman:give_startup_items" | ||
] | ||
}, | ||
"display": { | ||
"show_toast": false, | ||
"announce_to_chat": false | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/resources/data/gimmeman/loot_tables/give_startup_items.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"type": "advancement_reward", | ||
"pools": [ | ||
{ | ||
"rolls": 1, | ||
"entries": [ | ||
{ | ||
"type": "item", | ||
"name": "ae2:guide" | ||
}, | ||
{ | ||
"type": "item", | ||
"name": "scattered_shards:shard_tablet" | ||
}, | ||
{ | ||
"type": "item", | ||
"name": "worldcomment:comment_tool" | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains 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