Skip to content

Commit

Permalink
Creative tab adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Adubbz committed Dec 10, 2022
1 parent d2b26e3 commit dfdccb6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
7 changes: 2 additions & 5 deletions src/main/java/biomesoplenty/api/item/BOPItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public class BOPItems
public static RegistryObject<Item> BOP_ICON;

public static RegistryObject<Item> ROSE_QUARTZ_SHARD;

public static RegistryObject<Item> BLOOD_BUCKET;
public static RegistryObject<Item> MUSIC_DISC_WANDERER;
public static RegistryObject<Item> FIR_SIGN;
public static RegistryObject<Item> REDWOOD_SIGN;
public static RegistryObject<Item> CHERRY_SIGN;
Expand Down Expand Up @@ -47,8 +48,4 @@ public class BOPItems
public static RegistryObject<Item> UMBRAN_CHEST_BOAT;
public static RegistryObject<Item> HELLBARK_BOAT;
public static RegistryObject<Item> HELLBARK_CHEST_BOAT;

public static RegistryObject<Item> MUSIC_DISC_WANDERER;

public static RegistryObject<Item> BLOOD_BUCKET;
}
30 changes: 16 additions & 14 deletions src/main/java/biomesoplenty/core/BiomesOPlenty.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import biomesoplenty.init.*;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.EntityType;
Expand Down Expand Up @@ -129,38 +130,39 @@ private void loadComplete(final FMLLoadCompleteEvent event)
private void registerTab(CreativeModeTabEvent.Register event)
{
List<RegistryObject<Item>> itemBlacklist = List.of(BOPItems.BOP_ICON);
List<RegistryObject<Item>> blockBlacklist = List.of();
List<RegistryObject<Block>> blockBlacklist = List.of(BOPBlocks.BLOOD);

event.registerCreativeModeTab(new ResourceLocation(BiomesOPlenty.MOD_ID, "main"), builder -> {
builder.icon(() -> new ItemStack(BOPItems.BOP_ICON.get()))
.title(Component.translatable("itemGroup.biomesoplenty"))
.displayItems((featureFlags, output, hasOp) -> {
// Add items
for (Field field : BOPItems.class.getFields())
// Add blocks
for (Field field : BOPBlocks.class.getFields())
{
if (field.getType() != RegistryObject.class) continue;

// Don't add potted things to our tab
if (field.getName().startsWith("POTTED_")) continue;

try
{
RegistryObject<Item> item = (RegistryObject)field.get(null);
if (!itemBlacklist.contains(item))
output.accept(new ItemStack(item.get()));
RegistryObject<Block> block = (RegistryObject)field.get(null);
if (!blockBlacklist.contains(block))
output.accept(new ItemStack(block.get()));
}
catch (IllegalAccessException e) {}
}

// Add blocks
for (Field field : BOPBlocks.class.getFields())
// Add items
for (Field field : BOPItems.class.getFields())
{
if (field.getType() != RegistryObject.class) continue;

// Don't add potted things to our tab
if (field.getName().startsWith("POTTED_")) continue;

try
{
RegistryObject<Block> block = (RegistryObject)field.get(null);
if (!blockBlacklist.contains(block))
output.accept(new ItemStack(block.get()));
RegistryObject<Item> item = (RegistryObject)field.get(null);
if (!itemBlacklist.contains(item))
output.accept(new ItemStack(item.get()));
}
catch (IllegalAccessException e) {}
}
Expand Down

0 comments on commit dfdccb6

Please sign in to comment.