mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@b4192fd fix NPE from changes in e4358b82171 PaperMC/Paper@5b6445a Revert "fix NPE from changes in e4358b82171" PaperMC/Paper@323c087 Revert "#686: Fix contains for default section generating real sections" PaperMC/Paper@c837002 Fix client world difficulty sync issue (#7035) PaperMC/Paper@a4782f7 [ci skip] fixup indent PaperMC/Paper@83aee0f [ci skip] Clarify setSize consequences for Slimes (#7036) PaperMC/Paper@7c8fdc1 Add dropped hunk from mid-tick tasks (#7034) PaperMC/Paper@fd263ef Fix empty/null chunk section check in LevelChunk#getBlockData, rename… (#7039) PaperMC/Paper@b8d486c Create workflow to add new PRs to the PR Queue project (#6918) PaperMC/Paper@a50e273 Include axolotls in affected entities for water splash potions (#7024) PaperMC/Paper@af95df8 Port Actually unload POI data from Tuinity 1.16 (#7044) PaperMC/Paper@04897b1 [ci skip] Revert "Create workflow to add new PRs to the PR Queue project (#6918)" (#7046) PaperMC/Paper@b4a77a8 Updated Upstream (Bukkit/CraftBukkit) (#7045) PaperMC/Paper@0e25db2 Fix mis-placed processEnchantOrder from 1.18 update (#7052) PaperMC/Paper@53d026e Fix unused EntitySectionStorage#getEntities(AABB, Consumer) method being broken PaperMC/Paper@772e880 Fix light propagation in high y sections PaperMC/Paper@33ea869 Bump Starlight light version PaperMC/Paper@74fd151 Fix entity equipment on cancellation of EntityDeathEvent (#5740) PaperMC/Paper@758e2a7 Fix bad ticking checks for blocks PaperMC/Paper@0e91b6a Return 0 for light values if a dimenion does not have them PaperMC/Paper@188a8df Fix ChunkSnapshot#isSectionEmpty(int) PaperMC/Paper@bbc7451 Fix issue with snapshotted biomes in last commit PaperMC/Paper@b475c6a Backport log4j fix PaperMC/Paper@4e355c4 Updated Upstream (CraftBukkit) PaperMC/Paper@dce79f3 Update Log4J (#7069)
107 lines
4.1 KiB
Diff
107 lines
4.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Sat, 11 Jul 2020 19:41:34 -0500
|
|
Subject: [PATCH] Entity lifespan
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
|
index 3249ea9a4b7dc05a1b53373955c267e7a4c7903b..78f7022c6584e634b000cc0c079112fc6cc8e869 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
|
@@ -129,6 +129,7 @@ public abstract class Mob extends LivingEntity {
|
|
private BlockPos restrictCenter;
|
|
private float restrictRadius;
|
|
|
|
+ public int ticksSinceLastInteraction; // Purpur
|
|
public boolean aware = true; // CraftBukkit
|
|
|
|
protected Mob(EntityType<? extends Mob> type, Level world) {
|
|
@@ -286,6 +287,7 @@ public abstract class Mob extends LivingEntity {
|
|
entityliving = null;
|
|
}
|
|
}
|
|
+ if (entityliving instanceof ServerPlayer) this.ticksSinceLastInteraction = 0; // Purpur
|
|
this.target = entityliving;
|
|
return true;
|
|
// CraftBukkit end
|
|
@@ -330,9 +332,35 @@ public abstract class Mob extends LivingEntity {
|
|
this.playAmbientSound();
|
|
}
|
|
|
|
+ incrementTicksSinceLastInteraction();
|
|
this.level.getProfiler().pop();
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ private void incrementTicksSinceLastInteraction() {
|
|
+ ++ticksSinceLastInteraction;
|
|
+ //if (hasRider()) {
|
|
+ // ticksSinceLastInteraction = 0;
|
|
+ // return;
|
|
+ //}
|
|
+ if (level.purpurConfig.entityLifeSpan <= 0) {
|
|
+ return; // feature disabled
|
|
+ }
|
|
+ if (!this.removeWhenFarAway(0) || isPersistenceRequired() || requiresCustomPersistence() || hasCustomName()) {
|
|
+ return; // mob persistent
|
|
+ }
|
|
+ if (ticksSinceLastInteraction > level.purpurConfig.entityLifeSpan) {
|
|
+ this.discard();
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean hurt(DamageSource source, float amount) {
|
|
+ if (source.getEntity() instanceof ServerPlayer) this.ticksSinceLastInteraction = 0; // Purpur
|
|
+ return super.hurt(source, amount);
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
@Override
|
|
protected void playHurtSound(DamageSource source) {
|
|
this.resetAmbientSoundTime();
|
|
@@ -516,6 +544,7 @@ public abstract class Mob extends LivingEntity {
|
|
}
|
|
|
|
nbt.putBoolean("Bukkit.Aware", this.aware); // CraftBukkit
|
|
+ nbt.putInt("Purpur.ticksSinceLastInteraction", ticksSinceLastInteraction); // Purpur
|
|
}
|
|
|
|
@Override
|
|
@@ -586,6 +615,11 @@ public abstract class Mob extends LivingEntity {
|
|
this.aware = nbt.getBoolean("Bukkit.Aware");
|
|
}
|
|
// CraftBukkit end
|
|
+ // Purpur start
|
|
+ if (nbt.contains("Purpur.ticksSinceLastInteraction")) {
|
|
+ ticksSinceLastInteraction = nbt.getInt("Purpur.ticksSinceLastInteraction");
|
|
+ }
|
|
+ // Purpur end
|
|
}
|
|
|
|
@Override
|
|
@@ -1607,6 +1641,7 @@ public abstract class Mob extends LivingEntity {
|
|
this.setLastHurtMob(target);
|
|
}
|
|
|
|
+ if (target instanceof ServerPlayer) this.ticksSinceLastInteraction = 0; // Purpur
|
|
return flag;
|
|
}
|
|
|
|
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
index 3e58c569253c0162e506c07527bf7306c88ff8c1..971fef23a4381221164834e2c8f30aaf7ee7cd45 100644
|
|
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
@@ -112,6 +112,11 @@ public class PurpurWorldConfig {
|
|
elytraDamagePerTridentBoost = getInt("gameplay-mechanics.elytra.damage-per-boost.trident", elytraDamagePerTridentBoost);
|
|
}
|
|
|
|
+ public int entityLifeSpan = 0;
|
|
+ private void entitySettings() {
|
|
+ entityLifeSpan = getInt("gameplay-mechanics.entity-lifespan", entityLifeSpan);
|
|
+ }
|
|
+
|
|
public List<Item> itemImmuneToCactus = new ArrayList<>();
|
|
public List<Item> itemImmuneToExplosion = new ArrayList<>();
|
|
public List<Item> itemImmuneToFire = new ArrayList<>();
|