Guest User

Untitled

a guest
Dec 31st, 2020
300
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package taknax.tax.fodc;
  2.  
  3. import net.minecraft.init.Blocks;
  4. import net.minecraft.init.Items;
  5. import net.minecraft.item.ItemBlock;
  6. import net.minecraft.item.ItemStack;
  7. import net.minecraftforge.common.MinecraftForge;
  8. import net.minecraftforge.common.config.Configuration;
  9. import net.minecraftforge.fml.common.Mod;
  10. import net.minecraftforge.fml.common.Mod.EventHandler;
  11. import net.minecraftforge.fml.common.Mod.Instance;
  12. import net.minecraftforge.fml.common.SidedProxy;
  13. import net.minecraftforge.fml.common.event.FMLInitializationEvent;
  14. import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent;
  15. import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent.MissingMapping;
  16. import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
  17. import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
  18. import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
  19. import net.minecraftforge.fml.common.network.NetworkRegistry;
  20. import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
  21. import net.minecraftforge.fml.common.registry.GameRegistry;
  22. import net.minecraftforge.fml.relauncher.Side;
  23. import net.minecraftforge.oredict.OreDictionary;
  24.  
  25. import org.apache.logging.log4j.Logger;
  26.  
  27. import taknax.tax.fodc.block.BlockAutomaticOreConverter;
  28. import taknax.tax.fodc.block.BlockOreConversionTable;
  29. import taknax.tax.fodc.item.ItemOreConverter;
  30. import taknax.tax.fodc.network.MessageODC;
  31. import taknax.tax.fodc.proxy.CommonODCProxy;
  32. import taknax.tax.fodc.registry.OreNameRegistry;
  33. import taknax.tax.fodc.tileentity.TileEntityAutomaticOreConverter;
  34.  
  35. @Mod(
  36. modid = ModOreDicConvert.MODID,
  37. name = ModOreDicConvert.MODNAME,
  38. version = ModOreDicConvert.MODVERSION,
  39. dependencies = "required-after:forge@[13.19.1.2189,)"
  40. )
  41. public class ModOreDicConvert
  42. {
  43. public static final String MODID = "fodc";
  44. public static final String MODNAME = "Ore Dictionary Converter";
  45. public static final String MODVERSION = "1.10.0";
  46.  
  47. public static ItemOreConverter item_oreconverter = null;
  48. @Instance("fodc")
  49. public static ModOreDicConvert instance;
  50.  
  51. // Says where the client and server 'proxy' code is loaded.
  52. @SidedProxy(clientSide = "taknax.tax.fodc.proxy.ClientODCProxy", serverSide = "taknax.tax.fodc.proxy.CommonODCProxy")
  53. public static CommonODCProxy proxy;
  54. public static BlockOreConversionTable block_oreconvtable;
  55. public static BlockAutomaticOreConverter block_oreautoconv;
  56.  
  57. public static Logger log;
  58.  
  59. public static boolean log_orenames;
  60.  
  61. public static SimpleNetworkWrapper network_channel;
  62.  
  63.  
  64. @EventHandler
  65. public void preInit(FMLPreInitializationEvent event)
  66. {
  67. log = event.getModLog();
  68. Configuration config = new Configuration(event.getSuggestedConfigurationFile());
  69. config.load();
  70. log_orenames = config.getBoolean("log_names", Configuration.CATEGORY_GENERAL, false, "Log registered ore names.");
  71. OreNameRegistry.preInit(config);
  72. config.save();
  73.  
  74.  
  75. NetworkRegistry.INSTANCE.registerGuiHandler(this, proxy);
  76.  
  77. block_oreconvtable = new BlockOreConversionTable();
  78. block_oreautoconv = new BlockAutomaticOreConverter();
  79. item_oreconverter = new ItemOreConverter();
  80.  
  81. GameRegistry.register(item_oreconverter);
  82.  
  83. GameRegistry.register(block_oreconvtable);
  84. GameRegistry.register(block_oreautoconv);
  85. GameRegistry.register(new ItemBlock(block_oreconvtable).setRegistryName(block_oreconvtable.getRegistryName()));
  86. GameRegistry.register(new ItemBlock(block_oreautoconv).setRegistryName(block_oreautoconv.getRegistryName()));
  87.  
  88.  
  89.  
  90. network_channel = NetworkRegistry.INSTANCE.newSimpleChannel("taknax.tax.FODC");
  91. network_channel.registerMessage(MessageODC.Handler.class, MessageODC.class, 0, Side.SERVER);
  92. network_channel.registerMessage(MessageODC.Handler.class, MessageODC.class, 0, Side.CLIENT);
  93. }
  94.  
  95. @EventHandler
  96. public void init(FMLInitializationEvent event)
  97. {
  98. GameRegistry.registerTileEntity(TileEntityAutomaticOreConverter.class, "AutoOreConverter");
  99. proxy.init();
  100.  
  101. ItemStack iron_stack = new ItemStack(Items.IRON_INGOT);
  102. ItemStack redstone_stack = new ItemStack(Items.REDSTONE);
  103. ItemStack workbench_stack = new ItemStack(Blocks.CRAFTING_TABLE);
  104. ItemStack wood_stack = new ItemStack(Blocks.PLANKS,1,OreDictionary.WILDCARD_VALUE);
  105. ItemStack cobble_stack = new ItemStack(Blocks.COBBLESTONE,1,OreDictionary.WILDCARD_VALUE);
  106. ItemStack oreconverter_stack = new ItemStack(item_oreconverter);
  107.  
  108. GameRegistry.addRecipe(
  109. oreconverter_stack,
  110. "I",
  111. "C",
  112. "B",
  113. 'I', iron_stack,
  114. 'C', cobble_stack,
  115. 'B', workbench_stack);
  116. GameRegistry.addRecipe(
  117. new ItemStack(block_oreconvtable),
  118. "O",
  119. "W",
  120. 'O', oreconverter_stack,
  121. 'W', wood_stack);
  122. GameRegistry.addRecipe(
  123. new ItemStack(block_oreautoconv),
  124. "IOI",
  125. "CRC",
  126. "ICI",
  127. 'I', iron_stack,
  128. 'O', oreconverter_stack,
  129. 'R', redstone_stack,
  130. 'C', cobble_stack);
  131. }
  132.  
  133.  
  134. @EventHandler
  135. public void postInit(FMLPostInitializationEvent event)
  136. {
  137. //log.setParent(FMLLog.getLogger());
  138. String[] ore_names = OreDictionary.getOreNames();
  139. for (String name : ore_names)
  140. {
  141. if(name == null)
  142. {
  143. log.warn("null name in Ore Dictionary.");
  144. continue;
  145. }
  146. OreNameRegistry.registerOreName(name);
  147. }
  148. MinecraftForge.EVENT_BUS.register(this);
  149. }
  150.  
  151. @EventHandler
  152. public void remap(FMLMissingMappingsEvent event)
  153. {
  154. for(MissingMapping map:event.get())
  155. {
  156. String name = map.resourceLocation.getResourcePath();
  157. if(name.equals("oreconverter") && map.type == GameRegistry.Type.ITEM)
  158. {
  159. map.remap(item_oreconverter);
  160. } else if(name.equals("oreconvtable"))
  161. {
  162. switch(map.type)
  163. {
  164. case BLOCK:
  165. map.remap(block_oreconvtable);
  166. break;
  167. case ITEM:
  168. map.remap(ItemBlock.getItemFromBlock(block_oreconvtable));
  169. break;
  170. default:
  171. break;
  172. }
  173. } else if(name.equals("oreautoconverter"))
  174. {
  175. switch(map.type)
  176. {
  177. case BLOCK:
  178. map.remap(block_oreautoconv);
  179. break;
  180. case ITEM:
  181. map.remap(ItemBlock.getItemFromBlock(block_oreautoconv));
  182. break;
  183. default:
  184. break;
  185. }
  186. } else
  187. {
  188. map.warn();
  189. }
  190. }
  191. }
  192.  
  193. @SubscribeEvent
  194. public void onOreDictionaryRegister(OreDictionary.OreRegisterEvent event)
  195. {
  196. OreNameRegistry.registerOreName(event.getName());
  197. }
  198. }
  199. AntwortReport
  200. httpdigest
  201. Top Contributor
  202. Heute um 10:59
  203. Add bookmark
  204. #2
  205. Das hier ist kein Minecraft Modding Forum. Du solltest dein Glück vielleicht eher in einschlägigen Minecraft Foren versuchen.
  206. Like AntwortReport
  207. Taknax
  208.  
  209.  
  210.  
  211. Schreibe deine Antwort....
  212.  
  213. Antwort erstellen
  214. Dateien anhängen
  215. Foren Java - Programmierung Spiele- und Multimedia-Programmierung
  216. Werbung buchenImpressumDatenschutzerklärungKontakt aufnehmenBedingungen und RegelnHilfeStartseiteRSS
  217. © 2020 Gemeinsam Java programmieren lernen - public static void ('Forum') class Java_Hilfe { int antwort != 'null' } return this
  218. Versuche eine Mod von 1.11.2 in 1.12.2 zu porten. | Java - Hilfe | Java-Forum.org
  219.  
  220.  
  221. Chatfunktion aktivieren
  222. Antwort
RAW Paste Data