Advertisement
Nuparu00

Untitled

Aug 21st, 2017
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.20 KB | None | 0 0
  1.  
  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. import net.minecraft.util.Rotation;
  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.util.Mirror;
  17. import net.minecraft.item.ItemStack;
  18. import net.minecraft.item.ItemBlock;
  19. import net.minecraft.item.Item;
  20. import net.minecraft.creativetab.CreativeTabs;
  21. import net.minecraft.client.renderer.block.model.ModelResourceLocation;
  22. import net.minecraft.client.Minecraft;
  23. import net.minecraft.block.state.IBlockState;
  24. import net.minecraft.block.material.Material;
  25. import net.minecraft.block.SoundType;
  26. import net.minecraft.block.Block;
  27. import net.minecraft.block.properties.IProperty;
  28. import net.minecraft.block.properties.PropertyDirection;
  29. import net.minecraft.block.state.BlockStateContainer;
  30. import net.minecraft.entity.EntityLivingBase;
  31. import java.util.Random;
  32.  
  33. public class mcreator_virgil {
  34.  
  35.  public mcreator_virgil() {
  36.  }
  37.  
  38.  public static BlockVirgil 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("virgil");
  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:virgil", "inventory"));
  62.   }
  63.  }
  64.  
  65.  static {
  66.  
  67.   block = (BlockVirgil) (new BlockVirgil().setHardness(2.0F).setResistance(10.0F).setLightLevel(0.0F).setUnlocalizedName("Virgil")
  68.     .setLightOpacity(0).setCreativeTab(CreativeTabs.BUILDING_BLOCKS));
  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 BlockVirgil extends Block {
  79.  
  80.   int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0;
  81.  
  82.   boolean red = false;
  83.  
  84.           public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
  85.  
  86.   protected BlockVirgil() {
  87.    super(Material.GROUND);
  88.                this.setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
  89.    setSoundType(SoundType.WOOD);
  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.          @Override
  137.               public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
  138.     {
  139.         return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
  140.     }
  141.     public IBlockState getStateFromMeta(int meta)
  142.     {
  143.         return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta));
  144.     }
  145.     public int getMetaFromState(IBlockState state)
  146.     {
  147.         return ((EnumFacing)state.getValue(FACING)).getHorizontalIndex();
  148.     }
  149.         public IBlockState withRotation(IBlockState state, Rotation rot)
  150.     {
  151.         return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING)));
  152.     }
  153.     public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
  154.     {
  155.         return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING)));
  156.     }
  157.         protected BlockStateContainer createBlockState()
  158.     {
  159.         return new BlockStateContainer(this, new IProperty[] {FACING});
  160.     }
  161.    
  162.     }
  163. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement