Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.20.1-aria-for-painters' into 1…
Browse files Browse the repository at this point in the history
….20.1-aria-for-painters
  • Loading branch information
DaFuqs committed Dec 2, 2024
2 parents 0b384e4 + 8e9e4b4 commit 088ffe7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
25 changes: 17 additions & 8 deletions src/main/java/de/dafuqs/spectrum/mixin/LivingEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,13 @@ public abstract class LivingEntityMixin {
public abstract void travel(Vec3d movementInput);

@Shadow protected ItemStack activeItemStack;


@Shadow
protected abstract @Nullable SoundEvent getDeathSound();

@Shadow
protected abstract float getSoundVolume();

// FabricDefaultAttributeRegistry seems to only allow adding full containers and only single entity types?
@Inject(method = "createLivingAttributes()Lnet/minecraft/entity/attribute/DefaultAttributeContainer$Builder;", require = 1, allow = 1, at = @At("RETURN"))
private static void spectrum$addAttributes(final CallbackInfoReturnable<DefaultAttributeContainer.Builder> cir) {
Expand Down Expand Up @@ -493,15 +499,16 @@ private float getToughness() {

var damage = Float.MAX_VALUE;
if (SleepStatusEffect.isImmuneish(entity)) {
if (entity instanceof PlayerEntity player) {
if (entity instanceof PlayerEntity player)
damage = entity.getHealth() * 0.95F;
Support.grantAdvancementCriterion((ServerPlayerEntity) player, "lategame/survive_fatal_slumber", "get_slumbered_idiot");
}
else {
else
damage = entity.getMaxHealth() * 0.3F;
}
}

entity.damage(SpectrumDamageTypes.sleep(entity.getWorld(), null), damage);
if (entity.isAlive() && entity instanceof ServerPlayerEntity serverPlayerEntity && !serverPlayerEntity.isCreative()) {
Support.grantAdvancementCriterion(serverPlayerEntity, "lategame/survive_fatal_slumber", "survived_fatal_slumber");
}
}
}

Expand Down Expand Up @@ -580,8 +587,10 @@ private float getToughness() {
float h = target.getHealth();
target.setHealth(h - amount);
target.getDamageTracker().onDamage(source, amount);
if (target.isDead()) {
target.onDeath(source);
if (target.isDead() && !target.isInPose(EntityPose.DYING)) {
var deathSound = getDeathSound();
if (deathSound != null)
target.playSound(deathSound, getSoundVolume(), target.getSoundPitch());
}
cir.setReturnValue(true);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"hidden": true
},
"criteria": {
"get_slumbered_idiot": {
"survived_fatal_slumber": {
"trigger": "minecraft:impossible"
},
"gotten_previous": {
Expand Down

0 comments on commit 088ffe7

Please sign in to comment.