diff --git a/connector/pom.xml b/connector/pom.xml index ef14a4704..4aa6269b9 100644 --- a/connector/pom.xml +++ b/connector/pom.xml @@ -32,7 +32,7 @@ com.github.CloudburstMC.Protocol bedrock-v431 - 9947665 + 530a0e3 compile diff --git a/connector/src/main/java/org/geysermc/connector/entity/AreaEffectCloudEntity.java b/connector/src/main/java/org/geysermc/connector/entity/AreaEffectCloudEntity.java index cfd29fd8b..5a33bc98c 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/AreaEffectCloudEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/AreaEffectCloudEntity.java @@ -59,7 +59,7 @@ public class AreaEffectCloudEntity extends Entity { metadata.put(EntityData.EFFECT_COLOR, entityMetadata.getValue()); } else if (entityMetadata.getId() == 11) { Particle particle = (Particle) entityMetadata.getValue(); - int particleId = EffectRegistry.getParticleId(particle.getType()); + int particleId = EffectRegistry.getParticleId(session, particle.getType()); if (particleId != -1) { metadata.put(EntityData.AREA_EFFECT_CLOUD_PARTICLE_ID, particleId); } diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/tameable/CatEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/tameable/CatEntity.java index a8336636b..7aa702074 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/living/animal/tameable/CatEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/tameable/CatEntity.java @@ -49,7 +49,9 @@ public class CatEntity extends TameableEntity { @Override public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { super.updateBedrockMetadata(entityMetadata, session); - if (entityMetadata.getId() == 17) { + if (entityMetadata.getId() == 16) { + metadata.put(EntityData.SCALE, (boolean) entityMetadata.getValue() ? 0.8f : 0.4f); + } else if (entityMetadata.getId() == 17) { // Update collar color if tamed if (metadata.getFlags().getFlag(EntityFlag.TAMED)) { metadata.put(EntityData.COLOR, collarColor); @@ -76,6 +78,9 @@ public class CatEntity extends TameableEntity { } metadata.put(EntityData.VARIANT, variantColor); } + if (entityMetadata.getId() == 20) { + metadata.getFlags().setFlag(EntityFlag.RESTING, (boolean) entityMetadata.getValue()); + } if (entityMetadata.getId() == 22) { collarColor = (byte) (int) entityMetadata.getValue(); // Needed or else wild cats are a red color diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/merchant/VillagerEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/merchant/VillagerEntity.java index f8707398e..6ab0107cc 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/living/merchant/VillagerEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/living/merchant/VillagerEntity.java @@ -46,7 +46,7 @@ public class VillagerEntity extends AbstractMerchantEntity { /** * A map of Java profession IDs to Bedrock IDs */ - private static final Int2IntMap VILLAGER_VARIANTS = new Int2IntOpenHashMap(); + public static final Int2IntMap VILLAGER_PROFESSIONS = new Int2IntOpenHashMap(); /** * A map of all Java region IDs (plains, savanna...) to Bedrock */ @@ -54,21 +54,21 @@ public class VillagerEntity extends AbstractMerchantEntity { static { // Java villager profession IDs -> Bedrock - VILLAGER_VARIANTS.put(0, 0); - VILLAGER_VARIANTS.put(1, 8); - VILLAGER_VARIANTS.put(2, 11); - VILLAGER_VARIANTS.put(3, 6); - VILLAGER_VARIANTS.put(4, 7); - VILLAGER_VARIANTS.put(5, 1); - VILLAGER_VARIANTS.put(6, 2); - VILLAGER_VARIANTS.put(7, 4); - VILLAGER_VARIANTS.put(8, 12); - VILLAGER_VARIANTS.put(9, 5); - VILLAGER_VARIANTS.put(10, 13); - VILLAGER_VARIANTS.put(11, 14); - VILLAGER_VARIANTS.put(12, 3); - VILLAGER_VARIANTS.put(13, 10); - VILLAGER_VARIANTS.put(14, 9); + VILLAGER_PROFESSIONS.put(0, 0); + VILLAGER_PROFESSIONS.put(1, 8); + VILLAGER_PROFESSIONS.put(2, 11); + VILLAGER_PROFESSIONS.put(3, 6); + VILLAGER_PROFESSIONS.put(4, 7); + VILLAGER_PROFESSIONS.put(5, 1); + VILLAGER_PROFESSIONS.put(6, 2); + VILLAGER_PROFESSIONS.put(7, 4); + VILLAGER_PROFESSIONS.put(8, 12); + VILLAGER_PROFESSIONS.put(9, 5); + VILLAGER_PROFESSIONS.put(10, 13); + VILLAGER_PROFESSIONS.put(11, 14); + VILLAGER_PROFESSIONS.put(12, 3); + VILLAGER_PROFESSIONS.put(13, 10); + VILLAGER_PROFESSIONS.put(14, 9); VILLAGER_REGIONS.put(0, 1); VILLAGER_REGIONS.put(1, 2); @@ -88,7 +88,7 @@ public class VillagerEntity extends AbstractMerchantEntity { if (entityMetadata.getId() == 18) { VillagerData villagerData = (VillagerData) entityMetadata.getValue(); // Profession - metadata.put(EntityData.VARIANT, VILLAGER_VARIANTS.get(villagerData.getProfession())); + metadata.put(EntityData.VARIANT, VILLAGER_PROFESSIONS.get(villagerData.getProfession())); //metadata.put(EntityData.SKIN_ID, villagerData.getType()); Looks like this is modified but for any reason? // Region metadata.put(EntityData.MARK_VARIANT, VILLAGER_REGIONS.get(villagerData.getType())); diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/monster/ZombieVillagerEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/monster/ZombieVillagerEntity.java index d63d2654c..eb4881b15 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/living/monster/ZombieVillagerEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/living/monster/ZombieVillagerEntity.java @@ -48,8 +48,10 @@ public class ZombieVillagerEntity extends ZombieEntity { } if (entityMetadata.getId() == 20) { VillagerData villagerData = (VillagerData) entityMetadata.getValue(); - // Region - only one used on Bedrock + metadata.put(EntityData.VARIANT, VillagerEntity.VILLAGER_PROFESSIONS.get(villagerData.getProfession())); // Actually works properly with the OptionalPack metadata.put(EntityData.MARK_VARIANT, VillagerEntity.VILLAGER_REGIONS.get(villagerData.getType())); + // Used with the OptionalPack + metadata.put(EntityData.TRADE_TIER, villagerData.getLevel() - 1); } super.updateBedrockMetadata(entityMetadata, session); } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/effect/EffectRegistry.java b/connector/src/main/java/org/geysermc/connector/network/translators/effect/EffectRegistry.java index c71aa4f1d..f767b5827 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/effect/EffectRegistry.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/effect/EffectRegistry.java @@ -32,10 +32,9 @@ import com.nukkitx.protocol.bedrock.data.LevelEventType; import com.nukkitx.protocol.bedrock.data.SoundEvent; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import it.unimi.dsi.fastutil.objects.Object2IntMap; -import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import lombok.NonNull; import org.geysermc.connector.GeyserConnector; +import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.utils.FileUtils; import java.io.InputStream; @@ -51,11 +50,6 @@ public class EffectRegistry { public static final Map SOUND_EFFECTS = new HashMap<>(); public static final Int2ObjectMap RECORDS = new Int2ObjectOpenHashMap<>(); - /** - * Java particle type to Bedrock particle ID - * Used for area effect clouds. - */ - private static final Object2IntMap PARTICLE_TO_ID = new Object2IntOpenHashMap<>(); /** * Java particle type to Bedrock level event */ @@ -84,11 +78,7 @@ public class EffectRegistry { while (particlesIterator.hasNext()) { Map.Entry entry = particlesIterator.next(); JsonNode bedrockId = entry.getValue().get("bedrockId"); - JsonNode bedrockIdNumeric = entry.getValue().get("bedrockNumericId"); JsonNode eventType = entry.getValue().get("eventType"); - if (bedrockIdNumeric != null) { - PARTICLE_TO_ID.put(ParticleType.valueOf(entry.getKey().toUpperCase()), bedrockIdNumeric.asInt()); - } if (bedrockId != null) { PARTICLE_TO_STRING.put(ParticleType.valueOf(entry.getKey().toUpperCase()), bedrockId.asText()); } @@ -164,11 +154,19 @@ public class EffectRegistry { } /** + * Used for area effect clouds. + * * @param type the Java particle to search for * @return the Bedrock integer ID of the particle, or -1 if it does not exist */ - public static int getParticleId(@NonNull ParticleType type) { - return PARTICLE_TO_ID.getOrDefault(type, -1); + public static int getParticleId(GeyserSession session, @NonNull ParticleType type) { + LevelEventType levelEventType = getParticleLevelEventType(type); + if (levelEventType == null) { + return -1; + } + + // Remove the legacy bit applied to particles for LevelEventType serialization + return session.getUpstream().getSession().getPacketCodec().getHelper().getLevelEventId(levelEventType) & ~0x4000; } /** diff --git a/connector/src/main/resources/mappings b/connector/src/main/resources/mappings index 53e13b7a0..c5925b01c 160000 --- a/connector/src/main/resources/mappings +++ b/connector/src/main/resources/mappings @@ -1 +1 @@ -Subproject commit 53e13b7a0d2ea14df71ed0c9582d29a9b4fb4453 +Subproject commit c5925b01cf8e7d8b284cf359e927145b9b4694aa