generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add gamerule for lethal poison damage.
- Loading branch information
Showing
12 changed files
with
106 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/generated/data/combat-plus/damage_type/lethal_poison.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"exhaustion": 0.1, | ||
"message_id": "lethal_poison", | ||
"scaling": "when_caused_by_living_non_player" | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/generated/data/minecraft/tags/damage_type/bypasses_armor.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"values": [ | ||
"combat-plus:lethal_poison" | ||
] | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/provismet/CombatPlusCore/mixin/PoisonStatusEffectMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.provismet.CombatPlusCore.mixin; | ||
|
||
import com.provismet.CombatPlusCore.utility.CPCDamageTypes; | ||
import com.provismet.CombatPlusCore.utility.CPCGameRules; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.entity.effect.PoisonStatusEffect; | ||
import net.minecraft.entity.effect.StatusEffect; | ||
import net.minecraft.entity.effect.StatusEffectCategory; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(PoisonStatusEffect.class) | ||
public abstract class PoisonStatusEffectMixin extends StatusEffect { | ||
protected PoisonStatusEffectMixin (StatusEffectCategory category, int color) { | ||
super(category, color); | ||
} | ||
|
||
@Inject(method = "applyUpdateEffect", at=@At("HEAD")) | ||
private void applyDamage (LivingEntity entity, int amplifier, CallbackInfoReturnable<Boolean> cir) { | ||
if (entity.getHealth() <= 1 && entity.getWorld().getGameRules().getBoolean(CPCGameRules.LETHAL_POISON)) { | ||
entity.damage(CPCDamageTypes.POISON.createDamageSource(entity.getDamageSources()), 1); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/provismet/CombatPlusCore/utility/CPCDamageTypes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.provismet.CombatPlusCore.utility; | ||
|
||
import com.provismet.CombatPlusCore.CPCMain; | ||
import com.provismet.lilylib.container.DamageTypeContainer; | ||
import net.minecraft.entity.damage.DamageType; | ||
import net.minecraft.registry.Registerable; | ||
|
||
public abstract class CPCDamageTypes { | ||
public static final DamageTypeContainer POISON = new DamageTypeContainer( | ||
CPCMain.identifier("lethal_poison"), | ||
new DamageType("lethal_poison", 0.1f) | ||
); | ||
|
||
public static void bootstrap (Registerable<DamageType> registerable) { | ||
registerable.register(POISON.getKey(), POISON.getDamageType()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/java/com/provismet/datagen/CombatPlusCore/DamageTypeGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.provismet.datagen.CombatPlusCore; | ||
|
||
import com.provismet.CombatPlusCore.utility.CPCDamageTypes; | ||
import com.provismet.lilylib.datagen.provider.LilyDamageTypeProvider; | ||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; | ||
import net.minecraft.registry.RegistryWrapper; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class DamageTypeGenerator extends LilyDamageTypeProvider { | ||
protected DamageTypeGenerator (FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) { | ||
super(output, registriesFuture); | ||
} | ||
|
||
@Override | ||
protected void generate (RegistryWrapper.WrapperLookup registries, DamageConsumer consumer) { | ||
consumer.add(CPCDamageTypes.POISON); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters