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.
2020-04-08 22:22:38 +00:00
|
|
|
package com.thebrokenrail.reliccraft.item;
|
|
|
|
|
|
|
|
import com.thebrokenrail.reliccraft.RelicCraft;
|
|
|
|
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.DefaultedList;
|
|
|
|
import net.minecraft.util.Identifier;
|
|
|
|
import net.minecraft.util.Rarity;
|
|
|
|
|
|
|
|
public class DragonEggHolderBlockItem extends BlockItem {
|
|
|
|
public DragonEggHolderBlockItem(Block block) {
|
2020-04-15 22:19:40 +00:00
|
|
|
super(block, new Settings().rarity(Rarity.UNCOMMON).group(RelicCraft.ITEM_GROUP));
|
2020-04-08 22:22:38 +00:00
|
|
|
addPropertyGetter(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;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|