9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-22 16:29:23 +00:00
Files
DivineMC/patches/server/0025-Despawn-shulker-bullets-on-owner-death.patch
2023-04-04 22:43:29 +03:00

44 lines
2.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Tue, 4 Apr 2023 22:40:31 +0300
Subject: [PATCH] Despawn shulker bullets on owner death
diff --git a/src/main/java/gq/bxteam/divinemc/configuration/DivineWorldConfig.java b/src/main/java/gq/bxteam/divinemc/configuration/DivineWorldConfig.java
index ee19959e3401ac1e4cf859114f927d2521e48fd0..7328d7daa1e411ce492ffedc4e22162b0a4b2253 100644
--- a/src/main/java/gq/bxteam/divinemc/configuration/DivineWorldConfig.java
+++ b/src/main/java/gq/bxteam/divinemc/configuration/DivineWorldConfig.java
@@ -89,4 +89,9 @@ public class DivineWorldConfig {
private void enableBetterImpaling() {
enableBetterImpaling = getBoolean("gameplay-mechanics.tools.trident.better-impaling", enableBetterImpaling);
}
+
+ public boolean despawnShulkerBulletsOnOwnerDeath = true;
+ private void despawnShulkerBulletsOnOwnerDeath() {
+ despawnShulkerBulletsOnOwnerDeath = getBoolean("gameplay-mechanics.mob.shulker.despawn-bullets-on-player-death", despawnShulkerBulletsOnOwnerDeath);
+ }
}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ShulkerBullet.java b/src/main/java/net/minecraft/world/entity/projectile/ShulkerBullet.java
index 113ab29ba7adbb40f61eb0cfbda23ada7ef1305d..0f2bc9f977895c5d75b8dd6f625e49472b2d3ce7 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/ShulkerBullet.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/ShulkerBullet.java
@@ -218,6 +218,17 @@ public class ShulkerBullet extends Projectile {
Vec3 vec3d;
if (!this.level.isClientSide) {
+ // DivineMC start - despawn shulker bullets on owner death
+ if (this.level.divinemcConfig.despawnShulkerBulletsOnOwnerDeath) {
+ if (!isInvulnerable()) {
+ var owner = getOwner();
+ if (owner == null || !owner.isAlive()) {
+ discard();
+ return;
+ }
+ }
+ }
+ // DivineMC end
if (this.finalTarget == null && this.targetId != null) {
this.finalTarget = ((ServerLevel) this.level).getEntity(this.targetId);
if (this.finalTarget == null) {