Skip to content

Commit

Permalink
Creative tab sorting part 890342
Browse files Browse the repository at this point in the history
  • Loading branch information
Vazkii committed Dec 4, 2023
1 parent b5ff42d commit 9561ae5
Show file tree
Hide file tree
Showing 16 changed files with 63 additions and 21 deletions.
8 changes: 8 additions & 0 deletions src/main/java/org/violetmoon/quark/base/handler/MiscUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import net.minecraft.world.entity.ai.goal.GoalSelector;
import net.minecraft.world.entity.ai.goal.WrappedGoal;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.level.ChunkPos;
Expand Down Expand Up @@ -74,6 +75,13 @@ public class MiscUtil {
Direction.EAST
};

public static final DyeColor[] CREATIVE_COLOR_ORDER = new DyeColor[] {
DyeColor.WHITE, DyeColor.LIGHT_GRAY, DyeColor.GRAY, DyeColor.BLACK,
DyeColor.BROWN, DyeColor.RED, DyeColor.ORANGE, DyeColor.YELLOW,
DyeColor.LIME, DyeColor.GREEN, DyeColor.CYAN, DyeColor.LIGHT_BLUE,
DyeColor.BLUE, DyeColor.PURPLE, DyeColor.MAGENTA, DyeColor.PINK
};

