Guest User

Untitled

a guest
Mar 11th, 2020
126
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package net.mcreator.endrevival;
  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.client.model.ModelLoader;
  7. import net.minecraftforge.client.event.ModelRegistryEvent;
  8.  
  9. import net.minecraft.item.ItemBlock;
  10. import net.minecraft.item.Item;
  11. import net.minecraft.creativetab.CreativeTabs;
  12. import net.minecraft.client.renderer.block.model.ModelResourceLocation;
  13. import net.minecraft.block.state.IBlockState;
  14. import net.minecraft.block.material.Material;
  15. import net.minecraft.block.SoundType;
  16. import net.minecraft.block.Block;
  17. import net.minecraft.world.World;
  18. import net.minecraft.util.math.BlockPos;
  19. import net.minecraft.entity.Entity;
  20. import net.minecraft.entity.EntityLivingBase;
  21.  
  22. @Elementsendrevival.ModElement.Tag
  23. public class MCreatorChorusblock extends Elementsendrevival.ModElement {
  24. @GameRegistry.ObjectHolder("endrevival:chorusblock")
  25. public static final Block block = null;
  26.  
  27. public MCreatorChorusblock(Elementsendrevival instance) {
  28. super(instance, 34);
  29. }
  30.  
  31. @Override
  32. public void initElements() {
  33. elements.blocks.add(() -> new BlockCustom());
  34. elements.items.add(() -> new ItemBlock(block).setRegistryName(block.getRegistryName()));
  35. }
  36.  
  37. @SideOnly(Side.CLIENT)
  38. @Override
  39. public void registerModels(ModelRegistryEvent event) {
  40. ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation("endrevival:chorusblock", "inventory"));
  41. }
  42.  
  43. public static class BlockCustom extends Block {
  44. public BlockCustom() {
  45. super(Material.CIRCUITS);
  46. setRegistryName("chorusblock");
  47. setUnlocalizedName("chorusblock");
  48. setSoundType(SoundType.SLIME);
  49. setHardness(0.05F);
  50. setResistance(0F);
  51. setLightLevel(0F);
  52. setLightOpacity(255);
  53. setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
  54. }
  55.  
  56. @Override
  57. public boolean isOpaqueCube(IBlockState state) {
  58. return false;
  59. }
  60. }
  61.  
  62. public void onFallenUpon(World worldIn, BlockPos pos, Entity entityIn, float fallDistance)
  63. {
  64. if (entityIn.isSneaking())
  65. {
  66. super.onFallenUpon(worldIn, pos, entityIn, fallDistance);
  67. }
  68. else
  69. {
  70. entityIn.fall(fallDistance, 0.0F);
  71. }
  72. }
  73.  
  74. /**
  75. * Called when an Entity lands on this Block. This method *must* update motionY because the entity will not do that
  76. * on its own
  77. */
  78. public void onLanded(World worldIn, Entity entityIn)
  79. {
  80. if (entityIn.isSneaking())
  81. {
  82. super.onLanded(worldIn, entityIn);
  83. }
  84. else if (entityIn.motionY < 0.0D)
  85. {
  86. entityIn.motionY = -entityIn.motionY;
  87.  
  88. if (!(entityIn instanceof EntityLivingBase))
  89. {
  90. entityIn.motionY *= 0.8D;
  91. }
  92. }
  93. }
  94.  
  95. /**
  96. * Triggered whenever an entity collides with this block (enters into the block)
  97. */
  98. public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn)
  99. {
  100. if (Math.abs(entityIn.motionY) < 0.1D && !entityIn.isSneaking())
  101. {
  102. double d0 = 0.4D + Math.abs(entityIn.motionY) * 0.2D;
  103. entityIn.motionX *= d0;
  104. entityIn.motionZ *= d0;
  105. }
  106.  
  107. super.onEntityWalk(worldIn, pos, entityIn);
  108. }
  109. }
RAW Paste Data