3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-25 15:50:14 +01:00
Dieser Commit ist enthalten in:
AJ Ferguson 2024-05-02 03:47:30 -04:00
Ursprung fdae333351
Commit d003818e73
5 geänderte Dateien mit 27 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -202,7 +202,6 @@ public final class EntityDefinitions {
.type(EntityType.AREA_EFFECT_CLOUD)
.height(0.5f).width(1.0f)
.addTranslator(MetadataType.FLOAT, AreaEffectCloudEntity::setRadius)
.addTranslator(MetadataType.INT, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityDataTypes.EFFECT_COLOR, entityMetadata.getValue()))
.addTranslator(null) // Waiting
.addTranslator(MetadataType.PARTICLE, AreaEffectCloudEntity::setParticle)
.build();

Datei anzeigen

@ -34,6 +34,7 @@ import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.FloatEntityMetadata;
import org.geysermc.mcprotocollib.protocol.data.game.level.particle.EntityEffectParticleData;
import org.geysermc.mcprotocollib.protocol.data.game.level.particle.Particle;
import java.util.UUID;
@ -51,7 +52,7 @@ public class AreaEffectCloudEntity extends Entity {
dirtyMetadata.put(EntityDataTypes.AREA_EFFECT_CLOUD_DURATION, Integer.MAX_VALUE);
// This disabled client side shrink of the cloud
dirtyMetadata.put(EntityDataTypes.AREA_EFFECT_CLOUD_RADIUS, 0.0f);
dirtyMetadata.put(EntityDataTypes.AREA_EFFECT_CLOUD_RADIUS, 0.5f);
dirtyMetadata.put(EntityDataTypes.AREA_EFFECT_CLOUD_CHANGE_RATE, Float.MIN_VALUE);
dirtyMetadata.put(EntityDataTypes.AREA_EFFECT_CLOUD_CHANGE_ON_PICKUP, Float.MIN_VALUE);
@ -69,5 +70,9 @@ public class AreaEffectCloudEntity extends Entity {
Particle particle = entityMetadata.getValue();
Registries.PARTICLES.map(particle.getType(), p -> p.levelEventType() instanceof ParticleType particleType ? particleType : null).ifPresent(type ->
dirtyMetadata.put(EntityDataTypes.AREA_EFFECT_CLOUD_PARTICLE, type));
if (particle.getData() instanceof EntityEffectParticleData effectParticleData) {
dirtyMetadata.put(EntityDataTypes.EFFECT_COLOR, effectParticleData.getColor());
}
}
}

Datei anzeigen

@ -54,7 +54,7 @@ public class ThrownPotionEntity extends ThrowableItemEntity {
public void setItem(EntityMetadata<ItemStack, ?> entityMetadata) {
ItemStack itemStack = entityMetadata.getValue();
if (itemStack == null) {
dirtyMetadata.put(EntityDataTypes.EFFECT_COLOR, 0);
dirtyMetadata.put(EntityDataTypes.AUX_VALUE_DATA, (short) 0);
setFlag(EntityFlag.ENCHANTED, false);
setFlag(EntityFlag.LINGERING, false);
} else {
@ -63,12 +63,12 @@ public class ThrownPotionEntity extends ThrowableItemEntity {
if (components != null) {
PotionContents potionContents = components.get(DataComponentType.POTION_CONTENTS);
if (potionContents != null) {
Potion potion = Potion.VALUES[potionContents.getPotionId()];
Potion potion = Potion.getByJavaId(potionContents.getPotionId());
if (potion != null) {
dirtyMetadata.put(EntityDataTypes.EFFECT_COLOR, (int) potion.getBedrockId());
dirtyMetadata.put(EntityDataTypes.AUX_VALUE_DATA, potion.getBedrockId());
setFlag(EntityFlag.ENCHANTED, !NON_ENCHANTED_POTIONS.contains(potion));
} else {
dirtyMetadata.put(EntityDataTypes.EFFECT_COLOR, 0);
dirtyMetadata.put(EntityDataTypes.AUX_VALUE_DATA, (short) 0);
GeyserImpl.getInstance().getLogger().debug("Unknown java potion: " + potionContents.getPotionId());
}
}

Datei anzeigen

@ -43,16 +43,19 @@ public enum Potion {
INVISIBILITY(7),
LONG_INVISIBILITY(8),
LEAPING(9),
STRONG_LEAPING(11),
LONG_LEAPING(10),
STRONG_LEAPING(11),
FIRE_RESISTANCE(12),
LONG_FIRE_RESISTANCE(13),
SWIFTNESS(14),
STRONG_SWIFTNESS(16),
LONG_SWIFTNESS(15),
STRONG_SWIFTNESS(16),
SLOWNESS(17),
STRONG_SLOWNESS(42),
LONG_SLOWNESS(18),
STRONG_SLOWNESS(42),
TURTLE_MASTER(37),
LONG_TURTLE_MASTER(38),
STRONG_TURTLE_MASTER(39),
WATER_BREATHING(19),
LONG_WATER_BREATHING(20),
HEALING(21),
@ -60,20 +63,17 @@ public enum Potion {
HARMING(23),
STRONG_HARMING(24),
POISON(25),
STRONG_POISON(27),
LONG_POISON(26),
STRONG_POISON(27),
REGENERATION(28),
STRONG_REGENERATION(30),
LONG_REGENERATION(29),
STRONG_REGENERATION(30),
STRENGTH(31),
STRONG_STRENGTH(33),
LONG_STRENGTH(32),
STRONG_STRENGTH(33),
WEAKNESS(34),
LONG_WEAKNESS(35),
LUCK(2), //does not exist
TURTLE_MASTER(37),
STRONG_TURTLE_MASTER(39),
LONG_TURTLE_MASTER(38),
SLOW_FALLING(40),
LONG_SLOW_FALLING(41);
@ -91,6 +91,13 @@ public enum Potion {
return new PotionContents(this.ordinal(), -1, Int2ObjectMaps.emptyMap());
}
public static @Nullable Potion getByJavaId(int javaId) {
if (javaId >= 0 && javaId < VALUES.length) {
return VALUES[javaId];
}
return null;
}
public static @Nullable Potion getByBedrockId(int bedrockId) {
for (Potion potion : VALUES) {
if (potion.bedrockId == bedrockId) {

Datei anzeigen

@ -50,7 +50,7 @@ public class PotionItem extends Item {
if (potionContents != null) {
ItemDefinition customItemDefinition = CustomItemTranslator.getCustomItem(components, mapping);
if (customItemDefinition == null) {
Potion potion = Potion.VALUES[potionContents.getPotionId()];
Potion potion = Potion.getByJavaId(potionContents.getPotionId());
if (potion != null) {
return ItemData.builder()
.definition(mapping.getBedrockDefinition())