diff --git a/src/main/java/de/teamlapen/vampirism/core/ModDataComponents.java b/src/main/java/de/teamlapen/vampirism/core/ModDataComponents.java index 61ac0f7b3..1ac56977b 100644 --- a/src/main/java/de/teamlapen/vampirism/core/ModDataComponents.java +++ b/src/main/java/de/teamlapen/vampirism/core/ModDataComponents.java @@ -5,6 +5,7 @@ import de.teamlapen.vampirism.api.VampirismDataComponents; import de.teamlapen.vampirism.items.component.*; import net.minecraft.core.component.DataComponentType; +import net.minecraft.core.registries.Registries; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; import net.minecraft.util.Unit; @@ -19,25 +20,27 @@ public class ModDataComponents { - public static final DeferredRegister.DataComponents DATA_COMPONENTS = DeferredRegister.createDataComponents(REFERENCE.MODID); + public static final DeferredRegister.DataComponents ITEM_DATA_COMPONENTS = DeferredRegister.createDataComponents(Registries.DATA_COMPONENT_TYPE, REFERENCE.MODID); + public static final DeferredRegister.DataComponents ENCHANTMENT_DATA_COMPONENTS = DeferredRegister.createDataComponents(Registries.ENCHANTMENT_EFFECT_COMPONENT_TYPE, REFERENCE.MODID); - public static final DeferredHolder, DataComponentType> OIL = DATA_COMPONENTS.register(VampirismDataComponents.Keys.OIL_CONTENTS.getPath(), () -> DataComponentType.builder().persistent(OilContent.CODEC).networkSynchronized(OilContent.STREAM_CODEC).cacheEncoding().build()); - public static final DeferredHolder, DataComponentType> APPLIED_OIL = DATA_COMPONENTS.register(VampirismDataComponents.Keys.APPLIED_OIL.getPath(), () -> DataComponentType.builder().persistent(AppliedOilContent.CODEC).networkSynchronized(AppliedOilContent.STREAM_CODEC).cacheEncoding().build()); - public static final DeferredHolder, DataComponentType> VAMPIRE_BOOK = DATA_COMPONENTS.register(VampirismDataComponents.Keys.VAMPIRE_BOOK.getPath(), () -> DataComponentType.builder().persistent(VampireBookContents.CODEC).networkSynchronized(VampireBookContents.STREAM_CODEC).cacheEncoding().build()); - public static final DeferredHolder, DataComponentType> BLOOD_CONTAINER = DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.BLOOD_CONTAINER.getPath(), (builder) -> builder.persistent(ContainedFluid.CODEC).networkSynchronized(ContainedFluid.STREAM_CODEC)); - public static final DeferredHolder, DataComponentType> CONTAINED_PROJECTILES = DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.CONTAINED_PROJECTILES.getPath(), (builder) -> builder.persistent(ContainedProjectiles.CODEC).networkSynchronized(ContainedProjectiles.STREAM_CODEC)); - public static final DeferredHolder, DataComponentType> REFINEMENT_SET = DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.REFINEMENT_SET.getPath(), (builder) -> builder.persistent(EffectiveRefinementSet.CODEC).networkSynchronized(EffectiveRefinementSet.STREAM_CODEC)); - public static final DeferredHolder, DataComponentType> DO_NOT_NAME = DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.DO_NOT_NAME.getPath(), (builder) -> builder.persistent(Codec.unit(Unit.INSTANCE)).networkSynchronized(StreamCodec.unit(Unit.INSTANCE))); - public static final DeferredHolder, DataComponentType> VAMPIRE_SWORD = DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.VAMPIRE_SWORD.getPath(), (builder) -> builder.persistent(SwordTraining.CODEC).networkSynchronized(SwordTraining.STREAM_CODEC)); - public static final DeferredHolder, DataComponentType> BLOOD_CHARGED = DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.BLOOD_CHARGED.getPath(), (builder) -> builder.persistent(BloodCharged.CODEC).networkSynchronized(BloodCharged.STREAM_CODEC)); - public static final DeferredHolder, DataComponentType> TRAINING_CACHE = DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.TRAINING_CACHE.getPath(), (builder) -> builder.persistent(Codec.FLOAT).networkSynchronized(ByteBufCodecs.FLOAT)); - public static final DeferredHolder, DataComponentType> SELECTED_AMMUNITION = DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.SELECTED_AMMUNITION.getPath(), (builder) -> builder.persistent(SelectedAmmunition.CODEC).networkSynchronized(SelectedAmmunition.STREAM_CODEC)); - public static final DeferredHolder, DataComponentType> BOTTLE_BLOOD = DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.BOTTLE_BLOOD.getPath(), (builder) -> builder.persistent(BottleBlood.CODEC).networkSynchronized(BottleBlood.STREAM_CODEC)); - public static final DeferredHolder, DataComponentType> CROSSBOW_FRUGALITY_TRIGGERED = DATA_COMPONENTS.registerComponentType("crossbow_frugality_triggered", (builder) -> builder.persistent(Codec.unit(Unit.INSTANCE)).networkSynchronized(StreamCodec.unit(Unit.INSTANCE))); - public static final DeferredHolder, DataComponentType> IS_FACTION_BANNER = DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.IS_FACTION_BANNER.getPath(), (builder) -> builder.persistent(Unit.CODEC).networkSynchronized(StreamCodec.unit(Unit.INSTANCE))); - public static final DeferredHolder, DataComponentType>>> FRUGALITY = DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.FRUGALITY.getPath(), (builder) -> builder.persistent(ConditionalEffect.codec(EnchantmentValueEffect.CODEC, LootContextParamSets.ENCHANTED_DAMAGE).listOf())); + public static final DeferredHolder, DataComponentType> OIL = ITEM_DATA_COMPONENTS.register(VampirismDataComponents.Keys.OIL_CONTENTS.getPath(), () -> DataComponentType.builder().persistent(OilContent.CODEC).networkSynchronized(OilContent.STREAM_CODEC).cacheEncoding().build()); + public static final DeferredHolder, DataComponentType> APPLIED_OIL = ITEM_DATA_COMPONENTS.register(VampirismDataComponents.Keys.APPLIED_OIL.getPath(), () -> DataComponentType.builder().persistent(AppliedOilContent.CODEC).networkSynchronized(AppliedOilContent.STREAM_CODEC).cacheEncoding().build()); + public static final DeferredHolder, DataComponentType> VAMPIRE_BOOK = ITEM_DATA_COMPONENTS.register(VampirismDataComponents.Keys.VAMPIRE_BOOK.getPath(), () -> DataComponentType.builder().persistent(VampireBookContents.CODEC).networkSynchronized(VampireBookContents.STREAM_CODEC).cacheEncoding().build()); + public static final DeferredHolder, DataComponentType> BLOOD_CONTAINER = ITEM_DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.BLOOD_CONTAINER.getPath(), (builder) -> builder.persistent(ContainedFluid.CODEC).networkSynchronized(ContainedFluid.STREAM_CODEC)); + public static final DeferredHolder, DataComponentType> CONTAINED_PROJECTILES = ITEM_DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.CONTAINED_PROJECTILES.getPath(), (builder) -> builder.persistent(ContainedProjectiles.CODEC).networkSynchronized(ContainedProjectiles.STREAM_CODEC)); + public static final DeferredHolder, DataComponentType> REFINEMENT_SET = ITEM_DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.REFINEMENT_SET.getPath(), (builder) -> builder.persistent(EffectiveRefinementSet.CODEC).networkSynchronized(EffectiveRefinementSet.STREAM_CODEC)); + public static final DeferredHolder, DataComponentType> DO_NOT_NAME = ITEM_DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.DO_NOT_NAME.getPath(), (builder) -> builder.persistent(Codec.unit(Unit.INSTANCE)).networkSynchronized(StreamCodec.unit(Unit.INSTANCE))); + public static final DeferredHolder, DataComponentType> VAMPIRE_SWORD = ITEM_DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.VAMPIRE_SWORD.getPath(), (builder) -> builder.persistent(SwordTraining.CODEC).networkSynchronized(SwordTraining.STREAM_CODEC)); + public static final DeferredHolder, DataComponentType> BLOOD_CHARGED = ITEM_DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.BLOOD_CHARGED.getPath(), (builder) -> builder.persistent(BloodCharged.CODEC).networkSynchronized(BloodCharged.STREAM_CODEC)); + public static final DeferredHolder, DataComponentType> TRAINING_CACHE = ITEM_DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.TRAINING_CACHE.getPath(), (builder) -> builder.persistent(Codec.FLOAT).networkSynchronized(ByteBufCodecs.FLOAT)); + public static final DeferredHolder, DataComponentType> SELECTED_AMMUNITION = ITEM_DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.SELECTED_AMMUNITION.getPath(), (builder) -> builder.persistent(SelectedAmmunition.CODEC).networkSynchronized(SelectedAmmunition.STREAM_CODEC)); + public static final DeferredHolder, DataComponentType> BOTTLE_BLOOD = ITEM_DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.BOTTLE_BLOOD.getPath(), (builder) -> builder.persistent(BottleBlood.CODEC).networkSynchronized(BottleBlood.STREAM_CODEC)); + public static final DeferredHolder, DataComponentType> CROSSBOW_FRUGALITY_TRIGGERED = ITEM_DATA_COMPONENTS.registerComponentType("crossbow_frugality_triggered", (builder) -> builder.persistent(Codec.unit(Unit.INSTANCE)).networkSynchronized(StreamCodec.unit(Unit.INSTANCE))); + public static final DeferredHolder, DataComponentType> IS_FACTION_BANNER = ITEM_DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.IS_FACTION_BANNER.getPath(), (builder) -> builder.persistent(Unit.CODEC).networkSynchronized(StreamCodec.unit(Unit.INSTANCE))); + public static final DeferredHolder, DataComponentType>>> FRUGALITY = ENCHANTMENT_DATA_COMPONENTS.registerComponentType(VampirismDataComponents.Keys.FRUGALITY.getPath(), (builder) -> builder.persistent(ConditionalEffect.codec(EnchantmentValueEffect.CODEC, LootContextParamSets.ENCHANTED_DAMAGE).listOf())); static void register(IEventBus eventBus) { - DATA_COMPONENTS.register(eventBus); + ITEM_DATA_COMPONENTS.register(eventBus); + ENCHANTMENT_DATA_COMPONENTS.register(eventBus); } }