Guest User

Untitled

a guest
Aug 24th, 2019
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.09 KB | None | 0 0
  1. package com.dreaminginsanity.buildhelper;
  2.  
  3.  
  4. import net.minecraft.block.Block;
  5. import net.minecraft.client.settings.KeyBinding;
  6. import net.minecraft.item.BlockItem;
  7. import net.minecraft.item.Item;
  8. import net.minecraft.item.ItemGroup;
  9. import net.minecraftforge.client.event.InputEvent;
  10. import net.minecraftforge.client.event.InputEvent.KeyInputEvent;
  11. import net.minecraftforge.common.MinecraftForge;
  12. import net.minecraftforge.event.RegistryEvent;
  13. import net.minecraftforge.eventbus.api.EventPriority;
  14. import net.minecraftforge.eventbus.api.SubscribeEvent;
  15. import net.minecraftforge.fml.DistExecutor;
  16. import net.minecraftforge.fml.common.Mod;
  17. import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
  18. import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
  19. import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
  20. import org.apache.logging.log4j.LogManager;
  21. import org.apache.logging.log4j.Logger;
  22.  
  23. import com.dreaminginsanity.buildhelper.blocks.HologramBlock;
  24. import com.dreaminginsanity.buildhelper.blocks.ModBlocks;
  25. import com.dreaminginsanity.buildhelper.setup.ClientProxy;
  26. import com.dreaminginsanity.buildhelper.setup.IProxy;
  27. import com.dreaminginsanity.buildhelper.setup.ModSetup;
  28.  
  29. // The value here should match an entry in the META-INF/mods.toml file
  30. @Mod("buildhelper")
  31. public class BuildHelper
  32. {
  33.    
  34.    
  35.     public static IProxy proxy = new DistExecutor.runForDist(() -> () -> () -> new ClientProxy(), () -> () -> () -> new ServerProxy());
  36.     private static final Logger LOGGER = LogManager.getLogger();
  37.     public static ModSetup setup = new ModSetup();
  38.  
  39.     public BuildHelper() {
  40.         FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
  41.        
  42.         MinecraftForge.EVENT_BUS.register(this);
  43.     }
  44.  
  45.     private void setup(final FMLCommonSetupEvent event)
  46.     {
  47.         setup.init();
  48.         proxy.init();
  49.        
  50.         LOGGER.info("HERE IN SETUP!");
  51.     }
  52.  
  53.  
  54.     @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
  55.     public static class RegistryEvents {
  56.         @SubscribeEvent
  57.         public static void onBlocksRegistry(final RegistryEvent.Register<Block> event) {
  58.            
  59.             event.getRegistry().registerAll(
  60.                     new  HologramBlock()
  61.             );
  62.            
  63.             LOGGER.info("Blocks Registered!");
  64.         }
  65.        
  66.         @SubscribeEvent
  67.         public static void onItemsRegistry(final RegistryEvent.Register<Item> event) {
  68.            
  69.             event.getRegistry().registerAll(
  70.                    
  71.                     new  BlockItem(ModBlocks.HOLOGRAM, new Item.Properties().group(ItemGroup.MISC)).setRegistryName(ModBlocks.HOLOGRAM.getRegistryName())
  72.             );
  73.            
  74.             LOGGER.info("Items Registered!");
  75.         }
  76.        
  77.         @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
  78.         public void onEvent(KeyInputEvent event) {
  79.            
  80.             KeyBinding[] keyBindings = ClientProxy.keyBindings;
  81.             if (keyBindings[0].isPressed())
  82.             {
  83.                 LOGGER.info("Key binding ="+keyBindings[0].getKeyDescription());
  84.             }
  85.         }
  86.        
  87.     }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment