diff --git a/src/generated/resources/data/iceandfire/tags/items/dragon_arrows.json b/src/generated/resources/data/iceandfire/tags/items/dragon_arrows.json new file mode 100644 index 000000000..75e0f0acb --- /dev/null +++ b/src/generated/resources/data/iceandfire/tags/items/dragon_arrows.json @@ -0,0 +1,5 @@ +{ + "values": [ + "iceandfire:dragonbone_arrow" + ] +} \ No newline at end of file diff --git a/src/main/java/com/github/alexthe666/iceandfire/datagen/tags/IafItemTags.java b/src/main/java/com/github/alexthe666/iceandfire/datagen/tags/IafItemTags.java index 32f744eb4..3e8959424 100644 --- a/src/main/java/com/github/alexthe666/iceandfire/datagen/tags/IafItemTags.java +++ b/src/main/java/com/github/alexthe666/iceandfire/datagen/tags/IafItemTags.java @@ -50,6 +50,7 @@ public class IafItemTags extends ItemTagsProvider { // Logic public static TagKey MAKE_ITEM_DROPS_FIREIMMUNE = createKey("make_item_drops_fireimmune"); + public static TagKey DRAGON_ARROWS = createKey("dragon_arrows"); public static TagKey DRAGON_BLOODS = createKey("dragon_bloods"); public static TagKey DRAGON_HEARTS = createKey("dragon_hearts"); @@ -93,6 +94,9 @@ protected void addTags() { .add(IafItemRegistry.DRAGONSTEEL_LIGHTNING_SHOVEL.get()) .add(IafItemRegistry.DRAGONSTEEL_LIGHTNING_HOE.get()); + tag(DRAGON_ARROWS) + .add(IafItemRegistry.DRAGONBONE_ARROW.get()); + tag(DRAGON_BLOODS) .add(IafItemRegistry.FIRE_DRAGON_BLOOD.get()) .add(IafItemRegistry.ICE_DRAGON_BLOOD.get()) diff --git a/src/main/java/com/github/alexthe666/iceandfire/item/ItemDragonArrow.java b/src/main/java/com/github/alexthe666/iceandfire/item/ItemDragonArrow.java index 8592c8632..15fce85fe 100644 --- a/src/main/java/com/github/alexthe666/iceandfire/item/ItemDragonArrow.java +++ b/src/main/java/com/github/alexthe666/iceandfire/item/ItemDragonArrow.java @@ -4,9 +4,11 @@ import com.github.alexthe666.iceandfire.entity.EntityDragonArrow; import com.github.alexthe666.iceandfire.entity.IafEntityRegistry; import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.projectile.AbstractArrow; import net.minecraft.world.item.ArrowItem; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.level.Level; import org.jetbrains.annotations.NotNull; @@ -16,14 +18,19 @@ public ItemDragonArrow() { } @Override - public @NotNull AbstractArrow createArrow(@NotNull Level worldIn, @NotNull ItemStack stack, @NotNull LivingEntity shooter) { - EntityDragonArrow arrowentity = new EntityDragonArrow(IafEntityRegistry.DRAGON_ARROW.get(), shooter, worldIn); - return arrowentity; + public @NotNull AbstractArrow createArrow(@NotNull final Level level, @NotNull final ItemStack arrow, @NotNull final LivingEntity shooter) { + return new EntityDragonArrow(IafEntityRegistry.DRAGON_ARROW.get(), shooter, level); } @Override - public boolean isInfinite(@NotNull ItemStack stack, @NotNull ItemStack bow, net.minecraft.world.entity.player.@NotNull Player player) { - int enchant = net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.INFINITY_ARROWS, bow); - return enchant > 0 && this.getClass() == ItemDragonArrow.class; + public boolean isInfinite(@NotNull final ItemStack arrow, @NotNull final ItemStack bow, @NotNull final Player player) { + // Technically this would always return false - it's more a compat layer for Apotheosis' Endless Quiver enchantment + boolean isInfinite = super.isInfinite(arrow, bow, player); + + if (!isInfinite) { + isInfinite = bow.getEnchantmentLevel(Enchantments.INFINITY_ARROWS) > 0 && getClass() == ItemDragonArrow.class; + } + + return isInfinite; } } diff --git a/src/main/java/com/github/alexthe666/iceandfire/item/ItemDragonBow.java b/src/main/java/com/github/alexthe666/iceandfire/item/ItemDragonBow.java index e44343e8a..6b0eec36d 100644 --- a/src/main/java/com/github/alexthe666/iceandfire/item/ItemDragonBow.java +++ b/src/main/java/com/github/alexthe666/iceandfire/item/ItemDragonBow.java @@ -1,18 +1,16 @@ package com.github.alexthe666.iceandfire.item; import com.github.alexthe666.iceandfire.IceAndFire; -import com.github.alexthe666.iceandfire.misc.IafTagRegistry; +import com.github.alexthe666.iceandfire.datagen.tags.IafItemTags; import net.minecraft.world.item.BowItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraftforge.registries.ForgeRegistries; import org.jetbrains.annotations.NotNull; import java.util.function.Predicate; public class ItemDragonBow extends BowItem { - public static final Predicate DRAGON_ARROWS = (stack) - -> stack.is(ForgeRegistries.ITEMS.tags().createTagKey(IafTagRegistry.DRAGON_ARROWS)); + private static final Predicate DRAGON_ARROWS = stack -> stack.is(IafItemTags.DRAGON_ARROWS); public ItemDragonBow() { super(new Item.Properties().durability(584).tab(IceAndFire.TAB_ITEMS)); diff --git a/src/main/java/com/github/alexthe666/iceandfire/misc/IafTagRegistry.java b/src/main/java/com/github/alexthe666/iceandfire/misc/IafTagRegistry.java index 487a42956..a6bf1ed4e 100644 --- a/src/main/java/com/github/alexthe666/iceandfire/misc/IafTagRegistry.java +++ b/src/main/java/com/github/alexthe666/iceandfire/misc/IafTagRegistry.java @@ -3,7 +3,6 @@ import net.minecraft.resources.ResourceLocation; public class IafTagRegistry { // FIXME :: Clean up - public static final ResourceLocation DRAGON_ARROWS = new ResourceLocation("iceandfire", "dragon_arrows"); public static final ResourceLocation MYRMEX_HARVESTABLES = new ResourceLocation("iceandfire", "myrmex_harvestables"); public static final ResourceLocation CHICKENS = new ResourceLocation("iceandfire", "chickens"); public static final ResourceLocation FEAR_DRAGONS = new ResourceLocation("iceandfire", "fear_dragons");