Advertisement
Guest User

Untitled

a guest
Apr 10th, 2020
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.75 KB | None | 0 0
  1. @Mod("hard_steel")
  2. public class HardSteel
  3. {
  4.  
  5. private static HardSteel instance;
  6. public static final String modid = "hard_steel";
  7. public static IProxy proxy = DistExecutor.runForDist(() -> () -> new ClientProxy(), () -> () -> new ServerProxy());
  8. public static final Logger logger = LogManager.getLogger(modid);
  9. public static final ItemGroup hard_steel = new GroupHardSteel();
  10.  
  11. public HardSteel()
  12. {
  13. instance = this;
  14. ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, HardSteelConfig.SERVER_CONFIG);
  15.  
  16. HardSteelConfig.loadConfig(HardSteelConfig.SERVER_CONFIG, FMLPaths.CONFIGDIR.get().resolve("hard_steel-general.toml"));
  17.  
  18. FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
  19. FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);
  20. FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC);
  21. FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
  22.  
  23. MinecraftForge.EVENT_BUS.register(this);
  24. MinecraftForge.EVENT_BUS.register(new LeatherDrops());
  25. MinecraftForge.EVENT_BUS.register(new CapabilityHandler()); <=== RIGHT HERE
  26. MinecraftForge.EVENT_BUS.register(new MobEquipEvent());
  27. }
  28.  
  29. public static HardSteel getInstance()
  30. {
  31. return instance;
  32. }
  33.  
  34. private void setup(final FMLCommonSetupEvent event)
  35. {
  36. OreGenerator.setupOregen();
  37.  
  38. CapabilityManager.INSTANCE.register(IReArmer.class, new ReArmerStorage(), ReArmer::new);
  39.  
  40. ConfiguredFeature<?> smithingTableReplacement = Biome.createDecoratedFeature(new SmithingTableReplacement(NoFeatureConfig::deserialize), IFeatureConfig.NO_FEATURE_CONFIG, Placement.NOPE , IPlacementConfig.NO_PLACEMENT_CONFIG);
  41. ForgeRegistries.BIOMES.forEach(biome -> biome.addFeature(GenerationStage.Decoration.TOP_LAYER_MODIFICATION, smithingTableReplacement));
  42.  
  43. ConfiguredFeature<?> anvilReplacement = Biome.createDecoratedFeature(new AnvilReplacement(NoFeatureConfig::deserialize), IFeatureConfig.NO_FEATURE_CONFIG, Placement.NOPE , IPlacementConfig.NO_PLACEMENT_CONFIG);
  44. ForgeRegistries.BIOMES.forEach(biome -> biome.addFeature(GenerationStage.Decoration.TOP_LAYER_MODIFICATION, anvilReplacement));
  45.  
  46. ConfiguredFeature<?> blastFurnaceReplacement = Biome.createDecoratedFeature(new BlastFurnaceReplacement(NoFeatureConfig::deserialize), IFeatureConfig.NO_FEATURE_CONFIG, Placement.NOPE , IPlacementConfig.NO_PLACEMENT_CONFIG);
  47. ForgeRegistries.BIOMES.forEach(biome -> biome.addFeature(GenerationStage.Decoration.TOP_LAYER_MODIFICATION, blastFurnaceReplacement));
  48.  
  49. Set<BlockState> smithingTableBlockStates = BlockStateUtilities.getAllStates(SmithingTableRegistryEvents.SMITHING_TABLE);
  50. Set<BlockState> blastFurnaceBlockStates = BlockStateUtilities.getAllStates(BlastFurnaceRegistryEvents.BLAST_FURNACE);
  51.  
  52.  
  53. Map<BlockState, PointOfInterestType> types = ObfuscationReflectionHelper.getPrivateValue(PointOfInterestType.class, null, "field_221073_u");
  54.  
  55. if(types == null) return;
  56.  
  57. for(BlockState blockState : smithingTableBlockStates){
  58. types.put(blockState, PointOfInterestType.TOOLSMITH);
  59. }
  60. for(BlockState blockState : blastFurnaceBlockStates){
  61. types.put(blockState, PointOfInterestType.ARMORER);
  62. }
  63. //HardSteel.logger.info("Types are: " + types.toString());
  64.  
  65. // smithing table
  66. Message.registerMessages(HardSteel.modid);
  67. // anvil
  68. //com.infamous.hard_steel.anvil.Message.registerMessages(HardSteel.modid);
  69.  
  70. proxy.init();
  71.  
  72. logger.info("Mod preinit");
  73. }
  74.  
  75.  
  76.  
  77. private void doClientStuff(final FMLClientSetupEvent event)
  78. {
  79.  
  80. logger.info("Got game settings {}", event.getMinecraftSupplier().get().gameSettings);
  81. }
  82.  
  83. private void enqueueIMC(final InterModEnqueueEvent event)
  84. {
  85.  
  86. InterModComms.sendTo("hard_steel", "helloworld", () -> { logger.info("Hello world from Hard Steel"); return "Hello world";});
  87. }
  88.  
  89. private void processIMC(final InterModProcessEvent event)
  90. {
  91.  
  92. logger.info("Got IMC {}", event.getIMCStream().
  93. map(m->m.getMessageSupplier().get()).
  94. collect(Collectors.toList()));
  95. }
  96.  
  97. @SubscribeEvent
  98. public void onServerStarting(FMLServerStartingEvent event)
  99. {
  100.  
  101. logger.info("Server starting");
  102. }
  103.  
  104. @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
  105. public static class RegistryEvents
  106. {
  107. @SubscribeEvent
  108. public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent)
  109. {
  110.  
  111. logger.info("Blocks registered");
  112. }
  113. }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement