Sunconure111

Untitled

Apr 21st, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.91 KB | None | 0 0
  1. //TODO: NEW ICON FOR SPIRITUAL_WARD
  2. public static final EnumGolemTrait SPIRITUAL_WARD = EnumHelper.addEnum(EnumGolemTrait.class, "SPIRITUAL_WARD", new Class[]{ResourceLocation.class}, new ResourceLocation(Bewitchment.MODID, "textures/thaumcraft/golems/tag_blessed.png"));
  3. public static final EnumGolemTrait UNCANNY = EnumHelper.addEnum(EnumGolemTrait.class, "UNCANNY", new Class[]{ResourceLocation.class}, new ResourceLocation(Bewitchment.MODID, "textures/thaumcraft/golems/tag_uncanny.png"));
  4. public static final EnumGolemTrait BLESSED = EnumHelper.addEnum(EnumGolemTrait.class, "BLESSED", new Class[]{ResourceLocation.class}, new ResourceLocation(Bewitchment.MODID, "textures/thaumcraft/golems/tag_blessed.png"));
  5.  
  6. public static void init() {
  7. ThaumcraftApi.registerResearchLocation(new ResourceLocation(Bewitchment.MODID, "tc/research/bewitchment"));
  8. ScanningManager.addScannableThing(new ScanOreDictionary("f_MATCOLDIRON", new String[]{"ingotColdIron", "blockColdIron", "nuggetColdIron"}));
  9. ScanningManager.addScannableThing(new ScanOreDictionary("f_MATDRAGONSBLOOD", new String[]{"resinDragonsBlood", "blockDragonsBloodResin"}));
  10. ScanningManager.addScannableThing(new ScanOreDictionary("f_MATSILVER", new String[]{"ingotSilver", "blockSilver", "plateSilver", "dustSilver", "nuggetSilver", "oreSilver"}));
  11. GolemMaterial.register(new GolemMaterial("COLDIRON", new String[]{"MATSTUDCOLDIRON"}, new ResourceLocation("bewitchment", "textures/entity/coldirongolem.png"), 2699070, 20, 8, 3, new ItemStack(ModObjects.cold_iron_plate), new ItemStack(ItemsTC.mechanismSimple), new EnumGolemTrait[]{EnumGolemTrait.HEAVY, EnumGolemTrait.FIREPROOF, EnumGolemTrait.BLASTPROOF, SPIRITUAL_WARD}));
  12. GolemMaterial.register(new GolemMaterial("DRAGONSBLOOD", new String[]{"MATSTUDDRAGONSBLOOD"}, new ResourceLocation("bewitchment", "textures/entity/dragonsbloodgolem.png"), 4786944, 10, 1, 1, new ItemStack(ModObjects.dragons_blood_resin), new ItemStack(ItemsTC.mechanismSimple), new EnumGolemTrait[]{EnumGolemTrait.FRAGILE, EnumGolemTrait.CLUMSY, EnumGolemTrait.LIGHT, UNCANNY}));
  13. GolemMaterial.register(new GolemMaterial("SILVER", new String[]{"MATSTUDSILVER"}, new ResourceLocation("bewitchment", "textures/entity/silvergolem.png"), 10922156, 14, 3, 2, new ItemStack(ModObjects.silver_plate), new ItemStack(ItemsTC.mechanismSimple), new EnumGolemTrait[]{EnumGolemTrait.LIGHT, BLESSED}));
  14.  
  15. }
  16.  
  17.  
  18. private static Aspect getOrCreateAspect(String tag, int color, Aspect[] components, ResourceLocation image) {
  19. Aspect a = Aspect.getAspect(tag);
  20. if (a != null) return a;
  21. return new Aspect(tag, color, components, image, 1);
  22. }
  23.  
  24. public static boolean isColdIronGolem(EntityLivingBase golem) {
  25. return golem instanceof EntityThaumcraftGolem && ((EntityThaumcraftGolem) golem).getProperties().hasTrait(SPIRITUAL_WARD);
  26. }
  27.  
  28. public static boolean isSilverGolem(EntityLivingBase golem) {
  29. return golem instanceof EntityThaumcraftGolem && ((EntityThaumcraftGolem) golem).getProperties().hasTrait(BLESSED);
  30. }
  31.  
  32. public static boolean isDragonsBloodGolem(EntityLivingBase golem) {
  33. return golem instanceof EntityThaumcraftGolem && ((EntityThaumcraftGolem) golem).getProperties().hasTrait(UNCANNY);
  34. }
  35.  
  36. //Todo: Apply slowness to all mobs attacked by this + make mobs flee it's presence.
  37. @SubscribeEvent
  38. public void handleDragonsBloodGolems(LivingHurtEvent event) {
  39. EntityLivingBase entity = event.getEntityLiving();
  40. if (!entity.world.isRemote) {
  41. Entity source = event.getSource().getImmediateSource();
  42. if (source instanceof EntityLivingBase && isDragonsBloodGolem((EntityLivingBase) source)) {
  43. entity.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 600, 0));
  44. }
  45. }
  46. }
  47.  
  48. @SubscribeEvent
  49. public void handleDragonsBloodGolems(LivingEvent.LivingUpdateEvent event) {
  50. if (isDragonsBloodGolem(event.getEntityLiving()) && event.getEntityLiving().getRNG().nextInt(20) == 0) {
  51. EntityThaumcraftGolem golem = (EntityThaumcraftGolem) event.getEntityLiving();
  52. List<EntityMob> mobsNearby = golem.world.getEntitiesWithinAABB(EntityMob.class, golem.getEntityBoundingBox().grow(8));
  53. mobsNearby.forEach(mob -> {
  54. Vec3d vec3d = RandomPositionGenerator.findRandomTargetBlockAwayFrom(golem, 16, 7, new Vec3d(mob.posX, mob.posY, mob.posZ));
  55. if (vec3d != null && mob.getDistanceSq(vec3d.x, vec3d.y, vec3d.z) >= mob.getDistanceSq(golem)) {
  56. Path path = mob.getNavigator().getPathToXYZ(vec3d.x, vec3d.y, vec3d.z);
  57. if (path != null) mob.getNavigator().setPath(path, 1);
  58. }
  59. });
  60. }
  61. }
  62.  
  63.  
  64. @SubscribeEvent
  65. public void handleSilverGolem(LivingHurtEvent event) {
  66. EntityLivingBase entity = event.getEntityLiving();
  67. if (!entity.world.isRemote) {
  68. Entity source = event.getSource().getImmediateSource();
  69. if (source instanceof EntityLivingBase) {
  70. float weakness = BewitchmentAPI.getSilverWeakness(entity);
  71. if (weakness > 1 && isSilverGolem((EntityLivingBase) source)) event.setAmount(event.getAmount() * weakness * 2);
  72. weakness = BewitchmentAPI.getSilverWeakness((EntityLivingBase) source);
  73. if (weakness > 1 && isSilverGolem(entity)) {
  74. event.setAmount(event.getAmount() * 0.4F);
  75. source.attackEntityFrom(DamageSource.causeThornsDamage(entity), 4);
  76. }
  77. }
  78. }
  79. }
  80.  
  81. @SubscribeEvent
  82. public void handleColdIronGolems(LivingHurtEvent event) {
  83. EntityLivingBase entity = event.getEntityLiving();
  84. if (!entity.world.isRemote) {
  85. Entity source = event.getSource().getImmediateSource();
  86. if (source instanceof EntityLivingBase) {
  87. float weakness = BewitchmentAPI.getColdIronWeakness(entity);
  88. if (weakness > 1 && isColdIronGolem((EntityLivingBase) source)) event.setAmount(event.getAmount() * weakness * 2);
  89. weakness = BewitchmentAPI.getColdIronWeakness((EntityLivingBase) source);
  90. if (weakness > 1 && isColdIronGolem(entity)) {
  91. event.setAmount(event.getAmount() * 0.4F);
  92. source.attackEntityFrom(DamageSource.causeThornsDamage(entity), 4);
  93. }
  94. }
  95. }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment