Fix wart farmers plating vegetables on soul sand

This commit is contained in:
jmp
2021-03-23 15:20:25 -07:00
parent 99f1ce61f6
commit c3de3ac665
3 changed files with 32 additions and 58 deletions

View File

@@ -28,18 +28,10 @@ index 774ba6a923f7e329f6af5efc17e1c46e87ed2d77..b8c73cd0ba916b7bf166a6d2f6b7ab68
for (int i = 0; i < this.getSize(); ++i) {
ItemStack itemstack = this.getItem(i);
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java b/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java
index 42c70a6c2972ac38e889a6d42fe2d7d4f6017d57..751f2b2f7d0e87212a6bd813d4f85cefd5bb2b50 100644
index 42c70a6c2972ac38e889a6d42fe2d7d4f6017d57..752642c0a15d68fcc1871e1cb02658b12c8978b3 100644
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java
@@ -21,6 +21,7 @@ import net.minecraft.world.item.Items;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.BlockCrops;
+import net.minecraft.world.level.block.BlockNetherWart;
import net.minecraft.world.level.block.BlockSoil;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.IBlockData;
@@ -32,6 +33,7 @@ public class BehaviorFarm extends Behavior<EntityVillager> {
@@ -32,6 +32,7 @@ public class BehaviorFarm extends Behavior<EntityVillager> {
private long c;
private int d;
private final List<BlockPosition> e = Lists.newArrayList();
@@ -47,7 +39,7 @@ index 42c70a6c2972ac38e889a6d42fe2d7d4f6017d57..751f2b2f7d0e87212a6bd813d4f85cef
public BehaviorFarm() {
super(ImmutableMap.of(MemoryModuleType.LOOK_TARGET, MemoryStatus.VALUE_ABSENT, MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_ABSENT, MemoryModuleType.SECONDARY_JOB_SITE, MemoryStatus.VALUE_PRESENT));
@@ -40,9 +42,14 @@ public class BehaviorFarm extends Behavior<EntityVillager> {
@@ -40,9 +41,14 @@ public class BehaviorFarm extends Behavior<EntityVillager> {
protected boolean a(WorldServer worldserver, EntityVillager entityvillager) {
if (!worldserver.getGameRules().getBoolean(GameRules.MOB_GRIEFING) && !worldserver.purpurConfig.villagerFarmingBypassMobGriefing) { // Purpur
return false;
@@ -63,50 +55,52 @@ index 42c70a6c2972ac38e889a6d42fe2d7d4f6017d57..751f2b2f7d0e87212a6bd813d4f85cef
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = entityvillager.getChunkCoordinates().i();
this.e.clear();
@@ -73,6 +80,11 @@ public class BehaviorFarm extends Behavior<EntityVillager> {
@@ -73,6 +79,11 @@ public class BehaviorFarm extends Behavior<EntityVillager> {
Block block = iblockdata.getBlock();
Block block1 = worldserver.getType(blockposition.down()).getBlock();
+ // Purpur start
+ if (this.clericWartFarmer) {
+ return block == Blocks.NETHER_WART && iblockdata.get(BlockNetherWart.AGE) == 3 || iblockdata.isAir() && block1 == Blocks.SOUL_SAND;
+ return block == Blocks.NETHER_WART && iblockdata.get(net.minecraft.world.level.block.BlockNetherWart.AGE) == 3 || iblockdata.isAir() && block1 == Blocks.SOUL_SAND;
+ }
+ // Purpur end
return block instanceof BlockCrops && ((BlockCrops) block).isRipe(iblockdata) || iblockdata.isAir() && block1 instanceof BlockSoil;
}
@@ -98,7 +110,7 @@ public class BehaviorFarm extends Behavior<EntityVillager> {
@@ -98,7 +109,7 @@ public class BehaviorFarm extends Behavior<EntityVillager> {
Block block = iblockdata.getBlock();
Block block1 = worldserver.getType(this.farmBlock.down()).getBlock();
- if (block instanceof BlockCrops && ((BlockCrops) block).isRipe(iblockdata)) {
+ if (block instanceof BlockCrops && ((BlockCrops) block).isRipe(iblockdata) || this.clericWartFarmer && block == Blocks.NETHER_WART && iblockdata.get(BlockNetherWart.AGE) == 3) { // Purpur
+ if (block instanceof BlockCrops && ((BlockCrops) block).isRipe(iblockdata) && !this.clericWartFarmer || this.clericWartFarmer && block == Blocks.NETHER_WART && iblockdata.get(net.minecraft.world.level.block.BlockNetherWart.AGE) == 3) { // Purpur
// CraftBukkit start
if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.farmBlock, Blocks.AIR.getBlockData()).isCancelled()) {
worldserver.a(this.farmBlock, true, entityvillager);
@@ -106,7 +118,7 @@ public class BehaviorFarm extends Behavior<EntityVillager> {
@@ -106,7 +117,7 @@ public class BehaviorFarm extends Behavior<EntityVillager> {
// CraftBukkit end
}
- if (iblockdata.isAir() && block1 instanceof BlockSoil && entityvillager.canPlant()) {
+ if (iblockdata.isAir() && (block1 instanceof BlockSoil || this.clericWartFarmer && block1 == Blocks.SOUL_SAND) && entityvillager.canPlant()) { // Purpur
+ if (iblockdata.isAir() && (block1 instanceof BlockSoil && !this.clericWartFarmer || this.clericWartFarmer && block1 == Blocks.SOUL_SAND) && entityvillager.canPlant()) { // Purpur
InventorySubcontainer inventorysubcontainer = entityvillager.getInventory();
for (int j = 0; j < inventorysubcontainer.getSize(); ++j) {
@@ -129,6 +141,12 @@ public class BehaviorFarm extends Behavior<EntityVillager> {
planted = Blocks.BEETROOTS;
flag = true;
}
@@ -116,6 +127,14 @@ public class BehaviorFarm extends Behavior<EntityVillager> {
if (!itemstack.isEmpty()) {
// CraftBukkit start
Block planted = null;
+ // Purpur start
+ else if (itemstack.getItem() == Items.NETHER_WART) {
+ planted = Blocks.NETHER_WART;
+ flag = true;
+ }
+ if (this.clericWartFarmer) {
+ if (itemstack.getItem() == Items.NETHER_WART) {
+ planted = Blocks.NETHER_WART;
+ flag = true;
+ }
+ } else
+ // Purpur end
if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.farmBlock, planted.getBlockData()).isCancelled()) {
worldserver.setTypeAndData(this.farmBlock, planted.getBlockData(), 3);
@@ -139,7 +157,7 @@ public class BehaviorFarm extends Behavior<EntityVillager> {
if (itemstack.getItem() == Items.WHEAT_SEEDS) {
planted = Blocks.WHEAT;
flag = true;
@@ -139,7 +158,7 @@ public class BehaviorFarm extends Behavior<EntityVillager> {
}
if (flag) {
@@ -161,24 +155,16 @@ index df12193e1a2e449193a3feab53fc684a2571ae3a..4a8217862a98488ce71ce577b5fa9d6a
} else {
object = new BehaviorWork();
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/SensorSecondaryPlaces.java b/src/main/java/net/minecraft/world/entity/ai/sensing/SensorSecondaryPlaces.java
index 25c10973c74f98224dd1d2ae5e7178b9781374aa..78df1ded72a625c676faf4d704e9e44cec2bc054 100644
index 25c10973c74f98224dd1d2ae5e7178b9781374aa..d50b5632f0e53147ea23109f1ed627b44f798b58 100644
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/SensorSecondaryPlaces.java
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/SensorSecondaryPlaces.java
@@ -11,6 +11,7 @@ import net.minecraft.server.level.WorldServer;
import net.minecraft.world.entity.ai.BehaviorController;
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
import net.minecraft.world.entity.npc.EntityVillager;
+import net.minecraft.world.entity.npc.VillagerProfession;
import net.minecraft.world.level.World;
public class SensorSecondaryPlaces extends Sensor<EntityVillager> {
@@ -20,6 +21,13 @@ public class SensorSecondaryPlaces extends Sensor<EntityVillager> {
@@ -20,6 +20,13 @@ public class SensorSecondaryPlaces extends Sensor<EntityVillager> {
}
protected void a(WorldServer worldserver, EntityVillager entityvillager) {
+ // Purpur start - make sure clerics don't wander to soul sand when the option is off
+ BehaviorController<?> behaviorcontroller = entityvillager.getBehaviorController();
+ if (!worldserver.purpurConfig.villagerClericsFarmWarts && entityvillager.getVillagerData().getProfession() == VillagerProfession.CLERIC) {
+ if (!worldserver.purpurConfig.villagerClericsFarmWarts && entityvillager.getVillagerData().getProfession() == net.minecraft.world.entity.npc.VillagerProfession.CLERIC) {
+ behaviorcontroller.removeMemory(MemoryModuleType.SECONDARY_JOB_SITE);
+ return;
+ }
@@ -186,7 +172,7 @@ index 25c10973c74f98224dd1d2ae5e7178b9781374aa..78df1ded72a625c676faf4d704e9e44c
ResourceKey<World> resourcekey = worldserver.getDimensionKey();
BlockPosition blockposition = entityvillager.getChunkCoordinates();
List<GlobalPos> list = Lists.newArrayList();
@@ -37,10 +45,10 @@ public class SensorSecondaryPlaces extends Sensor<EntityVillager> {
@@ -37,10 +44,10 @@ public class SensorSecondaryPlaces extends Sensor<EntityVillager> {
}
}
@@ -200,7 +186,7 @@ index 25c10973c74f98224dd1d2ae5e7178b9781374aa..78df1ded72a625c676faf4d704e9e44c
behaviorcontroller.removeMemory(MemoryModuleType.SECONDARY_JOB_SITE);
}
diff --git a/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java b/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
index bc14e242f97f9f6d8e581d12319c95ae5f70f250..77a5be6f5fc51689a74f853b5dfcef5e772e2c84 100644
index bc14e242f97f9f6d8e581d12319c95ae5f70f250..0924e0c13b3c57e46f6dc40232707088f96e98c7 100644
--- a/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
@@ -203,7 +203,7 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
@@ -208,23 +194,11 @@ index bc14e242f97f9f6d8e581d12319c95ae5f70f250..77a5be6f5fc51689a74f853b5dfcef5e
} else {
behaviorcontroller.setSchedule(Schedule.VILLAGER_DEFAULT);
- behaviorcontroller.a(Activity.WORK, Behaviors.b(villagerprofession, 0.5F), (Set) ImmutableSet.of(Pair.of(MemoryModuleType.JOB_SITE, MemoryStatus.VALUE_PRESENT)));
+ behaviorcontroller.a(Activity.WORK, Behaviors.createWorkTask(villagerprofession, 0.5F, this.world.purpurConfig.villagerClericsFarmWarts), (Set) ImmutableSet.of(Pair.of(MemoryModuleType.JOB_SITE, MemoryStatus.VALUE_PRESENT))); // Purpur
+ behaviorcontroller.a(Activity.WORK, Behaviors.createWorkTask(villagerprofession, 0.5F, this.world.purpurConfig.villagerClericsFarmWarts), ImmutableSet.of(Pair.of(MemoryModuleType.JOB_SITE, MemoryStatus.VALUE_PRESENT))); // Purpur
}
behaviorcontroller.a(Activity.CORE, Behaviors.a(villagerprofession, 0.5F));
@@ -923,6 +923,11 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
@Override
public boolean i(ItemStack itemstack) {
Item item = itemstack.getItem();
+ // Purpur start
+ if (this.world.purpurConfig.villagerClericsFarmWarts && item.getItem() == Items.NETHER_WART && this.getVillagerData().getProfession() == VillagerProfession.CLERIC) {
+ return true;
+ }
+ // Purpur end
return (EntityVillager.bs.contains(item) || this.getVillagerData().getProfession().c().contains(item)) && this.getInventory().b(itemstack);
}
@@ -944,6 +949,11 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
@@ -944,6 +944,11 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
}
public boolean canPlant() {

View File

@@ -1362,7 +1362,7 @@ index da2220b08a9cd9c2d7d3fd06702e6690e12f095e..c441d6b2ce29d914a29c2f39d70adb14
public static AttributeProvider.Builder eS() {
diff --git a/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java b/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
index 77a5be6f5fc51689a74f853b5dfcef5e772e2c84..6ad608a795e85daf7425f26041b5e4a86cadc033 100644
index 0924e0c13b3c57e46f6dc40232707088f96e98c7..16933de70a23414859019e19545bfa5baa38091a 100644
--- a/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
@@ -167,6 +167,11 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Add config for villager trading
diff --git a/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java b/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
index 6ad608a795e85daf7425f26041b5e4a86cadc033..77609e929512ca0fbd422dff11fc5e14eede90d0 100644
index 16933de70a23414859019e19545bfa5baa38091a..a02748bff911415d95bea344f179ad27ff9d6092 100644
--- a/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
@@ -373,7 +373,7 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation