Advertisement
mtga_Kestrel

Overriden Food

Sep 11th, 2024
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.04 KB | None | 0 0
  1. package org.kestrel.ultimahora.Items.Overrides;
  2.  
  3. import net.minecraft.world.food.Foods;
  4. import net.minecraft.world.item.Item;
  5. import net.neoforged.bus.api.IEventBus;
  6. import net.neoforged.neoforge.registries.DeferredRegister;
  7. import org.kestrel.ultimahora.Items.Base.FoodBase;
  8.  
  9. import java.util.Map;
  10. import java.util.function.Supplier;
  11.  
  12. import static org.kestrel.ultimahora.Ultimahora.LOGGER;
  13.  
  14. public class Food {
  15.     public static final DeferredRegister.Items FOOD_ITEMS = DeferredRegister.createItems("minecraft");
  16.  
  17.  
  18.     public static final Supplier<Item> RAW_BEEF = FOOD_ITEMS.register("beef", () -> new FoodBase((new Item.Properties()).food(Foods.BEEF), Map.of(
  19.             FoodBase.PoisonType.ECOLI, true
  20.     )));
  21.  
  22.     public static final Supplier<Item> RAW_PORK = FOOD_ITEMS.register("porkchop", () -> new FoodBase((new Item.Properties()).food(Foods.PORKCHOP), Map.of(
  23.             FoodBase.PoisonType.PARASITE, true
  24.     )));
  25.     public static final Supplier<Item> RAW_CHICKEN = FOOD_ITEMS.register("chicken", () -> new FoodBase((new Item.Properties()).food(Foods.CHICKEN), Map.of(
  26.             FoodBase.PoisonType.SALMONELLA, true
  27.     )));
  28.     public static final Supplier<Item> RAW_MUTTON = FOOD_ITEMS.register("mutton", () -> new FoodBase((new Item.Properties()).food(Foods.MUTTON), Map.of(
  29.             FoodBase.PoisonType.SALMONELLA, true,
  30.             FoodBase.PoisonType.ECOLI, true
  31.     )));
  32.  
  33.  
  34.     public static void Ready(IEventBus event) {
  35.         LOGGER.info("Registering food apperently...");
  36.         FOOD_ITEMS.register(event);
  37.     }
  38. }
  39.  
  40.  
  41. Register:
  42. package org.kestrel.ultimahora.data;
  43.  
  44. import net.minecraft.core.registries.Registries;
  45. import net.minecraft.network.chat.Component;
  46. import net.minecraft.resources.ResourceLocation;
  47. import net.minecraft.world.item.CreativeModeTab;
  48. import net.minecraft.world.item.ItemStack;
  49. import net.neoforged.bus.api.IEventBus;
  50. import net.neoforged.neoforge.registries.DeferredRegister;
  51. import org.kestrel.ultimahora.Items.Overrides.Food;
  52.  
  53. import java.util.function.Supplier;
  54.  
  55. import static org.kestrel.ultimahora.Ultimahora.MODID;
  56.  
  57. public class ULTHCreativeModeTabs {
  58.     public static final DeferredRegister<CreativeModeTab> ULTH_TAB =
  59.             DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MODID);
  60.     static final ResourceLocation foodIcon = ResourceLocation.fromNamespaceAndPath(MODID, "textures/gui/container/creative_inventory/ulth-food.png");
  61.  
  62.  
  63.     public static final Supplier<CreativeModeTab> BASIC = ULTH_TAB.register("ulthbasic", () -> CreativeModeTab.builder()
  64.             .withTabsImage(foodIcon)
  65.             .title(Component.translatable("creativetab.ultimahora.basic"))
  66.             .icon(() -> new ItemStack(Food.RAW_BEEF.get()))
  67.             .displayItems(((itemDisplayParameters, output) -> {
  68.                 Food.FOOD_ITEMS.getEntries().forEach(entry -> {
  69.                     output.accept(entry.get());
  70.                 });
  71.             }))
  72.             .build());
  73.  
  74.     public static void register(IEventBus eventBus) {
  75.         ULTH_TAB.register(eventBus);
  76.     }
  77. }
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement