Advertisement
Guest User

Custom code to improve mods

a guest
Dec 17th, 2017
4,172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.26 KB | None | 0 0
  1. ________________________________________________
  2. Tooltip for items, eg armour, food, ect.
  3.  
  4. Imports:
  5. import net.minecraftforge.fml.relauncher.SideOnly;
  6. import net.minecraft.entity.player.EntityPlayer;
  7. import java.util.List;
  8.  
  9. Code:
  10. @SideOnly(Side.CLIENT)
  11.         public void addInformation(ItemStack itemStack, EntityPlayer player, List dataList, boolean bool) {
  12.             dataList.add("\u00A7fThis is a tooltip");
  13.         }
  14. __________________________________________________
  15. Tooltip for blocks.
  16.  
  17. Imports:
  18. import net.minecraftforge.fml.relauncher.SideOnly;
  19. import javax.annotation.Nullable;
  20. import net.minecraft.client.util.ITooltipFlag;
  21. import java.util.List;
  22.  
  23. Code:
  24.  
  25. @SideOnly(Side.CLIENT)
  26.         public void addInformation(ItemStack stack, @Nullable World player, List<String> tooltip, ITooltipFlag advanced)
  27.         {
  28.             tooltip.add("\u00A7fThis is a tooltip");
  29.         }
  30.  
  31. Colour codes for tooltips, see https://minecraft.gamepedia.com/Formatting_codes
  32.  
  33. _________________________________________________________
  34. Enchanted glow effect, used on nether star and golden apple.
  35.  
  36. Imports:
  37. import net.minecraftforge.fml.relauncher.SideOnly;
  38.  
  39. Code:
  40.     @SideOnly(Side.CLIENT)
  41.                 public boolean hasEffect(ItemStack par1ItemStack)
  42.                 {
  43.                  return true;
  44.                 }
  45. _____________________________________________________
  46. Makes it so tools cannot be enchantable with books. Setting enchantability to 0 in mcreator only disables it for enchanting it via enchanting table.
  47.  
  48. Code:
  49.  
  50. @Override
  51.     public boolean isBookEnchantable( final ItemStack itemstack1, final ItemStack itemstack2 )
  52.     {
  53.         return false;
  54.     }
  55. ____________________________________________________
  56.  
  57. Random amount of items dropped when broken block.
  58.  
  59.  
  60. Code:
  61.  
  62. public int quantityDropped(IBlockState state, int fortune, Random random) {
  63.   return random.nextInt(5) + 1;
  64.  }
  65. ____________________________________________________
  66.  
  67. How much xp is given when block is broken.
  68.  
  69. Code:
  70.  
  71.      public int getExpDrop(IBlockState state, IBlockAccess world, BlockPos pos, int fortune)
  72.          {
  73.              return 1;
  74.          }
  75.  
  76. ______________________________________________________
  77. If block has properties of bookshelf, make number higher for better enchanting power.
  78.  
  79. Code:
  80.  
  81.     public float getEnchantPowerBonus(World world, BlockPos pos)
  82.     {
  83.         return 1;
  84.     }
  85. _____________________________________________________
  86. If block can be used as a beacon base.
  87.  
  88. Code:
  89.  
  90.     public boolean isBeaconBase(IBlockAccess worldObj, BlockPos pos, BlockPos beacon)
  91.     {
  92.         return true;
  93.     }
  94. _____________________________________________________
  95. If block can be broken by Wither or Enderdragon.
  96.  
  97. Imports:
  98. import net.minecraft.entity.Entity;
  99.  
  100. Code:
  101.  
  102.     @Override
  103.     public boolean canEntityDestroy(IBlockState state, IBlockAccess world, BlockPos pos, Entity entity) {
  104.         if (entity instanceof net.minecraft.entity.boss.EntityDragon) {
  105.             return false;
  106.         }
  107.         else if ((entity instanceof net.minecraft.entity.boss.EntityWither) || (entity instanceof net.minecraft.entity.projectile.EntityWitherSkull)) {
  108.             return false;
  109.         }
  110.         return true;
  111.     }
  112. __________________________________________________________
  113.  
  114. Adjust speed of how fast you eat this food, default is 32.
  115.  
  116. Code:
  117. public int getMaxItemUseDuration(ItemStack stack)
  118.     {
  119.         return 32;
  120.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement