mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-12-22 14:59:22 +01:00
creative tab
This commit is contained in:
parent
b2e7a3f467
commit
778398186c
13 changed files with 78 additions and 65 deletions
|
@ -6,15 +6,12 @@ import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
|||
import de.ellpeck.naturesaura.chunk.effect.DrainSpotEffects;
|
||||
import de.ellpeck.naturesaura.compat.Compat;
|
||||
import de.ellpeck.naturesaura.events.CommonEvents;
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.proxy.ClientProxy;
|
||||
import de.ellpeck.naturesaura.proxy.IProxy;
|
||||
import de.ellpeck.naturesaura.proxy.ServerProxy;
|
||||
import de.ellpeck.naturesaura.recipes.ModRecipes;
|
||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
|
@ -32,13 +29,6 @@ public final class NaturesAura {
|
|||
public static final String MOD_NAME = "Nature's Aura";
|
||||
|
||||
public static final Logger LOGGER = LogManager.getLogger(NaturesAura.MOD_NAME);
|
||||
// TODO creative tab
|
||||
/* public static final CreativeModeTab CREATIVE_TAB = new CreativeModeTab(NaturesAura.MOD_ID) {
|
||||
@Override
|
||||
public ItemStack makeIcon() {
|
||||
return new ItemStack(ModItems.GOLD_LEAF);
|
||||
}
|
||||
};*/
|
||||
public static NaturesAura instance;
|
||||
// this causes a classloading issue if it's not wrapped like this
|
||||
@SuppressWarnings("Convert2MethodRef")
|
||||
|
|
|
@ -32,7 +32,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
public class PatchouliCompat implements ICompat {
|
||||
|
||||
private static final ResourceLocation BOOK = new ResourceLocation(NaturesAura.MOD_ID, "book");
|
||||
public static final ResourceLocation BOOK = new ResourceLocation(NaturesAura.MOD_ID, "book");
|
||||
private static final Map<ResourceLocation, IMultiblock> MULTIBLOCKS = new HashMap<>();
|
||||
|
||||
public static void addPatchouliMultiblock(ResourceLocation name, String[][] pattern, Object... rawMatchers) {
|
||||
|
|
|
@ -5,17 +5,16 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
|||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||
import de.ellpeck.naturesaura.data.ItemModelGenerator;
|
||||
import de.ellpeck.naturesaura.reg.IColorProvidingItem;
|
||||
import de.ellpeck.naturesaura.reg.ICustomCreativeTab;
|
||||
import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
||||
import net.minecraft.client.color.item.ItemColor;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ClipContext;
|
||||
|
@ -28,7 +27,9 @@ import net.minecraftforge.common.MinecraftForge;
|
|||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICustomItemModel {
|
||||
import java.util.List;
|
||||
|
||||
public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICustomItemModel, ICustomCreativeTab {
|
||||
|
||||
public ItemAuraBottle(Item emptyBottle) {
|
||||
super("aura_bottle");
|
||||
|
@ -52,17 +53,10 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu
|
|||
});
|
||||
}
|
||||
|
||||
// TODO aura bottle creative
|
||||
/* @Override
|
||||
public void fillItemCategory(CreativeModeTab tab, NonNullList<ItemStack> items) {
|
||||
if (this.allowedIn(tab)) {
|
||||
for (var type : NaturesAuraAPI.AURA_TYPES.values()) {
|
||||
var stack = new ItemStack(this);
|
||||
ItemAuraBottle.setType(stack, type);
|
||||
items.add(stack);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
@Override
|
||||
public List<ItemStack> getCreativeTabItems() {
|
||||
return NaturesAuraAPI.AURA_TYPES.values().stream().map(t -> ItemAuraBottle.setType(new ItemStack(this), t)).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getName(ItemStack stack) {
|
||||
|
|
|
@ -7,6 +7,7 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
|||
import de.ellpeck.naturesaura.api.aura.container.ItemAuraContainer;
|
||||
import de.ellpeck.naturesaura.api.render.ITrinketItem;
|
||||
import de.ellpeck.naturesaura.enchant.ModEnchantments;
|
||||
import de.ellpeck.naturesaura.reg.ICustomCreativeTab;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
|
@ -26,8 +27,10 @@ import net.minecraftforge.common.util.LazyOptional;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemAuraCache extends ItemImpl implements ITrinketItem {
|
||||
public class ItemAuraCache extends ItemImpl implements ITrinketItem, ICustomCreativeTab {
|
||||
|
||||
private final int capacity;
|
||||
|
||||
|
@ -61,19 +64,17 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO creative tabs for items with variations
|
||||
/* @Override
|
||||
public void fillItemCategory(CreativeModeTab tab, NonNullList<ItemStack> items) {
|
||||
if (this.allowedIn(tab)) {
|
||||
items.add(new ItemStack(this));
|
||||
|
||||
var stack = new ItemStack(this);
|
||||
stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).ifPresent(container -> {
|
||||
container.storeAura(container.getMaxAura(), false);
|
||||
items.add(stack);
|
||||
});
|
||||
}
|
||||
}*/
|
||||
@Override
|
||||
public List<ItemStack> getCreativeTabItems() {
|
||||
var ret = new ArrayList<ItemStack>();
|
||||
ret.add(new ItemStack(this));
|
||||
var full = new ItemStack(this);
|
||||
full.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).ifPresent(container -> {
|
||||
container.storeAura(container.getMaxAura(), false);
|
||||
ret.add(full);
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBarVisible(ItemStack stack) {
|
||||
|
|
|
@ -3,18 +3,19 @@ package de.ellpeck.naturesaura.items;
|
|||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.entities.EntityEffectInhibitor;
|
||||
import de.ellpeck.naturesaura.reg.IColorProvidingItem;
|
||||
import de.ellpeck.naturesaura.reg.ICustomCreativeTab;
|
||||
import net.minecraft.client.color.item.ItemColor;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public class ItemEffectPowder extends ItemImpl implements IColorProvidingItem {
|
||||
import java.util.List;
|
||||
|
||||
public class ItemEffectPowder extends ItemImpl implements IColorProvidingItem, ICustomCreativeTab {
|
||||
|
||||
public ItemEffectPowder() {
|
||||
super("effect_powder");
|
||||
|
@ -46,17 +47,10 @@ public class ItemEffectPowder extends ItemImpl implements IColorProvidingItem {
|
|||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
// TODO effect powder creative tab
|
||||
/* @Override
|
||||
public void fillItemCategory(CreativeModeTab tab, NonNullList<ItemStack> items) {
|
||||
if (this.allowedIn(tab)) {
|
||||
for (var effect : NaturesAuraAPI.EFFECT_POWDERS.keySet()) {
|
||||
var stack = new ItemStack(this);
|
||||
ItemEffectPowder.setEffect(stack, effect);
|
||||
items.add(stack);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
@Override
|
||||
public List<ItemStack> getCreativeTabItems() {
|
||||
return NaturesAuraAPI.EFFECT_POWDERS.keySet().stream().map(e -> ItemEffectPowder.setEffect(new ItemStack(this), e)).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getName(ItemStack stack) {
|
||||
|
@ -68,4 +62,5 @@ public class ItemEffectPowder extends ItemImpl implements IColorProvidingItem {
|
|||
public ItemColor getItemColor() {
|
||||
return (stack, tintIndex) -> NaturesAuraAPI.EFFECT_POWDERS.getOrDefault(ItemEffectPowder.getEffect(stack), 0xFFFFFF);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package de.ellpeck.naturesaura.reg;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ICustomCreativeTab {
|
||||
|
||||
List<ItemStack> getCreativeTabItems();
|
||||
|
||||
}
|
|
@ -7,13 +7,10 @@ import de.ellpeck.naturesaura.blocks.*;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraBloom;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityEnderCrate;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModBlockEntities;
|
||||
import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat;
|
||||
import de.ellpeck.naturesaura.enchant.AuraMendingEnchantment;
|
||||
import de.ellpeck.naturesaura.enchant.ModEnchantments;
|
||||
import de.ellpeck.naturesaura.entities.*;
|
||||
import de.ellpeck.naturesaura.gen.LevelGenAncientTree;
|
||||
import de.ellpeck.naturesaura.gen.LevelGenAuraBloom;
|
||||
import de.ellpeck.naturesaura.gen.LevelGenNetherWartMushroom;
|
||||
import de.ellpeck.naturesaura.gen.ModFeatures;
|
||||
import de.ellpeck.naturesaura.gui.ContainerEnderCrate;
|
||||
import de.ellpeck.naturesaura.gui.ModContainers;
|
||||
import de.ellpeck.naturesaura.items.*;
|
||||
|
@ -22,12 +19,13 @@ import de.ellpeck.naturesaura.potion.ModPotions;
|
|||
import de.ellpeck.naturesaura.potion.PotionBreathless;
|
||||
import de.ellpeck.naturesaura.recipes.EnabledCondition;
|
||||
import de.ellpeck.naturesaura.recipes.ModRecipes;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.item.ArmorItem;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
@ -41,14 +39,16 @@ import net.minecraftforge.fml.common.Mod;
|
|||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegisterEvent;
|
||||
import vazkii.patchouli.api.PatchouliAPI;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public final class ModRegistry {
|
||||
|
||||
public static final Set<IModItem> ALL_ITEMS = new HashSet<>();
|
||||
// we use a list so that the creative tab maintains addition order
|
||||
public static final List<IModItem> ALL_ITEMS = new ArrayList<>();
|
||||
|
||||
@SubscribeEvent
|
||||
public static void register(RegisterEvent event) {
|
||||
|
@ -276,6 +276,7 @@ public final class ModRegistry {
|
|||
Helper.populateObjectHolders(ModEntities.class, event.getForgeRegistry());
|
||||
});
|
||||
|
||||
/*
|
||||
event.register(ForgeRegistries.Keys.FEATURES, h -> {
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "aura_bloom"), new LevelGenAuraBloom(ModBlocks.AURA_BLOOM, 60, false));
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "aura_cactus"), new LevelGenAuraBloom(ModBlocks.AURA_CACTUS, 60, false));
|
||||
|
@ -286,6 +287,7 @@ public final class ModRegistry {
|
|||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "nether_wart_mushroom"), new LevelGenNetherWartMushroom());
|
||||
Helper.populateObjectHolders(ModFeatures.class, event.getForgeRegistry());
|
||||
});
|
||||
*/
|
||||
|
||||
event.register(ForgeRegistries.Keys.RECIPE_TYPES, h -> {
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "altar"), ModRecipes.ALTAR_TYPE);
|
||||
|
@ -301,6 +303,25 @@ public final class ModRegistry {
|
|||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "tree_ritual"), ModRecipes.TREE_RITUAL_SERIALIZER);
|
||||
CraftingHelper.register(new EnabledCondition.Serializer());
|
||||
});
|
||||
|
||||
event.register(BuiltInRegistries.CREATIVE_MODE_TAB.key(), h -> {
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "tab"), CreativeModeTab.builder()
|
||||
.title(Component.translatable("item_group." + NaturesAura.MOD_ID + ".tab"))
|
||||
.icon(() -> new ItemStack(ModItems.GOLD_LEAF))
|
||||
.displayItems((params, output) -> {
|
||||
output.accept(PatchouliAPI.get().getBookStack(PatchouliCompat.BOOK));
|
||||
ModRegistry.ALL_ITEMS.forEach(i -> {
|
||||
if (i instanceof ICustomCreativeTab c) {
|
||||
output.acceptAll(c.getCreativeTabItems());
|
||||
} else if (i instanceof ItemLike l) {
|
||||
if (l.asItem() != Items.AIR)
|
||||
output.accept(l);
|
||||
}
|
||||
});
|
||||
})
|
||||
.build()
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
|
@ -332,4 +353,5 @@ public final class ModRegistry {
|
|||
for (var item : items)
|
||||
helper.register(new ResourceLocation(NaturesAura.MOD_ID, ((IModItem) item).getBaseName()), item);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"itemGroup.naturesaura": "Nature's Aura",
|
||||
"item_group.naturesaura.tab": "Nature's Aura",
|
||||
"block.naturesaura.ancient_log": "Ancient Log",
|
||||
"block.naturesaura.ancient_bark": "Ancient Bark",
|
||||
"block.naturesaura.ancient_leaves": "Ancient Leaves",
|
||||
|
@ -241,4 +241,4 @@
|
|||
"enchantment.naturesaura.aura_mending": "Nature's Mend",
|
||||
"enchantment.naturesaura.aura_mending.desc": "Repairs tools using Aura",
|
||||
"naturesaura:aura_mending.enchant.desc": "Heals the player using Aura"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue