Skip to content

Commit

Permalink
Some touch-ups
Browse files Browse the repository at this point in the history
  • Loading branch information
Camotoy committed Dec 10, 2024
1 parent c575689 commit 357fd13
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ dependencies {
}

repositories {
// mavenLocal()

mavenCentral()

// Floodgate, Cumulus etc.
Expand Down Expand Up @@ -67,6 +69,4 @@ repositories {

// For Adventure snapshots
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")

//mavenLocal()
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ protected Tag<Item> getFoodTag() {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@
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);
}
Expand All @@ -62,6 +60,11 @@ protected void initializeMetadata() {
@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());
}
Expand Down
12 changes: 9 additions & 3 deletions core/src/main/java/org/geysermc/geyser/item/type/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@
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;
Expand Down Expand Up @@ -103,14 +105,18 @@ public Rarity defaultRarity() {
* 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
Expand Down

0 comments on commit 357fd13

Please sign in to comment.