Advertisement
Guest User

Untitled

a guest
Aug 8th, 2018
458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. package mod.mcreator;
  2.  
  3. import net.minecraft.world.World;
  4. import net.minecraft.world.IBlockAccess;
  5. import net.minecraft.util.MathHelper;
  6. import net.minecraft.util.IIcon;
  7. import net.minecraft.item.ItemStack;
  8. import net.minecraft.item.Item;
  9. import net.minecraft.init.Items;
  10. import net.minecraft.entity.player.EntityPlayer;
  11. import net.minecraft.creativetab.CreativeTabs;
  12. import net.minecraft.client.renderer.texture.IIconRegister;
  13. import net.minecraft.client.Minecraft;
  14. import net.minecraft.block.material.Material;
  15. import net.minecraft.block.Block;
  16.  
  17. import java.util.Random;
  18.  
  19. import cpw.mods.fml.relauncher.SideOnly;
  20. import cpw.mods.fml.relauncher.Side;
  21. import cpw.mods.fml.common.registry.GameRegistry;
  22. import cpw.mods.fml.common.event.FMLServerStartingEvent;
  23. import cpw.mods.fml.common.event.FMLPreInitializationEvent;
  24.  
  25. public class mcreator_sugarcaneblock {
  26.  
  27. public mcreator_sugarcaneblock() {
  28. }
  29.  
  30. public static BlockSugarcaneblock block;
  31.  
  32. public static Object instance;
  33.  
  34. public int addFuel(ItemStack fuel) {
  35. return 0;
  36. }
  37.  
  38. public void serverLoad(FMLServerStartingEvent event) {
  39. }
  40.  
  41. public void preInit(FMLPreInitializationEvent event) {
  42.  
  43. GameRegistry.registerBlock(block, "Sugarcaneblock");
  44. }
  45.  
  46. public void registerRenderers() {
  47. }
  48.  
  49. public void load() {
  50.  
  51. GameRegistry.addRecipe(new ItemStack(block, 1), new Object[]{"XXX", "X45", "X78", Character.valueOf('4'), new ItemStack(Items.reeds, 1),
  52. Character.valueOf('5'), new ItemStack(Items.reeds, 1), Character.valueOf('7'), new ItemStack(Items.reeds, 1), Character.valueOf('8'),
  53. new ItemStack(Items.reeds, 1),});
  54. }
  55.  
  56. static {
  57.  
  58. block = (BlockSugarcaneblock) (new BlockSugarcaneblock().setHardness(0.25F).setResistance(10.0F).setLightLevel(0.0F)
  59. .setBlockName("Sugarcaneblock").setBlockTextureName("sugarcaneblocktop").setLightOpacity(0).setStepSound(Block.soundTypeWood)
  60. .setCreativeTab(CreativeTabs.tabBlock));
  61. block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
  62. Block.blockRegistry.addObject(178, "Sugarcaneblock", block);
  63. block.setHarvestLevel("axe", 0);
  64. }
  65.  
  66. public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
  67. }
  68.  
  69. public void generateNether(World world, Random random, int chunkX, int chunkZ) {
  70. }
  71.  
  72. static class BlockSugarcaneblock extends Block {
  73.  
  74. int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0;
  75.  
  76. Random field_149942_b = new Random();
  77.  
  78. IIcon gor = null, dol = null, st1 = null, st2 = null, st3 = null, st4 = null;
  79.  
  80. boolean red = false;
  81.  
  82. protected BlockSugarcaneblock() {
  83. super(Material.wood);
  84.  
  85. }
  86.  
  87. public void onBlockAdded(World world, int i, int j, int k) {
  88. EntityPlayer entity = Minecraft.getMinecraft().thePlayer;
  89. if (entity != null && world != null) {
  90. int le = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
  91. world.setBlockMetadataWithNotify(i, j, k, le, 2);
  92. }
  93.  
  94. world.scheduleBlockUpdate(i, j, k, this, this.tickRate(world));
  95.  
  96. }
  97.  
  98. public int isProvidingStrongPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) {
  99. return red ? 1 : 0;
  100. }
  101.  
  102. @SideOnly(Side.CLIENT)
  103. @Override
  104. public IIcon getIcon(int i, int par2) {
  105.  
  106. if (i == 0)
  107. return gor;
  108.  
  109. else if (i == 1)
  110. return dol;
  111.  
  112. else if (i == 2)
  113. return st1;
  114.  
  115. else if (i == 3)
  116. return st2;
  117.  
  118. else if (i == 4)
  119. return st4;
  120.  
  121. else if (i == 5)
  122. return st3;
  123.  
  124. else
  125. return gor;
  126.  
  127. }
  128.  
  129. @SideOnly(Side.CLIENT)
  130. @Override
  131. public void registerBlockIcons(IIconRegister reg) {
  132. this.gor = reg.registerIcon("sugarcaneblocktop");
  133. this.dol = reg.registerIcon("sugarcaneblock");
  134. this.st1 = reg.registerIcon("sugarcaneblock");
  135. this.st2 = reg.registerIcon("sugarcaneblock");
  136. this.st3 = reg.registerIcon("sugarcaneblock");
  137. this.st4 = reg.registerIcon("sugarcaneblocktop");
  138. }
  139.  
  140. public int getRenderType() {
  141. return 0;
  142. }
  143.  
  144. @Override
  145. public int tickRate(World world) {
  146. return 10;
  147. }
  148.  
  149. public int quantityDropped(Random par1Random) {
  150. return 4;
  151. }
  152.  
  153. public Item getItemDropped(int par1, Random par2Random, int par3) {
  154. return Items.reeds;
  155. }
  156. }
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement