aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/entity/monster/ZombieVillager.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/entity/monster/ZombieVillager.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/world/entity/monster/ZombieVillager.java.patch449
1 files changed, 449 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/entity/monster/ZombieVillager.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/entity/monster/ZombieVillager.java.patch
new file mode 100644
index 0000000000..f4dc49b5ce
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/world/entity/monster/ZombieVillager.java.patch
@@ -0,0 +1,449 @@
+--- a/net/minecraft/world/entity/monster/ZombieVillager.java
++++ b/net/minecraft/world/entity/monster/ZombieVillager.java
+@@ -15,12 +15,8 @@
+ import net.minecraft.network.syncher.EntityDataAccessor;
+ import net.minecraft.network.syncher.EntityDataSerializers;
+ import net.minecraft.network.syncher.SynchedEntityData;
+-import net.minecraft.server.level.ServerLevel;
+-import net.minecraft.server.level.ServerPlayer;
+-import net.minecraft.sounds.SoundEvent;
+-import net.minecraft.sounds.SoundEvents;
+ import net.minecraft.world.DifficultyInstance;
+-import net.minecraft.world.InteractionHand;
++import net.minecraft.world.EnumHand;
+ import net.minecraft.world.InteractionResult;
+ import net.minecraft.world.damagesource.DamageSource;
+ import net.minecraft.world.effect.MobEffectInstance;
+@@ -28,9 +24,9 @@
+ import net.minecraft.world.entity.Entity;
+ import net.minecraft.world.entity.EntityDimensions;
+ import net.minecraft.world.entity.EntityType;
++import net.minecraft.world.entity.EnumMobSpawn;
+ import net.minecraft.world.entity.EquipmentSlot;
+-import net.minecraft.world.entity.MobSpawnType;
+-import net.minecraft.world.entity.SpawnGroupData;
++import net.minecraft.world.entity.GroupDataEntity;
+ import net.minecraft.world.entity.ai.village.ReputationEventType;
+ import net.minecraft.world.entity.npc.Villager;
+ import net.minecraft.world.entity.npc.VillagerData;
+@@ -46,37 +42,47 @@
+ import net.minecraft.world.level.ServerLevelAccessor;
+ import net.minecraft.world.level.block.BedBlock;
+ import net.minecraft.world.level.block.Blocks;
+-import net.minecraft.world.level.block.state.BlockState;
++import net.minecraft.world.level.block.state.IBlockData;
+ import org.joml.Vector3f;
+ import org.slf4j.Logger;
+
++// CraftBukkit start
++import net.minecraft.server.MinecraftServer;
++import net.minecraft.server.level.ServerLevel;
++import net.minecraft.server.level.ServerPlayer;
++import net.minecraft.sounds.SoundEvent;
++import net.minecraft.sounds.SoundEvents;
++import org.bukkit.event.entity.CreatureSpawnEvent;
++import org.bukkit.event.entity.EntityTransformEvent;
++// CraftBukkit end
++
+ public class ZombieVillager extends Zombie implements VillagerDataHolder {
+
+ private static final Logger LOGGER = LogUtils.getLogger();
+- private static final EntityDataAccessor<Boolean> DATA_CONVERTING_ID = SynchedEntityData.defineId(ZombieVillager.class, EntityDataSerializers.BOOLEAN);
++ public static final EntityDataAccessor<Boolean> DATA_CONVERTING_ID = SynchedEntityData.defineId(ZombieVillager.class, EntityDataSerializers.BOOLEAN);
+ private static final EntityDataAccessor<VillagerData> DATA_VILLAGER_DATA = SynchedEntityData.defineId(ZombieVillager.class, EntityDataSerializers.VILLAGER_DATA);
+ private static final int VILLAGER_CONVERSION_WAIT_MIN = 3600;
+ private static final int VILLAGER_CONVERSION_WAIT_MAX = 6000;
+ private static final int MAX_SPECIAL_BLOCKS_COUNT = 14;
+ private static final int SPECIAL_BLOCK_RADIUS = 4;
+- private int villagerConversionTime;
++ public int villagerConversionTime;
+ @Nullable
+- private UUID conversionStarter;
++ public UUID conversionStarter;
+ @Nullable
+ private Tag gossips;
+ @Nullable
+ private CompoundTag tradeOffers;
+ private int villagerXp;
++ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
+
+- public ZombieVillager(EntityType<? extends ZombieVillager> entitytype, Level level) {
+- super(entitytype, level);
+- BuiltInRegistries.VILLAGER_PROFESSION.getRandom(this.random).ifPresent((holder_reference) -> {
+- this.setVillagerData(this.getVillagerData().setProfession((VillagerProfession) holder_reference.value()));
++ public ZombieVillager(EntityType<? extends ZombieVillager> entityType, Level level) {
++ super(entityType, level);
++ BuiltInRegistries.VILLAGER_PROFESSION.getRandom(this.random).ifPresent((holder_c) -> {
++ this.setVillagerData(this.getVillagerData().setProfession((VillagerProfession) holder_c.value()));
+ });
+ }
+
+ @Override
+- @Override
+ protected void defineSynchedData() {
+ super.defineSynchedData();
+ this.entityData.define(ZombieVillager.DATA_CONVERTING_ID, false);
+@@ -84,67 +90,68 @@
+ }
+
+ @Override
+- @Override
+- public void addAdditionalSaveData(CompoundTag compoundtag) {
+- super.addAdditionalSaveData(compoundtag);
+- DataResult dataresult = VillagerData.CODEC.encodeStart(NbtOps.INSTANCE, this.getVillagerData());
++ public void addAdditionalSaveData(CompoundTag compound) {
++ super.addAdditionalSaveData(compound);
++ DataResult<Tag> dataresult = VillagerData.CODEC.encodeStart(NbtOps.INSTANCE, this.getVillagerData()); // CraftBukkit - decompile error
+ Logger logger = ZombieVillager.LOGGER;
+
+ Objects.requireNonNull(logger);
+- dataresult.resultOrPartial(logger::error).ifPresent((tag) -> {
+- compoundtag.put("VillagerData", tag);
++ dataresult.resultOrPartial(logger::error).ifPresent((nbtbase) -> {
++ compound.put("VillagerData", nbtbase);
+ });
+ if (this.tradeOffers != null) {
+- compoundtag.put("Offers", this.tradeOffers);
++ compound.put("Offers", this.tradeOffers);
+ }
+
+ if (this.gossips != null) {
+- compoundtag.put("Gossips", this.gossips);
++ compound.put("Gossips", this.gossips);
+ }
+
+- compoundtag.putInt("ConversionTime", this.isConverting() ? this.villagerConversionTime : -1);
++ compound.putInt("ConversionTime", this.isConverting() ? this.villagerConversionTime : -1);
+ if (this.conversionStarter != null) {
+- compoundtag.putUUID("ConversionPlayer", this.conversionStarter);
++ compound.putUUID("ConversionPlayer", this.conversionStarter);
+ }
+
+- compoundtag.putInt("Xp", this.villagerXp);
++ compound.putInt("Xp", this.villagerXp);
+ }
+
+ @Override
+- @Override
+- public void readAdditionalSaveData(CompoundTag compoundtag) {
+- super.readAdditionalSaveData(compoundtag);
+- if (compoundtag.contains("VillagerData", 10)) {
+- DataResult<VillagerData> dataresult = VillagerData.CODEC.parse(new Dynamic(NbtOps.INSTANCE, compoundtag.get("VillagerData")));
++ public void readAdditionalSaveData(CompoundTag compound) {
++ super.readAdditionalSaveData(compound);
++ if (compound.contains("VillagerData", 10)) {
++ DataResult<VillagerData> dataresult = VillagerData.CODEC.parse(new Dynamic(NbtOps.INSTANCE, compound.get("VillagerData")));
+ Logger logger = ZombieVillager.LOGGER;
+
+ Objects.requireNonNull(logger);
+ dataresult.resultOrPartial(logger::error).ifPresent(this::setVillagerData);
+ }
+
+- if (compoundtag.contains("Offers", 10)) {
+- this.tradeOffers = compoundtag.getCompound("Offers");
++ if (compound.contains("Offers", 10)) {
++ this.tradeOffers = compound.getCompound("Offers");
+ }
+
+- if (compoundtag.contains("Gossips", 9)) {
+- this.gossips = compoundtag.getList("Gossips", 10);
++ if (compound.contains("Gossips", 9)) {
++ this.gossips = compound.getList("Gossips", 10);
+ }
+
+- if (compoundtag.contains("ConversionTime", 99) && compoundtag.getInt("ConversionTime") > -1) {
+- this.startConverting(compoundtag.hasUUID("ConversionPlayer") ? compoundtag.getUUID("ConversionPlayer") : null, compoundtag.getInt("ConversionTime"));
++ if (compound.contains("ConversionTime", 99) && compound.getInt("ConversionTime") > -1) {
++ this.startConverting(compound.hasUUID("ConversionPlayer") ? compound.getUUID("ConversionPlayer") : null, compound.getInt("ConversionTime"));
+ }
+
+- if (compoundtag.contains("Xp", 3)) {
+- this.villagerXp = compoundtag.getInt("Xp");
++ if (compound.contains("Xp", 3)) {
++ this.villagerXp = compound.getInt("Xp");
+ }
+
+ }
+
+ @Override
+- @Override
+ public void tick() {
+ if (!this.level().isClientSide && this.isAlive() && this.isConverting()) {
+ int i = this.getConversionProgress();
++ // CraftBukkit start - Use wall time instead of ticks for villager conversion
++ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
++ i *= elapsedTicks;
++ // CraftBukkit end
+
+ this.villagerConversionTime -= i;
+ if (this.villagerConversionTime <= 0) {
+@@ -153,12 +160,12 @@
+ }
+
+ super.tick();
++ this.lastTick = MinecraftServer.currentTick; // CraftBukkit
+ }
+
+ @Override
+- @Override
+- public InteractionResult mobInteract(Player player, InteractionHand interactionhand) {
+- ItemStack itemstack = player.getItemInHand(interactionhand);
++ public InteractionResult mobInteract(Player player, EnumHand hand) {
++ ItemStack itemstack = player.getItemInHand(hand);
+
+ if (itemstack.is(Items.GOLDEN_APPLE)) {
+ if (this.hasEffect(MobEffects.WEAKNESS)) {
+@@ -175,19 +182,17 @@
+ return InteractionResult.CONSUME;
+ }
+ } else {
+- return super.mobInteract(player, interactionhand);
++ return super.mobInteract(player, hand);
+ }
+ }
+
+ @Override
+- @Override
+ protected boolean convertsInWater() {
+ return false;
+ }
+
+ @Override
+- @Override
+- public boolean removeWhenFarAway(double d0) {
++ public boolean removeWhenFarAway(double distanceToClosestPlayer) {
+ return !this.isConverting() && this.villagerXp == 0;
+ }
+
+@@ -195,74 +200,83 @@
+ return (Boolean) this.getEntityData().get(ZombieVillager.DATA_CONVERTING_ID);
+ }
+
+- private void startConverting(@Nullable UUID uuid, int i) {
+- this.conversionStarter = uuid;
+- this.villagerConversionTime = i;
++ public void startConverting(@Nullable UUID conversionStarter, int villagerConversionTime) {
++ this.conversionStarter = conversionStarter;
++ this.villagerConversionTime = villagerConversionTime;
+ this.getEntityData().set(ZombieVillager.DATA_CONVERTING_ID, true);
+- this.removeEffect(MobEffects.WEAKNESS);
+- this.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, i, Math.min(this.level().getDifficulty().getId() - 1, 0)));
++ // CraftBukkit start
++ this.removeEffect(MobEffects.WEAKNESS, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
++ this.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, villagerConversionTime, Math.min(this.level().getDifficulty().getId() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
++ // CraftBukkit end
+ this.level().broadcastEntityEvent(this, (byte) 16);
+ }
+
+ @Override
+- @Override
+- public void handleEntityEvent(byte b0) {
+- if (b0 == 16) {
++ public void handleEntityEvent(byte id) {
++ if (id == 16) {
+ if (!this.isSilent()) {
+ this.level().playLocalSound(this.getX(), this.getEyeY(), this.getZ(), SoundEvents.ZOMBIE_VILLAGER_CURE, this.getSoundSource(), 1.0F + this.random.nextFloat(), this.random.nextFloat() * 0.7F + 0.3F, false);
+ }
+
+ } else {
+- super.handleEntityEvent(b0);
++ super.handleEntityEvent(id);
+ }
+ }
+
+- private void finishConversion(ServerLevel serverlevel) {
+- Villager villager = (Villager) this.convertTo(EntityType.VILLAGER, false);
+- EquipmentSlot[] aequipmentslot = EquipmentSlot.values();
+- int i = aequipmentslot.length;
++ private void finishConversion(ServerLevel serverLevel) {
++ // CraftBukkit start
++ Villager entityvillager = (Villager) this.convertTo(EntityType.VILLAGER, false, EntityTransformEvent.TransformReason.CURED, CreatureSpawnEvent.SpawnReason.CURED);
++ if (entityvillager == null) {
++ ((org.bukkit.entity.ZombieVillager) getBukkitEntity()).setConversionTime(-1); // SPIGOT-5208: End conversion to stop event spam
++ return;
++ }
++ // CraftBukkit end
++ EquipmentSlot[] aenumitemslot = EquipmentSlot.values();
++ int i = aenumitemslot.length;
+
+ for (int j = 0; j < i; ++j) {
+- EquipmentSlot equipmentslot = aequipmentslot[j];
+- ItemStack itemstack = this.getItemBySlot(equipmentslot);
++ EquipmentSlot enumitemslot = aenumitemslot[j];
++ ItemStack itemstack = this.getItemBySlot(enumitemslot);
+
+ if (!itemstack.isEmpty()) {
+ if (EnchantmentHelper.hasBindingCurse(itemstack)) {
+- villager.getSlot(equipmentslot.getIndex() + 300).set(itemstack);
++ entityvillager.getSlot(enumitemslot.getIndex() + 300).set(itemstack);
+ } else {
+- double d0 = (double) this.getEquipmentDropChance(equipmentslot);
++ double d0 = (double) this.getEquipmentDropChance(enumitemslot);
+
+ if (d0 > 1.0D) {
++ this.forceDrops = true; // CraftBukkit
+ this.spawnAtLocation(itemstack);
++ this.forceDrops = false; // CraftBukkit
+ }
+ }
+ }
+ }
+
+- villager.setVillagerData(this.getVillagerData());
++ entityvillager.setVillagerData(this.getVillagerData());
+ if (this.gossips != null) {
+- villager.setGossips(this.gossips);
++ entityvillager.setGossips(this.gossips);
+ }
+
+ if (this.tradeOffers != null) {
+- villager.setOffers(new MerchantOffers(this.tradeOffers));
++ entityvillager.setOffers(new MerchantOffers(this.tradeOffers));
+ }
+
+- villager.setVillagerXp(this.villagerXp);
+- villager.finalizeSpawn(serverlevel, serverlevel.getCurrentDifficultyAt(villager.blockPosition()), MobSpawnType.CONVERSION, (SpawnGroupData) null, (CompoundTag) null);
+- villager.refreshBrain(serverlevel);
++ entityvillager.setVillagerXp(this.villagerXp);
++ entityvillager.finalizeSpawn(serverLevel, serverLevel.getCurrentDifficultyAt(entityvillager.blockPosition()), EnumMobSpawn.CONVERSION, (GroupDataEntity) null, (CompoundTag) null);
++ entityvillager.refreshBrain(serverLevel);
+ if (this.conversionStarter != null) {
+- Player player = serverlevel.getPlayerByUUID(this.conversionStarter);
++ Player entityhuman = serverLevel.getPlayerByUUID(this.conversionStarter);
+
+- if (player instanceof ServerPlayer) {
+- CriteriaTriggers.CURED_ZOMBIE_VILLAGER.trigger((ServerPlayer) player, this, villager);
+- serverlevel.onReputationEvent(ReputationEventType.ZOMBIE_VILLAGER_CURED, player, villager);
++ if (entityhuman instanceof ServerPlayer) {
++ CriteriaTriggers.CURED_ZOMBIE_VILLAGER.trigger((ServerPlayer) entityhuman, this, entityvillager);
++ serverLevel.onReputationEvent(ReputationEventType.ZOMBIE_VILLAGER_CURED, entityhuman, entityvillager);
+ }
+ }
+
+- villager.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0));
++ entityvillager.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); // CraftBukkit
+ if (!this.isSilent()) {
+- serverlevel.levelEvent((Player) null, 1027, this.blockPosition(), 0);
++ serverLevel.levelEvent((Player) null, 1027, this.blockPosition(), 0);
+ }
+
+ }
+@@ -272,14 +286,14 @@
+
+ if (this.random.nextFloat() < 0.01F) {
+ int j = 0;
+- BlockPos.MutableBlockPos blockpos_mutableblockpos = new BlockPos.MutableBlockPos();
++ BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
+
+ for (int k = (int) this.getX() - 4; k < (int) this.getX() + 4 && j < 14; ++k) {
+ for (int l = (int) this.getY() - 4; l < (int) this.getY() + 4 && j < 14; ++l) {
+ for (int i1 = (int) this.getZ() - 4; i1 < (int) this.getZ() + 4 && j < 14; ++i1) {
+- BlockState blockstate = this.level().getBlockState(blockpos_mutableblockpos.set(k, l, i1));
++ IBlockData iblockdata = this.level().getBlockState(blockposition_mutableblockposition.set(k, l, i1));
+
+- if (blockstate.is(Blocks.IRON_BARS) || blockstate.getBlock() instanceof BedBlock) {
++ if (iblockdata.is(Blocks.IRON_BARS) || iblockdata.getBlock() instanceof BedBlock) {
+ if (this.random.nextFloat() < 0.3F) {
+ ++i;
+ }
+@@ -295,71 +309,62 @@
+ }
+
+ @Override
+- @Override
+ public float getVoicePitch() {
+ return this.isBaby() ? (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 2.0F : (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F;
+ }
+
+ @Override
+- @Override
+ public SoundEvent getAmbientSound() {
+ return SoundEvents.ZOMBIE_VILLAGER_AMBIENT;
+ }
+
+ @Override
+- @Override
+- public SoundEvent getHurtSound(DamageSource damagesource) {
++ public SoundEvent getHurtSound(DamageSource damageSource) {
+ return SoundEvents.ZOMBIE_VILLAGER_HURT;
+ }
+
+ @Override
+- @Override
+ public SoundEvent getDeathSound() {
+ return SoundEvents.ZOMBIE_VILLAGER_DEATH;
+ }
+
+ @Override
+- @Override
+ public SoundEvent getStepSound() {
+ return SoundEvents.ZOMBIE_VILLAGER_STEP;
+ }
+
+ @Override
+- @Override
+ protected ItemStack getSkull() {
+ return ItemStack.EMPTY;
+ }
+
+- public void setTradeOffers(CompoundTag compoundtag) {
+- this.tradeOffers = compoundtag;
++ public void setTradeOffers(CompoundTag tradeOffers) {
++ this.tradeOffers = tradeOffers;
+ }
+
+- public void setGossips(Tag tag) {
+- this.gossips = tag;
++ public void setGossips(Tag gossips) {
++ this.gossips = gossips;
+ }
+
+ @Nullable
+ @Override
+- @Override
+- public SpawnGroupData finalizeSpawn(ServerLevelAccessor serverlevelaccessor, DifficultyInstance difficultyinstance, MobSpawnType mobspawntype, @Nullable SpawnGroupData spawngroupdata, @Nullable CompoundTag compoundtag) {
+- this.setVillagerData(this.getVillagerData().setType(VillagerType.byBiome(serverlevelaccessor.getBiome(this.blockPosition()))));
+- return super.finalizeSpawn(serverlevelaccessor, difficultyinstance, mobspawntype, spawngroupdata, compoundtag);
++ public GroupDataEntity finalizeSpawn(ServerLevelAccessor level, DifficultyInstance difficulty, EnumMobSpawn reason, @Nullable GroupDataEntity spawnData, @Nullable CompoundTag dataTag) {
++ this.setVillagerData(this.getVillagerData().setType(VillagerType.byBiome(level.getBiome(this.blockPosition()))));
++ return super.finalizeSpawn(level, difficulty, reason, spawnData, dataTag);
+ }
+
+ @Override
+- @Override
+- public void setVillagerData(VillagerData villagerdata) {
++ public void setVillagerData(VillagerData data) {
+ VillagerData villagerdata1 = this.getVillagerData();
+
+- if (villagerdata1.getProfession() != villagerdata.getProfession()) {
++ if (villagerdata1.getProfession() != data.getProfession()) {
+ this.tradeOffers = null;
+ }
+
+- this.entityData.set(ZombieVillager.DATA_VILLAGER_DATA, villagerdata);
++ this.entityData.set(ZombieVillager.DATA_VILLAGER_DATA, data);
+ }
+
+ @Override
+- @Override
+ public VillagerData getVillagerData() {
+ return (VillagerData) this.entityData.get(ZombieVillager.DATA_VILLAGER_DATA);
+ }
+@@ -368,13 +373,12 @@
+ return this.villagerXp;
+ }
+
+- public void setVillagerXp(int i) {
+- this.villagerXp = i;
++ public void setVillagerXp(int villagerXp) {
++ this.villagerXp = villagerXp;
+ }
+
+ @Override
+- @Override
+- protected Vector3f getPassengerAttachmentPoint(Entity entity, EntityDimensions entitydimensions, float f) {
+- return new Vector3f(0.0F, entitydimensions.height + 0.175F * f, 0.0F);
++ protected Vector3f getPassengerAttachmentPoint(Entity entity, EntityDimensions entitysize, float f) {
++ return new Vector3f(0.0F, entitysize.height + 0.175F * f, 0.0F);
+ }
+ }