Skip to content

Commit

Permalink
Set Creative Tab icon to one of our blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Griefed committed Nov 11, 2023
1 parent d1aa4ea commit 855fd64
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
8 changes: 3 additions & 5 deletions common/src/main/java/de/griefed/addemall/CommonClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
import de.griefed.addemall.block.GeneratedModBlocks;
import de.griefed.addemall.item.GeneratedModItems;
import de.griefed.addemall.platform.Services;
import net.minecraft.core.Registry;
import net.minecraft.network.chat.Component;
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.TooltipFlag;

import java.util.List;
Expand Down Expand Up @@ -35,9 +33,9 @@ public static void init() {
}

/*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/
GeneratedModBlocks.loadClass();
GeneratedModItems.loadClass();
/*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/
GeneratedModBlocks.loadClass();
GeneratedModItems.loadClass();
/*###GENERATED CODE - DO NOT EDIT - MANUALLY EDITED CODE WILL BE LOST###*/
}

public static void onItemTooltip(ItemStack stack, TooltipFlag context, List<Component> tooltip) {
Expand Down
22 changes: 11 additions & 11 deletions fabric/src/main/java/de/griefed/addemall/AddEmAllFabric.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package de.griefed.addemall;

import de.griefed.addemall.block.GeneratedModBlocks;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -15,17 +15,17 @@ public class AddEmAllFabric implements ModInitializer {
public static final String MOD_ID = "addemall";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);

public static final CreativeModeTab TAB_ADDEMALL = FabricItemGroupBuilder.build(
new ResourceLocation(Constants.MOD_ID, "tab"),
() -> new ItemStack(Items.DIAMOND)
);
public static final CreativeModeTab TAB_ADDEMALL = FabricItemGroupBuilder.build(
new ResourceLocation(Constants.MOD_ID, "tab"),
() -> new ItemStack(GeneratedModBlocks.METAL_PLATING_2_ITEM.get())
);

@Override
public void onInitialize() {
Constants.LOG.info("Hello world!");
LOGGER.info("Hello Fabric World! I'm gonna AddEmAll!");
@Override
public void onInitialize() {
Constants.LOG.info("Hello world!");
LOGGER.info("Hello Fabric World! I'm gonna AddEmAll!");
CommonClass.init();

ItemTooltipCallback.EVENT.register(CommonClass::onItemTooltip);
}
ItemTooltipCallback.EVENT.register(CommonClass::onItemTooltip);
}
}
12 changes: 6 additions & 6 deletions forge/src/main/java/de/griefed/addemall/AddEmAllForge.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package de.griefed.addemall;

import com.mojang.logging.LogUtils;
import de.griefed.addemall.block.GeneratedModBlocks;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
Expand All @@ -22,10 +22,10 @@ public class AddEmAllForge {
private static final Logger LOGGER = LogUtils.getLogger();

public static final CreativeModeTab TAB_ADDEMALL = new CreativeModeTab(Constants.MOD_ID + ".tab") {
@Override
public @NotNull ItemStack makeIcon() {
return new ItemStack(Items.DIAMOND);
}
@Override
public @NotNull ItemStack makeIcon() {
return new ItemStack(GeneratedModBlocks.METAL_PLATING_2_ITEM.get());
}
};

// Very Important Comment
Expand Down

0 comments on commit 855fd64

Please sign in to comment.