-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(idk maybe priorities will be more consistant now) Now the fabric and neoforge versions have the same death handling entry
- Loading branch information
Showing
3 changed files
with
31 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/com/b1n_ry/yigd/mixin/LivingEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.b1n_ry.yigd.mixin; | ||
|
||
import com.b1n_ry.yigd.DeathHandler; | ||
import com.b1n_ry.yigd.Yigd; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.damagesource.DamageSource; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.level.GameRules; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(value = LivingEntity.class, priority = 500) | ||
public class LivingEntityMixin { | ||
@Inject(method = "dropAllDeathLoot", at = @At("HEAD")) | ||
private void onDeath(ServerLevel level, DamageSource damageSource, CallbackInfo ci) { | ||
LivingEntity entity = (LivingEntity) (Object) this; | ||
|
||
if (!(entity instanceof ServerPlayer player)) return; | ||
|
||
if (!player.isDeadOrDying()) return; | ||
if (player.isSpectator()) return; | ||
|
||
if (level.getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY)) return; | ||
|
||
Yigd.DEATH_HANDLER.onPlayerDeath(player, level, player.position(), damageSource); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters