Skip to content

Commit

Permalink
Add "bypasses_cuirass" tag and var names
Browse files Browse the repository at this point in the history
  • Loading branch information
dhyces committed Apr 2, 2024
1 parent b3e0cac commit 088b5e1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.minecraft.entity.damage.DamageType;
import net.minecraft.entity.damage.DamageTypes;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.tag.DamageTypeTags;
Expand All @@ -27,5 +28,6 @@ protected void configure(RegistryWrapper.WrapperLookup registries) {
getOrCreateTagBuilder(DamageTypeTags.AVOIDS_GUARDIAN_THORNS).add(ModDamageTypeKeys.SOUL_RIP);
getOrCreateTagBuilder(DamageTypeTags.ALWAYS_TRIGGERS_SILVERFISH).add(ModDamageTypeKeys.SOUL_RIP);
getOrCreateTagBuilder(ModDamageTypeTags.IS_YMPE).add(ModDamageTypeKeys.YMPE, ModDamageTypeKeys.YMPE_ENTITY);
getOrCreateTagBuilder(ModDamageTypeTags.BYPASSES_CUIRASS).forceAddTag(DamageTypeTags.IS_FALL).add(DamageTypes.MAGIC, DamageTypes.OUT_OF_WORLD);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"replace": false,
"values": [
"#minecraft:is_fall",
"minecraft:magic",
"minecraft:out_of_world"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

public class ModDamageTypeTags {
public static final TagKey<DamageType> IS_YMPE = create("is_ympe");
public static final TagKey<DamageType> BYPASSES_CUIRASS = create("bypasses_cuirass");

private static TagKey<DamageType> create(String tag) {
return TagKey.of(RegistryKeys.DAMAGE_TYPE, AylythUtil.id(tag));
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/moriyashiine/aylyth/mixin/PlayerEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import moriyashiine.aylyth.common.registry.ModSoundEvents;
import moriyashiine.aylyth.common.registry.key.ModDamageTypeKeys;
import moriyashiine.aylyth.common.registry.key.ModDimensionKeys;
import moriyashiine.aylyth.common.registry.tag.ModDamageTypeTags;
import moriyashiine.aylyth.common.util.AylythUtil;
import moriyashiine.aylyth.common.world.ModWorldState;
import net.minecraft.block.Block;
Expand Down Expand Up @@ -145,17 +146,15 @@ private void aylyth_webbingScuffedry(CallbackInfoReturnable<Boolean> cir) {
if (!getWorld().isClient) {
PlayerEntity player = (PlayerEntity) (Object) this;
CuirassComponent component = ModComponents.CUIRASS_COMPONENT.get(player);
boolean bl = source.isOf(DamageTypes.MAGIC) || source.isIn(DamageTypeTags.IS_FALL) || source.isOf(DamageTypes.OUT_OF_WORLD);
boolean bl2 = source.getAttacker() != null && source.getAttacker() instanceof LivingEntity livingEntity1 && livingEntity1.getMainHandStack().getItem() instanceof AxeItem;
boolean bl3 = source.isIn(DamageTypeTags.IS_FIRE);
if(bl2 || bl3){
boolean bypassesCuirass = source.isIn(ModDamageTypeTags.BYPASSES_CUIRASS);
boolean isAxe = source.getAttacker() instanceof LivingEntity livingEntity1 && livingEntity1.getMainHandStack().getItem() instanceof AxeItem;
boolean isFireDamage = source.isIn(DamageTypeTags.IS_FIRE);
if (isAxe || isFireDamage) {
component.setStage(0);
component.setStageTimer(0);
player.getWorld().playSoundFromEntity(null, player, ModSoundEvents.ENTITY_PLAYER_INCREASE_YMPE_INFESTATION_STAGE.value(), SoundCategory.PLAYERS, 1, player.getSoundPitch());
return amount;
} else if(bl){
return amount;
} else {
} else if (!bypassesCuirass) {
while (component.getStage() > 0) {
amount--;
component.setStage(component.getStage() - 1);
Expand Down

0 comments on commit 088b5e1

Please sign in to comment.