Enable fabric/sponge modules, bump fabric to 1.19.1-pre4

This commit is contained in:
Jason Penilla committed 2022-07-08 12:59:07 -07:00
1 parent 16afe80d07
commit fb2bf2d5de
5 files changed
+14 -46

No files matched your search

@@ -25,9 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
import net.draycia.carbon.fabric.callback.PlayerStatusMessageEvents;
import net.kyori.adventure.platform.fabric.FabricServerAudiences;
import net.minecraft.network.Connection;
import net.minecraft.network.chat.ChatType;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.players.PlayerList;
@@ -46,20 +44,20 @@ abstract class PlayerListMixin {
@Shadow @Final private MinecraftServer server;
@Shadow
public abstract void broadcastSystemMessage(Component component, ResourceKey<ChatType> resourceKey);
public abstract void broadcastSystemMessage(Component component, boolean bool);
public Map<Thread, Pair<Component, ResourceKey<ChatType>>> carbon$joinMsg = new ConcurrentHashMap<>();
public Map<Thread, Pair<Component, Boolean>> carbon$joinMsg = new ConcurrentHashMap<>();
@Redirect(
method = "placeNewPlayer(Lnet/minecraft/network/Connection;Lnet/minecraft/server/level/ServerPlayer;)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Lnet/minecraft/resources/ResourceKey;)V"
target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V"
)
)
public void redirectJoinMessage(final PlayerList instance, final Component component, final ResourceKey<ChatType> resourceKey) {
public void redirectJoinMessage(final PlayerList instance, final Component component, final boolean bool) {
// move to after player is added to playerlist and world
this.carbon$joinMsg.put(Thread.currentThread(), Pair.of(component, resourceKey));
this.carbon$joinMsg.put(Thread.currentThread(), Pair.of(component, bool));
}
@Inject(
@@ -67,7 +65,7 @@ abstract class PlayerListMixin {
at = @At("RETURN")
)
public void injectJoin(final Connection connection, final ServerPlayer serverPlayer, final CallbackInfo ci) {
final @Nullable Pair<Component, ResourceKey<ChatType>> remove = this.carbon$joinMsg.remove(Thread.currentThread());
final @Nullable Pair<Component, Boolean> remove = this.carbon$joinMsg.remove(Thread.currentThread());
if (remove != null) {
final PlayerStatusMessageEvents.MessageEvent event = PlayerStatusMessageEvents.MessageEvent.of(
serverPlayer, remove.getFirst().asComponent()
@@ -19,16 +19,11 @@
*/
package net.draycia.carbon.fabric.mixin;
import java.util.concurrent.CompletableFuture;
import net.draycia.carbon.fabric.callback.PlayerStatusMessageEvents;
import net.kyori.adventure.platform.fabric.FabricServerAudiences;
import net.minecraft.network.chat.ChatType;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.game.ServerboundChatPacket;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.FilteredText;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
import net.minecraft.server.players.PlayerList;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -36,10 +31,7 @@ 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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ServerGamePacketListenerImpl.class)
abstract class ServerGamePacketListenerImplMixin {
@@ -48,43 +40,21 @@ abstract class ServerGamePacketListenerImplMixin {
@Shadow public ServerPlayer player;
@Inject(
method = "handleChat(Lnet/minecraft/network/protocol/game/ServerboundChatPacket;Lnet/minecraft/server/network/FilteredText;)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/network/protocol/game/ServerboundChatPacket;getSignature(Ljava/util/UUID;)Lnet/minecraft/network/chat/MessageSignature;",
shift = At.Shift.BEFORE
)
// , cancellable = true // todo
)
public void injectHandleChat(final ServerboundChatPacket serverboundChatPacket, final FilteredText<String> filteredText, final CallbackInfo ci) {
// todo
}
@Inject(
method = "queryChatPreview",
at = @At("HEAD")
// , cancellable = true // todo
)
public void injectQueryChatPreview(final String string, final CallbackInfoReturnable<CompletableFuture<Component>> cir) {
// todo
}
@Redirect(
method = "onDisconnect(Lnet/minecraft/network/chat/Component;)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Lnet/minecraft/resources/ResourceKey;)V"
target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V"
)
)
public void redirectQuitMessage(final PlayerList instance, final Component component, final ResourceKey<ChatType> resourceKey) {
public void redirectQuitMessage(final PlayerList instance, final Component component, final boolean bool) {
final PlayerStatusMessageEvents.MessageEvent event = PlayerStatusMessageEvents.MessageEvent.of(
this.player, component.asComponent()
);
PlayerStatusMessageEvents.QUIT_MESSAGE.invoker().onMessage(event);
final net.kyori.adventure.text.@Nullable Component message = event.message();
if (message != null) {
instance.broadcastSystemMessage(FabricServerAudiences.of(this.server).toNative(message), resourceKey);
instance.broadcastSystemMessage(FabricServerAudiences.of(this.server).toNative(message), bool);
}
}
@@ -44,13 +44,13 @@ abstract class ServerPlayerMixin {
method = "die(Lnet/minecraft/world/damagesource/DamageSource;)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Lnet/minecraft/resources/ResourceKey;)V"
target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V"
)
)
public void redirectBroadcastDeath(final PlayerList instance, final Component component, final ResourceKey<ChatType> resourceKey) {
public void redirectBroadcastDeath(final PlayerList instance, final Component component, final boolean bool) {
final @Nullable Component msg = this.carbon$fireDeathMessageEvent(component);
if (msg != null) {
instance.broadcastSystemMessage(msg, resourceKey);
instance.broadcastSystemMessage(msg, bool);
}
}
+1 -1
View File
@@ -77,7 +77,7 @@ sequenceOf(
"api",
"common",
"paper",
//"sponge",
"sponge",
"fabric",
"velocity"
).forEach {
+1 -1
View File
@@ -27,7 +27,7 @@ tasks {
sponge {
injectRepositories(false) // We specify repositories in settings.gradle.kts
apiVersion("8.1.0-SNAPSHOT")
apiVersion("9.0.0-SNAPSHOT")
plugin(rootProject.name.toLowerCase(Locale.ROOT)) {
loader {
name(PluginLoaders.JAVA_PLAIN)