add to creative menu with own tab
This commit is contained in:
		
							parent
							
								
									b70d18e826
								
							
						
					
					
						commit
						fe45e71669
					
				@ -38,7 +38,7 @@ mod_name=Networked Chests
 | 
			
		||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
 | 
			
		||||
mod_license=All Rights Reserved
 | 
			
		||||
# The mod version. See https://semver.org/
 | 
			
		||||
mod_version=0.1.0
 | 
			
		||||
mod_version=0.1.1
 | 
			
		||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
 | 
			
		||||
# This should match the base package used for the mod sources.
 | 
			
		||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
 | 
			
		||||
 | 
			
		||||
@ -17,5 +17,6 @@ public class Networked_chests {
 | 
			
		||||
        MinecraftForge.EVENT_BUS.register(this);
 | 
			
		||||
 | 
			
		||||
        items.register(modEventBus);
 | 
			
		||||
        creativeTab.register(modEventBus);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										37
									
								
								src/main/java/com/jenny/networked_chests/creativeTab.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								src/main/java/com/jenny/networked_chests/creativeTab.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,37 @@
 | 
			
		||||
package com.jenny.networked_chests;
 | 
			
		||||
 | 
			
		||||
import com.jenny.networked_chests.items.items;
 | 
			
		||||
import net.minecraft.core.registries.Registries;
 | 
			
		||||
import net.minecraft.network.chat.Component;
 | 
			
		||||
import net.minecraft.world.item.CreativeModeTab;
 | 
			
		||||
import net.minecraft.world.item.CreativeModeTabs;
 | 
			
		||||
import net.minecraft.world.item.Item;
 | 
			
		||||
import net.minecraft.world.item.ItemStack;
 | 
			
		||||
import net.minecraftforge.eventbus.api.IEventBus;
 | 
			
		||||
import net.minecraftforge.registries.DeferredRegister;
 | 
			
		||||
import net.minecraftforge.registries.RegistryObject;
 | 
			
		||||
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
 | 
			
		||||
import static com.jenny.networked_chests.Networked_chests.MODID;
 | 
			
		||||
 | 
			
		||||
public class creativeTab {
 | 
			
		||||
    public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MODID);
 | 
			
		||||
    public static final RegistryObject<CreativeModeTab> CREATIVE_TAB = CREATIVE_MODE_TABS.register("networked_chests", () -> CreativeModeTab.builder().withTabsBefore(CreativeModeTabs.SPAWN_EGGS).icon(() -> items.CHEST_INTERFACE.get().getDefaultInstance()).displayItems((parameters, output) -> {
 | 
			
		||||
        output.acceptAll(Arrays.stream(getItems()).toList());
 | 
			
		||||
    }).title(Component.literal("Networked Chests")).build());
 | 
			
		||||
 | 
			
		||||
    public static void register(IEventBus bus) {
 | 
			
		||||
        CREATIVE_MODE_TABS.register(bus);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static ItemStack[] getItems() {
 | 
			
		||||
        ItemStack[] ret = new ItemStack[items.ITEMS.getEntries().size()];
 | 
			
		||||
        int i = 0;
 | 
			
		||||
        for (RegistryObject<Item> item : items.ITEMS.getEntries()) {
 | 
			
		||||
            ret[i] = item.get().getDefaultInstance();
 | 
			
		||||
            i++;
 | 
			
		||||
        }
 | 
			
		||||
        return ret;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user