Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06a3cadcda | ||
|
|
3447ef2ba7 | ||
|
|
a2ec50b03d | ||
|
|
9718cc1687 | ||
|
|
cc55eb33b1 | ||
|
|
ec49adba86 |
No files matched your search
@@ -1,2 +1,8 @@
|
||||
# Metis
|
||||
|
||||
Metis API, a Minecraft-abstracted API for Fabric
|
||||
|
||||
### Requirements
|
||||
|
||||
- Java 17
|
||||
- Gradle 7.6.4
|
||||
+2
-2
@@ -38,8 +38,8 @@ allprojects {
|
||||
}
|
||||
|
||||
compileJava {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
publishing {
|
||||
|
||||
+2
-1
@@ -1 +1,2 @@
|
||||
org.gradle.jvmargs=-Xmx4G
|
||||
org.gradle.jvmargs=-Xmx4G
|
||||
org.gradle.parallel=true
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
#Sun May 26 12:36:17 CEST 2024
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -33,7 +33,7 @@ configurations {
|
||||
dependencies {
|
||||
// make sure to use the correct versions of mcProvided artifacts for the Minecraft version (look into the version manifest)
|
||||
mcProvided 'org.apache.logging.log4j:log4j-api:2.8.1'
|
||||
mcProvided 'org.apache.logging.log4j:log4j-core:2.8.1'
|
||||
mcProvided 'org.apache.logging.log4j:log4j-core:2.17.0'
|
||||
|
||||
apiParts 'net.kyori:adventure-api:4.9.3'
|
||||
apiParts 'net.kyori:adventure-text-serializer-gson:4.9.3'
|
||||
@@ -51,21 +51,21 @@ processResources {
|
||||
}
|
||||
}
|
||||
|
||||
task fullJar(type: Jar) {
|
||||
tasks.register('fullJar', Jar) {
|
||||
group = "build"
|
||||
archiveClassifier = "full"
|
||||
|
||||
from (configurations.include.filter { it.exists() }.collect { it.isDirectory() ? it : zipTree(it) }) {
|
||||
from(configurations.include.filter { it.exists() }.collect { it.isDirectory() ? it : zipTree(it) }) {
|
||||
exclude "META-INF/**"
|
||||
}
|
||||
|
||||
with jar
|
||||
}
|
||||
|
||||
task fullNoDuplicatesJar(type: Jar) {
|
||||
tasks.register('fullNoDuplicatesJar', Jar) {
|
||||
archiveClassifier = "full-no-duplicates"
|
||||
|
||||
from (configurations.apiParts.filter { it.exists() }.collect { it.isDirectory() ? it : zipTree(it) }) {
|
||||
from(configurations.apiParts.filter { it.exists() }.collect { it.isDirectory() ? it : zipTree(it) }) {
|
||||
exclude "META-INF/**"
|
||||
}
|
||||
|
||||
|
||||
+12
-10
@@ -7,16 +7,14 @@ plugins {
|
||||
id 'java-library'
|
||||
}
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
def minecraftVersion = "1.16_combat-6"
|
||||
def fabricLoaderVersion = "0.14.21"
|
||||
|
||||
archivesBaseName = "metis-builder"
|
||||
version = "${rootProject.version}-${minecraftVersion}"
|
||||
group = parent.group
|
||||
|
||||
repositories {
|
||||
base {
|
||||
archivesName = "metis-builder";
|
||||
}
|
||||
|
||||
configurations {
|
||||
@@ -27,7 +25,7 @@ configurations {
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${minecraftVersion}"
|
||||
mappings loom.officialMojangMappings()
|
||||
modImplementation "net.fabricmc:fabric-loader:0.12.12"
|
||||
modImplementation "net.fabricmc:fabric-loader:${fabricLoaderVersion}"
|
||||
|
||||
api project(":metis-api")
|
||||
include project(":metis-api")
|
||||
@@ -38,9 +36,10 @@ dependencies {
|
||||
}
|
||||
|
||||
loom {
|
||||
accessWidenerPath = file("src/main/resources/metisbuilder.accesswidener")
|
||||
|
||||
customMinecraftManifest = "https://gist.githubusercontent.com/rizecookey/4c6142baaccc3875f9b227fe22f2ace5/raw/c8ed74b19f7a5315813c9d4b199798b692a8f359/1.16_combat-6.json"
|
||||
intermediaryUrl = "https://maven.combatreforged.com/net/fabricmc/intermediary/%1\$s/intermediary-%1\$s-v2.jar"
|
||||
accessWidenerPath = file("src/main/resources/metisbuilder.accesswidener")
|
||||
}
|
||||
|
||||
processResources {
|
||||
@@ -51,21 +50,24 @@ processResources {
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
jar {
|
||||
from("LICENSE") {
|
||||
rename { "${it}_${project.archivesBaseName}"}
|
||||
rename { "${it}_${archiveBaseName}"}
|
||||
}
|
||||
}
|
||||
|
||||
task fullJar(type: RemapJarTask) {
|
||||
tasks.register('fullJar', RemapJarTask) {
|
||||
dependsOn jar
|
||||
archiveClassifier = "full"
|
||||
input = jar {
|
||||
|
||||
+9
-9
@@ -18,16 +18,16 @@ public final class MetisCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
|
||||
dispatcher.register(
|
||||
literal("factory")
|
||||
literal("metis")
|
||||
.requires(info -> info.getSender().getPermissionLevel() >= 4)
|
||||
.then(literal("version")
|
||||
.executes(context -> {
|
||||
FabricLoader loader = FabricLoader.getInstance();
|
||||
assert loader.getModContainer("factory-api").isPresent() && loader.getModContainer("factory-builder").isPresent();
|
||||
String apiVersion = loader.getModContainer("factory-api").get().getMetadata().getVersion().toString();
|
||||
String builderVersion = loader.getModContainer("factory-builder").get().getMetadata().getVersion().toString();
|
||||
context.getSource().sendMessage(Component.text("Factory version: \n ")
|
||||
.append(Component.text("- API: [factory-api@" + apiVersion + "]\n - Implementation: [factory-builder@" + builderVersion + "]")
|
||||
assert loader.getModContainer("metis-api").isPresent() && loader.getModContainer("metis-builder").isPresent();
|
||||
String apiVersion = loader.getModContainer("metis-api").get().getMetadata().getVersion().toString();
|
||||
String builderVersion = loader.getModContainer("metis-builder").get().getMetadata().getVersion().toString();
|
||||
context.getSource().sendMessage(Component.text("metis version: \n ")
|
||||
.append(Component.text("- API: [metis-api@" + apiVersion + "]\n - Implementation: [metis-builder@" + builderVersion + "]")
|
||||
.color(NamedTextColor.DARK_GREEN)));
|
||||
return 0;
|
||||
}))
|
||||
@@ -36,9 +36,9 @@ public final class MetisCommand {
|
||||
List<ModMetadata> plugins = FabricLoader.getInstance().getAllMods()
|
||||
.stream()
|
||||
.map(ModContainer::getMetadata)
|
||||
.filter(metadata -> metadata.getDepends().stream()
|
||||
.anyMatch(dep -> dep.getModId().equals("factory-api")))
|
||||
.collect(Collectors.toList());
|
||||
.filter(metadata -> metadata.getDependencies().stream()
|
||||
.anyMatch(dep -> dep.getModId().equals("metis-api")))
|
||||
.toList();
|
||||
Component result = Component.text("Found " + plugins.size() + " plugin(s): ");
|
||||
for (ModMetadata plugin : plugins) {
|
||||
result = result.append(Component.text("[" + plugin.getId() + "@" + plugin.getVersion().toString() + "]"));
|
||||
|
||||
+2
-1
@@ -34,7 +34,7 @@ public class PacketUtilsMixin {
|
||||
if (packetListener.getConnection().isConnected()) {
|
||||
packet.handle(packetListener);
|
||||
} else {
|
||||
LOGGER.debug("Ignoring packet due to disconnection: " + packet);
|
||||
LOGGER.debug("Ignoring packet due to disconnection: {}", packet);
|
||||
}
|
||||
|
||||
});
|
||||
@@ -47,6 +47,7 @@ public class PacketUtilsMixin {
|
||||
// end change
|
||||
}
|
||||
|
||||
@Unique
|
||||
private static MinecraftServer getServer() {
|
||||
return SERVER == null ? (SERVER = ((WrappedMetisServer) MetisAPI.getInstance().getServer()).unwrap()) : SERVER;
|
||||
}
|
||||
|
||||
+3
@@ -51,12 +51,15 @@ import java.util.Map;
|
||||
public abstract class CommandsMixin {
|
||||
@Shadow @Final private CommandDispatcher<CommandSourceStack> dispatcher;
|
||||
|
||||
/*
|
||||
// Makes non-syntax errors log
|
||||
@Redirect(method = "performCommand", at = @At(value = "INVOKE", target = "Lorg/apache/logging/log4j/Logger;isDebugEnabled()Z",remap = false))
|
||||
public boolean activateCommandExecutionErrors(Logger instance) {
|
||||
return true;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
@Redirect(method = "performCommand", at = @At(value = "INVOKE", target = "Lcom/mojang/brigadier/CommandDispatcher;execute(Lcom/mojang/brigadier/StringReader;Ljava/lang/Object;)I", remap = false))
|
||||
public int enableAPICommands(CommandDispatcher<?> commandDispatcher, StringReader input, Object source, CommandSourceStack commandSourceStack, String string) throws CommandSyntaxException {
|
||||
if (commandDispatcher == this.dispatcher) {
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ public abstract class ServerPlayerMixin extends net.minecraft.world.entity.playe
|
||||
this.keepInv = ext.isKeepInv();
|
||||
this.scoreboard = ext.getScoreboard();
|
||||
this.hiddenInTabList.clear();
|
||||
this.hiddenInTabList.addAll(ext.getHiddenInTabList().stream().map(Entity::getUUID).collect(Collectors.toList()));
|
||||
this.hiddenInTabList.addAll(ext.getHiddenInTabList().stream().map(Entity::getUUID).toList());
|
||||
|
||||
if (this.deathEventHappened) {
|
||||
this.prevInventory = this.inventory;
|
||||
|
||||
+39
-17
@@ -17,6 +17,7 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.chat.ChatType;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.ClientboundChatPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@@ -30,21 +31,16 @@ import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
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.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.*;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Mixin(PlayerList.class)
|
||||
public abstract class PlayerListMixin {
|
||||
@Shadow public abstract void broadcastMessage(Component component, ChatType chatType, UUID uUID);
|
||||
|
||||
@Shadow public abstract void broadcastAll(Packet<?> packet);
|
||||
|
||||
@Shadow @Final private MinecraftServer server;
|
||||
/**
|
||||
@@ -67,38 +63,62 @@ public abstract class PlayerListMixin {
|
||||
PlayerData.removePlayerData(serverPlayer);
|
||||
}
|
||||
// BEGIN : CHAT EVENT
|
||||
/*
|
||||
@Inject(at = @At("HEAD"), method = "broadcastMessage(Lnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/ChatType;Ljava/util/UUID;)V", cancellable = true)
|
||||
public void callBroadcastMessageEvent(Component component, ChatType chatType, UUID uUID, CallbackInfo ci) {
|
||||
}
|
||||
|
||||
*/
|
||||
// END : CHAT EVENT
|
||||
|
||||
// BEGIN: JOIN EVENT
|
||||
|
||||
@ModifyArgs(method = "broadcastMessage", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/protocol/game/ClientboundChatPacket;<init>(Lnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/ChatType;Ljava/util/UUID;)V"))
|
||||
private void handleChat(Args args) {
|
||||
MinecraftServer server = ((PlayerListAccessor) this).getServer();
|
||||
|
||||
Component component = args.get(0);
|
||||
String key = ((TranslatableComponent) component).getKey();
|
||||
ChatType chatType = args.get(1);
|
||||
|
||||
ServerBroadcastMessageEvent broadcastMessageEvent = new ServerBroadcastMessageEvent(Wrapped.wrap(server, WrappedMetisServer.class), ObjectMappings.convertComponent(component), ObjectMappings.convertChatType(chatType));
|
||||
ServerBroadcastMessageEvent.BACKEND.invoke(broadcastMessageEvent);
|
||||
|
||||
if (!broadcastMessageEvent.isCancelled() && broadcastMessageEvent.getMessage() != null) {
|
||||
this.server.sendMessage(ObjectMappings.convertComponent(broadcastMessageEvent.getMessage()), uUID);
|
||||
this.broadcastAll(new ClientboundChatPacket(ObjectMappings.convertComponent(broadcastMessageEvent.getMessage()), chatType, uUID));
|
||||
args.set(0, ObjectMappings.convertComponent(broadcastMessageEvent.getMessage()));
|
||||
return;
|
||||
}
|
||||
|
||||
ci.cancel();
|
||||
}
|
||||
// END : CHAT EVENT
|
||||
if (key.contains("multiplayer.player.left")) {
|
||||
}
|
||||
|
||||
// BEGIN: JOIN EVENT
|
||||
Component joinMessage;
|
||||
System.out.println("heya " + this.joinEvent.getJoinMessage() == null);
|
||||
System.out.println(key);
|
||||
if (key.contains("multiplayer.player.join") && this.joinEvent.getJoinMessage() != null) {
|
||||
args.set(0, ObjectMappings.convertComponent(joinEvent.getJoinMessage()));
|
||||
System.out.println("giggity giggity");
|
||||
}
|
||||
}
|
||||
|
||||
@Unique Component joinMessage = null;
|
||||
@Unique PlayerJoinEvent joinEvent;
|
||||
|
||||
/*
|
||||
@Redirect(method = "placeNewPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastMessage(Lnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/ChatType;Ljava/util/UUID;)V", ordinal = 0))
|
||||
public void catchJoinMessage(PlayerList playerList, Component component, ChatType chatType, UUID uUID) {
|
||||
joinMessage = component;
|
||||
playerList.broadcastMessage(component, ChatType.SYSTEM, Util.NIL_UUID);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
@Inject(method = "placeNewPlayer", at = @At("TAIL"))
|
||||
public void callPlayerJoinEvent(Connection connection, ServerPlayer serverPlayer, CallbackInfo ci) {
|
||||
PlayerJoinEvent joinEvent = new PlayerJoinEvent(Wrapped.wrap(serverPlayer, WrappedPlayer.class),
|
||||
ObjectMappings.convertComponent(joinMessage));
|
||||
PlayerJoinEvent.BACKEND.invoke(joinEvent);
|
||||
|
||||
if (joinEvent.getJoinMessage() != null) {
|
||||
this.broadcastMessage(ObjectMappings.convertComponent(joinEvent.getJoinMessage()), ChatType.SYSTEM, Util.NIL_UUID);
|
||||
}
|
||||
this.joinEvent = joinEvent;
|
||||
|
||||
PlayerJoinEvent.BACKEND.invokeEndFunctions(joinEvent);
|
||||
}
|
||||
@@ -139,6 +159,7 @@ public abstract class PlayerListMixin {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ModifyVariable(method = "respawn", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/server/MinecraftServer;getLevel(Lnet/minecraft/resources/ResourceKey;)Lnet/minecraft/server/level/ServerLevel;", ordinal = 0, shift = At.Shift.AFTER), ordinal = 1)
|
||||
public boolean modifyIsForced(boolean prev) {
|
||||
if (respawnEvent != null) {
|
||||
@@ -147,6 +168,7 @@ public abstract class PlayerListMixin {
|
||||
return prev;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@ModifyVariable(method = "respawn", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/server/MinecraftServer;getLevel(Lnet/minecraft/resources/ResourceKey;)Lnet/minecraft/server/level/ServerLevel;", ordinal = 0, shift = At.Shift.AFTER))
|
||||
public ServerLevel modifyLevel(ServerLevel prev) {
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
"1.16.x",
|
||||
"1.16.3-combat.8.c"
|
||||
],
|
||||
"factory-api": "*"
|
||||
"metis-api": "*"
|
||||
},
|
||||
"suggests": {
|
||||
},
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "factory-test",
|
||||
"id": "metis-test",
|
||||
"version": "0.1.0",
|
||||
|
||||
"name": "Factory Test",
|
||||
"description": "Testing the Factory API.",
|
||||
"name": "Metis Test",
|
||||
"description": "Testing the Metis API.",
|
||||
"authors": [
|
||||
"rizecookey"
|
||||
],
|
||||
@@ -18,6 +18,6 @@
|
||||
|
||||
"depends": {
|
||||
"fabricloader": ">=0.10.8",
|
||||
"factory-api": "*"
|
||||
"metis-api": "*"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user