Skip to content

Commit 3dcb365

Browse files
authored
Merge branch 'feature/1.20.5' into feature/1.20.5
2 parents 2ddb7f5 + 6ecff0d commit 3dcb365

File tree

58 files changed

+669
-702
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+669
-702
lines changed

core/src/main/java/org/geysermc/geyser/entity/type/FireworkEntity.java

Lines changed: 10 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,16 @@
2727

2828
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
2929
import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
30-
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
31-
import com.github.steveice10.opennbt.tag.builtin.ListTag;
32-
import com.github.steveice10.opennbt.tag.builtin.Tag;
30+
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponents;
3331
import org.cloudburstmc.math.vector.Vector3f;
34-
import org.cloudburstmc.nbt.NbtMap;
35-
import org.cloudburstmc.nbt.NbtMapBuilder;
36-
import org.cloudburstmc.nbt.NbtType;
3732
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
3833
import org.cloudburstmc.protocol.bedrock.packet.SetEntityMotionPacket;
39-
import org.geysermc.floodgate.util.DeviceOs;
4034
import org.geysermc.geyser.entity.EntityDefinition;
4135
import org.geysermc.geyser.entity.type.player.PlayerEntity;
42-
import org.geysermc.geyser.level.FireworkColor;
36+
import org.geysermc.geyser.item.Items;
4337
import org.geysermc.geyser.session.GeyserSession;
44-
import org.geysermc.geyser.util.MathUtils;
38+
import org.geysermc.geyser.translator.item.BedrockItemBuilder;
4539

46-
import java.util.ArrayList;
47-
import java.util.List;
4840
import java.util.OptionalInt;
4941
import java.util.UUID;
5042

