Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 00:00:41 +01:00
Merge remote-tracking branch 'origin/dev' into feature/1.21
Dieser Commit ist enthalten in:
Commit
c136bcb34d
@ -36,7 +36,7 @@ import java.util.Map;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a session has logged in, and is about to connect to a remote java server.
|
* Called when a session has logged in, and is about to connect to a remote Java server.
|
||||||
* This event is cancellable, and can be used to prevent the player from connecting to the remote server.
|
* This event is cancellable, and can be used to prevent the player from connecting to the remote server.
|
||||||
*/
|
*/
|
||||||
public final class SessionLoginEvent extends ConnectionEvent implements Cancellable {
|
public final class SessionLoginEvent extends ConnectionEvent implements Cancellable {
|
||||||
@ -99,9 +99,9 @@ public final class SessionLoginEvent extends ConnectionEvent implements Cancella
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link RemoteServer} the section will attempt to connect to.
|
* Gets the {@link RemoteServer} the session will attempt to connect to.
|
||||||
*
|
*
|
||||||
* @return the {@link RemoteServer} the section will attempt to connect to.
|
* @return the {@link RemoteServer} the session will attempt to connect to.
|
||||||
*/
|
*/
|
||||||
public @NonNull RemoteServer remoteServer() {
|
public @NonNull RemoteServer remoteServer() {
|
||||||
return this.remoteServer;
|
return this.remoteServer;
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
package org.geysermc.geyser.platform.mod.world;
|
package org.geysermc.geyser.platform.mod.world;
|
||||||
|
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
|
||||||
import net.minecraft.SharedConstants;
|
import net.minecraft.SharedConstants;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.RegistryAccess;
|
import net.minecraft.core.RegistryAccess;
|
||||||
@ -34,10 +33,7 @@ import net.minecraft.core.component.DataComponents;
|
|||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
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.Filterable;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.component.WritableBookContent;
|
|
||||||
import net.minecraft.world.item.component.WrittenBookContent;
|
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.entity.BannerBlockEntity;
|
import net.minecraft.world.level.block.entity.BannerBlockEntity;
|
||||||
@ -63,7 +59,6 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
public class GeyserModWorldManager extends GeyserWorldManager {
|
public class GeyserModWorldManager extends GeyserWorldManager {
|
||||||
|
|
||||||
private static final GsonComponentSerializer GSON_SERIALIZER = GsonComponentSerializer.gson();
|
private static final GsonComponentSerializer GSON_SERIALIZER = GsonComponentSerializer.gson();
|
||||||
private static final LegacyComponentSerializer LEGACY_SERIALIZER = LegacyComponentSerializer.legacySection();
|
|
||||||
private final MinecraftServer server;
|
private final MinecraftServer server;
|
||||||
|
|
||||||
public GeyserModWorldManager(MinecraftServer server) {
|
public GeyserModWorldManager(MinecraftServer server) {
|
||||||
@ -169,39 +164,6 @@ public class GeyserModWorldManager extends GeyserWorldManager {
|
|||||||
return server.getPlayerList().getPlayer(session.getPlayerEntity().getUuid());
|
return server.getPlayerList().getPlayer(session.getPlayerEntity().getUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getPageCount(ItemStack itemStack) {
|
|
||||||
WrittenBookContent writtenBookContent = itemStack.get(DataComponents.WRITTEN_BOOK_CONTENT);
|
|
||||||
if (writtenBookContent != null) {
|
|
||||||
return writtenBookContent.pages().size();
|
|
||||||
} else {
|
|
||||||
WritableBookContent writableBookContent = itemStack.get(DataComponents.WRITABLE_BOOK_CONTENT);
|
|
||||||
return writableBookContent != null ? writableBookContent.pages().size() : 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<String> getPages(ItemStack itemStack) {
|
|
||||||
WrittenBookContent writtenBookContent = itemStack.get(DataComponents.WRITTEN_BOOK_CONTENT);
|
|
||||||
if (writtenBookContent != null) {
|
|
||||||
return writtenBookContent.pages().stream()
|
|
||||||
.map(Filterable::raw)
|
|
||||||
.map(GeyserModWorldManager::fromComponent)
|
|
||||||
.toList();
|
|
||||||
} else {
|
|
||||||
WritableBookContent writableBookContent = itemStack.get(DataComponents.WRITABLE_BOOK_CONTENT);
|
|
||||||
if (writableBookContent == null) {
|
|
||||||
return List.of();
|
|
||||||
}
|
|
||||||
return writableBookContent.pages().stream()
|
|
||||||
.map(Filterable::raw)
|
|
||||||
.toList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String fromComponent(Component component) {
|
|
||||||
String json = Component.Serializer.toJson(component, RegistryAccess.EMPTY);
|
|
||||||
return LEGACY_SERIALIZER.serialize(GSON_SERIALIZER.deserializeOr(json, net.kyori.adventure.text.Component.empty()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static net.kyori.adventure.text.Component toKyoriComponent(Component component) {
|
private static net.kyori.adventure.text.Component toKyoriComponent(Component component) {
|
||||||
String json = Component.Serializer.toJson(component, RegistryAccess.EMPTY);
|
String json = Component.Serializer.toJson(component, RegistryAccess.EMPTY);
|
||||||
return GSON_SERIALIZER.deserializeOr(json, net.kyori.adventure.text.Component.empty());
|
return GSON_SERIALIZER.deserializeOr(json, net.kyori.adventure.text.Component.empty());
|
||||||
|
@ -30,8 +30,6 @@ import org.geysermc.geyser.item.type.*;
|
|||||||
import org.geysermc.geyser.level.block.Blocks;
|
import org.geysermc.geyser.level.block.Blocks;
|
||||||
import org.geysermc.geyser.registry.Registries;
|
import org.geysermc.geyser.registry.Registries;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
import static org.geysermc.geyser.item.type.Item.builder;
|
import static org.geysermc.geyser.item.type.Item.builder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1381,11 +1379,7 @@ public final class Items {
|
|||||||
|
|
||||||
public static <T extends Item> T register(T item, int id) {
|
public static <T extends Item> T register(T item, int id) {
|
||||||
item.setJavaId(id);
|
item.setJavaId(id);
|
||||||
// This makes sure that the array is large enough to put the java item at the correct location
|
Registries.JAVA_ITEMS.registerWithAnyIndex(id, item, AIR);
|
||||||
if (Registries.JAVA_ITEMS.get().size() <= id) {
|
|
||||||
Registries.JAVA_ITEMS.get().addAll(Collections.nCopies(id - Registries.JAVA_ITEMS.get().size() + 1, AIR));
|
|
||||||
}
|
|
||||||
Registries.JAVA_ITEMS.get().set(id, item);
|
|
||||||
Registries.JAVA_ITEM_IDENTIFIERS.register(item.javaIdentifier(), item);
|
Registries.JAVA_ITEM_IDENTIFIERS.register(item.javaIdentifier(), item);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
import org.geysermc.geyser.registry.loader.RegistryLoader;
|
import org.geysermc.geyser.registry.loader.RegistryLoader;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@ -94,6 +95,25 @@ public class ListRegistry<M> extends Registry<List<M>> {
|
|||||||
return this.mappings.set(index, value);
|
return this.mappings.set(index, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a new value into this registry with the given index, even if this value would normally be outside
|
||||||
|
* the range of a list.
|
||||||
|
*
|
||||||
|
* @param index the index
|
||||||
|
* @param value the value
|
||||||
|
* @param defaultValue the default value to fill empty spaces in the registry with.
|
||||||
|
* @return a new value into this registry with the given index.
|
||||||
|
*/
|
||||||
|
public M registerWithAnyIndex(int index, M value, M defaultValue) {
|
||||||
|
if (this.frozen) {
|
||||||
|
throw new IllegalStateException("Registry should not be modified after frozen!");
|
||||||
|
}
|
||||||
|
if (this.mappings.size() <= index) {
|
||||||
|
this.mappings.addAll(Collections.nCopies(index - this.mappings.size() + 1, defaultValue));
|
||||||
|
}
|
||||||
|
return this.mappings.set(index, value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark this registry as unsuitable for new additions. The backing list will then be optimized for storage.
|
* Mark this registry as unsuitable for new additions. The backing list will then be optimized for storage.
|
||||||
*/
|
*/
|
||||||
|
@ -213,7 +213,6 @@ public final class BlockRegistryPopulator {
|
|||||||
GeyserBedrockBlock[] javaToBedrockBlocks = new GeyserBedrockBlock[JAVA_BLOCKS_SIZE];
|
GeyserBedrockBlock[] javaToBedrockBlocks = new GeyserBedrockBlock[JAVA_BLOCKS_SIZE];
|
||||||
GeyserBedrockBlock[] javaToVanillaBedrockBlocks = new GeyserBedrockBlock[JAVA_BLOCKS_SIZE];
|
GeyserBedrockBlock[] javaToVanillaBedrockBlocks = new GeyserBedrockBlock[JAVA_BLOCKS_SIZE];
|
||||||
|
|
||||||
//List<String> javaToBedrockIdentifiers = new ArrayList<>(BlockRegistries.JAVA_BLOCKS.get().size());
|
|
||||||
var javaToBedrockIdentifiers = new Int2ObjectOpenHashMap<String>();
|
var javaToBedrockIdentifiers = new Int2ObjectOpenHashMap<String>();
|
||||||
Block lastBlockSeen = null;
|
Block lastBlockSeen = null;
|
||||||
|
|
||||||
@ -456,7 +455,7 @@ public final class BlockRegistryPopulator {
|
|||||||
};
|
};
|
||||||
block.setJavaId(javaBlockState.stateGroupId());
|
block.setJavaId(javaBlockState.stateGroupId());
|
||||||
|
|
||||||
BlockRegistries.JAVA_BLOCKS.get().add(javaBlockState.stateGroupId(), block); //TODO don't allow duplicates, allow blanks
|
BlockRegistries.JAVA_BLOCKS.registerWithAnyIndex(javaBlockState.stateGroupId(), block, Blocks.AIR);
|
||||||
BlockRegistries.JAVA_IDENTIFIER_TO_ID.register(javaId, stateRuntimeId);
|
BlockRegistries.JAVA_IDENTIFIER_TO_ID.register(javaId, stateRuntimeId);
|
||||||
BlockRegistries.BLOCK_STATES.register(stateRuntimeId, new BlockState(block, stateRuntimeId));
|
BlockRegistries.BLOCK_STATES.register(stateRuntimeId, new BlockState(block, stateRuntimeId));
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ netty-io-uring = "0.0.25.Final-SNAPSHOT"
|
|||||||
guava = "29.0-jre"
|
guava = "29.0-jre"
|
||||||
gson = "2.3.1" # Provided by Spigot 1.8.8
|
gson = "2.3.1" # Provided by Spigot 1.8.8
|
||||||
websocket = "1.5.1"
|
websocket = "1.5.1"
|
||||||
protocol = "3.0.0.Beta2-20240520.153053-5"
|
protocol = "3.0.0.Beta2-20240606.172607-7"
|
||||||
raknet = "1.0.0.CR3-20240416.144209-1"
|
raknet = "1.0.0.CR3-20240416.144209-1"
|
||||||
mcauthlib = "e5b0bcc"
|
mcauthlib = "e5b0bcc"
|
||||||
mcprotocollib = "1.21-SNAPSHOT"
|
mcprotocollib = "1.21-SNAPSHOT"
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren