Skip to content

Commit

Permalink
Updated Upstream (Gale)
Browse files Browse the repository at this point in the history
Upstream has released updates that appear to apply and compile correctly

Gale Changes:
Dreeam-qwq/Gale@dcccfce Drop `Optimize villager data storage`
  • Loading branch information
Dreeam-qwq committed Dec 17, 2024
1 parent d6b323a commit ac7d4e1
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 57 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ group = cn.dreeam.leaf
mcVersion = 1.21.1
version = 1.21.1-R0.1-SNAPSHOT

galeCommit = cbc2b46ac882eb2816412d6d9a45e9b22a772752
galeCommit = dcccfce143d711f40a4c64fcf5c296e05b516856

org.gradle.caching = true
org.gradle.parallel = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@ index 1cb55c9240dfa46cf117ac5b8923b064a96788c3..37e682452ecc30646faf1ae8da47f917
super.customServerAiStep();
if ((this.tickCount + this.getId()) % 120 == 0) {
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
index 491a4c38cbb393c1a565d75a87c0444e321938c0..e1fd6ad56c0fbaf59c9d9ac985ab5301d768f9ba 100644
index ba49442ed0b7c05c50dbc2a640f5759e391902f2..c96d612f0b3efc96f3f60f35449811cacc93123c 100644
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
@@ -144,6 +144,8 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
@@ -143,6 +143,8 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
return holder.is(PoiTypes.MEETING);
});

Expand All @@ -272,15 +272,15 @@ index 491a4c38cbb393c1a565d75a87c0444e321938c0..e1fd6ad56c0fbaf59c9d9ac985ab5301
public Villager(EntityType<? extends Villager> entityType, Level world) {
this(entityType, world, VillagerType.PLAINS);
}
@@ -247,6 +249,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
@@ -246,6 +248,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
}
// Spigot End

+ private int behaviorTick = 0; // Pufferfish
@Override
@Deprecated // Paper
protected void customServerAiStep() {
@@ -255,7 +258,11 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
@@ -254,7 +257,11 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
}
protected void customServerAiStep(final boolean inactive) {
// Paper end
Expand Down
48 changes: 24 additions & 24 deletions patches/server/0011-Purpur-Server-Changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3289,11 +3289,11 @@ index 18dad0825616c4167a0a7555689ee64910a87e09..6945992491027d43eca4f1ca697ad45c
&& this.lookTime > 0
&& entity.getBrain().getMemory(MemoryModuleType.INTERACTION_TARGET).isPresent();
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java b/src/main/java/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java
index 90ae43979e05839d676ab51feb489955ecbee50e..1acf55dd527ac06a46f7e29a720ec53565ddcb9d 100644
index 8508ac7de8cda3127b73e11ff4aee62502e65ead..b1544e028d5a9b84b944e1fb5a12bb163067fb54 100644
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java
@@ -62,6 +62,12 @@ public class TradeWithVillager extends Behavior<Villager> {
throwHalfStack(entity, WHEAT_SINGLETON_ARRAY, villager); // Gale - optimize villager data storage
@@ -59,6 +59,12 @@ public class TradeWithVillager extends Behavior<Villager> {
throwHalfStack(entity, ImmutableSet.of(Items.WHEAT), villager);
}

+ // Purpur start
Expand All @@ -3302,9 +3302,9 @@ index 90ae43979e05839d676ab51feb489955ecbee50e..1acf55dd527ac06a46f7e29a720ec535
+ }
+ // Purpur end
+
// Gale start - optimize villager data storage
if (this.trades != null && entity.getInventory().hasAnyOf(this.trades)) {
if (!this.trades.isEmpty() && entity.getInventory().hasAnyOf(this.trades)) {
throwHalfStack(entity, this.trades, villager);
}
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/VillagerGoalPackages.java b/src/main/java/net/minecraft/world/entity/ai/behavior/VillagerGoalPackages.java
index f000a6c1e61198e6dd06ae5f084d12fdf309f50a..3091d985ba9c55d404332576320718840538722e 100644
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/VillagerGoalPackages.java
Expand Down Expand Up @@ -3515,7 +3515,7 @@ index 92731b6b593289e9f583c9b705b219e81fcd8e73..9104d7010bda6f9f73b478c11490ef9c
// Paper end - optimise POI access
if (path != null && path.canReach()) {
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
index 8bed5992f639f805ccdec56a90101004570dc265..675126d9ab94b6c69d0436a42b9594a567aca6e4 100644
index 1595568f3140a62b0f2236644ac2da11db12af05..d548d1b2686667d809f363cd0ae4444bc3918bf2 100644
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
@@ -29,6 +29,13 @@ public class SecondaryPoiSensor extends Sensor<Villager> {
Expand All @@ -3531,16 +3531,16 @@ index 8bed5992f639f805ccdec56a90101004570dc265..675126d9ab94b6c69d0436a42b9594a5
+ // Purpur end
ResourceKey<Level> resourceKey = world.dimension();
BlockPos blockPos = entity.blockPosition();
@org.jetbrains.annotations.Nullable java.util.ArrayList<GlobalPos> list = null; // Gale - optimize villager data storage
@@ -50,7 +57,7 @@ public class SecondaryPoiSensor extends Sensor<Villager> {
List<GlobalPos> list = Lists.newArrayList();
@@ -45,7 +52,7 @@ public class SecondaryPoiSensor extends Sensor<Villager> {
}
}

- Brain<?> brain = entity.getBrain();
+ //Brain<?> brain = entity.getBrain(); // Purpur - moved up
// Gale start - optimize villager data storage
if (list != null) {
list.trimToSize();
if (!list.isEmpty()) {
brain.setMemory(MemoryModuleType.SECONDARY_JOB_SITE, list);
} else {
diff --git a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
index 4addcfe248dd4705be7e67551b258ce86c57e194..82d3e442f6d31211701878fc5ae7a346247ef124 100644
--- a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
Expand Down Expand Up @@ -12147,10 +12147,10 @@ index e0e5046c84941a8d17e18c177f3daea9cb631940..d503d7a5837dbeb98e58dbe8f7e5de45
}

diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
index e1fd6ad56c0fbaf59c9d9ac985ab5301d768f9ba..92e81a7092e594d1fbe2b239af363739fbba881a 100644
index c96d612f0b3efc96f3f60f35449811cacc93123c..6d8f0effc3143946eebbdb7e0a1a46ed2864df4a 100644
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
@@ -143,6 +143,8 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
@@ -142,6 +142,8 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
}, MemoryModuleType.MEETING_POINT, (entityvillager, holder) -> {
return holder.is(PoiTypes.MEETING);
});
Expand All @@ -12159,7 +12159,7 @@ index e1fd6ad56c0fbaf59c9d9ac985ab5301d768f9ba..92e81a7092e594d1fbe2b239af363739

public long nextGolemPanic = -1; // Pufferfish

@@ -157,6 +159,92 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
@@ -156,6 +158,92 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
this.getNavigation().setCanFloat(true);
this.setCanPickUpLoot(true);
this.setVillagerData(this.getVillagerData().setType(type).setProfession(VillagerProfession.NONE));
Expand Down Expand Up @@ -12252,7 +12252,7 @@ index e1fd6ad56c0fbaf59c9d9ac985ab5301d768f9ba..92e81a7092e594d1fbe2b239af363739
}

@Override
@@ -193,7 +281,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
@@ -192,7 +280,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
brain.addActivity(Activity.PLAY, VillagerGoalPackages.getPlayPackage(0.5F));
} else {
brain.setSchedule(Schedule.VILLAGER_DEFAULT);
Expand All @@ -12261,7 +12261,7 @@ index e1fd6ad56c0fbaf59c9d9ac985ab5301d768f9ba..92e81a7092e594d1fbe2b239af363739
}

brain.addActivity(Activity.CORE, VillagerGoalPackages.getCorePackage(villagerprofession, 0.5F));
@@ -256,12 +344,21 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
@@ -255,12 +343,21 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
// Paper start
this.customServerAiStep(false);
}
Expand All @@ -12285,7 +12285,7 @@ index e1fd6ad56c0fbaf59c9d9ac985ab5301d768f9ba..92e81a7092e594d1fbe2b239af363739
// Pufferfish end
if (this.assignProfessionWhenSpawned) {
this.assignProfessionWhenSpawned = false;
@@ -318,7 +415,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
@@ -317,7 +414,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
if (!itemstack.is(Items.VILLAGER_SPAWN_EGG) && this.isAlive() && !this.isTrading() && !this.isSleeping()) {
if (this.isBaby()) {
this.setUnhappy();
Expand All @@ -12294,7 +12294,7 @@ index e1fd6ad56c0fbaf59c9d9ac985ab5301d768f9ba..92e81a7092e594d1fbe2b239af363739
} else {
if (!this.level().isClientSide) {
boolean flag = this.getOffers().isEmpty();
@@ -332,9 +429,11 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
@@ -331,9 +428,11 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
}

if (flag) {
Expand All @@ -12307,7 +12307,7 @@ index e1fd6ad56c0fbaf59c9d9ac985ab5301d768f9ba..92e81a7092e594d1fbe2b239af363739
this.startTrading(player);
}

@@ -504,7 +603,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
@@ -503,7 +602,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
while (iterator.hasNext()) {
MerchantOffer merchantrecipe = (MerchantOffer) iterator.next();

Expand All @@ -12316,7 +12316,7 @@ index e1fd6ad56c0fbaf59c9d9ac985ab5301d768f9ba..92e81a7092e594d1fbe2b239af363739
}

}
@@ -746,7 +845,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
@@ -745,7 +844,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler

@Override
public boolean canBreed() {
Expand All @@ -12325,7 +12325,7 @@ index e1fd6ad56c0fbaf59c9d9ac985ab5301d768f9ba..92e81a7092e594d1fbe2b239af363739
}

private boolean hungry() {
@@ -960,6 +1059,11 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
@@ -938,6 +1037,11 @@ public class Villager extends AbstractVillager implements ReputationEventHandler

public boolean hasFarmSeeds() {
return this.getInventory().hasAnyMatching((itemstack) -> {
Expand All @@ -12337,15 +12337,15 @@ index e1fd6ad56c0fbaf59c9d9ac985ab5301d768f9ba..92e81a7092e594d1fbe2b239af363739
return itemstack.is(ItemTags.VILLAGER_PLANTABLE_SEEDS);
});
}
@@ -1017,6 +1121,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
@@ -995,6 +1099,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
}

public void spawnGolemIfNeeded(ServerLevel world, long time, int requiredCount) {
+ if (world.purpurConfig.villagerSpawnIronGolemRadius > 0 && world.getEntitiesOfClass(net.minecraft.world.entity.animal.IronGolem.class, getBoundingBox().inflate(world.purpurConfig.villagerSpawnIronGolemRadius)).size() > world.purpurConfig.villagerSpawnIronGolemLimit) return; // Purpur
if (this.wantsToSpawnGolem(time)) {
AABB axisalignedbb = this.getBoundingBox().inflate(10.0D, 10.0D, 10.0D);
List<Villager> list = world.getEntitiesOfClass(Villager.class, axisalignedbb);
@@ -1081,6 +1186,12 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
@@ -1059,6 +1164,12 @@ public class Villager extends AbstractVillager implements ReputationEventHandler

@Override
public void startSleeping(BlockPos pos) {
Expand All @@ -12359,7 +12359,7 @@ index e1fd6ad56c0fbaf59c9d9ac985ab5301d768f9ba..92e81a7092e594d1fbe2b239af363739
this.brain.setMemory(MemoryModuleType.LAST_SLEPT, this.level().getGameTime()); // CraftBukkit - decompile error
this.brain.eraseMemory(MemoryModuleType.WALK_TARGET);
diff --git a/src/main/java/net/minecraft/world/entity/npc/VillagerProfession.java b/src/main/java/net/minecraft/world/entity/npc/VillagerProfession.java
index fa84a4b23a52e60a61c2ee32c1ea449f6dbe0d2b..67ede6b9d6ff2953f155f50c0e92c517ee02c65f 100644
index 8734ab1bd8299bbf43906d81a349c2a13e0981a7..3ca83269311cbc18c9ef3ce62cff6a2d4dc0a683 100644
--- a/src/main/java/net/minecraft/world/entity/npc/VillagerProfession.java
+++ b/src/main/java/net/minecraft/world/entity/npc/VillagerProfession.java
@@ -31,7 +31,7 @@ public record VillagerProfession(
Expand Down
31 changes: 5 additions & 26 deletions patches/server/0012-Fix-Pufferfish-and-Purpur-patches.patch
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ index 096c89bd01cec2abd151bf6fffc4847d1bcd548f..cd0a8a6a1be75cab8bbb8ee3ac17bb73
this.values[this.vp++ & 0xFF] = (int)(l * 100L / Runtime.getRuntime().maxMemory());
this.repaint();
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 01ea21b960b5b32cdb14cefd1c23b50ba5cb8335..e8a89db44ed4f20516a9716bc3f41658f63a312c 100644
index e9d307dacea2f9b11cda5ecf5a06c7df09d1de90..8e7c2e82b5fce1944db58a0031aea40dbddb7057 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -486,7 +486,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
Expand Down Expand Up @@ -229,29 +229,8 @@ index 78745bc7373c36a871ed9672b7fb4311f2ff3ebd..63b827d91a935d6b6f04266eea682da9
public boolean isSunBurnTick() {
// Purpur - implemented in Entity - API for any mob to burn daylight
return super.isSunBurnTick();
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java b/src/main/java/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java
index b96e596fb123f5b69d2b2f5b4a65537beaab33e6..0f6ff2fb3c5df42a44e5082c2408d5262c187870 100644
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java
@@ -21,6 +21,7 @@ public class TradeWithVillager extends Behavior<Villager> {
private static final Item[] WHEAT_SINGLETON_ARRAY = {Items.WHEAT};
private @org.jetbrains.annotations.NotNull Item @org.jetbrains.annotations.Nullable [] trades = null;
// Gale end - optimize villager data storage
+ private static final Item[] NETHER_WART_SINGLETON_ARRAY = {Items.NETHER_WART}; // Leaf - sync with Gale's Optimize-villager-data-storage.patch

public TradeWithVillager() {
super(
@@ -64,7 +65,7 @@ public class TradeWithVillager extends Behavior<Villager> {

// Purpur start
if (world.purpurConfig.villagerClericsFarmWarts && world.purpurConfig.villagerClericFarmersThrowWarts && entity.getVillagerData().getProfession() == VillagerProfession.CLERIC && entity.getInventory().countItem(Items.NETHER_WART) > Items.NETHER_WART.getDefaultMaxStackSize() / 2) {
- throwHalfStack(entity, ImmutableSet.of(Items.NETHER_WART), villager);
+ throwHalfStack(entity, NETHER_WART_SINGLETON_ARRAY, villager); // Leaf - sync with Gale's Optimize-villager-data-storage.patch
}
// Purpur end

diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
index 675126d9ab94b6c69d0436a42b9594a567aca6e4..67f16bd710e0c04b4e2dac2c2cf5862853f3f4f4 100644
index d548d1b2686667d809f363cd0ae4444bc3918bf2..c3519eb6b28d180c9a5bf673037f1c4324ba5685 100644
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
@@ -22,19 +22,15 @@ public class SecondaryPoiSensor extends Sensor<Villager> {
Expand All @@ -261,15 +240,15 @@ index 675126d9ab94b6c69d0436a42b9594a567aca6e4..67f16bd710e0c04b4e2dac2c2cf58628
+ // Purpur start - make sure clerics don't wander to soul sand when the option is off
// Gale start - Lithium - skip secondary POI sensor if absent
var secondaryPoi = entity.getVillagerData().getProfession().secondaryPoi();
- if (secondaryPoi == null) { // Gale - optimize villager data storage
- if (secondaryPoi.isEmpty()) {
- entity.getBrain().eraseMemory(MemoryModuleType.SECONDARY_JOB_SITE);
- return;
- }
- // Gale end - Lithium - skip secondary POI sensor if absent
- // Purpur start - make sure clerics don't wander to soul sand when the option is off
Brain<?> brain = entity.getBrain();
- if (!world.purpurConfig.villagerClericsFarmWarts && entity.getVillagerData().getProfession() == net.minecraft.world.entity.npc.VillagerProfession.CLERIC) {
+ if (secondaryPoi == null || (!world.purpurConfig.villagerClericsFarmWarts && entity.getVillagerData().getProfession() == net.minecraft.world.entity.npc.VillagerProfession.CLERIC)) {
+ if (secondaryPoi.isEmpty() || (!world.purpurConfig.villagerClericsFarmWarts && entity.getVillagerData().getProfession() == net.minecraft.world.entity.npc.VillagerProfession.CLERIC)) {
brain.eraseMemory(MemoryModuleType.SECONDARY_JOB_SITE);
return;
}
Expand Down Expand Up @@ -311,7 +290,7 @@ index 6c68c1df84e006f9992435f4c8e328c17e88c51c..f86f42863227494f7f71a7813fd49049
@Override
protected void registerGoals() {
diff --git a/src/main/java/net/minecraft/world/entity/npc/VillagerProfession.java b/src/main/java/net/minecraft/world/entity/npc/VillagerProfession.java
index 67ede6b9d6ff2953f155f50c0e92c517ee02c65f..759d808ee73dfb480d91ae6f17dc56f4ad0b0a20 100644
index 3ca83269311cbc18c9ef3ce62cff6a2d4dc0a683..a636ab87d21c67b152b40b77e62fa8043ca4211e 100644
--- a/src/main/java/net/minecraft/world/entity/npc/VillagerProfession.java
+++ b/src/main/java/net/minecraft/world/entity/npc/VillagerProfession.java
@@ -31,7 +31,7 @@ public record VillagerProfession(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ index 02d7180e5b932dd8c7e8867f1334cbc47e26f5bd..9d196c8a8a0dc49a54264471429b6ff6
if (this.goalSelector.inactiveTick(this.activatedPriority, true) && !isThrottled) { // Pufferfish - pass activated priroity // Pufferfish - throttle inactive goal selector ticking
this.goalSelector.tick();
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
index 92e81a7092e594d1fbe2b239af363739fbba881a..0dc4491799806dc53da0c3815a02c082409ec988 100644
index 6d8f0effc3143946eebbdb7e0a1a46ed2864df4a..9edc76fea0e08a0067382c46836a518fdbe55546 100644
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
@@ -323,7 +323,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
@@ -322,7 +322,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
if (this.getUnhappyCounter() > 0) {
this.setUnhappyCounter(this.getUnhappyCounter() - 1);
}
Expand Down

0 comments on commit ac7d4e1

Please sign in to comment.