mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Initial 1.19.40.24 Bedrock support
This commit is contained in:
parent
730b0beb01
commit
94a810b683
7 changed files with 37 additions and 30 deletions
|
@ -27,7 +27,7 @@ package org.geysermc.geyser.level;
|
|||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
||||
import org.geysermc.geyser.util.JavaCodecEntry;
|
||||
import org.geysermc.geyser.util.JavaCodecUtil;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -39,7 +39,7 @@ import java.util.Map;
|
|||
public record JavaDimension(int minY, int maxY, boolean piglinSafe, double worldCoordinateScale) {
|
||||
|
||||
public static void load(CompoundTag tag, Map<String, JavaDimension> map) {
|
||||
for (CompoundTag dimension : JavaCodecEntry.iterateAsTag(tag.get("minecraft:dimension_type"))) {
|
||||
for (CompoundTag dimension : JavaCodecUtil.iterateAsTag(tag.get("minecraft:dimension_type"))) {
|
||||
CompoundTag elements = dimension.get("element");
|
||||
int minY = ((IntTag) elements.get("min_y")).getValue();
|
||||
int maxY = ((IntTag) elements.get("height")).getValue();
|
||||
|
|
|
@ -33,6 +33,7 @@ import com.nukkitx.protocol.bedrock.v534.Bedrock_v534;
|
|||
import com.nukkitx.protocol.bedrock.v544.Bedrock_v544;
|
||||
import com.nukkitx.protocol.bedrock.v545.Bedrock_v545;
|
||||
import com.nukkitx.protocol.bedrock.v554.Bedrock_v554;
|
||||
import com.nukkitx.protocol.bedrock.v557.Bedrock_v557;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -75,6 +76,7 @@ public final class GameProtocol {
|
|||
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC.toBuilder()
|
||||
.minecraftVersion("1.19.30/1.19.31")
|
||||
.build());
|
||||
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v557.V557_CODEC);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,7 +45,7 @@ import org.geysermc.geyser.level.chunk.bitarray.BitArrayVersion;
|
|||
import org.geysermc.geyser.level.chunk.bitarray.SingletonBitArray;
|
||||
import org.geysermc.geyser.registry.Registries;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.util.JavaCodecEntry;
|
||||
import org.geysermc.geyser.util.JavaCodecUtil;
|
||||
import org.geysermc.geyser.util.MathUtils;
|
||||
|
||||
// Array index formula by https://wiki.vg/Chunk_Format
|
||||
|
@ -59,7 +59,7 @@ public class BiomeTranslator {
|
|||
ListTag serverBiomes = worldGen.get("value");
|
||||
session.setBiomeGlobalPalette(MathUtils.getGlobalPaletteForSize(serverBiomes.size()));
|
||||
|
||||
for (CompoundTag biomeTag : JavaCodecEntry.iterateAsTag(worldGen)) {
|
||||
for (CompoundTag biomeTag : JavaCodecUtil.iterateAsTag(worldGen)) {
|
||||
String javaIdentifier = ((StringTag) biomeTag.get("name")).getValue();
|
||||
int bedrockId = Registries.BIOME_IDENTIFIERS.get().getOrDefault(javaIdentifier, 0);
|
||||
int javaId = ((IntTag) biomeTag.get("id")).getValue();
|
||||
|
|
|
@ -46,7 +46,7 @@ import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
|||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
import org.geysermc.geyser.util.ChunkUtils;
|
||||
import org.geysermc.geyser.util.DimensionUtils;
|
||||
import org.geysermc.geyser.util.JavaCodecEntry;
|
||||
import org.geysermc.geyser.util.JavaCodecUtil;
|
||||
import org.geysermc.geyser.util.PluginMessageUtils;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -66,7 +66,7 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
|||
|
||||
Int2ObjectMap<TextDecoration> chatTypes = session.getChatTypes();
|
||||
chatTypes.clear();
|
||||
for (CompoundTag tag : JavaCodecEntry.iterateAsTag(packet.getRegistry().get("minecraft:chat_type"))) {
|
||||
for (CompoundTag tag : JavaCodecUtil.iterateAsTag(packet.getRegistry().get("minecraft:chat_type"))) {
|
||||
// The ID is NOT ALWAYS THE SAME! ViaVersion as of 1.19 adds two registry entries that do NOT match vanilla.
|
||||
int id = ((IntTag) tag.get("id")).getValue();
|
||||
CompoundTag element = tag.get("element");
|
||||
|
|
|
@ -32,7 +32,7 @@ import com.github.steveice10.opennbt.tag.builtin.Tag;
|
|||
import javax.annotation.Nonnull;
|
||||
import java.util.Iterator;
|
||||
|
||||
public record JavaCodecEntry() {
|
||||
public final class JavaCodecUtil {
|
||||
|
||||
/**
|
||||
* Iterate over a Java Edition codec and return each entry as a CompoundTag
|
||||
|
@ -58,4 +58,7 @@ public record JavaCodecEntry() {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
private JavaCodecUtil() {
|
||||
}
|
||||
}
|
|
@ -26,17 +26,17 @@
|
|||
package org.geysermc.geyser.util;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.StatisticFormat;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.function.IntFunction;
|
||||
|
||||
public class StatisticFormatters {
|
||||
public final class StatisticFormatters {
|
||||
|
||||
private static final Map<StatisticFormat, IntFunction<String>> FORMATTERS = new Object2ObjectOpenHashMap<>();
|
||||
private static final Map<StatisticFormat, IntFunction<String>> FORMATTERS = new EnumMap<>(StatisticFormat.class);
|
||||
private static final DecimalFormat FORMAT = new DecimalFormat("###,###,##0.00");
|
||||
|
||||
public static final IntFunction<String> INTEGER = NumberFormat.getIntegerInstance(Locale.US)::format;
|
||||
|
@ -78,4 +78,7 @@ public class StatisticFormatters {
|
|||
public static IntFunction<String> get(StatisticFormat format) {
|
||||
return FORMATTERS.getOrDefault(format, INTEGER);
|
||||
}
|
||||
|
||||
private StatisticFormatters() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
package org.geysermc.geyser.util;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.*;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import org.geysermc.cumulus.form.SimpleForm;
|
||||
import org.geysermc.cumulus.util.FormImage;
|
||||
import org.geysermc.geyser.registry.BlockRegistries;
|
||||
|
@ -37,7 +38,6 @@ import org.geysermc.geyser.text.MinecraftLocale;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.function.IntFunction;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -79,23 +79,23 @@ public class StatisticsUtils {
|
|||
case 0:
|
||||
builder.title("stat.generalButton");
|
||||
|
||||
for (Map.Entry<Statistic, Integer> entry : session.getStatistics().entrySet()) {
|
||||
for (Object2IntMap.Entry<Statistic> entry : session.getStatistics().object2IntEntrySet()) {
|
||||
if (entry.getKey() instanceof CustomStatistic statistic) {
|
||||
String statName = statistic.name().toLowerCase(Locale.ROOT);
|
||||
IntFunction<String> formatter = StatisticFormatters.get(statistic.getFormat());
|
||||
content.add("stat.minecraft." + statName + ": " + formatter.apply(entry.getValue()));
|
||||
content.add("stat.minecraft." + statName + ": " + formatter.apply(entry.getIntValue()));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
builder.title("stat.itemsButton - stat_type.minecraft.mined");
|
||||
|
||||
for (Map.Entry<Statistic, Integer> entry : session.getStatistics().entrySet()) {
|
||||
for (Object2IntMap.Entry<Statistic> entry : session.getStatistics().object2IntEntrySet()) {
|
||||
if (entry.getKey() instanceof BreakBlockStatistic statistic) {
|
||||
String identifier = BlockRegistries.CLEAN_JAVA_IDENTIFIERS.get(statistic.getId());
|
||||
if (identifier != null) {
|
||||
String block = identifier.replace("minecraft:", "block.minecraft.");
|
||||
content.add(block + ": " + entry.getValue());
|
||||
content.add(block + ": " + entry.getIntValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -103,71 +103,70 @@ public class StatisticsUtils {
|
|||
case 2:
|
||||
builder.title("stat.itemsButton - stat_type.minecraft.broken");
|
||||
|
||||
for (Map.Entry<Statistic, Integer> entry : session.getStatistics().entrySet()) {
|
||||
for (Object2IntMap.Entry<Statistic> entry : session.getStatistics().object2IntEntrySet()) {
|
||||
if (entry.getKey() instanceof BreakItemStatistic statistic) {
|
||||
String item = mappings.getMapping(statistic.getId()).getJavaIdentifier();
|
||||
content.add(getItemTranslateKey(item, language) + ": " + entry.getValue());
|
||||
content.add(getItemTranslateKey(item, language) + ": " + entry.getIntValue());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
builder.title("stat.itemsButton - stat_type.minecraft.crafted");
|
||||
|
||||
for (Map.Entry<Statistic, Integer> entry : session.getStatistics().entrySet()) {
|
||||
for (Object2IntMap.Entry<Statistic> entry : session.getStatistics().object2IntEntrySet()) {
|
||||
if (entry.getKey() instanceof CraftItemStatistic statistic) {
|
||||
String item = mappings.getMapping(statistic.getId()).getJavaIdentifier();
|
||||
content.add(getItemTranslateKey(item, language) + ": " + entry.getValue());
|
||||
content.add(getItemTranslateKey(item, language) + ": " + entry.getIntValue());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
builder.title("stat.itemsButton - stat_type.minecraft.used");
|
||||
|
||||
for (Map.Entry<Statistic, Integer> entry : session.getStatistics().entrySet()) {
|
||||
for (Object2IntMap.Entry<Statistic> entry : session.getStatistics().object2IntEntrySet()) {
|
||||
if (entry.getKey() instanceof UseItemStatistic statistic) {
|
||||
String item = mappings.getMapping(statistic.getId()).getJavaIdentifier();
|
||||
content.add(getItemTranslateKey(item, language) + ": " + entry.getValue());
|
||||
content.add(getItemTranslateKey(item, language) + ": " + entry.getIntValue());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
builder.title("stat.itemsButton - stat_type.minecraft.picked_up");
|
||||
|
||||
for (Map.Entry<Statistic, Integer> entry : session.getStatistics().entrySet()) {
|
||||
for (Object2IntMap.Entry<Statistic> entry : session.getStatistics().object2IntEntrySet()) {
|
||||
if (entry.getKey() instanceof PickupItemStatistic statistic) {
|
||||
String item = mappings.getMapping(statistic.getId()).getJavaIdentifier();
|
||||
content.add(getItemTranslateKey(item, language) + ": " + entry.getValue());
|
||||
content.add(getItemTranslateKey(item, language) + ": " + entry.getIntValue());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
builder.title("stat.itemsButton - stat_type.minecraft.dropped");
|
||||
|
||||
for (Map.Entry<Statistic, Integer> entry : session.getStatistics().entrySet()) {
|
||||
for (Object2IntMap.Entry<Statistic> entry : session.getStatistics().object2IntEntrySet()) {
|
||||
if (entry.getKey() instanceof DropItemStatistic statistic) {
|
||||
String item = mappings.getMapping(statistic.getId()).getJavaIdentifier();
|
||||
content.add(getItemTranslateKey(item, language) + ": " + entry.getValue());
|
||||
content.add(getItemTranslateKey(item, language) + ": " + entry.getIntValue());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
builder.title("stat.mobsButton - geyser.statistics.killed");
|
||||
|
||||
for (Map.Entry<Statistic, Integer> entry : session.getStatistics().entrySet()) {
|
||||
for (Object2IntMap.Entry<Statistic> entry : session.getStatistics().object2IntEntrySet()) {
|
||||
if (entry.getKey() instanceof KillEntityStatistic statistic) {
|
||||
String entityName = statistic.getEntity().name().toLowerCase(Locale.ROOT);
|
||||
content.add("entity.minecraft." + entityName + ": " + entry.getValue());
|
||||
content.add("entity.minecraft." + entityName + ": " + entry.getIntValue());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
builder.title("stat.mobsButton - geyser.statistics.killed_by");
|
||||
|
||||
for (Map.Entry<Statistic, Integer> entry : session
|
||||
.getStatistics().entrySet()) {
|
||||
for (Object2IntMap.Entry<Statistic> entry : session.getStatistics().object2IntEntrySet()) {
|
||||
if (entry.getKey() instanceof KilledByEntityStatistic statistic) {
|
||||
String entityName = statistic.getEntity().name().toLowerCase(Locale.ROOT);
|
||||
content.add("entity.minecraft." + entityName + ": " + entry.getValue());
|
||||
content.add("entity.minecraft." + entityName + ": " + entry.getIntValue());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue