mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-05 18:27:17 +01:00
parent
8400a7987a
commit
ef79686997
2 changed files with 34 additions and 9 deletions
|
@ -97,21 +97,39 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -411,7 +437,12 @@
|
||||
@@ -411,18 +437,28 @@
|
||||
}
|
||||
|
||||
EntityVillager entityvillager = (EntityVillager) entityliving;
|
||||
- EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false);
|
||||
+ // CraftBukkit start
|
||||
+ EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false, EntityTransformEvent.TransformReason.INFECTION, CreatureSpawnEvent.SpawnReason.INFECTION);
|
||||
+ if (entityzombievillager == null) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ zombifyVillager(worldserver, entityvillager, this.blockPosition(), this.isSilent(), false);
|
||||
+ }
|
||||
+ }
|
||||
|
||||
+ public static EntityZombieVillager zombifyVillager(WorldServer worldserver, EntityVillager entityvillager, net.minecraft.core.BlockPosition blockPosition, boolean silent, boolean custom) {
|
||||
+ EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false, EntityTransformEvent.TransformReason.INFECTION, (custom) ? CreatureSpawnEvent.SpawnReason.CUSTOM : CreatureSpawnEvent.SpawnReason.INFECTION);
|
||||
+ if (entityzombievillager != null) {
|
||||
+ // CraftBukkit end
|
||||
entityzombievillager.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityzombievillager.blockPosition()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true), (NBTTagCompound) null);
|
||||
entityzombievillager.setVillagerData(entityvillager.getVillagerData());
|
||||
@@ -473,7 +504,7 @@
|
||||
entityzombievillager.setGossips((NBTBase) entityvillager.getGossips().store(DynamicOpsNBT.INSTANCE).getValue());
|
||||
entityzombievillager.setTradeOffers(entityvillager.getOffers().createTag());
|
||||
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);
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
+ return entityzombievillager; // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -473,7 +509,7 @@
|
||||
entitychicken1.finalizeSpawn(worldaccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (NBTTagCompound) null);
|
||||
entitychicken1.setChickenJockey(true);
|
||||
this.startRiding(entitychicken1);
|
||||
|
|
|
@ -4,6 +4,8 @@ import com.google.common.base.Preconditions;
|
|||
import java.util.Locale;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.world.entity.monster.EntityZombie;
|
||||
import net.minecraft.world.entity.monster.EntityZombieVillager;
|
||||
import net.minecraft.world.entity.npc.EntityVillager;
|
||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
||||
import net.minecraft.world.level.block.BlockBed;
|
||||
|
@ -14,8 +16,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
|||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.entity.Villager.Profession;
|
||||
import org.bukkit.entity.Villager.Type;
|
||||
import org.bukkit.entity.ZombieVillager;
|
||||
|
||||
public class CraftVillager extends CraftAbstractVillager implements Villager {
|
||||
|
||||
|
@ -121,6 +122,12 @@ public class CraftVillager extends CraftAbstractVillager implements Villager {
|
|||
getHandle().setUnhappy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZombieVillager zombify() {
|
||||
EntityZombieVillager entityzombievillager = EntityZombie.zombifyVillager(getHandle().level.getMinecraftWorld(), getHandle(), getHandle().blockPosition(), isSilent(), true);
|
||||
return (entityzombievillager != null) ? (ZombieVillager) entityzombievillager.getBukkitEntity() : null;
|
||||
}
|
||||
|
||||
public static Profession nmsToBukkitProfession(VillagerProfession nms) {
|
||||
return Profession.valueOf(IRegistry.VILLAGER_PROFESSION.getKey(nms).getPath().toUpperCase(Locale.ROOT));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue