Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/datagen/java/techguns2/datagen/BlockMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,25 @@ public BlockMetadata(TBlock block, ResourceLocation id)
.setRolls(ConstantValue.exactly(1f))
.add(LootItem.lootTableItem(this.block))
.when(ExplosionCondition.survivesExplosion()));
this.recipeMetadatas = new ArrayList<RecipeMetadata<?>>();
this.tags = new ArrayList<TagKey<Block>>();
this.itemTags = new ArrayList<TagKey<Item>>();
this.recipeMetadatas = new ArrayList<>();
this.tags = new ArrayList<>();
this.itemTags = new ArrayList<>();
}

@Override
public final CompletableFuture<List<LanguageMetadata>> fetchLanguageEntries()
public CompletableFuture<List<LanguageMetadata>> fetchLanguageEntries()
{
return CompletableFuture.completedFuture(ImmutableList.of(new LanguageMetadata(this.langId, this.langName)));
}

@Override
public final CompletableFuture<List<RecipeMetadata<?>>> fetchRecipes()
public CompletableFuture<List<RecipeMetadata<?>>> fetchRecipes()
{
return CompletableFuture.completedFuture(ImmutableList.copyOf(this.recipeMetadatas));
}

@Override
public final CompletableFuture<List<LootTableMetadata>> fetchLootTables()
public CompletableFuture<List<LootTableMetadata>> fetchLootTables()
{
return CompletableFuture.completedFuture(
ImmutableList.of(
Expand All @@ -91,7 +91,7 @@ public final CompletableFuture<List<LootTableMetadata>> fetchLootTables()
}

@Override
public final CompletableFuture<List<TagKey<?>>> fetchTags()
public CompletableFuture<List<TagKey<?>>> fetchTags()
{
ImmutableList.Builder<TagKey<?>> tags = ImmutableList.builder();
for (TagKey<Block> blockTag : this.tags)
Expand All @@ -109,7 +109,7 @@ public final CompletableFuture<List<TagKey<?>>> fetchTags()

public static <TBlock extends Block> BlockMetadata<TBlock> of(RegistryObject<TBlock> block)
{
return new BlockMetadata<TBlock>(block);
return new BlockMetadata<>(block);
}


Expand Down
11 changes: 4 additions & 7 deletions src/datagen/java/techguns2/datagen/DataGenerators.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraftforge.data.event.GatherDataEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import org.jetbrains.annotations.NotNull;
import techguns2.Techguns;
import techguns2.datagen.providers.IItemModelProvider;
import techguns2.datagen.providers.IRecipeMetadataProvider;
Expand All @@ -21,18 +22,14 @@
public class DataGenerators
{
@SubscribeEvent
public static void gatherData(GatherDataEvent event) throws IOException
public static void gatherData(@NotNull GatherDataEvent event) throws IOException
{
DataGenerator generator = event.getGenerator();
PackOutput packOutput = generator.getPackOutput();
ExistingFileHelper existingFileHelper = event.getExistingFileHelper();
CompletableFuture<HolderLookup.Provider> lookupProvider = event.getLookupProvider();

List<Object> possibleProviders = new ArrayList<>();
for (var itemMetadata : ItemMetadatas.getAll())
{
possibleProviders.add(itemMetadata);
}

List<Object> possibleProviders = new ArrayList<>(ItemMetadatas.getAll());

generator.addProvider(false, new ModRecipeProvider(packOutput,
possibleProviders
Expand Down
27 changes: 14 additions & 13 deletions src/datagen/java/techguns2/datagen/ItemMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.function.BiConsumer;
import java.util.function.Function;

import org.jetbrains.annotations.Nullable;

import com.google.common.collect.ImmutableList;

Expand All @@ -16,6 +15,8 @@
import net.minecraft.world.item.Item;
import net.minecraftforge.client.model.generators.ItemModelBuilder;
import net.minecraftforge.registries.RegistryObject;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import techguns2.Techguns;
import techguns2.datagen.providers.IItemModelProvider;
import techguns2.datagen.providers.ILangMetadataProvider;
Expand All @@ -34,7 +35,7 @@ public final class ItemMetadata<TItem extends Item> implements ILangMetadataProv
public final List<RecipeMetadata<?>> recipeMetadatas;
public final List<TagKey<Item>> tags;

public ItemMetadata(RegistryObject<TItem> registeredItem)
public ItemMetadata(@NotNull RegistryObject<TItem> registeredItem)
{
this(registeredItem.get(), registeredItem.getId());
}
Expand All @@ -45,49 +46,49 @@ public ItemMetadata(TItem item, ResourceLocation id)
this.id = id;
this.langId = Util.makeDescriptionId("item", id);
this.langName = this.langId;
this.recipeMetadatas = new ArrayList<RecipeMetadata<?>>();
this.tags = new ArrayList<TagKey<Item>>();
this.recipeMetadatas = new ArrayList<>();
this.tags = new ArrayList<>();
this.itemModelGenerator = null;
}

public final ItemMetadata<TItem> withLangName(String langName)
public ItemMetadata<TItem> withLangName(String langName)
{
this.langName = langName;
return this;
}

public final ItemMetadata<TItem> addRecipe(RecipeMetadata<?> recipeMetadata)
public ItemMetadata<TItem> addRecipe(RecipeMetadata<?> recipeMetadata)
{
this.recipeMetadatas.add(recipeMetadata);
return this;
}

public final ItemMetadata<TItem> addTag(TagKey<Item> tag)
public ItemMetadata<TItem> addTag(TagKey<Item> tag)
{
this.tags.add(tag);
return this;
}

@Override
public final CompletableFuture<List<LanguageMetadata>> fetchLanguageEntries()
public CompletableFuture<List<LanguageMetadata>> fetchLanguageEntries()
{
return CompletableFuture.completedFuture(ImmutableList.of(new LanguageMetadata(this.langId, this.langName)));
}

@Override
public final CompletableFuture<List<RecipeMetadata<?>>> fetchRecipes()
public CompletableFuture<List<RecipeMetadata<?>>> fetchRecipes()
{
return CompletableFuture.completedFuture(ImmutableList.copyOf(this.recipeMetadatas));
}

@Override
public final CompletableFuture<List<TagKey<?>>> fetchTags()
public CompletableFuture<List<TagKey<?>>> fetchTags()
{
return CompletableFuture.completedFuture(ImmutableList.copyOf(this.tags));
}

@Override
public final ItemModelBuilder fetchItemModel(IModelBuilderFactory<ItemModelBuilder> modelBuilderFactory)
public ItemModelBuilder fetchItemModel(IModelBuilderFactory<ItemModelBuilder> modelBuilderFactory)
{
String path = this.id.getPath();
ItemModelBuilder model = modelBuilderFactory.create(path);
Expand All @@ -106,11 +107,11 @@ public final ItemModelBuilder fetchItemModel(IModelBuilderFactory<ItemModelBuild

public static <TItem extends Item> ItemMetadata<TItem> of(RegistryObject<TItem> registeredItem)
{
return new ItemMetadata<TItem>(registeredItem);
return new ItemMetadata<>(registeredItem);
}

public static <TItem extends Item> ItemMetadata<TItem> of(TItem item, ResourceLocation id)
{
return new ItemMetadata<TItem>(item, id);
return new ItemMetadata<>(item, id);
}
}
2 changes: 1 addition & 1 deletion src/datagen/java/techguns2/datagen/ItemMetadatas.java
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public final class ItemMetadatas

private static final Map<ResourceLocation, ItemMetadata<?>> METADATA_MAP;

public static final Collection<ItemMetadata<?>> getAll()
public static Collection<ItemMetadata<?>> getAll()
{
return METADATA_MAP.values();
}
Expand Down
11 changes: 1 addition & 10 deletions src/datagen/java/techguns2/datagen/LanguageMetadata.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
package techguns2.datagen;

public final class LanguageMetadata
{
public final String id;
public final String value;

public LanguageMetadata(String id, String value)
{
this.id = id;
this.value = value;
}
public record LanguageMetadata(String id, String value) {
}
13 changes: 1 addition & 12 deletions src/datagen/java/techguns2/datagen/LootTableMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,5 @@
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSet;

public final class LootTableMetadata
{
public final ResourceLocation id;
public final LootTable.Builder table;
public final LootContextParamSet context;

public LootTableMetadata(ResourceLocation id, LootTable.Builder table, LootContextParamSet context)
{
this.id = id;
this.table = table;
this.context = context;
}
public record LootTableMetadata(ResourceLocation id, LootTable.Builder table, LootContextParamSet context) {
}
Loading