Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.95 KB | None | 0 0
  1. --- ../src-base/minecraft/net/minecraft/entity/monster/EntityZombie.java
  2. +++ ../src-work/minecraft/net/minecraft/entity/monster/EntityZombie.java
  3. @@ -51,6 +51,10 @@
  4. import net.minecraft.world.storage.loot.LootTableList;
  5. import net.minecraftforge.fml.relauncher.Side;
  6. import net.minecraftforge.fml.relauncher.SideOnly;
  7. +import org.bukkit.event.entity.CreatureSpawnEvent;
  8. +import org.bukkit.event.entity.EntityCombustByEntityEvent;
  9. +import org.bukkit.event.entity.EntityCombustEvent;
  10. +import org.bukkit.event.entity.EntityTargetEvent;
  11.  
  12. public class EntityZombie extends EntityMob
  13. {
  14. @@ -87,7 +91,7 @@
  15. this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false));
  16. this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true, new Class[] {EntityPigZombie.class}));
  17. this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
  18. - this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityVillager.class, false));
  19. + if (world.spigotConfig.zombieAggressiveTowardsVillager) this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityVillager.class, false)); // Spigot
  20. this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityIronGolem.class, true));
  21. }
  22.  
  23. @@ -98,7 +102,7 @@
  24. this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.23000000417232513D);
  25. this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(3.0D);
  26. this.getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(2.0D);
  27. - this.getAttributeMap().registerAttribute(SPAWN_REINFORCEMENTS_CHANCE).setBaseValue(this.rand.nextDouble() * 0.10000000149011612D);
  28. + this.getAttributeMap().registerAttribute(SPAWN_REINFORCEMENTS_CHANCE).setBaseValue(this.rand.nextDouble() * net.minecraftforge.common.ForgeModContainer.zombieSummonBaseChance);
  29. }
  30.  
  31. protected void entityInit()
  32. @@ -215,7 +219,13 @@
  33.  
  34. if (flag)
  35. {
  36. - this.setFire(8);
  37. + // this.setFire(8);
  38. + EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8);
  39. + this.world.getServer().getPluginManager().callEvent(event);
  40. +
  41. + if (!event.isCancelled()) {
  42. + this.setFire(event.getDuration());
  43. + }
  44. }
  45. }
  46. }
  47. @@ -239,12 +249,24 @@
  48. entitylivingbase = (EntityLivingBase)source.getTrueSource();
  49. }
  50.  
  51. - if (entitylivingbase != null && this.world.getDifficulty() == EnumDifficulty.HARD && (double)this.rand.nextFloat() < this.getEntityAttribute(SPAWN_REINFORCEMENTS_CHANCE).getAttributeValue() && this.world.getGameRules().getBoolean("doMobSpawning"))
  52. + int i = MathHelper.floor(this.posX);
  53. + int j = MathHelper.floor(this.posY);
  54. + int k = MathHelper.floor(this.posZ);
  55. + net.minecraftforge.event.entity.living.ZombieEvent.SummonAidEvent summonAid = net.minecraftforge.event.ForgeEventFactory.fireZombieSummonAid(this, world, i, j, k, entitylivingbase, this.getEntityAttribute(SPAWN_REINFORCEMENTS_CHANCE).getAttributeValue());
  56. + if (summonAid.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return true;
  57. +
  58. + if (summonAid.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW ||
  59. + entitylivingbase != null && this.world.getDifficulty() == EnumDifficulty.HARD && (double)this.rand.nextFloat() < this.getEntityAttribute(SPAWN_REINFORCEMENTS_CHANCE).getAttributeValue() && this.world.getGameRules().getBoolean("doMobSpawning"))
  60. {
  61. - int i = MathHelper.floor(this.posX);
  62. - int j = MathHelper.floor(this.posY);
  63. - int k = MathHelper.floor(this.posZ);
  64. - EntityZombie entityzombie = new EntityZombie(this.world);
  65. + EntityZombie entityzombie;
  66. + if (summonAid.getCustomSummonedAid() != null && summonAid.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW)
  67. + {
  68. + entityzombie = summonAid.getCustomSummonedAid();
  69. + }
  70. + else
  71. + {
  72. + entityzombie = new EntityZombie(this.world);
  73. + }
  74.  
  75. for (int l = 0; l < 50; ++l)
  76. {
  77. @@ -252,14 +274,14 @@
  78. int j1 = j + MathHelper.getInt(this.rand, 7, 40) * MathHelper.getInt(this.rand, -1, 1);
  79. int k1 = k + MathHelper.getInt(this.rand, 7, 40) * MathHelper.getInt(this.rand, -1, 1);
  80.  
  81. - if (this.world.getBlockState(new BlockPos(i1, j1 - 1, k1)).isTopSolid() && this.world.getLightFromNeighbors(new BlockPos(i1, j1, k1)) < 10)
  82. + if (this.world.getBlockState(new BlockPos(i1, j1 - 1, k1)).isSideSolid(this.world, new BlockPos(i1, j1 - 1, k1), net.minecraft.util.EnumFacing.UP) && this.world.getLightFromNeighbors(new BlockPos(i1, j1, k1)) < 10)
  83. {
  84. entityzombie.setPosition((double)i1, (double)j1, (double)k1);
  85.  
  86. if (!this.world.isAnyPlayerWithinRangeAt((double)i1, (double)j1, (double)k1, 7.0D) && this.world.checkNoEntityCollision(entityzombie.getEntityBoundingBox(), entityzombie) && this.world.getCollisionBoxes(entityzombie, entityzombie.getEntityBoundingBox()).isEmpty() && !this.world.containsAnyLiquid(entityzombie.getEntityBoundingBox()))
  87. {
  88. - this.world.spawnEntity(entityzombie);
  89. - entityzombie.setAttackTarget(entitylivingbase);
  90. + this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS);
  91. + if (entitylivingbase != null) entityzombie.setGoalTarget(entitylivingbase, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true);
  92. entityzombie.onInitialSpawn(this.world.getDifficultyForLocation(new BlockPos(entityzombie)), (IEntityLivingData)null);
  93. this.getEntityAttribute(SPAWN_REINFORCEMENTS_CHANCE).applyModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0));
  94. entityzombie.getEntityAttribute(SPAWN_REINFORCEMENTS_CHANCE).applyModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0));
  95. @@ -287,7 +309,13 @@
  96.  
  97. if (this.getHeldItemMainhand().isEmpty() && this.isBurning() && this.rand.nextFloat() < f * 0.3F)
  98. {
  99. - entityIn.setFire(2 * (int)f);
  100. + // entityIn.setFire(2 * (int)f);
  101. + EntityCombustByEntityEvent event = new EntityCombustByEntityEvent(this.getBukkitEntity(), entityIn.getBukkitEntity(), 2 * (int) f); // PAIL: fixme
  102. + this.world.getServer().getPluginManager().callEvent(event);
  103. +
  104. + if (!event.isCancelled()) {
  105. + entityIn.setFire(event.getDuration());
  106. + }
  107. }
  108. }
  109.  
  110. @@ -393,7 +421,7 @@
  111. EntityZombieVillager entityzombievillager = new EntityZombieVillager(this.world);
  112. entityzombievillager.copyLocationAndAnglesFrom(entityvillager);
  113. this.world.removeEntity(entityvillager);
  114. - entityzombievillager.onInitialSpawn(this.world.getDifficultyForLocation(new BlockPos(entityzombievillager)), new EntityZombie.GroupData(false));
  115. + entityzombievillager.onInitialSpawn(this.world.getDifficultyForLocation(new BlockPos(entityzombievillager)), new GroupData(false));
  116. entityzombievillager.setProfession(entityvillager.getProfession());
  117. entityzombievillager.setChild(entityvillager.isChild());
  118. entityzombievillager.setNoAI(entityvillager.isAIDisabled());
  119. @@ -404,7 +432,7 @@
  120. entityzombievillager.setAlwaysRenderNameTag(entityvillager.getAlwaysRenderNameTag());
  121. }
  122.  
  123. - this.world.spawnEntity(entityzombievillager);
  124. + this.world.addEntity(entityzombievillager, CreatureSpawnEvent.SpawnReason.INFECTION);
  125. this.world.playEvent((EntityPlayer)null, 1026, new BlockPos(this), 0);
  126. }
  127. }
  128. @@ -435,12 +463,12 @@
  129.  
  130. if (livingdata == null)
  131. {
  132. - livingdata = new EntityZombie.GroupData(this.world.rand.nextFloat() < 0.05F);
  133. + livingdata = new GroupData(this.world.rand.nextFloat() < net.minecraftforge.common.ForgeModContainer.zombieBabyChance);
  134. }
  135.  
  136. - if (livingdata instanceof EntityZombie.GroupData)
  137. + if (livingdata instanceof GroupData)
  138. {
  139. - EntityZombie.GroupData entityzombie$groupdata = (EntityZombie.GroupData)livingdata;
  140. + GroupData entityzombie$groupdata = (GroupData)livingdata;
  141.  
  142. if (entityzombie$groupdata.isChild)
  143. {
  144. @@ -463,7 +491,7 @@
  145. entitychicken1.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
  146. entitychicken1.onInitialSpawn(difficulty, (IEntityLivingData)null);
  147. entitychicken1.setChickenJockey(true);
  148. - this.world.spawnEntity(entitychicken1);
  149. + this.world.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT);
  150. this.startRiding(entitychicken1);
  151. }
  152. }
  153. @@ -531,7 +559,7 @@
  154.  
  155. public void onDeath(DamageSource cause)
  156. {
  157. - super.onDeath(cause);
  158. + // super.onDeath(cause); // CraftBukkit - moved down
  159.  
  160. if (cause.getTrueSource() instanceof EntityCreeper)
  161. {
  162. @@ -548,6 +576,7 @@
  163. }
  164. }
  165. }
  166. + super.onDeath(cause);
  167. }
  168.  
  169. protected ItemStack getSkullDrop()
  170. © 2020 GitHub, Inc.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement