Skip to content

Commit

Permalink
make dragon arrow logic more compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
SiverDX authored and TheBv committed Feb 9, 2024
1 parent c47f6b2 commit 3269b87
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"iceandfire:dragonbone_arrow"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class IafItemTags extends ItemTagsProvider {

// Logic
public static TagKey<Item> MAKE_ITEM_DROPS_FIREIMMUNE = createKey("make_item_drops_fireimmune");
public static TagKey<Item> DRAGON_ARROWS = createKey("dragon_arrows");

public static TagKey<Item> DRAGON_BLOODS = createKey("dragon_bloods");
public static TagKey<Item> DRAGON_HEARTS = createKey("dragon_hearts");
Expand Down Expand Up @@ -96,6 +97,9 @@ protected void addTags(HolderLookup.Provider provider) {
.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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,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;

Expand All @@ -15,14 +17,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;
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package com.github.alexthe666.iceandfire.item;

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<ItemStack> DRAGON_ARROWS = (stack)
-> stack.is(ForgeRegistries.ITEMS.tags().createTagKey(IafTagRegistry.DRAGON_ARROWS));
private static final Predicate<ItemStack> DRAGON_ARROWS = stack -> stack.is(IafItemTags.DRAGON_ARROWS);

public ItemDragonBow() {
super(new Item.Properties().durability(584));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 3269b87

Please sign in to comment.