TheOnlyTails

Main mod class kotlin

Oct 16th, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 4.59 KB | None | 0 0
  1. @file:Suppress("DEPRECATION")
  2.  
  3. package com.github.theonlytails.rubymod
  4.  
  5. import com.github.theonlytails.rubymod.client.gui.RubyBarrelScreen
  6. import com.github.theonlytails.rubymod.client.render.RubySheepRenderer
  7. import com.github.theonlytails.rubymod.containers.RubyBarrelContainer
  8. import com.github.theonlytails.rubymod.entities.RubySheepEntity
  9. import com.github.theonlytails.rubymod.registries.*
  10. import net.minecraft.block.ComposterBlock
  11. import net.minecraft.client.gui.ScreenManager
  12. import net.minecraft.client.renderer.RenderType
  13. import net.minecraft.client.renderer.RenderTypeLookup
  14. import net.minecraft.client.renderer.entity.EntityRendererManager
  15. import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes
  16. import net.minecraft.entity.player.PlayerInventory
  17. import net.minecraft.item.*
  18. import net.minecraft.potion.PotionBrewing
  19. import net.minecraft.potion.Potions
  20. import net.minecraft.util.text.ITextComponent
  21. import net.minecraft.world.biome.Biome
  22. import net.minecraftforge.common.MinecraftForge
  23. import net.minecraftforge.event.RegistryEvent.Register
  24. import net.minecraftforge.eventbus.api.SubscribeEvent
  25. import net.minecraftforge.fml.DeferredWorkQueue
  26. import net.minecraftforge.fml.client.registry.RenderingRegistry
  27. import net.minecraftforge.fml.common.Mod
  28. import net.minecraftforge.fml.common.Mod.EventBusSubscriber
  29. import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent
  30. import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent
  31. import org.apache.logging.log4j.LogManager
  32. import thedarkcolour.kotlinforforge.KotlinModLoadingContext.Companion.get
  33. import thedarkcolour.kotlinforforge.forge.FORGE_BUS
  34. import thedarkcolour.kotlinforforge.forge.MOD_BUS
  35.  
  36. @EventBusSubscriber(modid = RubyMod.MOD_ID, bus = EventBusSubscriber.Bus.MOD)
  37. @Mod("rubymod")
  38. object RubyMod {
  39.  
  40.     const val MOD_ID = "rubymod"
  41.     val RUBY_TAB: ItemGroup = object : ItemGroup("ruby_tab") {
  42.         override fun createIcon(): ItemStack {
  43.             return ItemStack(ItemRegistry.RUBY)
  44.         }
  45.     }
  46.     val RUBY_TAB_PROPERTY: Item.Properties = Item.Properties().group(RUBY_TAB)
  47.  
  48.     @Suppress("unused")
  49.     private val LOGGER = LogManager.getLogger()
  50.  
  51.     init {
  52.         val modEventBus = get().getKEventBus()
  53.  
  54.         FORGE_BUS.addListener { event: FMLCommonSetupEvent -> setup(event) }
  55.         MOD_BUS.addListener { event: FMLClientSetupEvent -> doClientStuff(event) }
  56.  
  57.         EntityTypeRegistry.ENTITY_TYPES.register(modEventBus)
  58.         BiomeRegistry.BIOMES.register(modEventBus)
  59.         FluidRegistry.FLUIDS.register(modEventBus)
  60.         TileEntityTypes.TILE_ENTITIES.register(modEventBus)
  61.         ContainerTypeRegistry.CONTAINER_TYPES.register(modEventBus)
  62.         EnchantmentRegistry.ENCHANTMENTS.register(modEventBus)
  63.         BlockRegistry.BLOCKS.register(modEventBus)
  64.         ItemRegistry.ITEMS.register(modEventBus)
  65.         PotionRegistry.POTIONS.register(modEventBus)
  66.  
  67.         MinecraftForge.EVENT_BUS.register(this)
  68.     }
  69.  
  70.     @Suppress("UNUSED_PARAMETER")
  71.     private fun setup(event: FMLCommonSetupEvent) {
  72.         DeferredWorkQueue.runLater {
  73.             GlobalEntityTypeAttributes.put(
  74.                 EntityTypeRegistry.RUBY_SHEEP,
  75.                 RubySheepEntity.setCustomAttributes().create())
  76.  
  77.             PotionBrewing.addMix(
  78.                 Potions.WATER,
  79.                 ItemRegistry.RUBY,
  80.                 PotionRegistry.MOTIVATION)
  81.  
  82.             PotionBrewing.addMix(
  83.                 PotionRegistry.MOTIVATION,
  84.                 Items.GLOWSTONE_DUST,
  85.                 PotionRegistry.STRONG_MOTIVATION)
  86.  
  87.             PotionBrewing.addMix(
  88.                 PotionRegistry.MOTIVATION,
  89.                 Items.REDSTONE,
  90.                 PotionRegistry.LONG_MOTIVATION)
  91.  
  92.             PotionBrewing.addMix(
  93.                 PotionRegistry.MOTIVATION,
  94.                 Items.FERMENTED_SPIDER_EYE,
  95.                 PotionRegistry.LAZINESS)
  96.  
  97.             PotionBrewing.addMix(
  98.                 PotionRegistry.LAZINESS,
  99.                 Items.GLOWSTONE_DUST,
  100.                 PotionRegistry.STRONG_LAZINESS)
  101.  
  102.             PotionBrewing.addMix(
  103.                 PotionRegistry.LAZINESS,
  104.                 Items.REDSTONE,
  105.                 PotionRegistry.LONG_LAZINESS)
  106.  
  107.             ComposterBlock.CHANCES[ItemRegistry.POISONED_APPLE.asItem()] = 0.3f
  108.         }
  109.  
  110.         FluidRegistry.FLUIDS.registry.entries.forEach {
  111.             RenderTypeLookup.setRenderLayer(it.value, RenderType.getTranslucent())
  112.         }
  113.     }
  114.  
  115.     @Suppress("UNUSED_PARAMETER")
  116.     private fun doClientStuff(event: FMLClientSetupEvent) {
  117.         DeferredWorkQueue.runLater {
  118.             ScreenManager.registerFactory(ContainerTypeRegistry.RUBY_BARREL) {
  119.                     screenContainer: RubyBarrelContainer,
  120.                     inv: PlayerInventory,
  121.                     titleIn: ITextComponent,
  122.                 ->
  123.                 RubyBarrelScreen(screenContainer, inv, titleIn)
  124.             }
  125.         }
  126.  
  127.         RenderingRegistry.registerEntityRenderingHandler(EntityTypeRegistry.RUBY_SHEEP) { renderManagerIn: EntityRendererManager ->
  128.             RubySheepRenderer(renderManagerIn)
  129.         }
  130.     }
  131.  
  132.     @SubscribeEvent
  133.     fun onRegisterBiomes(event: Register<Biome>?) {
  134.         BiomeRegistry.registerBiomes()
  135.     }
  136. }
Advertisement
Add Comment
Please, Sign In to add comment