Skip to content

Commit

Permalink
fix totem of undying
Browse files Browse the repository at this point in the history
  • Loading branch information
PinkGoosik committed Jun 19, 2024
1 parent 890890b commit 546e049
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
33 changes: 18 additions & 15 deletions src/main/java/ru/pinkgoosik/dimrevive/DimensionalRevive.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
});
Expand Down

0 comments on commit 546e049

Please sign in to comment.