Guest User

Untitled

a guest
Mar 31st, 2020
157
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. public void onFallenUpon(World worldIn, BlockPos pos, Entity entityIn, float fallDistance)
  62. {
  63. if (entityIn.isSneaking())
  64. {
  65. super.onFallenUpon(worldIn, pos, entityIn, fallDistance);
  66. }
  67. else
  68. {
  69. entityIn.fall(fallDistance, 0.0F);
  70. }
  71. }
  72.  
  73. /**
  74. * Called when an Entity lands on this Block. This method *must* update motionY because the entity will not do that
  75. * on its own
  76. */
  77. public void onLanded(World worldIn, Entity entityIn)
  78. {
  79. if (entityIn.isSneaking())
  80. {
  81. super.onLanded(worldIn, entityIn);
  82. }
  83. else if (entityIn.motionY < 0.0D)
  84. {
  85. entityIn.motionY = -entityIn.motionY;
  86.  
  87. if (!(entityIn instanceof EntityLivingBase))
  88. {
  89. entityIn.motionY *= 0.8D;
  90. }
  91. }
  92. }
  93.  
  94. /**
  95. * Triggered whenever an entity collides with this block (enters into the block)
  96. */
  97. public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn)
  98. {
  99. if (Math.abs(entityIn.motionY) < 0.1D && !entityIn.isSneaking())
  100. {
  101. double d0 = 0.4D + Math.abs(entityIn.motionY) * 0.2D;
  102. entityIn.motionX *= d0;
  103. entityIn.motionZ *= d0;
  104. }
  105.  
  106. super.onEntityWalk(worldIn, pos, entityIn);
  107. }
  108. }
  109. }
RAW Paste Data