PageRenderTime 25ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/1.12.2/src/main/java/moarvents/MoarVents.java

https://bitbucket.org/qwertz19281/moarvents
Java | 209 lines | 173 code | 21 blank | 15 comment | 14 complexity | 999b8b5c6ca35bdef42886eb799d2368 MD5 | raw file
  1. package moarvents;
  2. import net.minecraftforge.fml.common.Mod;
  3. import net.minecraftforge.fml.common.Mod.EventHandler;
  4. import net.minecraftforge.fml.common.event.FMLInitializationEvent;
  5. import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
  6. import net.minecraftforge.fml.common.registry.ForgeRegistries;
  7. import java.util.Calendar;
  8. import ic2.api.reactor.IReactor;
  9. import ic2.api.reactor.IReactorChamber;
  10. import ic2.core.block.reactor.tileentity.TileEntityReactorAccessHatch;
  11. import net.minecraft.block.material.Material;
  12. import net.minecraft.creativetab.CreativeTabs;
  13. import net.minecraft.item.ItemBlock;
  14. import net.minecraft.item.ItemStack;
  15. import net.minecraft.tileentity.TileEntity;
  16. import net.minecraft.util.EnumFacing;
  17. import net.minecraft.util.ResourceLocation;
  18. import net.minecraft.util.SoundEvent;
  19. import net.minecraft.util.math.BlockPos;
  20. import net.minecraft.world.IBlockAccess;
  21. @Mod(
  22. modid = "moarvents",
  23. name = "MoarVents",
  24. version = "beta1.2.5.2",
  25. updateJSON = "https://bitbucket.org/qwertz19281/moarvents/raw/master/update_info.json"
  26. )
  27. public class MoarVents
  28. {
  29. public static CRETAB ctab=null;
  30. static class CRETAB extends CreativeTabs {
  31. public CRETAB(String lable) {
  32. super(lable);
  33. }
  34. TexItem tabitem;
  35. ItemStack tis;
  36. @Override
  37. public ItemStack getTabIconItem()
  38. {
  39. return tis;
  40. }
  41. }
  42. //public static int lcnt = 9;
  43. //public static boolean selfSave = false;
  44. //public static boolean createEmitHeat = true;
  45. //public static boolean advLog = true;
  46. //public static Random rnd = new Random();
  47. public static BlockShaft shaft=null;
  48. public static BlockHeatConducter cndctr=null;
  49. public static BlockRHB rhb=null;
  50. public static BlockThermo thermo=null;
  51. public static BlockRdsw rdsw=null;
  52. public static BlockHEQ heq=null;
  53. public static TexBlock bconn=null;
  54. //public static BlockMaxKabel maxkabel=null;
  55. public static Item5x5Vent va=null;
  56. public static ItemFreezer vaB=null;
  57. public static TexItem[] mems=null;
  58. public static ItemOWHR owhr=null;public static ItemOWHD owhd=null;public static ItemOWHL owhl=null;public static ItemOWHU owhu=null;
  59. public static ItemColdBuffer coldt=null;
  60. public static ItemHotBuffer hott=null;
  61. public static ItemFireExtinguisher fireex=null;
  62. public static boolean foolDay=false;
  63. @EventHandler
  64. public void load(FMLInitializationEvent event){
  65. ctab.tabitem.setTextureName();
  66. va.setTextureName();
  67. vaB.setTextureName();
  68. for(int i=0;i<4;i++) {
  69. mems[i].setTextureName();
  70. }
  71. owhr.setTextureName();
  72. owhd.setTextureName();
  73. owhl.setTextureName();
  74. owhu.setTextureName();
  75. coldt.setTextureName();
  76. hott.setTextureName();
  77. fireex.setTextureName();
  78. cndctr.registerBlockTexture();
  79. rhb.registerBlockTexture();
  80. shaft.registerBlockTexture();
  81. thermo.registerBlockTexture();
  82. rdsw.registerBlockTexture();
  83. heq.registerBlockTexture();
  84. bconn.registerBlockTexture();
  85. }
  86. public static SoundEvent sre=new SoundEvent(new ResourceLocation("moarvents","fireex"));
  87. @EventHandler
  88. public void pre_load(FMLPreInitializationEvent event)
  89. {
  90. ctab=new CRETAB("moarvents");
  91. try{
  92. Calendar calendar = Calendar.getInstance();
  93. if (calendar.get(Calendar.MONTH) == 3 && calendar.get(Calendar.DAY_OF_MONTH) == 1) {
  94. foolDay=true;
  95. }
  96. calendar=null;
  97. if(foolDay){
  98. try{
  99. throw new ClassNotFoundException("qwertz19281.moarvents.AprilFool");
  100. }catch(ClassNotFoundException ex){
  101. ex.printStackTrace();
  102. }
  103. }
  104. }catch(Exception ex){}
  105. System.out.println("MoarVents: Init Objects");
  106. /*for (ItemName name : ItemName.values) {
  107. System.out.println(name.name());
  108. }*/
  109. ctab.tabitem=new TexItem().setUnlocalizedNameB("mv_ctab_tex_item");
  110. shaft=new BlockShaft();
  111. cndctr=new BlockHeatConducter(Material.ROCK);
  112. rhb=new BlockRHB(Material.ROCK);
  113. thermo=new BlockThermo(Material.ROCK);
  114. rdsw=new BlockRdsw(Material.ROCK);
  115. heq=new BlockHEQ(Material.ROCK);
  116. bconn=(TexBlock) new TexBlock(Material.ROCK).setUnlocalizedName("bconn").setRegistryName("bconn").setCreativeTab(ctab);
  117. //maxkabel=new BlockMaxKabel(Material.cloth);
  118. va=new Item5x5Vent();
  119. vaB=new ItemFreezer();
  120. mems=new TexItem[]{(TexItem)
  121. (new TexItem()).setUnlocalizedNameB("heatbuffer").setCreativeTab(CreativeTabs.MISC),
  122. (TexItem) (new TexItem()).setUnlocalizedNameB("membrancomp").setCreativeTab(CreativeTabs.MISC),
  123. (TexItem) (new TexItem()).setUnlocalizedNameB("membranliqheat").setCreativeTab(CreativeTabs.MISC),
  124. (TexItem) (new TexItem()).setUnlocalizedNameB("membrantemp").setCreativeTab(CreativeTabs.MISC)};
  125. owhr=new ItemOWHR();
  126. owhd=new ItemOWHD();
  127. owhl=new ItemOWHL();
  128. owhu=new ItemOWHU();
  129. coldt=new ItemColdBuffer();
  130. hott=new ItemHotBuffer();
  131. fireex=new ItemFireExtinguisher();
  132. System.out.println("MoarVents: Register Objects");
  133. ForgeRegistries.ITEMS.register(ctab.tabitem);
  134. ctab.tis=new ItemStack(ctab.tabitem);
  135. int bc;
  136. for (bc=0;bc<4;bc++) {
  137. mems[bc].setCreativeTab(ctab);
  138. }
  139. ForgeRegistries.ITEMS.register(va);
  140. ForgeRegistries.ITEMS.register(vaB);
  141. ForgeRegistries.ITEMS.register(mems[0]);
  142. ForgeRegistries.ITEMS.register(mems[1]);
  143. ForgeRegistries.ITEMS.register(mems[2]);
  144. ForgeRegistries.ITEMS.register(mems[3]);
  145. ForgeRegistries.ITEMS.register(owhr);
  146. ForgeRegistries.ITEMS.register(owhd);
  147. ForgeRegistries.ITEMS.register(owhl);
  148. ForgeRegistries.ITEMS.register(owhu);
  149. ForgeRegistries.ITEMS.register(coldt);
  150. ForgeRegistries.ITEMS.register(hott);
  151. ForgeRegistries.ITEMS.register(fireex);
  152. TileEntity.register("shaft", TileEntityShaft.class);
  153. TileEntity.register("hc", TileEntityHeatConducter.class);
  154. TileEntity.register("rhb", TileEntityRHB.class);
  155. TileEntity.register("thermo", TileEntityThermo.class);
  156. TileEntity.register("rdsw", TileEntityRodSwitcher.class);
  157. TileEntity.register("heq", TileEntityHEQ.class);
  158. ForgeRegistries.BLOCKS.registerAll(cndctr,rhb,shaft,thermo,rdsw,heq,bconn);
  159. ForgeRegistries.ITEMS.registerAll(
  160. new ItemBlock(cndctr).setRegistryName("hc").setCreativeTab(ctab),
  161. new ItemBlock(rhb).setRegistryName("rhb").setCreativeTab(ctab),
  162. new ItemBlock(shaft).setRegistryName("shaft").setCreativeTab(ctab),
  163. new ItemBlock(thermo).setRegistryName("thermo").setCreativeTab(ctab),
  164. new ItemBlock(rdsw).setRegistryName("rdsw").setCreativeTab(ctab),
  165. new ItemBlock(heq).setRegistryName("heq").setCreativeTab(ctab),
  166. new ItemBlock(bconn).setRegistryName("bconn").setCreativeTab(ctab)
  167. );
  168. //ForgeRegistries.SOUND_EVENTS.register(sre.setRegistryName(sre.getSoundName()));
  169. }
  170. /*public void regBlock(Block b) {
  171. ForgeRegistries.BLOCKS.register(b);
  172. ForgeRegistries.ITEMS.register(new ItemBlock(b).setRegistryName(b.getRegistryName()).setCreativeTab(b.getCreativeTabToDisplayOn()));
  173. }*/
  174. public static IReactor searchForInterface(IBlockAccess w,BlockPos pos,EnumFacing todir){
  175. TileEntity te=w.getTileEntity(pos);
  176. if(te instanceof IReactor){return (IReactor)te;}
  177. else if(te instanceof IReactorChamber)
  178. {return (IReactor)((IReactorChamber)te).getReactorInstance();}
  179. else if(te instanceof TileEntityReactorAccessHatch)
  180. {return (IReactor)((TileEntityReactorAccessHatch)te).getReactorInstance();}// (sic!)
  181. if(w.getBlockState(pos).getBlock()==bconn) {return searchForInterface(w,pos.add(todir.getDirectionVec()),todir);}
  182. return null;
  183. }
  184. public static TileEntity getTE(IBlockAccess w,BlockPos pos,EnumFacing todir){
  185. if(w.getBlockState(pos).getBlock()==bconn) {return getTE(w,pos.add(todir.getDirectionVec()),todir);}
  186. return w.getTileEntity(pos);
  187. }
  188. }