-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement datagen for damage type definitions and tags
- Loading branch information
1 parent
25a54d3
commit 9be479b
Showing
9 changed files
with
81 additions
and
7 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...data/hexcasting/damage_type/overcast.json → ...data/hexcasting/damage_type/overcast.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"exhaustion": 0, | ||
"exhaustion": 0.0, | ||
"message_id": "hexcasting.overcast", | ||
"scaling": "when_caused_by_living_non_player" | ||
} |
2 changes: 1 addition & 1 deletion
2
...es/data/hexcasting/damage_type/shame.json → ...es/data/hexcasting/damage_type/shame.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"exhaustion": 0, | ||
"exhaustion": 0.0, | ||
"message_id": "hexcasting.shame", | ||
"scaling": "when_caused_by_living_non_player" | ||
} |
1 change: 0 additions & 1 deletion
1
...raft/tags/damage_type/bypasses_armor.json → ...raft/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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"replace": false, | ||
"values": [ | ||
"hexcasting:overcast", | ||
"hexcasting:shame" | ||
|
1 change: 0 additions & 1 deletion
1
...ft/tags/damage_type/bypasses_effects.json → ...ft/tags/damage_type/bypasses_effects.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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"replace": false, | ||
"values": [ | ||
"hexcasting:overcast", | ||
"hexcasting:shame" | ||
|
1 change: 0 additions & 1 deletion
1
...damage_type/bypasses_invulnerability.json → ...damage_type/bypasses_invulnerability.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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"replace": false, | ||
"values": [ | ||
"hexcasting:shame" | ||
] | ||
|
1 change: 0 additions & 1 deletion
1
...aft/tags/damage_type/bypasses_shield.json → ...aft/tags/damage_type/bypasses_shield.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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"replace": false, | ||
"values": [ | ||
"hexcasting:overcast", | ||
"hexcasting:shame" | ||
|
16 changes: 16 additions & 0 deletions
16
Common/src/main/java/at/petrak/hexcasting/common/lib/HexDamageTypes.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 |
---|---|---|
@@ -1,12 +1,28 @@ | ||
package at.petrak.hexcasting.common.lib; | ||
|
||
import net.minecraft.core.registries.Registries; | ||
import net.minecraft.data.worldgen.BootstapContext; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.world.damagesource.DamageScaling; | ||
import net.minecraft.world.damagesource.DamageType; | ||
|
||
import static at.petrak.hexcasting.api.HexAPI.modLoc; | ||
|
||
public class HexDamageTypes { | ||
public static final ResourceKey<DamageType> OVERCAST = ResourceKey.create(Registries.DAMAGE_TYPE, modLoc("overcast")); | ||
public static final ResourceKey<DamageType> SHAME_ON_YOU = ResourceKey.create(Registries.DAMAGE_TYPE, modLoc("shame")); | ||
|
||
public static void bootstrap(BootstapContext<DamageType> ctx) { | ||
ctx.register(OVERCAST, new DamageType( | ||
"hexcasting.overcast", | ||
DamageScaling.WHEN_CAUSED_BY_LIVING_NON_PLAYER, | ||
0f | ||
)); | ||
|
||
ctx.register(SHAME_ON_YOU, new DamageType( | ||
"hexcasting.shame", | ||
DamageScaling.WHEN_CAUSED_BY_LIVING_NON_PLAYER, | ||
0f | ||
)); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
Common/src/main/java/at/petrak/hexcasting/datagen/tag/HexDamageTypeTagProvider.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,42 @@ | ||
package at.petrak.hexcasting.datagen.tag; | ||
|
||
import at.petrak.hexcasting.common.lib.HexDamageTypes; | ||
import net.minecraft.core.HolderLookup; | ||
import net.minecraft.data.PackOutput; | ||
import net.minecraft.data.tags.DamageTypeTagsProvider; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.tags.DamageTypeTags; | ||
import net.minecraft.tags.TagKey; | ||
import net.minecraft.world.damagesource.DamageType; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class HexDamageTypeTagProvider extends DamageTypeTagsProvider { | ||
public HexDamageTypeTagProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> provider) { | ||
super(output, provider); | ||
} | ||
|
||
@Override | ||
protected void addTags(@NotNull HolderLookup.Provider provider) { | ||
add(HexDamageTypes.OVERCAST, | ||
DamageTypeTags.BYPASSES_ARMOR, | ||
DamageTypeTags.BYPASSES_EFFECTS, | ||
DamageTypeTags.BYPASSES_SHIELD | ||
); | ||
|
||
add(HexDamageTypes.SHAME_ON_YOU, | ||
DamageTypeTags.BYPASSES_ARMOR, | ||
DamageTypeTags.BYPASSES_EFFECTS, | ||
DamageTypeTags.BYPASSES_INVULNERABILITY, | ||
DamageTypeTags.BYPASSES_SHIELD | ||
); | ||
} | ||
|
||
@SafeVarargs | ||
private void add(ResourceKey<DamageType> damageType, TagKey<DamageType>... tags) { | ||
for (var tag : tags) { | ||
this.tag(tag).add(damageType); | ||
} | ||
} | ||
} |
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