From 546e04907f9fb933dde05cb3265ac1d04bfb5f36 Mon Sep 17 00:00:00 2001 From: PinkGoosik Date: Wed, 19 Jun 2024 22:58:38 +0500 Subject: [PATCH] fix totem of undying --- gradle.properties | 2 +- .../dimrevive/DimensionalRevive.java | 33 ++++++++++--------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/gradle.properties b/gradle.properties index 5bc08f0..b22c6e0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs = -Xmx1G org.gradle.parallel = true # Mod Properties -mod_version = 0.1.5 +mod_version = 0.1.6 maven_group = ru.pinkgoosik archives_base_name = dimensional-revive diff --git a/src/main/java/ru/pinkgoosik/dimrevive/DimensionalRevive.java b/src/main/java/ru/pinkgoosik/dimrevive/DimensionalRevive.java index 59ffb75..501a488 100644 --- a/src/main/java/ru/pinkgoosik/dimrevive/DimensionalRevive.java +++ b/src/main/java/ru/pinkgoosik/dimrevive/DimensionalRevive.java @@ -17,6 +17,7 @@ import net.minecraft.registry.RegistryKey; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; +import net.minecraft.util.Hand; import net.minecraft.util.Identifier; import net.minecraft.util.math.Vec3d; import net.minecraft.world.GameMode; @@ -37,26 +38,28 @@ public void onInitialize() { ServerLivingEntityEvents.ALLOW_DEATH.register((entity, damageSource, damageAmount) -> { if(entity instanceof ServerPlayerEntity player && player instanceof PlayerExtension ex && player.getServer().isHardcore() && player.interactionManager.getGameMode().equals(GameMode.SURVIVAL)) { - SkeletonEntity skeleton = new SkeletonEntity(EntityType.SKELETON, player.getServerWorld()); - skeleton.refreshPositionAndAngles(player.getX(), player.getY(), player.getZ(), player.getYaw(), player.getPitch()); + if(!player.getStackInHand(Hand.MAIN_HAND).isOf(Items.TOTEM_OF_UNDYING) && !player.getStackInHand(Hand.OFF_HAND).isOf(Items.TOTEM_OF_UNDYING)) { + SkeletonEntity skeleton = new SkeletonEntity(EntityType.SKELETON, player.getServerWorld()); + skeleton.refreshPositionAndAngles(player.getX(), player.getY(), player.getZ(), player.getYaw(), player.getPitch()); - ItemStack head = new ItemStack(Items.PLAYER_HEAD); - GameProfile gameProfile = player.getGameProfile(); - head.getOrCreateNbt().put("SkullOwner", NbtHelper.writeGameProfile(new NbtCompound(), gameProfile)); + ItemStack head = new ItemStack(Items.PLAYER_HEAD); + GameProfile gameProfile = player.getGameProfile(); + head.getOrCreateNbt().put("SkullOwner", NbtHelper.writeGameProfile(new NbtCompound(), gameProfile)); - skeleton.equipStack(EquipmentSlot.HEAD, head); + skeleton.equipStack(EquipmentSlot.HEAD, head); - skeleton.equipStack(EquipmentSlot.CHEST, player.getEquippedStack(EquipmentSlot.CHEST).copy()); - skeleton.equipStack(EquipmentSlot.LEGS, player.getEquippedStack(EquipmentSlot.LEGS).copy()); - skeleton.equipStack(EquipmentSlot.FEET, player.getEquippedStack(EquipmentSlot.FEET).copy()); - skeleton.equipStack(EquipmentSlot.MAINHAND, player.getMainHandStack().copy()); - skeleton.equipStack(EquipmentSlot.OFFHAND, player.getOffHandStack().copy()); + skeleton.equipStack(EquipmentSlot.CHEST, player.getEquippedStack(EquipmentSlot.CHEST).copy()); + skeleton.equipStack(EquipmentSlot.LEGS, player.getEquippedStack(EquipmentSlot.LEGS).copy()); + skeleton.equipStack(EquipmentSlot.FEET, player.getEquippedStack(EquipmentSlot.FEET).copy()); + skeleton.equipStack(EquipmentSlot.MAINHAND, player.getMainHandStack().copy()); + skeleton.equipStack(EquipmentSlot.OFFHAND, player.getOffHandStack().copy()); - skeleton.setHealth(0); - player.getServerWorld().spawnEntity(skeleton); + skeleton.setHealth(0); + player.getServerWorld().spawnEntity(skeleton); - ex.onSilentDeath(damageSource); - return false; + ex.onSilentDeath(damageSource); + return false; + } } return true; });