Skip to content

Commit

Permalink
Added immortality ability
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucraft committed Mar 4, 2025
1 parent ae7bc15 commit 59ba70f
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.tags.DamageTypeTags;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.AttributeMap;
Expand All @@ -11,6 +13,8 @@
import net.threetag.palladium.entity.PalladiumEntityExtension;
import net.threetag.palladium.entity.PalladiumLivingEntityExtension;
import net.threetag.palladium.power.PowerHandler;
import net.threetag.palladium.power.ability.Abilities;
import net.threetag.palladium.power.ability.AbilityUtil;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
Expand All @@ -36,6 +40,10 @@ public abstract class LivingEntityMixin implements PalladiumLivingEntityExtensio

@Shadow public abstract void indicateDamage(double xDistance, double zDistance);

@Shadow public abstract void setHealth(float health);

@Shadow public abstract boolean removeAllEffects();

@Inject(method = "<init>", at = @At("RETURN"))
public void init(EntityType entityType, Level level, CallbackInfo ci) {
this.palladium$powerHandler = new PowerHandler((LivingEntity) (Object) this);
Expand All @@ -50,6 +58,16 @@ protected void getJumpPower(CallbackInfoReturnable<Float> cir) {
}
}

@SuppressWarnings("ConstantValue")
@Inject(method = "checkTotemDeathProtection", at = @At("HEAD"), cancellable = true)
private void checkTotemDeathProtection(DamageSource damageSource, CallbackInfoReturnable<Boolean> cir) {
if(!damageSource.is(DamageTypeTags.BYPASSES_INVULNERABILITY) && AbilityUtil.isTypeEnabled((LivingEntity) (Object) this, Abilities.IMMORTALITY.get())) {
this.setHealth(1.0F);
this.removeAllEffects();
cir.setReturnValue(true);
}
}

@Inject(method = "tick", at = @At("RETURN"))
private void tick(CallbackInfo ci) {
var entity = (LivingEntity) (Object) this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class Abilities {
public static final RegistrySupplier<Ability> TRAIL = ABILITIES.register("trail", TrailAbility::new);
public static final RegistrySupplier<Ability> FIRE_ASPECT = ABILITIES.register("fire_aspect", FireAspectAbility::new);
public static final RegistrySupplier<Ability> PARTICLES = ABILITIES.register("particles", ParticleAbility::new);
public static final RegistrySupplier<Ability> IMMORTALITY = ABILITIES.register("immortality", ImmortalityAbility::new);

public static void init() {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package net.threetag.palladium.power.ability;

import net.minecraft.world.item.Items;
import net.threetag.palladium.util.icon.ItemIcon;

public class ImmortalityAbility extends Ability {

public ImmortalityAbility() {
this.withProperty(ICON, new ItemIcon(Items.TOTEM_OF_UNDYING));
}

@Override
public String getDocumentationDescription() {
return "Makes you unable to die.";
}

}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.20.1 2024-04-15T20:17:37.6885958 Palladium Languages: en_us
16aca9f7b03c6b4b35d5007b8557aaa98d75d86a assets/palladium/lang/en_us.json
// 1.20.1 2025-03-04T18:08:12.6931285 Palladium Languages: en_us
1e8f31207dd0b0ad756833996afcf54bd93d4761 assets/palladium/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.20.1 2024-04-15T20:17:37.685616 Palladium Languages: de_de
9f5bc6cef87031fca451ea2be31d62697fbb0bf5 assets/palladium/lang/de_de.json
// 1.20.1 2025-03-04T18:08:12.6885621 Palladium Languages: de_de
65b705810d5d0ea698be9b051d4a0246dab43c68 assets/palladium/lang/de_de.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.20.1 2024-04-15T20:17:37.6885958 Palladium Languages: sxu
5226f34443f9bfc2c28bfac90a1433e5659ba3ee assets/palladium/lang/sxu.json
// 1.20.1 2025-03-04T18:08:12.6961384 Palladium Languages: sxu
033b223fd2bdc6b8236c3233cf0585aaf9482717 assets/palladium/lang/sxu.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"ability.palladium.gui_overlay": "GUI-Overlay",
"ability.palladium.healing": "Heilung",
"ability.palladium.hide_body_part": "Körperteile verstecken",
"ability.palladium.immortality": "Unsterblichkeit",
"ability.palladium.intangibility": "Ungreifbarkeit",
"ability.palladium.invisibility": "Unsichtbarkeit",
"ability.palladium.name_change": "Namesänderung",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"ability.palladium.gui_overlay": "Gui Overlay",
"ability.palladium.healing": "Healing",
"ability.palladium.hide_body_part": "Hide Body Part",
"ability.palladium.immortality": "Immortality",
"ability.palladium.intangibility": "Intangibility",
"ability.palladium.invisibility": "Invisibility",
"ability.palladium.name_change": "Name Change",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"ability.palladium.gui_overlay": "GUI-Overlay",
"ability.palladium.healing": "Helung",
"ability.palladium.hide_body_part": "Görperdeile versteggen",
"ability.palladium.immortality": "Unsterblichkeht",
"ability.palladium.intangibility": "Ungreifbarkeht",
"ability.palladium.invisibility": "Unsischtbarkeet",
"ability.palladium.name_change": "Namesänderung",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ protected void addTranslations() {
this.addAbility(Abilities.SCULK_IMMUNITY, "Sculk Immunity");
this.addAbility(Abilities.FIRE_ASPECT, "Fire Aspect");
this.addAbility(Abilities.PARTICLES, "Particles");
this.addAbility(Abilities.IMMORTALITY, "Immortality");
this.add("ability.geckolib.render_layer_animation", "Gecko Render Layer Animation");
this.add("ability.geckolib.armor_animation", "Gecko Armor Animation");

Expand Down Expand Up @@ -308,6 +309,7 @@ protected void addTranslations() {
this.addAbility(Abilities.SCULK_IMMUNITY, "Sculk-Immunität");
this.addAbility(Abilities.FIRE_ASPECT, "Verbrennung");
this.addAbility(Abilities.PARTICLES, "Partikel");
this.addAbility(Abilities.IMMORTALITY, "Unsterblichkeit");
this.add("ability.geckolib.render_layer_animation", "Gecko Render Layer Animation");
this.add("ability.geckolib.armor_animation", "Gecko Armor Animation");

Expand Down Expand Up @@ -498,6 +500,7 @@ protected void addTranslations() {
this.addAbility(Abilities.SCULK_IMMUNITY, "Sculk-Immunität");
this.addAbility(Abilities.FIRE_ASPECT, "Vorbrennung");
this.addAbility(Abilities.PARTICLES, "Partikel");
this.addAbility(Abilities.IMMORTALITY, "Unsterblichkeht");
this.add("ability.geckolib.render_layer_animation", "Gecko Render Layer Animation");
this.add("ability.geckolib.armor_animation", "Gecko Armor Animation");

Expand Down

0 comments on commit 59ba70f

Please sign in to comment.