mirror of
https://github.com/GeyserMC/Geyser.git
synced 2025-12-26 10:19:12 +00:00
Merchant changes, implement splash_potion entity type, some xp orb fixes
This commit is contained in:
@@ -345,6 +345,7 @@ public final class EntityDefinitions {
|
||||
.build();
|
||||
EXPERIENCE_ORB = EntityDefinition.inherited(ExpOrbEntity::new, entityBase)
|
||||
.type(EntityType.EXPERIENCE_ORB)
|
||||
.addTranslator(null) // int determining xb orb texture
|
||||
.identifier("minecraft:xp_orb")
|
||||
.build();
|
||||
EVOKER_FANGS = EntityDefinition.inherited(EvokerFangsEntity::new, entityBase)
|
||||
|
||||
@@ -435,7 +435,7 @@ public class Entity implements GeyserEntity {
|
||||
}
|
||||
|
||||
public String teamIdentifier() {
|
||||
// experience orbs are the only known entities that do not send an uuid (even though they do have one),
|
||||
// experience orbs were the only known entities that do not send an uuid pre 1.21.5 (even though they do have one),
|
||||
// but to be safe in the future it's done in the entity class itself instead of the entity specific one.
|
||||
// All entities without an uuid cannot show up in the scoreboard!
|
||||
return uuid != null ? uuid.toString() : null;
|
||||
|
||||
@@ -28,7 +28,6 @@ package org.geysermc.geyser.entity.type;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.entity.EntityDefinitions;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
|
||||
import java.util.UUID;
|
||||
@@ -36,12 +35,7 @@ import java.util.UUID;
|
||||
public class ExpOrbEntity extends Entity {
|
||||
|
||||
public ExpOrbEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> entityDefinition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
|
||||
this(session, 1, entityId, geyserId, position);
|
||||
}
|
||||
|
||||
public ExpOrbEntity(GeyserSession session, int amount, int entityId, long geyserId, Vector3f position) {
|
||||
super(session, entityId, geyserId, null, EntityDefinitions.EXPERIENCE_ORB, position, Vector3f.ZERO, 0, 0, 0);
|
||||
|
||||
this.dirtyMetadata.put(EntityDataTypes.TRADE_EXPERIENCE, amount);
|
||||
super(session, entityId, geyserId, uuid, entityDefinition, position, motion, yaw, pitch, headYaw);
|
||||
this.dirtyMetadata.put(EntityDataTypes.TRADE_EXPERIENCE, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,14 +36,14 @@ import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.C
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Setter
|
||||
public class MerchantContainer extends Container {
|
||||
@Getter @Setter
|
||||
@Getter
|
||||
private Entity villager;
|
||||
@Setter
|
||||
private List<VillagerTrade> villagerTrades;
|
||||
@Getter @Setter
|
||||
@Getter
|
||||
private ClientboundMerchantOffersPacket pendingOffersPacket;
|
||||
@Getter @Setter
|
||||
@Getter
|
||||
private int tradeExperience;
|
||||
|
||||
public MerchantContainer(String title, int id, int size, ContainerType containerType, PlayerInventory playerInventory) {
|
||||
|
||||
@@ -160,7 +160,7 @@ public interface RegistryHasher extends MinecraftHasher<Integer> {
|
||||
|
||||
// Encode as a single element if the list only has one element
|
||||
MinecraftHasher<AdventureModePredicate> ADVENTURE_MODE_PREDICATE = MinecraftHasher.either(BLOCK_PREDICATE,
|
||||
predicate -> predicate.getPredicates().size() == 1 ? predicate.getPredicates().getFirst() : null, BLOCK_PREDICATE.list(), AdventureModePredicate::getPredicates);
|
||||
predicate -> predicate.getPredicates().size() == 1 ? predicate.getPredicates().get(0) : null, BLOCK_PREDICATE.list(), AdventureModePredicate::getPredicates);
|
||||
|
||||
MinecraftHasher<ModifierOperation> ATTRIBUTE_MODIFIER_OPERATION = MinecraftHasher.fromEnum(operation -> switch (operation) {
|
||||
case ADD -> "add_value";
|
||||
|
||||
@@ -272,11 +272,10 @@ public class Item {
|
||||
}
|
||||
|
||||
protected final void translateDyedColor(DataComponents components, BedrockItemBuilder builder) {
|
||||
// TODO 1.21.5
|
||||
// DyedItemColor dyedItemColor = components.get(DataComponentTypes.DYED_COLOR);
|
||||
// if (dyedItemColor != null) {
|
||||
// builder.putInt("customColor", dyedItemColor.getRgb());
|
||||
// }
|
||||
Integer dyedItemColor = components.get(DataComponentTypes.DYED_COLOR);
|
||||
if (dyedItemColor != null) {
|
||||
builder.putInt("customColor", dyedItemColor);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,6 +27,7 @@ package org.geysermc.geyser.translator.protocol.java.inventory;
|
||||
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.inventory.VillagerTrade;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.ClientboundMerchantOffersPacket;
|
||||
import org.cloudburstmc.nbt.NbtMap;
|
||||
import org.cloudburstmc.nbt.NbtMapBuilder;
|
||||
@@ -159,8 +160,10 @@ public class JavaMerchantOffersTranslator extends PacketTranslator<ClientboundMe
|
||||
}
|
||||
|
||||
private static ItemStack toItemStack(VillagerTrade.ItemCost itemCost) {
|
||||
// TODO 1.21.5 figure out how to deal with components here!
|
||||
return new ItemStack(itemCost.itemId(), itemCost.count());
|
||||
if (itemCost == null) {
|
||||
return null;
|
||||
}
|
||||
return new ItemStack(itemCost.itemId(), itemCost.count(), new DataComponents(itemCost.components()));
|
||||
}
|
||||
|
||||
private static NbtMap getItemTag(GeyserSession session, ItemStack stack) {
|
||||
|
||||
@@ -70,34 +70,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
* Tests for issues reported on GitHub.
|
||||
*/
|
||||
public class ScoreboardIssueTests {
|
||||
// TODO 1.21.5
|
||||
// /**
|
||||
// * Test for <a href="https://github.com/GeyserMC/Geyser/issues/5075">#5075</a>
|
||||
// */
|
||||
// @Test
|
||||
// void entityWithoutUuid() {
|
||||
// // experience orbs are the only known entities without an uuid, see Entity#teamIdentifier for more info
|
||||
// mockContextScoreboard(context -> {
|
||||
// var addExperienceOrbTranslator = new JavaAddExperienceOrbTranslator();
|
||||
// var removeEntitiesTranslator = new JavaRemoveEntitiesTranslator();
|
||||
//
|
||||
// // Entity#teamIdentifier used to throw because it returned uuid.toString where uuid could be null.
|
||||
// // this would result in both EntityCache#spawnEntity and EntityCache#removeEntity throwing an exception,
|
||||
// // because the entity would be registered and deregistered to the scoreboard.
|
||||
// assertDoesNotThrow(() -> {
|
||||
// context.translate(addExperienceOrbTranslator, new ClientboundAddExperienceOrbPacket(2, 0, 0, 0, 1));
|
||||
//
|
||||
// String displayName = context.mockOrSpy(EntityCache.class).getEntityByJavaId(2).getDisplayName();
|
||||
// assertEquals("entity.minecraft.experience_orb", displayName);
|
||||
//
|
||||
// context.translate(removeEntitiesTranslator, new ClientboundRemoveEntitiesPacket(new int[] { 2 }));
|
||||
// });
|
||||
//
|
||||
// // we know that spawning and removing the entity should be fine
|
||||
// assertNextPacketType(context, AddEntityPacket.class);
|
||||
// assertNextPacketType(context, RemoveEntityPacket.class);
|
||||
// });
|
||||
// }
|
||||
|
||||
/**
|
||||
* Test for <a href="https://github.com/GeyserMC/Geyser/issues/5078">#5078</a>
|
||||
|
||||
@@ -15,7 +15,7 @@ protocol-common = "3.0.0.Beta6-20250324.162731-5"
|
||||
protocol-codec = "3.0.0.Beta6-20250324.162731-5"
|
||||
raknet = "1.0.0.CR3-20250218.160705-18"
|
||||
minecraftauth = "4.1.1"
|
||||
mcprotocollib = "1.21.5-20250328.173210-19"
|
||||
mcprotocollib = "1.21.5-20250328.175415-20"
|
||||
adventure = "4.14.0"
|
||||
adventure-platform = "4.3.0"
|
||||
junit = "5.9.2"
|
||||
|
||||
Reference in New Issue
Block a user