mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 22:13:42 +01:00
ab347c4c96
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 42d5a714 SPIGOT-5899: Hoglins API similar to Piglins 2c1ee10e SPIGOT-5887: ClickType doesn't include off hand swaps 5ff7c7ce SPIGOT-5886: Missing BlockData CraftBukkit Changes:7560f5f5
SPIGOT-5905: Fix hex colours not being allowed in MOTDd47c47ee
SPIGOT-5889: Villager using composter should call EntityChangeBlockEvent2fe6b4a3
SPIGOT-5899: Hoglins API similar to Piglinse09dbeca
SPIGOT-5887: ClickType doesn't include off hand swaps23aac2a5
SPIGOT-5903: EntityDismountEvent cannot be triggered asynchronously92cbf656
SPIGOT-5884: Tab completions lost on reloadData / minecraft:reloadfb4e54ad
SPIGOT-5902: PlayerRespawnEvent places player at spawn before event is calledaa8f3d5a
SPIGOT-5901: Structures are generated in all worlds based on the setting for the main worlda0c35937
SPIGOT-5895: PlayerChangedWorldEvent#getFrom is incorrect89c0a5c3
SPIGOT-5886: Missing BlockData Spigot Changes: 0287a20d SPIGOT-5903: EntityDismountEvent cannot be triggered asynchronously
143 lines
7.3 KiB
Diff
143 lines
7.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Phoenix616 <mail@moep.tv>
|
|
Date: Sat, 1 Feb 2020 16:50:39 +0100
|
|
Subject: [PATCH] Pillager patrol spawn settings and per player options
|
|
|
|
This adds config options for defining the spawn chance, spawn delay and
|
|
spawn start day as well as toggles for handling the spawn delay and
|
|
start day per player. (Based on the time played statistic)
|
|
When not per player it will use the Vanilla mechanic of one delay per
|
|
world and the world age for the start day.
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
index f888fc1c5ef4212f81ed936da6485abadc336407..b987399ca3786a30f87c98658e8bf04d4aa2e2da 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
@@ -579,10 +579,21 @@ public class PaperWorldConfig {
|
|
}
|
|
|
|
public boolean disablePillagerPatrols = false;
|
|
+ public double patrolSpawnChance = 0.2;
|
|
+ public boolean patrolPerPlayerDelay = false;
|
|
+ public int patrolDelay = 12000;
|
|
+ public boolean patrolPerPlayerStart = false;
|
|
+ public int patrolStartDay = 5;
|
|
private void pillagerSettings() {
|
|
disablePillagerPatrols = getBoolean("game-mechanics.disable-pillager-patrols", disablePillagerPatrols);
|
|
+ patrolSpawnChance = getDouble("game-mechanics.pillager-patrols.spawn-chance", patrolSpawnChance);
|
|
+ patrolPerPlayerDelay = getBoolean("game-mechanics.pillager-patrols.spawn-delay.per-player", patrolPerPlayerDelay);
|
|
+ patrolDelay = getInt("game-mechanics.pillager-patrols.spawn-delay.ticks", patrolDelay);
|
|
+ patrolPerPlayerStart = getBoolean("game-mechanics.pillager-patrols.start.per-player", patrolPerPlayerStart);
|
|
+ patrolStartDay = getInt("game-mechanics.pillager-patrols.start.day", patrolStartDay);
|
|
}
|
|
|
|
+
|
|
public boolean entitiesTargetWithFollowRange = false;
|
|
private void entitiesTargetWithFollowRange() {
|
|
entitiesTargetWithFollowRange = getBoolean("entities-target-with-follow-range", entitiesTargetWithFollowRange);
|
|
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
index 2e902d7015dabad22d4ff6dfd79ed92255718651..7792ce6e94d25021666ef21da790f337d411234e 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
@@ -81,6 +81,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
|
public boolean viewingCredits;
|
|
private int containerUpdateDelay; // Paper
|
|
public long loginTime; // Paper
|
|
+ public int patrolSpawnDelay; // Paper - per player patrol spawns
|
|
// Paper start - cancellable death event
|
|
public boolean queueHealthUpdatePacket = false;
|
|
public net.minecraft.server.PacketPlayOutUpdateHealth queuedHealthUpdatePacket;
|
|
diff --git a/src/main/java/net/minecraft/server/MobSpawnerPatrol.java b/src/main/java/net/minecraft/server/MobSpawnerPatrol.java
|
|
index b1fea06d29a0c98136496d6eff81e6959cb73672..78029e10e6670936fb7dbedc7f34c5f8045fc291 100644
|
|
--- a/src/main/java/net/minecraft/server/MobSpawnerPatrol.java
|
|
+++ b/src/main/java/net/minecraft/server/MobSpawnerPatrol.java
|
|
@@ -4,13 +4,15 @@ import java.util.Random;
|
|
|
|
public class MobSpawnerPatrol implements MobSpawner {
|
|
|
|
+ private int getSpawnDelay() { return a; } // Paper - OBFHELPER
|
|
+ private void setSpawnDelay(int spawnDelay) { this.a = spawnDelay; } // Paper - OBFHELPER
|
|
private int a;
|
|
|
|
public MobSpawnerPatrol() {}
|
|
|
|
@Override
|
|
public int a(WorldServer worldserver, boolean flag, boolean flag1) {
|
|
- if (worldserver.paperConfig.disablePillagerPatrols) return 0; // Paper
|
|
+ if (worldserver.paperConfig.disablePillagerPatrols || worldserver.paperConfig.patrolSpawnChance == 0) return 0; // Paper
|
|
if (!flag) {
|
|
return 0;
|
|
} else if (!worldserver.getGameRules().getBoolean(GameRules.DO_PATROL_SPAWNING)) {
|
|
@@ -18,23 +20,51 @@ public class MobSpawnerPatrol implements MobSpawner {
|
|
} else {
|
|
Random random = worldserver.random;
|
|
|
|
- --this.a;
|
|
- if (this.a > 0) {
|
|
+ // Paper start - Patrol settings
|
|
+ // Random player selection moved up for per player spawning and configuration
|
|
+ int j = worldserver.getPlayers().size();
|
|
+ if (j < 1) {
|
|
return 0;
|
|
+ }
|
|
+
|
|
+ EntityPlayer entityhuman = worldserver.getPlayers().get(random.nextInt(j));
|
|
+ if (entityhuman.isSpectator()) {
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ int patrolSpawnDelay;
|
|
+ if (worldserver.paperConfig.patrolPerPlayerDelay) {
|
|
+ --entityhuman.patrolSpawnDelay;
|
|
+ patrolSpawnDelay = entityhuman.patrolSpawnDelay;
|
|
} else {
|
|
- this.a += 12000 + random.nextInt(1200);
|
|
- long i = worldserver.getDayTime() / 24000L;
|
|
+ setSpawnDelay(getSpawnDelay() - 1);
|
|
+ patrolSpawnDelay = getSpawnDelay();
|
|
+ }
|
|
+
|
|
+ if (patrolSpawnDelay > 0) {
|
|
+ return 0;
|
|
+ } else {
|
|
+ long days;
|
|
+ if (worldserver.paperConfig.patrolPerPlayerStart) {
|
|
+ days = entityhuman.getStatisticManager().getStatisticValue(StatisticList.CUSTOM.get(StatisticList.PLAY_ONE_MINUTE)) / 24000L; // PLAY_ONE_MINUTE is actually counting in ticks, a misnomer by Mojang
|
|
+ } else {
|
|
+ days = worldserver.getDayTime() / 24000L;
|
|
+ }
|
|
+ if (worldserver.paperConfig.patrolPerPlayerDelay) {
|
|
+ entityhuman.patrolSpawnDelay += worldserver.paperConfig.patrolDelay + random.nextInt(1200);
|
|
+ } else {
|
|
+ setSpawnDelay(getSpawnDelay() + worldserver.paperConfig.patrolDelay + random.nextInt(1200));
|
|
+ }
|
|
|
|
- if (i >= 5L && worldserver.isDay()) {
|
|
- if (random.nextInt(5) != 0) {
|
|
+ if (days >= worldserver.paperConfig.patrolStartDay && worldserver.isDay()) {
|
|
+ if (random.nextDouble() >= worldserver.paperConfig.patrolSpawnChance) {
|
|
+ // Paper end
|
|
return 0;
|
|
} else {
|
|
- int j = worldserver.getPlayers().size();
|
|
|
|
if (j < 1) {
|
|
return 0;
|
|
} else {
|
|
- EntityHuman entityhuman = (EntityHuman) worldserver.getPlayers().get(random.nextInt(j));
|
|
|
|
if (entityhuman.isSpectator()) {
|
|
return 0;
|
|
diff --git a/src/main/java/net/minecraft/server/StatisticWrapper.java b/src/main/java/net/minecraft/server/StatisticWrapper.java
|
|
index 3b6034038a4841ebc980b2392c71025d9b0dde35..9c95c0ccfcdc11d8b8bc60986365e76ca0821c68 100644
|
|
--- a/src/main/java/net/minecraft/server/StatisticWrapper.java
|
|
+++ b/src/main/java/net/minecraft/server/StatisticWrapper.java
|
|
@@ -27,6 +27,7 @@ public class StatisticWrapper<T> implements Iterable<Statistic<T>> {
|
|
return this.b.values().iterator();
|
|
}
|
|
|
|
+ public Statistic<T> get(T t) { return this.b(t); }; // Paper - OBFHELPER
|
|
public Statistic<T> b(T t0) {
|
|
return this.a(t0, Counter.DEFAULT);
|
|
}
|