mirror of
https://github.com/GeyserMC/Geyser.git
synced 2026-01-06 15:41:50 +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) {
|
||||
|
||||
Reference in New Issue
Block a user