diff --git a/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e b/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e new file mode 100644 index 000000000..1f783ea1c --- /dev/null +++ b/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e @@ -0,0 +1,4 @@ +// 1.21.1 2025-04-03T22:15:00.0218531 Recipes +9775e550332c69f1ee2ac4a09834a35db6f6a2ed data/minecraft/recipe/ammo_box_add_ammo.json +9775e550332c69f1ee2ac4a09834a35db6f6a2ed data/minecraft/recipe/ammo_box_extract_ammo.json +2e1d1bbf32801f3d355c0d3f78ebbb1122cebd4c data/minecraft/recipe/potion_mortar_shell.json diff --git a/src/generated/resources/data/minecraft/recipe/ammo_box_add_ammo.json b/src/generated/resources/data/minecraft/recipe/ammo_box_add_ammo.json new file mode 100644 index 000000000..951d4afac --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/ammo_box_add_ammo.json @@ -0,0 +1,4 @@ +{ + "type": "superbwarfare:ammo_box_add_ammo", + "category": "misc" +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/ammo_box_extract_ammo.json b/src/generated/resources/data/minecraft/recipe/ammo_box_extract_ammo.json new file mode 100644 index 000000000..6cda2aa93 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/ammo_box_extract_ammo.json @@ -0,0 +1,4 @@ +{ + "type": "superbwarfare:ammo_box_extract_ammo", + "category": "misc" +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/potion_mortar_shell.json b/src/generated/resources/data/minecraft/recipe/potion_mortar_shell.json new file mode 100644 index 000000000..e5ee9b624 --- /dev/null +++ b/src/generated/resources/data/minecraft/recipe/potion_mortar_shell.json @@ -0,0 +1,4 @@ +{ + "type": "superbwarfare:potion_mortar_shell", + "category": "misc" +} \ No newline at end of file diff --git a/src/main/java/com/atsuishio/superbwarfare/datagen/DataGenerators.java b/src/main/java/com/atsuishio/superbwarfare/datagen/DataGenerators.java index c0b683aed..dee870f08 100644 --- a/src/main/java/com/atsuishio/superbwarfare/datagen/DataGenerators.java +++ b/src/main/java/com/atsuishio/superbwarfare/datagen/DataGenerators.java @@ -22,7 +22,7 @@ public class DataGenerators { ExistingFileHelper existingFileHelper = event.getExistingFileHelper(); generator.addProvider(event.includeServer(), ModLootTableProvider.create(packOutput, event.getLookupProvider())); -// generator.addProvider(event.includeServer(), new ModRecipeProvider(packOutput)); + generator.addProvider(event.includeServer(), new ModRecipeProvider(packOutput, event.getLookupProvider())); generator.addProvider(event.includeServer(), new ModBlockStateProvider(packOutput, existingFileHelper)); generator.addProvider(event.includeServer(), new ModItemModelProvider(packOutput, existingFileHelper)); ModBlockTagProvider tagProvider = generator.addProvider(event.includeServer(), new ModBlockTagProvider(packOutput, lookupProvider, existingFileHelper)); diff --git a/src/main/java/com/atsuishio/superbwarfare/datagen/ModRecipeProvider.java b/src/main/java/com/atsuishio/superbwarfare/datagen/ModRecipeProvider.java new file mode 100644 index 000000000..e035a1436 --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/datagen/ModRecipeProvider.java @@ -0,0 +1,28 @@ +package com.atsuishio.superbwarfare.datagen; + +import com.atsuishio.superbwarfare.recipe.AmmoBoxAddAmmoRecipe; +import com.atsuishio.superbwarfare.recipe.AmmoBoxExtractAmmoRecipe; +import com.atsuishio.superbwarfare.recipe.PotionMortarShellRecipe; +import net.minecraft.core.HolderLookup; +import net.minecraft.data.PackOutput; +import net.minecraft.data.recipes.RecipeOutput; +import net.minecraft.data.recipes.RecipeProvider; +import net.minecraft.data.recipes.SpecialRecipeBuilder; +import net.neoforged.neoforge.common.conditions.IConditionBuilder; +import org.jetbrains.annotations.NotNull; + +import java.util.concurrent.CompletableFuture; + +public class ModRecipeProvider extends RecipeProvider implements IConditionBuilder { + + public ModRecipeProvider(PackOutput output, CompletableFuture registries) { + super(output, registries); + } + + @Override + protected void buildRecipes(@NotNull RecipeOutput recipeOutput) { + SpecialRecipeBuilder.special(PotionMortarShellRecipe::new).save(recipeOutput, "potion_mortar_shell"); + SpecialRecipeBuilder.special(AmmoBoxAddAmmoRecipe::new).save(recipeOutput, "ammo_box_add_ammo"); + SpecialRecipeBuilder.special(AmmoBoxExtractAmmoRecipe::new).save(recipeOutput, "ammo_box_extract_ammo"); + } +} diff --git a/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/MortarShell.java b/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/MortarShell.java index 94a0eeb42..a4d343617 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/MortarShell.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/common/ammo/MortarShell.java @@ -1,12 +1,20 @@ package com.atsuishio.superbwarfare.item.common.ammo; import com.atsuishio.superbwarfare.entity.projectile.MortarShellEntity; +import com.atsuishio.superbwarfare.init.ModEntities; +import net.minecraft.core.Direction; +import net.minecraft.core.Position; import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.projectile.Projectile; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ProjectileItem; import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; -public class MortarShell extends Item { +import javax.annotation.ParametersAreNonnullByDefault; + +public class MortarShell extends Item implements ProjectileItem { public MortarShell() { super(new Properties()); @@ -17,4 +25,12 @@ public class MortarShell extends Item { shellEntity.setEffectsFromItem(stack); return shellEntity; } + + @Override + @ParametersAreNonnullByDefault + public @NotNull Projectile asProjectile(Level level, Position pos, ItemStack stack, Direction direction) { + var shell = new MortarShellEntity(ModEntities.MORTAR_SHELL.get(), pos.x(), pos.y(), pos.z(), level); + shell.setEffectsFromItem(stack); + return shell; + } } diff --git a/src/main/java/com/atsuishio/superbwarfare/recipe/PotionMortarShellRecipe.java b/src/main/java/com/atsuishio/superbwarfare/recipe/PotionMortarShellRecipe.java index 99ce5b470..343b39dda 100644 --- a/src/main/java/com/atsuishio/superbwarfare/recipe/PotionMortarShellRecipe.java +++ b/src/main/java/com/atsuishio/superbwarfare/recipe/PotionMortarShellRecipe.java @@ -58,7 +58,7 @@ public class PotionMortarShellRecipe extends CustomRecipe { return ItemStack.EMPTY; } else { ItemStack res = new ItemStack(ModItems.POTION_MORTAR_SHELL.get(), 4); - res.set(DataComponents.POTION_CONTENTS, res.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY)); + res.set(DataComponents.POTION_CONTENTS, stack.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY)); return res; }