mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 11:19:19 +00:00
Rune recipes to json
This commit is contained in:
1 parent
748ef78b3a
commit
e0951a851c
35 files changed
+755
-405
No files matched your search
@@ -57,12 +57,6 @@ public final class BotaniaAPI {
|
||||
// TODO 1.15 MOVE THIS
|
||||
public static IForgeRegistry<Brew> brewRegistry;
|
||||
|
||||
/*
|
||||
* These maps are not meant to be mutated!
|
||||
*/
|
||||
public static Map<ResourceLocation, RecipePetals> petalRecipes = Collections.emptyMap();
|
||||
public static Map<ResourceLocation, RecipeRuneAltar> runeAltarRecipes = Collections.emptyMap();
|
||||
|
||||
public static Map<ResourceLocation, Integer> oreWeights = Collections.emptyMap();
|
||||
public static Map<ResourceLocation, Integer> oreWeightsNether = Collections.emptyMap();
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* This class is distributed as part of the Botania Mod.
|
||||
* Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*/
|
||||
package vazkii.botania.api.recipe;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Implementation detail, you shouldn't need to use this.
|
||||
*/
|
||||
public interface IModRecipe {
|
||||
List<Ingredient> getInputs();
|
||||
ItemStack getOutput();
|
||||
ResourceLocation getId();
|
||||
}
|
||||
@@ -11,19 +11,34 @@ package vazkii.botania.api.recipe;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.IRecipeType;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.RecipeWrapper;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.crafting.ModRecipeTypes;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RecipeRuneAltar implements IModRecipe {
|
||||
public class RecipeRuneAltar implements IRecipe<RecipeWrapper> {
|
||||
private final ResourceLocation id;
|
||||
private final ItemStack output;
|
||||
private final ImmutableList<Ingredient> inputs;
|
||||
private final NonNullList<Ingredient> inputs;
|
||||
private final int mana;
|
||||
|
||||
public RecipeRuneAltar(ResourceLocation id, ItemStack output, int mana, Ingredient... inputs) {
|
||||
@@ -31,14 +46,15 @@ public class RecipeRuneAltar implements IModRecipe {
|
||||
Preconditions.checkArgument(mana <= 100000);
|
||||
this.id = id;
|
||||
this.output = output;
|
||||
this.inputs = ImmutableList.copyOf(inputs);
|
||||
this.inputs = NonNullList.from(null, inputs);
|
||||
this.mana = mana;
|
||||
}
|
||||
|
||||
public boolean matches(IItemHandler inv) {
|
||||
@Override
|
||||
public boolean matches(RecipeWrapper inv, @Nonnull World world) {
|
||||
List<Ingredient> ingredientsMissing = new ArrayList<>(inputs);
|
||||
|
||||
for (int i = 0; i < inv.getSlots(); i++) {
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
ItemStack input = inv.getStackInSlot(i);
|
||||
if (input.isEmpty()) {
|
||||
break;
|
||||
@@ -64,42 +80,92 @@ public class RecipeRuneAltar implements IModRecipe {
|
||||
return ingredientsMissing.isEmpty();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NonNullList<Ingredient> getIngredients() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getIcon() {
|
||||
return new ItemStack(ModBlocks.runeAltar);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ResourceLocation getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public List<Ingredient> getInputs() {
|
||||
return inputs;
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeSerializer<?> getSerializer() {
|
||||
return ModRecipeTypes.RUNE_SERIALIZER;
|
||||
}
|
||||
|
||||
public ItemStack getOutput() {
|
||||
return output;
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeType<?> getType() {
|
||||
return ModRecipeTypes.RUNE_TYPE;
|
||||
}
|
||||
|
||||
public int getManaUsage() {
|
||||
return mana;
|
||||
}
|
||||
|
||||
public void write(PacketBuffer buf) {
|
||||
buf.writeResourceLocation(id);
|
||||
buf.writeVarInt(inputs.size());
|
||||
for (Ingredient input : inputs) {
|
||||
input.write(buf);
|
||||
}
|
||||
buf.writeItemStack(output, false);
|
||||
buf.writeVarInt(mana);
|
||||
|
||||
// Ignored IRecipe methods
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getCraftingResult(@Nonnull RecipeWrapper inv) {
|
||||
return getRecipeOutput();
|
||||
}
|
||||
|
||||
public static RecipeRuneAltar read(PacketBuffer buf) {
|
||||
ResourceLocation id = buf.readResourceLocation();
|
||||
Ingredient[] inputs = new Ingredient[buf.readVarInt()];
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
inputs[i] = Ingredient.read(buf);
|
||||
@Override
|
||||
public boolean canFit(int width, int height) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class Serializer extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<RecipeRuneAltar> {
|
||||
@Nonnull
|
||||
@Override
|
||||
public RecipeRuneAltar read(@Nonnull ResourceLocation id, @Nonnull JsonObject json) {
|
||||
ItemStack output = CraftingHelper.getItemStack(JSONUtils.getJsonObject(json, "output"), true);
|
||||
int mana = JSONUtils.getInt(json, "mana");
|
||||
JsonArray ingrs = JSONUtils.getJsonArray(json, "ingredients");
|
||||
List<Ingredient> inputs = new ArrayList<>();
|
||||
for (JsonElement e : ingrs) {
|
||||
inputs.add(Ingredient.deserialize(e));
|
||||
}
|
||||
return new RecipeRuneAltar(id, output, mana, inputs.toArray(new Ingredient[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeRuneAltar read(@Nonnull ResourceLocation id, @Nonnull PacketBuffer buf) {
|
||||
Ingredient[] inputs = new Ingredient[buf.readVarInt()];
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
inputs[i] = Ingredient.read(buf);
|
||||
}
|
||||
ItemStack output = buf.readItemStack();
|
||||
int mana = buf.readVarInt();
|
||||
return new RecipeRuneAltar(id, output, mana, inputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(@Nonnull PacketBuffer buf, @Nonnull RecipeRuneAltar recipe) {
|
||||
buf.writeVarInt(recipe.getIngredients().size());
|
||||
for (Ingredient input : recipe.getIngredients()) {
|
||||
input.write(buf);
|
||||
}
|
||||
buf.writeItemStack(recipe.getRecipeOutput(), false);
|
||||
buf.writeVarInt(recipe.getManaUsage());
|
||||
}
|
||||
ItemStack output = buf.readItemStack();
|
||||
int mana = buf.readVarInt();
|
||||
return new RecipeRuneAltar(id, output, mana, inputs);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public class JEIBotaniaPlugin implements IModPlugin {
|
||||
registry.addRecipes(Minecraft.getInstance().world.getRecipeManager().getRecipes(ModRecipeTypes.PURE_DAISY_TYPE).values(), PureDaisyRecipeCategory.UID);
|
||||
registry.addRecipes(Minecraft.getInstance().world.getRecipeManager().getRecipes(ModRecipeTypes.PETAL_TYPE).values(), PetalApothecaryRecipeCategory.UID);
|
||||
registry.addRecipes(TileAlfPortal.elvenTradeRecipes(Minecraft.getInstance().world.getRecipeManager()), ElvenTradeRecipeCategory.UID);
|
||||
registry.addRecipes(BotaniaAPI.runeAltarRecipes.values(), RunicAltarRecipeCategory.UID);
|
||||
registry.addRecipes(Minecraft.getInstance().world.getRecipeManager().getRecipes(ModRecipeTypes.RUNE_TYPE).values(), RunicAltarRecipeCategory.UID);
|
||||
registry.addRecipes(TilePool.manaInfusionRecipes(Minecraft.getInstance().world.getRecipeManager()), ManaPoolRecipeCategory.UID);
|
||||
|
||||
registry.addRecipes(
|
||||
|
||||
+2
-2
@@ -84,11 +84,11 @@ public class RunicAltarRecipeCategory implements IRecipeCategory<RecipeRuneAltar
|
||||
@Override
|
||||
public void setIngredients(RecipeRuneAltar recipe, IIngredients iIngredients) {
|
||||
List<List<ItemStack>> list = new ArrayList<>();
|
||||
for (Ingredient ingr : recipe.getInputs()) {
|
||||
for (Ingredient ingr : recipe.getIngredients()) {
|
||||
list.add(Arrays.asList(ingr.getMatchingStacks()));
|
||||
}
|
||||
iIngredients.setInputLists(VanillaTypes.ITEM, list);
|
||||
iIngredients.setOutput(VanillaTypes.ITEM, recipe.getOutput());
|
||||
iIngredients.setOutput(VanillaTypes.ITEM, recipe.getRecipeOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,8 +15,6 @@ import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.recipe.IModRecipe;
|
||||
import vazkii.botania.common.crafting.ModRecipeTypes;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -12,8 +12,6 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.recipe.IModRecipe;
|
||||
import vazkii.botania.common.crafting.ModRecipeTypes;
|
||||
import vazkii.patchouli.api.IComponentProcessor;
|
||||
import vazkii.patchouli.api.IVariableProvider;
|
||||
|
||||
@@ -52,7 +52,6 @@ import vazkii.botania.common.block.tile.TileAlfPortal;
|
||||
import vazkii.botania.common.block.tile.TileEnchanter;
|
||||
import vazkii.botania.common.block.tile.TileTerraPlate;
|
||||
import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex;
|
||||
import vazkii.botania.common.brew.ModBrews;
|
||||
import vazkii.botania.common.capability.NoopCapStorage;
|
||||
import vazkii.botania.common.capability.NoopExoflameHeatable;
|
||||
import vazkii.botania.common.core.command.CommandSkyblockSpread;
|
||||
@@ -69,7 +68,6 @@ import vazkii.botania.common.core.loot.TrueGuardianKiller;
|
||||
import vazkii.botania.common.core.proxy.IProxy;
|
||||
import vazkii.botania.common.core.proxy.ServerProxy;
|
||||
import vazkii.botania.common.crafting.FluxfieldCondition;
|
||||
import vazkii.botania.common.crafting.SyncHandler;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
import vazkii.botania.common.network.PacketHandler;
|
||||
import vazkii.botania.common.world.ModFeatures;
|
||||
@@ -252,7 +250,6 @@ public class Botania {
|
||||
+ " \"Do not Override\". Whoever had the brilliant idea of overriding it needs to go"
|
||||
+ " back to elementary school and learn to read. (Expected classname: " + expect + ", Actual classname: " + clname + ")");
|
||||
}
|
||||
event.getServer().getResourceManager().addReloadListener(new SyncHandler.ReloadListener());
|
||||
}
|
||||
|
||||
private void serverStarting(FMLServerStartingEvent event) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.items.wrapper.RecipeWrapper;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -39,6 +40,7 @@ import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.core.handler.ModSounds;
|
||||
import vazkii.botania.common.core.helper.Vector3;
|
||||
import vazkii.botania.common.crafting.ModRecipeTypes;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.item.material.ItemRune;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
@@ -49,6 +51,7 @@ import javax.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver, ITickableTileEntity {
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RUNE_ALTAR) public static TileEntityType<TileRuneAltar> TYPE;
|
||||
@@ -206,11 +209,10 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver,
|
||||
if (currentRecipe != null) {
|
||||
this.manaToGet = currentRecipe.getManaUsage();
|
||||
} else {
|
||||
for (RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes.values()) {
|
||||
if (recipe.matches(itemHandler)) {
|
||||
this.manaToGet = recipe.getManaUsage();
|
||||
break getMana;
|
||||
}
|
||||
Optional<RecipeRuneAltar> maybeRecipe = world.getRecipeManager().getRecipe(ModRecipeTypes.RUNE_TYPE, new RecipeWrapper(itemHandler), world);
|
||||
if (maybeRecipe.isPresent()) {
|
||||
this.manaToGet = maybeRecipe.get().getManaUsage();
|
||||
break getMana;
|
||||
}
|
||||
this.manaToGet = 0;
|
||||
}
|
||||
@@ -243,13 +245,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver,
|
||||
}
|
||||
|
||||
public boolean hasValidRecipe() {
|
||||
for (RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes.values()) {
|
||||
if (recipe.matches(itemHandler)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return world.getRecipeManager().getRecipe(ModRecipeTypes.RUNE_TYPE, new RecipeWrapper(itemHandler), world).isPresent();
|
||||
}
|
||||
|
||||
public void onWanded(PlayerEntity player, ItemStack wand) {
|
||||
@@ -262,15 +258,13 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver,
|
||||
if (currentRecipe != null) {
|
||||
recipe = currentRecipe;
|
||||
} else {
|
||||
for (RecipeRuneAltar recipe_ : BotaniaAPI.runeAltarRecipes.values()) {
|
||||
if (recipe_.matches(itemHandler)) {
|
||||
recipe = recipe_;
|
||||
break;
|
||||
}
|
||||
Optional<RecipeRuneAltar> maybeRecipe = world.getRecipeManager().getRecipe(ModRecipeTypes.RUNE_TYPE, new RecipeWrapper(itemHandler), world);
|
||||
if (maybeRecipe.isPresent()) {
|
||||
recipe = maybeRecipe.get();
|
||||
}
|
||||
}
|
||||
|
||||
if (manaToGet > 0 && mana >= manaToGet) {
|
||||
if (recipe != null && manaToGet > 0 && mana >= manaToGet) {
|
||||
List<ItemEntity> items = world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(pos, pos.add(1, 1, 1)));
|
||||
ItemEntity livingrock = null;
|
||||
for (ItemEntity item : items) {
|
||||
@@ -283,7 +277,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver,
|
||||
if (livingrock != null) {
|
||||
int mana = recipe.getManaUsage();
|
||||
recieveMana(-mana);
|
||||
ItemStack output = recipe.getOutput().copy();
|
||||
ItemStack output = recipe.getRecipeOutput().copy();
|
||||
ItemEntity outputItem = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, output);
|
||||
world.addEntity(outputItem);
|
||||
currentRecipe = null;
|
||||
@@ -391,32 +385,30 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver,
|
||||
|
||||
if (amt > 0) {
|
||||
float anglePer = 360F / amt;
|
||||
for (RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes.values()) {
|
||||
if (recipe.matches(itemHandler)) {
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.enableRescaleNormal();
|
||||
RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
world.getRecipeManager().getRecipe(ModRecipeTypes.RUNE_TYPE, new RecipeWrapper(itemHandler), world).ifPresent(recipe -> {
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.enableRescaleNormal();
|
||||
RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
float progress = (float) mana / (float) manaToGet;
|
||||
float progress = (float) mana / (float) manaToGet;
|
||||
|
||||
mc.textureManager.bindTexture(HUDHandler.manaBar);
|
||||
RenderSystem.color4f(1F, 1F, 1F, 1F);
|
||||
RenderHelper.drawTexturedModalRect(xc + radius + 9, yc - 8, progress == 1F ? 0 : 22, 8, 22, 15);
|
||||
mc.textureManager.bindTexture(HUDHandler.manaBar);
|
||||
RenderSystem.color4f(1F, 1F, 1F, 1F);
|
||||
RenderHelper.drawTexturedModalRect(xc + radius + 9, yc - 8, progress == 1F ? 0 : 22, 8, 22, 15);
|
||||
|
||||
if (progress == 1F) {
|
||||
mc.getItemRenderer().renderItemIntoGUI(new ItemStack(ModBlocks.livingrock), xc + radius + 16, yc + 8);
|
||||
RenderSystem.translatef(0F, 0F, 100F);
|
||||
mc.getItemRenderer().renderItemIntoGUI(new ItemStack(ModItems.twigWand), xc + radius + 24, yc + 8);
|
||||
RenderSystem.translatef(0F, 0F, -100F);
|
||||
}
|
||||
|
||||
RenderHelper.renderProgressPie(xc + radius + 32, yc - 8, progress, recipe.getOutput());
|
||||
|
||||
if (progress == 1F) {
|
||||
mc.fontRenderer.drawStringWithShadow("+", xc + radius + 14, yc + 12, 0xFFFFFF);
|
||||
}
|
||||
if (progress == 1F) {
|
||||
mc.getItemRenderer().renderItemIntoGUI(new ItemStack(ModBlocks.livingrock), xc + radius + 16, yc + 8);
|
||||
RenderSystem.translatef(0F, 0F, 100F);
|
||||
mc.getItemRenderer().renderItemIntoGUI(new ItemStack(ModItems.twigWand), xc + radius + 24, yc + 8);
|
||||
RenderSystem.translatef(0F, 0F, -100F);
|
||||
}
|
||||
}
|
||||
|
||||
RenderHelper.renderProgressPie(xc + radius + 32, yc - 8, progress, recipe.getRecipeOutput());
|
||||
|
||||
if (progress == 1F) {
|
||||
mc.fontRenderer.drawStringWithShadow("+", xc + radius + 14, yc + 12, 0xFFFFFF);
|
||||
}
|
||||
});
|
||||
|
||||
for (int i = 0; i < amt; i++) {
|
||||
double xPos = xc + Math.cos(angle * Math.PI / 180D) * radius - 8;
|
||||
|
||||
@@ -19,6 +19,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
import vazkii.botania.api.recipe.*;
|
||||
import vazkii.botania.common.crafting.recipe.HeadRecipe;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import static vazkii.botania.common.lib.ResourceLocationHelper.prefix;
|
||||
@@ -41,6 +42,10 @@ public class ModRecipeTypes {
|
||||
public static final IRecipeType<RecipePetals> PETAL_TYPE = new RecipeType<>();
|
||||
public static final IRecipeSerializer<RecipePetals> PETAL_SERIALIZER = new RecipePetals.Serializer();
|
||||
|
||||
public static final IRecipeType<RecipeRuneAltar> RUNE_TYPE = new RecipeType<>();
|
||||
public static final IRecipeSerializer<RecipeRuneAltar> RUNE_SERIALIZER = new RecipeRuneAltar.Serializer();
|
||||
public static final IRecipeSerializer<HeadRecipe> RUNE_HEAD_SERIALIZER = new HeadRecipe.Serializer();
|
||||
|
||||
@SubscribeEvent
|
||||
public static void register(RegistryEvent.Register<IRecipeSerializer<?>> evt) {
|
||||
ResourceLocation id = prefix("elven_trade");
|
||||
@@ -63,6 +68,11 @@ public class ModRecipeTypes {
|
||||
id = prefix("petal_apothecary");
|
||||
Registry.register(Registry.RECIPE_TYPE, id, PETAL_TYPE);
|
||||
evt.getRegistry().register(PETAL_SERIALIZER.setRegistryName(id));
|
||||
|
||||
id = prefix("runic_altar");
|
||||
Registry.register(Registry.RECIPE_TYPE, id, RUNE_TYPE);
|
||||
evt.getRegistry().register(RUNE_SERIALIZER.setRegistryName(id));
|
||||
evt.getRegistry().register(RUNE_HEAD_SERIALIZER.setRegistryName(prefix("runic_altar_head")));
|
||||
}
|
||||
|
||||
private static class RecipeType<T extends IRecipe<?>> implements IRecipeType<T> {
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* This class is distributed as part of the Botania Mod.
|
||||
* Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*/
|
||||
package vazkii.botania.common.crafting;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraftforge.common.Tags;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
import vazkii.botania.api.recipe.RecipeRuneAltar;
|
||||
import vazkii.botania.api.recipe.RegisterRecipesEvent;
|
||||
import vazkii.botania.common.crafting.recipe.HeadRecipe;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
import vazkii.botania.common.lib.ModTags;
|
||||
|
||||
import static vazkii.botania.common.lib.ResourceLocationHelper.prefix;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID)
|
||||
public final class ModRuneRecipes {
|
||||
|
||||
// todo 1.13 re-tagify these once the community settles down on some names
|
||||
@SubscribeEvent
|
||||
public static void register(RegisterRecipesEvent evt) {
|
||||
final int costTier1 = 5200;
|
||||
final int costTier2 = 8000;
|
||||
final int costTier3 = 12000;
|
||||
|
||||
Ingredient manaSteel = Ingredient.fromTag(ModTags.Items.INGOTS_MANASTEEL);
|
||||
Ingredient manaDiamond = Ingredient.fromTag(ModTags.Items.GEMS_MANA_DIAMOND);
|
||||
Ingredient manaPowder = Ingredient.fromTag(ModTags.Items.DUSTS_MANA);
|
||||
evt.runeAltar().accept(new RecipeRuneAltar(prefix("water"), new ItemStack(ModItems.runeWater, 2), costTier1, manaPowder, manaSteel, Ingredient.fromItems(Items.BONE_MEAL), Ingredient.fromItems(Blocks.SUGAR_CANE), Ingredient.fromItems(Items.FISHING_ROD)));
|
||||
evt.runeAltar().accept(new RecipeRuneAltar(prefix("fire"), new ItemStack(ModItems.runeFire, 2), costTier1, manaPowder, manaSteel, Ingredient.fromItems(Items.NETHER_BRICK), Ingredient.fromItems(Items.GUNPOWDER), Ingredient.fromItems(Items.NETHER_WART)));
|
||||
|
||||
Ingredient stone = Ingredient.fromTag(Tags.Items.STONE);
|
||||
Ingredient coalBlock = Ingredient.fromTag(Tags.Items.STORAGE_BLOCKS_COAL);
|
||||
evt.runeAltar().accept(new RecipeRuneAltar(prefix("earth"), new ItemStack(ModItems.runeEarth, 2), costTier1, manaPowder, manaSteel, stone, coalBlock, Ingredient.fromItems(Blocks.BROWN_MUSHROOM, Blocks.RED_MUSHROOM)));
|
||||
|
||||
evt.runeAltar().accept(new RecipeRuneAltar(prefix("air"), new ItemStack(ModItems.runeAir, 2), costTier1, manaPowder, manaSteel, Ingredient.fromTag(ItemTags.CARPETS), Ingredient.fromItems(Items.FEATHER), Ingredient.fromItems(Items.STRING)));
|
||||
|
||||
Ingredient fire = Ingredient.fromTag(ModTags.Items.RUNES_FIRE);
|
||||
Ingredient water = Ingredient.fromTag(ModTags.Items.RUNES_WATER);
|
||||
Ingredient earth = Ingredient.fromTag(ModTags.Items.RUNES_EARTH);
|
||||
Ingredient air = Ingredient.fromTag(ModTags.Items.RUNES_AIR);
|
||||
|
||||
Ingredient sapling = Ingredient.fromTag(ItemTags.SAPLINGS);
|
||||
Ingredient leaves = Ingredient.fromTag(ItemTags.LEAVES);
|
||||
Ingredient sand = Ingredient.fromTag(ItemTags.SAND);
|
||||
evt.runeAltar().accept(new RecipeRuneAltar(prefix("spring"), new ItemStack(ModItems.runeSpring), costTier2, water, fire, sapling, sapling, sapling, Ingredient.fromItems(Items.WHEAT)));
|
||||
evt.runeAltar().accept(new RecipeRuneAltar(prefix("summer"), new ItemStack(ModItems.runeSummer), costTier2, earth, air, sand, sand, Ingredient.fromItems(Items.SLIME_BALL), Ingredient.fromItems(Items.MELON_SLICE)));
|
||||
evt.runeAltar().accept(new RecipeRuneAltar(prefix("autumn"), new ItemStack(ModItems.runeAutumn), costTier2, fire, air, leaves, leaves, leaves, Ingredient.fromItems(Items.SPIDER_EYE)));
|
||||
|
||||
evt.runeAltar().accept(new RecipeRuneAltar(prefix("winter"), new ItemStack(ModItems.runeWinter), costTier2, water, earth, Ingredient.fromItems(Blocks.SNOW), Ingredient.fromItems(Blocks.SNOW_BLOCK), Ingredient.fromTag(ItemTags.WOOL), Ingredient.fromItems(Blocks.CAKE)));
|
||||
|
||||
Ingredient spring = Ingredient.fromTag(ModTags.Items.RUNES_SPRING);
|
||||
Ingredient summer = Ingredient.fromTag(ModTags.Items.RUNES_SUMMER);
|
||||
Ingredient autumn = Ingredient.fromTag(ModTags.Items.RUNES_AUTUMN);
|
||||
Ingredient winter = Ingredient.fromTag(ModTags.Items.RUNES_WINTER);
|
||||
|
||||
evt.runeAltar().accept(new RecipeRuneAltar(prefix("mana"), new ItemStack(ModItems.runeMana), costTier2, manaSteel, manaSteel, manaSteel, manaSteel, manaSteel, Ingredient.fromItems(ModItems.manaPearl)));
|
||||
|
||||
evt.runeAltar().accept(new RecipeRuneAltar(prefix("lust"), new ItemStack(ModItems.runeLust), costTier3, manaDiamond, manaDiamond, summer, air));
|
||||
evt.runeAltar().accept(new RecipeRuneAltar(prefix("gluttony"), new ItemStack(ModItems.runeGluttony), costTier3, manaDiamond, manaDiamond, winter, fire));
|
||||
evt.runeAltar().accept(new RecipeRuneAltar(prefix("greed"), new ItemStack(ModItems.runeGreed), costTier3, manaDiamond, manaDiamond, spring, water));
|
||||
evt.runeAltar().accept(new RecipeRuneAltar(prefix("sloth"), new ItemStack(ModItems.runeSloth), costTier3, manaDiamond, manaDiamond, autumn, air));
|
||||
evt.runeAltar().accept(new RecipeRuneAltar(prefix("wrath"), new ItemStack(ModItems.runeWrath), costTier3, manaDiamond, manaDiamond, winter, earth));
|
||||
evt.runeAltar().accept(new RecipeRuneAltar(prefix("envy"), new ItemStack(ModItems.runeEnvy), costTier3, manaDiamond, manaDiamond, winter, water));
|
||||
evt.runeAltar().accept(new RecipeRuneAltar(prefix("pride"), new ItemStack(ModItems.runePride), costTier3, manaDiamond, manaDiamond, summer, fire));
|
||||
|
||||
evt.runeAltar().accept(new HeadRecipe(prefix("head"), new ItemStack(Items.PLAYER_HEAD), 22500, Ingredient.fromItems(Items.SKELETON_SKULL), Ingredient.fromItems(ModItems.pixieDust), Ingredient.fromItems(Items.PRISMARINE_CRYSTALS), Ingredient.fromItems(Items.NAME_TAG), Ingredient.fromItems(Items.GOLDEN_APPLE)));
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* This class is distributed as part of the Botania Mod.
|
||||
* Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*/
|
||||
package vazkii.botania.common.crafting;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.resources.IResourceManagerReloadListener;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ClientPlayerNetworkEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.network.PacketDistributor;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.recipe.RecipePetals;
|
||||
import vazkii.botania.api.recipe.RecipeRuneAltar;
|
||||
import vazkii.botania.api.recipe.RegisterRecipesEvent;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
import vazkii.botania.common.network.PacketHandler;
|
||||
import vazkii.botania.common.network.PacketSyncRecipes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SyncHandler {
|
||||
public static class ReloadListener implements IResourceManagerReloadListener {
|
||||
@Override
|
||||
public void onResourceManagerReload(@Nullable IResourceManager manager) {
|
||||
Map<ResourceLocation, RecipePetals> apothecary = new HashMap<>();
|
||||
Map<ResourceLocation, RecipeRuneAltar> runeAltar = new HashMap<>();
|
||||
|
||||
RegisterRecipesEvent evt = new RegisterRecipesEvent(
|
||||
r -> apothecary.put(r.getId(), r),
|
||||
r -> runeAltar.put(r.getId(), r)
|
||||
);
|
||||
MinecraftForge.EVENT_BUS.post(evt);
|
||||
|
||||
BotaniaAPI.runeAltarRecipes = ImmutableMap.copyOf(runeAltar);
|
||||
PacketHandler.HANDLER.send(PacketDistributor.ALL.noArg(), syncPacket());
|
||||
}
|
||||
}
|
||||
|
||||
private static PacketSyncRecipes syncPacket() {
|
||||
return new PacketSyncRecipes(BotaniaAPI.runeAltarRecipes);
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID, value = Dist.CLIENT)
|
||||
public static class ClientEvents {
|
||||
@SubscribeEvent
|
||||
public static void clientLogout(ClientPlayerNetworkEvent.LoggedOutEvent evt) {
|
||||
BotaniaAPI.runeAltarRecipes = Collections.emptyMap();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,15 +8,31 @@
|
||||
*/
|
||||
package vazkii.botania.common.crafting.recipe;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import net.minecraftforge.items.wrapper.RecipeWrapper;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
import vazkii.botania.api.recipe.RecipeRuneAltar;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.crafting.ModRecipeTypes;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HeadRecipe extends RecipeRuneAltar {
|
||||
|
||||
@@ -27,11 +43,11 @@ public class HeadRecipe extends RecipeRuneAltar {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(IItemHandler inv) {
|
||||
boolean matches = super.matches(inv);
|
||||
public boolean matches(RecipeWrapper inv, @Nonnull World world) {
|
||||
boolean matches = super.matches(inv, world);
|
||||
|
||||
if (matches) {
|
||||
for (int i = 0; i < inv.getSlots(); i++) {
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if (stack.isEmpty()) {
|
||||
break;
|
||||
@@ -50,8 +66,9 @@ public class HeadRecipe extends RecipeRuneAltar {
|
||||
return matches;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getOutput() {
|
||||
public ItemStack getRecipeOutput() {
|
||||
ItemStack stack = new ItemStack(Items.PLAYER_HEAD);
|
||||
if (!name.isEmpty()) {
|
||||
ItemNBTHelper.setString(stack, "SkullOwner", name);
|
||||
@@ -59,4 +76,37 @@ public class HeadRecipe extends RecipeRuneAltar {
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static class Serializer extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<HeadRecipe> {
|
||||
|
||||
// todo 1.15 reduce this duplication with RecipeRuneAltar, probably by introducing an abstract superclass
|
||||
@Nonnull
|
||||
@Override
|
||||
public HeadRecipe read(@Nonnull ResourceLocation id, @Nonnull JsonObject json) {
|
||||
ItemStack output = CraftingHelper.getItemStack(JSONUtils.getJsonObject(json, "output"), true);
|
||||
int mana = JSONUtils.getInt(json, "mana");
|
||||
JsonArray ingrs = JSONUtils.getJsonArray(json, "ingredients");
|
||||
List<Ingredient> inputs = new ArrayList<>();
|
||||
for (JsonElement e : ingrs) {
|
||||
inputs.add(Ingredient.deserialize(e));
|
||||
}
|
||||
return new HeadRecipe(id, output, mana, inputs.toArray(new Ingredient[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public HeadRecipe read(@Nonnull ResourceLocation id, @Nonnull PacketBuffer buf) {
|
||||
Ingredient[] inputs = new Ingredient[buf.readVarInt()];
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
inputs[i] = Ingredient.read(buf);
|
||||
}
|
||||
ItemStack output = buf.readItemStack();
|
||||
int mana = buf.readVarInt();
|
||||
return new HeadRecipe(id, output, mana, inputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(@Nonnull PacketBuffer buf, @Nonnull HeadRecipe recipe) {
|
||||
ModRecipeTypes.RUNE_SERIALIZER.write(buf, recipe);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* This class is distributed as part of the Botania Mod.
|
||||
* Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*/
|
||||
package vazkii.botania.common.network;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class PacketAck implements ILoginPacket {
|
||||
private int loginIndex;
|
||||
|
||||
public static PacketAck decode(PacketBuffer buf) {
|
||||
return new PacketAck();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoginIndex(int index) {
|
||||
this.loginIndex = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLoginIndex() {
|
||||
return loginIndex;
|
||||
}
|
||||
|
||||
public void handle(Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import net.minecraftforge.fml.network.simple.SimpleChannel;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public final class PacketHandler {
|
||||
private static final String PROTOCOL = "3";
|
||||
private static final String PROTOCOL = "4";
|
||||
public static final SimpleChannel HANDLER = NetworkRegistry.newSimpleChannel(
|
||||
new ResourceLocation(LibMisc.MOD_ID, "chan"),
|
||||
() -> PROTOCOL,
|
||||
@@ -39,20 +39,7 @@ public final class PacketHandler {
|
||||
HANDLER.registerMessage(id++, PacketDodge.class, PacketDodge::encode, PacketDodge::decode, PacketDodge::handle);
|
||||
HANDLER.registerMessage(id++, PacketJump.class, PacketJump::encode, PacketJump::decode, PacketJump::handle);
|
||||
HANDLER.registerMessage(id++, PacketItemAge.class, PacketItemAge::encode, PacketItemAge::decode, PacketItemAge::handle);
|
||||
HANDLER.registerMessage(id++, PacketSyncRecipes.class, PacketSyncRecipes::encode, PacketSyncRecipes::decode, PacketSyncRecipes::handle);
|
||||
HANDLER.registerMessage(id++, PacketIndexKeybindRequest.class, PacketIndexKeybindRequest::encode, PacketIndexKeybindRequest::decode, PacketIndexKeybindRequest::handle);
|
||||
|
||||
HANDLER.messageBuilder(PacketSyncRecipes.Login.class, id++)
|
||||
.loginIndex(ILoginPacket::getLoginIndex, ILoginPacket::setLoginIndex)
|
||||
.encoder(PacketSyncRecipes.Login::encode).decoder(PacketSyncRecipes.Login::decode)
|
||||
.consumer(FMLHandshakeHandler.biConsumerFor((hh, msg, ctx) -> msg.handle(ctx)))
|
||||
.markAsLoginPacket().add();
|
||||
|
||||
HANDLER.messageBuilder(PacketAck.class, id++)
|
||||
.loginIndex(ILoginPacket::getLoginIndex, ILoginPacket::setLoginIndex)
|
||||
.encoder((packet, buf) -> {}).decoder(PacketAck::decode)
|
||||
.consumer(FMLHandshakeHandler.indexFirst((hh, msg, ctx) -> msg.handle(ctx)))
|
||||
.add();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* This class is distributed as part of the Botania Mod.
|
||||
* Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*/
|
||||
package vazkii.botania.common.network;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.recipe.RecipePetals;
|
||||
import vazkii.botania.api.recipe.RecipeRuneAltar;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class PacketSyncRecipes {
|
||||
private Map<ResourceLocation, RecipeRuneAltar> runeAltar;
|
||||
|
||||
public PacketSyncRecipes(Map<ResourceLocation, RecipeRuneAltar> runeAltar) {
|
||||
this.runeAltar = runeAltar;
|
||||
}
|
||||
|
||||
public void encode(PacketBuffer buf) {
|
||||
buf.writeVarInt(runeAltar.size());
|
||||
for (RecipeRuneAltar recipe : runeAltar.values()) {
|
||||
recipe.write(buf);
|
||||
}
|
||||
}
|
||||
|
||||
public static PacketSyncRecipes decode(PacketBuffer buf) {
|
||||
int runeCount = buf.readVarInt();
|
||||
Map<ResourceLocation, RecipeRuneAltar> rune = Stream.generate(() -> RecipeRuneAltar.read(buf))
|
||||
.limit(runeCount)
|
||||
.collect(Collectors.toMap(RecipeRuneAltar::getId, r -> r));
|
||||
return new PacketSyncRecipes(rune);
|
||||
}
|
||||
|
||||
public void handle(Supplier<NetworkEvent.Context> ctx) {
|
||||
if (ctx.get().getDirection().getReceptionSide().isClient()) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
if (Minecraft.getInstance().isSingleplayer()) {
|
||||
return;
|
||||
}
|
||||
BotaniaAPI.runeAltarRecipes = runeAltar;
|
||||
});
|
||||
}
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
|
||||
// The login packet wraps the proper one because directly extending it will cause a freeze on the handshake.
|
||||
public static class Login implements ILoginPacket {
|
||||
private final PacketSyncRecipes wrapped;
|
||||
private int loginIndex;
|
||||
|
||||
public Login() {
|
||||
this(new PacketSyncRecipes(BotaniaAPI.runeAltarRecipes));
|
||||
}
|
||||
|
||||
public Login(PacketSyncRecipes packet) {
|
||||
this.wrapped = packet;
|
||||
}
|
||||
|
||||
public static Login decode(PacketBuffer buf) {
|
||||
return new Login(PacketSyncRecipes.decode(buf));
|
||||
}
|
||||
|
||||
public void encode(PacketBuffer buf) {
|
||||
wrapped.encode(buf);
|
||||
}
|
||||
|
||||
public void handle(Supplier<NetworkEvent.Context> ctx) {
|
||||
wrapped.handle(ctx);
|
||||
PacketHandler.HANDLER.reply(new PacketAck(), ctx.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoginIndex(int index) {
|
||||
this.loginIndex = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLoginIndex() {
|
||||
return loginIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ public class DataGenerators {
|
||||
evt.getGenerator().addProvider(new PureDaisyProvider(evt.getGenerator()));
|
||||
evt.getGenerator().addProvider(new BrewProvider(evt.getGenerator()));
|
||||
evt.getGenerator().addProvider(new PetalProvider(evt.getGenerator()));
|
||||
evt.getGenerator().addProvider(new RuneProvider(evt.getGenerator()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package vazkii.botania.data.recipes;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.IFinishedRecipe;
|
||||
import net.minecraft.data.RecipeProvider;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.Tags;
|
||||
import vazkii.botania.api.recipe.RecipeRuneAltar;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.crafting.ModRecipeTypes;
|
||||
import vazkii.botania.common.crafting.recipe.HeadRecipe;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.ModTags;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static vazkii.botania.common.lib.ResourceLocationHelper.prefix;
|
||||
|
||||
public class RuneProvider extends RecipeProvider {
|
||||
public RuneProvider(DataGenerator gen) {
|
||||
super(gen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Botania runic altar recipes";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRecipes(Consumer<IFinishedRecipe> consumer) {
|
||||
// todo 1.13 re-tagify these once the community settles down on some names
|
||||
final int costTier1 = 5200;
|
||||
final int costTier2 = 8000;
|
||||
final int costTier3 = 12000;
|
||||
|
||||
Ingredient manaSteel = Ingredient.fromTag(ModTags.Items.INGOTS_MANASTEEL);
|
||||
Ingredient manaDiamond = Ingredient.fromTag(ModTags.Items.GEMS_MANA_DIAMOND);
|
||||
Ingredient manaPowder = Ingredient.fromTag(ModTags.Items.DUSTS_MANA);
|
||||
consumer.accept(new FinishedRecipe(idFor("water"), new ItemStack(ModItems.runeWater, 2), costTier1, manaPowder, manaSteel, Ingredient.fromItems(Items.BONE_MEAL), Ingredient.fromItems(Blocks.SUGAR_CANE), Ingredient.fromItems(Items.FISHING_ROD)));
|
||||
consumer.accept(new FinishedRecipe(idFor("fire"), new ItemStack(ModItems.runeFire, 2), costTier1, manaPowder, manaSteel, Ingredient.fromItems(Items.NETHER_BRICK), Ingredient.fromItems(Items.GUNPOWDER), Ingredient.fromItems(Items.NETHER_WART)));
|
||||
|
||||
Ingredient stone = Ingredient.fromTag(Tags.Items.STONE);
|
||||
Ingredient coalBlock = Ingredient.fromTag(Tags.Items.STORAGE_BLOCKS_COAL);
|
||||
consumer.accept(new FinishedRecipe(idFor("earth"), new ItemStack(ModItems.runeEarth, 2), costTier1, manaPowder, manaSteel, stone, coalBlock, Ingredient.fromItems(Blocks.BROWN_MUSHROOM, Blocks.RED_MUSHROOM)));
|
||||
|
||||
consumer.accept(new FinishedRecipe(idFor("air"), new ItemStack(ModItems.runeAir, 2), costTier1, manaPowder, manaSteel, Ingredient.fromTag(ItemTags.CARPETS), Ingredient.fromItems(Items.FEATHER), Ingredient.fromItems(Items.STRING)));
|
||||
|
||||
Ingredient fire = Ingredient.fromTag(ModTags.Items.RUNES_FIRE);
|
||||
Ingredient water = Ingredient.fromTag(ModTags.Items.RUNES_WATER);
|
||||
Ingredient earth = Ingredient.fromTag(ModTags.Items.RUNES_EARTH);
|
||||
Ingredient air = Ingredient.fromTag(ModTags.Items.RUNES_AIR);
|
||||
|
||||
Ingredient sapling = Ingredient.fromTag(ItemTags.SAPLINGS);
|
||||
Ingredient leaves = Ingredient.fromTag(ItemTags.LEAVES);
|
||||
Ingredient sand = Ingredient.fromTag(ItemTags.SAND);
|
||||
consumer.accept(new FinishedRecipe(idFor("spring"), new ItemStack(ModItems.runeSpring), costTier2, water, fire, sapling, sapling, sapling, Ingredient.fromItems(Items.WHEAT)));
|
||||
consumer.accept(new FinishedRecipe(idFor("summer"), new ItemStack(ModItems.runeSummer), costTier2, earth, air, sand, sand, Ingredient.fromItems(Items.SLIME_BALL), Ingredient.fromItems(Items.MELON_SLICE)));
|
||||
consumer.accept(new FinishedRecipe(idFor("autumn"), new ItemStack(ModItems.runeAutumn), costTier2, fire, air, leaves, leaves, leaves, Ingredient.fromItems(Items.SPIDER_EYE)));
|
||||
|
||||
consumer.accept(new FinishedRecipe(idFor("winter"), new ItemStack(ModItems.runeWinter), costTier2, water, earth, Ingredient.fromItems(Blocks.SNOW), Ingredient.fromItems(Blocks.SNOW_BLOCK), Ingredient.fromTag(ItemTags.WOOL), Ingredient.fromItems(Blocks.CAKE)));
|
||||
|
||||
Ingredient spring = Ingredient.fromTag(ModTags.Items.RUNES_SPRING);
|
||||
Ingredient summer = Ingredient.fromTag(ModTags.Items.RUNES_SUMMER);
|
||||
Ingredient autumn = Ingredient.fromTag(ModTags.Items.RUNES_AUTUMN);
|
||||
Ingredient winter = Ingredient.fromTag(ModTags.Items.RUNES_WINTER);
|
||||
|
||||
consumer.accept(new FinishedRecipe(idFor("mana"), new ItemStack(ModItems.runeMana), costTier2, manaSteel, manaSteel, manaSteel, manaSteel, manaSteel, Ingredient.fromItems(ModItems.manaPearl)));
|
||||
|
||||
consumer.accept(new FinishedRecipe(idFor("lust"), new ItemStack(ModItems.runeLust), costTier3, manaDiamond, manaDiamond, summer, air));
|
||||
consumer.accept(new FinishedRecipe(idFor("gluttony"), new ItemStack(ModItems.runeGluttony), costTier3, manaDiamond, manaDiamond, winter, fire));
|
||||
consumer.accept(new FinishedRecipe(idFor("greed"), new ItemStack(ModItems.runeGreed), costTier3, manaDiamond, manaDiamond, spring, water));
|
||||
consumer.accept(new FinishedRecipe(idFor("sloth"), new ItemStack(ModItems.runeSloth), costTier3, manaDiamond, manaDiamond, autumn, air));
|
||||
consumer.accept(new FinishedRecipe(idFor("wrath"), new ItemStack(ModItems.runeWrath), costTier3, manaDiamond, manaDiamond, winter, earth));
|
||||
consumer.accept(new FinishedRecipe(idFor("envy"), new ItemStack(ModItems.runeEnvy), costTier3, manaDiamond, manaDiamond, winter, water));
|
||||
consumer.accept(new FinishedRecipe(idFor("pride"), new ItemStack(ModItems.runePride), costTier3, manaDiamond, manaDiamond, summer, fire));
|
||||
|
||||
consumer.accept(new FinishedHeadRecipe(idFor("head"), new ItemStack(Items.PLAYER_HEAD), 22500, Ingredient.fromItems(Items.SKELETON_SKULL), Ingredient.fromItems(ModItems.pixieDust), Ingredient.fromItems(Items.PRISMARINE_CRYSTALS), Ingredient.fromItems(Items.NAME_TAG), Ingredient.fromItems(Items.GOLDEN_APPLE)));
|
||||
}
|
||||
|
||||
private static ResourceLocation idFor(String s) {
|
||||
return prefix("rune/" + s);
|
||||
}
|
||||
|
||||
private static class FinishedRecipe implements IFinishedRecipe {
|
||||
private final ResourceLocation id;
|
||||
private final ItemStack output;
|
||||
private final int mana;
|
||||
private final Ingredient[] inputs;
|
||||
|
||||
private FinishedRecipe(ResourceLocation id, ItemStack output, int mana, Ingredient... inputs) {
|
||||
this.id = id;
|
||||
this.output = output;
|
||||
this.mana = mana;
|
||||
this.inputs = inputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonObject json) {
|
||||
json.add("output", ItemNBTHelper.serializeStack(output));
|
||||
JsonArray ingredients = new JsonArray();
|
||||
for (Ingredient ingr : inputs) {
|
||||
ingredients.add(ingr.serialize());
|
||||
}
|
||||
json.addProperty("mana", mana);
|
||||
json.add("ingredients", ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeSerializer<?> getSerializer() {
|
||||
return ModRecipeTypes.RUNE_SERIALIZER;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JsonObject getAdvancementJson() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getAdvancementID() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class FinishedHeadRecipe extends FinishedRecipe {
|
||||
private FinishedHeadRecipe(ResourceLocation id, ItemStack output, int mana, Ingredient... inputs) {
|
||||
super(id, output, mana, inputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeSerializer<?> getSerializer() {
|
||||
return ModRecipeTypes.RUNE_HEAD_SERIALIZER;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user