Advertisement
Guest User

Code

a guest
Sep 6th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.DamageSource;
  14. import net.minecraft.util.BlockRenderLayer;
  15. import net.minecraft.item.ItemStack;
  16. import net.minecraft.item.ItemBlock;
  17. import net.minecraft.item.Item;
  18. import net.minecraft.init.Blocks;
  19. import net.minecraft.entity.player.EntityPlayer;
  20. import net.minecraft.entity.Entity;
  21. import net.minecraft.creativetab.CreativeTabs;
  22. import net.minecraft.client.renderer.block.model.ModelResourceLocation;
  23. import net.minecraft.client.Minecraft;
  24. import net.minecraft.block.state.IBlockState;
  25. import net.minecraft.block.material.Material;
  26. import net.minecraft.block.SoundType;
  27. import net.minecraft.block.Block;
  28.  
  29. import java.util.Random;
  30.  
  31. public class mcreator_infectious {
  32.  
  33.     public mcreator_infectious() {
  34.     }
  35.  
  36.     public static BlockInfectious block;
  37.  
  38.     public static Object instance;
  39.  
  40.     public int addFuel(ItemStack fuel) {
  41.         return 0;
  42.     }
  43.  
  44.     public void serverLoad(FMLServerStartingEvent event) {
  45.     }
  46.  
  47.     public void preInit(FMLPreInitializationEvent event) {
  48.         block.setRegistryName("infectious");
  49.         GameRegistry.register(block);
  50.         GameRegistry.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
  51.     }
  52.  
  53.     public void registerRenderers() {
  54.     }
  55.  
  56.     public void load(FMLInitializationEvent event) {
  57.         if (event.getSide() == Side.CLIENT) {
  58.             Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
  59.                     .register(Item.getItemFromBlock(block), 0, new ModelResourceLocation("testenvironmentmod:infectious", "inventory"));
  60.         }
  61.  
  62.         GameRegistry.addRecipe(new ItemStack(block, 1), new Object[]{"XXX", "X4X", "XXX", Character.valueOf('4'), Blocks.DIRT,});
  63.     }
  64.  
  65.     static {
  66.  
  67.         block = (BlockInfectious) (new BlockInfectious().setHardness(0.0F).setResistance(0.0F).setLightLevel(1.0F).setUnlocalizedName("Infectious")
  68.                 .setLightOpacity(0).setCreativeTab(CreativeTabs.MISC));
  69.         block.setHarvestLevel("pickaxe", 0);
  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 BlockInfectious extends Block {
  79.  
  80.         int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0;
  81.  
  82.         boolean red = false;
  83.  
  84.         protected BlockInfectious() {
  85.             super(Material.LEAVES);
  86.  
  87.             setSoundType(SoundType.GROUND);
  88.  
  89.         }
  90.  
  91.         @Override
  92.         public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
  93.             int i = pos.getX();
  94.             int j = pos.getY();
  95.             int k = pos.getZ();
  96.             world.scheduleUpdate(new BlockPos(i, j, k), this, this.tickRate(world));
  97.  
  98.         }
  99.  
  100.         @Override
  101.         public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
  102.             return red ? 15 : 0;
  103.         }
  104.  
  105.         @Override
  106.         public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
  107.             return red ? 15 : 0;
  108.         }
  109.  
  110.         @Override
  111.         public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random random) {
  112.             EntityPlayer entity = Minecraft.getMinecraft().player;
  113.             int i = pos.getX();
  114.             int j = pos.getY();
  115.             int k = pos.getZ();
  116.             if (true) {
  117.                 world.setBlockState(new BlockPos(i + 1, j, k), mcreator_infectious.block.getDefaultState(), 3);
  118.                  world.setBlockState(new BlockPos(i, j + 1, k), mcreator_infectious.block.getDefaultState(), 3);
  119.                     world.setBlockState(new BlockPos(i, j, k + 1), mcreator_infectious.block.getDefaultState(), 3);
  120.                     world.setBlockState(new BlockPos(i - 1, j, k), mcreator_infectious.block.getDefaultState(), 3);
  121.                     world.setBlockState(new BlockPos(i, j - 1, k), mcreator_infectious.block.getDefaultState(), 3);
  122.                     world.setBlockState(new BlockPos(i, j, k - 1), mcreator_infectious.block.getDefaultState(), 3);
  123.             }
  124.  
  125.         }
  126.  
  127.         @Override
  128.         public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
  129.             int i = pos.getX();
  130.             int j = pos.getY();
  131.             int k = pos.getZ();
  132.             if (true) {
  133.                 entity.attackEntityFrom(DamageSource.GENERIC, 200);
  134.             }
  135.  
  136.         }
  137.  
  138.         @SideOnly(Side.CLIENT)
  139.         @Override
  140.         public BlockRenderLayer getBlockLayer() {
  141.             return BlockRenderLayer.SOLID;
  142.         }
  143.  
  144.         @Override
  145.         public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
  146.             return new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
  147.         }
  148.  
  149.         @Override
  150.         public int tickRate(World world) {
  151.             return 10;
  152.         }
  153.  
  154.         @Override
  155.         public int quantityDropped(Random par1Random) {
  156.             return 0;
  157.         }
  158.  
  159.         @Override
  160.         public Item getItemDropped(IBlockState state, Random par2Random, int par3) {
  161.             return new ItemStack(Blocks.DIRT, 1, 1).getItem();
  162.         }
  163.     }
  164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement