9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-22 16:29:23 +00:00
Files
DivineMC/patches/server/0032-Despawn-shulker-bullets-on-owner-death.patch
2024-06-17 17:24:01 +03:00

43 lines
2.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Sat, 10 Jun 2023 13:12:59 +0300
Subject: [PATCH] Despawn shulker bullets on owner death
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 7fde1807640d0b02d417f48f1f6758f8ae32e04b..8cbe6ad4277c255f6087e7734008d65d15b1a0da 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/ShulkerBullet.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/ShulkerBullet.java
@@ -226,6 +226,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) {
diff --git a/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java b/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java
index e1274fe3b0ff369d1f6f229026ced2e03ea335ca..7e62ee9418d5add5b0b4ddb885d3a1745ce799b2 100644
--- a/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java
+++ b/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java
@@ -89,4 +89,9 @@ public class DivineWorldConfig {
dontEjectPlayerFromBoatUnderwater = getBoolean("gameplay-mechanics.boat.dont-eject-players-from-boat-underwater", dontEjectPlayerFromBoatUnderwater);
alwaysAllowToEnterTheBoat = getBoolean("gameplay-mechanics.boat.always-allow-to-enter-the-boat", alwaysAllowToEnterTheBoat);
}
+
+ public boolean despawnShulkerBulletsOnOwnerDeath = true;
+ private void despawnShulkerBulletsOnOwnerDeath() {
+ despawnShulkerBulletsOnOwnerDeath = getBoolean("gameplay-mechanics.mob.shulker.despawn-bullets-on-player-death", despawnShulkerBulletsOnOwnerDeath);
+ }
}