From c808084db6e0f37fd1ef9d7f1c98b3e1e033c826 Mon Sep 17 00:00:00 2001 From: Light_Quanta Date: Thu, 3 Apr 2025 22:37:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E6=B3=A8=E5=86=8C=E7=89=B9?= =?UTF-8?q?=E6=AE=8A=E9=85=8D=E6=96=B9=EF=BC=8C=E5=85=81=E8=AE=B8=E5=8F=91?= =?UTF-8?q?=E5=B0=84=E5=99=A8=E5=8F=91=E5=B0=84=E8=BF=AB=E5=87=BB=E7=82=AE?= =?UTF-8?q?=E7=82=AE=E5=BC=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e | 4 +++ .../minecraft/recipe/ammo_box_add_ammo.json | 4 +++ .../recipe/ammo_box_extract_ammo.json | 4 +++ .../minecraft/recipe/potion_mortar_shell.json | 4 +++ .../superbwarfare/datagen/DataGenerators.java | 2 +- .../datagen/ModRecipeProvider.java | 28 +++++++++++++++++++ .../item/common/ammo/MortarShell.java | 18 +++++++++++- .../recipe/PotionMortarShellRecipe.java | 2 +- 8 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e create mode 100644 src/generated/resources/data/minecraft/recipe/ammo_box_add_ammo.json create mode 100644 src/generated/resources/data/minecraft/recipe/ammo_box_extract_ammo.json create mode 100644 src/generated/resources/data/minecraft/recipe/potion_mortar_shell.json create mode 100644 src/main/java/com/atsuishio/superbwarfare/datagen/ModRecipeProvider.java 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; }