This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
RelicCraft/src/main/java/com/thebrokenrail/reliccraft/item/DragonEggHolderBlockItem.java

30 lines
1.2 KiB
Java
Raw Normal View History

package com.thebrokenrail.reliccraft.item;
import com.thebrokenrail.reliccraft.RelicCraft;
2020-06-28 16:38:49 +00:00
import com.thebrokenrail.reliccraft.mixin.ModelPredicateProviderRegistryHook;
import net.minecraft.block.Block;
import net.minecraft.inventory.Inventories;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Identifier;
import net.minecraft.util.Rarity;
2020-06-28 16:38:49 +00:00
import net.minecraft.util.collection.DefaultedList;
public class DragonEggHolderBlockItem extends BlockItem {
public DragonEggHolderBlockItem(Block block) {
super(block, new Settings().rarity(Rarity.UNCOMMON).group(RelicCraft.ITEM_GROUP));
2020-06-28 16:38:49 +00:00
ModelPredicateProviderRegistryHook.callRegister(this, new Identifier(RelicCraft.NAMESPACE, "active"), (stack, world, entity) -> {
CompoundTag tag = stack.getSubTag("BlockEntityTag");
if (tag != null) {
DefaultedList<ItemStack> list = DefaultedList.ofSize(1, ItemStack.EMPTY);
Inventories.fromTag(tag, list);
if (!list.get(0).isEmpty()) {
return 1;
}
}
return 0;
});
}
}