public static BooleanProperty directionProperty(Direction direction) {
return switch (direction) {
case DOWN -> BlockStateProperties.DOWN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.RecordItem;
import org.violetmoon.quark.base.Quark;
Expand All @@ -29,7 +30,7 @@ public QuarkMusicDiscItem(int comparatorValue, Supplier<SoundEvent> sound, Strin
this.module = module;
this.isAmbient = lengthInTicks == Integer.MAX_VALUE;
this.soundSupplier = sound;
CreativeTabManager.addToCreativeTab(CreativeModeTabs.TOOLS_AND_UTILITIES, this);
CreativeTabManager.addToCreativeTabNextTo(CreativeModeTabs.TOOLS_AND_UTILITIES, this, Items.MUSIC_DISC_RELIC, false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.HitResult;
Expand All @@ -39,7 +40,7 @@ public QuarkBoatItem(String type, ZetaModule module, boolean chest) {

this.type = type;
this.chest = chest;
CreativeTabManager.addToCreativeTab(CreativeModeTabs.TOOLS_AND_UTILITIES, this);
CreativeTabManager.addToCreativeTabNextTo(CreativeModeTabs.TOOLS_AND_UTILITIES, this, Blocks.RAIL, true);
}

// Vanilla copy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
Expand Down Expand Up @@ -71,7 +72,7 @@ public StoolBlock(ZetaModule module, DyeColor color) {
.noOcclusion());

registerDefaultState(stateDefinition.any().setValue(WATERLOGGED, false).setValue(BIG, false).setValue(SAT_IN, false));
setCreativeTab(CreativeModeTabs.COLORED_BLOCKS);
setCreativeTab(CreativeModeTabs.COLORED_BLOCKS, Blocks.PINK_BED, false);
}

public void blockClicked(Level world, BlockPos pos) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public VariantChestBlock(String prefix, String type, ZetaModule module, Supplier
super(props, supplier);
String resloc = (prefix != null ? prefix + "_" : "") + type + "_chest";
module.zeta.registry.registerBlock(this, resloc, true);
CreativeTabManager.addToCreativeTabNextTo(CreativeModeTabs.FUNCTIONAL_BLOCKS, this, Blocks.CHEST, false);

this.module = module;
this.type = type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public VariantTrappedChestBlock(String prefix, String type, ZetaModule module, S
String resloc = (prefix != null ? prefix + "_" : "") + type + "_trapped_chest";

module.zeta.registry.registerBlock(this, resloc, true);
CreativeTabManager.addToCreativeTabNextTo(CreativeModeTabs.REDSTONE_BLOCKS, this, Blocks.TRAPPED_CHEST, false);

this.module = module;
this.type = type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SoundType;

import org.violetmoon.quark.base.handler.MiscUtil;
import org.violetmoon.zeta.block.IZetaBlock;
import org.violetmoon.zeta.block.ZetaGlassBlock;
import org.violetmoon.zeta.block.ZetaInheritedPaneBlock;
Expand All @@ -27,7 +28,7 @@ public final void register(ZRegister event) {
new ZetaInheritedPaneBlock((IZetaBlock) new ZetaGlassBlock("framed_glass", this, false, props).setCreativeTab(CreativeModeTabs.COLORED_BLOCKS, Blocks.GLASS, false))
.setCreativeTab(CreativeModeTabs.COLORED_BLOCKS, Blocks.GLASS_PANE, false);

for(DyeColor dye : DyeColor.values())
for(DyeColor dye : MiscUtil.CREATIVE_COLOR_ORDER)
new ZetaInheritedPaneBlock((IZetaBlock) new ZetaGlassBlock(dye.getName() + "_framed_glass", this, true, props).setCreativeTab(CreativeModeTabs.COLORED_BLOCKS, Blocks.PINK_STAINED_GLASS, true))
.setCreativeTab(CreativeModeTabs.COLORED_BLOCKS, Blocks.PINK_STAINED_GLASS_PANE, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.core.registries.Registries;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.handler.MiscUtil;
import org.violetmoon.quark.content.building.block.StoolBlock;
import org.violetmoon.quark.content.building.client.render.entity.StoolEntityRenderer;
import org.violetmoon.quark.content.building.entity.Stool;
Expand All @@ -13,6 +14,7 @@
import org.violetmoon.zeta.event.play.entity.player.ZRightClickBlock;
import org.violetmoon.zeta.module.ZetaLoadModule;
import org.violetmoon.zeta.module.ZetaModule;
import org.violetmoon.zeta.registry.CreativeTabManager;
import org.violetmoon.zeta.util.Hint;

import net.minecraft.client.renderer.entity.EntityRenderers;
Expand All @@ -37,8 +39,10 @@ public class StoolsModule extends ZetaModule {

@LoadEvent
public final void register(ZRegister event) {
for(DyeColor dye : DyeColor.values())
CreativeTabManager.daisyChain();
for(DyeColor dye : MiscUtil.CREATIVE_COLOR_ORDER)
new StoolBlock(this, dye);
CreativeTabManager.endDaisyChain();

stoolEntity = EntityType.Builder.of(Stool::new, MobCategory.MISC)
.sized(6F / 16F, 0.5F)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.world.entity.animal.horse.AbstractChestedHorse;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.ServerLevelAccessor;
Expand Down Expand Up @@ -48,7 +49,7 @@
import org.violetmoon.zeta.event.play.entity.player.ZPlayerInteract;
import org.violetmoon.zeta.module.ZetaLoadModule;
import org.violetmoon.zeta.module.ZetaModule;

import org.violetmoon.zeta.registry.CreativeTabManager;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.function.BooleanSupplier;
Expand Down Expand Up @@ -114,6 +115,9 @@ private void makeChestBlocks(ZetaModule module, String name, Block base, Boolean
trappedChests.add(trappedChest);
trappedChestMappings.put(TagKey.create(Registries.STRUCTURE, new ResourceLocation(Quark.MOD_ID, name + "_chest_structures")), trappedChest);

CreativeTabManager.addToCreativeTabNextTo(CreativeModeTabs.FUNCTIONAL_BLOCKS, regularChest, Blocks.CHEST, false);
CreativeTabManager.addToCreativeTabNextTo(CreativeModeTabs.REDSTONE_BLOCKS, trappedChest, Blocks.TRAPPED_CHEST, false);

ILootrIntegration.INSTANCE.makeChestBlocks(module, name, base, condition, regularChest, trappedChest);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.levelgen.Heightmap.Types;
Expand All @@ -43,6 +44,7 @@
import org.violetmoon.zeta.item.ZetaMobBucketItem;
import org.violetmoon.zeta.module.ZetaLoadModule;
import org.violetmoon.zeta.module.ZetaModule;
import org.violetmoon.zeta.registry.CreativeTabManager;
import org.violetmoon.zeta.util.Hint;

/**
Expand Down Expand Up @@ -73,19 +75,21 @@ public class CrabsModule extends ZetaModule {

@LoadEvent
public final void register(ZRegister event) {
CreativeTabManager.daisyChain();
crab_leg = new ZetaItem("crab_leg", this, new Item.Properties()
.food(new FoodProperties.Builder()
.meat()
.nutrition(1)
.saturationMod(0.3F)
.build())).setCreativeTab(CreativeModeTabs.FOOD_AND_DRINKS);
.build())).setCreativeTab(CreativeModeTabs.FOOD_AND_DRINKS, Items.PUFFERFISH, false);

Item cookedCrabLeg = new ZetaItem("cooked_crab_leg", this, new Item.Properties()
.food(new FoodProperties.Builder()
.meat()
.nutrition(8)
.saturationMod(0.8F)
.build())).setCreativeTab(CreativeModeTabs.FOOD_AND_DRINKS);
CreativeTabManager.endDaisyChain();

crab_shell = new ZetaItem("crab_shell", this, new Item.Properties())
.setCondition(() -> enableBrewing).setCreativeTab(CreativeModeTabs.INGREDIENTS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.BlockHitResult;
Expand All @@ -31,7 +32,7 @@ public class AbacusItem extends ZetaItem {

public AbacusItem(ZetaModule module) {
super("abacus", module, new Item.Properties().stacksTo(1));
CreativeTabManager.addToCreativeTab(CreativeModeTabs.TOOLS_AND_UTILITIES, this);
CreativeTabManager.addToCreativeTabNextTo(CreativeModeTabs.TOOLS_AND_UTILITIES, this, Items.SPYGLASS, true);
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import org.violetmoon.zeta.block.ZetaGlassBlock;
import org.violetmoon.zeta.module.ZetaModule;
Expand All @@ -19,7 +20,7 @@ public class DirtyGlassBlock extends ZetaGlassBlock {

public DirtyGlassBlock(String regname, ZetaModule module, Properties properties) {
super(regname, module, true, properties);
setCreativeTab(CreativeModeTabs.COLORED_BLOCKS);
setCreativeTab(CreativeModeTabs.COLORED_BLOCKS, Blocks.TINTED_GLASS, false);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.MapColor;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.handler.MiscUtil;
import org.violetmoon.quark.content.tweaks.block.DirtyGlassBlock;
import org.violetmoon.zeta.block.ZetaBlock;
import org.violetmoon.zeta.block.ZetaInheritedPaneBlock;
Expand All @@ -19,6 +21,7 @@
import org.violetmoon.zeta.item.ZetaItem;
import org.violetmoon.zeta.module.ZetaLoadModule;
import org.violetmoon.zeta.module.ZetaModule;
import org.violetmoon.zeta.registry.CreativeTabManager;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -41,16 +44,20 @@ public class GlassShardModule extends ZetaModule {

@LoadEvent
public final void register(ZRegister event) {
CreativeTabManager.daisyChain();
dirtyGlass = (ZetaBlock) new DirtyGlassBlock("dirty_glass", this,
Block.Properties.of().mapColor(MapColor.COLOR_BROWN).strength(0.3F).sound(SoundType.GLASS));

new ZetaInheritedPaneBlock(dirtyGlass).setCreativeTab(CreativeModeTabs.COLORED_BLOCKS);
CreativeTabManager.endDaisyChain();

clearShard = new ZetaItem("clear_shard", this, new Item.Properties()).setCreativeTab(CreativeModeTabs.INGREDIENTS);
CreativeTabManager.daisyChain();
clearShard = new ZetaItem("clear_shard", this, new Item.Properties()).setCreativeTab(CreativeModeTabs.INGREDIENTS, Items.PINK_DYE, false);
dirtyShard = new ZetaItem("dirty_shard", this, new Item.Properties()).setCreativeTab(CreativeModeTabs.INGREDIENTS);

for(DyeColor color : DyeColor.values())
for(DyeColor color : MiscUtil.CREATIVE_COLOR_ORDER)
shardColors.put(color, new ZetaItem(color.getSerializedName() + "_shard", this, new Item.Properties()).setCreativeTab(CreativeModeTabs.INGREDIENTS));
CreativeTabManager.endDaisyChain();
}

@LoadEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import org.violetmoon.quark.content.world.module.AncientWoodModule;
import org.violetmoon.zeta.item.ZetaItem;
Expand All @@ -19,7 +20,7 @@ public class AncientFruitItem extends ZetaItem {
public AncientFruitItem(ZetaModule module) {
super("ancient_fruit", module, new Item.Properties()
.food(new FoodProperties.Builder().nutrition(4).saturationMod(0.3F).alwaysEat().build()));
CreativeTabManager.addToCreativeTab(CreativeModeTabs.FOOD_AND_DRINKS, this);
CreativeTabManager.addToCreativeTabNextTo(CreativeModeTabs.FOOD_AND_DRINKS, this, Items.CHORUS_FRUIT, false);
}

@Override
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/org/violetmoon/zeta/item/IZetaItem.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.violetmoon.zeta.item;

import org.violetmoon.zeta.module.IDisableable;
import org.violetmoon.zeta.registry.CreativeTabManager;

import net.minecraft.resources.ResourceKey;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import org.violetmoon.zeta.module.IDisableable;
import org.violetmoon.zeta.registry.CreativeTabManager;
import net.minecraft.world.level.ItemLike;

public interface IZetaItem extends IDisableable<IZetaItem> {

Expand All @@ -17,5 +19,12 @@ default Item setCreativeTab(ResourceKey<CreativeModeTab> tab) {
CreativeTabManager.addToCreativeTab(tab, i);
return i;
}

default Item setCreativeTab(ResourceKey<CreativeModeTab> tab, ItemLike parent, boolean behindParent) {
Item i = getItem();
CreativeTabManager.addToCreativeTabNextTo(tab, i, parent, behindParent);

return i;
}

}
11 changes: 6 additions & 5 deletions src/main/java/org/violetmoon/zeta/item/ZetaSignItem.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package org.violetmoon.zeta.item;

import java.util.function.BooleanSupplier;

import org.violetmoon.zeta.module.ZetaModule;

import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.SignItem;
import net.minecraft.world.level.block.Block;
import org.violetmoon.zeta.module.ZetaModule;
import org.violetmoon.zeta.registry.CreativeTabManager;

import java.util.function.BooleanSupplier;
import net.minecraft.world.level.block.Blocks;

public class ZetaSignItem extends SignItem implements IZetaItem {

Expand All @@ -19,7 +20,7 @@ public ZetaSignItem(ZetaModule module, Block sign, Block wallSign) {

String resloc = module.zeta.registryUtil.inherit(sign, "%s");
module.zeta.registry.registerItem(this, resloc);
CreativeTabManager.addToCreativeTab(CreativeModeTabs.FUNCTIONAL_BLOCKS, this);
setCreativeTab(CreativeModeTabs.FUNCTIONAL_BLOCKS, Blocks.CHEST, true);
this.module = module;
}

Expand Down

0 comments on commit 9561ae5

Please sign in to comment.