9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-28 03:09:11 +00:00
Files
DivineMC/patches/server/0015-Despawn-shulker-bullets-on-owner-death.patch
2023-06-16 01:22:06 +03:00

44 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/gq/bxteam/divinemc/configuration/DivineWorldConfig.java b/src/main/java/gq/bxteam/divinemc/configuration/DivineWorldConfig.java
index 9eede8eb7fefc414f3a1207cd3ca2b33deb5ea13..ca344da743a7503795bdaeff0a1b14e0721f5092 100644
--- a/src/main/java/gq/bxteam/divinemc/configuration/DivineWorldConfig.java
+++ b/src/main/java/gq/bxteam/divinemc/configuration/DivineWorldConfig.java
@@ -84,4 +84,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);
+ }
}
\ 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 a38c02af71e0eca2d727342b31a2118d107cfb63..aef2cd823e6672395e365673cc83d2c39819d4ae 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) {