Advertisement
Guest User

Untitled

a guest
Oct 15th, 2021
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. package aurum.survival;
  2.  
  3. import java.lang.reflect.Field;
  4. import java.util.List;
  5. import net.minecraft.server.*;
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.craftbukkit.CraftServer;
  8. import org.bukkit.craftbukkit.entity.CraftIronGolem;
  9. import org.bukkit.plugin.Plugin;
  10.  
  11. /**
  12. * @author Tim Cancy
  13. */
  14. public class AngryIronGolem extends net.minecraft.server.EntityIronGolem {
  15.  
  16. private AurumSurvival plugin;
  17.  
  18. @SuppressWarnings("unchecked")
  19. public AngryIronGolem(World world) {
  20. super(world);
  21. Plugin pluginAurum = Bukkit.getPluginManager().getPlugin("Aurum Survival");
  22. if (pluginAurum == null || !(pluginAurum instanceof AurumSurvival)) {
  23. this.world.removeEntity(this);
  24. return;
  25. }
  26. this.plugin = (AurumSurvival) pluginAurum;
  27. this.bukkitEntity = new CraftIronGolem((CraftServer) this.plugin.getServer(), this);
  28. try {
  29. Field navigation = EntityLiving.class.getDeclaredField("navigation");
  30. navigation.setAccessible(true);
  31. navigation.set(this, new AurumSurvivalNavigation(this.plugin, this, this.world, 16.0f));
  32. } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
  33. }
  34. try {
  35. Field goala = this.goalSelector.getClass().getDeclaredField("a");
  36. goala.setAccessible(true);
  37. ((List<PathfinderGoal>) goala.get(this.goalSelector)).clear();
  38. Field targeta = this.targetSelector.getClass().getDeclaredField("a");
  39. targeta.setAccessible(true);
  40. ((List<PathfinderGoal>) targeta.get(this.targetSelector)).clear();
  41. this.goalSelector.a(1, new PathfinderGoalMeleeAttack(this, 0.25F, true));
  42. this.goalSelector.a(2, new PathfinderGoalMoveTowardsTarget(this, 0.22F, 32.0F));
  43. this.goalSelector.a(3, new PathfinderGoalMoveThroughVillage(this, 0.16F, true));
  44. this.goalSelector.a(4, new PathfinderGoalMoveTowardsRestriction(this, 0.16F));
  45. this.goalSelector.a(5, new PathfinderGoalOfferFlower(this));
  46. this.goalSelector.a(6, new PathfinderGoalRandomStroll(this, 0.16F));
  47. this.goalSelector.a(7, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F));
  48. this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this));
  49. this.targetSelector.a(1, new PathfinderGoalDefendVillage(this));
  50. this.targetSelector.a(2, new PathfinderGoalHurtByTarget(this, false));
  51. this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityMonster.class, 16.0F, 0, false, true));
  52. } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
  53. }
  54. }
  55.  
  56. public void anger() {
  57. this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 16.0F, 0, false, true));
  58. }
  59.  
  60. public void rose(boolean bool) {
  61. super.e(bool);
  62. }
  63. }
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement