generated from neoforged/MDK
-
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.
- Loading branch information
1 parent
5ccfd9a
commit 121e8b2
Showing
37 changed files
with
1,419 additions
and
8 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
src/generated/resources/.cache/132ced8588d83c256215f9004a517e67500de5e8
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 @@ | ||
// 1.20.2 2023-12-27T14:38:20.1780825 Ender IO Data (examplemod com.example.examplemod.registry.EnderBlockRegistry@430b5c0e) | ||
c1179f903b7e75f188bc87b191d646264a7c1c10 assets/examplemod/blockstates/example_block.json | ||
d32c5ad4076b1e22be3420304265a566242e4fb7 assets/examplemod/lang/en_us.json | ||
7c88b8231b94199736a42deb3c7c4afaf43ce8c6 assets/examplemod/models/block/example_block.json | ||
dea7c460ab71faf20207d3584b00732bdd44ae43 data/examplemod/loot_tables/blocks/example_block.json |
2 changes: 2 additions & 0 deletions
2
src/generated/resources/.cache/ceeb1d80e7df35351cd63f885edb271da6a88fd0
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,2 @@ | ||
// 1.20.2 2023-12-27T14:38:20.1780825 Ender IO Data (examplemod com.example.examplemod.registry.EnderItemRegistry@155f437a) | ||
608e98bf5926abfd9d441b916410bb804f31f633 assets/examplemod/models/item/example_block.json |
2 changes: 2 additions & 0 deletions
2
src/generated/resources/.cache/f974ae965ba85610fe3af49963ed1ddd4a94d07f
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,2 @@ | ||
// 1.20.2 2023-12-27T14:38:20.1660732 Ender IO Data (examplemod com.example.examplemod.registry.EnderItemRegistry@7b3ebc30) | ||
af0d8df01e38c368aa227d28d9f4050fedcf032a assets/examplemod/models/item/example_item.json |
7 changes: 7 additions & 0 deletions
7
src/generated/resources/assets/examplemod/blockstates/example_block.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,7 @@ | ||
{ | ||
"variants": { | ||
"": { | ||
"model": "examplemod:block/example_block" | ||
} | ||
} | ||
} |
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,3 @@ | ||
{ | ||
"block.examplemod.example_block": "Example block" | ||
} |
6 changes: 6 additions & 0 deletions
6
src/generated/resources/assets/examplemod/models/block/example_block.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,6 @@ | ||
{ | ||
"parent": "minecraft:block/cube_all", | ||
"textures": { | ||
"all": "examplemod:block/example_block" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/generated/resources/assets/examplemod/models/item/example_block.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,6 @@ | ||
{ | ||
"parent": "minecraft:item/generated", | ||
"textures": { | ||
"layer0": "examplemod:item/example_block" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/generated/resources/assets/examplemod/models/item/example_item.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,6 @@ | ||
{ | ||
"parent": "minecraft:item/generated", | ||
"textures": { | ||
"layer0": "examplemod:item/example_item" | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/generated/resources/data/examplemod/loot_tables/blocks/example_block.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,21 @@ | ||
{ | ||
"type": "minecraft:block", | ||
"pools": [ | ||
{ | ||
"bonus_rolls": 0.0, | ||
"conditions": [ | ||
{ | ||
"condition": "minecraft:survives_explosion" | ||
} | ||
], | ||
"entries": [ | ||
{ | ||
"type": "minecraft:item", | ||
"name": "examplemod:example_block" | ||
} | ||
], | ||
"rolls": 1.0 | ||
} | ||
], | ||
"random_sequence": "examplemod:blocks/example_block" | ||
} |
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
80 changes: 80 additions & 0 deletions
80
src/main/java/com/example/examplemod/data/EnderBlockLootProvider.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,80 @@ | ||
package com.example.examplemod.data; | ||
|
||
import com.example.examplemod.registry.EnderBlockRegistry; | ||
import com.example.examplemod.registry.EnderDeferredBlock; | ||
import net.minecraft.core.registries.BuiltInRegistries; | ||
import net.minecraft.data.loot.BlockLootSubProvider; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.flag.FeatureFlags; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.storage.loot.BuiltInLootTables; | ||
import net.minecraft.world.level.storage.loot.LootTable; | ||
import net.neoforged.neoforge.registries.DeferredHolder; | ||
|
||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.Locale; | ||
import java.util.Set; | ||
import java.util.function.BiConsumer; | ||
|
||
public class EnderBlockLootProvider extends BlockLootSubProvider { | ||
|
||
private final EnderBlockRegistry registry; | ||
|
||
public EnderBlockLootProvider(Set<Item> explosionResistant, EnderBlockRegistry registry) { | ||
super(explosionResistant, FeatureFlags.REGISTRY.allFlags()); | ||
this.registry = registry; | ||
} | ||
|
||
@Override | ||
protected void generate() { | ||
for (DeferredHolder<Block, ? extends Block> block : registry.getEntries()) { | ||
BiConsumer<EnderBlockLootProvider, Block> lootTable = ((EnderDeferredBlock<Block>) block).getLootTable(); | ||
if (lootTable != null) { | ||
lootTable.accept(this, block.get()); | ||
} | ||
} | ||
} | ||
|
||
//TODO why these 2 methods, can we join them? | ||
@Override | ||
public void generate(BiConsumer<ResourceLocation, LootTable.Builder> p_249322_) { | ||
this.generate(); | ||
Set<ResourceLocation> set = new HashSet<>(); | ||
|
||
for(DeferredHolder<Block, ? extends Block> block : registry.getEntries()) { | ||
if (block.get().isEnabled(this.enabledFeatures)) { | ||
ResourceLocation resourcelocation = block.get().getLootTable(); | ||
if (resourcelocation != BuiltInLootTables.EMPTY && set.add(resourcelocation)) { | ||
LootTable.Builder loottable$builder = this.map.remove(resourcelocation); | ||
if (loottable$builder == null) { | ||
throw new IllegalStateException( | ||
String.format(Locale.ROOT, "Missing loottable '%s' for '%s'", resourcelocation, BuiltInRegistries.BLOCK.getKey(block.get())) | ||
); | ||
} | ||
|
||
p_249322_.accept(resourcelocation, loottable$builder); | ||
} | ||
} | ||
} | ||
|
||
if (!this.map.isEmpty()) { | ||
throw new IllegalStateException("Created block loot tables for non-blocks: " + this.map.keySet()); | ||
} | ||
} | ||
|
||
@Override | ||
public void dropSelf(Block block) { | ||
super.dropSelf(block); | ||
} | ||
|
||
public void createDoor(Block block) { | ||
this.add(block, super::createDoorTable); | ||
} | ||
|
||
@Override | ||
public void add(Block p_250610_, LootTable.Builder p_249817_) { | ||
super.add(p_250610_, p_249817_); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/example/examplemod/data/EnderBlockStateProvider.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,30 @@ | ||
package com.example.examplemod.data; | ||
|
||
import com.example.examplemod.registry.EnderBlockRegistry; | ||
import com.example.examplemod.registry.EnderDeferredBlock; | ||
import net.minecraft.data.PackOutput; | ||
import net.minecraft.world.level.block.Block; | ||
import net.neoforged.neoforge.client.model.generators.BlockStateProvider; | ||
import net.neoforged.neoforge.common.data.ExistingFileHelper; | ||
import net.neoforged.neoforge.registries.DeferredHolder; | ||
|
||
import java.util.function.BiConsumer; | ||
|
||
public class EnderBlockStateProvider extends BlockStateProvider { | ||
private final EnderBlockRegistry registry; | ||
|
||
public EnderBlockStateProvider(PackOutput output, String modid, ExistingFileHelper exFileHelper, EnderBlockRegistry registry) { | ||
super(output, modid, exFileHelper); | ||
this.registry = registry; | ||
} | ||
|
||
@Override | ||
protected void registerStatesAndModels() { | ||
for (DeferredHolder<Block, ? extends Block> block : registry.getEntries()) { | ||
BiConsumer<BlockStateProvider, Block> blockstate = ((EnderDeferredBlock<Block>) block).getBlockStateProvider(); | ||
if (blockstate != null) { | ||
blockstate.accept(this, block.get()); | ||
} | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/com/example/examplemod/data/EnderDataProvider.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,43 @@ | ||
package com.example.examplemod.data; | ||
|
||
import com.example.examplemod.ExampleMod; | ||
import net.minecraft.data.CachedOutput; | ||
import net.minecraft.data.DataProvider; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class EnderDataProvider implements DataProvider { | ||
private final String modid; | ||
private final List<DataProvider> subProviders = new ArrayList<>(); | ||
private final static EnderDataProvider INSTANCE = new EnderDataProvider(ExampleMod.MODID); | ||
|
||
public EnderDataProvider(String modid) { | ||
this.modid = modid; | ||
} | ||
|
||
public static EnderDataProvider getInstance() { | ||
return INSTANCE; | ||
} | ||
|
||
public void addSubProvider(boolean include, DataProvider provider) { | ||
if (include) { | ||
subProviders.add(provider); | ||
} | ||
} | ||
|
||
@Override | ||
public CompletableFuture<?> run(CachedOutput pOutput) { | ||
List<CompletableFuture<?>> list = new ArrayList<>(); | ||
for (DataProvider provider : subProviders) { | ||
list.add(provider.run(pOutput)); | ||
} | ||
return CompletableFuture.allOf(list.toArray(CompletableFuture[]::new)); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "Ender IO Data (" + modid + ")"; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/main/java/com/example/examplemod/data/EnderItemModelProvider.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,59 @@ | ||
package com.example.examplemod.data; | ||
|
||
import com.example.examplemod.registry.EnderDeferredItem; | ||
import com.example.examplemod.registry.EnderItemRegistry; | ||
import net.minecraft.core.registries.BuiltInRegistries; | ||
import net.minecraft.data.PackOutput; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.level.ItemLike; | ||
import net.neoforged.neoforge.client.model.generators.ItemModelBuilder; | ||
import net.neoforged.neoforge.client.model.generators.ItemModelProvider; | ||
import net.neoforged.neoforge.client.model.generators.ModelFile; | ||
import net.neoforged.neoforge.common.data.ExistingFileHelper; | ||
import net.neoforged.neoforge.registries.DeferredHolder; | ||
|
||
import java.util.Objects; | ||
import java.util.function.BiConsumer; | ||
|
||
public class EnderItemModelProvider extends ItemModelProvider { | ||
private final EnderItemRegistry registry; | ||
|
||
public EnderItemModelProvider(PackOutput output, String modid, ExistingFileHelper existingFileHelper, EnderItemRegistry itemRegistry) { | ||
super(output, modid, existingFileHelper); | ||
this.registry = itemRegistry; | ||
} | ||
|
||
@Override | ||
protected void registerModels() { | ||
for (DeferredHolder<Item, ? extends Item> item : registry.getEntries()) { | ||
BiConsumer<EnderItemModelProvider, Item> modelProvider = ((EnderDeferredItem<? extends Item>) item).getModelProvider(); | ||
if (modelProvider != null) { | ||
modelProvider.accept(this, item.get()); | ||
} | ||
} | ||
} | ||
|
||
public ItemModelBuilder basicBlock(Item item) { | ||
return basicBlock(Objects.requireNonNull(BuiltInRegistries.ITEM.getKey(item))); | ||
} | ||
|
||
public ItemModelBuilder basicBlock(ResourceLocation item) { | ||
return getBuilder(item.toString()) | ||
.parent(new ModelFile.UncheckedModelFile("item/generated")) | ||
.texture("layer0", new ResourceLocation(item.getNamespace(), "block/" + item.getPath())); | ||
} | ||
|
||
public ItemModelBuilder basicItem(Item item, ResourceLocation texture) { | ||
return getBuilder(BuiltInRegistries.ITEM.getKey(item).toString()) | ||
.parent(new ModelFile.UncheckedModelFile("item/generated")) | ||
.texture("layer0", new ResourceLocation(texture.getNamespace(), "item/" + texture.getPath())); | ||
} | ||
|
||
public ResourceLocation itemTexture(ItemLike item) { | ||
return Objects.requireNonNull(BuiltInRegistries.ITEM.getKey(item.asItem())); | ||
} | ||
|
||
|
||
} | ||
|
44 changes: 44 additions & 0 deletions
44
src/main/java/com/example/examplemod/data/EnderLangProvider.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,44 @@ | ||
package com.example.examplemod.data; | ||
|
||
import com.example.examplemod.registry.EnderBlockRegistry; | ||
import com.example.examplemod.registry.EnderDeferredBlock; | ||
import com.example.examplemod.registry.EnderDeferredItem; | ||
import com.example.examplemod.registry.EnderItemRegistry; | ||
import net.minecraft.data.PackOutput; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.level.block.Block; | ||
import net.neoforged.neoforge.common.data.LanguageProvider; | ||
import net.neoforged.neoforge.registries.DeferredHolder; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
public class EnderLangProvider extends LanguageProvider { | ||
@Nullable | ||
private EnderBlockRegistry blocks; | ||
@Nullable | ||
private EnderItemRegistry items; | ||
|
||
public EnderLangProvider(PackOutput output, String modid, String locale, EnderBlockRegistry registry) { | ||
super(output, modid, locale); | ||
this.blocks = registry; | ||
} | ||
|
||
public EnderLangProvider(PackOutput output, String modid, String locale, EnderItemRegistry registry) { | ||
super(output, modid, locale); | ||
this.items = registry; | ||
} | ||
|
||
@Override | ||
protected void addTranslations() { | ||
if (blocks != null) { | ||
for (DeferredHolder<Block, ? extends Block> block : blocks.getEntries()) { | ||
this.add(block.get(), ((EnderDeferredBlock<Block>) block).getTranslation()); | ||
} | ||
} | ||
if (items != null) { | ||
for (DeferredHolder<Item, ? extends Item> item : items.getEntries()) { | ||
this.add(item.get(), ((EnderDeferredItem<Item>) item).getTranslation()); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.