From 357fd137dc6d5a9111ded2e9c64cf11e10bfd5bf Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Mon, 9 Dec 2024 22:42:40 -0500 Subject: [PATCH] Some touch-ups --- .../main/kotlin/geyser.base-conventions.gradle.kts | 4 ++-- .../type/living/animal/tameable/WolfEntity.java | 6 +++++- .../entity/type/living/monster/CreakingEntity.java | 11 +++++++---- .../java/org/geysermc/geyser/item/type/Item.java | 12 +++++++++--- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/build-logic/src/main/kotlin/geyser.base-conventions.gradle.kts b/build-logic/src/main/kotlin/geyser.base-conventions.gradle.kts index 045015fe1..093f0a8c0 100644 --- a/build-logic/src/main/kotlin/geyser.base-conventions.gradle.kts +++ b/build-logic/src/main/kotlin/geyser.base-conventions.gradle.kts @@ -26,6 +26,8 @@ dependencies { } repositories { + // mavenLocal() + mavenCentral() // Floodgate, Cumulus etc. @@ -67,6 +69,4 @@ repositories { // For Adventure snapshots maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") - - //mavenLocal() } diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/WolfEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/WolfEntity.java index 1b06f3860..ff2d57aef 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/WolfEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/WolfEntity.java @@ -128,7 +128,11 @@ public class WolfEntity extends TameableEntity { public void setBody(ItemStack stack) { super.setBody(stack); isCurseOfBinding = ItemUtils.hasEffect(session, stack, EnchantmentComponent.PREVENT_ARMOR_CHANGE); - repairableItems = GeyserItemStack.from(stack).getComponent(DataComponentType.REPAIRABLE); + if (stack != null && stack.getDataComponents() != null) { + repairableItems = stack.getDataComponents().get(DataComponentType.REPAIRABLE); + } else { + repairableItems = null; + } } @Override diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/monster/CreakingEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/monster/CreakingEntity.java index 1a26eb43b..1b9fdd8a4 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/monster/CreakingEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/monster/CreakingEntity.java @@ -40,14 +40,12 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.MetadataTyp import java.util.Optional; import java.util.UUID; - public class CreakingEntity extends MonsterEntity { - - private Vector3i homePosition; - public static final String CREAKING_STATE = "minecraft:creaking_state"; public static final String CREAKING_SWAYING_TICKS = "minecraft:creaking_swaying_ticks"; + private Vector3i homePosition; + public CreakingEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) { super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw); } @@ -62,6 +60,11 @@ public class CreakingEntity extends MonsterEntity { @Override public void addAdditionalSpawnData(AddEntityPacket addEntityPacket) { propertyManager.add(CREAKING_STATE, "neutral"); + // also, the creaking seems to have this minecraft:creaking_swaying_ticks thingy + // which i guess is responsible for some animation? + // it's sent over the network, all 6 "stages" 50ms in between of each other. + // no clue what it's used for tbh, so i'm not gonna bother implementing it + // - chris propertyManager.add(CREAKING_SWAYING_TICKS, 0); propertyManager.applyIntProperties(addEntityPacket.getProperties().getIntProperties()); } diff --git a/core/src/main/java/org/geysermc/geyser/item/type/Item.java b/core/src/main/java/org/geysermc/geyser/item/type/Item.java index b12ab4d67..51750e7b1 100644 --- a/core/src/main/java/org/geysermc/geyser/item/type/Item.java +++ b/core/src/main/java/org/geysermc/geyser/item/type/Item.java @@ -49,10 +49,12 @@ import org.geysermc.geyser.text.MinecraftLocale; import org.geysermc.geyser.translator.item.BedrockItemBuilder; import org.geysermc.geyser.translator.text.MessageTranslator; import org.geysermc.geyser.util.MinecraftKey; +import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponent; import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType; import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents; import org.geysermc.mcprotocollib.protocol.data.game.item.component.DyedItemColor; import org.geysermc.mcprotocollib.protocol.data.game.item.component.ItemEnchantments; +import org.jetbrains.annotations.UnmodifiableView; import java.util.ArrayList; import java.util.HashMap; @@ -103,14 +105,18 @@ public class Item { * Otherwise, prefer using GeyserItemStack's getComponent */ @NonNull + @UnmodifiableView public DataComponents gatherComponents(DataComponents others) { if (others == null) { return baseComponents; } - DataComponents components = baseComponents.clone(); - components.getDataComponents().putAll(others.getDataComponents()); - return new DataComponents(ImmutableMap.copyOf(components.getDataComponents())); + //noinspection UnstableApiUsage + var builder = ImmutableMap., DataComponent>builderWithExpectedSize( + baseComponents.getDataComponents().size() + others.getDataComponents().size()); + builder.putAll(baseComponents.getDataComponents()); + builder.putAll(others.getDataComponents()); + return new DataComponents(builder.build()); } @Nullable