|
| 1 | +package me.tofaa.entitylib.meta.types; |
| 2 | + |
| 3 | +import com.github.retrooper.packetevents.manager.server.ServerVersion; |
| 4 | +import com.github.retrooper.packetevents.protocol.component.builtin.item.ItemProfile; |
| 5 | +import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; |
| 6 | +import me.tofaa.entitylib.meta.Metadata; |
| 7 | +import net.kyori.adventure.text.Component; |
| 8 | + |
| 9 | +import java.util.Collections; |
| 10 | +import java.util.Optional; |
| 11 | + |
| 12 | +public class MannequinMeta extends AvatarMeta { |
| 13 | + |
| 14 | + public static final byte OFFSET = AvatarMeta.MAX_OFFSET; |
| 15 | + public static final byte MAX_OFFSET = OFFSET + 3; |
| 16 | + |
| 17 | + public MannequinMeta(int entityId, Metadata metadata) { |
| 18 | + super(entityId, metadata); |
| 19 | + isVersionNewer(ServerVersion.V_1_21_8); |
| 20 | + } |
| 21 | + |
| 22 | + public ItemProfile getProfile() { |
| 23 | + return super.metadata.getIndex(OFFSET, new ItemProfile(null, null, Collections.emptyList())); |
| 24 | + } |
| 25 | + |
| 26 | + public void setProfile(ItemProfile value) { |
| 27 | + super.metadata.setIndex(OFFSET, EntityDataTypes.RESOLVABLE_PROFILE, value); |
| 28 | + } |
| 29 | + |
| 30 | + public boolean getImmovable() { |
| 31 | + return super.metadata.getIndex(offset(OFFSET, 1), false); |
| 32 | + } |
| 33 | + |
| 34 | + public void setImmovable(boolean value) { |
| 35 | + super.metadata.setIndex(offset(OFFSET, 1), EntityDataTypes.BOOLEAN, value); |
| 36 | + } |
| 37 | + |
| 38 | + public Optional<Component> getDescription() { |
| 39 | + return super.metadata.getIndex(offset(OFFSET, 2), Optional.empty()); |
| 40 | + } |
| 41 | + |
| 42 | + @SuppressWarnings("OptionalUsedAsFieldOrParameterType") |
| 43 | + public void setDescription(Optional<Component> value) { |
| 44 | + super.metadata.setIndex(offset(OFFSET, 2), EntityDataTypes.OPTIONAL_ADV_COMPONENT, value); |
| 45 | + } |
| 46 | +} |
0 commit comments