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 {
// mavenLocal()
mavenCentral()
// Floodgate, Cumulus etc.
@ -67,6 +69,4 @@ repositories {
// For Adventure 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) {
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

View file

@ -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());
}

View file

@ -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.<DataComponentType<?>, DataComponent<?, ?>>builderWithExpectedSize(
baseComponents.getDataComponents().size() + others.getDataComponents().size());
builder.putAll(baseComponents.getDataComponents());
builder.putAll(others.getDataComponents());
return new DataComponents(builder.build());
}
@Nullable