generated from neoforged/MDK
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix the datagen helper to properly work with addons
- Loading branch information
1 parent
4723c43
commit b1c421b
Showing
14 changed files
with
153 additions
and
55 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
1 change: 1 addition & 0 deletions
1
src/api/java/com/github/minecraftschurlimods/bibliocraft/api/BibliocraftApi.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
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
34 changes: 34 additions & 0 deletions
34
...com/github/minecraftschurlimods/bibliocraft/api/datagen/NonClearingBlockTagsProvider.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,34 @@ | ||
package com.github.minecraftschurlimods.bibliocraft.api.datagen; | ||
|
||
import net.minecraft.core.HolderLookup; | ||
import net.minecraft.data.PackOutput; | ||
import net.neoforged.neoforge.common.data.BlockTagsProvider; | ||
import net.neoforged.neoforge.common.data.ExistingFileHelper; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* The default {@link BlockTagsProvider} implementation clears the builders before calling {@link BlockTagsProvider#addTags(HolderLookup.Provider)}. | ||
* We don't want that, so we override {@link BlockTagsProvider#addTags(HolderLookup.Provider)} to not do that. | ||
*/ | ||
public abstract class NonClearingBlockTagsProvider extends BlockTagsProvider { | ||
// Store the provider here because while the superclass has it, it is private there. | ||
private final CompletableFuture<HolderLookup.Provider> lookupProvider; | ||
|
||
/** | ||
* See super constructor for information. | ||
*/ | ||
public NonClearingBlockTagsProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, String modId, @Nullable ExistingFileHelper existingFileHelper) { | ||
super(output, lookupProvider, modId, existingFileHelper); | ||
this.lookupProvider = lookupProvider; | ||
} | ||
|
||
@Override | ||
protected CompletableFuture<HolderLookup.Provider> createContentsProvider() { | ||
return lookupProvider.thenApply(provider -> { | ||
addTags(provider); | ||
return provider; | ||
}); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
.../com/github/minecraftschurlimods/bibliocraft/api/datagen/NonClearingItemTagsProvider.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,70 @@ | ||
package com.github.minecraftschurlimods.bibliocraft.api.datagen; | ||
|
||
import net.minecraft.core.HolderLookup; | ||
import net.minecraft.data.PackOutput; | ||
import net.minecraft.data.tags.ItemTagsProvider; | ||
import net.minecraft.tags.TagBuilder; | ||
import net.minecraft.tags.TagKey; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.level.block.Block; | ||
import net.neoforged.neoforge.common.data.ExistingFileHelper; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Optional; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* The default {@link ItemTagsProvider} implementation clears the builders before calling {@link ItemTagsProvider#addTags(HolderLookup.Provider)}. | ||
* We don't want that, so we override {@link ItemTagsProvider#addTags(HolderLookup.Provider)} to not do that. | ||
*/ | ||
public abstract class NonClearingItemTagsProvider extends ItemTagsProvider { | ||
// Store the provider here because while the superclass has it, it is private there. | ||
private final CompletableFuture<HolderLookup.Provider> lookupProvider; | ||
|
||
/** | ||
* See super constructor for information. | ||
*/ | ||
public NonClearingItemTagsProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, CompletableFuture<TagLookup<Block>> blockTags) { | ||
super(output, lookupProvider, blockTags); | ||
this.lookupProvider = lookupProvider; | ||
} | ||
|
||
/** | ||
* See super constructor for information. | ||
*/ | ||
@Deprecated | ||
public NonClearingItemTagsProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, CompletableFuture<TagLookup<Item>> parentProvider, CompletableFuture<TagLookup<Block>> blockTags) { | ||
super(output, lookupProvider, parentProvider, blockTags); | ||
this.lookupProvider = lookupProvider; | ||
} | ||
|
||
/** | ||
* See super constructor for information. | ||
*/ | ||
public NonClearingItemTagsProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, CompletableFuture<TagLookup<Block>> blockTags, String modId, @Nullable ExistingFileHelper existingFileHelper) { | ||
super(output, lookupProvider, blockTags, modId, existingFileHelper); | ||
this.lookupProvider = lookupProvider; | ||
} | ||
|
||
/** | ||
* See super constructor for information. | ||
*/ | ||
public NonClearingItemTagsProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, CompletableFuture<TagLookup<Item>> parentProvider, CompletableFuture<TagLookup<Block>> blockTags, String modId, @Nullable ExistingFileHelper existingFileHelper) { | ||
super(output, lookupProvider, parentProvider, blockTags, modId, existingFileHelper); | ||
this.lookupProvider = lookupProvider; | ||
} | ||
|
||
@Override | ||
protected CompletableFuture<HolderLookup.Provider> createContentsProvider() { | ||
return lookupProvider.thenApply(provider -> { | ||
addTags(provider); | ||
return provider; | ||
}).thenCombine(blockTags, (provider, tagLookup) -> { | ||
tagsToCopy.forEach((block, item) -> { | ||
TagBuilder tagBuilder = getOrCreateRawBuilder(item); | ||
tagLookup.apply(block).orElseThrow(() -> new IllegalStateException("Missing block tag " + item.location())).build().forEach(tagBuilder::add); | ||
}); | ||
return provider; | ||
}); | ||
} | ||
} |
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
8 changes: 7 additions & 1 deletion
8
...ta/java/com/github/minecraftschurlimods/bibliocraft/datagen/data/BCBlockTagsProvider.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
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
2 changes: 0 additions & 2 deletions
2
src/generated/resources/.cache/735031f3addf80804addae5e3f53249900116f1e
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.