Advertisement
supersaiyansubtlety

player_interact_statics.zs

Feb 17th, 2020
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. #priority 1000
  2.  
  3. import crafttweaker.enchantments.IEnchantmentDefinition;
  4. import crafttweaker.enchantments.IEnchantment;
  5. import crafttweaker.block.IBlockDefinition;
  6. import crafttweaker.block.IBlock;
  7. import crafttweaker.block.IBlockState;
  8. /* import crafttweaker.event.PlayerInteractEvent; */
  9. import crafttweaker.event.IPlayerEvent;
  10. import mods.contenttweaker.Commands;
  11. import mods.ctutils.utils.Math;
  12. import crafttweaker.entity.IEntityEquipmentSlot as slots;
  13.  
  14.  
  15.  
  16. function getUnbreakingLevel (enchantments as IEnchantment []) as int
  17. {
  18. val unbreaking as IEnchantmentDefinition [] = [<enchantment:minecraft:unbreaking>] as IEnchantmentDefinition [];
  19.  
  20. for enchant in enchantments
  21. {
  22. if (unbreaking[0].id == enchant.definition.id)
  23. {
  24. return enchant.level;
  25. }
  26. }
  27. return 0;
  28. }
  29.  
  30. function damageTool(event as IPlayerEvent)
  31. {
  32. val unbreakingLvl = getUnbreakingLevel(event.player.currentItem.enchantments);
  33.  
  34. if(Math.random() < (0.5/((unbreakingLvl as float) + 1.0)))
  35. {
  36. if(event.player.currentItem.damage < event.player.currentItem.maxDamage)
  37. {
  38. event.player.setItemToSlot(slots.mainHand(), event.player.currentItem.withDamage(event.player.currentItem.damage + 1));
  39. }
  40. else
  41. {
  42. Commands.call("playsound entity.item.break player @s", event.player, event.player.world, false, true);
  43. event.player.setItemToSlot(slots.mainHand(), null);
  44. }
  45. }
  46. }
  47.  
  48. static hoeMatchState as IBlockState[IBlockDefinition] =
  49. {
  50. <block:vbe:stairscoarsedirt>.getBlock().definition : <blockstate:vbe:stairsdirt>,
  51. <block:vbe:slabcoarsedirt>.getBlock().definition : <blockstate:vbe:slabdirt>,
  52. <block:blocklayering:layer_coarse_dirt>.getBlock().definition : <blockstate:blocklayering:layer_dirt>
  53. };
  54.  
  55. /* static shovelable as IBlock[IBlock] =
  56. [
  57. <block:minecraft:grass_path> : <block:minecraft:grass>,
  58. <block:vbe:stairspath> : <block:vbe:stairsgrass>,
  59. <block:vbe:slabpath> : <block:vbe:slabgrass>,
  60. <block:blocklayering:layer_path> : <block:blocklayering:layer_grass>
  61. ]; */
  62. /* static hoeable as IBlock[IBlockDefinition] =
  63. {
  64. <vbe:stairscoarsedirt>.asBlock().definition : <vbe:stairsdirt>.asBlock(),
  65. <vbe:slabcoarsedirt>.asBlock().definition : <vbe:slabdirt>.asBlock(),
  66. <blocklayering:layer_coarse_dirt>.asBlock().definition : <blocklayering:layer_dirt>.asBlock(),
  67. <minecraft:grass_path>.asBlock().definition : <minecraft:grass>.asBlock(),
  68. <vbe:stairspath>.asBlock().definition : <vbe:stairsgrass>.asBlock(),
  69. <vbe:slabpath>.asBlock().definition : <vbe:slabgrass>.asBlock(),
  70. <blocklayering:layer_path>.asBlock().definition : <blocklayering:layer_grass>.asBlock(),
  71. <minecraft:farmland>.asBlock().definition : <vbe:stairsdirt>.asBlock()
  72. }; */
  73.  
  74. /* static hoeableIds as string[string] =
  75. {
  76. <vbe:stairscoarsedirt>.asBlock().definition.id : <vbe:stairsdirt>.asBlock().definition.id,
  77. <vbe:slabcoarsedirt>.asBlock().definition.id : <vbe:slabdirt>.asBlock().definition.id,
  78. <blocklayering:layer_coarse_dirt>.asBlock().definition.id : <blocklayering:layer_dirt>.asBlock().definition.id,
  79. <minecraft:grass_path>.asBlock().definition.id : <minecraft:grass>.asBlock().definition.id,
  80. <minecraft:grass_path>.asBlock().definition.id : <minecraft:grass>.asBlock().definition.id,
  81. <vbe:stairspath>.asBlock().definition.id : <vbe:stairsgrass>.asBlock().definition.id,
  82. <vbe:slabpath>.asBlock().definition.id : <vbe:slabgrass>.asBlock().definition.id,
  83. <blocklayering:layer_path>.asBlock().definition.id : <blocklayering:layer_grass>.asBlock().definition.id
  84. }; */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement