Some npcs
This commit is contained in:
6 files changed
+94
-150
No files matched your search
@@ -1,20 +0,0 @@
|
||||
From 3aeeaf31b7a7f888f54e47826e8ec0ddbe65c4bf Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 14:37:42 +0100
|
||||
Subject: [PATCH] paper File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/npc/CatSpawner.java b/net/minecraft/world/entity/npc/CatSpawner.java
|
||||
index 8ef8738e016df2539c058795bb83bbca38b18161..e6d368bc601357cfca694ce328c8e6e47491f3b5 100644
|
||||
--- a/net/minecraft/world/entity/npc/CatSpawner.java
|
||||
+++ b/net/minecraft/world/entity/npc/CatSpawner.java
|
||||
@@ -82,8 +82,8 @@ public class CatSpawner implements CustomSpawner {
|
||||
if (cat == null) {
|
||||
return 0;
|
||||
} else {
|
||||
+ cat.moveTo(pos, 0.0F, 0.0F); // Paper - move up - Fix MC-147659
|
||||
cat.finalizeSpawn(serverLevel, serverLevel.getCurrentDifficultyAt(pos), EntitySpawnReason.NATURAL, null);
|
||||
- cat.moveTo(pos, 0.0F, 0.0F);
|
||||
serverLevel.addFreshEntityWithPassengers(cat);
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
--- a/net/minecraft/world/entity/npc/CatSpawner.java
|
||||
+++ b/net/minecraft/world/entity/npc/CatSpawner.java
|
||||
@@ -68,12 +_,12 @@
|
||||
private void spawnCat(BlockPos pos, ServerLevel level, boolean persistent) {
|
||||
Cat cat = EntityType.CAT.create(level, EntitySpawnReason.NATURAL);
|
||||
if (cat != null) {
|
||||
+ cat.snapTo(pos, 0.0F, 0.0F); // Paper - move up - Fix MC-147659
|
||||
cat.finalizeSpawn(level, level.getCurrentDifficultyAt(pos), EntitySpawnReason.NATURAL, null);
|
||||
if (persistent) {
|
||||
cat.setPersistenceRequired();
|
||||
}
|
||||
|
||||
- cat.snapTo(pos, 0.0F, 0.0F);
|
||||
level.addFreshEntityWithPassengers(cat);
|
||||
}
|
||||
}
|
||||
+26
-33
@@ -1,14 +1,6 @@
|
||||
From 3aeeaf31b7a7f888f54e47826e8ec0ddbe65c4bf Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 14:37:42 +0100
|
||||
Subject: [PATCH] paper File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/npc/Villager.java b/net/minecraft/world/entity/npc/Villager.java
|
||||
index c99bc2ba4d9651ff7c7c2eecee2d9e27d3583e93..27568a1604d2dd5d46e836bbc25431929e218aa1 100644
|
||||
--- a/net/minecraft/world/entity/npc/Villager.java
|
||||
+++ b/net/minecraft/world/entity/npc/Villager.java
|
||||
@@ -90,6 +90,14 @@ import net.minecraft.world.level.ServerLevelAccessor;
|
||||
@@ -91,6 +_,14 @@
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -23,7 +15,7 @@ index c99bc2ba4d9651ff7c7c2eecee2d9e27d3583e93..27568a1604d2dd5d46e836bbc2543192
|
||||
public class Villager extends AbstractVillager implements ReputationEventHandler, VillagerDataHolder {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final EntityDataAccessor<VillagerData> DATA_VILLAGER_DATA = SynchedEntityData.defineId(Villager.class, EntityDataSerializers.VILLAGER_DATA);
|
||||
@@ -275,7 +283,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -286,7 +_,7 @@
|
||||
this.increaseProfessionLevelOnUpdate = false;
|
||||
}
|
||||
|
||||
@@ -32,7 +24,7 @@ index c99bc2ba4d9651ff7c7c2eecee2d9e27d3583e93..27568a1604d2dd5d46e836bbc2543192
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,7 +392,13 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -395,7 +_,13 @@
|
||||
this.updateDemand();
|
||||
|
||||
for (MerchantOffer merchantOffer : this.getOffers()) {
|
||||
@@ -47,7 +39,7 @@ index c99bc2ba4d9651ff7c7c2eecee2d9e27d3583e93..27568a1604d2dd5d46e836bbc2543192
|
||||
}
|
||||
|
||||
this.resendOffersToTradingPlayer();
|
||||
@@ -445,7 +459,13 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -456,7 +_,13 @@
|
||||
int i = 2 - this.numberOfRestocksToday;
|
||||
if (i > 0) {
|
||||
for (MerchantOffer merchantOffer : this.getOffers()) {
|
||||
@@ -62,7 +54,7 @@ index c99bc2ba4d9651ff7c7c2eecee2d9e27d3583e93..27568a1604d2dd5d46e836bbc2543192
|
||||
}
|
||||
}
|
||||
|
||||
@@ -466,6 +486,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -477,6 +_,7 @@
|
||||
int playerReputation = this.getPlayerReputation(player);
|
||||
if (playerReputation != 0) {
|
||||
for (MerchantOffer merchantOffer : this.getOffers()) {
|
||||
@@ -70,7 +62,7 @@ index c99bc2ba4d9651ff7c7c2eecee2d9e27d3583e93..27568a1604d2dd5d46e836bbc2543192
|
||||
merchantOffer.addToSpecialPriceDiff(-Mth.floor(playerReputation * merchantOffer.getPriceMultiplier()));
|
||||
}
|
||||
}
|
||||
@@ -475,6 +496,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -486,6 +_,7 @@
|
||||
int amplifier = effect.getAmplifier();
|
||||
|
||||
for (MerchantOffer merchantOffer1 : this.getOffers()) {
|
||||
@@ -78,7 +70,7 @@ index c99bc2ba4d9651ff7c7c2eecee2d9e27d3583e93..27568a1604d2dd5d46e836bbc2543192
|
||||
double d = 0.3 + 0.0625 * amplifier;
|
||||
int i = (int)Math.floor(d * merchantOffer1.getBaseCostA().getCount());
|
||||
merchantOffer1.addToSpecialPriceDiff(-Math.max(i, 1));
|
||||
@@ -594,7 +616,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -594,7 +_,7 @@
|
||||
}
|
||||
|
||||
if (offer.shouldRewardExp()) {
|
||||
@@ -87,7 +79,7 @@ index c99bc2ba4d9651ff7c7c2eecee2d9e27d3583e93..27568a1604d2dd5d46e836bbc2543192
|
||||
}
|
||||
}
|
||||
|
||||
@@ -612,7 +634,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -612,7 +_,7 @@
|
||||
|
||||
@Override
|
||||
public void die(DamageSource cause) {
|
||||
@@ -96,21 +88,21 @@ index c99bc2ba4d9651ff7c7c2eecee2d9e27d3583e93..27568a1604d2dd5d46e836bbc2543192
|
||||
Entity entity = cause.getEntity();
|
||||
if (entity != null) {
|
||||
this.tellWitnessesThatIWasMurdered(entity);
|
||||
@@ -782,12 +804,19 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -780,12 +_,19 @@
|
||||
@Override
|
||||
public void thunderHit(ServerLevel level, LightningBolt lightning) {
|
||||
if (level.getDifficulty() != Difficulty.PEACEFUL) {
|
||||
- LOGGER.info("Villager {} was struck by lightning {}.", this, lightning);
|
||||
+ // Paper - Add EntityZapEvent; move log down, event can cancel
|
||||
Witch witch = this.convertTo(EntityType.WITCH, ConversionParams.single(this, false, false), mob -> {
|
||||
Witch witch = this.convertTo(EntityType.WITCH, ConversionParams.single(this, false, false), witch1 -> {
|
||||
+ // Paper start - Add EntityZapEvent
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityZapEvent(this, lightning, mob).isCancelled()) {
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityZapEvent(this, lightning, witch1).isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ if (org.spigotmc.SpigotConfig.logVillagerDeaths) Villager.LOGGER.info("Villager {} was struck by lightning {}.", this, lightning); // Move down
|
||||
+ // Paper end - Add EntityZapEvent
|
||||
mob.finalizeSpawn(level, level.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CONVERSION, null);
|
||||
mob.setPersistenceRequired();
|
||||
witch1.finalizeSpawn(level, level.getCurrentDifficultyAt(witch1.blockPosition()), EntitySpawnReason.CONVERSION, null);
|
||||
witch1.setPersistenceRequired();
|
||||
this.releaseAllPois();
|
||||
- });
|
||||
+ return true; // Paper start - Add EntityZapEvent
|
||||
@@ -118,7 +110,7 @@ index c99bc2ba4d9651ff7c7c2eecee2d9e27d3583e93..27568a1604d2dd5d46e836bbc2543192
|
||||
if (witch == null) {
|
||||
super.thunderHit(level, lightning);
|
||||
}
|
||||
@@ -827,6 +856,12 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -825,6 +_,12 @@
|
||||
|
||||
@Override
|
||||
protected void updateTrades() {
|
||||
@@ -129,22 +121,23 @@ index c99bc2ba4d9651ff7c7c2eecee2d9e27d3583e93..27568a1604d2dd5d46e836bbc2543192
|
||||
+ public boolean updateTrades(int amount) {
|
||||
+ // Paper end - More vanilla friendly methods to update trades
|
||||
VillagerData villagerData = this.getVillagerData();
|
||||
Int2ObjectMap<VillagerTrades.ItemListing[]> map1;
|
||||
if (this.level().enabledFeatures().contains(FeatureFlags.TRADE_REBALANCE)) {
|
||||
@@ -840,9 +875,11 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
VillagerTrades.ItemListing[] itemListings = map1.get(villagerData.getLevel());
|
||||
if (itemListings != null) {
|
||||
MerchantOffers offers = this.getOffers();
|
||||
- this.addOffersFromItemListings(offers, itemListings, 2);
|
||||
+ this.addOffersFromItemListings(offers, itemListings, amount); // Paper - More vanilla friendly methods to update trades
|
||||
+ return true; // Paper - More vanilla friendly methods to update trades
|
||||
ResourceKey<VillagerProfession> resourceKey = villagerData.profession().unwrapKey().orElse(null);
|
||||
if (resourceKey != null) {
|
||||
@@ -840,10 +_,12 @@
|
||||
VillagerTrades.ItemListing[] itemListings = map1.get(villagerData.level());
|
||||
if (itemListings != null) {
|
||||
MerchantOffers offers = this.getOffers();
|
||||
- this.addOffersFromItemListings(offers, itemListings, 2);
|
||||
+ this.addOffersFromItemListings(offers, itemListings, amount); // Paper - More vanilla friendly methods to update trades
|
||||
+ return true; // Paper - More vanilla friendly methods to update trades
|
||||
}
|
||||
}
|
||||
}
|
||||
+ return false; // Paper - More vanilla friendly methods to update trades
|
||||
}
|
||||
|
||||
public void gossip(ServerLevel serverLevel, Villager target, long gameTime) {
|
||||
@@ -871,7 +908,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -872,7 +_,7 @@
|
||||
List<Villager> entitiesOfClass = serverLevel.getEntitiesOfClass(Villager.class, aabb);
|
||||
List<Villager> list = entitiesOfClass.stream().filter(villager -> villager.wantsToSpawnGolem(gameTime)).limit(5L).toList();
|
||||
if (list.size() >= minVillagerAmount) {
|
||||
@@ -153,7 +146,7 @@ index c99bc2ba4d9651ff7c7c2eecee2d9e27d3583e93..27568a1604d2dd5d46e836bbc2543192
|
||||
EntityType.IRON_GOLEM,
|
||||
EntitySpawnReason.MOB_SUMMONED,
|
||||
serverLevel,
|
||||
@@ -880,9 +917,11 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@@ -881,9 +_,11 @@
|
||||
8,
|
||||
6,
|
||||
SpawnUtil.Strategy.LEGACY_IRON_GOLEM,
|
||||
+4
-12
@@ -1,17 +1,9 @@
|
||||
From 3aeeaf31b7a7f888f54e47826e8ec0ddbe65c4bf Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 14:37:42 +0100
|
||||
Subject: [PATCH] paper File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/npc/VillagerTrades.java b/net/minecraft/world/entity/npc/VillagerTrades.java
|
||||
index d6ad685cca188d2729288df133d551a27f0fcf66..830d5ee7fff4c9761de5b740e699795c9129deaa 100644
|
||||
--- a/net/minecraft/world/entity/npc/VillagerTrades.java
|
||||
+++ b/net/minecraft/world/entity/npc/VillagerTrades.java
|
||||
@@ -1844,7 +1844,8 @@ public class VillagerTrades {
|
||||
return null;
|
||||
} else {
|
||||
ServerLevel serverLevel = (ServerLevel)trader.level();
|
||||
@@ -1747,7 +_,8 @@
|
||||
@Override
|
||||
public MerchantOffer getOffer(Entity trader, RandomSource random) {
|
||||
if (trader.level() instanceof ServerLevel serverLevel) {
|
||||
- BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, trader.blockPosition(), 100, true);
|
||||
+ if (!serverLevel.paperConfig().environment.treasureMaps.enabled) return null; // Paper - Configurable cartographer treasure maps
|
||||
+ BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, trader.blockPosition(), 100, !serverLevel.paperConfig().environment.treasureMaps.findAlreadyDiscoveredVillager); // Paper - Configurable cartographer treasure maps
|
||||
+12
-38
@@ -1,14 +1,6 @@
|
||||
From 3aeeaf31b7a7f888f54e47826e8ec0ddbe65c4bf Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 14:37:42 +0100
|
||||
Subject: [PATCH] paper File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/npc/WanderingTrader.java b/net/minecraft/world/entity/npc/WanderingTrader.java
|
||||
index 94ddbc0e0543255b6611d2db5c18af49d78018d8..6655d06e2011e20e7346dfe57527795269094d8a 100644
|
||||
--- a/net/minecraft/world/entity/npc/WanderingTrader.java
|
||||
+++ b/net/minecraft/world/entity/npc/WanderingTrader.java
|
||||
@@ -47,11 +47,23 @@ import net.minecraft.world.level.Level;
|
||||
@@ -45,11 +_,23 @@
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -21,11 +13,11 @@ index 94ddbc0e0543255b6611d2db5c18af49d78018d8..6655d06e2011e20e7346dfe575277952
|
||||
+import org.bukkit.event.entity.VillagerAcquireTradeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
+public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVillager implements Consumable.OverrideConsumeSound {
|
||||
private static final int NUMBER_OF_TRADE_OFFERS = 5;
|
||||
+public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVillager implements Consumable.OverrideConsumeSound { // CraftBukkit
|
||||
private static final int DEFAULT_DESPAWN_DELAY = 0;
|
||||
@Nullable
|
||||
private BlockPos wanderTarget;
|
||||
private int despawnDelay;
|
||||
private int despawnDelay = 0;
|
||||
+ // Paper start - Add more WanderingTrader API
|
||||
+ public boolean canDrinkPotion = true;
|
||||
+ public boolean canDrinkMilk = true;
|
||||
@@ -33,43 +25,25 @@ index 94ddbc0e0543255b6611d2db5c18af49d78018d8..6655d06e2011e20e7346dfe575277952
|
||||
|
||||
public WanderingTrader(EntityType<? extends WanderingTrader> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
@@ -67,7 +79,7 @@ public class WanderingTrader extends AbstractVillager implements Consumable.Over
|
||||
@@ -65,7 +_,7 @@
|
||||
this,
|
||||
PotionContents.createItemStack(Items.POTION, Potions.INVISIBILITY),
|
||||
SoundEvents.WANDERING_TRADER_DISAPPEARED,
|
||||
- wanderingTrader -> this.level().isNight() && !wanderingTrader.isInvisible()
|
||||
+ wanderingTrader -> this.canDrinkPotion && this.level().isNight() && !wanderingTrader.isInvisible() // Paper - Add more WanderingTrader API
|
||||
- wanderingTrader -> this.level().isDarkOutside() && !wanderingTrader.isInvisible()
|
||||
+ wanderingTrader -> this.canDrinkPotion && this.level().isDarkOutside() && !wanderingTrader.isInvisible() // Paper - Add more WanderingTrader API
|
||||
)
|
||||
);
|
||||
this.goalSelector
|
||||
@@ -77,7 +89,7 @@ public class WanderingTrader extends AbstractVillager implements Consumable.Over
|
||||
@@ -75,7 +_,7 @@
|
||||
this,
|
||||
new ItemStack(Items.MILK_BUCKET),
|
||||
SoundEvents.WANDERING_TRADER_REAPPEARED,
|
||||
- wanderingTrader -> this.level().isDay() && wanderingTrader.isInvisible()
|
||||
+ wanderingTrader -> this.canDrinkMilk && this.level().isDay() && wanderingTrader.isInvisible() // Paper - Add more WanderingTrader API
|
||||
- wanderingTrader -> this.level().isBrightOutside() && wanderingTrader.isInvisible()
|
||||
+ wanderingTrader -> this.canDrinkMilk && this.level().isBrightOutside() && wanderingTrader.isInvisible() // Paper - Add more WanderingTrader API
|
||||
)
|
||||
);
|
||||
this.goalSelector.addGoal(1, new TradeWithPlayerGoal(this));
|
||||
@@ -145,7 +157,16 @@ public class WanderingTrader extends AbstractVillager implements Consumable.Over
|
||||
VillagerTrades.ItemListing itemListing = itemListings1[randomInt];
|
||||
MerchantOffer offer = itemListing.getOffer(this, this.random);
|
||||
if (offer != null) {
|
||||
- offers.add(offer);
|
||||
+ // CraftBukkit start
|
||||
+ VillagerAcquireTradeEvent event = new VillagerAcquireTradeEvent((AbstractVillager) this.getBukkitEntity(), offer.asBukkit());
|
||||
+ // Suppress during worldgen
|
||||
+ if (this.valid) {
|
||||
+ Bukkit.getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+ if (!event.isCancelled()) {
|
||||
+ offers.add(CraftMerchantRecipe.fromBukkit(event.getRecipe()).toMinecraft());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,7 +210,7 @@ public class WanderingTrader extends AbstractVillager implements Consumable.Over
|
||||
@@ -163,7 +_,7 @@
|
||||
protected void rewardTradeXp(MerchantOffer offer) {
|
||||
if (offer.shouldRewardExp()) {
|
||||
int i = 3 + this.random.nextInt(4);
|
||||
@@ -78,7 +52,7 @@ index 94ddbc0e0543255b6611d2db5c18af49d78018d8..6655d06e2011e20e7346dfe575277952
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,7 +262,7 @@ public class WanderingTrader extends AbstractVillager implements Consumable.Over
|
||||
@@ -215,7 +_,7 @@
|
||||
|
||||
private void maybeDespawn() {
|
||||
if (this.despawnDelay > 0 && !this.isTrading() && --this.despawnDelay == 0) {
|
||||
+36
-47
@@ -1,14 +1,6 @@
|
||||
From 3aeeaf31b7a7f888f54e47826e8ec0ddbe65c4bf Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 14:37:42 +0100
|
||||
Subject: [PATCH] paper File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/npc/WanderingTraderSpawner.java b/net/minecraft/world/entity/npc/WanderingTraderSpawner.java
|
||||
index ba68656225507a209f2f4269ec2744cab09315f5..ef2afb17a22a703470e13d12c989a685e72f0ab8 100644
|
||||
--- a/net/minecraft/world/entity/npc/WanderingTraderSpawner.java
|
||||
+++ b/net/minecraft/world/entity/npc/WanderingTraderSpawner.java
|
||||
@@ -38,41 +38,51 @@ public class WanderingTraderSpawner implements CustomSpawner {
|
||||
@@ -38,38 +_,47 @@
|
||||
|
||||
public WanderingTraderSpawner(ServerLevelData serverLevelData) {
|
||||
this.serverLevelData = serverLevelData;
|
||||
@@ -35,49 +27,46 @@ index ba68656225507a209f2f4269ec2744cab09315f5..ef2afb17a22a703470e13d12c989a685
|
||||
}
|
||||
|
||||
@Override
|
||||
public int tick(ServerLevel level, boolean spawnHostiles, boolean spawnPassives) {
|
||||
public void tick(ServerLevel level, boolean spawnEnemies, boolean spawnFriendlies) {
|
||||
+ // Paper start - Add Wandering Trader spawn rate config options
|
||||
+ if (this.tickDelay == Integer.MIN_VALUE) {
|
||||
+ this.tickDelay = level.paperConfig().entities.spawning.wanderingTrader.spawnMinuteLength;
|
||||
+ this.spawnDelay = level.paperConfig().entities.spawning.wanderingTrader.spawnDayLength;
|
||||
+ this.spawnChance = level.paperConfig().entities.spawning.wanderingTrader.spawnChanceMin;
|
||||
+ }
|
||||
if (!level.getGameRules().getBoolean(GameRules.RULE_DO_TRADER_SPAWNING)) {
|
||||
return 0;
|
||||
- } else if (--this.tickDelay > 0) {
|
||||
+ } else if (--this.tickDelay - 1 > 0) {
|
||||
+ this.tickDelay = this.tickDelay - 1;
|
||||
return 0;
|
||||
} else {
|
||||
- this.tickDelay = 1200;
|
||||
- this.spawnDelay -= 1200;
|
||||
- this.serverLevelData.setWanderingTraderSpawnDelay(this.spawnDelay);
|
||||
+ this.tickDelay = level.paperConfig().entities.spawning.wanderingTrader.spawnMinuteLength;
|
||||
+ this.spawnDelay = this.spawnDelay - level.paperConfig().entities.spawning.wanderingTrader.spawnMinuteLength;
|
||||
+ //this.serverLevelData.setWanderingTraderSpawnDelay(this.spawnDelay); // Paper - We don't need to save this value to disk if it gets set back to a hardcoded value anyways
|
||||
if (this.spawnDelay > 0) {
|
||||
return 0;
|
||||
} else {
|
||||
- this.spawnDelay = 24000;
|
||||
+ this.spawnDelay = level.paperConfig().entities.spawning.wanderingTrader.spawnDayLength;
|
||||
if (!level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) {
|
||||
return 0;
|
||||
} else {
|
||||
int i = this.spawnChance;
|
||||
- this.spawnChance = Mth.clamp(this.spawnChance + 25, 25, 75);
|
||||
- this.serverLevelData.setWanderingTraderSpawnChance(this.spawnChance);
|
||||
+ this.spawnChance = Mth.clamp(this.spawnChance + level.paperConfig().entities.spawning.wanderingTrader.spawnChanceFailureIncrement, level.paperConfig().entities.spawning.wanderingTrader.spawnChanceMin, level.paperConfig().entities.spawning.wanderingTrader.spawnChanceMax);
|
||||
+ //this.serverLevelData.setWanderingTraderSpawnChance(this.spawnChance); // Paper - We don't need to save this value to disk if it gets set back to a hardcoded value anyways
|
||||
if (this.random.nextInt(100) > i) {
|
||||
return 0;
|
||||
} else if (this.spawn(level)) {
|
||||
- this.spawnChance = 25;
|
||||
+ this.spawnChance = level.paperConfig().entities.spawning.wanderingTrader.spawnChanceMin;
|
||||
+ // Paper end - Add Wandering Trader spawn rate config options
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
@@ -100,14 +110,14 @@ public class WanderingTraderSpawner implements CustomSpawner {
|
||||
if (level.getGameRules().getBoolean(GameRules.RULE_DO_TRADER_SPAWNING)) {
|
||||
- if (--this.tickDelay <= 0) {
|
||||
- this.tickDelay = 1200;
|
||||
- this.spawnDelay -= 1200;
|
||||
- this.serverLevelData.setWanderingTraderSpawnDelay(this.spawnDelay);
|
||||
+ if (this.tickDelay - 1 <= 0) { // Paper - Prevent tickDelay going below 0
|
||||
+ this.tickDelay = level.paperConfig().entities.spawning.wanderingTrader.spawnMinuteLength;
|
||||
+ this.spawnDelay = this.spawnDelay - level.paperConfig().entities.spawning.wanderingTrader.spawnMinuteLength;
|
||||
+ //this.serverLevelData.setWanderingTraderSpawnDelay(this.spawnDelay); // Paper - We don't need to save this value to disk if it gets set back to a hardcoded value anyways
|
||||
if (this.spawnDelay <= 0) {
|
||||
- this.spawnDelay = 24000;
|
||||
+ this.spawnDelay = level.paperConfig().entities.spawning.wanderingTrader.spawnDayLength;
|
||||
if (level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) {
|
||||
int i = this.spawnChance;
|
||||
- this.spawnChance = Mth.clamp(this.spawnChance + 25, 25, 75);
|
||||
- this.serverLevelData.setWanderingTraderSpawnChance(this.spawnChance);
|
||||
+ this.spawnChance = Mth.clamp(this.spawnChance + level.paperConfig().entities.spawning.wanderingTrader.spawnChanceFailureIncrement, level.paperConfig().entities.spawning.wanderingTrader.spawnChanceMin, level.paperConfig().entities.spawning.wanderingTrader.spawnChanceMax);
|
||||
+ //this.serverLevelData.setWanderingTraderSpawnChance(this.spawnChance); // Paper - We don't need to save this value to disk if it gets set back to a hardcoded value anyways
|
||||
if (this.random.nextInt(100) <= i) {
|
||||
if (this.spawn(level)) {
|
||||
- this.spawnChance = 25;
|
||||
+ this.spawnChance = level.paperConfig().entities.spawning.wanderingTrader.spawnChanceMin;
|
||||
+ // Paper end - Add Wandering Trader spawn rate config options
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
- }
|
||||
+ } else { this.tickDelay--; } // Paper - Prevent tickDelay going below 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,14 +_,14 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -94,7 +83,7 @@ index ba68656225507a209f2f4269ec2744cab09315f5..ef2afb17a22a703470e13d12c989a685
|
||||
wanderingTrader.setWanderTarget(blockPos1);
|
||||
wanderingTrader.restrictTo(blockPos1, 16);
|
||||
return true;
|
||||
@@ -121,7 +131,7 @@ public class WanderingTraderSpawner implements CustomSpawner {
|
||||
@@ -112,7 +_,7 @@
|
||||
private void tryToSpawnLlamaFor(ServerLevel serverLevel, WanderingTrader trader, int maxDistance) {
|
||||
BlockPos blockPos = this.findSpawnPositionNear(serverLevel, trader.blockPosition(), maxDistance);
|
||||
if (blockPos != null) {
|
||||
Reference in new issue
Block a user