Guest User

Untitled

a guest
Aug 23rd, 2019
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.29 KB | None | 0 0
  1. package de.krokoyt.fa;
  2.  
  3. import net.minecraft.block.Block;
  4. import net.minecraft.block.Blocks;
  5. import net.minecraft.client.Minecraft;
  6. import net.minecraft.client.particle.Particle;
  7. import net.minecraft.client.renderer.texture.TextureManager;
  8. import net.minecraft.client.settings.ParticleStatus;
  9. import net.minecraft.entity.player.PlayerEntity;
  10. import net.minecraft.item.Items;
  11. import net.minecraft.particles.BasicParticleType;
  12. import net.minecraft.particles.IParticleData;
  13. import net.minecraft.particles.ParticleType;
  14. import net.minecraft.particles.ParticleTypes;
  15. import net.minecraft.resources.IResourceManager;
  16. import net.minecraft.world.World;
  17. import net.minecraftforge.common.MinecraftForge;
  18. import net.minecraftforge.event.RegistryEvent;
  19. import net.minecraftforge.event.RegistryEvent.Register;
  20. import net.minecraftforge.event.entity.living.LivingEvent;
  21. import net.minecraftforge.event.world.BlockEvent.FarmlandTrampleEvent;
  22. import net.minecraftforge.eventbus.api.SubscribeEvent;
  23. import net.minecraftforge.fml.InterModComms;
  24. import net.minecraftforge.fml.common.Mod;
  25. import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
  26. import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
  27. import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
  28. import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
  29. import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
  30. import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
  31. import org.apache.logging.log4j.LogManager;
  32. import org.apache.logging.log4j.Logger;
  33.  
  34. import de.krokoyt.fa.particles.Footstep;
  35.  
  36. import java.util.stream.Collectors;
  37.  
  38. // The value here should match an entry in the META-INF/mods.toml file
  39. @Mod("fa")
  40. public class RealisticUlities
  41. {
  42. // Directly reference a log4j logger.
  43. private static final Logger LOGGER = LogManager.getLogger();
  44.  
  45.  
  46.  
  47. public RealisticUlities() {
  48.  
  49. // Register the setup method for modloading
  50. FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
  51. // Register the enqueueIMC method for modloading
  52. FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);
  53. // Register the processIMC method for modloading
  54. FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC);
  55. // Register the doClientStuff method for modloading
  56. FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
  57.  
  58. // Register ourselves for server and other game events we are interested in
  59. MinecraftForge.EVENT_BUS.register(this);
  60. MinecraftForge.EVENT_BUS.register(new Events());
  61. }
  62.  
  63. private void setup(final FMLCommonSetupEvent event)
  64. {
  65. de.krokoyt.fa.particles.ParticleTypes.registration();
  66.  
  67.  
  68. //(
  69. // entity.worldObj,
  70. // entity.posX + entity.worldObj.rand.nextFloat() * entity.width
  71. //
  72. // * 2.0F - entity.width,
  73. // entity.posY + 0.5D + entity.worldObj.rand.nextFloat()
  74. //
  75. // * entity.height,
  76. // entity.posZ + entity.worldObj.rand.nextFloat() * entity.width
  77. //
  78. // * 2.0F - entity.width,
  79. //
  80. // targetX + 0.5,
  81. //
  82. // targetY + 1,
  83. //
  84. // targetZ + 0.5,10, col.toInt(),1F);
  85.  
  86.  
  87.  
  88. // some preinit code
  89. LOGGER.info("HELLO FROM PREINIT");
  90. LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
  91. }
  92.  
  93. private void doClientStuff(final FMLClientSetupEvent event) {
  94. // do something that can only be done on the client
  95. Minecraft.getInstance().particles.registerFactory(de.krokoyt.fa.particles.ParticleTypes.FOOTSTEP, new Footstep.Factory());
  96. LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().gameSettings);
  97. }
  98.  
  99. private void enqueueIMC(final InterModEnqueueEvent event)
  100. {
  101. // some example code to dispatch IMC to another mod
  102. InterModComms.sendTo("examplemod", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";});
  103. }
  104.  
  105. private void processIMC(final InterModProcessEvent event)
  106. {
  107. // some example code to receive and process InterModComms from other mods
  108. LOGGER.info("Got IMC {}", event.getIMCStream().
  109. map(m->m.getMessageSupplier().get()).
  110. collect(Collectors.toList()));
  111. }
  112. // You can use SubscribeEvent and let the Event Bus discover methods to call
  113. @SubscribeEvent
  114. public void onServerStarting(FMLServerStartingEvent event) {
  115. // do something when the server starts
  116. LOGGER.info("HELLO from server starting");
  117. }
  118.  
  119. // You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD
  120. // Event bus for receiving Registry Events)
  121. @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
  122. public static class RegistryEvents {
  123.  
  124.  
  125.  
  126.  
  127. @SubscribeEvent
  128. public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
  129. // register a new block here
  130. LOGGER.info("HELLO from Register Block");
  131. }
  132. }
  133. }
Add Comment
Please, Sign In to add comment