Some touch-ups

This commit is contained in:
Camotoy 2024-12-09 22:42:40 -05:00
parent c575689f2e
commit 357fd137dc
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
4 changed files with 23 additions and 10 deletions

View file

@ -26,6 +26,8 @@ dependencies {
} }
repositories { repositories {
// mavenLocal()
mavenCentral() mavenCentral()
// Floodgate, Cumulus etc. // Floodgate, Cumulus etc.
@ -67,6 +69,4 @@ repositories {
// For Adventure snapshots // For Adventure snapshots
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
//mavenLocal()
} }

View file

@ -128,7 +128,11 @@ public class WolfEntity extends TameableEntity {
public void setBody(ItemStack stack) { public void setBody(ItemStack stack) {
super.setBody(stack); super.setBody(stack);
isCurseOfBinding = ItemUtils.hasEffect(session, stack, EnchantmentComponent.PREVENT_ARMOR_CHANGE); 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 @Override

View file

@ -40,14 +40,12 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.MetadataTyp
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
public class CreakingEntity extends MonsterEntity { public class CreakingEntity extends MonsterEntity {
private Vector3i homePosition;
public static final String CREAKING_STATE = "minecraft:creaking_state"; public static final String CREAKING_STATE = "minecraft:creaking_state";
public static final String CREAKING_SWAYING_TICKS = "minecraft:creaking_swaying_ticks"; 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) { 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); super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
} }
@ -62,6 +60,11 @@ public class CreakingEntity extends MonsterEntity {
@Override @Override
public void addAdditionalSpawnData(AddEntityPacket addEntityPacket) { public void addAdditionalSpawnData(AddEntityPacket addEntityPacket) {
propertyManager.add(CREAKING_STATE, "neutral"); 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.add(CREAKING_SWAYING_TICKS, 0);
propertyManager.applyIntProperties(addEntityPacket.getProperties().getIntProperties()); propertyManager.applyIntProperties(addEntityPacket.getProperties().getIntProperties());
} }

View file

@ -49,10 +49,12 @@ import org.geysermc.geyser.text.MinecraftLocale;
import org.geysermc.geyser.translator.item.BedrockItemBuilder; import org.geysermc.geyser.translator.item.BedrockItemBuilder;
import org.geysermc.geyser.translator.text.MessageTranslator; import org.geysermc.geyser.translator.text.MessageTranslator;
import org.geysermc.geyser.util.MinecraftKey; 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.DataComponentType;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents; 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.DyedItemColor;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.ItemEnchantments; import org.geysermc.mcprotocollib.protocol.data.game.item.component.ItemEnchantments;
import org.jetbrains.annotations.UnmodifiableView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -103,14 +105,18 @@ public class Item {
* Otherwise, prefer using GeyserItemStack's getComponent * Otherwise, prefer using GeyserItemStack's getComponent
*/ */
@NonNull @NonNull
@UnmodifiableView
public DataComponents gatherComponents(DataComponents others) { public DataComponents gatherComponents(DataComponents others) {
if (others == null) { if (others == null) {
return baseComponents; return baseComponents;
} }
DataComponents components = baseComponents.clone(); //noinspection UnstableApiUsage
components.getDataComponents().putAll(others.getDataComponents()); var builder = ImmutableMap.<DataComponentType<?>, DataComponent<?, ?>>builderWithExpectedSize(
return new DataComponents(ImmutableMap.copyOf(components.getDataComponents())); baseComponents.getDataComponents().size() + others.getDataComponents().size());
builder.putAll(baseComponents.getDataComponents());
builder.putAll(others.getDataComponents());
return new DataComponents(builder.build());
} }
@Nullable @Nullable