@@ -59,80 +51,16 @@ public void setFireworkItem(EntityMetadata<ItemStack, ?> entityMetadata) {
5951
if (item == null) {
6052
return;
6153
}
62-
CompoundTag tag = item.getNbt();
63-
64-
if (tag == null) {
65-
return;
66-
}
67-
68-
// TODO: Remove once Mojang fixes bugs with fireworks crashing clients on these specific devices.
69-
// https://bugs.mojang.com/browse/MCPE-89115
70-
if (session.getClientData().getDeviceOs() == DeviceOs.XBOX
71-
|| session.getClientData().getDeviceOs() == DeviceOs.PS4) {
54+
DataComponents components = item.getDataComponents();
55+
if (components == null) {
7256
return;
7357
}
7458

75-
CompoundTag fireworks = tag.get("Fireworks");
76-
if (fireworks == null) {
77-
// Thank you Mineplex very cool
78-
return;
79-
}
80-
81-
NbtMapBuilder fireworksBuilder = NbtMap.builder();
82-
if (fireworks.get("Flight") != null) {
83-
fireworksBuilder.putByte("Flight", MathUtils.getNbtByte(fireworks.get("Flight").getValue()));
84-
}
85-
86-
List<NbtMap> explosions = new ArrayList<>();
87-
if (fireworks.get("Explosions") != null) {
88-
for (Tag effect : ((ListTag) fireworks.get("Explosions")).getValue()) {
89-
CompoundTag effectData = (CompoundTag) effect;
90-
NbtMapBuilder effectBuilder = NbtMap.builder();
91-
92-
if (effectData.get("Type") != null) {
93-
effectBuilder.putByte("FireworkType", MathUtils.getNbtByte(effectData.get("Type").getValue()));
94-
}
95-
96-
if (effectData.get("Colors") != null) {
97-
int[] oldColors = (int[]) effectData.get("Colors").getValue();
98-
byte[] colors = new byte[oldColors.length];
99-
100-
int i = 0;
101-
for (int color : oldColors) {
102-
colors[i++] = FireworkColor.fromJavaRGB(color);
103-
}
104-
105-
effectBuilder.putByteArray("FireworkColor", colors);
106-
}
107-
108-
if (effectData.get("FadeColors") != null) {
109-
int[] oldColors = (int[]) effectData.get("FadeColors").getValue();
110-
byte[] colors = new byte[oldColors.length];
111-
112-
int i = 0;
113-
for (int color : oldColors) {
114-
colors[i++] = FireworkColor.fromJavaRGB(color);
115-
}
116-
117-
effectBuilder.putByteArray("FireworkFade", colors);
118-
}
119-
120-
if (effectData.get("Trail") != null) {
121-
effectBuilder.putByte("FireworkTrail", MathUtils.getNbtByte(effectData.get("Trail").getValue()));
122-
}
123-
124-
if (effectData.get("Flicker") != null) {
125-
effectBuilder.putByte("FireworkFlicker", MathUtils.getNbtByte(effectData.get("Flicker").getValue()));
126-
}
127-
128-
explosions.add(effectBuilder.build());
129-
}
130-
}
131-
132-
fireworksBuilder.putList("Explosions", NbtType.COMPOUND, explosions);
133-
134-
NbtMapBuilder builder = NbtMap.builder();
135-
builder.put("Fireworks", fireworksBuilder.build());
59+
// TODO this looked the same, so I'm going to assume it is and (keep below comment if true)
60+
// Translate using item methods to get firework NBT for Bedrock
61+
BedrockItemBuilder builder = new BedrockItemBuilder();
62+
Items.FIREWORK_ROCKET.translateComponentsToBedrock(session, components, builder);
63+
13664
dirtyMetadata.put(EntityDataTypes.DISPLAY_FIREWORK, builder.build());
13765
}
13866

core/src/main/java/org/geysermc/geyser/entity/type/LivingEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ protected void updateAttribute(Attribute javaAttribute, List<AttributeData> newA
299299
case GENERIC_MOVEMENT_SPEED -> newAttributes.add(calculateAttribute(javaAttribute, GeyserAttributeType.MOVEMENT_SPEED));
300300
case GENERIC_FOLLOW_RANGE -> newAttributes.add(calculateAttribute(javaAttribute, GeyserAttributeType.FOLLOW_RANGE));
301301
case GENERIC_KNOCKBACK_RESISTANCE -> newAttributes.add(calculateAttribute(javaAttribute, GeyserAttributeType.KNOCKBACK_RESISTANCE));
302-
case HORSE_JUMP_STRENGTH -> newAttributes.add(calculateAttribute(javaAttribute, GeyserAttributeType.HORSE_JUMP_STRENGTH));
302+
case GENERIC_JUMP_STRENGTH -> newAttributes.add(calculateAttribute(javaAttribute, GeyserAttributeType.HORSE_JUMP_STRENGTH));
303303
}
304304
}
305305
}

core/src/main/java/org/geysermc/geyser/entity/type/ThrownPotionEntity.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727

