mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 04:55:47 +01:00
01a13871de
Patch documentation to come Issues with the old system that are fixed now: - World generation does not scale with cpu cores effectively. - Relies on the main thread for scheduling and maintaining chunk state, dropping chunk load/generate rates at lower tps. - Unreliable prioritisation of chunk gen/load calls that block the main thread. - Shutdown logic is utterly unreliable, as it has to wait for all chunks to unload - is it guaranteed that the chunk system is in a state on shutdown that it can reliably do this? Watchdog shutdown also typically failed due to thread checks, which is now resolved. - Saving of data is not unified (i.e can save chunk data without saving entity data, poses problems for desync if shutdown is really abnormal. - Entities are not loaded with chunks. This caused quite a bit of headache for Chunk#getEntities API, but now the new chunk system loads entities with chunks so that they are ready whenever the chunk loads in. Effectively brings the behavior back to 1.16 era, but still storing entities in their own separate regionfiles. The above list is not complete. The patch documentation will complete it. New chunk system hard relies on starlight and dataconverter, and most importantly the new concurrent utilities in ConcurrentUtil. Some of the old async chunk i/o interface (i.e the old file io thread reroutes _some_ calls to the new file io thread) is kept for plugin compat reasons. It will be removed in the next major version of minecraft. The old legacy chunk system patches have been moved to the removed folder in case we need them again.
66 lines
3.3 KiB
Diff
66 lines
3.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: HexedHero <6012891+HexedHero@users.noreply.github.com>
|
|
Date: Thu, 6 May 2021 14:56:43 +0100
|
|
Subject: [PATCH] Add more WanderingTrader API
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
|
|
index abb2c5c4ac481c7529aa29322babb1929235e15a..86e1ba898d6b92735258419fa74352e5116226dc 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
|
|
@@ -56,6 +56,10 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill
|
|
@Nullable
|
|
private BlockPos wanderTarget;
|
|
private int despawnDelay;
|
|
+ // Paper start - Add more WanderingTrader API
|
|
+ public boolean canDrinkPotion = true;
|
|
+ public boolean canDrinkMilk = true;
|
|
+ // Paper end
|
|
|
|
public WanderingTrader(EntityType<? extends WanderingTrader> type, Level world) {
|
|
super(type, world);
|
|
@@ -66,10 +70,10 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill
|
|
protected void registerGoals() {
|
|
this.goalSelector.addGoal(0, new FloatGoal(this));
|
|
this.goalSelector.addGoal(0, new UseItemGoal<>(this, PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.INVISIBILITY), SoundEvents.WANDERING_TRADER_DISAPPEARED, (entityvillagertrader) -> {
|
|
- return this.level.isNight() && !entityvillagertrader.isInvisible();
|
|
+ return this.canDrinkPotion && this.level.isNight() && !entityvillagertrader.isInvisible(); // Paper - Add more WanderingTrader API
|
|
}));
|
|
this.goalSelector.addGoal(0, new UseItemGoal<>(this, new ItemStack(Items.MILK_BUCKET), SoundEvents.WANDERING_TRADER_REAPPEARED, (entityvillagertrader) -> {
|
|
- return this.level.isDay() && entityvillagertrader.isInvisible();
|
|
+ return canDrinkMilk && this.level.isDay() && entityvillagertrader.isInvisible(); // Paper - Add more WanderingTrader API
|
|
}));
|
|
this.goalSelector.addGoal(1, new TradeWithPlayerGoal(this));
|
|
this.goalSelector.addGoal(1, new AvoidEntityGoal<>(this, Zombie.class, 8.0F, 0.5D, 0.5D));
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java
|
|
index 65b052567d1d855021d7273672b4354aba0a42a4..fa7107593b20e0151d8d67104e4a92dcc697d461 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java
|
|
@@ -34,4 +34,26 @@ public class CraftWanderingTrader extends CraftAbstractVillager implements Wande
|
|
public void setDespawnDelay(int despawnDelay) {
|
|
this.getHandle().setDespawnDelay(despawnDelay);
|
|
}
|
|
+
|
|
+ // Paper start - Add more WanderingTrader API
|
|
+ @Override
|
|
+ public void setCanDrinkPotion(boolean bool) {
|
|
+ getHandle().canDrinkPotion = bool;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean canDrinkPotion() {
|
|
+ return getHandle().canDrinkPotion;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setCanDrinkMilk(boolean bool) {
|
|
+ getHandle().canDrinkMilk = bool;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean canDrinkMilk() {
|
|
+ return getHandle().canDrinkMilk;
|
|
+ }
|
|
+ // Paper end
|
|
}
|