@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/monster/EntityZombie.java
|
||||
+++ b/net/minecraft/world/entity/monster/EntityZombie.java
|
||||
@@ -65,6 +65,15 @@
|
||||
@@ -67,6 +67,15 @@
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
public class EntityZombie extends EntityMonster {
|
||||
|
||||
private static final MinecraftKey SPEED_MODIFIER_BABY_ID = MinecraftKey.withDefaultNamespace("baby");
|
||||
@@ -89,6 +98,7 @@
|
||||
@@ -91,6 +100,7 @@
|
||||
private boolean canBreakDoors;
|
||||
private int inWaterTime;
|
||||
public int conversionTime;
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
public EntityZombie(EntityTypes<? extends EntityZombie> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -205,7 +215,10 @@
|
||||
@@ -203,7 +213,10 @@
|
||||
public void tick() {
|
||||
if (!this.level().isClientSide && this.isAlive() && !this.isNoAi()) {
|
||||
if (this.isUnderWaterConverting()) {
|
||||
@@ -36,7 +36,7 @@
|
||||
if (this.conversionTime < 0) {
|
||||
this.doUnderWaterConversion();
|
||||
}
|
||||
@@ -222,6 +235,7 @@
|
||||
@@ -220,6 +233,7 @@
|
||||
}
|
||||
|
||||
super.tick();
|
||||
@@ -44,7 +44,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -256,6 +270,7 @@
|
||||
@@ -254,6 +268,7 @@
|
||||
}
|
||||
|
||||
public void startUnderWaterConversion(int i) {
|
||||
@@ -52,36 +52,65 @@
|
||||
this.conversionTime = i;
|
||||
this.getEntityData().set(EntityZombie.DATA_DROWNED_CONVERSION_ID, true);
|
||||
}
|
||||
@@ -269,11 +284,15 @@
|
||||
@@ -267,26 +282,39 @@
|
||||
}
|
||||
|
||||
protected void convertToZombieType(EntityTypes<? extends EntityZombie> entitytypes) {
|
||||
- EntityZombie entityzombie = (EntityZombie) this.convertTo(entitytypes, true);
|
||||
+ EntityZombie entityzombie = (EntityZombie) this.convertTo(entitytypes, true, EntityTransformEvent.TransformReason.DROWNED, CreatureSpawnEvent.SpawnReason.DROWNED);
|
||||
|
||||
if (entityzombie != null) {
|
||||
- this.convertTo(entitytypes, ConversionParams.single(this, true, true), (entityzombie) -> {
|
||||
+ EntityZombie converted = this.convertTo(entitytypes, ConversionParams.single(this, true, true), (entityzombie) -> { // CraftBukkit
|
||||
entityzombie.handleAttributes(entityzombie.level().getCurrentDifficultyAt(entityzombie.blockPosition()).getSpecialMultiplier());
|
||||
entityzombie.setCanBreakDoors(entityzombie.supportsBreakDoorGoal() && this.canBreakDoors());
|
||||
+ // CraftBukkit start - SPIGOT-5208: End conversion to stop event spam
|
||||
+ } else {
|
||||
+ ((Zombie) getBukkitEntity()).setConversionTime(-1);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
- });
|
||||
+ // CraftBukkit start
|
||||
+ }, EntityTransformEvent.TransformReason.DROWNED, CreatureSpawnEvent.SpawnReason.DROWNED);
|
||||
+ if (converted == null) {
|
||||
+ ((Zombie) getBukkitEntity()).setConversionTime(-1); // CraftBukkit - SPIGOT-5208: End conversion to stop event spam
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -312,9 +331,9 @@
|
||||
if (EntityPositionTypes.isSpawnPositionOk(entitytypes, this.level(), blockposition) && EntityPositionTypes.checkSpawnRules(entitytypes, worldserver, EnumMobSpawn.REINFORCEMENT, blockposition, this.level().random)) {
|
||||
|
||||
@VisibleForTesting
|
||||
public boolean convertVillagerToZombieVillager(WorldServer worldserver, EntityVillager entityvillager) {
|
||||
+ // CraftBukkit start
|
||||
+ return convertVillagerToZombieVillager(worldserver, entityvillager, this.blockPosition(), this.isSilent(), EntityTransformEvent.TransformReason.INFECTION, CreatureSpawnEvent.SpawnReason.INFECTION) != null;
|
||||
+ }
|
||||
+
|
||||
+ public static EntityZombieVillager convertVillagerToZombieVillager(WorldServer worldserver, EntityVillager entityvillager, net.minecraft.core.BlockPosition blockPosition, boolean silent, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
+ // CraftBukkit end
|
||||
EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, ConversionParams.single(entityvillager, true, true), (entityzombievillager1) -> {
|
||||
entityzombievillager1.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityzombievillager1.blockPosition()), EntitySpawnReason.CONVERSION, new EntityZombie.GroupDataZombie(false, true));
|
||||
entityzombievillager1.setVillagerData(entityvillager.getVillagerData());
|
||||
entityzombievillager1.setGossips((NBTBase) entityvillager.getGossips().store(DynamicOpsNBT.INSTANCE));
|
||||
entityzombievillager1.setTradeOffers(entityvillager.getOffers().copy());
|
||||
entityzombievillager1.setVillagerXp(entityvillager.getVillagerXp());
|
||||
- if (!this.isSilent()) {
|
||||
- worldserver.levelEvent((EntityHuman) null, 1026, this.blockPosition(), 0);
|
||||
+ // CraftBukkit start
|
||||
+ if (!silent) {
|
||||
+ worldserver.levelEvent((EntityHuman) null, 1026, blockPosition, 0);
|
||||
}
|
||||
|
||||
- });
|
||||
+ }, transformReason, spawnReason);
|
||||
|
||||
- return entityzombievillager != null;
|
||||
+ return entityzombievillager;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
protected boolean isSunSensitive() {
|
||||
@@ -324,9 +352,9 @@
|
||||
if (EntityPositionTypes.isSpawnPositionOk(entitytypes, worldserver, blockposition) && EntityPositionTypes.checkSpawnRules(entitytypes, worldserver, EntitySpawnReason.REINFORCEMENT, blockposition, worldserver.random)) {
|
||||
entityzombie.setPos((double) i1, (double) j1, (double) k1);
|
||||
if (!this.level().hasNearbyAlivePlayer((double) i1, (double) j1, (double) k1, 7.0D) && this.level().isUnobstructed(entityzombie) && this.level().noCollision((Entity) entityzombie) && !this.level().containsAnyLiquid(entityzombie.getBoundingBox())) {
|
||||
if (!worldserver.hasNearbyAlivePlayer((double) i1, (double) j1, (double) k1, 7.0D) && worldserver.isUnobstructed(entityzombie) && worldserver.noCollision((Entity) entityzombie) && (entityzombie.canSpawnInLiquids() || !worldserver.containsAnyLiquid(entityzombie.getBoundingBox()))) {
|
||||
- entityzombie.setTarget(entityliving);
|
||||
+ entityzombie.setTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); // CraftBukkit
|
||||
entityzombie.finalizeSpawn(worldserver, this.level().getCurrentDifficultyAt(entityzombie.blockPosition()), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null);
|
||||
entityzombie.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityzombie.blockPosition()), EntitySpawnReason.REINFORCEMENT, (GroupDataEntity) null);
|
||||
- worldserver.addFreshEntityWithPassengers(entityzombie);
|
||||
+ worldserver.addFreshEntityWithPassengers(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit
|
||||
AttributeModifiable attributemodifiable = this.getAttribute(GenericAttributes.SPAWN_REINFORCEMENTS_CHANCE);
|
||||
AttributeModifier attributemodifier = attributemodifiable.getModifier(EntityZombie.REINFORCEMENT_CALLER_CHARGE_ID);
|
||||
double d0 = attributemodifier != null ? attributemodifier.amount() : 0.0D;
|
||||
@@ -340,7 +359,14 @@
|
||||
@@ -352,7 +380,14 @@
|
||||
float f = this.level().getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty();
|
||||
|
||||
if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < f * 0.3F) {
|
||||
@@ -97,50 +126,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -415,8 +441,17 @@
|
||||
if (worldserver.getDifficulty() != EnumDifficulty.HARD && this.random.nextBoolean()) {
|
||||
return flag;
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ flag = zombifyVillager(worldserver, entityvillager, this.blockPosition(), this.isSilent(), CreatureSpawnEvent.SpawnReason.INFECTION) == null;
|
||||
+ }
|
||||
|
||||
- EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false);
|
||||
+ return flag;
|
||||
+ }
|
||||
+
|
||||
+ public static EntityZombieVillager zombifyVillager(WorldServer worldserver, EntityVillager entityvillager, net.minecraft.core.BlockPosition blockPosition, boolean silent, CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
+ {
|
||||
+ EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false, EntityTransformEvent.TransformReason.INFECTION, spawnReason);
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (entityzombievillager != null) {
|
||||
entityzombievillager.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityzombievillager.blockPosition()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true));
|
||||
@@ -424,15 +459,17 @@
|
||||
entityzombievillager.setGossips((NBTBase) entityvillager.getGossips().store(DynamicOpsNBT.INSTANCE));
|
||||
entityzombievillager.setTradeOffers(entityvillager.getOffers().copy());
|
||||
entityzombievillager.setVillagerXp(entityvillager.getVillagerXp());
|
||||
- if (!this.isSilent()) {
|
||||
- worldserver.levelEvent((EntityHuman) null, 1026, this.blockPosition(), 0);
|
||||
+ // CraftBukkit start
|
||||
+ if (!silent) {
|
||||
+ worldserver.levelEvent((EntityHuman) null, 1026, blockPosition, 0);
|
||||
}
|
||||
|
||||
- flag = false;
|
||||
+ // flag = false;
|
||||
}
|
||||
- }
|
||||
|
||||
- return flag;
|
||||
+ return entityzombievillager;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -385,7 +420,7 @@
|
||||
|
||||
@Override
|
||||
@@ -483,7 +520,7 @@
|
||||
entitychicken1.finalizeSpawn(worldaccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null);
|
||||
public EntityTypes<? extends EntityZombie> getType() {
|
||||
- return super.getType();
|
||||
+ return (EntityTypes<? extends EntityZombie>) super.getType(); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
protected boolean canSpawnInLiquids() {
|
||||
@@ -496,7 +531,7 @@
|
||||
entitychicken1.finalizeSpawn(worldaccess, difficultydamagescaler, EntitySpawnReason.JOCKEY, (GroupDataEntity) null);
|
||||
entitychicken1.setChickenJockey(true);
|
||||
this.startRiding(entitychicken1);
|
||||
- worldaccess.addFreshEntity(entitychicken1);
|
||||
|
||||
Reference in New Issue
Block a user