mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 06:28:54 +00:00
Enable fabric/sponge modules, bump fabric to 1.19.1-pre4
This commit is contained in:
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.draycia.carbon.fabric.callback.PlayerStatusMessageEvents;
|
||||||
import net.kyori.adventure.platform.fabric.FabricServerAudiences;
|
import net.kyori.adventure.platform.fabric.FabricServerAudiences;
|
||||||
import net.minecraft.network.Connection;
|
import net.minecraft.network.Connection;
|
||||||
import net.minecraft.network.chat.ChatType;
|
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceKey;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.players.PlayerList;
|
import net.minecraft.server.players.PlayerList;
|
||||||
@@ -46,20 +44,20 @@ abstract class PlayerListMixin {
|
|||||||
@Shadow @Final private MinecraftServer server;
|
@Shadow @Final private MinecraftServer server;
|
||||||
|
|
||||||
@Shadow
|
@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(
|
@Redirect(
|
||||||
method = "placeNewPlayer(Lnet/minecraft/network/Connection;Lnet/minecraft/server/level/ServerPlayer;)V",
|
method = "placeNewPlayer(Lnet/minecraft/network/Connection;Lnet/minecraft/server/level/ServerPlayer;)V",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
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
|
// 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(
|
@Inject(
|
||||||
@@ -67,7 +65,7 @@ abstract class PlayerListMixin {
|
|||||||
at = @At("RETURN")
|
at = @At("RETURN")
|
||||||
)
|
)
|
||||||
public void injectJoin(final Connection connection, final ServerPlayer serverPlayer, final CallbackInfo ci) {
|
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) {
|
if (remove != null) {
|
||||||
final PlayerStatusMessageEvents.MessageEvent event = PlayerStatusMessageEvents.MessageEvent.of(
|
final PlayerStatusMessageEvents.MessageEvent event = PlayerStatusMessageEvents.MessageEvent.of(
|
||||||
serverPlayer, remove.getFirst().asComponent()
|
serverPlayer, remove.getFirst().asComponent()
|
||||||
|
|||||||
+3
-33
@@ -19,16 +19,11 @@
|
|||||||
*/
|
*/
|
||||||
package net.draycia.carbon.fabric.mixin;
|
package net.draycia.carbon.fabric.mixin;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import net.draycia.carbon.fabric.callback.PlayerStatusMessageEvents;
|
import net.draycia.carbon.fabric.callback.PlayerStatusMessageEvents;
|
||||||
import net.kyori.adventure.platform.fabric.FabricServerAudiences;
|
import net.kyori.adventure.platform.fabric.FabricServerAudiences;
|
||||||
import net.minecraft.network.chat.ChatType;
|
|
||||||
import net.minecraft.network.chat.Component;
|
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.MinecraftServer;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.network.FilteredText;
|
|
||||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||||
import net.minecraft.server.players.PlayerList;
|
import net.minecraft.server.players.PlayerList;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
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.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
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.Redirect;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
||||||
|
|
||||||
@Mixin(ServerGamePacketListenerImpl.class)
|
@Mixin(ServerGamePacketListenerImpl.class)
|
||||||
abstract class ServerGamePacketListenerImplMixin {
|
abstract class ServerGamePacketListenerImplMixin {
|
||||||
@@ -48,43 +40,21 @@ abstract class ServerGamePacketListenerImplMixin {
|
|||||||
|
|
||||||
@Shadow public ServerPlayer player;
|
@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(
|
@Redirect(
|
||||||
method = "onDisconnect(Lnet/minecraft/network/chat/Component;)V",
|
method = "onDisconnect(Lnet/minecraft/network/chat/Component;)V",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
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(
|
final PlayerStatusMessageEvents.MessageEvent event = PlayerStatusMessageEvents.MessageEvent.of(
|
||||||
this.player, component.asComponent()
|
this.player, component.asComponent()
|
||||||
);
|
);
|
||||||
PlayerStatusMessageEvents.QUIT_MESSAGE.invoker().onMessage(event);
|
PlayerStatusMessageEvents.QUIT_MESSAGE.invoker().onMessage(event);
|
||||||
final net.kyori.adventure.text.@Nullable Component message = event.message();
|
final net.kyori.adventure.text.@Nullable Component message = event.message();
|
||||||
if (message != null) {
|
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",
|
method = "die(Lnet/minecraft/world/damagesource/DamageSource;)V",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
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);
|
final @Nullable Component msg = this.carbon$fireDeathMessageEvent(component);
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
instance.broadcastSystemMessage(msg, resourceKey);
|
instance.broadcastSystemMessage(msg, bool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -77,7 +77,7 @@ sequenceOf(
|
|||||||
"api",
|
"api",
|
||||||
"common",
|
"common",
|
||||||
"paper",
|
"paper",
|
||||||
//"sponge",
|
"sponge",
|
||||||
"fabric",
|
"fabric",
|
||||||
"velocity"
|
"velocity"
|
||||||
).forEach {
|
).forEach {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ tasks {
|
|||||||
|
|
||||||
sponge {
|
sponge {
|
||||||
injectRepositories(false) // We specify repositories in settings.gradle.kts
|
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)) {
|
plugin(rootProject.name.toLowerCase(Locale.ROOT)) {
|
||||||
loader {
|
loader {
|
||||||
name(PluginLoaders.JAVA_PLAIN)
|
name(PluginLoaders.JAVA_PLAIN)
|
||||||
|
|||||||
Reference in new issue
Block a user