Compare commits

...

2 commits

Author SHA1 Message Date
Ell
f3e34143cf various small fixes 2023-07-25 14:12:29 +02:00
Ell
778398186c creative tab 2023-07-25 14:04:48 +02:00
20 changed files with 93 additions and 76 deletions

View file

@ -1,6 +1,5 @@
package de.ellpeck.naturesaura; package de.ellpeck.naturesaura;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
@ -128,6 +127,7 @@ public final class Helper {
poseStack.pushPose(); poseStack.pushPose();
poseStack.translate(x, y, 0); poseStack.translate(x, y, 0);
poseStack.scale(scale, scale, scale); poseStack.scale(scale, scale, scale);
graphics.setColor(1, 1, 1, 1);
graphics.renderItem(stack, 0, 0); graphics.renderItem(stack, 0, 0);
graphics.renderItemDecorations(Minecraft.getInstance().font, stack, 0, 0, null); graphics.renderItemDecorations(Minecraft.getInstance().font, stack, 0, 0, null);
poseStack.popPose(); poseStack.popPose();
@ -373,4 +373,5 @@ public final class Helper {
player.level().playSound(null, player.getX() + 0.5, player.getY() + 0.5, player.getZ() + 0.5, SoundEvents.ARROW_HIT_PLAYER, SoundSource.PLAYERS, 0.65F, 1F); player.level().playSound(null, player.getX() + 0.5, player.getY() + 0.5, player.getZ() + 0.5, SoundEvents.ARROW_HIT_PLAYER, SoundSource.PLAYERS, 0.65F, 1F);
return true; return true;
} }
} }

View file

@ -6,15 +6,12 @@ import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.chunk.effect.DrainSpotEffects; import de.ellpeck.naturesaura.chunk.effect.DrainSpotEffects;
import de.ellpeck.naturesaura.compat.Compat; import de.ellpeck.naturesaura.compat.Compat;
import de.ellpeck.naturesaura.events.CommonEvents; import de.ellpeck.naturesaura.events.CommonEvents;
import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.proxy.ClientProxy; import de.ellpeck.naturesaura.proxy.ClientProxy;
import de.ellpeck.naturesaura.proxy.IProxy; import de.ellpeck.naturesaura.proxy.IProxy;
import de.ellpeck.naturesaura.proxy.ServerProxy; import de.ellpeck.naturesaura.proxy.ServerProxy;
import de.ellpeck.naturesaura.recipes.ModRecipes; import de.ellpeck.naturesaura.recipes.ModRecipes;
import de.ellpeck.naturesaura.reg.ModRegistry; 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.ForgeConfigSpec;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.DistExecutor; 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 String MOD_NAME = "Nature's Aura";
public static final Logger LOGGER = LogManager.getLogger(NaturesAura.MOD_NAME); 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; public static NaturesAura instance;
// this causes a classloading issue if it's not wrapped like this // this causes a classloading issue if it's not wrapped like this
@SuppressWarnings("Convert2MethodRef") @SuppressWarnings("Convert2MethodRef")

View file

