Creating a usable API (#1713)

* Initial stab at API structuring

* Throwing all the things into the API*
Eliminated all internal imports
Also added some helpful comments
*except for the ritual stuff

* Reducing the API
Threw back the altar/incense/unnecessary items to main
Added in a functional API instance

* API cleanup
Removing all the unnecessities
Smushed and vaporized some redundant recipe stuffs

* Made API dummy instances
Refactor packaging
This commit is contained in:
Arcaratus 2020-11-23 21:03:19 -05:00 committed by GitHub
parent 952b6aeeb0
commit 574d6a8e74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
144 changed files with 558 additions and 990 deletions

View file

@ -12,7 +12,6 @@ import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import wayoftime.bloodmagic.api.tile.IAltarComponent;
import wayoftime.bloodmagic.impl.BloodMagicAPI;
import wayoftime.bloodmagic.common.block.BlockBloodRune;
import wayoftime.bloodmagic.tile.TileAltar;
@ -35,10 +34,6 @@ public class AltarUtil
BlockPos componentPos = pos.add(component.getOffset());
BlockState worldState = world.getBlockState(componentPos);
if (worldState.getBlock() instanceof IAltarComponent)
if (((IAltarComponent) worldState.getBlock()).getType(world, worldState, componentPos) == component.getComponent())
continue;
if (component.getComponent() == ComponentType.NOTAIR && worldState.getMaterial() != Material.AIR
&& !worldState.getMaterial().isLiquid())
continue;

View file

@ -20,13 +20,13 @@ import net.minecraftforge.fluids.capability.templates.FluidTank;
import net.minecraftforge.items.ItemHandlerHelper;
import wayoftime.bloodmagic.api.event.BloodMagicCraftedEvent;
import wayoftime.bloodmagic.impl.BloodMagicAPI;
import wayoftime.bloodmagic.api.recipe.RecipeBloodAltar;
import wayoftime.bloodmagic.recipe.RecipeBloodAltar;
import wayoftime.bloodmagic.block.enums.BloodRuneType;
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
import wayoftime.bloodmagic.core.data.Binding;
import wayoftime.bloodmagic.api.item.IBindable;
import wayoftime.bloodmagic.orb.BloodOrb;
import wayoftime.bloodmagic.orb.IBloodOrb;
import wayoftime.bloodmagic.common.item.IBindable;
import wayoftime.bloodmagic.common.item.BloodOrb;
import wayoftime.bloodmagic.common.item.IBloodOrb;
import wayoftime.bloodmagic.tile.TileAltar;
import wayoftime.bloodmagic.util.Constants;
import wayoftime.bloodmagic.util.helper.NetworkHelper;
@ -201,7 +201,7 @@ public class BloodAltar// implements IFluidHandler
RecipeBloodAltar recipe = BloodMagicAPI.INSTANCE.getRecipeRegistrar().getBloodAltar(tileAltar.getWorld(), input);
if (recipe != null)
{
if (recipe.getMinimumTier().ordinal() <= altarTier.ordinal())
if (recipe.getMinimumTier() <= altarTier.ordinal())
{
this.isActive = true;
this.recipe = recipe;

View file

@ -9,7 +9,6 @@ public enum ComponentType
{
GLOWSTONE, BLOODSTONE, BEACON, BLOODRUNE, CRYSTAL, NOTAIR;
public static final ComponentType[] VALUES = values();
private static final String BASE = "chat.bloodmagic.altar.comp.";
private String key;
@ -22,4 +21,17 @@ public enum ComponentType
{
return key;
}
public static ComponentType getType(String type)
{
for (ComponentType t : values())
{
if (t.name().equalsIgnoreCase(type))
{
return t;
}
}
return null;
}
}

View file

@ -0,0 +1,61 @@
package wayoftime.bloodmagic.altar;
/**
* Any Tile that implements this will be considered to be a Blood Altar
*/
public interface IBloodAltar
{
int getCapacity();
int getCurrentBlood();
/**
* @return - The actual human-readable tier (ordinal + 1) of the altar
*/
int getTier();
int getProgress();
float getSacrificeMultiplier();
float getSelfSacrificeMultiplier();
float getOrbMultiplier();
float getDislocationMultiplier();
float getConsumptionMultiplier();
float getConsumptionRate();
int getChargingRate();
int getChargingFrequency();
int getTotalCharge();
int getLiquidRequired();
int getBufferCapacity();
void sacrificialDaggerCall(int amount, boolean isSacrifice);
void startCycle();
void checkTier();
boolean isActive();
void setActive();
int fillMainTank(int amount);
/**
* Will set the altar to initiate a cooldown cycle after it crafts before
* starting to craft again, giving the user time to interact with the altar.
* This can only be set while the altar is not active.
*
* @param cooldown - How long the cooldown should last
*/
void requestPauseAfterCrafting(int cooldown);
}

View file

@ -0,0 +1,16 @@
package wayoftime.bloodmagic.altar;
import javax.annotation.Nullable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import wayoftime.bloodmagic.block.enums.BloodRuneType;
/**
* Any Block that implements this interface wil be considered as Blood Runes for the Blood Altar
*/
public interface IBloodRune
{
@Nullable
BloodRuneType getBloodRune(World world, BlockPos pos);
}