Initial work on the Sanguine Scientiem

Downloaded patchouli and, after lots of remorse, managed to get the beginnings of a guide.
This commit is contained in:
WayofTime 2020-10-29 15:45:38 -04:00
parent fea894a2b2
commit c159828248
32 changed files with 352 additions and 68 deletions
src/main/java

View file

@ -15,7 +15,9 @@ import com.google.common.collect.ImmutableSet;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import wayoftime.bloodmagic.api.IBloodMagicRecipeRegistrar;
import wayoftime.bloodmagic.api.impl.recipe.RecipeARC;
import wayoftime.bloodmagic.api.impl.recipe.RecipeAlchemyArray;
import wayoftime.bloodmagic.api.impl.recipe.RecipeBloodAltar;
import wayoftime.bloodmagic.api.impl.recipe.RecipeTartaricForge;
@ -250,6 +252,40 @@ public class BloodMagicRecipeRegistrar implements IBloodMagicRecipeRegistrar
return null;
}
public RecipeARC getARC(World world, @Nonnull ItemStack input, @Nonnull ItemStack arcToolInput, @Nonnull FluidStack inputFluid)
{
Preconditions.checkNotNull(input, "input cannot be null.");
Preconditions.checkNotNull(arcToolInput, "tool cannot be null.");
if (input.isEmpty() || arcToolInput.isEmpty())
return null;
List<RecipeARC> arcRecipes = world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ARC);
for (RecipeARC recipe : arcRecipes)
{
if (recipe.getInput().test(input) && recipe.getTool().test(arcToolInput))
{
if (recipe.getFluidIngredient() == null)
{
return recipe;
} else if (recipe.getFluidIngredient().test(inputFluid))
{
return recipe;
}
}
}
// if (input.isEmpty())
// return null;
//
// List<RecipeBloodAltar> altarRecipes = world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ALTAR);
//
// for (RecipeBloodAltar recipe : altarRecipes) if (recipe.getInput().test(input))
// return recipe;
return null;
}
// @Nullable
// public RecipeAlchemyTable getAlchemyTable(@Nonnull List<ItemStack> input)
// {

View file

@ -103,6 +103,8 @@ public class Constants
public static final String SOUL_FORGE_BURN = "burnTime";
public static final String SOUL_FORGE_CONSUMED = "consumedSouls";
public static final String ARC_PROGRESS = "progress";
public static final String ROUTING_MASTER = "master";
public static final String ROUTING_CONNECTION = "connections";
public static final String ROUTING_PRIORITY = "prioritiesPeople";

View file

@ -65,11 +65,28 @@ public abstract class RecipeARC extends BloodMagicRecipe
return input;
}
@Nonnull
public final Ingredient getTool()
{
return arc_tool;
}
public final FluidStackIngredient getFluidIngredient()
{
return inputFluid;
}
public final FluidStack getFluidOutput()
{
return outputFluid;
}
@Override
public final NonNullList<Ingredient> getIngredients()
{
NonNullList<Ingredient> list = NonNullList.create();
list.add(getInput());
list.add(getTool());
return list;
}

View file

@ -136,6 +136,10 @@ public class GeneratorLanguage extends LanguageProvider
add("ritual.bloodmagic.altarBuilderRitual", "The Assembly of the High Altar");
add("ritual.bloodmagic.portalRitual", "The Gate of the Fold");
// Guide
add("guide.bloodmagic.name", "Sanguine Scientiem");
add("guide.bloodmagic.landing_text", "\"It is my dear hope that by holding this tome in your hands, I may impart the knowledge of the lost art that is Blood Magic\"$(br)$(o)- Magus Arcana$()");
// Block names
addBlock(BloodMagicBlocks.BLANK_RUNE, "Blank Rune");
addBlock(BloodMagicBlocks.SPEED_RUNE, "Speed Rune");

View file

@ -23,6 +23,8 @@ import net.minecraftforge.fluids.capability.IFluidHandlerItem;
import net.minecraftforge.fluids.capability.templates.FluidTank;
import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraftforge.registries.ObjectHolder;
import wayoftime.bloodmagic.api.impl.BloodMagicAPI;
import wayoftime.bloodmagic.api.impl.recipe.RecipeARC;
import wayoftime.bloodmagic.tile.contailer.ContainerAlchemicalReactionChamber;
import wayoftime.bloodmagic.util.Constants;
import wayoftime.bloodmagic.util.MultiSlotItemHandler;
@ -42,7 +44,7 @@ public class TileAlchemicalReactionChamber extends TileInventory implements ITic
public FluidTank inputTank = new FluidTank(FluidAttributes.BUCKET_VOLUME * 20);
public FluidTank outputTank = new FluidTank(FluidAttributes.BUCKET_VOLUME * 20);
public int burnTime = 0;
public double currentProgress = 0;
public TileAlchemicalReactionChamber(TileEntityType<?> type)
{
@ -59,7 +61,7 @@ public class TileAlchemicalReactionChamber extends TileInventory implements ITic
{
super.deserialize(tag);
burnTime = tag.getInt(Constants.NBT.SOUL_FORGE_BURN);
currentProgress = tag.getDouble(Constants.NBT.ARC_PROGRESS);
CompoundNBT inputTankTag = tag.getCompound("inputtank");
inputTank.readFromNBT(inputTankTag);
@ -73,7 +75,7 @@ public class TileAlchemicalReactionChamber extends TileInventory implements ITic
{
super.serialize(tag);
tag.putInt(Constants.NBT.SOUL_FORGE_BURN, burnTime);
tag.putDouble(Constants.NBT.ARC_PROGRESS, currentProgress);
CompoundNBT inputTankTag = new CompoundNBT();
inputTank.writeToNBT(inputTankTag);
@ -165,6 +167,15 @@ public class TileAlchemicalReactionChamber extends TileInventory implements ITic
}
}
ItemStack inputStack = this.getStackInSlot(INPUT_SLOT);
ItemStack toolStack = this.getStackInSlot(ARC_TOOL_SLOT);
RecipeARC recipe = BloodMagicAPI.INSTANCE.getRecipeRegistrar().getARC(world, inputStack, toolStack, inputTank.getFluid());
if (recipe != null && outputSlotHandler.canTransferAllItemsToSlots(recipe.getAllListedOutputs(), true))
{
// We have enough fluid (if applicable) and the theoretical outputs can fit.
}
for (int i = 0; i < NUM_OUTPUTS; i++)
{
this.setInventorySlotContents(OUTPUT_SLOT + i, outputSlotHandler.getStackInSlot(i));
@ -173,47 +184,72 @@ public class TileAlchemicalReactionChamber extends TileInventory implements ITic
// FluidUtil.tryEmptyContainer(container, fluidDestination, maxAmount, player, doDrain)
}
// private boolean canCraft(RecipeTartaricForge recipe)
// {
// if (recipe == null)
// return false;
//
// ItemStack currentOutputStack = getStackInSlot(outputSlot);
// if (recipe.getOutput().isEmpty())
// return false;
// if (currentOutputStack.isEmpty())
// return true;
// if (!currentOutputStack.isItemEqual(recipe.getOutput()))
// return false;
// int result = currentOutputStack.getCount() + recipe.getOutput().getCount();
// return result <= getInventoryStackLimit() && result <= currentOutputStack.getMaxStackSize();
//
// }
//
// public void craftItem(RecipeTartaricForge recipe)
// {
// if (this.canCraft(recipe))
// {
// ItemStack currentOutputStack = getStackInSlot(outputSlot);
//
// List<ItemStack> inputList = new ArrayList<>();
// for (int i = 0; i < 4; i++) if (!getStackInSlot(i).isEmpty())
// inputList.add(getStackInSlot(i).copy());
//
// BloodMagicCraftedEvent.SoulForge event = new BloodMagicCraftedEvent.SoulForge(recipe.getOutput().copy(), inputList.toArray(new ItemStack[0]));
// MinecraftForge.EVENT_BUS.post(event);
//
// if (currentOutputStack.isEmpty())
// {
// setInventorySlotContents(outputSlot, event.getOutput());
// } else if (ItemHandlerHelper.canItemStacksStack(currentOutputStack, event.getOutput()))
// {
// currentOutputStack.grow(event.getOutput().getCount());
// }
//
// consumeInventory();
// }
// }
private boolean canCraft(RecipeARC recipe, MultiSlotItemHandler outputSlotHandler)
{
if (recipe == null)
return false;
if (outputSlotHandler.canTransferAllItemsToSlots(recipe.getAllListedOutputs(), true))
{
FluidStack outputStack = recipe.getFluidOutput();
return outputStack.isEmpty() ? true
: outputTank.fill(outputStack, FluidAction.SIMULATE) >= outputStack.getAmount();
}
return false;
}
public void craftItem(RecipeARC recipe, MultiSlotItemHandler outputSlotHandler)
{
if (this.canCraft(recipe, outputSlotHandler))
{
outputSlotHandler.canTransferAllItemsToSlots(recipe.getAllOutputs(world.rand), false);
outputTank.fill(recipe.getFluidOutput().copy(), FluidAction.EXECUTE);
consumeInventory();
}
}
public void consumeInventory()
{
ItemStack inputStack = getStackInSlot(INPUT_SLOT);
if (!inputStack.isEmpty())
{
if (inputStack.getItem().hasContainerItem(inputStack))
{
setInventorySlotContents(INPUT_SLOT, inputStack.getItem().getContainerItem(inputStack));
} else
{
inputStack.shrink(1);
if (inputStack.isEmpty())
{
setInventorySlotContents(INPUT_SLOT, ItemStack.EMPTY);
}
}
}
ItemStack toolStack = getStackInSlot(ARC_TOOL_SLOT);
if (!toolStack.isEmpty())
{
if (toolStack.isDamageable())
{
toolStack.setDamage(toolStack.getDamage() + 1);
if (toolStack.getDamage() >= toolStack.getMaxDamage())
{
setInventorySlotContents(ARC_TOOL_SLOT, ItemStack.EMPTY);
}
} else if (toolStack.getItem().hasContainerItem(toolStack))
{
setInventorySlotContents(ARC_TOOL_SLOT, toolStack.getItem().getContainerItem(inputStack));
} else
{
toolStack.shrink(1);
if (toolStack.isEmpty())
{
setInventorySlotContents(ARC_TOOL_SLOT, ItemStack.EMPTY);
}
}
}
}
@Override
public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_)

View file

@ -176,7 +176,6 @@ public class MultiSlotItemHandler implements IItemHandler
copyList[slot] = copy;
}
stack = ItemStack.EMPTY;
// System.out.println("Count: " + stack.getCount() + ", m: " + m);
break slots;
} else