Update CommonEvents.java
This commit is contained in:
parent
9a484df16e
commit
21f09b2526
|
|
@ -21,6 +21,7 @@
|
|||
package tschipp.carryon.events;
|
||||
|
||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents;
|
||||
import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.CommonLifecycleEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
|
|
@ -33,6 +34,7 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import tschipp.carryon.CarryOnCommon;
|
||||
import tschipp.carryon.common.carry.CarryOnData;
|
||||
import tschipp.carryon.common.carry.CarryOnData.CarryType;
|
||||
|
|
@ -132,10 +134,13 @@ public class CommonEvents {
|
|||
CarryOnCommon.onCarryTick(player);
|
||||
});
|
||||
|
||||
|
||||
ServerPlayerEvents.COPY_FROM.register(((oldPlayer, newPlayer, alive) -> {
|
||||
PlacementHandler.placeCarriedOnDeath(oldPlayer, newPlayer, !alive);
|
||||
}));
|
||||
ServerLivingEntityEvents.AFTER_DEATH.register((entity, damageSource)->{
|
||||
if (!(entity instanceof ServerPlayer)) return;
|
||||
var player = (ServerPlayer) entity;
|
||||
var carry = CarryOnDataManager.getCarryData(player);
|
||||
if (!carry.isCarrying() || player.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) && !carry.isCarrying(CarryType.PLAYER)) return;
|
||||
PlacementHandler.placeCarried(player);
|
||||
});
|
||||
|
||||
|
||||
PlayerBlockBreakEvents.BEFORE.register(((world, player, pos, state, blockEntity) -> {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user