Guest User

Untitled

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