Advertisement
Guest User

Untitled

a guest
Jun 30th, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.30 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.  
  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.init.Items;
  20. import net.minecraft.entity.player.EntityPlayer;
  21. import net.minecraft.entity.Entity;
  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_question {
  32.  
  33.     public mcreator_question() {
  34.     }
  35.  
  36.     public static BlockQuestion 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("question");
  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:question", "inventory"));
  60.         }
  61.     }
  62.  
  63.     static {
  64.  
  65.         block = (BlockQuestion) (new BlockQuestion().setHardness(2.0F).setResistance(10.0F).setLightLevel(0.1F).setUnlocalizedName("Question")
  66.                 .setLightOpacity(0).setCreativeTab(mcreator_marioTab.tab));
  67.         block.setHarvestLevel("pickaxe", 4);
  68.     }
  69.  
  70.     public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
  71.     }
  72.  
  73.     public void generateNether(World world, Random random, int chunkX, int chunkZ) {
  74.     }
  75.  
  76.     static class BlockQuestion extends Block {
  77.  
  78.         int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0;
  79.  
  80.         boolean red = false;
  81.  
  82.         protected BlockQuestion() {
  83.             super(Material.GROUND);
  84.  
  85.             setSoundType(SoundType.STONE);
  86.  
  87.         }
  88.  
  89.         @Override
  90.         public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
  91.             int i = pos.getX();
  92.             int j = pos.getY();
  93.             int k = pos.getZ();
  94.             world.scheduleUpdate(new BlockPos(i, j, k), this, this.tickRate(world));
  95.  
  96.         }
  97.  
  98.         @Override
  99.         public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
  100.             return red ? 15 : 0;
  101.         }
  102.  
  103.         @Override
  104.         public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
  105.             return red ? 15 : 0;
  106.         }
  107.  
  108.         @Override
  109. public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity){
  110. int i = pos.getX();int j = pos.getY();int k = pos.getZ();
  111. if (((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() !== null && ((EntityPlayer)entity).inventory.armorItemInSlot(3).getItem() == Items.DIAMOND_HELMET){
  112. world.setBlockState(new BlockPos(i, j, k), mcreator_brickBlock.block.getDefaultState(), 3);
  113. }
  114.  
  115. }
  116.  
  117.         @SideOnly(Side.CLIENT)
  118.         @Override
  119.         public BlockRenderLayer getBlockLayer() {
  120.             return BlockRenderLayer.SOLID;
  121.         }
  122.  
  123.         @Override
  124.         @javax.annotation.Nullable
  125.         public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) {
  126.             return NULL_AABB;
  127.         }
  128.  
  129.         @Override
  130.         public boolean isFullCube(IBlockState state) {
  131.             return false;
  132.         }
  133.  
  134.         @Override
  135.         public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
  136.             return new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
  137.         }
  138.  
  139.         @Override
  140.         public int tickRate(World world) {
  141.             return 10;
  142.         }
  143.  
  144.         @Override
  145.         public int quantityDropped(Random par1Random) {
  146.             return 1;
  147.         }
  148.  
  149.     }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement