Guest User

Untitled

a guest
Oct 7th, 2017
151
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package mod.mcreator;
  2.  
  3. import net.minecraftforge.fml.relauncher.SideOnly;
  4. import net.minecraftforge.fml.relauncher.Side;
  5. import net.minecraftforge.fml.common.registry.GameRegistry;
  6. import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
  7. import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
  8. import net.minecraftforge.fml.common.event.FMLInitializationEvent;
  9.  
  10. import net.minecraft.world.World;
  11. import net.minecraft.world.IBlockAccess;
  12. import net.minecraft.util.math.BlockPos;
  13. import net.minecraft.util.math.AxisAlignedBB;
  14. import net.minecraft.util.EnumFacing;
  15. import net.minecraft.util.BlockRenderLayer;
  16. import net.minecraft.item.ItemStack;
  17. import net.minecraft.item.ItemBlock;
  18. import net.minecraft.item.Item;
  19. import net.minecraft.client.renderer.block.model.ModelResourceLocation;
  20. import net.minecraft.client.Minecraft;
  21. import net.minecraft.block.state.IBlockState;
  22. import net.minecraft.block.material.Material;
  23. import net.minecraft.block.SoundType;
  24. import net.minecraft.block.Block;
  25.  
  26. import java.util.Random;
  27.  
  28. import net.minecraft.block.properties.IProperty;
  29. import net.minecraft.block.properties.PropertyDirection;
  30. import net.minecraft.block.state.BlockStateContainer;
  31. import net.minecraft.entity.EntityLivingBase;
  32.  
  33. public class mcreator_lightBarOff {
  34.  
  35. public mcreator_lightBarOff() {
  36. }
  37.  
  38. public static BlockLightBarOff block;
  39.  
  40. public static Object instance;
  41.  
  42. public int addFuel(ItemStack fuel) {
  43. return 0;
  44. }
  45.  
  46. public void serverLoad(FMLServerStartingEvent event) {
  47. }
  48.  
  49. public void preInit(FMLPreInitializationEvent event) {
  50. block.setRegistryName("lightbaroff");
  51. GameRegistry.register(block);
  52. GameRegistry.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
  53. }
  54.  
  55. public void registerRenderers() {
  56. }
  57.  
  58. public void load(FMLInitializationEvent event) {
  59. if (event.getSide() == Side.CLIENT) {
  60. Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
  61. .register(Item.getItemFromBlock(block), 0, new ModelResourceLocation("testenvironmentmod:lightbaroff", "inventory"));
  62. }
  63. }
  64.  
  65. static {
  66.  
  67. block = (BlockLightBarOff) (new BlockLightBarOff().setHardness(2.0F).setResistance(10.0F).setLightLevel(0.0F)
  68. .setUnlocalizedName("LightBarOff").setLightOpacity(0).setCreativeTab(mcreator_theBoyScoutMod.tab));
  69. block.setHarvestLevel("pickaxe", 4);
  70. }
  71.  
  72. public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
  73. }
  74.  
  75. public void generateNether(World world, Random random, int chunkX, int chunkZ) {
  76. }
  77.  
  78. static class BlockLightBarOff extends Block {
  79.  
  80. int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0;
  81.  
  82. boolean red = false;
  83. public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
  84.  
  85. protected BlockLightBarOff() {
  86. super(Material.IRON);
  87.  
  88. setSoundType(SoundType.METAL);
  89. this.setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
  90. }
  91.  
  92. @Override
  93. public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
  94. int i = pos.getX();
  95. int j = pos.getY();
  96. int k = pos.getZ();
  97. world.scheduleUpdate(new BlockPos(i, j, k), this, this.tickRate(world));
  98.  
  99. }
  100.  
  101. @Override
  102. public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
  103. return red ? 15 : 0;
  104. }
  105.  
  106. @Override
  107. public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
  108. return red ? 15 : 0;
  109. }
  110.  
  111. @Override
  112. public boolean isOpaqueCube(IBlockState state) {
  113. return false;
  114. }
  115.  
  116. @SideOnly(Side.CLIENT)
  117. @Override
  118. public BlockRenderLayer getBlockLayer() {
  119. return BlockRenderLayer.SOLID;
  120. }
  121.  
  122. @Override
  123. public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
  124. return new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
  125. }
  126.  
  127. @Override
  128. public int tickRate(World world) {
  129. return 10;
  130. }
  131.  
  132. @Override
  133. public int quantityDropped(Random par1Random) {
  134. return 1;
  135. }
  136.  
  137.  
  138.  
  139. @Override
  140. public IBlockState getStateFromMeta(int meta) {
  141. EnumFacing facing = EnumFacing.getFront(meta);
  142.  
  143. if(facing.getAxis()==EnumFacing.Axis.Y) {
  144. facing=EnumFacing.NORTH;
  145. }
  146.  
  147. return getDefaultState().withProperty(FACING, facing);
  148. }
  149.  
  150. @Override
  151. public int getMetaFromState(IBlockState state) {
  152. return ((EnumFacing) state.getValue(FACING)).getIndex();
  153. }
  154.  
  155. @Override
  156. protected BlockStateContainer createBlockState() {
  157. return new BlockStateContainer(this, new IProperty[]{FACING});
  158. }
  159.  
  160. @Override
  161. public IBlockState getStateForPlacement(World worldIn, BlockPos pos,
  162. EnumFacing facing, float hitX, float hitY, float hitZ, int meta,
  163. EntityLivingBase placer) {
  164. return getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
  165. }
  166.  
  167. }
  168. }
RAW Paste Data