mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-09-19 19:11:39 +02:00
22be9f2d6f
* Updated Upstream and Sidestream(s) (Paper/Purpur/Origami) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 2299159bb Add option to fix items merging through blocks (#5334) d8c20ddc7 Fix PlayerBucketEmptyEvent result itemstack (#5698) ceb3762fb Add PufferFishStateChangeEvent (#5606) cd4defec0 [CI-SKIP] Update version checker to use V2 downloads API (#5728) b9f2a673d Limit item frame cursors on maps (#5730) 81a537c1f Add PlayerKickEvent causes (#5648) b7976b956 Add More Lidded Block API (#5707) Purpur Changes: b88aef3a Fix Paper#4748 - Shulkerbox allow oversized stacks 9fec1bae Updated Upstream (Paper) 2aacc766 Update Toothpick to 1.1.0-SNAPSHOT a08d7470 Configurable anvil cumulative cost (#352) Origami Changes: 3b8adab Fix importing of classes not working if their directory doesn't exist * Updated Upstream and Sidestream(s) (Paper/Tuinity/Purpur/Empirecraft/Origami) Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Paper Changes: 525d0e3d3 fix beacon activate/deactivate events (#5646) e403d6aaf [Auto] Updated Upstream (CraftBukkit) 6bcd8b57c Updated Upstream (CraftBukkit) (#5742) 501cc9448 Reset villager inventory on cancelled pickup event (#5738) 3f72a549b Exit with non-zero exit code when killed by watchdog (#5732) a8d7ad099 Updated Upstream (Bukkit/CraftBukkit) (#5735) Tuinity Changes: e9c8348 Revert entity ticking chunk map for tracker Purpur Changes: 687936be Updated Upstream (Paper) 4c2d7e56 Fix advancement triggers on entity death 49a0fb90 Fix oversized shulker box dupe e92d259e Fix raid captains not giving voluntary exile advancement a97fdc48 Config to broadcast the death message to the affected player (#363) 9bf8e165 Add burn in daylight API for LivingEntity (#331) 96460068 Fix dupe bug caused by SPIGOT-6452 2618c24f Revert "allow disabling offline mode message on an ONLINE MODE proxy" aa79fa5c allow disabling offline mode message on an ONLINE MODE proxy 830141ca Bee can work when raining or at night (#365) ae6ca468 Updated Upstream (Paper) d99cc6e8 [ci-skip] Add better issue templates (#360) Empirecraft Changes: 12009c31 Updated Paper 5305540d Updated Paper 1043bd94 Revert "Call EntityPickupItemEvent for villagers" CB commit 820b9bdf Updated Paper Origami Changes: 64fba4f Fix importing of classes not working if their directory doesn't exist 3b8adab Fix importing of classes not working if their directory doesn't exist * rebuild Patches
171 lines
10 KiB
Diff
171 lines
10 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: tr7zw <tr7zw@live.de>
|
|
Date: Fri, 31 Jul 2020 21:58:24 -0500
|
|
Subject: [PATCH] Option for simpler Villagers
|
|
|
|
|
|
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 e042af3f78a25587ba14d5fd9e346805dd5f1e85..53916eb31f9b5699c56bbe466ba46834149a8f08 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
|
|
@@ -103,6 +103,7 @@ import org.bukkit.event.entity.VillagerReplenishTradeEvent;
|
|
|
|
public class EntityVillager extends EntityVillagerAbstract implements ReputationHandler, VillagerDataHolder {
|
|
|
|
+ private boolean simplerVillagerBehavior = org.yatopiamc.yatopia.server.YatopiaConfig.simplerVillagerBehavior; // Yatopia - so we don't make them bork upon reload
|
|
private static final DataWatcherObject<VillagerData> br = DataWatcher.a(EntityVillager.class, DataWatcherRegistry.q);
|
|
public static final Map<Item, Integer> bp = ImmutableMap.of(Items.BREAD, 4, Items.POTATO, 1, Items.CARROT, 1, Items.BEETROOT, 1);
|
|
private static final Set<Item> bs = ImmutableSet.of(Items.BREAD, Items.POTATO, Items.CARROT, Items.WHEAT, Items.WHEAT_SEEDS, Items.BEETROOT, new Item[]{Items.BEETROOT_SEEDS});
|
|
@@ -139,8 +140,14 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
|
|
public EntityVillager(EntityTypes<? extends EntityVillager> entitytypes, World world, VillagerType villagertype) {
|
|
super(entitytypes, world);
|
|
this.by = new Reputation();
|
|
+ if (!simplerVillagerBehavior) {
|
|
((Navigation) this.getNavigation()).a(true);
|
|
this.getNavigation().d(true);
|
|
+ // Yatopia start
|
|
+ } else {
|
|
+ initPathfinder();
|
|
+ }
|
|
+ // Yatopia end
|
|
this.setCanPickupLoot(true);
|
|
this.setVillagerData(this.getVillagerData().withType(villagertype).withProfession(VillagerProfession.NONE));
|
|
this.brainTickOffset = getRandom().nextInt(100); // Purpur
|
|
@@ -161,6 +168,38 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
|
|
protected void initPathfinder() {
|
|
this.goalSelector.a(0, new PathfinderGoalHasRider(this)); // Purpur
|
|
if (world.purpurConfig.villagerFollowEmeraldBlock) this.goalSelector.a(3, new PathfinderGoalTempt(this, 1.0D, false, TEMPT_ITEMS));
|
|
+ // Yatopia Start
|
|
+ if (!simplerVillagerBehavior) {
|
|
+ // safety
|
|
+ return;
|
|
+ }
|
|
+ this.goalSelector.a(0, new net.minecraft.world.entity.ai.goal.PathfinderGoalFloat(this));
|
|
+ if (org.yatopiamc.yatopia.server.YatopiaConfig.villagersHideAtNight) {
|
|
+ this.goalSelector.a(0, new net.minecraft.world.entity.ai.goal.PathfinderGoalUseItem<>(this, net.minecraft.world.item.alchemy.PotionUtil.a(new ItemStack(Items.POTION), net.minecraft.world.item.alchemy.Potions.INVISIBILITY), SoundEffects.ENTITY_WANDERING_TRADER_DISAPPEARED, (entityvillagertrader) -> {
|
|
+ return !this.world.isDay() && !entityvillagertrader.isInvisible();
|
|
+ }));
|
|
+ this.goalSelector.a(0, new net.minecraft.world.entity.ai.goal.PathfinderGoalUseItem<>(this, new ItemStack(Items.MILK_BUCKET), SoundEffects.ENTITY_WANDERING_TRADER_REAPPEARED, (entityvillagertrader) -> {
|
|
+ return this.world.isDay() && entityvillagertrader.isInvisible();
|
|
+ }));
|
|
+ }
|
|
+ this.goalSelector.a(1, new net.minecraft.world.entity.ai.goal.PathfinderGoalTradeWithPlayer(this));
|
|
+ this.goalSelector.a(1, new net.minecraft.world.entity.ai.goal.PathfinderGoalAvoidTarget<>(this, net.minecraft.world.entity.monster.EntityZombie.class, 8.0F, 0.5D, 0.5D));
|
|
+ this.goalSelector.a(1, new net.minecraft.world.entity.ai.goal.PathfinderGoalAvoidTarget<>(this, net.minecraft.world.entity.monster.EntityEvoker.class, 12.0F, 0.5D, 0.5D));
|
|
+ this.goalSelector.a(1, new net.minecraft.world.entity.ai.goal.PathfinderGoalAvoidTarget<>(this, net.minecraft.world.entity.monster.EntityVindicator.class, 8.0F, 0.5D, 0.5D));
|
|
+ this.goalSelector.a(1, new net.minecraft.world.entity.ai.goal.PathfinderGoalAvoidTarget<>(this, net.minecraft.world.entity.monster.EntityVex.class, 8.0F, 0.5D, 0.5D));
|
|
+ this.goalSelector.a(1, new net.minecraft.world.entity.ai.goal.PathfinderGoalAvoidTarget<>(this, net.minecraft.world.entity.monster.EntityPillager.class, 15.0F, 0.5D, 0.5D));
|
|
+ this.goalSelector.a(1, new net.minecraft.world.entity.ai.goal.PathfinderGoalAvoidTarget<>(this, net.minecraft.world.entity.monster.EntityIllagerIllusioner.class, 12.0F, 0.5D, 0.5D));
|
|
+ this.goalSelector.a(1, new net.minecraft.world.entity.ai.goal.PathfinderGoalPanic(this, 0.5D));
|
|
+ this.goalSelector.a(1, new net.minecraft.world.entity.ai.goal.PathfinderGoalLookAtTradingPlayer(this));
|
|
+ this.goalSelector.a(2, new net.minecraft.world.entity.ai.goal.PathfinderGoalStrollVillageGolem(this, 0.6D));
|
|
+ this.goalSelector.a(3, new net.minecraft.world.entity.ai.goal.PathfinderGoalMoveThroughVillage(this, 0.6D, false, 4, () -> {
|
|
+ return false;
|
|
+ }));
|
|
+ this.goalSelector.a(4, new net.minecraft.world.entity.ai.goal.PathfinderGoalMoveTowardsRestriction(this, 0.35D));
|
|
+ this.goalSelector.a(8, new net.minecraft.world.entity.ai.goal.PathfinderGoalRandomStrollLand(this, 0.35D));
|
|
+ this.goalSelector.a(9, new net.minecraft.world.entity.ai.goal.PathfinderGoalInteract(this, EntityHuman.class, 3.0F, 1.0F));
|
|
+ this.goalSelector.a(10, new net.minecraft.world.entity.ai.goal.PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F));
|
|
+ // Yatopia End
|
|
}
|
|
|
|
@Override
|
|
@@ -186,6 +225,7 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
|
|
|
|
@Override
|
|
protected BehaviorController<?> a(Dynamic<?> dynamic) {
|
|
+ if (simplerVillagerBehavior) return super.a(dynamic); // Yatopia
|
|
BehaviorController<EntityVillager> behaviorcontroller = this.cK().a(dynamic);
|
|
|
|
this.a(behaviorcontroller);
|
|
@@ -265,6 +305,27 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
|
|
// Spigot End
|
|
|
|
private int behaviorTick = 0;
|
|
+ // Yatopia start
|
|
+ private VillagerProfession getRandomProfession() {
|
|
+ int type = random.nextInt(13);
|
|
+ switch(type) {
|
|
+ case 0: return VillagerProfession.ARMORER;
|
|
+ case 1: return VillagerProfession.BUTCHER;
|
|
+ case 2: return VillagerProfession.CARTOGRAPHER;
|
|
+ case 3: return VillagerProfession.CLERIC;
|
|
+ case 4: return VillagerProfession.FARMER;
|
|
+ case 5: return VillagerProfession.FISHERMAN;
|
|
+ case 6: return VillagerProfession.FLETCHER;
|
|
+ case 7: return VillagerProfession.LEATHERWORKER;
|
|
+ case 8: return VillagerProfession.LIBRARIAN;
|
|
+ case 9: return VillagerProfession.MASON;
|
|
+ case 10: return VillagerProfession.SHEPHERD;
|
|
+ case 11: return VillagerProfession.TOOLSMITH;
|
|
+ case 12: return VillagerProfession.WEAPONSMITH;
|
|
+ default: return VillagerProfession.FARMER;
|
|
+ }
|
|
+ }
|
|
+ // Yatopia end
|
|
|
|
// Purpur start
|
|
boolean lobotomized = false;
|
|
@@ -290,6 +351,13 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
|
|
protected void mobTick() { mobTick(false); }
|
|
protected void mobTick(boolean inactive) {
|
|
this.world.getMethodProfiler().enter("villagerBrain");
|
|
+ // Yatopia start
|
|
+ if (simplerVillagerBehavior && this.getVillagerData().getProfession() == VillagerProfession.NONE) {
|
|
+ this.setVillagerData(this.getVillagerData().withProfession(getRandomProfession()));
|
|
+ }
|
|
+ if (simplerVillagerBehavior && canRefresh()) restUses();
|
|
+ if (simplerVillagerBehavior) return;
|
|
+ // Yatopia end
|
|
// Purpur start
|
|
if (world.purpurConfig.villagerLobotomizeEnabled) inactive = inactive || isLobotomized();
|
|
boolean tick = (world.getTime() + brainTickOffset) % world.purpurConfig.villagerBrainTicks == 0;
|
|
@@ -416,6 +484,7 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
|
|
this.fl();
|
|
}
|
|
|
|
+ public final boolean canRefresh() { return fc(); } // Yatopia - OBFHELPER
|
|
private void fl() {
|
|
Iterator iterator = this.getOffers().iterator();
|
|
|
|
@@ -490,6 +559,7 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
|
|
return this.fn() && this.fm();
|
|
}
|
|
|
|
+ public final void restUses() { fo(); } // Yatopia - OBFHELPER
|
|
private void fo() {
|
|
int i = 2 - this.bD;
|
|
|
|
@@ -722,6 +792,7 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
|
|
}
|
|
|
|
private void a(Entity entity) {
|
|
+ if (simplerVillagerBehavior) return; // Yatopia
|
|
if (this.world instanceof WorldServer) {
|
|
Optional<List<EntityLiving>> optional = this.bg.getMemory(MemoryModuleType.VISIBLE_MOBS);
|
|
|
|
@@ -738,6 +809,7 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
|
|
}
|
|
|
|
public void a(MemoryModuleType<GlobalPos> memorymoduletype) {
|
|
+ if (simplerVillagerBehavior) return;
|
|
if (this.world instanceof WorldServer) {
|
|
MinecraftServer minecraftserver = ((WorldServer) this.world).getMinecraftServer();
|
|
|
|
diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
|
|
index 4722a170519dfebc7b41ce886563a3b80c8e111b..f318508a4c2a6376b00d55886f313fd4e007c14f 100644
|
|
--- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
|
|
+++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
|
|
@@ -194,4 +194,11 @@ public class YatopiaConfig {
|
|
private static void itemStuckSleepTicks() {
|
|
itemStuckSleepTicks = getInt("settings.itemStuckSleepTicks", 1);
|
|
}
|
|
+
|
|
+ public static boolean simplerVillagerBehavior = false;
|
|
+ public static boolean villagersHideAtNight = false;
|
|
+ private static void villagerSettings() {
|
|
+ simplerVillagerBehavior = getBoolean("settings.villager.simplerVillagerBehavior", false);
|
|
+ villagersHideAtNight = getBoolean("settings.villager.villagersHideAtNight", false);
|
|
+ }
|
|
}
|