-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: datagen damagetypes and their tags
- Loading branch information
1 parent
ff261be
commit d3456d8
Showing
12 changed files
with
182 additions
and
140 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
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
File renamed without changes.
4 changes: 1 addition & 3 deletions
4
...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,7 +1,5 @@ | ||
{ | ||
"replace": false, | ||
"values": [ | ||
"hollow:sculk_jaw" | ||
] | ||
} | ||
|
||
} |
1 change: 0 additions & 1 deletion
1
...ecraft/tags/damage_type/no_knockback.json → ...ecraft/tags/damage_type/no_knockback.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": [ | ||
"hollow:sculk_jaw" | ||
] | ||
|
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
32 changes: 32 additions & 0 deletions
32
src/main/java/dev/spiritstudios/hollow/datagen/DamageTypeProvider.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,32 @@ | ||
package dev.spiritstudios.hollow.datagen; | ||
|
||
import dev.spiritstudios.hollow.Hollow; | ||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; | ||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; | ||
import net.minecraft.entity.damage.DamageType; | ||
import net.minecraft.registry.RegistryKeys; | ||
import net.minecraft.registry.RegistryWrapper; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class DamageTypeProvider extends FabricDynamicRegistryProvider { | ||
public DamageTypeProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) { | ||
super(output, registriesFuture); | ||
} | ||
|
||
@Override | ||
protected void configure(RegistryWrapper.WrapperLookup wrapperLookup, Entries entries) { | ||
RegistryWrapper<DamageType> lookup = wrapperLookup.getOrThrow(RegistryKeys.DAMAGE_TYPE); | ||
|
||
lookup.streamKeys() | ||
.filter(key -> | ||
key.getValue().getNamespace().equals(Hollow.MODID)) | ||
.forEach(key -> | ||
entries.add(key, lookup.getOrThrow(key).value())); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "Hollow/Damage Types"; | ||
} | ||
} |
130 changes: 130 additions & 0 deletions
130
src/main/java/dev/spiritstudios/hollow/datagen/TagProviders.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,130 @@ | ||
package dev.spiritstudios.hollow.datagen; | ||
|
||
import dev.spiritstudios.hollow.block.HollowLogBlock; | ||
import dev.spiritstudios.hollow.data.HollowBiomeTags; | ||
import dev.spiritstudios.hollow.registry.HollowBlocks; | ||
import dev.spiritstudios.hollow.registry.HollowDamageTypes; | ||
import dev.spiritstudios.hollow.registry.HollowEntityTypes; | ||
import dev.spiritstudios.specter.api.core.reflect.ReflectionHelper; | ||
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; | ||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; | ||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; | ||
import net.fabricmc.fabric.api.tag.convention.v2.ConventionalBiomeTags; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.damage.DamageType; | ||
import net.minecraft.registry.RegistryKeys; | ||
import net.minecraft.registry.RegistryWrapper; | ||
import net.minecraft.registry.tag.BlockTags; | ||
import net.minecraft.registry.tag.DamageTypeTags; | ||
import net.minecraft.registry.tag.EntityTypeTags; | ||
import net.minecraft.world.biome.Biome; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class TagProviders { | ||
public static void addAll(FabricDataGenerator.Pack pack) { | ||
pack.addProvider(TagProviders.BlockTagProvider::new); | ||
pack.addProvider(TagProviders.BiomeTagProvider::new); | ||
pack.addProvider(TagProviders.EntityTypeTagProvider::new); | ||
pack.addProvider(TagProviders.DamageTypeTagProvider::new); | ||
} | ||
|
||
private static class BiomeTagProvider extends FabricTagProvider<Biome> { | ||
public BiomeTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> completableFuture) { | ||
super(output, RegistryKeys.BIOME, completableFuture); | ||
} | ||
|
||
@Override | ||
protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { | ||
getOrCreateTagBuilder(HollowBiomeTags.HAS_CLOSER_FOG) | ||
.forceAddTag(ConventionalBiomeTags.IS_SWAMP); | ||
} | ||
} | ||
|
||
private static class BlockTagProvider extends FabricTagProvider.BlockTagProvider { | ||
public BlockTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) { | ||
super(output, registriesFuture); | ||
} | ||
|
||
@Override | ||
protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { | ||
FabricTagProvider<Block>.FabricTagBuilder hollowLogs = getOrCreateTagBuilder(HollowBlocks.Tags.HOLLOW_LOGS); | ||
FabricTagProvider<Block>.FabricTagBuilder axeMineable = getOrCreateTagBuilder(BlockTags.AXE_MINEABLE); | ||
|
||
ReflectionHelper.getStaticFields( | ||
HollowBlocks.class, | ||
HollowLogBlock.class | ||
).forEach(pair -> { | ||
hollowLogs.add(pair.value()); | ||
axeMineable.add(pair.value()); | ||
}); | ||
|
||
getOrCreateTagBuilder(BlockTags.PICKAXE_MINEABLE) | ||
.add(HollowBlocks.ECHOING_POT) | ||
.add(HollowBlocks.STONE_CHEST) | ||
.add(HollowBlocks.STONE_CHEST_LID) | ||
.add(HollowBlocks.COPPER_PILLAR) | ||
.add(HollowBlocks.WEATHERED_COPPER_PILLAR) | ||
.add(HollowBlocks.EXPOSED_COPPER_PILLAR) | ||
.add(HollowBlocks.OXIDIZED_COPPER_PILLAR) | ||
.add(HollowBlocks.WAXED_COPPER_PILLAR) | ||
.add(HollowBlocks.WAXED_WEATHERED_COPPER_PILLAR) | ||
.add(HollowBlocks.WAXED_EXPOSED_COPPER_PILLAR) | ||
.add(HollowBlocks.WAXED_OXIDIZED_COPPER_PILLAR); | ||
|
||
getOrCreateTagBuilder(BlockTags.HOE_MINEABLE) | ||
.add(HollowBlocks.SCULK_JAW); | ||
|
||
getOrCreateTagBuilder(BlockTags.FLOWER_POTS) | ||
.add(HollowBlocks.POTTED_ROOTED_ORCHID) | ||
.add(HollowBlocks.POTTED_PAEONIA); | ||
|
||
getOrCreateTagBuilder(BlockTags.SMALL_FLOWERS) | ||
.add(HollowBlocks.PAEONIA) | ||
.add(HollowBlocks.ROOTED_ORCHID) | ||
.add(HollowBlocks.LOTUS_LILYPAD); | ||
|
||
getOrCreateTagBuilder(BlockTags.FLOWERS) | ||
.add(HollowBlocks.CAMPION); | ||
|
||
getOrCreateTagBuilder(HollowBlocks.Tags.POLYPORE_PLACEABLE_ON) | ||
.forceAddTag(BlockTags.LOGS) | ||
.addTag(HollowBlocks.Tags.HOLLOW_LOGS); | ||
} | ||
} | ||
|
||
private static class EntityTypeTagProvider extends FabricTagProvider.EntityTypeTagProvider { | ||
public EntityTypeTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> completableFuture) { | ||
super(output, completableFuture); | ||
} | ||
|
||
@Override | ||
protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { | ||
getOrCreateTagBuilder(HollowEntityTypes.Tags.POISONS_FROG) | ||
.add(HollowEntityTypes.FIREFLY); | ||
|
||
getOrCreateTagBuilder(EntityTypeTags.FROG_FOOD) | ||
.add(HollowEntityTypes.FIREFLY); | ||
|
||
getOrCreateTagBuilder(HollowEntityTypes.Tags.IMMUNE_TO_SCULK_JAW) | ||
.add(EntityType.WARDEN); | ||
} | ||
} | ||
|
||
|
||
private static class DamageTypeTagProvider extends FabricTagProvider<DamageType> { | ||
public DamageTypeTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) { | ||
super(output, RegistryKeys.DAMAGE_TYPE, registriesFuture); | ||
} | ||
|
||
@Override | ||
protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { | ||
getOrCreateTagBuilder(DamageTypeTags.BYPASSES_ARMOR) | ||
.add(HollowDamageTypes.SCULK_JAW); | ||
|
||
getOrCreateTagBuilder(DamageTypeTags.NO_KNOCKBACK) | ||
.add(HollowDamageTypes.SCULK_JAW); | ||
} | ||
} | ||
} |
23 changes: 0 additions & 23 deletions
23
src/main/java/dev/spiritstudios/hollow/datagen/tag/BiomeTagProvider.java
This file was deleted.
Oops, something went wrong.
64 changes: 0 additions & 64 deletions
64
src/main/java/dev/spiritstudios/hollow/datagen/tag/BlockTagProvider.java
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
src/main/java/dev/spiritstudios/hollow/datagen/tag/EntityTypeTagProvider.java
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
src/main/java/dev/spiritstudios/hollow/registry/HollowDamageTypes.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,10 +1,23 @@ | ||
package dev.spiritstudios.hollow.registry; | ||
|
||
import dev.spiritstudios.hollow.Hollow; | ||
import net.minecraft.entity.damage.DamageScaling; | ||
import net.minecraft.entity.damage.DamageType; | ||
import net.minecraft.registry.Registerable; | ||
import net.minecraft.registry.RegistryKey; | ||
import net.minecraft.registry.RegistryKeys; | ||
|
||
public final class HollowDamageTypes { | ||
public static final RegistryKey<DamageType> SCULK_JAW = RegistryKey.of(RegistryKeys.DAMAGE_TYPE, Hollow.id("sculk_jaw")); | ||
|
||
public static void bootstrap(Registerable<DamageType> registerable) { | ||
registerable.register( | ||
SCULK_JAW, | ||
new DamageType( | ||
"sculk_jaw", | ||
DamageScaling.ALWAYS, | ||
0.1F | ||
) | ||
); | ||
} | ||
} |