mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
port Option for Villager Clerics to farm Nether Wart patch
This commit is contained in:
@@ -1,197 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||
Date: Sat, 5 Dec 2020 01:20:16 -0800
|
||||
Subject: [PATCH] Option for Villager Clerics to farm Nether Wart
|
||||
|
||||
Adds an option so that Villagers with the Cleric profession are able to
|
||||
farm Nether Wart. Reimplemented based on a feature of the carpet-extra
|
||||
mod.
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java b/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java
|
||||
index 2ade08d1466660ee1787fa97908002ef56389712..4fa4ec34963730507253182cad1c2bf04090ad50 100644
|
||||
--- a/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java
|
||||
@@ -41,6 +41,7 @@ public class HarvestFarmland extends Behavior<Villager> {
|
||||
private long nextOkStartTime;
|
||||
private int timeWorkedSoFar;
|
||||
private final List<BlockPos> validFarmlandAroundVillager = Lists.newArrayList();
|
||||
+ private boolean clericWartFarmer = false; // Purpur
|
||||
|
||||
public HarvestFarmland() {
|
||||
super(ImmutableMap.of(MemoryModuleType.LOOK_TARGET, MemoryStatus.VALUE_ABSENT, MemoryModuleType.WALK_TARGET, MemoryStatus.VALUE_ABSENT, MemoryModuleType.SECONDARY_JOB_SITE, MemoryStatus.VALUE_PRESENT));
|
||||
@@ -49,9 +50,10 @@ public class HarvestFarmland extends Behavior<Villager> {
|
||||
protected boolean checkExtraStartConditions(ServerLevel world, Villager entity) {
|
||||
if (!world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
|
||||
return false;
|
||||
- } else if (entity.getVillagerData().getProfession() != VillagerProfession.FARMER) {
|
||||
+ } else if (entity.getVillagerData().getProfession() != VillagerProfession.FARMER && !(world.purpurConfig.villagerClericsFarmWarts && entity.getVillagerData().getProfession() == VillagerProfession.CLERIC)) { // Purpur
|
||||
return false;
|
||||
} else {
|
||||
+ if (!this.clericWartFarmer && entity.getVillagerData().getProfession() == VillagerProfession.CLERIC) this.clericWartFarmer = true; // Purpur
|
||||
BlockPos.MutableBlockPos blockposition_mutableblockposition = entity.blockPosition().mutable();
|
||||
|
||||
this.validFarmlandAroundVillager.clear();
|
||||
@@ -82,6 +84,7 @@ public class HarvestFarmland extends Behavior<Villager> {
|
||||
Block block = iblockdata.getBlock();
|
||||
Block block1 = world.getBlockState(pos.below()).getBlock();
|
||||
|
||||
+ if (this.clericWartFarmer) return block == Blocks.NETHER_WART && iblockdata.getValue(net.minecraft.world.level.block.NetherWartBlock.AGE) == 3 || iblockdata.isAir() && block1 == Blocks.SOUL_SAND; // Purpur
|
||||
return block instanceof CropBlock && ((CropBlock) block).isMaxAge(iblockdata) || iblockdata.isAir() && block1 instanceof FarmBlock;
|
||||
}
|
||||
|
||||
@@ -107,20 +110,20 @@ public class HarvestFarmland extends Behavior<Villager> {
|
||||
Block block = iblockdata.getBlock();
|
||||
Block block1 = world.getBlockState(this.aboveFarmlandPos.below()).getBlock();
|
||||
|
||||
- if (block instanceof CropBlock && ((CropBlock) block).isMaxAge(iblockdata)) {
|
||||
+ if (block instanceof CropBlock && ((CropBlock) block).isMaxAge(iblockdata) && !this.clericWartFarmer || this.clericWartFarmer && block == Blocks.NETHER_WART && iblockdata.getValue(net.minecraft.world.level.block.NetherWartBlock.AGE) == 3) { // Purpur
|
||||
if (CraftEventFactory.callEntityChangeBlockEvent(entity, this.aboveFarmlandPos, iblockdata.getFluidState().createLegacyBlock())) { // CraftBukkit // Paper - fix wrong block state
|
||||
world.destroyBlock(this.aboveFarmlandPos, true, entity);
|
||||
} // CraftBukkit
|
||||
}
|
||||
|
||||
- if (iblockdata.isAir() && block1 instanceof FarmBlock && entity.hasFarmSeeds()) {
|
||||
+ if (iblockdata.isAir() && (block1 instanceof FarmBlock && !this.clericWartFarmer || this.clericWartFarmer && block1 == Blocks.SOUL_SAND) && entity.hasFarmSeeds()) { // Purpur
|
||||
SimpleContainer inventorysubcontainer = entity.getInventory();
|
||||
|
||||
for (int j = 0; j < inventorysubcontainer.getContainerSize(); ++j) {
|
||||
ItemStack itemstack = inventorysubcontainer.getItem(j);
|
||||
boolean flag = false;
|
||||
|
||||
- if (!itemstack.isEmpty() && itemstack.is(ItemTags.VILLAGER_PLANTABLE_SEEDS)) {
|
||||
+ if (!itemstack.isEmpty() && (itemstack.is(ItemTags.VILLAGER_PLANTABLE_SEEDS) || this.clericWartFarmer && itemstack.getItem() == net.minecraft.world.item.Items.NETHER_WART)) {
|
||||
Item item = itemstack.getItem();
|
||||
|
||||
if (item instanceof BlockItem) {
|
||||
@@ -136,7 +139,7 @@ public class HarvestFarmland extends Behavior<Villager> {
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
- world.playSound((Player) null, (double) this.aboveFarmlandPos.getX(), (double) this.aboveFarmlandPos.getY(), (double) this.aboveFarmlandPos.getZ(), SoundEvents.CROP_PLANTED, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
+ world.playSound((Player) null, (double) this.aboveFarmlandPos.getX(), (double) this.aboveFarmlandPos.getY(), (double) this.aboveFarmlandPos.getZ(), this.clericWartFarmer ? SoundEvents.NETHER_WART_PLANTED : SoundEvents.CROP_PLANTED, SoundSource.BLOCKS, 1.0F, 1.0F); // Purpur
|
||||
itemstack.shrink(1);
|
||||
if (itemstack.isEmpty()) {
|
||||
inventorysubcontainer.setItem(j, ItemStack.EMPTY);
|
||||
diff --git a/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java b/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java
|
||||
index 8508ac7de8cda3127b73e11ff4aee62502e65ead..b1544e028d5a9b84b944e1fb5a12bb163067fb54 100644
|
||||
--- a/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java
|
||||
@@ -59,6 +59,12 @@ public class TradeWithVillager extends Behavior<Villager> {
|
||||
throwHalfStack(entity, ImmutableSet.of(Items.WHEAT), 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);
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+
|
||||
if (!this.trades.isEmpty() && entity.getInventory().hasAnyOf(this.trades)) {
|
||||
throwHalfStack(entity, this.trades, villager);
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/ai/behavior/VillagerGoalPackages.java b/net/minecraft/world/entity/ai/behavior/VillagerGoalPackages.java
|
||||
index 41f4107101bcd5d753b72cdbabe7946a1975c653..4475b406dde30e5be8ce9d2ff45f8d22d242690c 100644
|
||||
--- a/net/minecraft/world/entity/ai/behavior/VillagerGoalPackages.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/VillagerGoalPackages.java
|
||||
@@ -74,8 +74,13 @@ public class VillagerGoalPackages {
|
||||
}
|
||||
|
||||
public static ImmutableList<Pair<Integer, ? extends BehaviorControl<? super Villager>>> getWorkPackage(VillagerProfession profession, float speed) {
|
||||
+ // Purpur start
|
||||
+ return getWorkPackage(profession, speed, false);
|
||||
+ }
|
||||
+ public static ImmutableList<Pair<Integer, ? extends BehaviorControl<? super Villager>>> getWorkPackage(VillagerProfession profession, float speed, boolean clericsFarmWarts) {
|
||||
+ // Purpur end
|
||||
WorkAtPoi workAtPoi;
|
||||
- if (profession == VillagerProfession.FARMER) {
|
||||
+ if (profession == VillagerProfession.FARMER || (clericsFarmWarts && profession == VillagerProfession.CLERIC)) { // Purpur
|
||||
workAtPoi = new WorkAtComposter();
|
||||
} else {
|
||||
workAtPoi = new WorkAtPoi();
|
||||
diff --git a/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java b/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
|
||||
index a0e0692d17760f440fe81d52887284c787e562db..ab9bebc07b5228dbc0d3ba4b0f7d1bbe41814c9b 100644
|
||||
--- a/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
|
||||
+++ b/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
|
||||
@@ -22,6 +22,13 @@ public class SecondaryPoiSensor extends Sensor<Villager> {
|
||||
|
||||
@Override
|
||||
protected void doTick(ServerLevel world, Villager entity) {
|
||||
+ // 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) {
|
||||
+ brain.eraseMemory(MemoryModuleType.SECONDARY_JOB_SITE);
|
||||
+ return;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
ResourceKey<Level> resourceKey = world.dimension();
|
||||
BlockPos blockPos = entity.blockPosition();
|
||||
List<GlobalPos> list = Lists.newArrayList();
|
||||
@@ -38,7 +45,7 @@ public class SecondaryPoiSensor extends Sensor<Villager> {
|
||||
}
|
||||
}
|
||||
|
||||
- Brain<?> brain = entity.getBrain();
|
||||
+ //Brain<?> brain = entity.getBrain(); // Purpur - moved up
|
||||
if (!list.isEmpty()) {
|
||||
brain.setMemory(MemoryModuleType.SECONDARY_JOB_SITE, list);
|
||||
} else {
|
||||
diff --git a/net/minecraft/world/entity/npc/Villager.java b/net/minecraft/world/entity/npc/Villager.java
|
||||
index ca1996ab3b998607c193ba427163a6a144990c97..66a8beddde806e04ca4d0e943734d6116b107bcc 100644
|
||||
--- a/net/minecraft/world/entity/npc/Villager.java
|
||||
+++ b/net/minecraft/world/entity/npc/Villager.java
|
||||
@@ -227,7 +227,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
brain.addActivity(Activity.PLAY, VillagerGoalPackages.getPlayPackage(0.5F));
|
||||
} else {
|
||||
brain.setSchedule(Schedule.VILLAGER_DEFAULT);
|
||||
- brain.addActivityWithConditions(Activity.WORK, VillagerGoalPackages.getWorkPackage(villagerprofession, 0.5F), ImmutableSet.of(Pair.of(MemoryModuleType.JOB_SITE, MemoryStatus.VALUE_PRESENT)));
|
||||
+ brain.addActivityWithConditions(Activity.WORK, VillagerGoalPackages.getWorkPackage(villagerprofession, 0.5F, this.level().purpurConfig.villagerClericsFarmWarts), ImmutableSet.of(Pair.of(MemoryModuleType.JOB_SITE, MemoryStatus.VALUE_PRESENT))); // Purpur
|
||||
}
|
||||
|
||||
brain.addActivity(Activity.CORE, VillagerGoalPackages.getCorePackage(villagerprofession, 0.5F));
|
||||
@@ -947,6 +947,11 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
|
||||
public boolean hasFarmSeeds() {
|
||||
return this.getInventory().hasAnyMatching((itemstack) -> {
|
||||
+ // Purpur start
|
||||
+ if (this.level().purpurConfig.villagerClericsFarmWarts && this.getVillagerData().getProfession() == VillagerProfession.CLERIC) {
|
||||
+ return itemstack.is(Items.NETHER_WART);
|
||||
+ }
|
||||
+ // Purpur end
|
||||
return itemstack.is(ItemTags.VILLAGER_PLANTABLE_SEEDS);
|
||||
});
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/npc/VillagerProfession.java b/net/minecraft/world/entity/npc/VillagerProfession.java
|
||||
index 8734ab1bd8299bbf43906d81a349c2a13e0981a7..3ca83269311cbc18c9ef3ce62cff6a2d4dc0a683 100644
|
||||
--- a/net/minecraft/world/entity/npc/VillagerProfession.java
|
||||
+++ b/net/minecraft/world/entity/npc/VillagerProfession.java
|
||||
@@ -31,7 +31,7 @@ public record VillagerProfession(
|
||||
public static final VillagerProfession ARMORER = register("armorer", PoiTypes.ARMORER, SoundEvents.VILLAGER_WORK_ARMORER);
|
||||
public static final VillagerProfession BUTCHER = register("butcher", PoiTypes.BUTCHER, SoundEvents.VILLAGER_WORK_BUTCHER);
|
||||
public static final VillagerProfession CARTOGRAPHER = register("cartographer", PoiTypes.CARTOGRAPHER, SoundEvents.VILLAGER_WORK_CARTOGRAPHER);
|
||||
- public static final VillagerProfession CLERIC = register("cleric", PoiTypes.CLERIC, SoundEvents.VILLAGER_WORK_CLERIC);
|
||||
+ public static final VillagerProfession CLERIC = register("cleric", PoiTypes.CLERIC, ImmutableSet.of(Items.NETHER_WART), ImmutableSet.of(Blocks.SOUL_SAND), SoundEvents.VILLAGER_WORK_CLERIC); // Purpur
|
||||
public static final VillagerProfession FARMER = register(
|
||||
"farmer",
|
||||
PoiTypes.FARMER,
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
index dec46168df0ca009bcc0a1abe3ff6f47f3d7a66e..53a740b2d85afc1fc09f91037aaff8b7e1caf5ea 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
@@ -1920,6 +1920,8 @@ public class PurpurWorldConfig {
|
||||
public boolean villagerCanBeLeashed = false;
|
||||
public boolean villagerCanBreed = true;
|
||||
public int villagerBreedingTicks = 6000;
|
||||
+ public boolean villagerClericsFarmWarts = false;
|
||||
+ public boolean villagerClericFarmersThrowWarts = true;
|
||||
private void villagerSettings() {
|
||||
villagerRidable = getBoolean("mobs.villager.ridable", villagerRidable);
|
||||
villagerRidableInWater = getBoolean("mobs.villager.ridable-in-water", villagerRidableInWater);
|
||||
@@ -1936,6 +1938,8 @@ public class PurpurWorldConfig {
|
||||
villagerCanBeLeashed = getBoolean("mobs.villager.can-be-leashed", villagerCanBeLeashed);
|
||||
villagerCanBreed = getBoolean("mobs.villager.can-breed", villagerCanBreed);
|
||||
villagerBreedingTicks = getInt("mobs.villager.breeding-delay-ticks", villagerBreedingTicks);
|
||||
+ villagerClericsFarmWarts = getBoolean("mobs.villager.clerics-farm-warts", villagerClericsFarmWarts);
|
||||
+ villagerClericFarmersThrowWarts = getBoolean("mobs.villager.cleric-wart-farmers-throw-warts-at-villagers", villagerClericFarmersThrowWarts);
|
||||
}
|
||||
|
||||
public boolean vindicatorRidable = false;
|
||||
@@ -0,0 +1,171 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||
Date: Sat, 5 Dec 2020 01:20:16 -0800
|
||||
Subject: [PATCH] Option for Villager Clerics to farm Nether Wart
|
||||
|
||||
Adds an option so that Villagers with the Cleric profession are able to
|
||||
farm Nether Wart. Reimplemented based on a feature of the carpet-extra
|
||||
mod.
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java b/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java
|
||||
index 4106549bd4dec1cc47d8765be8f5d119fe33bf56..e98fac58b29f78cb63bd868811cca41e1644e9ac 100644
|
||||
--- a/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/HarvestFarmland.java
|
||||
@@ -32,6 +32,7 @@ public class HarvestFarmland extends Behavior<Villager> {
|
||||
private long nextOkStartTime;
|
||||
private int timeWorkedSoFar;
|
||||
private final List<BlockPos> validFarmlandAroundVillager = Lists.newArrayList();
|
||||
+ private boolean clericWartFarmer = false; // Purpur - Option for Villager Clerics to farm Nether Wart
|
||||
|
||||
public HarvestFarmland() {
|
||||
super(
|
||||
@@ -50,9 +51,10 @@ public class HarvestFarmland extends Behavior<Villager> {
|
||||
protected boolean checkExtraStartConditions(ServerLevel level, Villager owner) {
|
||||
if (!level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
|
||||
return false;
|
||||
- } else if (owner.getVillagerData().getProfession() != VillagerProfession.FARMER) {
|
||||
+ } else if (owner.getVillagerData().getProfession() != VillagerProfession.FARMER && !(level.purpurConfig.villagerClericsFarmWarts && owner.getVillagerData().getProfession() == VillagerProfession.CLERIC)) { // Purpur - Option for Villager Clerics to farm Nether Wart
|
||||
return false;
|
||||
} else {
|
||||
+ if (!this.clericWartFarmer && owner.getVillagerData().getProfession() == VillagerProfession.CLERIC) this.clericWartFarmer = true; // Purpur - Option for Villager Clerics to farm Nether Wart
|
||||
BlockPos.MutableBlockPos mutableBlockPos = owner.blockPosition().mutable();
|
||||
this.validFarmlandAroundVillager.clear();
|
||||
|
||||
@@ -83,6 +85,7 @@ public class HarvestFarmland extends Behavior<Villager> {
|
||||
BlockState blockState = serverLevel.getBlockState(pos);
|
||||
Block block = blockState.getBlock();
|
||||
Block block1 = serverLevel.getBlockState(pos.below()).getBlock();
|
||||
+ if (this.clericWartFarmer) return block == net.minecraft.world.level.block.Blocks.NETHER_WART && blockState.getValue(net.minecraft.world.level.block.NetherWartBlock.AGE) == 3 || blockState.isAir() && block1 == net.minecraft.world.level.block.Blocks.SOUL_SAND; // Purpur - Option for Villager Clerics to farm Nether Wart
|
||||
return block instanceof CropBlock && ((CropBlock)block).isMaxAge(blockState) || blockState.isAir() && block1 instanceof FarmBlock;
|
||||
}
|
||||
|
||||
@@ -109,19 +112,19 @@ public class HarvestFarmland extends Behavior<Villager> {
|
||||
BlockState blockState = level.getBlockState(this.aboveFarmlandPos);
|
||||
Block block = blockState.getBlock();
|
||||
Block block1 = level.getBlockState(this.aboveFarmlandPos.below()).getBlock();
|
||||
- if (block instanceof CropBlock && ((CropBlock)block).isMaxAge(blockState)) {
|
||||
+ if (block instanceof CropBlock && ((CropBlock)block).isMaxAge(blockState) && !this.clericWartFarmer || this.clericWartFarmer && block == net.minecraft.world.level.block.Blocks.NETHER_WART && blockState.getValue(net.minecraft.world.level.block.NetherWartBlock.AGE) == 3) { // Purpur - Option for Villager Clerics to farm Nether Wart
|
||||
if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(owner, this.aboveFarmlandPos, blockState.getFluidState().createLegacyBlock())) { // CraftBukkit // Paper - fix wrong block state
|
||||
level.destroyBlock(this.aboveFarmlandPos, true, owner);
|
||||
} // CraftBukkit
|
||||
}
|
||||
|
||||
- if (blockState.isAir() && block1 instanceof FarmBlock && owner.hasFarmSeeds()) {
|
||||
+ if (blockState.isAir() && block1 instanceof FarmBlock && !this.clericWartFarmer || this.clericWartFarmer && block1 == net.minecraft.world.level.block.Blocks.SOUL_SAND && owner.hasFarmSeeds()) { // Purpur - Option for Villager Clerics to farm Nether Wart
|
||||
SimpleContainer inventory = owner.getInventory();
|
||||
|
||||
for (int i = 0; i < inventory.getContainerSize(); i++) {
|
||||
ItemStack item = inventory.getItem(i);
|
||||
boolean flag = false;
|
||||
- if (!item.isEmpty() && item.is(ItemTags.VILLAGER_PLANTABLE_SEEDS) && item.getItem() instanceof BlockItem blockItem) {
|
||||
+ if (!item.isEmpty() && (item.is(ItemTags.VILLAGER_PLANTABLE_SEEDS) || this.clericWartFarmer && item.getItem() == net.minecraft.world.item.Items.NETHER_WART) && item.getItem() instanceof BlockItem blockItem) { // Purpur - Option for Villager Clerics to farm Nether Wart
|
||||
BlockState blockState1 = blockItem.getBlock().defaultBlockState();
|
||||
if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(owner, this.aboveFarmlandPos, blockState1)) { // CraftBukkit
|
||||
level.setBlockAndUpdate(this.aboveFarmlandPos, blockState1);
|
||||
@@ -136,7 +139,7 @@ public class HarvestFarmland extends Behavior<Villager> {
|
||||
this.aboveFarmlandPos.getX(),
|
||||
this.aboveFarmlandPos.getY(),
|
||||
this.aboveFarmlandPos.getZ(),
|
||||
- SoundEvents.CROP_PLANTED,
|
||||
+ this.clericWartFarmer ? SoundEvents.NETHER_WART_PLANTED : SoundEvents.CROP_PLANTED, // Purpur - Option for Villager Clerics to farm Nether Wart
|
||||
SoundSource.BLOCKS,
|
||||
1.0F,
|
||||
1.0F
|
||||
diff --git a/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java b/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java
|
||||
index 243ac036f95794e7766aefb4630b635681ae5a5f..4d8523a43d60cd6b4fd5546ffb3a61417b2c475b 100644
|
||||
--- a/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java
|
||||
@@ -59,6 +59,12 @@ public class TradeWithVillager extends Behavior<Villager> {
|
||||
throwHalfStack(owner, ImmutableSet.of(Items.WHEAT), villager);
|
||||
}
|
||||
|
||||
+ // Purpur start - Option for Villager Clerics to farm Nether Wart
|
||||
+ if (level.purpurConfig.villagerClericsFarmWarts && level.purpurConfig.villagerClericFarmersThrowWarts && owner.getVillagerData().getProfession() == VillagerProfession.CLERIC && owner.getInventory().countItem(Items.NETHER_WART) > Items.NETHER_WART.getDefaultMaxStackSize() / 2) {
|
||||
+ throwHalfStack(owner, ImmutableSet.of(Items.NETHER_WART), villager);
|
||||
+ }
|
||||
+ // Purpur end - Option for Villager Clerics to farm Nether Wart
|
||||
+
|
||||
if (!this.trades.isEmpty() && owner.getInventory().hasAnyOf(this.trades)) {
|
||||
throwHalfStack(owner, this.trades, villager);
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/ai/behavior/VillagerGoalPackages.java b/net/minecraft/world/entity/ai/behavior/VillagerGoalPackages.java
|
||||
index 84afd8646b05409c582f29d73f9fea4b09feb603..32779b121322688a4b14e460b1f902ef67770b32 100644
|
||||
--- a/net/minecraft/world/entity/ai/behavior/VillagerGoalPackages.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/VillagerGoalPackages.java
|
||||
@@ -74,8 +74,13 @@ public class VillagerGoalPackages {
|
||||
}
|
||||
|
||||
public static ImmutableList<Pair<Integer, ? extends BehaviorControl<? super Villager>>> getWorkPackage(VillagerProfession profession, float speedModifier) {
|
||||
+ // Purpur start - Option for Villager Clerics to farm Nether Wart
|
||||
+ return getWorkPackage(profession, speedModifier, false);
|
||||
+ }
|
||||
+ public static ImmutableList<Pair<Integer, ? extends BehaviorControl<? super Villager>>> getWorkPackage(VillagerProfession profession, float speedModifier, boolean clericsFarmWarts) {
|
||||
+ // Purpur end - Option for Villager Clerics to farm Nether Wart
|
||||
WorkAtPoi workAtPoi;
|
||||
- if (profession == VillagerProfession.FARMER) {
|
||||
+ if (profession == VillagerProfession.FARMER || (clericsFarmWarts && profession == VillagerProfession.CLERIC)) { // Purpur - Option for Villager Clerics to farm Nether Wart
|
||||
workAtPoi = new WorkAtComposter();
|
||||
} else {
|
||||
workAtPoi = new WorkAtPoi();
|
||||
diff --git a/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java b/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
|
||||
index 6b99afb4f237b5d6def98f3e03492975b795bc95..234e9d4aca14bc2a2e138918be1430516d710060 100644
|
||||
--- a/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
|
||||
+++ b/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java
|
||||
@@ -22,6 +22,13 @@ public class SecondaryPoiSensor extends Sensor<Villager> {
|
||||
|
||||
@Override
|
||||
protected void doTick(ServerLevel level, Villager entity) {
|
||||
+ // Purpur start - Option for Villager Clerics to farm Nether Wart - make sure clerics don't wander to soul sand when the option is off
|
||||
+ Brain<?> brain = entity.getBrain();
|
||||
+ if (!level.purpurConfig.villagerClericsFarmWarts && entity.getVillagerData().getProfession() == net.minecraft.world.entity.npc.VillagerProfession.CLERIC) {
|
||||
+ brain.eraseMemory(MemoryModuleType.SECONDARY_JOB_SITE);
|
||||
+ return;
|
||||
+ }
|
||||
+ // Purpur end - Option for Villager Clerics to farm Nether Wart
|
||||
ResourceKey<Level> resourceKey = level.dimension();
|
||||
BlockPos blockPos = entity.blockPosition();
|
||||
List<GlobalPos> list = Lists.newArrayList();
|
||||
@@ -38,7 +45,7 @@ public class SecondaryPoiSensor extends Sensor<Villager> {
|
||||
}
|
||||
}
|
||||
|
||||
- Brain<?> brain = entity.getBrain();
|
||||
+ //Brain<?> brain = entity.getBrain(); // Purpur - Option for Villager Clerics to farm Nether Wart - moved up
|
||||
if (!list.isEmpty()) {
|
||||
brain.setMemory(MemoryModuleType.SECONDARY_JOB_SITE, list);
|
||||
} else {
|
||||
diff --git a/net/minecraft/world/entity/npc/Villager.java b/net/minecraft/world/entity/npc/Villager.java
|
||||
index 4b5b04a5e65c4ab5e00564f88df5a938f9ca1811..8f6e530d5ae170765440c451d82b113345de7c74 100644
|
||||
--- a/net/minecraft/world/entity/npc/Villager.java
|
||||
+++ b/net/minecraft/world/entity/npc/Villager.java
|
||||
@@ -265,7 +265,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
villagerBrain.setSchedule(Schedule.VILLAGER_DEFAULT);
|
||||
villagerBrain.addActivityWithConditions(
|
||||
Activity.WORK,
|
||||
- VillagerGoalPackages.getWorkPackage(profession, 0.5F),
|
||||
+ VillagerGoalPackages.getWorkPackage(profession, 0.5F, this.level().purpurConfig.villagerClericsFarmWarts), // Purpur - Option for Villager Clerics to farm Nether Wart
|
||||
ImmutableSet.of(Pair.of(MemoryModuleType.JOB_SITE, MemoryStatus.VALUE_PRESENT))
|
||||
);
|
||||
}
|
||||
@@ -917,7 +917,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
}
|
||||
|
||||
public boolean hasFarmSeeds() {
|
||||
- return this.getInventory().hasAnyMatching(itemStack -> itemStack.is(ItemTags.VILLAGER_PLANTABLE_SEEDS));
|
||||
+ return this.getInventory().hasAnyMatching(itemStack -> this.level().purpurConfig.villagerClericsFarmWarts && this.getVillagerData().getProfession() == VillagerProfession.CLERIC ? itemStack.is(Items.NETHER_WART) : itemStack.is(ItemTags.VILLAGER_PLANTABLE_SEEDS)); // Purpur - Option for Villager Clerics to farm Nether Wart
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/net/minecraft/world/entity/npc/VillagerProfession.java b/net/minecraft/world/entity/npc/VillagerProfession.java
|
||||
index 1ec8ad124c76483d11057eb97fcfb9aebee0c301..f783d058a080408d572938d36ba031f33a08e9af 100644
|
||||
--- a/net/minecraft/world/entity/npc/VillagerProfession.java
|
||||
+++ b/net/minecraft/world/entity/npc/VillagerProfession.java
|
||||
@@ -31,7 +31,7 @@ public record VillagerProfession(
|
||||
public static final VillagerProfession ARMORER = register("armorer", PoiTypes.ARMORER, SoundEvents.VILLAGER_WORK_ARMORER);
|
||||
public static final VillagerProfession BUTCHER = register("butcher", PoiTypes.BUTCHER, SoundEvents.VILLAGER_WORK_BUTCHER);
|
||||
public static final VillagerProfession CARTOGRAPHER = register("cartographer", PoiTypes.CARTOGRAPHER, SoundEvents.VILLAGER_WORK_CARTOGRAPHER);
|
||||
- public static final VillagerProfession CLERIC = register("cleric", PoiTypes.CLERIC, SoundEvents.VILLAGER_WORK_CLERIC);
|
||||
+ public static final VillagerProfession CLERIC = register("cleric", PoiTypes.CLERIC, ImmutableSet.of(Items.NETHER_WART), ImmutableSet.of(Blocks.SOUL_SAND), SoundEvents.VILLAGER_WORK_CLERIC); // Purpur - Option for Villager Clerics to farm Nether Wart
|
||||
public static final VillagerProfession FARMER = register(
|
||||
"farmer",
|
||||
PoiTypes.FARMER,
|
||||
@@ -1911,6 +1911,8 @@ public class PurpurWorldConfig {
|
||||
public boolean villagerCanBeLeashed = false;
|
||||
public boolean villagerCanBreed = true;
|
||||
public int villagerBreedingTicks = 6000;
|
||||
public boolean villagerClericsFarmWarts = false;
|
||||
public boolean villagerClericFarmersThrowWarts = true;
|
||||
private void villagerSettings() {
|
||||
villagerRidable = getBoolean("mobs.villager.ridable", villagerRidable);
|
||||
villagerRidableInWater = getBoolean("mobs.villager.ridable-in-water", villagerRidableInWater);
|
||||
@@ -1927,6 +1929,8 @@ public class PurpurWorldConfig {
|
||||
villagerCanBeLeashed = getBoolean("mobs.villager.can-be-leashed", villagerCanBeLeashed);
|
||||
villagerCanBreed = getBoolean("mobs.villager.can-breed", villagerCanBreed);
|
||||
villagerBreedingTicks = getInt("mobs.villager.breeding-delay-ticks", villagerBreedingTicks);
|
||||
villagerClericsFarmWarts = getBoolean("mobs.villager.clerics-farm-warts", villagerClericsFarmWarts);
|
||||
villagerClericFarmersThrowWarts = getBoolean("mobs.villager.cleric-wart-farmers-throw-warts-at-villagers", villagerClericFarmersThrowWarts);
|
||||
}
|
||||
|
||||
public boolean vindicatorRidable = false;
|
||||
|
||||
Reference in New Issue
Block a user