keaft

Untitled

Apr 9th, 2024 (edited)
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. #Name: events.zs
  2. #reloadable
  3. #Author: Keaft
  4.  
  5. import crafttweaker.data.IData;
  6. import crafttweaker.block.IBlock;
  7. import crafttweaker.block.IBlockState;
  8. import crafttweaker.command.ICommandManager;
  9. import crafttweaker.entity.AttributeInstance;
  10. import crafttweaker.entity.IEntity;
  11. import crafttweaker.entity.IEntityDefinition;
  12. import crafttweaker.entity.IEntityEquipmentSlot;
  13. import crafttweaker.entity.IEntityLivingBase;
  14. import crafttweaker.event.EntityJoinWorldEvent;
  15. import crafttweaker.event.IEventCancelable;
  16. import crafttweaker.event.PlayerInteractBlockEvent;
  17. import crafttweaker.event.PlayerInteractEvent;
  18. import crafttweaker.events.IEventManager;
  19. import crafttweaker.formatting.IFormattedText;
  20. import crafttweaker.item.IItemStack;
  21. import crafttweaker.world.IBlockPos;
  22. import crafttweaker.world.IWorld;
  23. import crafttweaker.player.IPlayer;
  24.  
  25. print("Initializing 'boss_summoning'...");
  26.  
  27.  
  28. events.onPlayerInteractBlock(function(event as PlayerInteractBlockEvent){
  29. var altarBlocks = [<minecraft:stone>,<minecraft:grass>] as IBlock[];
  30. if(event.world.remote || event.hand == "OFF_HAND") {
  31. 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.
  32. }
  33. for i, block in altarBlocks {
  34. event.player.sendMessage("iteration " + i + ": " + block.definition.id as string + " : " + event.block.definition.id as string);
  35. if (altarBlocks has event.block) {
  36. event.player.sendMessage("same");
  37. } else {
  38. event.player.sendMessage("not same");
  39. }
  40. }
  41. if (altarBlocks in event.block) {
  42. var mhItem = event.player.mainHandHeldItem;
  43. var ohItem = event.player.offHandHeldItem;
  44. var x as float = event.x as float;
  45. var y as float = event.y as float;
  46. var z as float = event.z as float;
  47. var aboveY = y + 1;
  48. var localSummonMessage as string = "You feel the ground shake beneath you.";
  49. if (!isNull(mhItem) && <minecraft:diamond>.matches(mhItem)) {
  50. event.player.setItemToSlot(IEntityEquipmentSlot.mainHand(), mhItem.amount == 1 ? null : mhItem.withAmount(mhItem.amount - 1));
  51. /* var totalTacos = 10; */
  52. var zombie as IEntityLivingBase = <entity:minecraft:zombie>.createEntity(event.entityLivingBase.world);
  53. zombie.setCustomName("tacoZombie");
  54. zombie.setItemToSlot(crafttweaker.entity.IEntityEquipmentSlot.head(),<minecraft:diamond_helmet>);
  55. zombie.getAttribute("generic.maxHealth").baseValue = 50.0;
  56. zombie.getAttribute("generic.armor").baseValue = 10.0;
  57. zombie.health = 50;
  58. /* zombie.setNBT({tacos: totalTacos}); */
  59. zombie.setPosition(crafttweaker.util.Position3f.create(x, aboveY, z).asBlockPos());
  60. event.entityLivingBase.world.spawnEntity(zombie);
  61. event.player.sendMessage(zombie.health as string);
  62. event.player.sendMessage("The " + mhItem.displayName + " wrenches from your hand.");
  63. server.commandManager.executeCommand(server,"execute @a[x=" + x as int + ",y=" + y as int + ",z=" + z as int + ",r=15] ~ ~ ~ tellraw @a[x=~1,y=~1,z=~1,rm=0,r=15] [\"" + localSummonMessage + "\"]");
  64. event.cancel();
  65. } else {
  66. if (!isNull(ohItem) && <minecraft:diamond>.matches(ohItem)) {
  67. event.player.setItemToSlot(IEntityEquipmentSlot.offhand(), ohItem.amount == 1 ? null : ohItem.withAmount(ohItem.amount - 1));
  68. //Attempt action
  69. event.cancel();
  70. }
  71. }
  72. return;
  73. }
  74. });
  75.  
  76. print("Initialized 'boss_summoning'");
Advertisement
Add Comment
Please, Sign In to add comment