From 522a5a3ce68367a8197e3103766bf213b0cffacb Mon Sep 17 00:00:00 2001 From: seymourimadeit Date: Sun, 16 Jun 2024 22:59:25 -0700 Subject: [PATCH] encantment datasv d trifb --- build.gradle | 2 +- gradle.properties | 14 ++++---- .../piglinproliferation/client/PPSounds.java | 2 +- .../common/enchantments/BangEnchantment.java | 4 +-- .../common/enchantments/PPEnchantments.java | 35 +++++++++---------- .../enchantments/TurningEnchantment.java | 4 +-- 6 files changed, 29 insertions(+), 32 deletions(-) diff --git a/build.gradle b/build.gradle index 3f508fe..634a95e 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id 'eclipse' id 'idea' id 'maven-publish' - id 'net.neoforged.gradle.userdev' version '7.0.105' + id 'net.neoforged.gradle.userdev' version '7.0.140' } version = minecraft_version + "-" + mod_version diff --git a/gradle.properties b/gradle.properties index b2d8ac0..5d258a1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,21 +1,21 @@ # Sets default memory used for gradle commands. Can be overridden by user or command line properties. -#org.gradle.jvmargs= +org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false org.gradle.debug=false ## Environment Properties -neogradle.subsystems.parchment.minecraftVersion=1.20.2 -neogradle.subsystems.parchment.mappingsVersion=2023.12.10 +neogradle.subsystems.parchment.minecraftVersion=1.20.6 +neogradle.subsystems.parchment.mappingsVersion=2024.06.16 # The Minecraft version must agree with the Neo version to get a valid artifact -minecraft_version=1.20.6 +minecraft_version=1.21 # The Minecraft version range can use any release version of Minecraft as bounds. # Snapshots, pre-releases, and release candidates are not guaranteed to sort properly # as they do not follow standard versioning conventions. -minecraft_version_range=[1.20.5,1.21) +minecraft_version_range=[1.21, 1.22) # The Neo version must agree with the Minecraft version to get a valid artifact -neo_version=20.6.42-beta +neo_version=21.0.13-beta # The Neo version range can use any version of Neo as bounds or match the loader version range neo_version_range=[20.5.14,) # The loader version range can only use the major version of Neo/FML as bounds @@ -31,7 +31,7 @@ mod_name=Piglin Proliferation # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=MIT for code, CC BY-NC-SA 4.0 for assets # The mod version. See https://semver.org/ -mod_version=1.2.2 +mod_version=2.0.0 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/tallestred/piglinproliferation/client/PPSounds.java b/src/main/java/tallestred/piglinproliferation/client/PPSounds.java index 9a81550..e33d88b 100644 --- a/src/main/java/tallestred/piglinproliferation/client/PPSounds.java +++ b/src/main/java/tallestred/piglinproliferation/client/PPSounds.java @@ -47,6 +47,6 @@ public class PPSounds { public static final DeferredHolder PARROT_IMITATE_ZOMBIFIED_PIGLIN = createVariableRangeSound("entity.parrot.imitate.zombified_piglin"); public static DeferredHolder createVariableRangeSound(String path) { - return SOUNDS.register(path, () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(PiglinProliferation.MODID, path))); + return SOUNDS.register(path, () -> SoundEvent.createVariableRangeEvent(ResourceLocation.fromNamespaceAndPath(PiglinProliferation.MODID, path))); } } diff --git a/src/main/java/tallestred/piglinproliferation/common/enchantments/BangEnchantment.java b/src/main/java/tallestred/piglinproliferation/common/enchantments/BangEnchantment.java index d156fae..40e3261 100644 --- a/src/main/java/tallestred/piglinproliferation/common/enchantments/BangEnchantment.java +++ b/src/main/java/tallestred/piglinproliferation/common/enchantments/BangEnchantment.java @@ -2,7 +2,7 @@ import net.minecraft.world.item.enchantment.Enchantment; -public class BangEnchantment extends Enchantment { +/*public class BangEnchantment extends Enchantment { public BangEnchantment(EnchantmentDefinition definition) { super(definition); } @@ -26,4 +26,4 @@ public boolean isDiscoverable() { public boolean checkCompatibility(Enchantment ench) { return !(ench instanceof TurningEnchantment) && super.checkCompatibility(ench); } -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/src/main/java/tallestred/piglinproliferation/common/enchantments/PPEnchantments.java b/src/main/java/tallestred/piglinproliferation/common/enchantments/PPEnchantments.java index 25e2992..c3c0bc0 100644 --- a/src/main/java/tallestred/piglinproliferation/common/enchantments/PPEnchantments.java +++ b/src/main/java/tallestred/piglinproliferation/common/enchantments/PPEnchantments.java @@ -1,37 +1,30 @@ package tallestred.piglinproliferation.common.enchantments; +import net.minecraft.core.component.DataComponentType; import net.minecraft.core.registries.Registries; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.enchantment.ConditionalEffect; import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.effects.EnchantmentValueEffect; +import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; import net.neoforged.neoforge.registries.DeferredHolder; import net.neoforged.neoforge.registries.DeferredRegister; import tallestred.piglinproliferation.PiglinProliferation; import tallestred.piglinproliferation.common.items.BucklerItem; import tallestred.piglinproliferation.common.tags.PPTags; +import java.util.List; +import java.util.function.UnaryOperator; + public class PPEnchantments { - public static final DeferredRegister ENCHANTMENTS = DeferredRegister.create(Registries.ENCHANTMENT, PiglinProliferation.MODID); - public static final DeferredHolder TURNING = ENCHANTMENTS.register("turning", () -> new TurningEnchantment(Enchantment.definition( - PPTags.BUCKLER_ENCHANTABLE, - 10, - 5, - Enchantment.dynamicCost(1, 10), - Enchantment.dynamicCost(15, 10), - 1, - EquipmentSlot.MAINHAND - ))); - public static final DeferredHolder BANG = ENCHANTMENTS.register("bang", () -> new BangEnchantment(Enchantment.definition( - PPTags.BUCKLER_ENCHANTABLE, - 10, - 3, - Enchantment.dynamicCost(1, 10), - Enchantment.dynamicCost(50, 10), - 1, - EquipmentSlot.MAINHAND - ))); + public static final DeferredRegister> ENCHANTMENTS = DeferredRegister.create(Registries.ENCHANTMENT_EFFECT_COMPONENT_TYPE, PiglinProliferation.MODID); + public static final DeferredHolder, DataComponentType>>> TURNING = registerComponentType("turning", builder -> + builder.persistent(ConditionalEffect.codec(EnchantmentValueEffect.CODEC, LootContextParamSets.ENCHANTED_ITEM).listOf())); + public static final DeferredHolder, DataComponentType>>> BANG = registerComponentType("turning", builder -> + builder.persistent(ConditionalEffect.codec(EnchantmentValueEffect.CODEC, LootContextParamSets.ENCHANTED_ITEM).listOf())); public static boolean hasBucklerEnchantsOnHands(LivingEntity player, Enchantment... enchantments) { InteractionHand hand = player.getMainHandItem().getItem() instanceof BucklerItem ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND; @@ -47,4 +40,8 @@ public static int getBucklerEnchantsOnHands(Enchantment enchantment, LivingEntit ItemStack stack = player.getItemInHand(hand); return stack.getEnchantmentLevel(enchantment); } + + public static DeferredHolder, DataComponentType> registerComponentType(String name, UnaryOperator> builder) { + return ENCHANTMENTS.register(name, () -> builder.apply(DataComponentType.builder()).build()); + } } diff --git a/src/main/java/tallestred/piglinproliferation/common/enchantments/TurningEnchantment.java b/src/main/java/tallestred/piglinproliferation/common/enchantments/TurningEnchantment.java index ffc26cf..923436d 100644 --- a/src/main/java/tallestred/piglinproliferation/common/enchantments/TurningEnchantment.java +++ b/src/main/java/tallestred/piglinproliferation/common/enchantments/TurningEnchantment.java @@ -2,7 +2,7 @@ import net.minecraft.world.item.enchantment.Enchantment; -public class TurningEnchantment extends Enchantment { +/*public class TurningEnchantment extends Enchantment { public TurningEnchantment(EnchantmentDefinition definition) { super(definition); } @@ -26,4 +26,4 @@ public boolean isDiscoverable() { public boolean checkCompatibility(Enchantment ench) { return !(ench instanceof BangEnchantment) && super.checkCompatibility(ench); } -} +}*/