Advertisement
Guest User

Code

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