net.minestom.server.item.enchant.EffectComponent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of minestom-snapshots Show documentation
Show all versions of minestom-snapshots Show documentation
1.20.4 Lightweight Minecraft server
package net.minestom.server.item.enchant;
import net.minestom.server.component.DataComponent;
import net.minestom.server.component.DataComponentMap;
import net.minestom.server.gamedata.tags.Tag;
import net.minestom.server.item.crossbow.CrossbowChargingSounds;
import net.minestom.server.registry.ObjectSet;
import net.minestom.server.sound.SoundEvent;
import net.minestom.server.utils.NamespaceID;
import net.minestom.server.utils.Unit;
import net.minestom.server.utils.collection.ObjectArray;
import net.minestom.server.utils.nbt.BinaryTagSerializer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class EffectComponent {
static final Map> NAMESPACES = new HashMap<>(32);
static final ObjectArray> IDS = ObjectArray.singleThread(32);
public static final DataComponent>> DAMAGE_PROTECTION = register("damage_protection", ConditionalEffect.nbtType(ValueEffect.NBT_TYPE).list());
public static final DataComponent>> DAMAGE_IMMUNITY = register("damage_immunity", ConditionalEffect.nbtType(DamageImmunityEffect.NBT_TYPE).list());
public static final DataComponent>> DAMAGE = register("damage", ConditionalEffect.nbtType(ValueEffect.NBT_TYPE).list());
public static final DataComponent>> SMASH_DAMAGE_PER_FALLEN_BLOCK = register("smash_damage_per_fallen_block", ConditionalEffect.nbtType(ValueEffect.NBT_TYPE).list());
public static final DataComponent>> KNOCKBACK = register("knockback", ConditionalEffect.nbtType(ValueEffect.NBT_TYPE).list());
public static final DataComponent>> ARMOR_EFFECTIVENESS = register("armor_effectiveness", ConditionalEffect.nbtType(ValueEffect.NBT_TYPE).list());
public static final DataComponent>> POST_ATTACK = register("post_attack", TargetedConditionalEffect.nbtType(EntityEffect.NBT_TYPE).list());
public static final DataComponent>> HIT_BLOCK = register("hit_block", ConditionalEffect.nbtType(EntityEffect.NBT_TYPE).list());
public static final DataComponent>> ITEM_DAMAGE = register("item_damage", ConditionalEffect.nbtType(ValueEffect.NBT_TYPE).list());
public static final DataComponent> ATTRIBUTES = register("attributes", AttributeEffect.NBT_TYPE.list());
public static final DataComponent>> EQUIPMENT_DROPS = register("equipment_drops", TargetedConditionalEffect.nbtType(ValueEffect.NBT_TYPE).list());
public static final DataComponent>> LOCATION_CHANGED = register("location_changed", ConditionalEffect.nbtType(LocationEffect.NBT_TYPE).list());
public static final DataComponent>> TICK = register("tick", ConditionalEffect.nbtType(EntityEffect.NBT_TYPE).list());
public static final DataComponent>> AMMO_USE = register("ammo_use", ConditionalEffect.nbtType(ValueEffect.NBT_TYPE).list());
public static final DataComponent>> PROJECTILE_PIERCING = register("projectile_piercing", ConditionalEffect.nbtType(ValueEffect.NBT_TYPE).list());
public static final DataComponent>> PROJECTILE_SPAWNED = register("projectile_spawned", ConditionalEffect.nbtType(EntityEffect.NBT_TYPE).list());
public static final DataComponent>> PROJECTILE_SPREAD = register("projectile_spread", ConditionalEffect.nbtType(ValueEffect.NBT_TYPE).list());
public static final DataComponent>> PROJECTILE_COUNT = register("projectile_count", ConditionalEffect.nbtType(ValueEffect.NBT_TYPE).list());
public static final DataComponent>> TRIDENT_RETURN_ACCELERATION = register("trident_return_acceleration", ConditionalEffect.nbtType(ValueEffect.NBT_TYPE).list());
public static final DataComponent>> FISHING_TIME_REDUCTION = register("fishing_time_reduction", ConditionalEffect.nbtType(ValueEffect.NBT_TYPE).list());
public static final DataComponent>> FISHING_LUCK_BONUS = register("fishing_luck_bonus", ConditionalEffect.nbtType(ValueEffect.NBT_TYPE).list());
public static final DataComponent>> BLOCK_EXPERIENCE = register("block_experience", ConditionalEffect.nbtType(ValueEffect.NBT_TYPE).list());
public static final DataComponent>> MOB_EXPERIENCE = register("mob_experience", ConditionalEffect.nbtType(ValueEffect.NBT_TYPE).list());
public static final DataComponent>> REPAIR_WITH_XP = register("repair_with_xp", ConditionalEffect.nbtType(ValueEffect.NBT_TYPE).list());
public static final DataComponent CROSSBOW_CHARGE_TIME = register("crossbow_charge_time", ValueEffect.NBT_TYPE);
public static final DataComponent> CROSSBOW_CHARGING_SOUNDS = register("crossbow_charging_sounds", CrossbowChargingSounds.NBT_TYPE.list());
public static final DataComponent>> TRIDENT_SOUND = register("trident_sound", ObjectSet.nbtType(Tag.BasicType.SOUND_EVENTS).list());
public static final DataComponent PREVENT_EQUIPMENT_DROP = register("prevent_equipment_drop", BinaryTagSerializer.UNIT);
public static final DataComponent PREVENT_ARMOR_CHANGE = register("prevent_armor_change", BinaryTagSerializer.UNIT);
public static final DataComponent TRIDENT_SPIN_ATTACK_STRENGTH = register("trident_spin_attack_strength", ValueEffect.NBT_TYPE);
public static final BinaryTagSerializer MAP_NBT_TYPE = DataComponentMap.nbtType(EffectComponent::fromId, EffectComponent::fromNamespaceId);
public static @Nullable DataComponent> fromNamespaceId(@NotNull String namespaceId) {
return NAMESPACES.get(namespaceId);
}
public static @Nullable DataComponent> fromNamespaceId(@NotNull NamespaceID namespaceId) {
return fromNamespaceId(namespaceId.asString());
}
public static @Nullable DataComponent> fromId(int id) {
return IDS.get(id);
}
public static @NotNull Collection> values() {
return NAMESPACES.values();
}
static DataComponent register(@NotNull String name, @Nullable BinaryTagSerializer nbt) {
DataComponent impl = DataComponent.createHeadless(NAMESPACES.size(), NamespaceID.from(name), null, nbt);
NAMESPACES.put(impl.name(), impl);
IDS.set(impl.id(), impl);
return impl;
}
}