Skip to content

Commit

Permalink
fix(neo): call living destruct on player death
Browse files Browse the repository at this point in the history
  • Loading branch information
gabizou committed Jan 13, 2025
1 parent 9508f6f commit 10a349e
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
38 changes: 38 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3445,6 +3445,14 @@
<sha256 value="09c47d508f2c59006156974b5bc415beb8e522fc61b6d72c9c8c4e348363c303" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="net.neoforged" name="bus" version="8.0.2">
<artifact name="bus-8.0.2.jar">
<sha256 value="7ae71dcb9225f3593dca618a668add22b3a1b3f010fdcd746fcb31c3f6d57969" origin="Generated by Gradle"/>
</artifact>
<artifact name="bus-8.0.2.pom">
<sha256 value="8992eca3b03081167e58301a2dc988d333843c901ebd84e0fc99dc34c0773af0" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="net.neoforged" name="coremods" version="7.0.3">
<artifact name="coremods-7.0.3.jar">
<sha256 value="d24c0d3e31af23cac36a0f9f98654b875f678b27ddccd8b28d331c1878a6de4a" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -3478,6 +3486,20 @@
<sha256 value="2057512b060091504949b393a1efc6c0850bd402710b2d68627383ec874726e9" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="net.neoforged" name="neoforge" version="21.1.93">
<artifact name="neoforge-21.1.93-installer.jar">
<sha256 value="a79dea79887e6e53a7bd57cc9584777f3a66747d28767cfeb6947a4c190066ab" origin="Generated by Gradle"/>
</artifact>
<artifact name="neoforge-21.1.93-universal.jar">
<sha256 value="bb97bbada7ede4d1a2306ca2dfb7660e10d0270e86e3609964f94830e4b0e957" origin="Generated by Gradle"/>
</artifact>
<artifact name="neoforge-21.1.93-userdev.jar">
<sha256 value="597f844ca324414697d73672d1d89c076d82587ff35be1385440d818e9c96fe3" origin="Generated by Gradle"/>
</artifact>
<artifact name="neoforge-21.1.93.module">
<sha256 value="3f2900a3b17f04a99086977335a4b036830f0d5d9d1e75730d227df10f5566d3" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="net.neoforged" name="neoform" version="1.21.1-20240808.144430">
<artifact name="neoform-1.21.1-20240808.144430.module">
<sha256 value="c697a0da4423ac17b9a5f891782a4bfd65143a39a3773de43cb54c67ba7d5747" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -3510,6 +3532,14 @@
<sha256 value="7758a8c6d5ca5e253646c831926c9b1c47dc289715c4b2e3f4105124baac50b6" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="net.neoforged.fancymodloader" name="earlydisplay" version="4.0.34">
<artifact name="earlydisplay-4.0.34.jar">
<sha256 value="a624954eac7581685d8222764982027a34463664c836aa248a4358043e93f971" origin="Generated by Gradle"/>
</artifact>
<artifact name="earlydisplay-4.0.34.module">
<sha256 value="8f15e91225c306a28c7c1eb8b7ee6ba5c3777737d0b70ed2899f3cfbe1a6c151" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="net.neoforged.fancymodloader" name="loader" version="4.0.24">
<artifact name="loader-4.0.24.jar">
<sha256 value="c76d1e7c27b40dcb4ba9f376766a95845647dff21f5e3a77d32858461f109ca1" origin="Generated by Gradle"/>
Expand All @@ -3518,6 +3548,14 @@
<sha256 value="e6a8d8953dca6209b1aaad4eb3e7bc420f18218ad312223fd420df91bd511094" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="net.neoforged.fancymodloader" name="loader" version="4.0.34">
<artifact name="loader-4.0.34.jar">
<sha256 value="c1c4e40edbe1f981374f14024cc36156bce333e5a283939dce23d5bf91dabd1a" origin="Generated by Gradle"/>
</artifact>
<artifact name="loader-4.0.34.module">
<sha256 value="ba034221fe97287fabdbc74317b83b0dfea1c2154ee25f4d1042860d78168720" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="net.neoforged.installertools" name="installertools" version="2.1.2">
<artifact name="installertools-2.1.2-fatjar.jar">
<sha256 value="9fe7c6df17299f661b9cd07fc1c4e85493b63efae6bb9da0255a97d9d0a87c60" origin="Generated by Gradle"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,16 @@
*/
package org.spongepowered.neoforge.hook;

import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.damagesource.DamageSource;
import net.neoforged.neoforge.common.CommonHooks;
import org.spongepowered.common.hooks.EventHooks;

public final class NeoEventHooks implements EventHooks {

@Override
public boolean callPlayerDestruction(ServerPlayer serverPlayer, DamageSource cause) {
return CommonHooks.onLivingDeath(serverPlayer, cause);
}

}
10 changes: 8 additions & 2 deletions src/main/java/org/spongepowered/common/hooks/EventHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
package org.spongepowered.common.hooks;

import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import org.spongepowered.api.event.SpongeEventFactory;
import org.spongepowered.api.event.entity.ChangeEntityWorldEvent;
Expand All @@ -39,9 +41,13 @@ public interface EventHooks {

default ChangeEntityWorldEvent.Pre callChangeEntityWorldEventPre(final Entity entity, final ServerLevel toWorld) {
final ChangeEntityWorldEvent.Pre event = SpongeEventFactory.createChangeEntityWorldEventPre(PhaseTracker.getCauseStackManager().currentCause(),
(org.spongepowered.api.entity.Entity) entity, (org.spongepowered.api.world.server.ServerWorld) entity.getCommandSenderWorld(),
(org.spongepowered.api.world.server.ServerWorld) toWorld, (org.spongepowered.api.world.server.ServerWorld) toWorld);
(org.spongepowered.api.entity.Entity) entity, (org.spongepowered.api.world.server.ServerWorld) entity.getCommandSenderWorld(),
(org.spongepowered.api.world.server.ServerWorld) toWorld, (org.spongepowered.api.world.server.ServerWorld) toWorld);
SpongeCommon.post(event);
return event;
}

default boolean callPlayerDestruction(ServerPlayer serverPlayer, DamageSource cause) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,9 @@ public void teleportTo(final ServerLevel world, final double x, final double y,
@Overwrite
public void die(final DamageSource cause) {
// Sponge start - Call Destruct Death Event
if (!PlatformHooks.INSTANCE.getEventHooks().callPlayerDestruction((net.minecraft.server.level.ServerPlayer) (Object) this, cause)) {
return;
}
final DestructEntityEvent.Death event = SpongeCommonEventFactory.callDestructEntityEventDeath((net.minecraft.server.level.ServerPlayer) (Object) this, cause,
Audiences.server());
if (event.isCancelled()) {
Expand Down

0 comments on commit 10a349e

Please sign in to comment.