diff --git a/src/datagen/java/techguns2/datagen/BlockMetadata.java b/src/datagen/java/techguns2/datagen/BlockMetadata.java index f90ee104..85055802 100644 --- a/src/datagen/java/techguns2/datagen/BlockMetadata.java +++ b/src/datagen/java/techguns2/datagen/BlockMetadata.java @@ -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>(); - this.tags = new ArrayList>(); - this.itemTags = new ArrayList>(); + this.recipeMetadatas = new ArrayList<>(); + this.tags = new ArrayList<>(); + this.itemTags = new ArrayList<>(); } @Override - public final CompletableFuture> fetchLanguageEntries() + public CompletableFuture> fetchLanguageEntries() { return CompletableFuture.completedFuture(ImmutableList.of(new LanguageMetadata(this.langId, this.langName))); } @Override - public final CompletableFuture>> fetchRecipes() + public CompletableFuture>> fetchRecipes() { return CompletableFuture.completedFuture(ImmutableList.copyOf(this.recipeMetadatas)); } @Override - public final CompletableFuture> fetchLootTables() + public CompletableFuture> fetchLootTables() { return CompletableFuture.completedFuture( ImmutableList.of( @@ -91,7 +91,7 @@ public final CompletableFuture> fetchLootTables() } @Override - public final CompletableFuture>> fetchTags() + public CompletableFuture>> fetchTags() { ImmutableList.Builder> tags = ImmutableList.builder(); for (TagKey blockTag : this.tags) @@ -109,7 +109,7 @@ public final CompletableFuture>> fetchTags() public static BlockMetadata of(RegistryObject block) { - return new BlockMetadata(block); + return new BlockMetadata<>(block); } diff --git a/src/datagen/java/techguns2/datagen/DataGenerators.java b/src/datagen/java/techguns2/datagen/DataGenerators.java index ae4a31d7..89d0b310 100644 --- a/src/datagen/java/techguns2/datagen/DataGenerators.java +++ b/src/datagen/java/techguns2/datagen/DataGenerators.java @@ -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; @@ -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 lookupProvider = event.getLookupProvider(); - - List possibleProviders = new ArrayList<>(); - for (var itemMetadata : ItemMetadatas.getAll()) - { - possibleProviders.add(itemMetadata); - } + + List possibleProviders = new ArrayList<>(ItemMetadatas.getAll()); generator.addProvider(false, new ModRecipeProvider(packOutput, possibleProviders diff --git a/src/datagen/java/techguns2/datagen/ItemMetadata.java b/src/datagen/java/techguns2/datagen/ItemMetadata.java index 90392d20..e6fc17f0 100644 --- a/src/datagen/java/techguns2/datagen/ItemMetadata.java +++ b/src/datagen/java/techguns2/datagen/ItemMetadata.java @@ -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; @@ -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; @@ -34,7 +35,7 @@ public final class ItemMetadata implements ILangMetadataProv public final List> recipeMetadatas; public final List> tags; - public ItemMetadata(RegistryObject registeredItem) + public ItemMetadata(@NotNull RegistryObject registeredItem) { this(registeredItem.get(), registeredItem.getId()); } @@ -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>(); - this.tags = new ArrayList>(); + this.recipeMetadatas = new ArrayList<>(); + this.tags = new ArrayList<>(); this.itemModelGenerator = null; } - public final ItemMetadata withLangName(String langName) + public ItemMetadata withLangName(String langName) { this.langName = langName; return this; } - public final ItemMetadata addRecipe(RecipeMetadata recipeMetadata) + public ItemMetadata addRecipe(RecipeMetadata recipeMetadata) { this.recipeMetadatas.add(recipeMetadata); return this; } - public final ItemMetadata addTag(TagKey tag) + public ItemMetadata addTag(TagKey tag) { this.tags.add(tag); return this; } @Override - public final CompletableFuture> fetchLanguageEntries() + public CompletableFuture> fetchLanguageEntries() { return CompletableFuture.completedFuture(ImmutableList.of(new LanguageMetadata(this.langId, this.langName))); } @Override - public final CompletableFuture>> fetchRecipes() + public CompletableFuture>> fetchRecipes() { return CompletableFuture.completedFuture(ImmutableList.copyOf(this.recipeMetadatas)); } @Override - public final CompletableFuture>> fetchTags() + public CompletableFuture>> fetchTags() { return CompletableFuture.completedFuture(ImmutableList.copyOf(this.tags)); } @Override - public final ItemModelBuilder fetchItemModel(IModelBuilderFactory modelBuilderFactory) + public ItemModelBuilder fetchItemModel(IModelBuilderFactory modelBuilderFactory) { String path = this.id.getPath(); ItemModelBuilder model = modelBuilderFactory.create(path); @@ -106,11 +107,11 @@ public final ItemModelBuilder fetchItemModel(IModelBuilderFactory ItemMetadata of(RegistryObject registeredItem) { - return new ItemMetadata(registeredItem); + return new ItemMetadata<>(registeredItem); } public static ItemMetadata of(TItem item, ResourceLocation id) { - return new ItemMetadata(item, id); + return new ItemMetadata<>(item, id); } } diff --git a/src/datagen/java/techguns2/datagen/ItemMetadatas.java b/src/datagen/java/techguns2/datagen/ItemMetadatas.java index 84f2514d..0d5800ef 100644 --- a/src/datagen/java/techguns2/datagen/ItemMetadatas.java +++ b/src/datagen/java/techguns2/datagen/ItemMetadatas.java @@ -380,7 +380,7 @@ public final class ItemMetadatas private static final Map> METADATA_MAP; - public static final Collection> getAll() + public static Collection> getAll() { return METADATA_MAP.values(); } diff --git a/src/datagen/java/techguns2/datagen/LanguageMetadata.java b/src/datagen/java/techguns2/datagen/LanguageMetadata.java index c8402188..03ea80b6 100644 --- a/src/datagen/java/techguns2/datagen/LanguageMetadata.java +++ b/src/datagen/java/techguns2/datagen/LanguageMetadata.java @@ -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) { } diff --git a/src/datagen/java/techguns2/datagen/LootTableMetadata.java b/src/datagen/java/techguns2/datagen/LootTableMetadata.java index 406e62c0..d9607878 100644 --- a/src/datagen/java/techguns2/datagen/LootTableMetadata.java +++ b/src/datagen/java/techguns2/datagen/LootTableMetadata.java @@ -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) { } diff --git a/src/datagen/java/techguns2/datagen/RecipeMetadata.java b/src/datagen/java/techguns2/datagen/RecipeMetadata.java index e8ce9148..ccd14d8c 100644 --- a/src/datagen/java/techguns2/datagen/RecipeMetadata.java +++ b/src/datagen/java/techguns2/datagen/RecipeMetadata.java @@ -6,12 +6,7 @@ import javax.annotation.Nullable; -import net.minecraft.data.recipes.FinishedRecipe; -import net.minecraft.data.recipes.RecipeBuilder; -import net.minecraft.data.recipes.RecipeCategory; -import net.minecraft.data.recipes.ShapedRecipeBuilder; -import net.minecraft.data.recipes.ShapelessRecipeBuilder; -import net.minecraft.data.recipes.SimpleCookingRecipeBuilder; +import net.minecraft.data.recipes.*; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; @@ -22,6 +17,9 @@ import net.minecraft.world.level.ItemLike; import net.minecraftforge.common.crafting.ConditionalRecipe; import net.minecraftforge.registries.RegistryObject; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; + import techguns2.machine.alloy_furnace.AlloyFurnaceRecipe; import techguns2.machine.ammo_press.AmmoPressRecipe; import techguns2.machine.charging_station.SimpleChargingStationRecipe; @@ -47,12 +45,12 @@ public RecipeMetadata(ResourceLocation id, Supplier recipeBuilderFactory, BiC this.recipeSaver = recipeSaver; } - public final void save(Consumer writer) + public void save(Consumer writer) { this.recipeSaver.accept(this, writer); } - public final T setupRecipeBuilder() + public T setupRecipeBuilder() { if (this.recipeBuilder == null) { @@ -62,7 +60,8 @@ public final T setupRecipeBuilder() return this.recipeBuilder; } - public static RecipeMetadata shapeless( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata shapeless( ResourceLocation id, RecipeCategory recipeCategory, ItemLike result, @@ -75,7 +74,8 @@ public static RecipeMetadata shapeless( }); } - public static RecipeMetadata shapeless( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata shapeless( ResourceLocation id, RecipeCategory recipeCategory, RegistryObject resultObject, @@ -88,7 +88,8 @@ public static RecipeMetadata shapeless( }); } - public static RecipeMetadata shapeless( + @Contract(value = "_, _, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata shapeless( ResourceLocation id, RecipeCategory recipeCategory, ItemLike result, @@ -102,7 +103,8 @@ public static RecipeMetadata shapeless( }); } - public static RecipeMetadata shapeless( + @Contract(value = "_, _, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata shapeless( ResourceLocation id, RecipeCategory recipeCategory, RegistryObject resultObject, @@ -116,7 +118,8 @@ public static RecipeMetadata shapeless( }); } - public static RecipeMetadata shaped( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata shaped( ResourceLocation id, RecipeCategory recipeCategory, ItemLike result, @@ -129,7 +132,8 @@ public static RecipeMetadata shaped( }); } - public static RecipeMetadata shaped( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata shaped( ResourceLocation id, RecipeCategory recipeCategory, RegistryObject resultObject, @@ -142,7 +146,8 @@ public static RecipeMetadata shaped( }); } - public static RecipeMetadata shaped( + @Contract(value = "_, _, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata shaped( ResourceLocation id, RecipeCategory recipeCategory, ItemLike result, @@ -156,7 +161,8 @@ public static RecipeMetadata shaped( }); } - public static RecipeMetadata shaped( + @Contract(value = "_, _, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata shaped( ResourceLocation id, RecipeCategory recipeCategory, RegistryObject resultObject, @@ -171,7 +177,8 @@ public static RecipeMetadata shaped( } - public static RecipeMetadata genericCooking( + @Contract(value = "_, _, _, _, _, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata genericCooking( ResourceLocation id, Ingredient input, RecipeCategory category, @@ -194,7 +201,8 @@ public static RecipeMetadata genericCooking( }); } - public static RecipeMetadata campfireCooking( + @Contract(value = "_, _, _, _, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata campfireCooking( ResourceLocation id, Ingredient input, RecipeCategory category, @@ -215,7 +223,8 @@ public static RecipeMetadata campfireCooking( }); } - public static RecipeMetadata blasting( + @Contract(value = "_, _, _, _, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata blasting( ResourceLocation id, Ingredient input, RecipeCategory category, @@ -236,7 +245,8 @@ public static RecipeMetadata blasting( }); } - public static RecipeMetadata smelting( + @Contract(value = "_, _, _, _, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata smelting( ResourceLocation id, Ingredient input, RecipeCategory category, @@ -257,7 +267,8 @@ public static RecipeMetadata smelting( }); } - public static RecipeMetadata smoking( + @Contract(value = "_, _, _, _, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata smoking( ResourceLocation id, Ingredient input, RecipeCategory category, @@ -278,7 +289,8 @@ public static RecipeMetadata smoking( }); } - public static RecipeMetadata ammoPress( + @Contract(value = "_, _ -> new", pure = true) + public static @NotNull RecipeMetadata ammoPress( ResourceLocation id, Consumer recipeBuilder) { @@ -289,7 +301,8 @@ public static RecipeMetadata ammoPress( }); } - public static RecipeMetadata ammoPress( + @Contract(value = "_, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata ammoPress( ResourceLocation id, ItemLike result, Consumer recipeBuilder) @@ -302,7 +315,8 @@ public static RecipeMetadata ammoPress( }); } - public static RecipeMetadata ammoPress( + @Contract(value = "_, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata ammoPress( ResourceLocation id, RegistryObject resultObject, Consumer recipeBuilder) @@ -315,7 +329,8 @@ public static RecipeMetadata ammoPress( }); } - public static RecipeMetadata ammoPress( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata ammoPress( ResourceLocation id, ItemLike result, @Nullable CompoundTag nbt, @@ -329,7 +344,8 @@ public static RecipeMetadata ammoPress( }); } - public static RecipeMetadata ammoPress( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata ammoPress( ResourceLocation id, RegistryObject resultObject, @Nullable CompoundTag nbt, @@ -343,7 +359,8 @@ public static RecipeMetadata ammoPress( }); } - public static RecipeMetadata ammoPress( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata ammoPress( ResourceLocation id, ItemLike result, int amount, @@ -357,7 +374,8 @@ public static RecipeMetadata ammoPress( }); } - public static RecipeMetadata ammoPress( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata ammoPress( ResourceLocation id, RegistryObject resultObject, int amount, @@ -371,7 +389,8 @@ public static RecipeMetadata ammoPress( }); } - public static RecipeMetadata ammoPress( + @Contract(value = "_, _, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata ammoPress( ResourceLocation id, ItemLike result, int amount, @@ -386,7 +405,8 @@ public static RecipeMetadata ammoPress( }); } - public static RecipeMetadata ammoPress( + @Contract(value = "_, _, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata ammoPress( ResourceLocation id, RegistryObject resultObject, int amount, @@ -401,7 +421,8 @@ public static RecipeMetadata ammoPress( }); } - public static RecipeMetadata alloyFurnace( + @Contract(value = "_, _ -> new", pure = true) + public static @NotNull RecipeMetadata alloyFurnace( ResourceLocation id, Consumer recipeBuilder) { @@ -412,7 +433,8 @@ public static RecipeMetadata alloyFurnace( }); } - public static RecipeMetadata alloyFurnace( + @Contract(value = "_, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata alloyFurnace( ResourceLocation id, ItemLike result, Consumer recipeBuilder) @@ -425,7 +447,8 @@ public static RecipeMetadata alloyFurnace( }); } - public static RecipeMetadata alloyFurnace( + @Contract(value = "_, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata alloyFurnace( ResourceLocation id, RegistryObject resultObject, Consumer recipeBuilder) @@ -438,7 +461,8 @@ public static RecipeMetadata alloyFurnace( }); } - public static RecipeMetadata alloyFurnace( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata alloyFurnace( ResourceLocation id, ItemLike result, @Nullable CompoundTag nbt, @@ -452,7 +476,8 @@ public static RecipeMetadata alloyFurnace( }); } - public static RecipeMetadata alloyFurnace( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata alloyFurnace( ResourceLocation id, RegistryObject resultObject, @Nullable CompoundTag nbt, @@ -466,7 +491,8 @@ public static RecipeMetadata alloyFurnace( }); } - public static RecipeMetadata alloyFurnace( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata alloyFurnace( ResourceLocation id, ItemLike result, int amount, @@ -480,7 +506,8 @@ public static RecipeMetadata alloyFurnace( }); } - public static RecipeMetadata alloyFurnace( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata alloyFurnace( ResourceLocation id, RegistryObject resultObject, int amount, @@ -494,7 +521,8 @@ public static RecipeMetadata alloyFurnace( }); } - public static RecipeMetadata alloyFurnace( + @Contract(value = "_, _, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata alloyFurnace( ResourceLocation id, ItemLike result, int amount, @@ -509,7 +537,8 @@ public static RecipeMetadata alloyFurnace( }); } - public static RecipeMetadata alloyFurnace( + @Contract(value = "_, _, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata alloyFurnace( ResourceLocation id, RegistryObject resultObject, int amount, @@ -524,7 +553,8 @@ public static RecipeMetadata alloyFurnace( }); } - public static RecipeMetadata charging( + @Contract(value = "_, _ -> new", pure = true) + public static @NotNull RecipeMetadata charging( ResourceLocation id, Consumer recipeBuilder) { @@ -535,7 +565,8 @@ public static RecipeMetadata charging( }); } - public static RecipeMetadata charging( + @Contract(value = "_, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata charging( ResourceLocation id, ItemLike result, Consumer recipeBuilder) @@ -548,7 +579,8 @@ public static RecipeMetadata charging( }); } - public static RecipeMetadata charging( + @Contract(value = "_, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata charging( ResourceLocation id, RegistryObject resultObject, Consumer recipeBuilder) @@ -561,7 +593,8 @@ public static RecipeMetadata charging( }); } - public static RecipeMetadata charging( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata charging( ResourceLocation id, ItemLike result, @Nullable CompoundTag nbt, @@ -575,7 +608,8 @@ public static RecipeMetadata charging( }); } - public static RecipeMetadata charging( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata charging( ResourceLocation id, RegistryObject resultObject, @Nullable CompoundTag nbt, @@ -589,7 +623,8 @@ public static RecipeMetadata charging( }); } - public static RecipeMetadata charging( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata charging( ResourceLocation id, ItemLike result, int amount, @@ -603,7 +638,8 @@ public static RecipeMetadata charging( }); } - public static RecipeMetadata charging( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata charging( ResourceLocation id, RegistryObject resultObject, int amount, @@ -617,7 +653,8 @@ public static RecipeMetadata charging( }); } - public static RecipeMetadata charging( + @Contract(value = "_, _, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata charging( ResourceLocation id, ItemLike result, int amount, @@ -632,7 +669,8 @@ public static RecipeMetadata charging( }); } - public static RecipeMetadata charging( + @Contract(value = "_, _, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata charging( ResourceLocation id, RegistryObject resultObject, int amount, @@ -647,7 +685,8 @@ public static RecipeMetadata charging( }); } - public static RecipeMetadata chemicalLaboratory( + @Contract(value = "_, _ -> new", pure = true) + public static @NotNull RecipeMetadata chemicalLaboratory( ResourceLocation id, Consumer recipeBuilder) { @@ -658,7 +697,8 @@ public static RecipeMetadata chemicalLaborator }); } - public static RecipeMetadata fabricator( + @Contract(value = "_, _ -> new", pure = true) + public static @NotNull RecipeMetadata fabricator( ResourceLocation id, Consumer recipeBuilder) { @@ -669,7 +709,8 @@ public static RecipeMetadata fabricator( }); } - public static RecipeMetadata fabricator( + @Contract(value = "_, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata fabricator( ResourceLocation id, ItemLike result, Consumer recipeBuilder) @@ -682,7 +723,8 @@ public static RecipeMetadata fabricator( }); } - public static RecipeMetadata fabricator( + @Contract(value = "_, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata fabricator( ResourceLocation id, RegistryObject resultObject, Consumer recipeBuilder) @@ -695,7 +737,8 @@ public static RecipeMetadata fabricator( }); } - public static RecipeMetadata fabricator( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata fabricator( ResourceLocation id, ItemLike result, @Nullable CompoundTag nbt, @@ -709,7 +752,8 @@ public static RecipeMetadata fabricator( }); } - public static RecipeMetadata fabricator( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata fabricator( ResourceLocation id, RegistryObject resultObject, @Nullable CompoundTag nbt, @@ -723,7 +767,8 @@ public static RecipeMetadata fabricator( }); } - public static RecipeMetadata fabricator( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata fabricator( ResourceLocation id, ItemLike result, int amount, @@ -737,7 +782,8 @@ public static RecipeMetadata fabricator( }); } - public static RecipeMetadata fabricator( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata fabricator( ResourceLocation id, RegistryObject resultObject, int amount, @@ -751,7 +797,8 @@ public static RecipeMetadata fabricator( }); } - public static RecipeMetadata fabricator( + @Contract(value = "_, _, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata fabricator( ResourceLocation id, ItemLike result, int amount, @@ -766,7 +813,8 @@ public static RecipeMetadata fabricator( }); } - public static RecipeMetadata fabricator( + @Contract(value = "_, _, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata fabricator( ResourceLocation id, RegistryObject resultObject, int amount, @@ -781,7 +829,8 @@ public static RecipeMetadata fabricator( }); } - public static RecipeMetadata grinder( + @Contract(value = "_, _ -> new", pure = true) + public static @NotNull RecipeMetadata grinder( ResourceLocation id, Consumer recipeBuilder) { @@ -792,7 +841,8 @@ public static RecipeMetadata grinder( }); } - public static RecipeMetadata grinder( + @Contract(value = "_, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata grinder( ResourceLocation id, ItemLike inputItem, Consumer recipeBuilder) @@ -805,7 +855,8 @@ public static RecipeMetadata grinder( }); } - public static RecipeMetadata grinder( + @Contract(value = "_, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata grinder( ResourceLocation id, RegistryObject inputItemObject, Consumer recipeBuilder) @@ -818,7 +869,8 @@ public static RecipeMetadata grinder( }); } - public static RecipeMetadata grinder( + @Contract(value = "_, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata grinder( ResourceLocation id, TagKey inputItemTag, Consumer recipeBuilder) @@ -831,7 +883,8 @@ public static RecipeMetadata grinder( }); } - public static RecipeMetadata grinderChanced( + @Contract(value = "_, _ -> new", pure = true) + public static @NotNull RecipeMetadata grinderChanced( ResourceLocation id, Consumer recipeBuilder) { @@ -842,7 +895,8 @@ public static RecipeMetadata grinderChanced( }); } - public static RecipeMetadata grinderChanced( + @Contract(value = "_, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata grinderChanced( ResourceLocation id, ItemLike inputItem, Consumer recipeBuilder) @@ -855,7 +909,8 @@ public static RecipeMetadata grinderChanced( }); } - public static RecipeMetadata grinderChanced( + @Contract(value = "_, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata grinderChanced( ResourceLocation id, RegistryObject inputItemObject, Consumer recipeBuilder) @@ -868,7 +923,8 @@ public static RecipeMetadata grinderChanced( }); } - public static RecipeMetadata grinderChanced( + @Contract(value = "_, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata grinderChanced( ResourceLocation id, TagKey inputItemTag, Consumer recipeBuilder) @@ -881,7 +937,8 @@ public static RecipeMetadata grinderChanced( }); } - public static RecipeMetadata metalPress( + @Contract(value = "_, _ -> new", pure = true) + public static @NotNull RecipeMetadata metalPress( ResourceLocation id, Consumer recipeBuilder) { @@ -892,7 +949,8 @@ public static RecipeMetadata metalPress( }); } - public static RecipeMetadata metalPress( + @Contract(value = "_, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata metalPress( ResourceLocation id, ItemLike result, Consumer recipeBuilder) @@ -905,7 +963,8 @@ public static RecipeMetadata metalPress( }); } - public static RecipeMetadata metalPress( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata metalPress( ResourceLocation id, ItemLike result, @Nullable @@ -920,7 +979,8 @@ public static RecipeMetadata metalPress( }); } - public static RecipeMetadata metalPress( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata metalPress( ResourceLocation id, ItemLike result, int count, @@ -934,7 +994,8 @@ public static RecipeMetadata metalPress( }); } - public static RecipeMetadata metalPress( + @Contract(value = "_, _, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata metalPress( ResourceLocation id, ItemLike result, int count, @@ -950,7 +1011,8 @@ public static RecipeMetadata metalPress( }); } - public static RecipeMetadata metalPress( + @Contract(value = "_, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata metalPress( ResourceLocation id, RegistryObject resultObject, Consumer recipeBuilder) @@ -963,7 +1025,8 @@ public static RecipeMetadata metalPress( }); } - public static RecipeMetadata metalPress( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata metalPress( ResourceLocation id, RegistryObject resultObject, @Nullable @@ -978,7 +1041,8 @@ public static RecipeMetadata metalPress( }); } - public static RecipeMetadata metalPress( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata metalPress( ResourceLocation id, RegistryObject resultObject, int count, @@ -992,7 +1056,8 @@ public static RecipeMetadata metalPress( }); } - public static RecipeMetadata metalPress( + @Contract(value = "_, _, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata metalPress( ResourceLocation id, RegistryObject resultObject, int count, @@ -1008,7 +1073,8 @@ public static RecipeMetadata metalPress( }); } - public static RecipeMetadata reactionChamber( + @Contract(value = "_, _ -> new", pure = true) + public static @NotNull RecipeMetadata reactionChamber( ResourceLocation id, Consumer recipeBuilder) { @@ -1019,7 +1085,8 @@ public static RecipeMetadata reactionChamber( }); } - public static RecipeMetadata reactionChamber( + @Contract(value = "_, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata reactionChamber( ResourceLocation id, ItemLike result, Consumer recipeBuilder) @@ -1032,7 +1099,8 @@ public static RecipeMetadata reactionChamber( }); } - public static RecipeMetadata reactionChamber( + @Contract(value = "_, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata reactionChamber( ResourceLocation id, RegistryObject resultObject, Consumer recipeBuilder) @@ -1045,7 +1113,8 @@ public static RecipeMetadata reactionChamber( }); } - public static RecipeMetadata reactionChamber( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata reactionChamber( ResourceLocation id, ItemLike result, @Nullable CompoundTag nbt, @@ -1059,7 +1128,8 @@ public static RecipeMetadata reactionChamber( }); } - public static RecipeMetadata reactionChamber( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata reactionChamber( ResourceLocation id, RegistryObject resultObject, @Nullable CompoundTag nbt, @@ -1073,7 +1143,8 @@ public static RecipeMetadata reactionChamber( }); } - public static RecipeMetadata reactionChamber( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata reactionChamber( ResourceLocation id, ItemLike result, int amount, @@ -1087,7 +1158,8 @@ public static RecipeMetadata reactionChamber( }); } - public static RecipeMetadata reactionChamber( + @Contract(value = "_, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata reactionChamber( ResourceLocation id, RegistryObject resultObject, int amount, @@ -1101,7 +1173,8 @@ public static RecipeMetadata reactionChamber( }); } - public static RecipeMetadata reactionChamber( + @Contract(value = "_, _, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata reactionChamber( ResourceLocation id, ItemLike result, int amount, @@ -1116,7 +1189,8 @@ public static RecipeMetadata reactionChamber( }); } - public static RecipeMetadata reactionChamber( + @Contract(value = "_, _, _, _, _ -> new", pure = true) + public static @NotNull RecipeMetadata reactionChamber( ResourceLocation id, RegistryObject resultObject, int amount, @@ -1131,26 +1205,28 @@ public static RecipeMetadata reactionChamber( }); } - public static RecipeMetadata fromBuilder(ResourceLocation id, Supplier builderFactory) + @Contract(value = "_, _ -> new", pure = true) + public static @NotNull RecipeMetadata fromBuilder(ResourceLocation id, Supplier builderFactory) { - return new RecipeMetadata(id, builderFactory, RecipeMetadata::recipeBuilderSaver); + return new RecipeMetadata<>(id, builderFactory, RecipeMetadata::recipeBuilderSaver); } - public static RecipeMetadata fromConditional(ResourceLocation id, Consumer recipeBuilder) + @Contract(value = "_, _ -> new", pure = true) + public static @NotNull RecipeMetadata fromConditional(ResourceLocation id, Consumer recipeBuilder) { - return new RecipeMetadata(id, () -> { + return new RecipeMetadata<>(id, () -> { var builder = new ConditionalRecipe.Builder(); recipeBuilder.accept(builder); return builder; }, RecipeMetadata::conditionalRecipeSaver); } - private static void conditionalRecipeSaver(RecipeMetadata metadata, Consumer writer) + private static void conditionalRecipeSaver(@NotNull RecipeMetadata metadata, Consumer writer) { metadata.setupRecipeBuilder().build(writer, metadata.id); } - private static void recipeBuilderSaver(RecipeMetadata metadata, Consumer writer) + private static void recipeBuilderSaver(@NotNull RecipeMetadata metadata, Consumer writer) { metadata.setupRecipeBuilder().save(writer, metadata.id); } diff --git a/src/datagen/java/techguns2/datagen/recipes/ModRecipeProvider.java b/src/datagen/java/techguns2/datagen/recipes/ModRecipeProvider.java index c72fe14f..94d35c98 100644 --- a/src/datagen/java/techguns2/datagen/recipes/ModRecipeProvider.java +++ b/src/datagen/java/techguns2/datagen/recipes/ModRecipeProvider.java @@ -25,6 +25,7 @@ import net.minecraftforge.common.crafting.ConditionalRecipe; import net.minecraftforge.common.crafting.conditions.NotCondition; import net.minecraftforge.common.crafting.conditions.TagEmptyCondition; +import org.jetbrains.annotations.NotNull; import techguns2.TGItems; import techguns2.Techguns; import techguns2.datagen.RecipeMetadata; @@ -44,18 +45,18 @@ public ModRecipeProvider(PackOutput output, Stream meta { super(output); - this._metadatas = new ArrayList>(); + this._metadatas = new ArrayList<>(); this._metadataProviders = metadataProviders.toList(); } @Override - public final CompletableFuture run(CachedOutput output) + public final @NotNull CompletableFuture run(@NotNull CachedOutput output) { return this.collectMetadata() .thenCompose((x) -> super.run(output)); } - private final CompletableFuture collectMetadata() + private CompletableFuture collectMetadata() { CompletableFuture completableFuture = CompletableFuture.runAsync(() -> { this._metadatas.clear(); @@ -66,18 +67,13 @@ private final CompletableFuture collectMetadata() { completableFuture = completableFuture .thenComposeAsync(x -> metadataProvider.fetchRecipes()) - .thenAccept(recipeMetadatas -> { - for (RecipeMetadata recipeMetadata : recipeMetadatas) - { - this._metadatas.add(recipeMetadata); - } - }); + .thenAccept(this._metadatas::addAll); } return completableFuture; } - private final void collectBuiltInMetadatas() + private void collectBuiltInMetadatas() { { ResourceLocation id = new ResourceLocation(Techguns.MODID, "gunpowder_in_chemical_laboratory"); @@ -208,7 +204,7 @@ private final void collectBuiltInMetadatas() } @Override - protected final void buildRecipes(Consumer builder) + protected final void buildRecipes(@NotNull Consumer builder) { for (RecipeMetadata recipeMetadata : this._metadatas) { diff --git a/src/main/java/techguns2/TGAmmoGroups.java b/src/main/java/techguns2/TGAmmoGroups.java index 2e13cce6..0af94aaf 100644 --- a/src/main/java/techguns2/TGAmmoGroups.java +++ b/src/main/java/techguns2/TGAmmoGroups.java @@ -10,7 +10,7 @@ public final class TGAmmoGroups implements TGInitializer { protected TGAmmoGroups() { } - + @SuppressWarnings("deprecation") @Override public final void setup(IEventBus eventBus) @@ -24,7 +24,7 @@ public final void setup(IEventBus eventBus) } private static final DeferredRegister REGISTER = DeferredRegister.create(TGCustomRegistries.AMMO_GROUPS, Techguns.MODID); - + public static final RegistryObject STONE_BULLETS = REGISTER.register("stone_bullets", () -> { AmmoGroup group = new AmmoGroup(); group.addAmmo(TGAmmo.STONE_BULLETS); @@ -120,7 +120,7 @@ public final void setup(IEventBus eventBus) group.addAmmo(TGAmmo.EXPLOSIVE_AS50_ROUND_MAGAZINE); return group; }); - public static final RegistryObject ADVANCED_ROUND_MAGAZINE = REGISTER.register("as50_round_magazine", () -> { + public static final RegistryObject ADVANCED_ROUND_MAGAZINE = REGISTER.register("advanced_round_magazine", () -> { AmmoGroup group = new AmmoGroup(); group.addAmmo(TGAmmo.ADVANCED_ROUND_MAGAZINE); return group; diff --git a/src/main/java/techguns2/TGBlockEntityTypes.java b/src/main/java/techguns2/TGBlockEntityTypes.java index f315af04..7c6d00ea 100644 --- a/src/main/java/techguns2/TGBlockEntityTypes.java +++ b/src/main/java/techguns2/TGBlockEntityTypes.java @@ -39,18 +39,18 @@ protected TGBlockEntityTypes() public final void setup(IEventBus eventBus) { REGISTER.register(eventBus); - + eventBus.addListener(TGBlockEntityTypes::registerEntityRendererLayers); eventBus.addListener(TGBlockEntityTypes::registerEntityRenderers); } - + private static final DeferredRegister> REGISTER = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, Techguns.MODID); - + public static final RegistryObject> BIO_BLOB = register("bio_blob", BioBlobBlockEntity::new, null, TGBlocks.BIO_BLOB); - + public static final RegistryObject> NPC_TURRET = register("turret", NPCTurretBlockEntity::new, null, TGBlocks.TURRET); public static final RegistryObject> AMMO_PRESS = register("ammo_press", AmmoPressBlockEntity::new, null, TGBlocks.AMMO_PRESS); - public static final RegistryObject> GRINDER = register("ammo_press", GrinderBlockEntity::new, null, TGBlocks.GRINDER); + public static final RegistryObject> GRINDER = register("grinder", GrinderBlockEntity::new, null, TGBlocks.GRINDER); public static final RegistryObject> METAL_PRESS = register("metal_press", MetalPressBlockEntity::new, null, TGBlocks.METAL_PRESS); public static final RegistryObject> ALLOY_FURNACE = register("alloy_furnace", AlloyFurnaceBlockEntity::new, null, TGBlocks.ALLOY_FURNACE); public static final RegistryObject> CHEMICAL_LABORATORY = register("chemical_laboratory", ChemicalLaboratoryBlockEntity::new, null, TGBlocks.CHEMICAL_LABORATORY); @@ -59,7 +59,7 @@ public final void setup(IEventBus eventBus) public static final RegistryObject> REACTION_CHAMBER_CONTROLLER = register("reaction_chamber_controller", ReactionChamberControllerBlockEntity::new, null, TGBlocks.REACTION_CHAMBER_CONTROLLER); public static final RegistryObject> REACTION_CHAMBER_PART = register("reaction_chamber_part", ReactionChamberPartBlockEntity::new, null, TGBlocks.REACTION_CHAMBER_PART); public static final RegistryObject> CHARGING_STATION = register("charging_station", ChargingStationBlockEntity::new, null, TGBlocks.CHARGING_STATION); - + private static RegistryObject> register( String name, BlockEntitySupplier blockEntitySupplier, @@ -69,12 +69,12 @@ private static RegistryObject> regist { return REGISTER.register(name, () -> BlockEntityType.Builder.of(blockEntitySupplier, blockSupplier.get()).build(dataFixerType)); } - + private static void registerEntityRendererLayers(EntityRenderersEvent.RegisterLayerDefinitions registerLayerDefinitionsEvent) { registerLayerDefinitionsEvent.registerLayerDefinition(AmmoPressRenderer.LAYER_LOCATION, AmmoPressRenderer::createLayer); } - + private static void registerEntityRenderers(EntityRenderersEvent.RegisterRenderers registerEntityRenderersEvent) { registerEntityRenderersEvent.registerBlockEntityRenderer(TGBlockEntityTypes.AMMO_PRESS.get(), AmmoPressRenderer::new); diff --git a/src/main/java/techguns2/TGBlocks.java b/src/main/java/techguns2/TGBlocks.java index 4a735e94..a85e67b2 100644 --- a/src/main/java/techguns2/TGBlocks.java +++ b/src/main/java/techguns2/TGBlocks.java @@ -43,21 +43,21 @@ public final class TGBlocks implements TGInitializer { - protected TGBlocks() + TGBlocks() { } - + private static final DeferredRegister BLOCK_REGISTER = DeferredRegister.create(ForgeRegistries.BLOCKS, Techguns.MODID); private static final DeferredRegister ITEM_REGISTER = DeferredRegister.create(ForgeRegistries.ITEMS, Techguns.MODID); @Override - public final void setup(IEventBus eventBus) + public void setup(IEventBus eventBus) { BLOCK_REGISTER.register(eventBus); ITEM_REGISTER.register(eventBus); } - - protected static final List> MACHINE_BLOCKS = new ArrayList>(); - + + static final List> MACHINE_BLOCKS = new ArrayList<>(); + public static final RegistryObject TIN_ORE = registerCommon( "tin_ore", () -> new DropExperienceBlock(BlockBehaviour.Properties.of() @@ -168,7 +168,7 @@ public final void setup(IEventBus eventBus) .sound(SoundType.STONE) .strength(5.0F, 6.0F)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject BIO_BLOB = registerCommon( "bio_blob", () -> new BioBlobBlock(BlockBehaviour.Properties.of() @@ -176,7 +176,7 @@ public final void setup(IEventBus eventBus) .lightLevel(x -> 7) .sound(SoundType.SLIME_BLOCK)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject SANDBAGS = registerCommon( "sandbags", () -> new SandBagsBlock(BlockBehaviour.Properties.of() @@ -185,7 +185,7 @@ public final void setup(IEventBus eventBus) .forceSolidOn() .strength(3.0F, 15.0F)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject YELLOW_LAMP = registerCommon( "yellow_lamp", () -> new TGLampBlock(BlockBehaviour.Properties.of() @@ -196,7 +196,7 @@ public final void setup(IEventBus eventBus) .noOcclusion() .sound(SoundType.GLASS)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject WHITE_LAMP = registerCommon( "white_lamp", () -> new TGLampBlock(BlockBehaviour.Properties.of() @@ -207,7 +207,7 @@ public final void setup(IEventBus eventBus) .noOcclusion() .sound(SoundType.GLASS)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject LANTERN = registerCommon( "yellow_lantern", () -> new TGLanternBlock(BlockBehaviour.Properties.of() @@ -218,7 +218,7 @@ public final void setup(IEventBus eventBus) .noOcclusion() .sound(SoundType.GLASS)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject WHITE_LANTERN = registerCommon( "white_lantern", () -> new TGLanternBlock(BlockBehaviour.Properties.of() @@ -229,7 +229,7 @@ public final void setup(IEventBus eventBus) .noOcclusion() .sound(SoundType.GLASS)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject METAL_LADDER = registerCommon( "metal_ladder", () -> new TGLadderBlock(BlockBehaviour.Properties.of() @@ -238,7 +238,7 @@ public final void setup(IEventBus eventBus) .strength(6.0F) .sound(SoundType.METAL)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject SHINY_LADDER = registerCommon( "shiny_ladder", () -> new TGLadderBlock(BlockBehaviour.Properties.of() @@ -247,7 +247,7 @@ public final void setup(IEventBus eventBus) .strength(6.0F) .sound(SoundType.METAL)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject RUSTY_LADDER = registerCommon( "rusty_ladder", () -> new TGLadderBlock(BlockBehaviour.Properties.of() @@ -256,7 +256,7 @@ public final void setup(IEventBus eventBus) .strength(6.0F) .sound(SoundType.METAL)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject CARBON_LADDER = registerCommon( "carbon_ladder", () -> new TGLadderBlock(BlockBehaviour.Properties.of() @@ -265,7 +265,7 @@ public final void setup(IEventBus eventBus) .strength(6.0F) .sound(SoundType.METAL)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject NEON_LIGHT = registerCommon( "neon_light", () -> new NeonLightRotatableBlock(BlockBehaviour.Properties.of() @@ -275,7 +275,7 @@ public final void setup(IEventBus eventBus) .strength(4.0F) .sound(SoundType.GLASS)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject QUAD_NEON_LIGHT = registerCommon( "quad_neon_light", () -> new NeonLightRotatableBlock(BlockBehaviour.Properties.of() @@ -285,7 +285,7 @@ public final void setup(IEventBus eventBus) .strength(4.0F) .sound(SoundType.GLASS)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject SQUARE_NEON_LIGHT = registerCommon( "square_neon_light", () -> new NeonLightBlock(BlockBehaviour.Properties.of() @@ -295,167 +295,166 @@ public final void setup(IEventBus eventBus) .strength(4.0F) .sound(SoundType.GLASS)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject CRATE = registerCommon( "ammo_crate", () -> new CrateBlock(BlockBehaviour.Properties.of() // TODO: Properties .sound(SoundType.STONE)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject WEAPON_CRATE = registerCommon( "weapon_crate", () -> new CrateBlock(BlockBehaviour.Properties.of() // TODO: Properties .sound(SoundType.STONE)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject ARMOR_CRATE = registerCommon( "armor_crate", () -> new CrateBlock(BlockBehaviour.Properties.of() // TODO: Properties .sound(SoundType.STONE)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject MEDICAL_CRATE = registerCommon( "medical_crate", () -> new CrateBlock(BlockBehaviour.Properties.of() // TODO: Properties .sound(SoundType.STONE)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject EXPLOSIVES_CRATE = registerCommon( "explosives_crate", () -> new CrateBlock(BlockBehaviour.Properties.of() // TODO: Properties .sound(SoundType.STONE)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject OAK_SUPPLY_CRATE = registerCommon( "oak_supply_crate", () -> new CrateBlock(BlockBehaviour.Properties.of() // TODO: Properties .sound(SoundType.STONE)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject SPRUCE_SUPPLY_CRATE = registerCommon( "spruce_supply_crate", () -> new CrateBlock(BlockBehaviour.Properties.of() // TODO: Properties .sound(SoundType.STONE)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject BIRCH_SUPPLY_CRATE = registerCommon( "birch_supply_crate", () -> new CrateBlock(BlockBehaviour.Properties.of() // TODO: Properties .sound(SoundType.STONE)), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject JUNGLE_SUPPLY_CRATE = registerCommon( "jungle_supply_crate", () -> new CrateBlock(BlockBehaviour.Properties.of() // TODO: Properties .sound(SoundType.STONE)), (block) -> new BlockItem(block, new Item.Properties())); - - public static final RegistryObject AMMO_PRESS = registerMachine("ammo_press", + + public static final RegistryObject AMMO_PRESS = registerMachine("ammo_press", () -> new AmmoPressBlock(BlockBehaviour.Properties.of()), (block) -> new BlockItem(block, new Item.Properties())); - - public static final RegistryObject METAL_PRESS = registerMachine("metal_press", + + public static final RegistryObject METAL_PRESS = registerMachine("metal_press", () -> new MetalPressBlock(BlockBehaviour.Properties.of()), (block) -> new BlockItem(block, new Item.Properties())); - - public static final RegistryObject CHEMICAL_LABORATORY = registerMachine("chemical_laboratory", + + public static final RegistryObject CHEMICAL_LABORATORY = registerMachine("chemical_laboratory", () -> new ChemicalLaboratoryBlock(BlockBehaviour.Properties.of()), (block) -> new BlockItem(block, new Item.Properties())); - - public static final RegistryObject TURRET = registerMachine("turret", + + public static final RegistryObject TURRET = registerMachine("turret", () -> new NPCTurretBlock(BlockBehaviour.Properties.of()), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject CAMO_BENCH = registerCommon( "camo_bench", () -> new Block(BlockBehaviour.Properties.of()), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject REPAIR_BENCH = registerCommon( "repair_bench", () -> new Block(BlockBehaviour.Properties.of()), (block) -> new BlockItem(block, new Item.Properties())); - - public static final RegistryObject CHARGING_STATION = registerMachine("charging_station", + + public static final RegistryObject CHARGING_STATION = registerMachine("charging_station", () -> new ChargingStationBlock(BlockBehaviour.Properties.of()), (block) -> new BlockItem(block, new Item.Properties())); - - public static final RegistryObject ALLOY_FURNACE = registerMachine("alloy_furnace", + + public static final RegistryObject ALLOY_FURNACE = registerMachine("alloy_furnace", () -> new AlloyFurnaceBlock(BlockBehaviour.Properties.of()), (block) -> new BlockItem(block, new Item.Properties())); - public static final RegistryObject GRINDER = registerMachine("grinder", + public static final RegistryObject GRINDER = registerMachine("grinder", () -> new GrinderBlock(BlockBehaviour.Properties.of()), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject UPGRADE_BENCH = registerCommon( - "repair_bench", + "upgrade_bench", () -> new Block(BlockBehaviour.Properties.of()), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject FABRICATOR_HOUSING = registerCommon( "fabricator_housing", () -> new Block(BlockBehaviour.Properties.of()), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject FABRICATOR_GLASS = registerCommon( "fabricator_glass", () -> new Block(BlockBehaviour.Properties.of()), (block) -> new BlockItem(block, new Item.Properties())); - - public static final RegistryObject FABRICATOR_PART = registerMBMachinePart("fabricator_part", + + public static final RegistryObject FABRICATOR_PART = registerMBMachinePart("fabricator_part", () -> new FabricatorPartBlock(BlockBehaviour.Properties.of()), (block) -> new BlockItem(block, new Item.Properties())); - - public static final RegistryObject FABRICATOR_CONTROLLER = registerMachine("fabricator_controller", + + public static final RegistryObject FABRICATOR_CONTROLLER = registerMachine("fabricator_controller", () -> new FabricatorControllerBlock(BlockBehaviour.Properties.of()), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject REACTION_CHAMBER_HOUSING = registerCommon( "reaction_chamber_housing", () -> new Block(BlockBehaviour.Properties.of()), (block) -> new BlockItem(block, new Item.Properties())); - + public static final RegistryObject REACTION_CHAMBER_GLASS = registerCommon( "reaction_chamber_glass", () -> new Block(BlockBehaviour.Properties.of()), (block) -> new BlockItem(block, new Item.Properties())); - - public static final RegistryObject REACTION_CHAMBER_PART = registerMBMachinePart("reaction_chamber_part", + + public static final RegistryObject REACTION_CHAMBER_PART = registerMBMachinePart("reaction_chamber_part", () -> new ReactionChamberPartBlock(BlockBehaviour.Properties.of()), (block) -> new BlockItem(block, new Item.Properties())); - - public static final RegistryObject REACTION_CHAMBER_CONTROLLER = registerMachine("reaction_chamber_controller", + + public static final RegistryObject REACTION_CHAMBER_CONTROLLER = registerMachine("reaction_chamber_controller", () -> new ReactionChamberControllerBlock(BlockBehaviour.Properties.of()), (block) -> new BlockItem(block, new Item.Properties())); - private static final < + private static < T extends AbstractMultiBlockMachinePartBlock, TPartBlockEntity extends AbstractMultiBlockMachinePartBlockEntity, TControllerBlockEntity extends AbstractMultiBlockMachineControllerBlockEntity - > RegistryObject registerMBMachinePart(String name, Supplier blockSupplier, Function itemSupplier) + > RegistryObject registerMBMachinePart(String name, Supplier blockSupplier, Function itemSupplier) { - var result = registerCommon(name, blockSupplier, itemSupplier); - return result; + return registerCommon(name, blockSupplier, itemSupplier); } - - private static final RegistryObject registerMachine(String name, Supplier blockSupplier, Function itemSupplier) + + private static RegistryObject registerMachine(String name, Supplier blockSupplier, Function itemSupplier) { var result = registerCommon(name, blockSupplier, itemSupplier); MACHINE_BLOCKS.add(result); return result; } - - private static final RegistryObject registerCommon(String name, Supplier blockSupplier, Function itemSupplier) + + private static RegistryObject registerCommon(String name, Supplier blockSupplier, Function itemSupplier) { var result = BLOCK_REGISTER.register(name, blockSupplier); ITEM_REGISTER.register(name, () -> itemSupplier.apply(result.get())); diff --git a/src/main/java/techguns2/block/BioBlobBlock.java b/src/main/java/techguns2/block/BioBlobBlock.java index 215934e8..cf62a2d6 100644 --- a/src/main/java/techguns2/block/BioBlobBlock.java +++ b/src/main/java/techguns2/block/BioBlobBlock.java @@ -17,54 +17,68 @@ import net.minecraft.world.level.pathfinder.PathComputationType; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.NotNull; import techguns2.block.entity.BioBlobBlockEntity; public final class BioBlobBlock extends BaseEntityBlock { public static final IntegerProperty SIZE = IntegerProperty.create("size", 0, 2); - public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; - + public static final DirectionProperty FACING = BlockStateProperties.FACING; + private final Map _shapes; - + public BioBlobBlock(Properties properties) { super(properties); - + this.registerDefaultState(this.stateDefinition.any() .setValue(SIZE, 0) .setValue(FACING, Direction.UP)); - + this._shapes = makeShapes(this.defaultBlockState()); } - + @Override - public final VoxelShape getShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext) + public @NotNull VoxelShape getShape( + @NotNull BlockState blockState, + @NotNull BlockGetter blockGetter, + @NotNull BlockPos blockPos, + @NotNull CollisionContext collisionContext + ) { return this._shapes.get(blockState); } - + @Override - public final VoxelShape getCollisionShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, - CollisionContext collisionContext) + public VoxelShape getCollisionShape( + @NotNull BlockState blockState, + @NotNull BlockGetter blockGetter, + @NotNull BlockPos blockPos, + @NotNull CollisionContext collisionContext + ) { return this._shapes.get(blockState); } - + @Override - public final boolean isPathfindable(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, - PathComputationType type) + public boolean isPathfindable( + @NotNull BlockState blockState, + @NotNull BlockGetter blockGetter, + @NotNull BlockPos blockPos, + @NotNull PathComputationType type + ) { return false; } - + @Override - protected final void createBlockStateDefinition(Builder builder) + protected void createBlockStateDefinition(Builder builder) { builder.add(SIZE, FACING); } @Override - public final BioBlobBlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) + public BioBlobBlockEntity newBlockEntity(@NotNull BlockPos blockPos, @NotNull BlockState blockState) { return new BioBlobBlockEntity(blockPos, blockState); } @@ -72,15 +86,15 @@ public final BioBlobBlockEntity newBlockEntity(BlockPos blockPos, BlockState blo private static Map makeShapes(BlockState defaultState) { ImmutableMap.Builder result = ImmutableMap.builder(); - + int size = 0; while (size < 3) { int w = 5 - (2 * size); int h = 3 + size; - + BlockState sizedState = defaultState.setValue(SIZE, size); - + result.put(sizedState.setValue(FACING, Direction.DOWN), Block.box(w, 0, w, 16 - w, h, 16 - w)); result.put(sizedState.setValue(FACING, Direction.WEST), @@ -88,15 +102,16 @@ private static Map makeShapes(BlockState defaultState) result.put(sizedState.setValue(FACING, Direction.NORTH), Block.box(w, w, 0, 16 - w, 16 - w, h)); result.put(sizedState.setValue(FACING, Direction.SOUTH), - Block.box(w, w, 16 - h, 16 - w, h, 1)); + //Block.box(w, w, 16 - h, 16 - w, h, 1)); fixed error + Block.box(w, w, 16 - h, 16 - w, 16-w, 16)); result.put(sizedState.setValue(FACING, Direction.UP), - Block.box(w, 16-h, w, 16 - w, 1, 16 - w)); + Block.box(w, 16-h, w, 16 - w, 16, 16 - w)); result.put(sizedState.setValue(FACING, Direction.EAST), - Block.box(16 - h, w, w, 1, 16 - w, 16 - w)); - + Block.box(16 - h, w, w, 16, 16 - w, 16 - w)); + size++; } - + return result.build(); } diff --git a/src/main/resources/assets/techguns2/textures/item/ingotbronze.png b/src/main/resources/assets/techguns2/textures/item/ingotbronze.png index eca45e35..d8718f05 100644 Binary files a/src/main/resources/assets/techguns2/textures/item/ingotbronze.png and b/src/main/resources/assets/techguns2/textures/item/ingotbronze.png differ diff --git a/src/main/resources/assets/techguns2/textures/item/ingotcopper.png b/src/main/resources/assets/techguns2/textures/item/ingotcopper.png deleted file mode 100644 index e99ca8e1..00000000 Binary files a/src/main/resources/assets/techguns2/textures/item/ingotcopper.png and /dev/null differ diff --git a/src/main/resources/assets/techguns2/textures/item/ingotlead.png b/src/main/resources/assets/techguns2/textures/item/ingotlead.png index c173213e..c70b34b6 100644 Binary files a/src/main/resources/assets/techguns2/textures/item/ingotlead.png and b/src/main/resources/assets/techguns2/textures/item/ingotlead.png differ diff --git a/src/main/resources/assets/techguns2/textures/item/ingotobsidiansteel.png b/src/main/resources/assets/techguns2/textures/item/ingotobsidiansteel.png index b1d0d6d0..e12bfc09 100644 Binary files a/src/main/resources/assets/techguns2/textures/item/ingotobsidiansteel.png and b/src/main/resources/assets/techguns2/textures/item/ingotobsidiansteel.png differ diff --git a/src/main/resources/assets/techguns2/textures/item/ingotsteel.png b/src/main/resources/assets/techguns2/textures/item/ingotsteel.png index 20e33541..6f3bd32b 100644 Binary files a/src/main/resources/assets/techguns2/textures/item/ingotsteel.png and b/src/main/resources/assets/techguns2/textures/item/ingotsteel.png differ diff --git a/src/main/resources/assets/techguns2/textures/item/ingottin.png b/src/main/resources/assets/techguns2/textures/item/ingottin.png index 12b773ca..748ea0cc 100644 Binary files a/src/main/resources/assets/techguns2/textures/item/ingottin.png and b/src/main/resources/assets/techguns2/textures/item/ingottin.png differ diff --git a/src/main/resources/assets/techguns2/textures/item/ingottitanium.png b/src/main/resources/assets/techguns2/textures/item/ingottitanium.png index e30577cc..1d889386 100644 Binary files a/src/main/resources/assets/techguns2/textures/item/ingottitanium.png and b/src/main/resources/assets/techguns2/textures/item/ingottitanium.png differ diff --git a/src/main/resources/assets/techguns2/textures/item/treatedleather.png b/src/main/resources/assets/techguns2/textures/item/treatedleather.png index 7626659c..e215cf9e 100644 Binary files a/src/main/resources/assets/techguns2/textures/item/treatedleather.png and b/src/main/resources/assets/techguns2/textures/item/treatedleather.png differ