Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-10-03 08:21:06 +02:00
Implement proper biome palette reading probably
With thanks to @kennytv for the magic required to get global palette bits.
Dieser Commit ist enthalten in:
Ursprung
27ce6c4b36
Commit
66d578eadc
@ -695,6 +695,7 @@ public final class EntityDefinitions {
|
|||||||
.type(EntityType.WITCH)
|
.type(EntityType.WITCH)
|
||||||
.height(1.8f).width(0.6f)
|
.height(1.8f).width(0.6f)
|
||||||
.offset(1.62f)
|
.offset(1.62f)
|
||||||
|
.addTranslator(null) // Using item
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -792,8 +793,12 @@ public final class EntityDefinitions {
|
|||||||
TURTLE = EntityDefinition.inherited(TurtleEntity::new, ageableEntityBase)
|
TURTLE = EntityDefinition.inherited(TurtleEntity::new, ageableEntityBase)
|
||||||
.type(EntityType.TURTLE)
|
.type(EntityType.TURTLE)
|
||||||
.height(0.4f).width(1.2f)
|
.height(0.4f).width(1.2f)
|
||||||
|
.addTranslator(null) // Home position
|
||||||
.addTranslator(MetadataType.BOOLEAN, TurtleEntity::setPregnant)
|
.addTranslator(MetadataType.BOOLEAN, TurtleEntity::setPregnant)
|
||||||
.addTranslator(MetadataType.BOOLEAN, TurtleEntity::setLayingEgg)
|
.addTranslator(MetadataType.BOOLEAN, TurtleEntity::setLayingEgg)
|
||||||
|
.addTranslator(null) // Travel position
|
||||||
|
.addTranslator(null) // Going home
|
||||||
|
.addTranslator(null) // Travelling
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
EntityDefinition<AbstractMerchantEntity> abstractVillagerEntityBase = EntityDefinition.inherited(AbstractMerchantEntity::new, ageableEntityBase)
|
EntityDefinition<AbstractMerchantEntity> abstractVillagerEntityBase = EntityDefinition.inherited(AbstractMerchantEntity::new, ageableEntityBase)
|
||||||
|
@ -204,6 +204,11 @@ public class GeyserSession implements CommandSender {
|
|||||||
private final Map<Vector3i, SkullPlayerEntity> skullCache = new Object2ObjectOpenHashMap<>();
|
private final Map<Vector3i, SkullPlayerEntity> skullCache = new Object2ObjectOpenHashMap<>();
|
||||||
private final Long2ObjectMap<ClientboundMapItemDataPacket> storedMaps = new Long2ObjectOpenHashMap<>();
|
private final Long2ObjectMap<ClientboundMapItemDataPacket> storedMaps = new Long2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Required to decode biomes correctly.
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
private int biomeGlobalPalette;
|
||||||
/**
|
/**
|
||||||
* Stores the map between Java and Bedrock biome network IDs.
|
* Stores the map between Java and Bedrock biome network IDs.
|
||||||
*/
|
*/
|
||||||
|
@ -85,6 +85,7 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
|
|||||||
// Ensure that, if the player is using lower world heights, the position is not offset
|
// Ensure that, if the player is using lower world heights, the position is not offset
|
||||||
int yOffset = session.getChunkCache().getChunkMinY();
|
int yOffset = session.getChunkCache().getChunkMinY();
|
||||||
int chunkSize = session.getChunkCache().getChunkHeightY();
|
int chunkSize = session.getChunkCache().getChunkHeightY();
|
||||||
|
int biomeGlobalPalette = session.getBiomeGlobalPalette();
|
||||||
|
|
||||||
// Temporarily stores compound tags of Bedrock-only block entities
|
// Temporarily stores compound tags of Bedrock-only block entities
|
||||||
List<NbtMap> bedrockOnlyBlockEntities = new ArrayList<>();
|
List<NbtMap> bedrockOnlyBlockEntities = new ArrayList<>();
|
||||||
@ -105,7 +106,7 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
|
|||||||
try {
|
try {
|
||||||
NetInput in = new StreamNetInput(new ByteArrayInputStream(packet.getChunkData()));
|
NetInput in = new StreamNetInput(new ByteArrayInputStream(packet.getChunkData()));
|
||||||
for (int sectionY = 0; sectionY < chunkSize; sectionY++) {
|
for (int sectionY = 0; sectionY < chunkSize; sectionY++) {
|
||||||
ChunkSection javaSection = ChunkSection.read(in);
|
ChunkSection javaSection = ChunkSection.read(in, biomeGlobalPalette);
|
||||||
javaChunks[sectionY] = javaSection.getChunkData();
|
javaChunks[sectionY] = javaSection.getChunkData();
|
||||||
javaBiomes[sectionY] = javaSection.getBiomeData();
|
javaBiomes[sectionY] = javaSection.getBiomeData();
|
||||||
|
|
||||||
@ -266,7 +267,7 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
|
|||||||
bedrockBlockEntities[blockEntityCount] = blockEntityTranslator.getBlockEntityTag(type, x + chunkBlockX, y, z + chunkBlockZ, tag, blockState);
|
bedrockBlockEntities[blockEntityCount] = blockEntityTranslator.getBlockEntityTag(type, x + chunkBlockX, y, z + chunkBlockZ, tag, blockState);
|
||||||
|
|
||||||
// Check for custom skulls
|
// Check for custom skulls
|
||||||
if (session.getPreferencesCache().showCustomSkulls() && tag != null && tag.contains("SkullOwner")) {
|
if (session.getPreferencesCache().showCustomSkulls() && type == BlockEntityType.SKULL && tag != null && tag.contains("SkullOwner")) {
|
||||||
SkullBlockEntityTranslator.spawnPlayer(session, tag, x + chunkBlockX, y, z + chunkBlockZ, blockState);
|
SkullBlockEntityTranslator.spawnPlayer(session, tag, x + chunkBlockX, y, z + chunkBlockZ, blockState);
|
||||||
}
|
}
|
||||||
blockEntityCount++;
|
blockEntityCount++;
|
||||||
|
@ -35,6 +35,7 @@ import org.geysermc.connector.network.translators.world.chunk.BlockStorage;
|
|||||||
import org.geysermc.connector.network.translators.world.chunk.GeyserChunkSection;
|
import org.geysermc.connector.network.translators.world.chunk.GeyserChunkSection;
|
||||||
import org.geysermc.connector.network.translators.world.chunk.bitarray.SingletonBitArray;
|
import org.geysermc.connector.network.translators.world.chunk.bitarray.SingletonBitArray;
|
||||||
import org.geysermc.connector.registry.Registries;
|
import org.geysermc.connector.registry.Registries;
|
||||||
|
import org.geysermc.connector.utils.MathUtils;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@ -49,6 +50,7 @@ public class BiomeTranslator {
|
|||||||
|
|
||||||
CompoundTag worldGen = codec.get("minecraft:worldgen/biome");
|
CompoundTag worldGen = codec.get("minecraft:worldgen/biome");
|
||||||
ListTag serverBiomes = worldGen.get("value");
|
ListTag serverBiomes = worldGen.get("value");
|
||||||
|
session.setBiomeGlobalPalette(MathUtils.getGlobalPaletteForSize(serverBiomes.size()));
|
||||||
|
|
||||||
for (Tag tag : serverBiomes) {
|
for (Tag tag : serverBiomes) {
|
||||||
CompoundTag biomeTag = (CompoundTag) tag;
|
CompoundTag biomeTag = (CompoundTag) tag;
|
||||||
|
@ -29,6 +29,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
import com.github.steveice10.mc.protocol.data.game.level.particle.ParticleType;
|
import com.github.steveice10.mc.protocol.data.game.level.particle.ParticleType;
|
||||||
import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.registry.type.ParticleMapping;
|
import org.geysermc.connector.registry.type.ParticleMapping;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -49,9 +50,14 @@ public class ParticleTypesRegistryLoader extends EffectRegistryLoader<Map<Partic
|
|||||||
try {
|
try {
|
||||||
while (particlesIterator.hasNext()) {
|
while (particlesIterator.hasNext()) {
|
||||||
Map.Entry<String, JsonNode> entry = particlesIterator.next();
|
Map.Entry<String, JsonNode> entry = particlesIterator.next();
|
||||||
|
String key = entry.getKey().toUpperCase(Locale.ROOT);
|
||||||
JsonNode bedrockId = entry.getValue().get("bedrockId");
|
JsonNode bedrockId = entry.getValue().get("bedrockId");
|
||||||
JsonNode eventType = entry.getValue().get("eventType");
|
JsonNode eventType = entry.getValue().get("eventType");
|
||||||
particles.put(ParticleType.valueOf(entry.getKey().toUpperCase(Locale.ROOT)), new ParticleMapping(
|
if (eventType == null && bedrockId == null) {
|
||||||
|
GeyserConnector.getInstance().getLogger().debug("Skipping particle mapping " + key + " because no Bedrock equivalent exists.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
particles.put(ParticleType.valueOf(key), new ParticleMapping(
|
||||||
eventType == null ? null : LevelEventType.valueOf(eventType.asText().toUpperCase(Locale.ROOT)),
|
eventType == null ? null : LevelEventType.valueOf(eventType.asText().toUpperCase(Locale.ROOT)),
|
||||||
bedrockId == null ? null : bedrockId.asText())
|
bedrockId == null ? null : bedrockId.asText())
|
||||||
);
|
);
|
||||||
|
@ -105,4 +105,11 @@ public class MathUtils {
|
|||||||
public static long chunkPositionToLong(int x, int z) {
|
public static long chunkPositionToLong(int x, int z) {
|
||||||
return ((x & 0xFFFFFFFFL) << 32L) | (z & 0xFFFFFFFFL);
|
return ((x & 0xFFFFFFFFL) << 32L) | (z & 0xFFFFFFFFL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the bits per entry used when this number is the maximum amount of entries.
|
||||||
|
*/
|
||||||
|
public static int getGlobalPaletteForSize(int size) {
|
||||||
|
return 32 - Integer.numberOfLeadingZeros(size - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren