注册药水弹的配方
This commit is contained in:
parent
325eff00b4
commit
695aa82f78
7 changed files with 119 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
|||
// 1.20.1 2025-02-22T22:55:11.4694739 Recipes
|
||||
2e1d1bbf32801f3d355c0d3f78ebbb1122cebd4c data/minecraft/recipes/potion_mortar_shell.json
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"type": "superbwarfare:potion_mortar_shell",
|
||||
"category": "misc"
|
||||
}
|
|
@ -65,6 +65,7 @@ public class ModUtils {
|
|||
ModPotion.POTIONS.register(bus);
|
||||
ModMenuTypes.REGISTRY.register(bus);
|
||||
ModVillagers.register(bus);
|
||||
ModRecipes.RECIPE_SERIALIZERS.register(bus);
|
||||
|
||||
bus.addListener(this::onCommonSetup);
|
||||
bus.addListener(this::onClientSetup);
|
||||
|
|
|
@ -22,7 +22,7 @@ public class DataGenerators {
|
|||
ExistingFileHelper existingFileHelper = event.getExistingFileHelper();
|
||||
|
||||
generator.addProvider(event.includeServer(), ModLootTableProvider.create(packOutput));
|
||||
// generator.addProvider(event.includeServer(), new ModWorldGenProvider(packOutput, lookupProvider));
|
||||
generator.addProvider(event.includeServer(), new ModRecipeProvider(packOutput));
|
||||
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));
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package com.atsuishio.superbwarfare.datagen;
|
||||
|
||||
import com.atsuishio.superbwarfare.init.ModRecipes;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.data.recipes.FinishedRecipe;
|
||||
import net.minecraft.data.recipes.RecipeProvider;
|
||||
import net.minecraft.data.recipes.SpecialRecipeBuilder;
|
||||
import net.minecraftforge.common.crafting.conditions.IConditionBuilder;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ModRecipeProvider extends RecipeProvider implements IConditionBuilder {
|
||||
|
||||
public ModRecipeProvider(PackOutput pOutput) {
|
||||
super(pOutput);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildRecipes(Consumer<FinishedRecipe> pWriter) {
|
||||
SpecialRecipeBuilder.special(ModRecipes.POTION_MORTAR_SHELL_SERIALIZER.get()).save(pWriter, "potion_mortar_shell");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.atsuishio.superbwarfare.init;
|
||||
|
||||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.atsuishio.superbwarfare.recipe.PotionMortarShellRecipe;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.item.crafting.SimpleCraftingRecipeSerializer;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModRecipes {
|
||||
|
||||
public static final DeferredRegister<RecipeSerializer<?>> RECIPE_SERIALIZERS = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, ModUtils.MODID);
|
||||
|
||||
public static final RegistryObject<RecipeSerializer<PotionMortarShellRecipe>> POTION_MORTAR_SHELL_SERIALIZER =
|
||||
RECIPE_SERIALIZERS.register("potion_mortar_shell", () -> new SimpleCraftingRecipeSerializer<>(PotionMortarShellRecipe::new));
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package com.atsuishio.superbwarfare.recipe;
|
||||
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModRecipes;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.alchemy.PotionUtils;
|
||||
import net.minecraft.world.item.crafting.CraftingBookCategory;
|
||||
import net.minecraft.world.item.crafting.CustomRecipe;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
public class PotionMortarShellRecipe extends CustomRecipe {
|
||||
|
||||
public PotionMortarShellRecipe(ResourceLocation pId, CraftingBookCategory pCategory) {
|
||||
super(pId, pCategory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(CraftingContainer pContainer, Level pLevel) {
|
||||
if (pContainer.getWidth() == 3 && pContainer.getHeight() == 3) {
|
||||
for (int i = 0; i < pContainer.getWidth(); ++i) {
|
||||
for (int j = 0; j < pContainer.getHeight(); ++j) {
|
||||
int index = i + j * pContainer.getWidth();
|
||||
|
||||
ItemStack itemstack = pContainer.getItem(index);
|
||||
|
||||
if (index % 2 == 0) {
|
||||
if (i == 1 && j == 1) {
|
||||
if (!itemstack.is(Items.LINGERING_POTION)) {
|
||||
return false;
|
||||
}
|
||||
} else if (!itemstack.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
} else if (!itemstack.is(ModItems.MORTAR_SHELL.get())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack assemble(CraftingContainer pContainer, RegistryAccess pRegistryAccess) {
|
||||
ItemStack itemstack = pContainer.getItem(1 + pContainer.getWidth());
|
||||
if (!itemstack.is(Items.LINGERING_POTION)) {
|
||||
return ItemStack.EMPTY;
|
||||
} else {
|
||||
ItemStack res = new ItemStack(ModItems.POTION_MORTAR_SHELL.get(), 4);
|
||||
PotionUtils.setPotion(res, PotionUtils.getPotion(itemstack));
|
||||
PotionUtils.setCustomEffects(res, PotionUtils.getCustomEffects(itemstack));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCraftInDimensions(int pWidth, int pHeight) {
|
||||
return pWidth >= 2 && pHeight >= 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return ModRecipes.POTION_MORTAR_SHELL_SERIALIZER.get();
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue