3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-03 14:50:19 +01:00

Merge branch 'master' of https://github.com/GeyserMC/Geyser into feature/1.17

Dieser Commit ist enthalten in:
Camotoy 2021-05-29 15:49:31 -04:00
Commit 7b0099e869
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
7 geänderte Dateien mit 40 neuen und 35 gelöschten Zeilen

Datei anzeigen

@ -32,7 +32,7 @@
<dependency> <dependency>
<groupId>com.github.CloudburstMC.Protocol</groupId> <groupId>com.github.CloudburstMC.Protocol</groupId>
<artifactId>bedrock-v431</artifactId> <artifactId>bedrock-v431</artifactId>
<version>9947665</version> <version>530a0e3</version>
<scope>compile</scope> <scope>compile</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>

Datei anzeigen

@ -59,7 +59,7 @@ public class AreaEffectCloudEntity extends Entity {
metadata.put(EntityData.EFFECT_COLOR, entityMetadata.getValue()); metadata.put(EntityData.EFFECT_COLOR, entityMetadata.getValue());
} else if (entityMetadata.getId() == 11) { } else if (entityMetadata.getId() == 11) {
Particle particle = (Particle) entityMetadata.getValue(); Particle particle = (Particle) entityMetadata.getValue();
int particleId = EffectRegistry.getParticleId(particle.getType()); int particleId = EffectRegistry.getParticleId(session, particle.getType());
if (particleId != -1) { if (particleId != -1) {
metadata.put(EntityData.AREA_EFFECT_CLOUD_PARTICLE_ID, particleId); metadata.put(EntityData.AREA_EFFECT_CLOUD_PARTICLE_ID, particleId);
} }

Datei anzeigen

@ -49,7 +49,9 @@ public class CatEntity extends TameableEntity {
@Override @Override
public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
super.updateBedrockMetadata(entityMetadata, 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 // Update collar color if tamed
if (metadata.getFlags().getFlag(EntityFlag.TAMED)) { if (metadata.getFlags().getFlag(EntityFlag.TAMED)) {
metadata.put(EntityData.COLOR, collarColor); metadata.put(EntityData.COLOR, collarColor);
@ -76,6 +78,9 @@ public class CatEntity extends TameableEntity {
} }
metadata.put(EntityData.VARIANT, variantColor); metadata.put(EntityData.VARIANT, variantColor);
} }
if (entityMetadata.getId() == 20) {
metadata.getFlags().setFlag(EntityFlag.RESTING, (boolean) entityMetadata.getValue());
}
if (entityMetadata.getId() == 22) { if (entityMetadata.getId() == 22) {
collarColor = (byte) (int) entityMetadata.getValue(); collarColor = (byte) (int) entityMetadata.getValue();
// Needed or else wild cats are a red color // Needed or else wild cats are a red color

Datei anzeigen

@ -46,7 +46,7 @@ public class VillagerEntity extends AbstractMerchantEntity {
/** /**
* A map of Java profession IDs to Bedrock IDs * 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 * A map of all Java region IDs (plains, savanna...) to Bedrock
*/ */
@ -54,21 +54,21 @@ public class VillagerEntity extends AbstractMerchantEntity {
static { static {
// Java villager profession IDs -> Bedrock // Java villager profession IDs -> Bedrock
VILLAGER_VARIANTS.put(0, 0); VILLAGER_PROFESSIONS.put(0, 0);
VILLAGER_VARIANTS.put(1, 8); VILLAGER_PROFESSIONS.put(1, 8);
VILLAGER_VARIANTS.put(2, 11); VILLAGER_PROFESSIONS.put(2, 11);
VILLAGER_VARIANTS.put(3, 6); VILLAGER_PROFESSIONS.put(3, 6);
VILLAGER_VARIANTS.put(4, 7); VILLAGER_PROFESSIONS.put(4, 7);
VILLAGER_VARIANTS.put(5, 1); VILLAGER_PROFESSIONS.put(5, 1);
VILLAGER_VARIANTS.put(6, 2); VILLAGER_PROFESSIONS.put(6, 2);
VILLAGER_VARIANTS.put(7, 4); VILLAGER_PROFESSIONS.put(7, 4);
VILLAGER_VARIANTS.put(8, 12); VILLAGER_PROFESSIONS.put(8, 12);
VILLAGER_VARIANTS.put(9, 5); VILLAGER_PROFESSIONS.put(9, 5);
VILLAGER_VARIANTS.put(10, 13); VILLAGER_PROFESSIONS.put(10, 13);
VILLAGER_VARIANTS.put(11, 14); VILLAGER_PROFESSIONS.put(11, 14);
VILLAGER_VARIANTS.put(12, 3); VILLAGER_PROFESSIONS.put(12, 3);
VILLAGER_VARIANTS.put(13, 10); VILLAGER_PROFESSIONS.put(13, 10);
VILLAGER_VARIANTS.put(14, 9); VILLAGER_PROFESSIONS.put(14, 9);
VILLAGER_REGIONS.put(0, 1); VILLAGER_REGIONS.put(0, 1);
VILLAGER_REGIONS.put(1, 2); VILLAGER_REGIONS.put(1, 2);
@ -88,7 +88,7 @@ public class VillagerEntity extends AbstractMerchantEntity {
if (entityMetadata.getId() == 18) { if (entityMetadata.getId() == 18) {
VillagerData villagerData = (VillagerData) entityMetadata.getValue(); VillagerData villagerData = (VillagerData) entityMetadata.getValue();
// Profession // 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? //metadata.put(EntityData.SKIN_ID, villagerData.getType()); Looks like this is modified but for any reason?
// Region // Region
metadata.put(EntityData.MARK_VARIANT, VILLAGER_REGIONS.get(villagerData.getType())); metadata.put(EntityData.MARK_VARIANT, VILLAGER_REGIONS.get(villagerData.getType()));

Datei anzeigen

@ -48,8 +48,10 @@ public class ZombieVillagerEntity extends ZombieEntity {
} }
if (entityMetadata.getId() == 20) { if (entityMetadata.getId() == 20) {
VillagerData villagerData = (VillagerData) entityMetadata.getValue(); 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())); 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); super.updateBedrockMetadata(entityMetadata, session);
} }

Datei anzeigen

@ -32,10 +32,9 @@ import com.nukkitx.protocol.bedrock.data.LevelEventType;
import com.nukkitx.protocol.bedrock.data.SoundEvent; import com.nukkitx.protocol.bedrock.data.SoundEvent;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; 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 lombok.NonNull;
import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.utils.FileUtils; import org.geysermc.connector.utils.FileUtils;
import java.io.InputStream; import java.io.InputStream;
@ -51,11 +50,6 @@ public class EffectRegistry {
public static final Map<SoundEffect, Effect> SOUND_EFFECTS = new HashMap<>(); public static final Map<SoundEffect, Effect> SOUND_EFFECTS = new HashMap<>();
public static final Int2ObjectMap<SoundEvent> RECORDS = new Int2ObjectOpenHashMap<>(); public static final Int2ObjectMap<SoundEvent> RECORDS = new Int2ObjectOpenHashMap<>();
/**
* Java particle type to Bedrock particle ID
* Used for area effect clouds.
*/
private static final Object2IntMap<ParticleType> PARTICLE_TO_ID = new Object2IntOpenHashMap<>();
/** /**
* Java particle type to Bedrock level event * Java particle type to Bedrock level event
*/ */
@ -84,11 +78,7 @@ public class EffectRegistry {
while (particlesIterator.hasNext()) { while (particlesIterator.hasNext()) {
Map.Entry<String, JsonNode> entry = particlesIterator.next(); Map.Entry<String, JsonNode> entry = particlesIterator.next();
JsonNode bedrockId = entry.getValue().get("bedrockId"); JsonNode bedrockId = entry.getValue().get("bedrockId");
JsonNode bedrockIdNumeric = entry.getValue().get("bedrockNumericId");
JsonNode eventType = entry.getValue().get("eventType"); JsonNode eventType = entry.getValue().get("eventType");
if (bedrockIdNumeric != null) {
PARTICLE_TO_ID.put(ParticleType.valueOf(entry.getKey().toUpperCase()), bedrockIdNumeric.asInt());
}
if (bedrockId != null) { if (bedrockId != null) {
PARTICLE_TO_STRING.put(ParticleType.valueOf(entry.getKey().toUpperCase()), bedrockId.asText()); 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 * @param type the Java particle to search for
* @return the Bedrock integer ID of the particle, or -1 if it does not exist * @return the Bedrock integer ID of the particle, or -1 if it does not exist
*/ */
public static int getParticleId(@NonNull ParticleType type) { public static int getParticleId(GeyserSession session, @NonNull ParticleType type) {
return PARTICLE_TO_ID.getOrDefault(type, -1); 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;
} }
/** /**

@ -1 +1 @@
Subproject commit 53e13b7a0d2ea14df71ed0c9582d29a9b4fb4453 Subproject commit c5925b01cf8e7d8b284cf359e927145b9b4694aa