Skip to content

Commit

Permalink
encantment datasv d trifb
Browse files Browse the repository at this point in the history
  • Loading branch information
seymourimadeit committed Jun 17, 2024
1 parent a64fd1d commit 522a5a3
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 32 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ public class PPSounds {
public static final DeferredHolder<SoundEvent, SoundEvent> PARROT_IMITATE_ZOMBIFIED_PIGLIN = createVariableRangeSound("entity.parrot.imitate.zombified_piglin");

public static DeferredHolder<SoundEvent, SoundEvent> 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)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -26,4 +26,4 @@ public boolean isDiscoverable() {
public boolean checkCompatibility(Enchantment ench) {
return !(ench instanceof TurningEnchantment) && super.checkCompatibility(ench);
}
}
}*/
Original file line number Diff line number Diff line change
@@ -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<Enchantment> ENCHANTMENTS = DeferredRegister.create(Registries.ENCHANTMENT, PiglinProliferation.MODID);
public static final DeferredHolder<Enchantment, TurningEnchantment> 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<Enchantment, BangEnchantment> 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<DataComponentType<?>> ENCHANTMENTS = DeferredRegister.create(Registries.ENCHANTMENT_EFFECT_COMPONENT_TYPE, PiglinProliferation.MODID);
public static final DeferredHolder<DataComponentType<?>, DataComponentType<List<ConditionalEffect<EnchantmentValueEffect>>>> TURNING = registerComponentType("turning", builder ->
builder.persistent(ConditionalEffect.codec(EnchantmentValueEffect.CODEC, LootContextParamSets.ENCHANTED_ITEM).listOf()));
public static final DeferredHolder<DataComponentType<?>, DataComponentType<List<ConditionalEffect<EnchantmentValueEffect>>>> 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;
Expand All @@ -47,4 +40,8 @@ public static int getBucklerEnchantsOnHands(Enchantment enchantment, LivingEntit
ItemStack stack = player.getItemInHand(hand);
return stack.getEnchantmentLevel(enchantment);
}

public static <D> DeferredHolder<DataComponentType<?>, DataComponentType<D>> registerComponentType(String name, UnaryOperator<DataComponentType.Builder<D>> builder) {
return ENCHANTMENTS.register(name, () -> builder.apply(DataComponentType.builder()).build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -26,4 +26,4 @@ public boolean isDiscoverable() {
public boolean checkCompatibility(Enchantment ench) {
return !(ench instanceof BangEnchantment) && super.checkCompatibility(ench);
}
}
}*/

0 comments on commit 522a5a3

Please sign in to comment.