@ -61,7 +61,7 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<
if (Multiblocks.TREE_RITUAL.isComplete((Level) level, pos)) { if (Multiblocks.TREE_RITUAL.isComplete((Level) level, pos)) {
var saplingStack = new ItemStack(level.getBlockState(pos).getBlock()); var saplingStack = new ItemStack(level.getBlockState(pos).getBlock());
if (!saplingStack.isEmpty()) { if (!saplingStack.isEmpty()) {
for (var recipe : ((Level) level).getRecipeManager().getRecipesFor(ModRecipes.TREE_RITUAL_TYPE, null, null)) { for (var recipe : ((Level) level).getRecipeManager().getRecipesFor(ModRecipes.TREE_RITUAL_TYPE, null, (Level) level)) {
if (recipe.saplingType.test(saplingStack)) { if (recipe.saplingType.test(saplingStack)) {
List<Ingredient> required = new ArrayList<>(Arrays.asList(recipe.ingredients)); List<Ingredient> required = new ArrayList<>(Arrays.asList(recipe.ingredients));
var toPick = new MutableObject<BlockEntityWoodStand>(); var toPick = new MutableObject<BlockEntityWoodStand>();
@ -114,4 +114,5 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<
public void registerTESR() { public void registerTESR() {
BlockEntityRenderers.register(ModBlockEntities.WOOD_STAND, RenderWoodStand::new); BlockEntityRenderers.register(ModBlockEntities.WOOD_STAND, RenderWoodStand::new);
} }
} }

View file

@ -42,7 +42,7 @@ public final class Multiblocks {
// try-catch to prevent blocks that need to have been placed crashing here // try-catch to prevent blocks that need to have been placed crashing here
try { try {
var stack = new ItemStack(state.getBlock()); var stack = new ItemStack(state.getBlock());
return !stack.isEmpty() && level.getRecipeManager().getRecipesFor(ModRecipes.TREE_RITUAL_TYPE, null, null).stream().anyMatch(r -> r.saplingType.test(stack)); return !stack.isEmpty() && level.getRecipeManager().getRecipesFor(ModRecipes.TREE_RITUAL_TYPE, null, level).stream().anyMatch(r -> r.saplingType.test(stack));
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} }

View file

@ -70,7 +70,7 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab
var items = this.level.getEntitiesOfClass(ItemEntity.class, var items = this.level.getEntitiesOfClass(ItemEntity.class,
new AABB(this.worldPosition).inflate(2)); new AABB(this.worldPosition).inflate(2));
for (var recipe : this.level.getRecipeManager().getRecipesFor(ModRecipes.ANIMAL_SPAWNER_TYPE, null, null)) { for (var recipe : this.level.getRecipeManager().getRecipesFor(ModRecipes.ANIMAL_SPAWNER_TYPE, null, this.level)) {
if (recipe.ingredients.length != items.size()) if (recipe.ingredients.length != items.size())
continue; continue;
List<Ingredient> required = new ArrayList<>(Arrays.asList(recipe.ingredients)); List<Ingredient> required = new ArrayList<>(Arrays.asList(recipe.ingredients));

View file

@ -198,7 +198,7 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
} }
private AltarRecipe getRecipeForInput(ItemStack input) { private AltarRecipe getRecipeForInput(ItemStack input) {
for (var recipe : this.level.getRecipeManager().getRecipesFor(ModRecipes.ALTAR_TYPE, null, null)) { for (var recipe : this.level.getRecipeManager().getRecipesFor(ModRecipes.ALTAR_TYPE, null, this.level)) {
if (recipe.input.test(input)) { if (recipe.input.test(input)) {
if (recipe.catalyst == Ingredient.EMPTY) if (recipe.catalyst == Ingredient.EMPTY)
return recipe; return recipe;

View file

@ -38,7 +38,7 @@ public class BlockEntityOfferingTable extends BlockEntityImpl implements ITickab
} }
private OfferingRecipe getRecipe(ItemStack input) { private OfferingRecipe getRecipe(ItemStack input) {
for (var recipe : this.level.getRecipeManager().getRecipesFor(ModRecipes.OFFERING_TYPE, null, null)) for (var recipe : this.level.getRecipeManager().getRecipesFor(ModRecipes.OFFERING_TYPE, null, this.level))
if (recipe.input.test(input)) if (recipe.input.test(input))
return recipe; return recipe;
return null; return null;
@ -139,4 +139,5 @@ public class BlockEntityOfferingTable extends BlockEntityImpl implements ITickab
public IItemHandlerModifiable getItemHandler() { public IItemHandlerModifiable getItemHandler() {
return this.items; return this.items;
} }
} }

View file

@ -32,7 +32,7 @@ import java.util.stream.Collectors;
public class PatchouliCompat implements ICompat { 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<>(); private static final Map<ResourceLocation, IMultiblock> MULTIBLOCKS = new HashMap<>();
public static void addPatchouliMultiblock(ResourceLocation name, String[][] pattern, Object... rawMatchers) { public static void addPatchouliMultiblock(ResourceLocation name, String[][] pattern, Object... rawMatchers) {

View file

@ -269,7 +269,7 @@ public class ClientEvents {
stack.pushPose(); stack.pushPose();
var color = container.getAuraColor(); var color = container.getAuraColor();
RenderSystem.setShaderColor((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 1); graphics.setColor((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 1);
if (width < 80) if (width < 80)
graphics.blit(ClientEvents.OVERLAYS, x + width, y, width, 0, 80 - width, 6, 256, 256); graphics.blit(ClientEvents.OVERLAYS, x + width, y, width, 0, 80 - width, 6, 256, 256);
if (width > 0) if (width > 0)
@ -282,7 +282,7 @@ public class ClientEvents {
graphics.drawString(mc.font, s, conf == 1 ? x / scale : (x + 80) / scale - mc.font.width(s), (y - 7) / scale, color, true); graphics.drawString(mc.font, s, conf == 1 ? x / scale : (x + 80) / scale - mc.font.width(s), (y - 7) / scale, color, true);
stack.popPose(); stack.popPose();
RenderSystem.setShaderColor(1F, 1F, 1F, 1); graphics.setColor(1F, 1F, 1F, 1);
stack.pushPose(); stack.pushPose();
} }
@ -292,7 +292,7 @@ public class ClientEvents {
int conf = ModConfig.instance.auraBarLocation.get(); int conf = ModConfig.instance.auraBarLocation.get();
if (!mc.options.renderDebug && (conf != 2 || !(mc.screen instanceof ChatScreen))) { if (!mc.options.renderDebug && (conf != 2 || !(mc.screen instanceof ChatScreen))) {
var color = IAuraType.forLevel(mc.level).getColor(); var color = IAuraType.forLevel(mc.level).getColor();
RenderSystem.setShaderColor((color >> 16 & 0xFF) / 255F, (color >> 8 & 0xFF) / 255F, (color & 0xFF) / 255F, 1); graphics.setColor((color >> 16 & 0xFF) / 255F, (color >> 8 & 0xFF) / 255F, (color & 0xFF) / 255F, 1);
var totalAmount = IAuraChunk.triangulateAuraInArea(mc.level, mc.player.blockPosition(), 35); var totalAmount = IAuraChunk.triangulateAuraInArea(mc.level, mc.player.blockPosition(), 35);
var totalPercentage = totalAmount / (IAuraChunk.DEFAULT_AURA * 2F); var totalPercentage = totalAmount / (IAuraChunk.DEFAULT_AURA * 2F);
@ -417,7 +417,7 @@ public class ClientEvents {
} }
} }
RenderSystem.setShaderColor(1F, 1F, 1F, 1); graphics.setColor(1F, 1F, 1F, 1);
stack.popPose(); stack.popPose();
} }
@ -443,7 +443,7 @@ public class ClientEvents {
} }
private void drawContainerInfo(GuiGraphics graphics, int stored, int max, int color, Minecraft mc, Window res, int yOffset, String name, String textBelow) { private void drawContainerInfo(GuiGraphics graphics, int stored, int max, int color, Minecraft mc, Window res, int yOffset, String name, String textBelow) {
RenderSystem.setShaderColor((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 1); graphics.setColor((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 1);
var x = res.getGuiScaledWidth() / 2 - 40; var x = res.getGuiScaledWidth() / 2 - 40;
var y = res.getGuiScaledHeight() / 2 + yOffset; var y = res.getGuiScaledHeight() / 2 + yOffset;
@ -459,4 +459,5 @@ public class ClientEvents {
if (textBelow != null) if (textBelow != null)
graphics.drawString(mc.font, textBelow, x + 40 - mc.font.width(textBelow) / 2F, y + 7, color, true); graphics.drawString(mc.font, textBelow, x + 40 - mc.font.width(textBelow) / 2F, y + 7, color, true);
} }
} }

View file

@ -5,17 +5,16 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.data.ItemModelGenerator; import de.ellpeck.naturesaura.data.ItemModelGenerator;
import de.ellpeck.naturesaura.reg.IColorProvidingItem; import de.ellpeck.naturesaura.reg.IColorProvidingItem;
import de.ellpeck.naturesaura.reg.ICustomCreativeTab;
import de.ellpeck.naturesaura.reg.ICustomItemModel; import de.ellpeck.naturesaura.reg.ICustomItemModel;
import net.minecraft.client.color.item.ItemColor; import net.minecraft.client.color.item.ItemColor;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList;
import net.minecraft.core.dispenser.DefaultDispenseItemBehavior; import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ClipContext; 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.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; 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) { public ItemAuraBottle(Item emptyBottle) {
super("aura_bottle"); super("aura_bottle");
@ -52,17 +53,10 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu
}); });
} }
// TODO aura bottle creative @Override
/* @Override public List<ItemStack> getCreativeTabItems() {
public void fillItemCategory(CreativeModeTab tab, NonNullList<ItemStack> items) { return NaturesAuraAPI.AURA_TYPES.values().stream().map(t -> ItemAuraBottle.setType(new ItemStack(this), t)).toList();
if (this.allowedIn(tab)) { }
for (var type : NaturesAuraAPI.AURA_TYPES.values()) {
var stack = new ItemStack(this);
ItemAuraBottle.setType(stack, type);
items.add(stack);
}
}
}*/
@Override @Override
public Component getName(ItemStack stack) { public Component getName(ItemStack stack) {

View file

@ -7,6 +7,7 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.container.ItemAuraContainer; import de.ellpeck.naturesaura.api.aura.container.ItemAuraContainer;
import de.ellpeck.naturesaura.api.render.ITrinketItem; import de.ellpeck.naturesaura.api.render.ITrinketItem;
import de.ellpeck.naturesaura.enchant.ModEnchantments; import de.ellpeck.naturesaura.enchant.ModEnchantments;
import de.ellpeck.naturesaura.reg.ICustomCreativeTab;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.texture.OverlayTexture;
@ -26,8 +27,10 @@ import net.minecraftforge.common.util.LazyOptional;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; 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; private final int capacity;
@ -61,19 +64,17 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem {
} }
} }
// TODO creative tabs for items with variations @Override
/* @Override public List<ItemStack> getCreativeTabItems() {
public void fillItemCategory(CreativeModeTab tab, NonNullList<ItemStack> items) { var ret = new ArrayList<ItemStack>();
if (this.allowedIn(tab)) { ret.add(new ItemStack(this));
items.add(new ItemStack(this)); var full = new ItemStack(this);
full.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).ifPresent(container -> {
var stack = new ItemStack(this); container.storeAura(container.getMaxAura(), false);
stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).ifPresent(container -> { ret.add(full);
container.storeAura(container.getMaxAura(), false); });
items.add(stack); return ret;
}); }
}
}*/
@Override @Override
public boolean isBarVisible(ItemStack stack) { public boolean isBarVisible(ItemStack stack) {

View file

@ -3,18 +3,19 @@ package de.ellpeck.naturesaura.items;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.entities.EntityEffectInhibitor; import de.ellpeck.naturesaura.entities.EntityEffectInhibitor;
import de.ellpeck.naturesaura.reg.IColorProvidingItem; import de.ellpeck.naturesaura.reg.IColorProvidingItem;
import de.ellpeck.naturesaura.reg.ICustomCreativeTab;
import net.minecraft.client.color.item.ItemColor; import net.minecraft.client.color.item.ItemColor;
import net.minecraft.core.NonNullList;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.item.context.UseOnContext;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; 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() { public ItemEffectPowder() {
super("effect_powder"); super("effect_powder");
@ -46,17 +47,10 @@ public class ItemEffectPowder extends ItemImpl implements IColorProvidingItem {
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} }
// TODO effect powder creative tab @Override
/* @Override public List<ItemStack> getCreativeTabItems() {
public void fillItemCategory(CreativeModeTab tab, NonNullList<ItemStack> items) { return NaturesAuraAPI.EFFECT_POWDERS.keySet().stream().map(e -> ItemEffectPowder.setEffect(new ItemStack(this), e)).toList();
if (this.allowedIn(tab)) { }
for (var effect : NaturesAuraAPI.EFFECT_POWDERS.keySet()) {
var stack = new ItemStack(this);
ItemEffectPowder.setEffect(stack, effect);
items.add(stack);
}
}
}*/
@Override @Override
public Component getName(ItemStack stack) { public Component getName(ItemStack stack) {
@ -68,4 +62,5 @@ public class ItemEffectPowder extends ItemImpl implements IColorProvidingItem {
public ItemColor getItemColor() { public ItemColor getItemColor() {
return (stack, tintIndex) -> NaturesAuraAPI.EFFECT_POWDERS.getOrDefault(ItemEffectPowder.getEffect(stack), 0xFFFFFF); return (stack, tintIndex) -> NaturesAuraAPI.EFFECT_POWDERS.getOrDefault(ItemEffectPowder.getEffect(stack), 0xFFFFFF);
} }
} }

View file

@ -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();
}

View file

@ -7,13 +7,10 @@ import de.ellpeck.naturesaura.blocks.*;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraBloom; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraBloom;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityEnderCrate; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityEnderCrate;
import de.ellpeck.naturesaura.blocks.tiles.ModBlockEntities; 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.AuraMendingEnchantment;
import de.ellpeck.naturesaura.enchant.ModEnchantments; import de.ellpeck.naturesaura.enchant.ModEnchantments;
import de.ellpeck.naturesaura.entities.*; 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.ContainerEnderCrate;
import de.ellpeck.naturesaura.gui.ModContainers; import de.ellpeck.naturesaura.gui.ModContainers;
import de.ellpeck.naturesaura.items.*; 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.potion.PotionBreathless;
import de.ellpeck.naturesaura.recipes.EnabledCondition; import de.ellpeck.naturesaura.recipes.EnabledCondition;
import de.ellpeck.naturesaura.recipes.ModRecipes; 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.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory; import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.*;
import net.minecraft.world.item.BlockItem; import net.minecraft.world.level.ItemLike;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; 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.items.IItemHandler;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegisterEvent; import net.minecraftforge.registries.RegisterEvent;
import vazkii.patchouli.api.PatchouliAPI;
import java.util.HashSet; import java.util.ArrayList;
import java.util.Set; import java.util.List;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public final class ModRegistry { 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 @SubscribeEvent
public static void register(RegisterEvent event) { public static void register(RegisterEvent event) {
@ -276,6 +276,7 @@ public final class ModRegistry {
Helper.populateObjectHolders(ModEntities.class, event.getForgeRegistry()); Helper.populateObjectHolders(ModEntities.class, event.getForgeRegistry());
}); });
/*
event.register(ForgeRegistries.Keys.FEATURES, h -> { 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_bloom"), new LevelGenAuraBloom(ModBlocks.AURA_BLOOM, 60, false));
h.register(new ResourceLocation(NaturesAura.MOD_ID, "aura_cactus"), new LevelGenAuraBloom(ModBlocks.AURA_CACTUS, 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()); h.register(new ResourceLocation(NaturesAura.MOD_ID, "nether_wart_mushroom"), new LevelGenNetherWartMushroom());
Helper.populateObjectHolders(ModFeatures.class, event.getForgeRegistry()); Helper.populateObjectHolders(ModFeatures.class, event.getForgeRegistry());
}); });
*/
event.register(ForgeRegistries.Keys.RECIPE_TYPES, h -> { event.register(ForgeRegistries.Keys.RECIPE_TYPES, h -> {
h.register(new ResourceLocation(NaturesAura.MOD_ID, "altar"), ModRecipes.ALTAR_TYPE); 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); h.register(new ResourceLocation(NaturesAura.MOD_ID, "tree_ritual"), ModRecipes.TREE_RITUAL_SERIALIZER);
CraftingHelper.register(new EnabledCondition.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() { public static void init() {
@ -332,4 +353,5 @@ public final class ModRegistry {
for (var item : items) for (var item : items)
helper.register(new ResourceLocation(NaturesAura.MOD_ID, ((IModItem) item).getBaseName()), item); helper.register(new ResourceLocation(NaturesAura.MOD_ID, ((IModItem) item).getBaseName()), item);
} }
} }

View file

@ -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_log": "Ancient Log",
"block.naturesaura.ancient_bark": "Ancient Bark", "block.naturesaura.ancient_bark": "Ancient Bark",
"block.naturesaura.ancient_leaves": "Ancient Leaves", "block.naturesaura.ancient_leaves": "Ancient Leaves",