keaft

Untitled

Apr 8th, 2024
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. #Name: events.zs
  2. #reloadable
  3.  
  4. import crafttweaker.data.IData;
  5. import crafttweaker.block.IBlock;
  6. import crafttweaker.block.IBlockState;
  7. import crafttweaker.command.ICommandManager;
  8. import crafttweaker.entity.AttributeInstance;
  9. import crafttweaker.entity.IEntity;
  10. import crafttweaker.entity.IEntityDefinition;
  11. import crafttweaker.entity.IEntityEquipmentSlot;
  12. import crafttweaker.event.EntityJoinWorldEvent;
  13. import crafttweaker.event.IEventCancelable;
  14. import crafttweaker.event.PlayerInteractBlockEvent;
  15. import crafttweaker.event.PlayerInteractEvent;
  16. import crafttweaker.events.IEventManager;
  17. import crafttweaker.formatting.IFormattedText;
  18. import crafttweaker.item.IItemStack;
  19. import crafttweaker.world.IBlockPos;
  20. import crafttweaker.world.IWorld;
  21. import crafttweaker.player.IPlayer;
  22.  
  23. events.onPlayerInteractBlock(function(event as PlayerInteractBlockEvent){
  24. if(event.world.remote || event.hand == "OFF_HAND") {
  25. return; // If it is on the client or the OFF_HAND, do not continue. 1.12.2 forge doesn't seem to be able to differentiate which hand is being fired here, but limiting it to 1 makes sure it doesn't fire multiple times.
  26. }
  27. if (event.block.definition.id == "minecraft:stone") {
  28. var mhItem = event.player.mainHandHeldItem;
  29. var ohItem = event.player.offHandHeldItem;
  30. var x as float = event.x as float;
  31. var y as float = event.y as float;
  32. var z as float = event.z as float;
  33. if (!isNull(mhItem) && <minecraft:diamond>.matches(mhItem)) {
  34. event.player.setItemToSlot(IEntityEquipmentSlot.mainHand(), mhItem.amount == 1 ? null : mhItem.withAmount(mhItem.amount - 1));
  35. y = y + 1;
  36. /* val customZombieNBT as IData = {
  37. ForgeCaps:{
  38. Health:20.0f,
  39. ArmorItems:[
  40. {
  41. id:"minecraft:iron_boots",
  42. Count:1,
  43. Damage:0
  44. },
  45. {},
  46. {},
  47. {
  48. id:"minecraft:diamond_helmet",
  49. Count:1,
  50. Damage:0
  51. }
  52. ],
  53. HandItems:[
  54. {},
  55. {}
  56. ],
  57. ArmorDropChances:[
  58. 0.085f,
  59. 0.085f,
  60. 0.085f,
  61. 0.085f
  62. ],
  63. HandDropChances:[
  64. 0.085f,
  65. 0.085f
  66. ],
  67. Leashed:0,
  68. LeftHanded:0,
  69. CanBreakDoors:0
  70. }
  71. }; */
  72. var timeToKill = event.world.getWorldTime() +200;
  73. var zombie as IEntityLivingBase = <entity:minecraft:zombie>.createEntity(event.entityLivingBase.world);
  74. zombie.setCustomName("tacoZombie");
  75. zombie.setItemToSlot(crafttweaker.entity.IEntityEquipmentSlot.head(),<minecraft:diamond_helmet>);
  76. zombie.setNBT({killTime: timeToKill});
  77. zombie.setPosition(crafttweaker.util.Position3f.create(x, y, z).asBlockPos());
  78. event.entityLivingBase.world.spawnEntity(zombie);
  79. /* event.player.sendMessage(zombie.getItemInSlot(0).string); */
  80. //server.commandManager.executeCommand(server, "summon minecraft:zombie "~x~" "~y~" "~z);
  81. event.cancel();
  82. } else {
  83. if (!isNull(ohItem) && <minecraft:diamond>.matches(ohItem)) {
  84. event.player.setItemToSlot(IEntityEquipmentSlot.offhand(), ohItem.amount == 1 ? null : ohItem.withAmount(ohItem.amount - 1));
  85. y = y + 1;
  86. server.commandManager.executeCommand(server, "summon minecraft:zombie "~x~" "~y~" "~z);
  87. event.cancel();
  88. }
  89. }
  90. return;
  91. }
  92. });
Advertisement
Add Comment
Please, Sign In to add comment