2828
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
2929
import com.github.steveice10.mc.protocol.data.game.item.ItemStack;
30-
import com.github.steveice10.opennbt.tag.builtin.StringTag;
31-
import com.github.steveice10.opennbt.tag.builtin.Tag;
30+
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponentType;
31+
import com.github.steveice10.mc.protocol.data.game.item.component.DataComponents;
32+
import com.github.steveice10.mc.protocol.data.game.item.component.PotionContents;
3233
import org.cloudburstmc.math.vector.Vector3f;
3334
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
3435
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
@@ -58,16 +59,17 @@ public void setItem(EntityMetadata<ItemStack, ?> entityMetadata) {
5859
setFlag(EntityFlag.LINGERING, false);
5960
} else {
6061
// As of Java 1.19.3, the server/client doesn't seem to care of the item is actually a potion?
61-
if (itemStack.getNbt() != null) {
62-
Tag potionTag = itemStack.getNbt().get("Potion");
63-
if (potionTag instanceof StringTag) {
64-
Potion potion = Potion.getByJavaIdentifier(((StringTag) potionTag).getValue());
62+
DataComponents components = itemStack.getDataComponents();
63+
if (components != null) {
64+
PotionContents potionContents = components.get(DataComponentType.POTION_CONTENTS);
65+
if (potionContents != null) {
66+
Potion potion = Potion.VALUES[potionContents.getPotionId()];
6567
if (potion != null) {
6668
dirtyMetadata.put(EntityDataTypes.EFFECT_COLOR, (int) potion.getBedrockId());
6769
setFlag(EntityFlag.ENCHANTED, !NON_ENCHANTED_POTIONS.contains(potion));
6870
} else {
6971
dirtyMetadata.put(EntityDataTypes.EFFECT_COLOR, 0);
70-
GeyserImpl.getInstance().getLogger().debug("Unknown java potion: " + potionTag.getValue());
72+
GeyserImpl.getInstance().getLogger().debug("Unknown java potion: " + potionContents.getPotionId());
7173
}
7274
}
7375

core/src/main/java/org/geysermc/geyser/entity/type/living/animal/AxolotlEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void setPlayingDead(BooleanEntityMetadata entityMetadata) {
6161

6262
@Override
6363
public boolean canEat(Item item) {
64-
return session.getTagCache().isAxolotlTemptItem(item);
64+
return session.getTagCache().isAxolotlFood(item);
6565
}
6666

6767
@Override

core/src/main/java/org/geysermc/geyser/inventory/item/Enchantment.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public enum JavaEnchantment {
118118
KNOCKBACK,
119119
FIRE_ASPECT,
120120
LOOTING,
121-
SWEEPING,
121+
SWEEPING_EDGE,
122122
EFFICIENCY,
123123
SILK_TOUCH,
124124
UNBREAKING,
@@ -136,6 +136,9 @@ public enum JavaEnchantment {
136136
MULTISHOT,
137137
QUICK_CHARGE,
138138
PIERCING,
139+
DENSITY,
140+
BREACH,
141+
WIND_BURST,
139142
MENDING,
140143
VANISHING_CURSE;
141144

core/src/main/java/org/geysermc/geyser/inventory/item/TippedArrowPotion.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
*/
3737
@Getter
3838
public enum TippedArrowPotion {
39+
WATER(-1, ArrowParticleColors.NONE), // Guessing this based off of the Potion enum. TODO merge?
3940
MUNDANE(2, ArrowParticleColors.NONE), // 3 is extended?
4041
THICK(4, ArrowParticleColors.NONE),
4142
AWKWARD(5, ArrowParticleColors.NONE),
@@ -94,6 +95,10 @@ public enum TippedArrowPotion {
9495
this.javaColor = arrowParticleColor.getColor();
9596
}
9697

98+
public static TippedArrowPotion of(int id) {
99+
return VALUES[id];
100+
}
101+
97102
public static @Nullable TippedArrowPotion getByJavaIdentifier(String javaIdentifier) {
98103
for (TippedArrowPotion potion : VALUES) {
99104
if (potion.javaIdentifier.equals(javaIdentifier)) {

core/src/main/java/org/geysermc/geyser/inventory/updater/AnvilInventoryUpdater.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ private int calcMergeEnchantmentCost(GeyserSession session, GeyserItemStack inpu
350350
if (enchantment == JavaEnchantment.IMPALING) {
351351
// Multiplier is halved on Bedrock for some reason
352352
rarityMultiplier /= 2;
353-
} else if (enchantment == JavaEnchantment.SWEEPING) {
353+
} else if (enchantment == JavaEnchantment.SWEEPING_EDGE) {
354354
// Doesn't exist on Bedrock
355355
rarityMultiplier = 0;
356356
}

core/src/main/java/org/geysermc/geyser/item/ArmorMaterial.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@
3131

3232
public enum ArmorMaterial {
3333
LEATHER(() -> Items.LEATHER),
34-
CHAIN(() -> Items.IRON_INGOT),
34+
CHAINMAIL(() -> Items.IRON_INGOT),
3535
IRON(() -> Items.IRON_INGOT),
3636
GOLD(() -> Items.GOLD_INGOT),
3737
DIAMOND(() -> Items.DIAMOND),
38-
TURTLE(() -> Items.SCUTE),
39-
NETHERITE(() -> Items.NETHERITE_INGOT);
38+
TURTLE(() -> Items.TURTLE_SCUTE),
39+
NETHERITE(() -> Items.NETHERITE_INGOT),
40+
ARMADILLO(() -> Items.ARMADILLO_SCUTE);
4041

4142
private final Supplier<Item> repairIngredient;
4243

0 commit comments

Comments
 (0)