Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-19 14:30:17 +01:00
Use Mojang mappings for Geyser-Fabric
Dieser Commit ist enthalten in:
Ursprung
0e07991edf
Commit
144d7b000a
1
Jenkinsfile
vendored
1
Jenkinsfile
vendored
@ -101,7 +101,6 @@ pipeline {
|
||||
success {
|
||||
script {
|
||||
if (env.BRANCH_NAME == 'master') {
|
||||
build propagate: false, wait: false, job: 'GeyserMC/Geyser-Fabric/master', parameters: [booleanParam(name: 'SKIP_DISCORD', value: true)]
|
||||
build propagate: false, wait: false, job: 'GeyserMC/GeyserConnect/master', parameters: [booleanParam(name: 'SKIP_DISCORD', value: true)]
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ java {
|
||||
dependencies {
|
||||
//to change the versions see the gradle.properties file
|
||||
minecraft(libs.fabric.minecraft)
|
||||
mappings(libs.fabric.yarn) { artifact { classifier = "v2" } }
|
||||
mappings(loom.officialMojangMappings())
|
||||
modImplementation(libs.fabric.loader)
|
||||
|
||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||
|
@ -54,12 +54,12 @@ public class GeyserFabricDumpInfo extends BootstrapDumpInfo {
|
||||
}
|
||||
}
|
||||
this.environmentType = FabricLoader.getInstance().getEnvironmentType();
|
||||
if (AsteriskSerializer.showSensitive || (server.getServerIp() == null || server.getServerIp().equals("") || server.getServerIp().equals("0.0.0.0"))) {
|
||||
this.serverIP = server.getServerIp();
|
||||
if (AsteriskSerializer.showSensitive || (server.getLocalIp() == null || server.getLocalIp().equals("") || server.getLocalIp().equals("0.0.0.0"))) {
|
||||
this.serverIP = server.getLocalIp();
|
||||
} else {
|
||||
this.serverIP = "***";
|
||||
}
|
||||
this.serverPort = server.getServerPort();
|
||||
this.serverPort = server.getPort();
|
||||
this.mods = new ArrayList<>();
|
||||
|
||||
for (ModContainer mod : FabricLoader.getInstance().getAllMods()) {
|
||||
|
@ -31,27 +31,28 @@ import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.geyser.GeyserBootstrap;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.GeyserLogger;
|
||||
import org.geysermc.geyser.api.command.Command;
|
||||
import org.geysermc.geyser.api.network.AuthType;
|
||||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
import org.geysermc.geyser.command.GeyserCommandManager;
|
||||
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
||||
import org.geysermc.geyser.ping.GeyserLegacyPingPassthrough;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.GeyserBootstrap;
|
||||
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
||||
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
||||
import org.geysermc.geyser.level.WorldManager;
|
||||
import org.geysermc.geyser.ping.GeyserLegacyPingPassthrough;
|
||||
import org.geysermc.geyser.ping.IGeyserPingPassthrough;
|
||||
import org.geysermc.geyser.util.FileUtils;
|
||||
import org.geysermc.geyser.platform.fabric.command.GeyserFabricCommandExecutor;
|
||||
import org.geysermc.geyser.platform.fabric.command.GeyserFabricCommandManager;
|
||||
import org.geysermc.geyser.platform.fabric.world.GeyserFabricWorldManager;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.FileUtils;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
@ -145,7 +146,7 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
|
||||
|
||||
if (this.geyserConfig.getRemote().address().equalsIgnoreCase("auto")) {
|
||||
this.geyserConfig.setAutoconfiguredRemote(true);
|
||||
String ip = server.getServerIp();
|
||||
String ip = server.getLocalIp();
|
||||
int port = ((GeyserServerPortGetter) server).geyser$getServerPort();
|
||||
if (ip != null && !ip.isEmpty() && !ip.equals("0.0.0.0")) {
|
||||
this.geyserConfig.getRemote().setAddress(ip);
|
||||
@ -185,16 +186,16 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
|
||||
GeyserFabricCommandExecutor helpExecutor = new GeyserFabricCommandExecutor(connector,
|
||||
(GeyserCommand) connector.commandManager().getCommands().get("help"), !playerCommands.contains("help"));
|
||||
commandExecutors.add(helpExecutor);
|
||||
LiteralArgumentBuilder<ServerCommandSource> builder = net.minecraft.server.command.CommandManager.literal("geyser").executes(helpExecutor);
|
||||
LiteralArgumentBuilder<CommandSourceStack> builder = Commands.literal("geyser").executes(helpExecutor);
|
||||
|
||||
// Register all subcommands as valid
|
||||
for (Map.Entry<String, Command> command : connector.commandManager().getCommands().entrySet()) {
|
||||
GeyserFabricCommandExecutor executor = new GeyserFabricCommandExecutor(connector, (GeyserCommand) command.getValue(),
|
||||
!playerCommands.contains(command.getKey()));
|
||||
commandExecutors.add(executor);
|
||||
builder.then(net.minecraft.server.command.CommandManager.literal(command.getKey()).executes(executor));
|
||||
builder.then(Commands.literal(command.getKey()).executes(executor));
|
||||
}
|
||||
server.getCommandManager().getDispatcher().register(builder);
|
||||
server.getCommands().getDispatcher().register(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -245,7 +246,7 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
|
||||
|
||||
@Override
|
||||
public String getMinecraftServerVersion() {
|
||||
return this.server.getVersion();
|
||||
return this.server.getServerVersion();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -39,7 +39,7 @@ public interface GeyserServerPortGetter {
|
||||
* <li>If it's an integrated server, it will return the LAN port if opened, else -1.</li>
|
||||
* </ul>
|
||||
*
|
||||
* The reason is that {@link MinecraftServer#getServerPort()} doesn't return the LAN port if it's the integrated server,
|
||||
* The reason is that {@link MinecraftServer#getPort()} doesn't return the LAN port if it's the integrated server,
|
||||
* and changing the behavior of this method via a mixin should be avoided as it could have unexpected consequences.
|
||||
*
|
||||
* @return The server port.
|
||||
|
@ -25,31 +25,33 @@
|
||||
|
||||
package org.geysermc.geyser.platform.fabric.command;
|
||||
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.platform.fabric.GeyserFabricMod;
|
||||
import org.geysermc.geyser.text.ChatColor;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class FabricCommandSender implements GeyserCommandSource {
|
||||
|
||||
private final ServerCommandSource source;
|
||||
private final CommandSourceStack source;
|
||||
|
||||
public FabricCommandSender(ServerCommandSource source) {
|
||||
public FabricCommandSender(CommandSourceStack source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return source.getName();
|
||||
return source.getTextName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
if (source.getEntity() instanceof ServerPlayerEntity) {
|
||||
((ServerPlayerEntity) source.getEntity()).sendMessage(Text.literal(message), false);
|
||||
public void sendMessage(@Nonnull String message) {
|
||||
if (source.getEntity() instanceof ServerPlayer) {
|
||||
((ServerPlayer) source.getEntity()).displayClientMessage(Component.literal(message), false);
|
||||
} else {
|
||||
GeyserImpl.getInstance().getLogger().info(ChatColor.toANSI(message + ChatColor.RESET));
|
||||
}
|
||||
@ -57,7 +59,7 @@ public class FabricCommandSender implements GeyserCommandSource {
|
||||
|
||||
@Override
|
||||
public boolean isConsole() {
|
||||
return !(source.getEntity() instanceof ServerPlayerEntity);
|
||||
return !(source.getEntity() instanceof ServerPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,7 +27,7 @@ package org.geysermc.geyser.platform.fabric.command;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
import org.geysermc.geyser.command.GeyserCommandExecutor;
|
||||
@ -39,7 +39,7 @@ import org.geysermc.geyser.text.GeyserLocale;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class GeyserFabricCommandExecutor extends GeyserCommandExecutor implements Command<ServerCommandSource> {
|
||||
public class GeyserFabricCommandExecutor extends GeyserCommandExecutor implements Command<CommandSourceStack> {
|
||||
|
||||
private final GeyserCommand command;
|
||||
/**
|
||||
@ -59,13 +59,13 @@ public class GeyserFabricCommandExecutor extends GeyserCommandExecutor implement
|
||||
* @param source The command source attempting to run the command
|
||||
* @return True if the command source is allowed to
|
||||
*/
|
||||
public boolean canRun(ServerCommandSource source) {
|
||||
return !requiresPermission() || source.hasPermissionLevel(GeyserFabricPermissions.RESTRICTED_MIN_LEVEL);
|
||||
public boolean canRun(CommandSourceStack source) {
|
||||
return !requiresPermission() || source.hasPermission(GeyserFabricPermissions.RESTRICTED_MIN_LEVEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int run(CommandContext context) {
|
||||
ServerCommandSource source = (ServerCommandSource) context.getSource();
|
||||
CommandSourceStack source = (CommandSourceStack) context.getSource();
|
||||
FabricCommandSender sender = new FabricCommandSender(source);
|
||||
GeyserSession session = getGeyserSession(sender);
|
||||
if (!canRun(source)) {
|
||||
|
@ -27,11 +27,11 @@ package org.geysermc.geyser.platform.fabric.mixin.client;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.server.IntegratedServer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.integrated.IntegratedServer;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.world.GameMode;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import org.geysermc.geyser.platform.fabric.GeyserFabricMod;
|
||||
import org.geysermc.geyser.platform.fabric.GeyserServerPortGetter;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
@ -46,25 +46,25 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
@Mixin(IntegratedServer.class)
|
||||
public class IntegratedServerMixin implements GeyserServerPortGetter {
|
||||
@Shadow
|
||||
private int lanPort;
|
||||
private int publishedPort;
|
||||
|
||||
@Shadow @Final private MinecraftClient client;
|
||||
@Shadow @Final private Minecraft minecraft;
|
||||
|
||||
@Inject(method = "openToLan", at = @At("RETURN"))
|
||||
private void onOpenToLan(GameMode gameMode, boolean cheatsAllowed, int port, CallbackInfoReturnable<Boolean> cir) {
|
||||
@Inject(method = "publishServer", at = @At("RETURN"))
|
||||
private void onOpenToLan(GameType gameType, boolean cheatsAllowed, int port, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (cir.getReturnValueZ()) {
|
||||
// If the LAN is opened, starts Geyser.
|
||||
GeyserFabricMod.getInstance().startGeyser((MinecraftServer) (Object) this);
|
||||
// Ensure player locale has been loaded, in case it's different from Java system language
|
||||
GeyserLocale.loadGeyserLocale(this.client.options.language);
|
||||
GeyserLocale.loadGeyserLocale(this.minecraft.options.languageCode);
|
||||
// Give indication that Geyser is loaded
|
||||
this.client.player.sendMessage(Text.literal(GeyserLocale.getPlayerLocaleString("geyser.core.start",
|
||||
this.client.options.language, "localhost", String.valueOf(this.lanPort))), false);
|
||||
this.minecraft.player.displayClientMessage(Component.literal(GeyserLocale.getPlayerLocaleString("geyser.core.start",
|
||||
this.minecraft.options.languageCode, "localhost", String.valueOf(this.publishedPort))), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int geyser$getServerPort() {
|
||||
return this.lanPort;
|
||||
return this.publishedPort;
|
||||
}
|
||||
}
|
||||
|
@ -26,26 +26,26 @@
|
||||
package org.geysermc.geyser.platform.fabric.mixin.server;
|
||||
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import net.minecraft.resource.ResourcePackManager;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.SaveLoader;
|
||||
import net.minecraft.server.WorldGenerationProgressListenerFactory;
|
||||
import net.minecraft.server.dedicated.MinecraftDedicatedServer;
|
||||
import net.minecraft.util.ApiServices;
|
||||
import net.minecraft.world.level.storage.LevelStorage;
|
||||
import net.minecraft.server.Services;
|
||||
import net.minecraft.server.WorldStem;
|
||||
import net.minecraft.server.dedicated.DedicatedServer;
|
||||
import net.minecraft.server.level.progress.ChunkProgressListenerFactory;
|
||||
import net.minecraft.server.packs.repository.PackRepository;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
import org.geysermc.geyser.platform.fabric.GeyserServerPortGetter;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
import java.net.Proxy;
|
||||
|
||||
@Mixin(MinecraftDedicatedServer.class)
|
||||
@Mixin(DedicatedServer.class)
|
||||
public abstract class MinecraftDedicatedServerMixin extends MinecraftServer implements GeyserServerPortGetter {
|
||||
public MinecraftDedicatedServerMixin(Thread serverThread, LevelStorage.Session session, ResourcePackManager dataPackManager, SaveLoader saveLoader, Proxy proxy, DataFixer dataFixer, ApiServices apiServices, WorldGenerationProgressListenerFactory worldGenerationProgressListenerFactory) {
|
||||
super(serverThread, session, dataPackManager, saveLoader, proxy, dataFixer, apiServices, worldGenerationProgressListenerFactory);
|
||||
public MinecraftDedicatedServerMixin(Thread thread, LevelStorageSource.LevelStorageAccess levelStorageAccess, PackRepository packRepository, WorldStem worldStem, Proxy proxy, DataFixer dataFixer, Services services, ChunkProgressListenerFactory chunkProgressListenerFactory) {
|
||||
super(thread, levelStorageAccess, packRepository, worldStem, proxy, dataFixer, services, chunkProgressListenerFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int geyser$getServerPort() {
|
||||
return this.getServerPort();
|
||||
return this.getPort();
|
||||
}
|
||||
}
|
||||
|
@ -29,15 +29,15 @@ import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.nbt.NbtMap;
|
||||
import com.nukkitx.nbt.NbtMapBuilder;
|
||||
import com.nukkitx.nbt.NbtType;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.LecternBlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.WritableBookItem;
|
||||
import net.minecraft.item.WrittenBookItem;
|
||||
import net.minecraft.nbt.NbtList;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.WritableBookItem;
|
||||
import net.minecraft.world.item.WrittenBookItem;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.LecternBlockEntity;
|
||||
import org.geysermc.geyser.level.GeyserWorldManager;
|
||||
import org.geysermc.geyser.platform.fabric.GeyserFabricMod;
|
||||
import org.geysermc.geyser.platform.fabric.command.GeyserFabricCommandExecutor;
|
||||
@ -65,9 +65,9 @@ public class GeyserFabricWorldManager extends GeyserWorldManager {
|
||||
public NbtMap getLecternDataAt(GeyserSession session, int x, int y, int z, boolean isChunkLoad) {
|
||||
Runnable lecternGet = () -> {
|
||||
// Mostly a reimplementation of Spigot lectern support
|
||||
PlayerEntity player = getPlayer(session);
|
||||
ServerPlayer player = getPlayer(session);
|
||||
if (player != null) {
|
||||
BlockEntity blockEntity = player.world.getBlockEntity(new BlockPos(x, y, z));
|
||||
BlockEntity blockEntity = player.level.getBlockEntity(new BlockPos(x, y, z));
|
||||
if (!(blockEntity instanceof LecternBlockEntity lectern)) {
|
||||
return;
|
||||
}
|
||||
@ -83,14 +83,14 @@ public class GeyserFabricWorldManager extends GeyserWorldManager {
|
||||
int pageCount = WrittenBookItem.getPageCount(book);
|
||||
boolean hasBookPages = pageCount > 0;
|
||||
NbtMapBuilder lecternTag = LecternInventoryTranslator.getBaseLecternTag(x, y, z, hasBookPages ? pageCount : 1);
|
||||
lecternTag.putInt("page", lectern.getCurrentPage() / 2);
|
||||
lecternTag.putInt("page", lectern.getPage() / 2);
|
||||
NbtMapBuilder bookTag = NbtMap.builder()
|
||||
.putByte("Count", (byte) book.getCount())
|
||||
.putShort("Damage", (short) 0)
|
||||
.putString("Name", "minecraft:writable_book");
|
||||
List<NbtMap> pages = new ArrayList<>(hasBookPages ? pageCount : 1);
|
||||
if (hasBookPages && WritableBookItem.isValid(book.getNbt())) {
|
||||
NbtList listTag = book.getNbt().getList("pages", 8);
|
||||
if (hasBookPages && WritableBookItem.makeSureTagIsValid(book.getTag())) {
|
||||
ListTag listTag = book.getTag().getList("pages", 8);
|
||||
|
||||
for (int i = 0; i < listTag.size(); i++) {
|
||||
String page = listTag.getString(i);
|
||||
@ -127,14 +127,14 @@ public class GeyserFabricWorldManager extends GeyserWorldManager {
|
||||
// Workaround for our commands because fabric doesn't have native permissions
|
||||
for (GeyserFabricCommandExecutor executor : GeyserFabricMod.getInstance().getCommandExecutors()) {
|
||||
if (executor.getCommand().permission().equals(permission)) {
|
||||
return executor.canRun(getPlayer(session).getCommandSource());
|
||||
return executor.canRun(getPlayer(session).createCommandSourceStack());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private PlayerEntity getPlayer(GeyserSession session) {
|
||||
return server.getPlayerManager().getPlayer(session.getPlayerEntity().getUuid());
|
||||
private ServerPlayer getPlayer(GeyserSession session) {
|
||||
return server.getPlayerList().getPlayer(session.getPlayerEntity().getUuid());
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,6 @@ paper-mojangapi = { group = "io.papermc.paper", name = "paper-mojangapi", versio
|
||||
|
||||
# check these on https://modmuss50.me/fabric.html
|
||||
fabric-minecraft = { group = "com.mojang", name = "minecraft", version = "1.19.1" }
|
||||
fabric-yarn = { group = "net.fabricmc", name = "yarn", version = "1.19.1+build.1" }
|
||||
fabric-loader = { group = "net.fabricmc", name = "fabric-loader", version = "0.14.8" }
|
||||
fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version = "0.58.5+1.19.1" }
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren