Swap the API packages
The new one is now built for the api jar and the old one is now internal. It will slowly be moved around to sane places within the internal code. Most of the features provided in the old "api" are addon specific features which will generally rely on the main jar anyways. The new API will be specific to compatibility features, such as blacklists, recipes, and value modification.
This commit is contained in:
parent
4fbcac6aa2
commit
ddaadfbe52
421 changed files with 1006 additions and 999 deletions
|
@ -0,0 +1,67 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockStack {
|
||||
private final Block block;
|
||||
private final int meta;
|
||||
private final IBlockState state;
|
||||
|
||||
public BlockStack(Block block, int meta) {
|
||||
this.block = block;
|
||||
this.meta = meta;
|
||||
this.state = block.getStateFromMeta(meta);
|
||||
}
|
||||
|
||||
public BlockStack(Block block) {
|
||||
this(block, 0);
|
||||
}
|
||||
|
||||
public ItemStack getItemStack() {
|
||||
return new ItemStack(block, 1, meta);
|
||||
}
|
||||
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
public int getMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
public IBlockState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof BlockStack)) return false;
|
||||
|
||||
BlockStack that = (BlockStack) o;
|
||||
|
||||
if (meta != that.meta) return false;
|
||||
return block != null ? block.equals(that.block) : that.block == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = block != null ? block.hashCode() : 0;
|
||||
result = 31 * result + meta;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getBlock().getRegistryName() + ":" + getMeta();
|
||||
}
|
||||
|
||||
public static BlockStack getStackFromPos(World world, BlockPos pos) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
return new BlockStack(state.getBlock(), state.getBlock().getMetaFromState(state));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.util.helper.LogHelper;
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
||||
/**
|
||||
* The primary API class. Includes helper methods and blacklists.
|
||||
* <p>
|
||||
* Some API methods can be used via IMC instead. The supported methods are:
|
||||
*/
|
||||
// TODO - Nuke this class
|
||||
public class BloodMagicAPI {
|
||||
public static boolean loggingEnabled;
|
||||
|
||||
public static LogHelper logger = new LogHelper("BloodMagic|API");
|
||||
|
||||
public static DamageSource damageSource = new DamageSourceBloodMagic();
|
||||
}
|
|
@ -0,0 +1,167 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class Constants {
|
||||
public static class NBT {
|
||||
public static final String OWNER_UUID = "ownerUUID";
|
||||
public static final String OWNER_NAME = "ownerNAME";
|
||||
public static final String USES = "uses";
|
||||
public static final String ACTIVATED = "activated";
|
||||
public static final String UNUSABLE = "unusable";
|
||||
public static final String SACRIFICE = "sacrifice";
|
||||
public static final String DIMENSION_ID = "dimensionId";
|
||||
public static final String X_COORD = "xCoord";
|
||||
public static final String Y_COORD = "yCoord";
|
||||
public static final String Z_COORD = "zCoord";
|
||||
public static final String PORTAL_LOCATION = "portalLocation";
|
||||
public static final String ORB_TIER = "orbTier";
|
||||
public static final String CURRENT_ESSENCE = "currentEssence";
|
||||
public static final String CURRENT_RITUAL = "currentRitual";
|
||||
public static final String CURRENT_RITUAL_TAG = "currentRitualTag";
|
||||
public static final String IS_RUNNING = "isRunning";
|
||||
public static final String IS_REDSTONED = "isStoned";
|
||||
public static final String RUNTIME = "runtime";
|
||||
public static final String DIRECTION = "direction";
|
||||
public static final String REAGENT_TANKS = "reagentTanks";
|
||||
public static final String CURRENT_INCENSE = "BM:CurrentIncense";
|
||||
public static final String CURRENT_PURITY = "BM:CurrentPurity";
|
||||
public static final String EMPTY = "Empty";
|
||||
public static final String OUTPUT_AMOUNT = "outputAmount";
|
||||
public static final String INPUT_AMOUNT = "inputAmount";
|
||||
public static final String STORED_LP = "storedLP";
|
||||
public static final String RITUAL_READER = "ritualReaderState";
|
||||
public static final String ITEMS = "Items";
|
||||
public static final String SLOT = "Slot";
|
||||
|
||||
public static final String ALTAR = "bloodAltar";
|
||||
public static final String ALTAR_TIER = "upgradeLevel";
|
||||
public static final String ALTAR_ACTIVE = "isActive";
|
||||
public static final String ALTAR_LIQUID_REQ = "liquidRequired";
|
||||
public static final String ALTAR_FILLABLE = "fillable";
|
||||
public static final String ALTAR_UPGRADED = "isUpgraded";
|
||||
public static final String ALTAR_CONSUMPTION_RATE = "consumptionRate";
|
||||
public static final String ALTAR_DRAIN_RATE = "drainRate";
|
||||
public static final String ALTAR_CONSUMPTION_MULTIPLIER = "consumptionMultiplier";
|
||||
public static final String ALTAR_EFFICIENCY_MULTIPLIER = "efficiencyMultiplier";
|
||||
public static final String ALTAR_SELF_SACRIFICE_MULTIPLIER = "selfSacrificeMultiplier";
|
||||
public static final String ALTAR_SACRIFICE_MULTIPLIER = "sacrificeMultiplier";
|
||||
public static final String ALTAR_CAPACITY_MULTIPLIER = "capacityMultiplier";
|
||||
public static final String ALTAR_ORB_CAPACITY_MULTIPLIER = "orbCapacityMultiplier";
|
||||
public static final String ALTAR_DISLOCATION_MULTIPLIER = "dislocationMultiplier";
|
||||
public static final String ALTAR_CAPACITY = "capacity";
|
||||
public static final String ALTAR_BUFFER_CAPACITY = "bufferCapacity";
|
||||
public static final String ALTAR_PROGRESS = "progress";
|
||||
public static final String ALTAR_IS_RESULT_BLOCK = "isResultBlock";
|
||||
public static final String ALTAR_LOCKDOWN_DURATION = "lockdownDuration";
|
||||
public static final String ALTAR_ACCELERATION_UPGRADES = "accelerationUpgrades";
|
||||
public static final String ALTAR_DEMON_BLOOD_DURATION = "demonBloodDuration";
|
||||
public static final String ALTAR_COOLDOWN_AFTER_CRAFTING = "cooldownAfterCrafting";
|
||||
public static final String ALTAR_TOTAL_CHARGE = "totalCharge";
|
||||
public static final String ALTAR_MAX_CHARGE = "maxCharge";
|
||||
public static final String ALTAR_CHARGE_RATE = "chargeRate";
|
||||
public static final String ALTAR_CHARGE_FREQUENCY = "chargeFrequency";
|
||||
public static final String ALTAR_CURRENT_TIER_DISPLAYED = "currentTierDisplayed";
|
||||
|
||||
public static final String ALTARMAKER_CURRENT_TIER = "currentTier";
|
||||
|
||||
public static final String PROJECTILE_TICKS_IN_AIR = "projectileTicksInAir";
|
||||
public static final String PROJECTILE_MAX_TICKS_IN_AIR = "projectileMaxTicksInAir";
|
||||
|
||||
public static final String TICKS_REMAINING = "ticksRemaining";
|
||||
public static final String CONTAINED_BLOCK_NAME = "containedBlockName";
|
||||
public static final String CONTAINED_BLOCK_META = "containedBlockMeta";
|
||||
public static final String CONTAINED_TILE_ENTITY = "containedTileEntity";
|
||||
|
||||
public static final String PREVIOUS_INPUT = "previousInput";
|
||||
|
||||
public static final String LIVING_ARMOUR = "livingArmour";
|
||||
|
||||
public static final String CHARGE_TIME = "chargeTime";
|
||||
public static final String HELD_DOWN = "heldDown";
|
||||
|
||||
public static final String UPGRADE_POISON_TIMER = "poisonTimer";
|
||||
public static final String UPGRADE_FIRE_TIMER = "fireTimer";
|
||||
|
||||
public static final String SOULS = "souls";
|
||||
public static final String SOUL_SWORD_DAMAGE = "soulSwordDamage";
|
||||
public static final String SOUL_SWORD_ACTIVE_DRAIN = "soulSwordActiveDrain";
|
||||
public static final String SOUL_SWORD_DROP = "soulSwordDrop";
|
||||
public static final String SOUL_SWORD_STATIC_DROP = "soulSwordStaticDrop";
|
||||
public static final String SOUL_SWORD_HEALTH = "soulSwordHealth";
|
||||
public static final String SOUL_SWORD_ATTACK_SPEED = "soulSwordAttackSpeed";
|
||||
public static final String SOUL_SWORD_SPEED = "soulSwordSpeed";
|
||||
public static final String SOUL_SWORD_DIG_SPEED = "soulSwordDigSpeed";
|
||||
public static final String WILL_TYPE = "demonWillType";
|
||||
|
||||
public static final String SOUL_FORGE_BURN = "burnTime";
|
||||
public static final String SOUL_FORGE_CONSUMED = "consumedSouls";
|
||||
|
||||
public static final String ROUTING_MASTER = "master";
|
||||
public static final String ROUTING_CONNECTION = "connections";
|
||||
public static final String ROUTING_PRIORITY = "prioritiesPeople";
|
||||
public static final String ROUTING_MASTER_GENERAL = "generalList";
|
||||
public static final String ROUTING_MASTER_INPUT = "inputList";
|
||||
public static final String ROUTING_MASTER_OUTPUT = "outputList";
|
||||
|
||||
public static final String GHOST_STACK_SIZE = "stackSize";
|
||||
|
||||
public static final String ITEM_INVENTORY = "itemInventory";
|
||||
|
||||
public static final String BLOCKPOS_CONNECTION = "connections";
|
||||
|
||||
public static final String CURRENT_SIGIL = "currentSigil";
|
||||
public static final String MOST_SIG = "mostSig";
|
||||
public static final String LEAST_SIG = "leastSig";
|
||||
public static final String COLOR = "color";
|
||||
|
||||
public static final String POTION_AUGMENT_LENGHT = "length:";
|
||||
public static final String POTION_AUGMENT_STRENGTH = "strength:";
|
||||
public static final String POTION_IMPURITY = "impurity";
|
||||
|
||||
public static final String TANK = "tank";
|
||||
}
|
||||
|
||||
public static class Mod {
|
||||
public static final String DOMAIN = BloodMagic.MODID.toLowerCase(Locale.ENGLISH) + ":";
|
||||
}
|
||||
|
||||
public static final class Gui {
|
||||
public static final int TELEPOSER_GUI = 0;
|
||||
public static final int SOUL_FORGE_GUI = 1;
|
||||
public static final int ROUTING_NODE_GUI = 2;
|
||||
public static final int MASTER_ROUTING_NODE_GUI = 3;
|
||||
public static final int ALCHEMY_TABLE_GUI = 4;
|
||||
public static final int SIGIL_HOLDING_GUI = 5;
|
||||
}
|
||||
|
||||
public static class Compat {
|
||||
public static final String JEI_CATEGORY_ALTAR = BloodMagic.MODID + ":altar";
|
||||
public static final String JEI_CATEGORY_BINDING = BloodMagic.MODID + ":binding";
|
||||
public static final String JEI_CATEGORY_ALCHEMYARRAY = BloodMagic.MODID + ":alchemyArray";
|
||||
public static final String JEI_CATEGORY_SOULFORGE = BloodMagic.MODID + ":soulForge";
|
||||
public static final String JEI_CATEGORY_ALCHEMYTABLE = BloodMagic.MODID + ":salchemyTable";
|
||||
public static final String JEI_CATEGORY_ARMOURDOWNGRADE = BloodMagic.MODID + ":armourDowngrade";
|
||||
|
||||
public static final String WAILA_CONFIG_BYPASS_SNEAK = BloodMagic.MODID + ".bypassSneak";
|
||||
public static final String WAILA_CONFIG_ALTAR = BloodMagic.MODID + ".bloodAltar";
|
||||
public static final String WAILA_CONFIG_TELEPOSER = BloodMagic.MODID + ".teleposer";
|
||||
public static final String WAILA_CONFIG_RITUAL = BloodMagic.MODID + ".ritualController";
|
||||
public static final String WAILA_CONFIG_ARRAY = BloodMagic.MODID + ".array";
|
||||
public static final String WAILA_CONFIG_BLOOD_TANK = BloodMagic.MODID + ".bloodTank";
|
||||
|
||||
public static final Item THAUMCRAFT_GOGGLES = ForgeRegistries.ITEMS.getValue(new ResourceLocation("Thaumcraft", "goggles"));
|
||||
}
|
||||
|
||||
public static class Misc {
|
||||
public static final int POTION_ARRAY_SIZE = 256;
|
||||
public static final float ALTERED_STEP_HEIGHT = 1.00314159f;
|
||||
public static final int NIGHT_VISION_CONSTANT_BEGIN = 30002;
|
||||
public static final int NIGHT_VISION_CONSTANT_END = 30000;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally;
|
||||
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
|
||||
public class DamageSourceBloodMagic extends DamageSource {
|
||||
public DamageSourceBloodMagic() {
|
||||
super("bloodMagic");
|
||||
|
||||
setDamageBypassesArmor();
|
||||
setDamageIsAbsolute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDeathMessage(EntityLivingBase livingBase) {
|
||||
return new TextComponentString(TextHelper.localizeEffect("chat.bloodmagic.damageSource", livingBase.getName()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemStackWrapper {
|
||||
public final Item item;
|
||||
public final int stackSize;
|
||||
public final int meta;
|
||||
public NBTTagCompound nbtTag;
|
||||
|
||||
public ItemStackWrapper(Item item, int stackSize, int meta) {
|
||||
this.item = item;
|
||||
this.stackSize = stackSize;
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
public ItemStackWrapper(Item item, int stackSize) {
|
||||
this(item, stackSize, 0);
|
||||
}
|
||||
|
||||
public ItemStackWrapper(Item item) {
|
||||
this(item, 1, 0);
|
||||
}
|
||||
|
||||
public ItemStackWrapper(Block block, int stackSize, int meta) {
|
||||
this(Item.getItemFromBlock(block), stackSize, meta);
|
||||
}
|
||||
|
||||
public ItemStackWrapper(Block block, int stackSize) {
|
||||
this(block, stackSize, 0);
|
||||
}
|
||||
|
||||
public ItemStackWrapper(Block block) {
|
||||
this(block, 1, 0);
|
||||
}
|
||||
|
||||
public ItemStackWrapper(BlockStack blockStack) {
|
||||
this(blockStack.getBlock(), 1, blockStack.getMeta());
|
||||
}
|
||||
|
||||
public ItemStack toStack() {
|
||||
return new ItemStack(item, stackSize, meta);
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return toStack().getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return stackSize + "x" + item.getUnlocalizedName() + "@" + this.meta;
|
||||
}
|
||||
|
||||
public ItemStack toStack(int count) {
|
||||
ItemStack result = new ItemStack(item, count, meta);
|
||||
result.setTagCompound(nbtTag);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Item getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public int getStackSize() {
|
||||
return stackSize;
|
||||
}
|
||||
|
||||
public int getMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
public NBTTagCompound getNbtTag() {
|
||||
return nbtTag;
|
||||
}
|
||||
|
||||
public void setNbtTag(NBTTagCompound nbtTag) {
|
||||
this.nbtTag = nbtTag;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ItemStackWrapper getHolder(ItemStack stack) {
|
||||
if (stack.isEmpty())
|
||||
return null;
|
||||
|
||||
ItemStackWrapper wrapper = new ItemStackWrapper(stack.getItem(), stack.getCount(), stack.getItemDamage());
|
||||
wrapper.setNbtTag(stack.getTagCompound());
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
public static List<ItemStackWrapper> toWrapperList(List<ItemStack> itemStackList) {
|
||||
List<ItemStackWrapper> wrapperList = new ArrayList<ItemStackWrapper>();
|
||||
for (ItemStack stack : itemStackList)
|
||||
wrapperList.add(ItemStackWrapper.getHolder(stack));
|
||||
|
||||
return wrapperList;
|
||||
}
|
||||
|
||||
public static List<ItemStack> toStackList(List<ItemStackWrapper> wrapperList) {
|
||||
List<ItemStack> stackList = new ArrayList<ItemStack>();
|
||||
for (ItemStackWrapper wrapper : wrapperList)
|
||||
stackList.add(wrapper.toStack());
|
||||
|
||||
return stackList;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.alchemyCrafting;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.iface.IAlchemyArray;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class AlchemyArrayEffect {
|
||||
public final String key;
|
||||
|
||||
public AlchemyArrayEffect(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public abstract boolean update(TileEntity tile, int ticksActive);
|
||||
|
||||
public abstract void writeToNBT(NBTTagCompound tag);
|
||||
|
||||
public abstract void readFromNBT(NBTTagCompound tag);
|
||||
|
||||
public abstract AlchemyArrayEffect getNewCopy();
|
||||
|
||||
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity) {
|
||||
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.alchemyCrafting;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect {
|
||||
public final ItemStack outputStack;
|
||||
public int tickLimit;
|
||||
|
||||
public AlchemyArrayEffectCrafting(ItemStack outputStack) {
|
||||
this(outputStack, 200);
|
||||
}
|
||||
|
||||
public AlchemyArrayEffectCrafting(ItemStack outputStack, int tickLimit) {
|
||||
this(outputStack.toString() + tickLimit, outputStack, tickLimit);
|
||||
}
|
||||
|
||||
public AlchemyArrayEffectCrafting(String key, ItemStack outputStack, int tickLimit) {
|
||||
super(key);
|
||||
this.outputStack = outputStack;
|
||||
this.tickLimit = tickLimit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TileEntity tile, int ticksActive) {
|
||||
// TODO: Add recipe rechecking to verify nothing screwy is going on.
|
||||
if (tile.getWorld().isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ticksActive >= tickLimit) {
|
||||
BlockPos pos = tile.getPos();
|
||||
|
||||
ItemStack output = outputStack.copy();
|
||||
|
||||
EntityItem outputEntity = new EntityItem(tile.getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output);
|
||||
|
||||
tile.getWorld().spawnEntity(outputEntity);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlchemyArrayEffect getNewCopy() {
|
||||
return new AlchemyArrayEffectCrafting(key, outputStack, tickLimit);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,151 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.alchemyCrafting;
|
||||
|
||||
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class AlchemyCircleRenderer {
|
||||
public final ResourceLocation arrayResource;
|
||||
public float offsetFromFace = -0.9f;
|
||||
|
||||
public AlchemyCircleRenderer() {
|
||||
this(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png"));
|
||||
}
|
||||
|
||||
public AlchemyCircleRenderer(ResourceLocation arrayResource) {
|
||||
this.arrayResource = arrayResource;
|
||||
}
|
||||
|
||||
public float getRotation(float craftTime) {
|
||||
float offset = 2;
|
||||
if (craftTime >= offset) {
|
||||
float modifier = (float) Math.pow(craftTime - offset, 1.5);
|
||||
return modifier * 1f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getSecondaryRotation(float craftTime) {
|
||||
float offset = 50;
|
||||
if (craftTime >= offset) {
|
||||
float modifier = (float) Math.pow(craftTime - offset, 1.7);
|
||||
return modifier * 0.5f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getSizeModifier(float craftTime) {
|
||||
if (craftTime >= 150 && craftTime <= 250) {
|
||||
return (200 - craftTime) / 50f;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public float getVerticalOffset(float craftTime) {
|
||||
if (craftTime >= 5) {
|
||||
if (craftTime <= 40) {
|
||||
return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3));
|
||||
} else {
|
||||
return -0.4f;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) {
|
||||
if (!(tile instanceof TileAlchemyArray)) {
|
||||
return;
|
||||
}
|
||||
|
||||
TileAlchemyArray tileArray = (TileAlchemyArray) tile;
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder wr = tessellator.getBuffer();
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
// float rot = (float)(this.worldObj.provider.getWorldTime() % (360 /
|
||||
// this.rotationspeed) * this.rotationspeed) + this.rotationspeed * f;
|
||||
float rot = getRotation(craftTime);
|
||||
float secondaryRot = getSecondaryRotation(craftTime);
|
||||
|
||||
float size = 1.0F * getSizeModifier(craftTime);
|
||||
|
||||
// Bind the texture to the circle
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(arrayResource);
|
||||
|
||||
GlStateManager.disableCull();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(770, 1);
|
||||
|
||||
GlStateManager.translate(x, y, z);
|
||||
|
||||
// Specify which face this "circle" is located on
|
||||
EnumFacing sideHit = EnumFacing.UP;
|
||||
EnumFacing rotation = tileArray.getRotation();
|
||||
|
||||
GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace);
|
||||
|
||||
switch (sideHit) {
|
||||
case DOWN:
|
||||
GlStateManager.translate(0, 0, 1);
|
||||
GlStateManager.rotate(-90.0f, 1, 0, 0);
|
||||
break;
|
||||
case EAST:
|
||||
GlStateManager.rotate(-90.0f, 0, 1, 0);
|
||||
GlStateManager.translate(0, 0, -1);
|
||||
break;
|
||||
case NORTH:
|
||||
break;
|
||||
case SOUTH:
|
||||
GlStateManager.rotate(180.0f, 0, 1, 0);
|
||||
GlStateManager.translate(-1, 0, -1);
|
||||
break;
|
||||
case UP:
|
||||
GlStateManager.translate(0, 1, 0);
|
||||
GlStateManager.rotate(90.0f, 1, 0, 0);
|
||||
break;
|
||||
case WEST:
|
||||
GlStateManager.translate(0, 0, 1);
|
||||
GlStateManager.rotate(90.0f, 0, 1, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(0.5f, 0.5f, getVerticalOffset(craftTime));
|
||||
GlStateManager.rotate(rotation.getHorizontalAngle() + 180, 0, 0, 1);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.rotate(rot, 0, 0, 1);
|
||||
GlStateManager.rotate(secondaryRot, 1, 0, 0);
|
||||
GlStateManager.rotate(secondaryRot * 0.45812f, 0, 0, 1);
|
||||
double var31 = 0.0D;
|
||||
double var33 = 1.0D;
|
||||
double var35 = 0;
|
||||
double var37 = 1;
|
||||
|
||||
GlStateManager.color(1f, 1f, 1f, 1f);
|
||||
wr.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||
// wr.setBrightness(200);
|
||||
wr.pos(size / 2f, size / 2f, 0.0D).tex(var33, var37).endVertex();
|
||||
wr.pos(size / 2f, -size / 2f, 0.0D).tex(var33, var35).endVertex();
|
||||
wr.pos(-size / 2f, -size / 2f, 0.0D).tex(var31, var35).endVertex();
|
||||
wr.pos(-size / 2f, size / 2f, 0.0D).tex(var31, var37).endVertex();
|
||||
tessellator.draw();
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
// GlStateManager.depthMask(true);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableCull();
|
||||
// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.altar;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
* Used for building the altar structure.
|
||||
*/
|
||||
public class AltarComponent {
|
||||
private BlockPos offset;
|
||||
private boolean upgradeSlot;
|
||||
|
||||
private EnumAltarComponent component;
|
||||
|
||||
/**
|
||||
* Sets a component location for the altar.
|
||||
*
|
||||
* @param offset - Where the block should be in relation to the Altar
|
||||
* @param component - The type of Component the location should contain
|
||||
*/
|
||||
public AltarComponent(BlockPos offset, EnumAltarComponent component) {
|
||||
this.offset = offset;
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use for setting a location at which there must be a block, but the type
|
||||
* of block does not matter.
|
||||
*
|
||||
* @param offset - Where the block should be in relation to the Altar
|
||||
*/
|
||||
public AltarComponent(BlockPos offset) {
|
||||
this(offset, EnumAltarComponent.NOTAIR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the location to an upgrade slot.
|
||||
*
|
||||
* @return the current instance for further use.
|
||||
*/
|
||||
public AltarComponent setUpgradeSlot() {
|
||||
this.upgradeSlot = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BlockPos getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public boolean isUpgradeSlot() {
|
||||
return upgradeSlot;
|
||||
}
|
||||
|
||||
public EnumAltarComponent getComponent() {
|
||||
return component;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.altar;
|
||||
|
||||
public class AltarUpgrade {
|
||||
private int speedCount;
|
||||
private int efficiencyCount;
|
||||
private int sacrificeCount;
|
||||
private int selfSacrificeCount;
|
||||
private int displacementCount;
|
||||
private int capacityCount;
|
||||
private int orbCapacityCount;
|
||||
private int betterCapacityCount;
|
||||
private int accelerationCount;
|
||||
private int chargingCount;
|
||||
|
||||
public AltarUpgrade(int speedCount, int efficiencyCount, int sacrificeCount, int selfSacrificeCount, int displacementCount, int capacityCount, int orbCapacityCount, int betterCapacityCount, int accelerationCount, int chargingCount) {
|
||||
this.speedCount = speedCount;
|
||||
this.efficiencyCount = efficiencyCount;
|
||||
this.sacrificeCount = sacrificeCount;
|
||||
this.selfSacrificeCount = selfSacrificeCount;
|
||||
this.displacementCount = displacementCount;
|
||||
this.capacityCount = capacityCount;
|
||||
this.orbCapacityCount = orbCapacityCount;
|
||||
this.betterCapacityCount = betterCapacityCount;
|
||||
this.accelerationCount = accelerationCount;
|
||||
this.chargingCount = chargingCount;
|
||||
}
|
||||
|
||||
public AltarUpgrade() {
|
||||
}
|
||||
|
||||
// Adders
|
||||
|
||||
public AltarUpgrade addSpeed() {
|
||||
speedCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addEfficiency() {
|
||||
efficiencyCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addSacrifice() {
|
||||
sacrificeCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addSelfSacrifice() {
|
||||
selfSacrificeCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addDisplacement() {
|
||||
displacementCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addCapacity() {
|
||||
capacityCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addOrbCapacity() {
|
||||
orbCapacityCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addBetterCapacity() {
|
||||
betterCapacityCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addAcceleration() {
|
||||
accelerationCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addCharging() {
|
||||
chargingCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getSpeedCount() {
|
||||
return speedCount;
|
||||
}
|
||||
|
||||
public int getEfficiencyCount() {
|
||||
return efficiencyCount;
|
||||
}
|
||||
|
||||
public int getSacrificeCount() {
|
||||
return sacrificeCount;
|
||||
}
|
||||
|
||||
public int getSelfSacrificeCount() {
|
||||
return selfSacrificeCount;
|
||||
}
|
||||
|
||||
public int getDisplacementCount() {
|
||||
return displacementCount;
|
||||
}
|
||||
|
||||
public int getCapacityCount() {
|
||||
return capacityCount;
|
||||
}
|
||||
|
||||
public int getOrbCapacityCount() {
|
||||
return orbCapacityCount;
|
||||
}
|
||||
|
||||
public int getBetterCapacityCount() {
|
||||
return betterCapacityCount;
|
||||
}
|
||||
|
||||
public int getAccelerationCount() {
|
||||
return accelerationCount;
|
||||
}
|
||||
|
||||
public int getChargingCount() {
|
||||
return chargingCount;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.altar;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* List of different components used to construct different tiers of altars.
|
||||
*/
|
||||
public enum EnumAltarComponent {
|
||||
GLOWSTONE,
|
||||
BLOODSTONE,
|
||||
BEACON,
|
||||
BLOODRUNE,
|
||||
CRYSTAL,
|
||||
NOTAIR;
|
||||
|
||||
public static final EnumAltarComponent[] VALUES = values();
|
||||
private static final String BASE = "chat.bloodmagic.altar.comp.";
|
||||
private String key;
|
||||
|
||||
EnumAltarComponent() {
|
||||
this.key = BASE + name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.altar;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
//@formatter:off
|
||||
public enum EnumAltarTier {
|
||||
ONE(), TWO() {
|
||||
@Override
|
||||
public void buildComponents() {
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-1, -1, -1), EnumAltarComponent.BLOODRUNE));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(0, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(1, -1, -1), EnumAltarComponent.BLOODRUNE));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-1, -1, 0), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(1, -1, 0), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-1, -1, 1), EnumAltarComponent.BLOODRUNE));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(0, -1, 1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(1, -1, 1), EnumAltarComponent.BLOODRUNE));
|
||||
}
|
||||
},
|
||||
THREE() {
|
||||
@Override
|
||||
public void buildComponents() {
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-1, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(0, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(1, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-1, -1, 0), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(1, -1, 0), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-1, -1, 1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(0, -1, 1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(1, -1, 1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-3, -1, -3)));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-3, 0, -3)));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(3, -1, -3)));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(3, 0, -3)));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-3, -1, 3)));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-3, 0, 3)));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(3, -1, 3)));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(3, 0, 3)));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-3, 1, -3), EnumAltarComponent.GLOWSTONE));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(3, 1, -3), EnumAltarComponent.GLOWSTONE));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-3, 1, 3), EnumAltarComponent.GLOWSTONE));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(3, 1, 3), EnumAltarComponent.GLOWSTONE));
|
||||
|
||||
for (int i = -2; i <= 2; i++) {
|
||||
altarComponents.add(new AltarComponent(new BlockPos(3, -2, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-3, -2, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(i, -2, 3), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(i, -2, -3), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
}
|
||||
}
|
||||
},
|
||||
FOUR() {
|
||||
@Override
|
||||
public void buildComponents() {
|
||||
altarComponents.addAll(THREE.getAltarComponents());
|
||||
|
||||
for (int i = -3; i <= 3; i++) {
|
||||
altarComponents.add(new AltarComponent(new BlockPos(5, -3, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-5, -3, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(i, -3, 5), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(i, -3, -5), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
}
|
||||
|
||||
for (int i = -2; i <= 1; i++) {
|
||||
altarComponents.add(new AltarComponent(new BlockPos(5, i, 5)));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(5, i, -5)));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-5, i, -5)));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-5, i, 5)));
|
||||
}
|
||||
|
||||
altarComponents.add(new AltarComponent(new BlockPos(5, 2, 5), EnumAltarComponent.BLOODSTONE));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(5, 2, -5), EnumAltarComponent.BLOODSTONE));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-5, 2, -5), EnumAltarComponent.BLOODSTONE));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-5, 2, 5), EnumAltarComponent.BLOODSTONE));
|
||||
}
|
||||
},
|
||||
FIVE() {
|
||||
@Override
|
||||
public void buildComponents() {
|
||||
altarComponents.addAll(FOUR.getAltarComponents());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-8, -3, 8), EnumAltarComponent.BEACON));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-8, -3, -8), EnumAltarComponent.BEACON));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(8, -3, -8), EnumAltarComponent.BEACON));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(8, -3, 8), EnumAltarComponent.BEACON));
|
||||
|
||||
for (int i = -6; i <= 6; i++) {
|
||||
altarComponents.add(new AltarComponent(new BlockPos(8, -4, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-8, -4, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(i, -4, 8), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(i, -4, -8), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
}
|
||||
}
|
||||
},
|
||||
SIX() {
|
||||
@Override
|
||||
public void buildComponents() {
|
||||
altarComponents.addAll(FIVE.getAltarComponents());
|
||||
|
||||
for (int i = -4; i <= 2; i++) {
|
||||
altarComponents.add(new AltarComponent(new BlockPos(11, i, 11)));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-11, i, -11)));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(11, i, -11)));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-11, i, 11)));
|
||||
}
|
||||
|
||||
altarComponents.add(new AltarComponent(new BlockPos(11, 3, 11), EnumAltarComponent.CRYSTAL));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-11, 3, -11), EnumAltarComponent.CRYSTAL));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(11, 3, -11), EnumAltarComponent.CRYSTAL));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-11, 3, 11), EnumAltarComponent.CRYSTAL));
|
||||
|
||||
for (int i = -9; i <= 9; i++) {
|
||||
altarComponents.add(new AltarComponent(new BlockPos(11, -5, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-11, -5, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(i, -5, 11), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(i, -5, -11), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
}
|
||||
}
|
||||
//@formatter:on
|
||||
};
|
||||
|
||||
public static final int MAXTIERS = values().length;
|
||||
|
||||
ArrayList<AltarComponent> altarComponents = new ArrayList<AltarComponent>();
|
||||
|
||||
public void buildComponents() {
|
||||
|
||||
}
|
||||
|
||||
public int toInt() {
|
||||
return ordinal() + 1;
|
||||
}
|
||||
|
||||
public ArrayList<AltarComponent> getAltarComponents() {
|
||||
return altarComponents;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.altar;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface IAltarComponent {
|
||||
@Nullable
|
||||
EnumAltarComponent getType(World world, IBlockState state, BlockPos pos);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.altar;
|
||||
|
||||
/**
|
||||
* Any item that implements this interface will not be pulled into the Altar on
|
||||
* right click.
|
||||
*/
|
||||
public interface IAltarManipulator {
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.altar;
|
||||
|
||||
public interface IBloodAltar {
|
||||
int getCapacity();
|
||||
|
||||
int getCurrentBlood();
|
||||
|
||||
EnumAltarTier 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);
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.compress;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class CompressionHandler {
|
||||
/**
|
||||
* Called to look at the inventory and syphons the required stack. Returns
|
||||
* resultant stack if successful, and null if not.
|
||||
*
|
||||
* @param inv The inventory iterated through
|
||||
* @return The result of the compression
|
||||
*/
|
||||
public abstract ItemStack compressInventory(ItemStack[] inv, World world);
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.compress;
|
||||
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A registry aimed to help compress items in an inventory into its compressible
|
||||
* form.
|
||||
*/
|
||||
public class CompressionRegistry {
|
||||
public static List<CompressionHandler> compressionRegistry = new ArrayList<CompressionHandler>();
|
||||
public static Map<ItemStack, Integer> thresholdMap = new HashMap<ItemStack, Integer>();
|
||||
|
||||
public static void registerHandler(CompressionHandler handler) {
|
||||
compressionRegistry.add(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an item so that it only compresses while above this threshold
|
||||
*
|
||||
* @param stack item/block to be compressed
|
||||
* @param threshold amount that is to be compressed
|
||||
*/
|
||||
public static void registerItemThreshold(ItemStack stack, int threshold) {
|
||||
thresholdMap.put(stack, threshold);
|
||||
}
|
||||
|
||||
public static ItemStack compressInventory(ItemStack[] inv, World world) {
|
||||
for (CompressionHandler handler : compressionRegistry) {
|
||||
ItemStack stack = handler.compressInventory(inv, world);
|
||||
if (stack != null) {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Pair<ItemStack, Boolean> compressInventory(TileEntity tile, World world) {
|
||||
if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) {
|
||||
IItemHandler itemHandler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
||||
ItemStack[] inventory = new ItemStack[itemHandler.getSlots()]; //THIS MUST NOT BE EDITED!
|
||||
ItemStack[] copyInventory = new ItemStack[itemHandler.getSlots()];
|
||||
|
||||
for (int slot = 0; slot < itemHandler.getSlots(); slot++) {
|
||||
inventory[slot] = itemHandler.extractItem(slot, 64, true);
|
||||
copyInventory[slot] = inventory[slot].copy();
|
||||
}
|
||||
|
||||
for (CompressionHandler handler : compressionRegistry) {
|
||||
ItemStack stack = handler.compressInventory(copyInventory, world);
|
||||
if (!stack.isEmpty()) {
|
||||
for (int slot = 0; slot < itemHandler.getSlots(); slot++) {
|
||||
if (inventory[slot] != null && !ItemStack.areItemStacksEqual(inventory[slot], copyInventory[slot])) {
|
||||
itemHandler.extractItem(slot, inventory[slot].getCount(), false);
|
||||
if (copyInventory[slot] != null) {
|
||||
itemHandler.insertItem(slot, copyInventory[slot], false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Pair.of(Utils.insertStackIntoTile(stack, itemHandler), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Pair.of(ItemStack.EMPTY, false);
|
||||
}
|
||||
|
||||
public static int getItemThreshold(ItemStack stack) {
|
||||
for (Map.Entry<ItemStack, Integer> entry : thresholdMap.entrySet()) {
|
||||
if (areItemStacksEqual(entry.getKey(), stack)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean areItemStacksEqual(ItemStack stack, ItemStack compressedStack) {
|
||||
return stack.isItemEqual(compressedStack) && (stack.getTagCompound() == null ? !compressedStack.hasTagCompound() : stack.getTagCompound().equals(compressedStack.getTagCompound()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.event;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
@Cancelable
|
||||
public class AddToNetworkEvent extends Event {
|
||||
public final String ownerNetwork;
|
||||
public int addedAmount;
|
||||
public int maximum;
|
||||
|
||||
/**
|
||||
* This event is called whenever the network is added to. If cancelled, no
|
||||
* LP will be drained from the source. If result is set to Result.DENY, the
|
||||
* LP will still be drained but the soul network will not be added to.
|
||||
*
|
||||
* @param ownerNetwork Key used for the soul network
|
||||
* @param addedAmount Amount added
|
||||
* @param maximum Ceiling that the network can add to
|
||||
*/
|
||||
public AddToNetworkEvent(String ownerNetwork, int addedAmount, int maximum) {
|
||||
this.ownerNetwork = ownerNetwork;
|
||||
this.addedAmount = addedAmount;
|
||||
this.maximum = maximum;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.event;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.registry.AltarRecipeRegistry;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
/**
|
||||
* Fired whenever a craft is completed in a BloodAltar.
|
||||
* <p>
|
||||
* It is not cancelable, however you can modify the output stack.
|
||||
*/
|
||||
public class AltarCraftedEvent extends Event {
|
||||
|
||||
private final AltarRecipeRegistry.AltarRecipe altarRecipe;
|
||||
private final ItemStack output;
|
||||
|
||||
/**
|
||||
* @param altarRecipe - The recipe that was crafted.
|
||||
* @param output - The item obtained from the recipe
|
||||
*/
|
||||
public AltarCraftedEvent(AltarRecipeRegistry.AltarRecipe altarRecipe, ItemStack output) {
|
||||
this.altarRecipe = altarRecipe;
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
public AltarRecipeRegistry.AltarRecipe getAltarRecipe() {
|
||||
return altarRecipe;
|
||||
}
|
||||
|
||||
public ItemStack getOutput() {
|
||||
return output;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.event;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
public class BoundToolEvent extends Event {
|
||||
public EntityPlayer player;
|
||||
|
||||
public BoundToolEvent(EntityPlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is called when a
|
||||
* {@link WayofTime.bloodmagic.item.ItemBoundTool} is being charged.
|
||||
* <p>
|
||||
* If canceled, will result in the charging being canceled.
|
||||
*/
|
||||
|
||||
@Cancelable
|
||||
public static class Charge extends BoundToolEvent {
|
||||
public ItemStack result;
|
||||
|
||||
public Charge(EntityPlayer player, ItemStack result) {
|
||||
super(player);
|
||||
this.result = result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is called when a
|
||||
* {@link WayofTime.bloodmagic.item.ItemBoundTool}'s charge is released.
|
||||
* <p>
|
||||
* If canceled, will result in the charge not being released.
|
||||
*/
|
||||
|
||||
@Cancelable
|
||||
public static class Release extends BoundToolEvent {
|
||||
public final ItemStack boundTool;
|
||||
public int charge;
|
||||
|
||||
public Release(EntityPlayer player, ItemStack boundTool, int charge) {
|
||||
super(player);
|
||||
this.boundTool = boundTool;
|
||||
this.charge = charge;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.event;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
@Cancelable
|
||||
public class ItemBindEvent extends Event {
|
||||
public final EntityPlayer player;
|
||||
public String key;
|
||||
public ItemStack itemStack;
|
||||
|
||||
/**
|
||||
* This event is called whenever a player attempts to bind a
|
||||
* {@link WayofTime.bloodmagic.apibutnotreally.iface.IBindable} item.
|
||||
*
|
||||
* @param player The player doing the binding
|
||||
* @param key The UUID of the player doing the binding
|
||||
* @param itemStack The {@link ItemStack} that the player is binding
|
||||
* <p>
|
||||
* This event is {@link Cancelable}.<br>
|
||||
*/
|
||||
public ItemBindEvent(EntityPlayer player, String key, ItemStack itemStack) {
|
||||
super();
|
||||
this.player = player;
|
||||
this.key = key;
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.event;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.ritual.IMasterRitualStone;
|
||||
import WayofTime.bloodmagic.apibutnotreally.ritual.Ritual;
|
||||
import WayofTime.bloodmagic.apibutnotreally.ritual.imperfect.IImperfectRitualStone;
|
||||
import WayofTime.bloodmagic.apibutnotreally.ritual.imperfect.ImperfectRitual;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
public class RitualEvent extends Event {
|
||||
public final IMasterRitualStone mrs;
|
||||
public final String ownerName;
|
||||
public final Ritual ritual;
|
||||
|
||||
private RitualEvent(IMasterRitualStone mrs, String ownerName, Ritual ritual) {
|
||||
this.mrs = mrs;
|
||||
this.ownerName = ownerName;
|
||||
this.ritual = ritual;
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is called when a ritual is activated. If cancelled, it will
|
||||
* not activate.
|
||||
* <p>
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#activateRitual(ItemStack, EntityPlayer, Ritual)}
|
||||
*/
|
||||
@Cancelable
|
||||
public static class RitualActivatedEvent extends RitualEvent {
|
||||
public final EntityPlayer player;
|
||||
public final ItemStack crystalStack;
|
||||
public int crystalTier;
|
||||
|
||||
public RitualActivatedEvent(IMasterRitualStone mrs, String owner, Ritual ritual, EntityPlayer player, ItemStack activationCrystal, int crystalTier) {
|
||||
super(mrs, owner, ritual);
|
||||
|
||||
this.player = player;
|
||||
this.crystalStack = activationCrystal;
|
||||
this.crystalTier = crystalTier;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is called when a Ritual effect is performed. If cancelled, the
|
||||
* effect will not happen.
|
||||
* <p>
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#performRitual(World, net.minecraft.util.math.BlockPos)}
|
||||
*/
|
||||
@Cancelable
|
||||
public static class RitualRunEvent extends RitualEvent {
|
||||
public RitualRunEvent(IMasterRitualStone mrs, String owner, Ritual ritual) {
|
||||
super(mrs, owner, ritual);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is called when a Ritual is stopped by a
|
||||
* {@link Ritual.BreakType}.
|
||||
* <p>
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(Ritual.BreakType)}
|
||||
*/
|
||||
public static class RitualStopEvent extends RitualEvent {
|
||||
|
||||
public final Ritual.BreakType method;
|
||||
|
||||
public RitualStopEvent(IMasterRitualStone mrs, String owner, Ritual ritual, Ritual.BreakType method) {
|
||||
super(mrs, owner, ritual);
|
||||
|
||||
this.method = method;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class ImperfectRitualActivatedEvent extends Event {
|
||||
|
||||
public final IImperfectRitualStone ims;
|
||||
public final String ownerName;
|
||||
public final ImperfectRitual imperfectRitual;
|
||||
|
||||
public ImperfectRitualActivatedEvent(IImperfectRitualStone ims, String ownerName, ImperfectRitual imperfectRitual) {
|
||||
this.ims = ims;
|
||||
this.ownerName = ownerName;
|
||||
this.imperfectRitual = imperfectRitual;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.event;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
@Cancelable
|
||||
public class SacrificeKnifeUsedEvent extends Event {
|
||||
public final EntityPlayer player;
|
||||
public final int healthDrained;
|
||||
public int lpAdded;
|
||||
public boolean shouldDrainHealth;
|
||||
public boolean shouldFillAltar;
|
||||
|
||||
/**
|
||||
* This event is called whenever a player attempts to use a
|
||||
* {@link WayofTime.bloodmagic.item.ItemSacrificialDagger} to self-sacrifice
|
||||
* near an altar.
|
||||
*
|
||||
* @param player The player doing the sacrificing
|
||||
* @param shouldDrainHealth Determines whether or not health is lost
|
||||
* @param shouldFillAltar Determines whether or not an altar should be filled
|
||||
* @param hp Amount of health lost
|
||||
* @param lpAdded Amount of LP added to the altar
|
||||
* <p>
|
||||
* This event is {@link Cancelable}.<br>
|
||||
*/
|
||||
public SacrificeKnifeUsedEvent(EntityPlayer player, boolean shouldDrainHealth, boolean shouldFillAltar, int hp, int lpAdded) {
|
||||
this.player = player;
|
||||
this.shouldDrainHealth = shouldDrainHealth;
|
||||
this.shouldFillAltar = shouldFillAltar;
|
||||
this.healthDrained = hp;
|
||||
this.lpAdded = lpAdded;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.event;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Base event class for Soul Network related events.
|
||||
* <p>
|
||||
* {@link #ownerUUID} contains the owner's UUID {@link #syphon} contains the
|
||||
* amount of LP to be drained
|
||||
*/
|
||||
public class SoulNetworkEvent extends Event {
|
||||
public final String ownerUUID;
|
||||
public int syphon;
|
||||
|
||||
public SoulNetworkEvent(String ownerUUID, int syphon) {
|
||||
this.ownerUUID = ownerUUID;
|
||||
this.syphon = syphon;
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is called when an
|
||||
* {@link WayofTime.bloodmagic.apibutnotreally.impl.ItemBindable} is being drained
|
||||
* inside of a {@link net.minecraft.tileentity.TileEntity}.
|
||||
* <p>
|
||||
* If canceled, the drain will not be executed.
|
||||
*/
|
||||
@Cancelable
|
||||
public static class ItemDrainInContainerEvent extends SoulNetworkEvent {
|
||||
public ItemStack stack;
|
||||
|
||||
public ItemDrainInContainerEvent(ItemStack stack, String ownerName, int syphon) {
|
||||
super(ownerName, syphon);
|
||||
this.stack = stack;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is called when a {@link EntityPlayer} drains the Soul Network
|
||||
* <p>
|
||||
* If canceled, the drain will not be executed.
|
||||
*/
|
||||
@Cancelable
|
||||
public static class PlayerDrainNetworkEvent extends SoulNetworkEvent {
|
||||
public final EntityPlayer player;
|
||||
// If true, will damage regardless of if the network had enough inside it
|
||||
public boolean shouldDamage;
|
||||
|
||||
public PlayerDrainNetworkEvent(EntityPlayer player, String ownerNetwork, int drainAmount) {
|
||||
super(ownerNetwork, drainAmount);
|
||||
this.shouldDamage = false;
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class ItemDrainNetworkEvent extends PlayerDrainNetworkEvent {
|
||||
@Nullable
|
||||
public final ItemStack itemStack;
|
||||
/**
|
||||
* Amount of damage that would incur if the network could not drain
|
||||
* properly
|
||||
*/
|
||||
public float damageAmount;
|
||||
|
||||
/**
|
||||
* Set result to deny the action i.e. damage/drain anyways. Cancelling
|
||||
* event prevents action without penalties
|
||||
*
|
||||
* @param player Player using the item
|
||||
* @param ownerNetwork Network that the item is tied to
|
||||
* @param itemStack Item used
|
||||
* @param drainAmount Original drain amount - change to alter cost
|
||||
*/
|
||||
public ItemDrainNetworkEvent(EntityPlayer player, String ownerNetwork, @Nullable ItemStack itemStack, int drainAmount) {
|
||||
super(player, ownerNetwork, drainAmount);
|
||||
this.itemStack = itemStack;
|
||||
this.damageAmount = (float) (drainAmount) / 100.0f;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.event;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
/**
|
||||
* Fired when a teleposer attempts to transpose two blocks. Use this to perform
|
||||
* special cleanup or compensation, or cancel it entirely to prevent the
|
||||
* transposition.
|
||||
*/
|
||||
@Cancelable
|
||||
public class TeleposeEvent extends Event {
|
||||
public final World initalWorld;
|
||||
public final BlockPos initialBlockPos;
|
||||
public final IBlockState initialState;
|
||||
|
||||
public final World finalWorld;
|
||||
public final BlockPos finalBlockPos;
|
||||
public final IBlockState finalState;
|
||||
|
||||
public TeleposeEvent(World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos) {
|
||||
this.initalWorld = initialWorld;
|
||||
this.initialBlockPos = initialBlockPos;
|
||||
this.initialState = initialWorld.getBlockState(initialBlockPos);
|
||||
|
||||
this.finalWorld = finalWorld;
|
||||
this.finalBlockPos = finalBlockPos;
|
||||
this.finalState = finalWorld.getBlockState(finalBlockPos);
|
||||
}
|
||||
|
||||
public TileEntity getInitialTile() {
|
||||
return initalWorld.getTileEntity(initialBlockPos);
|
||||
}
|
||||
|
||||
public TileEntity getFinalTile() {
|
||||
return finalWorld.getTileEntity(finalBlockPos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when a Teleposer attempts to move an Entity between locations. Can
|
||||
* be cancelled to stop transposition.
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Ent extends TeleposeEvent {
|
||||
public final Entity entity;
|
||||
|
||||
public Ent(Entity entity, World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos) {
|
||||
super(initialWorld, initialBlockPos, finalWorld, finalBlockPos);
|
||||
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getInitialTile() throws IllegalArgumentException {
|
||||
throw new IllegalArgumentException("Attempted to get a TileEntity from an Entity Telepose Event.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getFinalTile() throws IllegalArgumentException {
|
||||
throw new IllegalArgumentException("Attempted to get a TileEntity from an Entity Telepose Event.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the entity has been transposed.
|
||||
*/
|
||||
public static class Post extends Ent {
|
||||
|
||||
public Post(Entity entity, World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos) {
|
||||
super(entity, initialWorld, initialBlockPos, finalWorld, finalBlockPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.iface;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IActivatable {
|
||||
boolean getActivated(ItemStack stack);
|
||||
|
||||
ItemStack setActivatedState(ItemStack stack, boolean activated);
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.iface;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public interface IAlchemyArray {
|
||||
EnumFacing getRotation();
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.iface;
|
||||
|
||||
/**
|
||||
* Any item that implements this interface will not be pulled into the Altar on
|
||||
* right click.
|
||||
*/
|
||||
public interface IAltarReader {
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.iface;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Implement this interface on any Item that can be bound to a player.
|
||||
*/
|
||||
public interface IBindable {
|
||||
/**
|
||||
* Gets the username of the Item's owner. Usually for display, such as in
|
||||
* the tooltip.
|
||||
* <p>
|
||||
* If the item is not bound, this will be null.
|
||||
*
|
||||
* @param stack - The owned ItemStack
|
||||
* @return - The username of the Item's owner
|
||||
*/
|
||||
String getOwnerName(ItemStack stack);
|
||||
|
||||
/**
|
||||
* Gets the UUID of the Item's owner.
|
||||
* <p>
|
||||
* If the item is not bound, this will be null.
|
||||
*
|
||||
* @param stack - The owned ItemStack
|
||||
* @return - The UUID of the Item's owner
|
||||
*/
|
||||
String getOwnerUUID(ItemStack stack);
|
||||
|
||||
/**
|
||||
* Called when the player attempts to bind the item.
|
||||
*
|
||||
* @param player - The Player attempting to bind the item
|
||||
* @param stack - The ItemStack to attempt binding
|
||||
* @return If binding was successful.
|
||||
*/
|
||||
boolean onBind(EntityPlayer player, ItemStack stack);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.iface;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* An interface for items that have custom drainage behaviour when used in
|
||||
* certain alchemy recipes.
|
||||
*/
|
||||
public interface ICustomAlchemyConsumable {
|
||||
ItemStack drainUseOnAlchemyCraft(ItemStack stack);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.iface;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IDemonWillViewer {
|
||||
boolean canSeeDemonWillAura(World world, ItemStack stack, EntityPlayer player);
|
||||
|
||||
int getDemonWillAuraResolution(World world, ItemStack stack, EntityPlayer player);
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.iface;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Marks blocks as one that is documented.
|
||||
* <p>
|
||||
* This documentation can be read by an
|
||||
* {@link WayofTime.bloodmagic.item.ItemSanguineBook} (or child)
|
||||
*/
|
||||
public interface IDocumentedBlock {
|
||||
/**
|
||||
* Provides the documentation to provide to the player. Usually a
|
||||
* short'n'sweet description about basic usage.
|
||||
*
|
||||
* @param player - The EntityPlayer attempting to view the Documentation.
|
||||
* @param world - The World interaction is happening in.
|
||||
* @param pos - The BlockPos being interacted at.
|
||||
* @param state - The IBlockState of the interacted Block.
|
||||
* @return - A list of formatted ITextComponent to provide to the player.
|
||||
* Provide an empty list if there is no available documentation.
|
||||
*/
|
||||
@Nonnull
|
||||
List<ITextComponent> getDocumentation(EntityPlayer player, World world, BlockPos pos, IBlockState state);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.iface;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.BlockStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Used to define a HarvestHandler for the Harvest Ritual.
|
||||
*/
|
||||
public interface IHarvestHandler {
|
||||
/**
|
||||
* Called whenever the Harvest Ritual attempts to harvest a block. <br>
|
||||
* Use this to break the block, plant a new one, and drop the produced
|
||||
* items. <br>
|
||||
* Make sure to do checks so you are certain the blocks being handled are
|
||||
* the block types you want.
|
||||
*
|
||||
* @param world - The world the
|
||||
* {@link WayofTime.bloodmagic.apibutnotreally.ritual.IMasterRitualStone} is in.
|
||||
* @param pos - The position of the Block being checked
|
||||
* @param blockStack - The Block being checked
|
||||
* @return If the block was successfully harvested.
|
||||
*/
|
||||
boolean harvestAndPlant(World world, BlockPos pos, BlockStack blockStack);
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.iface;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Interface used for any item that can store LP in itself
|
||||
*/
|
||||
public interface IItemLPContainer {
|
||||
int getCapacity();
|
||||
|
||||
void setStoredLP(ItemStack stack, int lp);
|
||||
|
||||
int getStoredLP(ItemStack stack);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.iface;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.soul.EnumDemonWillType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IMultiWillTool {
|
||||
EnumDemonWillType getCurrentType(ItemStack stack);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.iface;
|
||||
|
||||
/**
|
||||
* Held items that implement this will cause the beams between routing nodes to
|
||||
* render.
|
||||
*/
|
||||
public interface INodeRenderer {
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.iface;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IPurificationAsh {
|
||||
double getTotalPurity(ItemStack stack);
|
||||
|
||||
double getMaxPurity(ItemStack stack);
|
||||
|
||||
double getPurityRate(ItemStack stack);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.iface;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.soul.EnumDemonWillType;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ISentientSwordEffectProvider {
|
||||
boolean applyOnHitEffect(EnumDemonWillType type, ItemStack swordStack, ItemStack providerStack, EntityLivingBase attacker, EntityLivingBase target);
|
||||
|
||||
boolean providesEffectForWill(EnumDemonWillType type);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.iface;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ISentientTool {
|
||||
boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player);
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.iface;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Used for all {@link WayofTime.bloodmagic.apibutnotreally.impl.ItemSigil} <b>EXCEPT</b>
|
||||
* Sigils of Holdings.
|
||||
*/
|
||||
public interface ISigil {
|
||||
boolean performArrayEffect(World world, BlockPos pos);
|
||||
|
||||
boolean hasArrayEffect();
|
||||
|
||||
interface Holding {
|
||||
@Nonnull
|
||||
ItemStack getHeldItem(ItemStack holdingStack, EntityPlayer player);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.iface;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This interface is used for items intended to train specific upgrades while
|
||||
* held in the player's inventory.
|
||||
*/
|
||||
public interface IUpgradeTrainer {
|
||||
List<String> getTrainedUpgrades(ItemStack stack);
|
||||
|
||||
boolean setTrainedUpgrades(ItemStack stack, List<String> keys);
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.impl;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.Constants;
|
||||
import WayofTime.bloodmagic.apibutnotreally.iface.IBindable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Base class for all bindable items.
|
||||
*/
|
||||
public class ItemBindable extends Item implements IBindable {
|
||||
public ItemBindable() {
|
||||
super();
|
||||
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
// IBindable
|
||||
|
||||
@Override
|
||||
public boolean onBind(EntityPlayer player, ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwnerName(ItemStack stack) {
|
||||
return !stack.isEmpty() ? stack.getTagCompound().getString(Constants.NBT.OWNER_NAME) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwnerUUID(ItemStack stack) {
|
||||
return !stack.isEmpty() ? stack.getTagCompound().getString(Constants.NBT.OWNER_UUID) : null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.impl;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.Constants;
|
||||
import WayofTime.bloodmagic.apibutnotreally.iface.ISigil;
|
||||
import WayofTime.bloodmagic.apibutnotreally.util.helper.NBTHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Base class for all (static) sigils.
|
||||
*/
|
||||
public class ItemSigil extends ItemBindable implements ISigil {
|
||||
private int lpUsed;
|
||||
|
||||
public ItemSigil(int lpUsed) {
|
||||
super();
|
||||
|
||||
this.lpUsed = lpUsed;
|
||||
}
|
||||
|
||||
public boolean isUnusable(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
return stack.getTagCompound().getBoolean(Constants.NBT.UNUSABLE);
|
||||
}
|
||||
|
||||
public ItemStack setUnusable(ItemStack stack, boolean unusable) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
stack.getTagCompound().setBoolean(Constants.NBT.UNUSABLE, unusable);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performArrayEffect(World world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasArrayEffect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getLpUsed() {
|
||||
return lpUsed;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.impl;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.Constants;
|
||||
import WayofTime.bloodmagic.apibutnotreally.iface.IActivatable;
|
||||
import WayofTime.bloodmagic.apibutnotreally.iface.ISigil;
|
||||
import WayofTime.bloodmagic.apibutnotreally.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.apibutnotreally.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.apibutnotreally.util.helper.PlayerHelper;
|
||||
import com.google.common.base.Strings;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Base class for all toggleable sigils.
|
||||
*/
|
||||
public class ItemSigilToggleable extends ItemSigil implements IActivatable {
|
||||
public ItemSigilToggleable(int lpUsed) {
|
||||
super(lpUsed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActivated(ItemStack stack) {
|
||||
return !stack.isEmpty() && NBTHelper.checkNBT(stack).getTagCompound().getBoolean(Constants.NBT.ACTIVATED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack setActivatedState(ItemStack stack, boolean activated) {
|
||||
if (!stack.isEmpty()) {
|
||||
NBTHelper.checkNBT(stack).getTagCompound().setBoolean(Constants.NBT.ACTIVATED, activated);
|
||||
return stack;
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (stack.getItem() instanceof ISigil.Holding)
|
||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||
|
||||
if (!world.isRemote && !isUnusable(stack)) {
|
||||
if (player.isSneaking())
|
||||
setActivatedState(stack, !getActivated(stack));
|
||||
if (getActivated(stack) && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()))
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (stack.getItem() instanceof ISigil.Holding)
|
||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||
if (Strings.isNullOrEmpty(getOwnerUUID(stack)) || player.isSneaking()) // Make sure Sigils are bound before handling. Also ignores while toggling state
|
||||
return EnumActionResult.PASS;
|
||||
|
||||
return (NetworkHelper.getSoulNetwork(getOwnerUUID(player.getHeldItem(hand))).syphonAndDamage(player, getLpUsed()) && onSigilUse(player.getHeldItem(hand), player, world, pos, side, hitX, hitY, hitZ)) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
public boolean onSigilUse(ItemStack itemStack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
|
||||
if (!worldIn.isRemote && entityIn instanceof EntityPlayerMP && getActivated(stack)) {
|
||||
if (entityIn.ticksExisted % 100 == 0) {
|
||||
if (!NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage((EntityPlayer) entityIn, getLpUsed())) {
|
||||
setActivatedState(stack, false);
|
||||
}
|
||||
}
|
||||
|
||||
onSigilUpdate(stack, worldIn, (EntityPlayer) entityIn, itemSlot, isSelected);
|
||||
}
|
||||
}
|
||||
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.incense;
|
||||
|
||||
public enum EnumTranquilityType {
|
||||
PLANT(),
|
||||
CROP(),
|
||||
TREE(),
|
||||
EARTHEN(),
|
||||
WATER(),
|
||||
FIRE(),
|
||||
LAVA();
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.incense;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IIncensePath {
|
||||
/**
|
||||
* Goes from 0 to however far this path block can be from the altar while
|
||||
* still functioning. 0 represents a block that can work when it is two
|
||||
* blocks horizontally away from the altar.
|
||||
*/
|
||||
int getLevelOfPath(World world, BlockPos pos, IBlockState state);
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.incense;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface ITranquilityHandler {
|
||||
TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state);
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.incense;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class IncenseTranquilityRegistry {
|
||||
public static List<ITranquilityHandler> handlerList = new ArrayList<ITranquilityHandler>();
|
||||
|
||||
public static void registerTranquilityHandler(ITranquilityHandler handler) {
|
||||
handlerList.add(handler);
|
||||
}
|
||||
|
||||
public static TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) {
|
||||
for (ITranquilityHandler handler : handlerList) {
|
||||
TranquilityStack tranq = handler.getTranquilityOfBlock(world, pos, block, state);
|
||||
if (tranq != null) {
|
||||
return tranq;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.incense;
|
||||
|
||||
public class TranquilityStack {
|
||||
public final EnumTranquilityType type;
|
||||
public double value;
|
||||
|
||||
public TranquilityStack(EnumTranquilityType type, double value) {
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.livingArmour;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* An interface this is used purely for internal implementation.
|
||||
*
|
||||
* @author WayofTime
|
||||
*/
|
||||
public interface ILivingArmour {
|
||||
Multimap<String, AttributeModifier> getAttributeModifiers();
|
||||
|
||||
boolean canApplyUpgrade(EntityPlayer user, LivingArmourUpgrade upgrade);
|
||||
|
||||
boolean upgradeArmour(EntityPlayer user, LivingArmourUpgrade upgrade);
|
||||
|
||||
boolean removeUpgrade(EntityPlayer user, LivingArmourUpgrade upgrade);
|
||||
|
||||
void notifyPlayerOfUpgrade(EntityPlayer user, LivingArmourUpgrade upgrade);
|
||||
|
||||
/**
|
||||
* Ticks the upgrades and stat trackers, passing in the world and player as
|
||||
* well as the LivingArmour
|
||||
*
|
||||
* @param world - The World
|
||||
* @param player - The player wearing the Armour
|
||||
*/
|
||||
void onTick(World world, EntityPlayer player);
|
||||
|
||||
void readFromNBT(NBTTagCompound tag);
|
||||
|
||||
void writeToNBT(NBTTagCompound tag, boolean forceWrite);
|
||||
|
||||
/**
|
||||
* Writes the LivingArmour to the NBTTag. This will only write the trackers
|
||||
* that are dirty.
|
||||
*
|
||||
* @param tag - The NBT tag to write to
|
||||
*/
|
||||
void writeDirtyToNBT(NBTTagCompound tag);
|
||||
|
||||
void writeToNBT(NBTTagCompound tag);
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.livingArmour;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.BloodMagicAPI;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class LivingArmourHandler {
|
||||
public static List<Class<? extends StatTracker>> trackers = new ArrayList<Class<? extends StatTracker>>();
|
||||
public static HashMap<String, Class<? extends LivingArmourUpgrade>> upgradeMap = new HashMap<String, Class<? extends LivingArmourUpgrade>>();
|
||||
public static HashMap<String, Constructor<? extends LivingArmourUpgrade>> upgradeConstructorMap = new HashMap<String, Constructor<? extends LivingArmourUpgrade>>();
|
||||
public static HashMap<String, Integer> upgradeMaxLevelMap = new HashMap<String, Integer>();
|
||||
|
||||
public static void registerStatTracker(Class<? extends StatTracker> tracker) {
|
||||
trackers.add(tracker);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a LivingArmourUpgrade using its unique identifier and class.
|
||||
* This is done to more easily load upgrades
|
||||
*
|
||||
* @param upgrade
|
||||
*/
|
||||
public static void registerArmourUpgrade(LivingArmourUpgrade upgrade) {
|
||||
Class<? extends LivingArmourUpgrade> clazz = upgrade.getClass();
|
||||
upgradeMap.put(upgrade.getUniqueIdentifier(), clazz);
|
||||
upgradeMaxLevelMap.put(upgrade.getUniqueIdentifier(), upgrade.getMaxTier());
|
||||
try {
|
||||
Constructor<? extends LivingArmourUpgrade> ctor = clazz.getConstructor(int.class);
|
||||
if (ctor == null) {
|
||||
BloodMagicAPI.logger.error("Error adding living armour upgrade {} as it doesn't have a valid constructor.", upgrade.getUniqueIdentifier());
|
||||
} else {
|
||||
upgradeConstructorMap.put(upgrade.getUniqueIdentifier(), ctor);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level) {
|
||||
return generateUpgradeFromKey(key, level, null);
|
||||
}
|
||||
|
||||
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level, NBTTagCompound tag) {
|
||||
Constructor<? extends LivingArmourUpgrade> ctor = upgradeConstructorMap.get(key);
|
||||
if (ctor != null) {
|
||||
try {
|
||||
LivingArmourUpgrade upgrade = ctor.newInstance(level);
|
||||
if (upgrade != null && tag != null) {
|
||||
upgrade.readFromNBT(tag);
|
||||
}
|
||||
return upgrade;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.livingArmour;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class LivingArmourUpgrade {
|
||||
public static String chatBase = "chat.bloodmagic.livingArmour.upgrade.";
|
||||
public static String tooltipBase = "tooltip.bloodmagic.livingArmour.upgrade.";
|
||||
|
||||
/**
|
||||
* Upgrade level 0 is the first upgrade. Upgrade goes from 0 to getMaxTier()
|
||||
* - 1.
|
||||
*/
|
||||
protected int level = 0;
|
||||
|
||||
/**
|
||||
* The LivingArmourUpgrade must have a constructor that has a single integer
|
||||
* parameter. Upgrades may have other constructors, but must have one of
|
||||
* these.
|
||||
*
|
||||
* @param level The level of the upgrade
|
||||
*/
|
||||
public LivingArmourUpgrade(int level) {
|
||||
this.level = Math.min(level, getMaxTier() - 1);
|
||||
}
|
||||
|
||||
public double getAdditionalDamageOnHit(double damage, EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double getKnockbackOnHit(EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Percentage of damage blocked. This stacks multiplicities with other
|
||||
* upgrades.
|
||||
*
|
||||
* @return 0 for no damage blocked, 1 for full damage blocked
|
||||
*/
|
||||
public double getArmourProtection(EntityLivingBase wearer, DamageSource source) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getUpgradeLevel() {
|
||||
return this.level;
|
||||
}
|
||||
|
||||
public abstract String getUniqueIdentifier();
|
||||
|
||||
public abstract String getUnlocalizedName();
|
||||
|
||||
public abstract int getMaxTier();
|
||||
|
||||
public abstract int getCostOfUpgrade();
|
||||
|
||||
public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) {
|
||||
}
|
||||
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers() {
|
||||
return HashMultimap.create();
|
||||
}
|
||||
|
||||
public double getMiningSpeedModifier(EntityPlayer player) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public abstract void writeToNBT(NBTTagCompound tag);
|
||||
|
||||
public abstract void readFromNBT(NBTTagCompound tag);
|
||||
|
||||
public int getRunicShielding() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean runOnClient() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isDowngrade() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.livingArmour;
|
||||
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class StatTracker {
|
||||
private boolean isDirty = false;
|
||||
|
||||
public abstract String getUniqueIdentifier();
|
||||
|
||||
/**
|
||||
* When called the StatTracker should reset all of its data, including
|
||||
* upgrades.
|
||||
*/
|
||||
public abstract void resetTracker();
|
||||
|
||||
public abstract void readFromNBT(NBTTagCompound tag);
|
||||
|
||||
public abstract void writeToNBT(NBTTagCompound tag);
|
||||
|
||||
/**
|
||||
* Called each tick to update the tracker's information. Called in
|
||||
* LivingArmour
|
||||
*
|
||||
* @param world World the player is in
|
||||
* @param player The player that has the armour equipped
|
||||
* @param livingArmour The equipped LivingArmour
|
||||
* @return True if there is a new upgrade unlocked this tick.
|
||||
*/
|
||||
public abstract boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour);
|
||||
|
||||
public abstract void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour);
|
||||
|
||||
public abstract List<LivingArmourUpgrade> getUpgrades();
|
||||
|
||||
/**
|
||||
* Used to obtain the progress from the current level to the next level.
|
||||
* <p>
|
||||
* 0.0 being 0% - 1.0 being 100%.
|
||||
*
|
||||
* @param livingArmour The equipped LivingArmour
|
||||
* @return the progress from the current level to the next level.
|
||||
*/
|
||||
public double getProgress(LivingArmour livingArmour, int currentLevel) {
|
||||
return 1.0D;
|
||||
}
|
||||
|
||||
public final boolean isDirty() {
|
||||
return isDirty;
|
||||
}
|
||||
|
||||
public final void markDirty() {
|
||||
this.isDirty = true;
|
||||
}
|
||||
|
||||
public final void resetDirty() {
|
||||
this.isDirty = false;
|
||||
}
|
||||
|
||||
public abstract boolean providesUpgrade(String key);
|
||||
|
||||
public abstract void onArmourUpgradeAdded(LivingArmourUpgrade upgrade);
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.orb;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Base object for all Blood Orbs. Makes Orb creation quite a bit easier.
|
||||
* <p>
|
||||
* Just create a new BloodOrb instance then register it in {@link net.minecraftforge.event.RegistryEvent.Register<BloodOrb>}
|
||||
*/
|
||||
public class BloodOrb extends IForgeRegistryEntry.Impl<BloodOrb> {
|
||||
private final String name;
|
||||
private final int tier;
|
||||
private final int capacity;
|
||||
@Nullable
|
||||
private ModelResourceLocation modelLocation;
|
||||
|
||||
/**
|
||||
* A base object for BloodOrbs. A bit cleaner than the old way through
|
||||
* EnergyItems.
|
||||
*
|
||||
* @param name - A name for the Orb. Gets put into an unlocalized name.
|
||||
* @param tier - The tier of the Orb.
|
||||
* @param capacity - The max amount of LP the Orb can store.
|
||||
*/
|
||||
public BloodOrb(String name, int tier, int capacity) {
|
||||
this.name = name;
|
||||
this.tier = tier;
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getTier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
public int getCapacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ModelResourceLocation getModelLocation() {
|
||||
return modelLocation;
|
||||
}
|
||||
|
||||
public BloodOrb withModel(@Nonnull ModelResourceLocation modelLocation) {
|
||||
this.modelLocation = modelLocation;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BloodOrb{" + "name='" + name + '\'' + ", tier=" + tier + ", capacity=" + capacity + ", owner=" + getRegistryName() + '}';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.orb;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface IBloodOrb {
|
||||
@Nullable
|
||||
BloodOrb getOrb(ItemStack stack);
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
@Deprecated // This entire "api" is going to be nuked over time. Consider all of this unstable.
|
||||
@API(owner = BloodMagic.MODID, provides = BloodMagic.MODID + "|API", apiVersion = BloodMagic.VERSION)
|
||||
package WayofTime.bloodmagic.apibutnotreally;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import net.minecraftforge.fml.common.API;
|
|
@ -0,0 +1,44 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.recipe;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.iface.ICustomAlchemyConsumable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class AlchemyTableCustomRecipe extends AlchemyTableRecipe {
|
||||
public AlchemyTableCustomRecipe(Block result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) {
|
||||
this(new ItemStack(result), lpDrained, ticksRequired, tierRequired, recipe);
|
||||
}
|
||||
|
||||
public AlchemyTableCustomRecipe(Item result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) {
|
||||
this(new ItemStack(result), lpDrained, ticksRequired, tierRequired, recipe);
|
||||
}
|
||||
|
||||
public AlchemyTableCustomRecipe(ItemStack result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) {
|
||||
super(result, lpDrained, ticksRequired, tierRequired, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getContainerItem(ItemStack stack) {
|
||||
if (stack.isEmpty()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
ItemStack copyStack = stack.copy();
|
||||
|
||||
if (copyStack.getItem() instanceof ICustomAlchemyConsumable) {
|
||||
return ((ICustomAlchemyConsumable) copyStack.getItem()).drainUseOnAlchemyCraft(copyStack);
|
||||
}
|
||||
|
||||
if (copyStack.getItem().hasContainerItem(stack)) {
|
||||
return copyStack.getItem().getContainerItem(copyStack);
|
||||
}
|
||||
|
||||
copyStack.shrink(1);
|
||||
if (copyStack.isEmpty()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return copyStack;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,201 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.recipe;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class AlchemyTableRecipe {
|
||||
protected ItemStack output = ItemStack.EMPTY;
|
||||
protected ArrayList<Object> input = new ArrayList<Object>();
|
||||
protected int lpDrained;
|
||||
protected int ticksRequired;
|
||||
protected int tierRequired;
|
||||
|
||||
public AlchemyTableRecipe(Block result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) {
|
||||
this(new ItemStack(result), lpDrained, ticksRequired, tierRequired, recipe);
|
||||
}
|
||||
|
||||
public AlchemyTableRecipe(Item result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) {
|
||||
this(new ItemStack(result), lpDrained, ticksRequired, tierRequired, recipe);
|
||||
}
|
||||
|
||||
public AlchemyTableRecipe(ItemStack result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe) {
|
||||
output = result.copy();
|
||||
this.lpDrained = lpDrained;
|
||||
this.ticksRequired = ticksRequired;
|
||||
this.tierRequired = tierRequired;
|
||||
for (Object in : recipe) {
|
||||
if (in instanceof ItemStack) {
|
||||
input.add(((ItemStack) in).copy());
|
||||
} else if (in instanceof Item) {
|
||||
input.add(new ItemStack((Item) in));
|
||||
} else if (in instanceof Block) {
|
||||
input.add(new ItemStack((Block) in));
|
||||
} else if (in instanceof String) {
|
||||
input.add(OreDictionary.getOres((String) in));
|
||||
} else {
|
||||
String ret = "Invalid alchemy recipe: ";
|
||||
for (Object tmp : recipe) {
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += output;
|
||||
throw new RuntimeException(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the recipe area
|
||||
*/
|
||||
public int getRecipeSize() {
|
||||
return input.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the output of the recipe, sensitive to the input list provided.
|
||||
* If the input list does not technically match, the recipe should return
|
||||
* the default output.
|
||||
*
|
||||
* @param inputList
|
||||
* @return
|
||||
*/
|
||||
public ItemStack getRecipeOutput(List<ItemStack> inputList) {
|
||||
return output.copy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if a recipe matches current crafting inventory. World and
|
||||
* BlockPos are for future-proofing
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean matches(List<ItemStack> checkedList, World world, BlockPos pos) {
|
||||
ArrayList<Object> required = new ArrayList<Object>(input);
|
||||
|
||||
for (ItemStack slot : checkedList) {
|
||||
if (!slot.isEmpty()) {
|
||||
boolean inRecipe = false;
|
||||
|
||||
for (Object aRequired : required) {
|
||||
boolean match = false;
|
||||
|
||||
if (aRequired instanceof ItemStack) {
|
||||
match = OreDictionary.itemMatches((ItemStack) aRequired, slot, false);
|
||||
} else if (aRequired instanceof List) {
|
||||
Iterator<ItemStack> itr = ((List<ItemStack>) aRequired).iterator();
|
||||
while (itr.hasNext() && !match) {
|
||||
match = OreDictionary.itemMatches(itr.next(), slot, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
inRecipe = true;
|
||||
required.remove(aRequired);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!inRecipe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return required.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the input for this recipe, any mod accessing this value should
|
||||
* never manipulate the values in this array as it will effect the recipe
|
||||
* itself.
|
||||
*
|
||||
* @return The recipes input vales.
|
||||
*/
|
||||
public List<Object> getInput() {
|
||||
return ImmutableList.copyOf(input);
|
||||
}
|
||||
|
||||
public ItemStack[] getRemainingItems(ItemStack[] inventory) {
|
||||
ItemStack[] ret = inventory.clone();
|
||||
for (int i = 0; i < ret.length; i++) {
|
||||
ret[i] = getContainerItem(inventory[i]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
protected ItemStack getContainerItem(ItemStack stack) {
|
||||
if (stack.isEmpty()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
ItemStack copyStack = stack.copy();
|
||||
|
||||
if (copyStack.getItem().hasContainerItem(stack)) {
|
||||
return copyStack.getItem().getContainerItem(copyStack);
|
||||
}
|
||||
|
||||
copyStack.shrink(1);
|
||||
if (copyStack.isEmpty()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return copyStack;
|
||||
}
|
||||
|
||||
public int getLpDrained() {
|
||||
return lpDrained;
|
||||
}
|
||||
|
||||
public int getTicksRequired() {
|
||||
return ticksRequired;
|
||||
}
|
||||
|
||||
public int getTierRequired() {
|
||||
return tierRequired;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this)
|
||||
.append("output", output)
|
||||
.append("input", input)
|
||||
.append("lpDrained", lpDrained)
|
||||
.append("ticksRequired", ticksRequired)
|
||||
.append("tierRequired", tierRequired)
|
||||
.append("recipeSize", getRecipeSize())
|
||||
.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof AlchemyTableRecipe)) return false;
|
||||
|
||||
AlchemyTableRecipe that = (AlchemyTableRecipe) o;
|
||||
|
||||
if (lpDrained != that.lpDrained) return false;
|
||||
if (ticksRequired != that.ticksRequired) return false;
|
||||
if (tierRequired != that.tierRequired) return false;
|
||||
if (output != null ? !output.equals(that.output) : that.output != null) return false;
|
||||
return input != null ? input.equals(that.input) : that.input == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = output != null ? output.hashCode() : 0;
|
||||
result = 31 * result + (input != null ? input.hashCode() : 0);
|
||||
result = 31 * result + lpDrained;
|
||||
result = 31 * result + ticksRequired;
|
||||
result = 31 * result + tierRequired;
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,151 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.recipe;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.livingArmour.LivingArmourUpgrade;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class LivingArmourDowngradeRecipe {
|
||||
protected LivingArmourUpgrade upgrade = null;
|
||||
protected ItemStack keyStack = ItemStack.EMPTY;
|
||||
protected List<Object> input = new ArrayList<Object>();
|
||||
|
||||
public LivingArmourDowngradeRecipe(LivingArmourUpgrade upgrade, ItemStack keyStack, Object... recipe) {
|
||||
this.upgrade = upgrade;
|
||||
this.keyStack = keyStack;
|
||||
for (Object in : recipe) {
|
||||
if (in instanceof ItemStack) {
|
||||
input.add(((ItemStack) in).copy());
|
||||
} else if (in instanceof Item) {
|
||||
input.add(new ItemStack((Item) in));
|
||||
} else if (in instanceof Block) {
|
||||
input.add(new ItemStack((Block) in));
|
||||
} else if (in instanceof String) {
|
||||
input.add(OreDictionary.getOres((String) in));
|
||||
} else {
|
||||
String ret = "Invalid living armour downgrade recipe: ";
|
||||
for (Object tmp : recipe) {
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += upgrade.toString();
|
||||
throw new RuntimeException(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the recipe area
|
||||
*/
|
||||
public int getRecipeSize() {
|
||||
return input.size();
|
||||
}
|
||||
|
||||
public LivingArmourUpgrade getRecipeOutput() {
|
||||
return upgrade;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if a recipe matches current crafting inventory. World and
|
||||
* BlockPos are for future-proofing
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean matches(ItemStack key, List<ItemStack> checkedList, World world, BlockPos pos) {
|
||||
if (!OreDictionary.itemMatches(keyStack, key, false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ArrayList<Object> required = new ArrayList<Object>(input);
|
||||
|
||||
for (ItemStack slot : checkedList) {
|
||||
if (slot != null) {
|
||||
boolean inRecipe = false;
|
||||
|
||||
for (Object aRequired : required) {
|
||||
boolean match = false;
|
||||
|
||||
Object next = aRequired;
|
||||
|
||||
if (next instanceof ItemStack) {
|
||||
match = OreDictionary.itemMatches((ItemStack) next, slot, false);
|
||||
} else if (next instanceof List) {
|
||||
Iterator<ItemStack> itr = ((List<ItemStack>) next).iterator();
|
||||
while (itr.hasNext() && !match) {
|
||||
match = OreDictionary.itemMatches(itr.next(), slot, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
inRecipe = true;
|
||||
required.remove(next);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!inRecipe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return required.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the input for this recipe, any mod accessing this value should
|
||||
* never manipulate the values in this array as it will effect the recipe
|
||||
* itself.
|
||||
*
|
||||
* @return The recipes input vales.
|
||||
*/
|
||||
public List<Object> getInput() {
|
||||
return ImmutableList.copyOf(input);
|
||||
}
|
||||
|
||||
public ItemStack getKey() {
|
||||
return this.keyStack;
|
||||
}
|
||||
|
||||
public void consumeInventory(IItemHandler inv) {
|
||||
for (int i = 0; i < inv.getSlots(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if (stack.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (stack.getItem().hasContainerItem(stack)) {
|
||||
inv.extractItem(i, stack.getCount(), false);
|
||||
inv.insertItem(i, stack.getItem().getContainerItem(stack), false);
|
||||
} else {
|
||||
inv.extractItem(i, 1, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected ItemStack getContainerItem(ItemStack stack) {
|
||||
if (stack.isEmpty()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
ItemStack copyStack = stack.copy();
|
||||
|
||||
if (copyStack.getItem().hasContainerItem(stack)) {
|
||||
return copyStack.getItem().getContainerItem(copyStack);
|
||||
}
|
||||
|
||||
copyStack.shrink(1);
|
||||
if (copyStack.isEmpty()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return copyStack;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,165 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.recipe;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class TartaricForgeRecipe {
|
||||
protected ItemStack output = null;
|
||||
protected List<Object> input = new ArrayList<Object>();
|
||||
protected double minimumSouls;
|
||||
protected double soulsDrained;
|
||||
|
||||
public TartaricForgeRecipe(Block result, double minSouls, double drain, Object... recipe) {
|
||||
this(new ItemStack(result), minSouls, drain, recipe);
|
||||
}
|
||||
|
||||
public TartaricForgeRecipe(Item result, double minSouls, double drain, Object... recipe) {
|
||||
this(new ItemStack(result), minSouls, drain, recipe);
|
||||
}
|
||||
|
||||
public TartaricForgeRecipe(ItemStack result, double minSouls, double drain, Object... recipe) {
|
||||
output = result.copy();
|
||||
this.minimumSouls = minSouls;
|
||||
this.soulsDrained = drain;
|
||||
for (Object in : recipe) {
|
||||
if (in instanceof ItemStack) {
|
||||
input.add(((ItemStack) in).copy());
|
||||
} else if (in instanceof Item) {
|
||||
input.add(new ItemStack((Item) in));
|
||||
} else if (in instanceof Block) {
|
||||
input.add(new ItemStack((Block) in));
|
||||
} else if (in instanceof String) {
|
||||
input.add(OreDictionary.getOres((String) in));
|
||||
} else {
|
||||
String ret = "Invalid soul forge recipe: ";
|
||||
for (Object tmp : recipe) {
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += output;
|
||||
throw new RuntimeException(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the recipe area
|
||||
*/
|
||||
public int getRecipeSize() {
|
||||
return input.size();
|
||||
}
|
||||
|
||||
public ItemStack getRecipeOutput() {
|
||||
return output.copy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if a recipe matches current crafting inventory. World and
|
||||
* BlockPos are for future-proofing
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean matches(List<ItemStack> checkedList, World world, BlockPos pos) {
|
||||
ArrayList<Object> required = new ArrayList<Object>(input);
|
||||
|
||||
for (int x = 0; x < checkedList.size(); x++) {
|
||||
ItemStack slot = checkedList.get(x);
|
||||
|
||||
if (slot != null) {
|
||||
boolean inRecipe = false;
|
||||
Iterator<Object> req = required.iterator();
|
||||
|
||||
while (req.hasNext()) {
|
||||
boolean match = false;
|
||||
|
||||
Object next = req.next();
|
||||
|
||||
if (next instanceof ItemStack) {
|
||||
match = OreDictionary.itemMatches((ItemStack) next, slot, false);
|
||||
} else if (next instanceof List) {
|
||||
Iterator<ItemStack> itr = ((List<ItemStack>) next).iterator();
|
||||
while (itr.hasNext() && !match) {
|
||||
match = OreDictionary.itemMatches(itr.next(), slot, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
inRecipe = true;
|
||||
required.remove(next);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!inRecipe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return required.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the input for this recipe, any mod accessing this value should
|
||||
* never manipulate the values in this array as it will effect the recipe
|
||||
* itself.
|
||||
*
|
||||
* @return The recipes input vales.
|
||||
*/
|
||||
public List<Object> getInput() {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
public double getMinimumSouls() {
|
||||
return minimumSouls;
|
||||
}
|
||||
|
||||
public double getSoulsDrained() {
|
||||
return soulsDrained;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this)
|
||||
.append("output", output)
|
||||
.append("input", input)
|
||||
.append("minimumSouls", minimumSouls)
|
||||
.append("soulsDrained", soulsDrained)
|
||||
.append("recipeSize", getRecipeSize())
|
||||
.append("recipeOutput", getRecipeOutput())
|
||||
.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof TartaricForgeRecipe)) return false;
|
||||
|
||||
TartaricForgeRecipe that = (TartaricForgeRecipe) o;
|
||||
|
||||
if (Double.compare(that.minimumSouls, minimumSouls) != 0) return false;
|
||||
if (Double.compare(that.soulsDrained, soulsDrained) != 0) return false;
|
||||
if (output != null ? !output.equals(that.output) : that.output != null) return false;
|
||||
return input != null ? input.equals(that.input) : that.input == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result;
|
||||
long temp;
|
||||
result = output != null ? output.hashCode() : 0;
|
||||
result = 31 * result + (input != null ? input.hashCode() : 0);
|
||||
temp = Double.doubleToLongBits(minimumSouls);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(soulsDrained);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,350 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.registry;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.ItemStackWrapper;
|
||||
import WayofTime.bloodmagic.apibutnotreally.alchemyCrafting.AlchemyArrayEffect;
|
||||
import WayofTime.bloodmagic.apibutnotreally.alchemyCrafting.AlchemyArrayEffectCrafting;
|
||||
import WayofTime.bloodmagic.apibutnotreally.alchemyCrafting.AlchemyCircleRenderer;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class AlchemyArrayRecipeRegistry {
|
||||
public static final AlchemyCircleRenderer defaultRenderer = new AlchemyCircleRenderer(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BaseArray.png"));
|
||||
|
||||
private static BiMap<List<ItemStack>, AlchemyArrayRecipe> recipes = HashBiMap.create();
|
||||
private static HashMap<String, AlchemyArrayEffect> effectMap = new HashMap<String, AlchemyArrayEffect>();
|
||||
|
||||
/**
|
||||
* General case for creating an AlchemyArrayEffect for a given input.
|
||||
*
|
||||
* @param input - Input item(s) that is used to change the Alchemy Circle into the
|
||||
* circle that you are making
|
||||
* @param catalystStack - Catalyst item that, when right-clicked onto the array, will
|
||||
* cause an effect
|
||||
* @param arrayEffect - The effect that will be activated once the array is activated
|
||||
* @param circleRenderer - Circle rendered when the array is passive - can be substituted
|
||||
* for a special renderer
|
||||
*/
|
||||
public static void registerRecipe(List<ItemStack> input, @Nullable ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) {
|
||||
effectMap.put(arrayEffect.getKey(), arrayEffect);
|
||||
|
||||
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(input)) {
|
||||
AlchemyArrayEffect eff = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
||||
if (eff != null) {
|
||||
return; // Recipe already exists!
|
||||
} else {
|
||||
arrayRecipe.catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
|
||||
if (circleRenderer != null) {
|
||||
if (arrayRecipe.defaultCircleRenderer == null) {
|
||||
arrayRecipe.defaultCircleRenderer = circleRenderer;
|
||||
} else {
|
||||
arrayRecipe.circleMap.put(ItemStackWrapper.getHolder(catalystStack), circleRenderer);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
recipes.put(input, new AlchemyArrayRecipe(input, catalystStack, arrayEffect, circleRenderer == null ? defaultRenderer : circleRenderer));
|
||||
}
|
||||
|
||||
public static AlchemyArrayEffect getAlchemyArrayEffect(String key) {
|
||||
return effectMap.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key
|
||||
* @return an array of two ItemStacks - first index is the input stack,
|
||||
* second is the catalyst stack. Returns {null, null} if no recipe
|
||||
* is valid.
|
||||
*/
|
||||
public static ItemStack[] getRecipeForArrayEffect(String key) {
|
||||
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||
AlchemyArrayRecipe recipe = entry.getValue();
|
||||
if (recipe != null && entry.getKey().size() > 0) {
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayEffect> effectEntry : recipe.catalystMap.entrySet()) {
|
||||
if (effectEntry.getValue() != null && effectEntry.getValue().key.equals(key)) {
|
||||
return new ItemStack[]{entry.getKey().get(0), effectEntry.getKey().toStack()};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ItemStack[]{null, null};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param stack of the recipe
|
||||
* @return an array of two ItemStacks - first index is the input stack,
|
||||
* second is the catalyst stack. Returns {null, null} if no recipe
|
||||
* is valid.
|
||||
*/
|
||||
public static ItemStack[] getRecipeForOutputStack(ItemStack stack) {
|
||||
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||
AlchemyArrayRecipe recipe = entry.getValue();
|
||||
if (recipe != null && entry.getKey().size() > 0) {
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayEffect> effectEntry : recipe.catalystMap.entrySet()) {
|
||||
if (effectEntry.getValue() instanceof AlchemyArrayEffectCrafting) {
|
||||
AlchemyArrayEffectCrafting craftingEffect = (AlchemyArrayEffectCrafting) effectEntry.getValue();
|
||||
ItemStack resultStack = craftingEffect.outputStack;
|
||||
if (!resultStack.isEmpty()) {
|
||||
if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage()) {
|
||||
return new ItemStack[]{entry.getKey().get(0), effectEntry.getKey().toStack()};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ItemStack[]{null, null};
|
||||
}
|
||||
|
||||
public static void registerCraftingRecipe(ItemStack input, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource) {
|
||||
registerRecipe(input, catalystStack, new AlchemyArrayEffectCrafting(outputStack), arrayResource);
|
||||
}
|
||||
|
||||
public static void registerCraftingRecipe(List<ItemStack> inputStacks, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource) {
|
||||
registerRecipe(inputStacks, catalystStack, new AlchemyArrayEffectCrafting(outputStack), arrayResource);
|
||||
}
|
||||
|
||||
public static void registerCraftingRecipe(String inputOreDict, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource) {
|
||||
registerRecipe(OreDictionary.doesOreNameExist(inputOreDict) && OreDictionary.getOres(inputOreDict).size() > 0 ? OreDictionary.getOres(inputOreDict) : Collections.<ItemStack>emptyList(), catalystStack, new AlchemyArrayEffectCrafting(outputStack), arrayResource);
|
||||
}
|
||||
|
||||
public static void registerCraftingRecipe(ItemStack input, ItemStack catalystStack, ItemStack outputStack) {
|
||||
registerRecipe(input, catalystStack, new AlchemyArrayEffectCrafting(outputStack));
|
||||
}
|
||||
|
||||
public static void registerCraftingRecipe(List<ItemStack> inputStacks, ItemStack catalystStack, ItemStack outputStack) {
|
||||
registerRecipe(inputStacks, catalystStack, new AlchemyArrayEffectCrafting(outputStack));
|
||||
}
|
||||
|
||||
public static void registerCraftingRecipe(String inputOreDict, ItemStack catalystStack, ItemStack outputStack) {
|
||||
registerRecipe(OreDictionary.doesOreNameExist(inputOreDict) && OreDictionary.getOres(inputOreDict).size() > 0 ? OreDictionary.getOres(inputOreDict) : Collections.<ItemStack>emptyList(), catalystStack, new AlchemyArrayEffectCrafting(outputStack));
|
||||
}
|
||||
|
||||
public static void registerRecipe(ItemStack inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource) {
|
||||
AlchemyCircleRenderer circleRenderer = arrayResource == null ? defaultRenderer : new AlchemyCircleRenderer(arrayResource);
|
||||
registerRecipe(Collections.singletonList(inputStacks), catalystStack, arrayEffect, circleRenderer);
|
||||
}
|
||||
|
||||
public static void registerRecipe(ItemStack inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) {
|
||||
registerRecipe(Collections.singletonList(inputStacks), catalystStack, arrayEffect, circleRenderer);
|
||||
}
|
||||
|
||||
public static void registerRecipe(List<ItemStack> inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource) {
|
||||
AlchemyCircleRenderer circleRenderer = arrayResource == null ? defaultRenderer : new AlchemyCircleRenderer(arrayResource);
|
||||
registerRecipe(inputStacks, catalystStack, arrayEffect, circleRenderer);
|
||||
}
|
||||
|
||||
public static void registerRecipe(String inputOreDict, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource) {
|
||||
AlchemyCircleRenderer circleRenderer = arrayResource == null ? defaultRenderer : new AlchemyCircleRenderer(arrayResource);
|
||||
registerRecipe(OreDictionary.doesOreNameExist(inputOreDict) && OreDictionary.getOres(inputOreDict).size() > 0 ? OreDictionary.getOres(inputOreDict) : Collections.<ItemStack>emptyList(), catalystStack, arrayEffect, circleRenderer);
|
||||
}
|
||||
|
||||
public static void registerRecipe(ItemStack input, ItemStack catalystStack, AlchemyArrayEffect arrayEffect) {
|
||||
registerRecipe(Collections.singletonList(input), catalystStack, arrayEffect, (AlchemyCircleRenderer) null);
|
||||
}
|
||||
|
||||
public static void registerRecipe(List<ItemStack> inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect) {
|
||||
registerRecipe(inputStacks, catalystStack, arrayEffect, (AlchemyCircleRenderer) null);
|
||||
}
|
||||
|
||||
public static void registerRecipe(String inputOreDict, ItemStack catalystStack, AlchemyArrayEffect arrayEffect) {
|
||||
registerRecipe(OreDictionary.doesOreNameExist(inputOreDict) && OreDictionary.getOres(inputOreDict).size() > 0 ? OreDictionary.getOres(inputOreDict) : Collections.<ItemStack>emptyList(), catalystStack, arrayEffect, (AlchemyCircleRenderer) null);
|
||||
}
|
||||
|
||||
public static void replaceAlchemyCircle(List<ItemStack> input, AlchemyCircleRenderer circleRenderer) {
|
||||
if (circleRenderer == null)
|
||||
return;
|
||||
|
||||
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(input))
|
||||
arrayRecipe.defaultCircleRenderer = circleRenderer;
|
||||
}
|
||||
}
|
||||
|
||||
public static AlchemyArrayRecipe getRecipeForInput(List<ItemStack> input) {
|
||||
return recipes.get(input);
|
||||
}
|
||||
|
||||
public static AlchemyArrayEffect getAlchemyArrayEffect(List<ItemStack> input, @Nullable ItemStack catalystStack) {
|
||||
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (input.size() == 1 && arrayRecipe.getInput().size() == 1) {
|
||||
if (ItemStackWrapper.getHolder(arrayRecipe.getInput().get(0)).equals(ItemStackWrapper.getHolder(input.get(0)))) {
|
||||
AlchemyArrayEffect effect = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
||||
if (effect != null) {
|
||||
return effect.getNewCopy();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (input.equals(arrayRecipe.getInput())) {
|
||||
AlchemyArrayEffect effect = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
||||
if (effect != null) {
|
||||
return effect.getNewCopy();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static AlchemyArrayEffect getAlchemyArrayEffect(ItemStack input, @Nullable ItemStack catalystStack) {
|
||||
return getAlchemyArrayEffect(Collections.singletonList(input), catalystStack);
|
||||
}
|
||||
|
||||
public static AlchemyCircleRenderer getAlchemyCircleRenderer(List<ItemStack> input, @Nullable ItemStack catalystStack) {
|
||||
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(input)) {
|
||||
return arrayRecipe.getAlchemyArrayRendererForCatalyst(catalystStack);
|
||||
}
|
||||
}
|
||||
|
||||
return defaultRenderer;
|
||||
}
|
||||
|
||||
public static AlchemyCircleRenderer getAlchemyCircleRenderer(ItemStack itemStack, @Nullable ItemStack catalystStack) {
|
||||
return getAlchemyCircleRenderer(Collections.singletonList(itemStack), catalystStack);
|
||||
}
|
||||
|
||||
public static BiMap<List<ItemStack>, AlchemyArrayRecipe> getRecipes() {
|
||||
return HashBiMap.create(recipes);
|
||||
}
|
||||
|
||||
public static class AlchemyArrayRecipe {
|
||||
public final List<ItemStack> input;
|
||||
public final BiMap<ItemStackWrapper, AlchemyArrayEffect> catalystMap = HashBiMap.create();
|
||||
public final BiMap<ItemStackWrapper, AlchemyCircleRenderer> circleMap = HashBiMap.create();
|
||||
public AlchemyCircleRenderer defaultCircleRenderer;
|
||||
|
||||
private AlchemyArrayRecipe(List<ItemStack> input, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer, boolean useless) {
|
||||
this.input = input;
|
||||
|
||||
catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
|
||||
|
||||
this.defaultCircleRenderer = circleRenderer;
|
||||
}
|
||||
|
||||
public AlchemyArrayRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) {
|
||||
this(Collections.singletonList(inputStack), catalystStack, arrayEffect, circleRenderer, false);
|
||||
}
|
||||
|
||||
public AlchemyArrayRecipe(String inputOreDict, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) {
|
||||
this(OreDictionary.doesOreNameExist(inputOreDict) && OreDictionary.getOres(inputOreDict).size() > 0 ? OreDictionary.getOres(inputOreDict) : Collections.<ItemStack>emptyList(), catalystStack, arrayEffect, circleRenderer, false);
|
||||
}
|
||||
|
||||
public AlchemyArrayRecipe(List<ItemStack> inputStacks, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) {
|
||||
this(inputStacks, catalystStack, arrayEffect, circleRenderer, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the inputed list of ItemStacks to see if it matches with the
|
||||
* recipe's list.
|
||||
*
|
||||
* @param comparedList - The list to compare with
|
||||
* @return - True if the ItemStack(s) is a compatible item
|
||||
*/
|
||||
public boolean doesInputMatchRecipe(List<ItemStack> comparedList) {
|
||||
return !(comparedList == null || this.input == null) && (this.input.size() == 1 && comparedList.size() == 1 ? this.input.get(0).isItemEqual(comparedList.get(0)) : this.input.equals(comparedList));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the actual AlchemyArrayEffect for the given catalyst.
|
||||
*
|
||||
* @param comparedStack The catalyst that is being checked
|
||||
* @return - The effect
|
||||
*/
|
||||
public AlchemyArrayEffect getAlchemyArrayEffectForCatalyst(@Nullable ItemStack comparedStack) {
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayEffect> entry : catalystMap.entrySet()) {
|
||||
ItemStack catalystStack = entry.getKey().toStack();
|
||||
|
||||
if (comparedStack == null && catalystStack == null)
|
||||
return entry.getValue();
|
||||
|
||||
if (comparedStack == null || catalystStack == null)
|
||||
continue;
|
||||
|
||||
if (catalystStack.isItemEqual(comparedStack))
|
||||
return entry.getValue();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public AlchemyCircleRenderer getAlchemyArrayRendererForCatalyst(@Nullable ItemStack comparedStack) {
|
||||
for (Entry<ItemStackWrapper, AlchemyCircleRenderer> entry : circleMap.entrySet()) {
|
||||
ItemStack catalystStack = entry.getKey().toStack();
|
||||
|
||||
if (comparedStack == null && catalystStack == null)
|
||||
return entry.getValue();
|
||||
|
||||
if (comparedStack == null || catalystStack == null)
|
||||
continue;
|
||||
|
||||
if (catalystStack.isItemEqual(comparedStack))
|
||||
return entry.getValue();
|
||||
}
|
||||
|
||||
return defaultCircleRenderer;
|
||||
}
|
||||
|
||||
public AlchemyCircleRenderer getDefaultCircleRenderer() {
|
||||
return defaultCircleRenderer;
|
||||
}
|
||||
|
||||
public List<ItemStack> getInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
public BiMap<ItemStackWrapper, AlchemyArrayEffect> getCatalystMap() {
|
||||
return catalystMap;
|
||||
}
|
||||
|
||||
public BiMap<ItemStackWrapper, AlchemyCircleRenderer> getCircleMap() {
|
||||
return circleMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof AlchemyArrayRecipe)) return false;
|
||||
|
||||
AlchemyArrayRecipe that = (AlchemyArrayRecipe) o;
|
||||
|
||||
if (defaultCircleRenderer != null ? !defaultCircleRenderer.equals(that.defaultCircleRenderer) : that.defaultCircleRenderer != null)
|
||||
return false;
|
||||
if (input != null ? !input.equals(that.input) : that.input != null) return false;
|
||||
if (catalystMap != null ? !catalystMap.equals(that.catalystMap) : that.catalystMap != null) return false;
|
||||
return circleMap != null ? circleMap.equals(that.circleMap) : that.circleMap == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = defaultCircleRenderer != null ? defaultCircleRenderer.hashCode() : 0;
|
||||
result = 31 * result + (input != null ? input.hashCode() : 0);
|
||||
result = 31 * result + (catalystMap != null ? catalystMap.hashCode() : 0);
|
||||
result = 31 * result + (circleMap != null ? circleMap.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.registry;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.recipe.AlchemyTableRecipe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AlchemyTableRecipeRegistry {
|
||||
private static List<AlchemyTableRecipe> recipeList = new ArrayList<AlchemyTableRecipe>();
|
||||
|
||||
public static void registerRecipe(AlchemyTableRecipe recipe) {
|
||||
recipeList.add(recipe);
|
||||
}
|
||||
|
||||
public static void registerRecipe(ItemStack outputStack, int lpDrained, int ticksRequired, int tierRequired, Object... objects) {
|
||||
registerRecipe(new AlchemyTableRecipe(outputStack, lpDrained, ticksRequired, tierRequired, objects));
|
||||
}
|
||||
|
||||
public static void removeRecipe(AlchemyTableRecipe recipe) {
|
||||
recipeList.remove(recipe);
|
||||
}
|
||||
|
||||
public static AlchemyTableRecipe getMatchingRecipe(List<ItemStack> itemList, World world, BlockPos pos) {
|
||||
for (AlchemyTableRecipe recipe : recipeList) {
|
||||
if (recipe.matches(itemList, world, pos)) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<AlchemyTableRecipe> getRecipeList() {
|
||||
return new ArrayList<AlchemyTableRecipe>(recipeList);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,215 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.registry;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.BloodMagicAPI;
|
||||
import WayofTime.bloodmagic.apibutnotreally.ItemStackWrapper;
|
||||
import WayofTime.bloodmagic.apibutnotreally.altar.EnumAltarTier;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class AltarRecipeRegistry {
|
||||
private static BiMap<List<ItemStackWrapper>, AltarRecipe> recipes = HashBiMap.create();
|
||||
|
||||
/**
|
||||
* Registers an {@link AltarRecipe} for the Blood Altar. This can be a
|
||||
* {@code ItemStack}, {@code List<Itemstack>}, or {@code String}
|
||||
* OreDictionary entry.
|
||||
* <p>
|
||||
* If the OreDictionary entry does not exist or is empty, it will not be
|
||||
* registered.
|
||||
*
|
||||
* @param altarRecipe - The AltarRecipe to register
|
||||
*/
|
||||
public static void registerRecipe(AltarRecipe altarRecipe) {
|
||||
if (!recipes.containsValue(altarRecipe) && altarRecipe.getInput().size() > 0)
|
||||
recipes.put(altarRecipe.getInput(), altarRecipe);
|
||||
else
|
||||
BloodMagicAPI.logger.error("Error adding altar recipe for input [{}].", altarRecipe.toString());
|
||||
}
|
||||
|
||||
public static void registerFillRecipe(ItemStack orbStack, EnumAltarTier tier, int maxForOrb, int consumeRate, int drainRate) {
|
||||
registerRecipe(new AltarRecipe(orbStack, orbStack, tier, maxForOrb, consumeRate, drainRate, true));
|
||||
}
|
||||
|
||||
public static void removeRecipe(AltarRecipe altarRecipe) {
|
||||
recipes.remove(altarRecipe.getInput());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the recipe that the provided input is registered to.
|
||||
*
|
||||
* @param input - The input ItemStack to get the recipe for
|
||||
* @return - The recipe that the provided input is registered to.
|
||||
*/
|
||||
public static AltarRecipe getRecipeForInput(List<ItemStack> input) {
|
||||
List<ItemStackWrapper> wrapperList = ItemStackWrapper.toWrapperList(input);
|
||||
if (recipes.keySet().contains(wrapperList))
|
||||
return recipes.get(wrapperList);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//TODO: Determine a more time-effective method
|
||||
public static AltarRecipe getRecipeForInput(ItemStack input) {
|
||||
for (AltarRecipe recipe : recipes.values()) {
|
||||
if (recipe.doesRequiredItemMatch(input, recipe.getMinTier())) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static AltarRecipe getRecipeForInput(String input) {
|
||||
return getRecipeForInput(OreDictionary.getOres(input));
|
||||
}
|
||||
|
||||
public static BiMap<List<ItemStackWrapper>, AltarRecipe> getRecipes() {
|
||||
return HashBiMap.create(recipes);
|
||||
}
|
||||
|
||||
public static class AltarRecipe {
|
||||
private final List<ItemStackWrapper> input;
|
||||
private final ItemStack output;
|
||||
private final EnumAltarTier minTier;
|
||||
private final int syphon, consumeRate, drainRate;
|
||||
private final boolean fillable;
|
||||
|
||||
/**
|
||||
* Allows creation of a recipe for the
|
||||
* {@link WayofTime.bloodmagic.block.BlockAltar} /
|
||||
* {@link WayofTime.bloodmagic.tile.TileAltar}. The output ItemStack is
|
||||
* allowed to be null as some recipes do not contain an output. (Blood
|
||||
* Orbs)
|
||||
*
|
||||
* @param input - The input ItemStack
|
||||
* @param output - The ItemStack obtained from the recipe
|
||||
* @param minTier - The minimum tier of Altar required
|
||||
* @param syphon - The amount of LP to syphon from the Altar
|
||||
* @param consumeRate - The rate at which LP is consumed during crafting
|
||||
* @param drainRate - The rate at which LP is drained during crafting
|
||||
* @param fillable - Whether the input item can be filled with LP. IE: Orbs
|
||||
*/
|
||||
public AltarRecipe(List<ItemStack> input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean fillable) {
|
||||
this.input = ItemStackWrapper.toWrapperList(input);
|
||||
this.output = output;
|
||||
this.minTier = minTier;
|
||||
this.syphon = syphon < 0 ? -syphon : syphon;
|
||||
this.consumeRate = consumeRate < 0 ? -consumeRate : consumeRate;
|
||||
this.drainRate = drainRate < 0 ? -drainRate : drainRate;
|
||||
this.fillable = fillable;
|
||||
}
|
||||
|
||||
public AltarRecipe(List<ItemStack> input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate) {
|
||||
this(input, output, minTier, syphon, consumeRate, drainRate, false);
|
||||
}
|
||||
|
||||
public AltarRecipe(ItemStack input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean fillable) {
|
||||
this(Collections.singletonList(input), output, minTier, syphon, consumeRate, drainRate, fillable);
|
||||
}
|
||||
|
||||
public AltarRecipe(ItemStack input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate) {
|
||||
this(Collections.singletonList(input), output, minTier, syphon, consumeRate, drainRate, false);
|
||||
}
|
||||
|
||||
public AltarRecipe(String inputEntry, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean fillable) {
|
||||
this(OreDictionary.doesOreNameExist(inputEntry) && OreDictionary.getOres(inputEntry).size() > 0 ? OreDictionary.getOres(inputEntry) : Collections.<ItemStack>emptyList(), output, minTier, syphon, consumeRate, drainRate, fillable);
|
||||
}
|
||||
|
||||
public AltarRecipe(String inputEntry, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate) {
|
||||
this(OreDictionary.doesOreNameExist(inputEntry) && OreDictionary.getOres(inputEntry).size() > 0 ? OreDictionary.getOres(inputEntry) : Collections.<ItemStack>emptyList(), output, minTier, syphon, consumeRate, drainRate, false);
|
||||
}
|
||||
|
||||
public boolean doesRequiredItemMatch(ItemStack comparedStack, EnumAltarTier tierCheck) {
|
||||
if (comparedStack == null || this.input == null)
|
||||
return false;
|
||||
|
||||
if (tierCheck.ordinal() < minTier.ordinal())
|
||||
return false;
|
||||
|
||||
for (ItemStackWrapper stack : input) {
|
||||
if (comparedStack.isItemEqual(stack.toStack()))
|
||||
return true;
|
||||
|
||||
if (comparedStack.getItem() == stack.item && stack.meta == OreDictionary.WILDCARD_VALUE)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<ItemStackWrapper> getInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
public ItemStack getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
public EnumAltarTier getMinTier() {
|
||||
return minTier;
|
||||
}
|
||||
|
||||
public int getSyphon() {
|
||||
return syphon;
|
||||
}
|
||||
|
||||
public int getConsumeRate() {
|
||||
return consumeRate;
|
||||
}
|
||||
|
||||
public int getDrainRate() {
|
||||
return drainRate;
|
||||
}
|
||||
|
||||
public boolean isFillable() {
|
||||
return fillable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof AltarRecipe)) return false;
|
||||
|
||||
AltarRecipe that = (AltarRecipe) o;
|
||||
|
||||
if (syphon != that.syphon) return false;
|
||||
if (consumeRate != that.consumeRate) return false;
|
||||
if (drainRate != that.drainRate) return false;
|
||||
if (fillable != that.fillable) return false;
|
||||
if (input != null ? !input.equals(that.input) : that.input != null) return false;
|
||||
if (output != null ? !output.equals(that.output) : that.output != null) return false;
|
||||
return minTier == that.minTier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = input != null ? input.hashCode() : 0;
|
||||
result = 31 * result + (output != null ? output.hashCode() : 0);
|
||||
result = 31 * result + (minTier != null ? minTier.hashCode() : 0);
|
||||
result = 31 * result + syphon;
|
||||
result = 31 * result + consumeRate;
|
||||
result = 31 * result + drainRate;
|
||||
result = 31 * result + (fillable ? 1 : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this)
|
||||
.append("input", input)
|
||||
.append("output", output)
|
||||
.append("minTier", minTier)
|
||||
.append("syphon", syphon)
|
||||
.append("consumeRate", consumeRate)
|
||||
.append("drainRate", drainRate)
|
||||
.append("fillable", fillable)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.registry;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.BlockStack;
|
||||
import WayofTime.bloodmagic.apibutnotreally.iface.IHarvestHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockStem;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class HarvestRegistry {
|
||||
private static List<IHarvestHandler> handlerList = new ArrayList<IHarvestHandler>();
|
||||
private static Map<Block, Integer> standardCrops = new HashMap<Block, Integer>();
|
||||
private static Set<BlockStack> tallCrops = new HashSet<BlockStack>();
|
||||
private static Map<BlockStack, BlockStack> stemCrops = new HashMap<BlockStack, BlockStack>();
|
||||
private static Map<BlockStack, Integer> amplifierMap = new HashMap<BlockStack, Integer>();
|
||||
|
||||
/**
|
||||
* Registers a handler for the Harvest Ritual to call.
|
||||
*
|
||||
* @param handler - The custom handler to register
|
||||
*/
|
||||
public static void registerHandler(IHarvestHandler handler) {
|
||||
if (!handlerList.contains(handler))
|
||||
handlerList.add(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a standard crop (IE: Wheat, Carrots, Potatoes, Netherwart, etc)
|
||||
* for the
|
||||
* {@link WayofTime.bloodmagic.ritual.harvest.HarvestHandlerPlantable}
|
||||
* handler to handle.
|
||||
*
|
||||
* @param crop - The crop block to handle.
|
||||
* @param matureMeta - The meta value at which the crop is considered mature and ready
|
||||
* to be harvested.
|
||||
*/
|
||||
public static void registerStandardCrop(Block crop, int matureMeta) {
|
||||
if (!standardCrops.containsKey(crop))
|
||||
standardCrops.put(crop, matureMeta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a tall crop (Sugar Cane and Cactus) for the
|
||||
* {@link WayofTime.bloodmagic.ritual.harvest.HarvestHandlerTall} handler to
|
||||
* handle.
|
||||
*
|
||||
* @param crop - The crop block to handle.
|
||||
*/
|
||||
public static void registerTallCrop(BlockStack crop) {
|
||||
if (!tallCrops.contains(crop))
|
||||
tallCrops.add(crop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a stem crop (Melon and Pumpkin) for the
|
||||
* {@link WayofTime.bloodmagic.ritual.harvest.HarvestHandlerStem} handler to
|
||||
* handle.
|
||||
* <p>
|
||||
* Use {@link net.minecraftforge.oredict.OreDictionary#WILDCARD_VALUE} to
|
||||
* accept any meta for the crop block.
|
||||
* <p>
|
||||
* The Stem must be instanceof {@link BlockStem}
|
||||
*
|
||||
* @param crop - The crop block to handle.
|
||||
* @param stem - The stem of the crop
|
||||
*/
|
||||
public static void registerStemCrop(BlockStack crop, BlockStack stem) {
|
||||
if (!stemCrops.containsKey(crop) && stem.getBlock() instanceof BlockStem)
|
||||
stemCrops.put(stem, crop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a range amplifier for the Harvest Ritual.
|
||||
*
|
||||
* @param blockStack - The block for the amplifier.
|
||||
* @param range - The range the amplifier provides.
|
||||
*/
|
||||
public static void registerRangeAmplifier(BlockStack blockStack, int range) {
|
||||
if (!amplifierMap.containsKey(blockStack))
|
||||
amplifierMap.put(blockStack, range);
|
||||
}
|
||||
|
||||
public static List<IHarvestHandler> getHandlerList() {
|
||||
return new ArrayList<IHarvestHandler>(handlerList);
|
||||
}
|
||||
|
||||
public static Map<Block, Integer> getStandardCrops() {
|
||||
return new HashMap<Block, Integer>(standardCrops);
|
||||
}
|
||||
|
||||
public static Set<BlockStack> getTallCrops() {
|
||||
return new HashSet<BlockStack>(tallCrops);
|
||||
}
|
||||
|
||||
public static Map<BlockStack, BlockStack> getStemCrops() {
|
||||
return new HashMap<BlockStack, BlockStack>(stemCrops);
|
||||
}
|
||||
|
||||
public static Map<BlockStack, Integer> getAmplifierMap() {
|
||||
return new HashMap<BlockStack, Integer>(amplifierMap);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.registry;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.BlockStack;
|
||||
import WayofTime.bloodmagic.apibutnotreally.BloodMagicAPI;
|
||||
import WayofTime.bloodmagic.apibutnotreally.ritual.imperfect.ImperfectRitual;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ImperfectRitualRegistry {
|
||||
public static final Map<ImperfectRitual, Boolean> enabledRituals = new HashMap<ImperfectRitual, Boolean>();
|
||||
private static final BiMap<String, ImperfectRitual> registry = HashBiMap.create();
|
||||
|
||||
/**
|
||||
* The safe way to register a new Ritual.
|
||||
*
|
||||
* @param imperfectRitual - The imperfect ritual to register.
|
||||
* @param id - The ID for the imperfect ritual. Cannot be duplicated.
|
||||
*/
|
||||
public static void registerRitual(ImperfectRitual imperfectRitual, String id, boolean enabled) {
|
||||
if (imperfectRitual != null) {
|
||||
if (registry.containsKey(id))
|
||||
BloodMagicAPI.logger.error("Duplicate imperfect ritual id: %s", id);
|
||||
else {
|
||||
registry.put(id, imperfectRitual);
|
||||
enabledRituals.put(imperfectRitual, enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerRitual(ImperfectRitual imperfectRitual, String id) {
|
||||
registerRitual(imperfectRitual, id, true);
|
||||
}
|
||||
|
||||
public static void registerRitual(ImperfectRitual imperfectRitual, boolean enabled) {
|
||||
registerRitual(imperfectRitual, imperfectRitual.getName(), enabled);
|
||||
}
|
||||
|
||||
public static void registerRitual(ImperfectRitual imperfectRitual) {
|
||||
registerRitual(imperfectRitual, imperfectRitual.getName());
|
||||
}
|
||||
|
||||
public static ImperfectRitual getRitualForBlock(BlockStack blockStack) {
|
||||
for (ImperfectRitual imperfectRitual : getRegistry().values())
|
||||
if (imperfectRitual.getRequiredBlock().equals(blockStack))
|
||||
return imperfectRitual;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ImperfectRitual getRitualForId(String id) {
|
||||
return registry.get(id);
|
||||
}
|
||||
|
||||
public static String getIdForRitual(ImperfectRitual imperfectRitual) {
|
||||
return registry.inverse().get(imperfectRitual);
|
||||
}
|
||||
|
||||
public static boolean isMapEmpty() {
|
||||
return registry.isEmpty();
|
||||
}
|
||||
|
||||
public static int getMapSize() {
|
||||
return registry.size();
|
||||
}
|
||||
|
||||
public static boolean ritualEnabled(ImperfectRitual imperfectRitual) {
|
||||
try {
|
||||
return enabledRituals.get(imperfectRitual);
|
||||
} catch (NullPointerException e) {
|
||||
BloodMagicAPI.logger.error("Invalid Imperfect Ritual was called");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean ritualEnabled(String id) {
|
||||
return ritualEnabled(getRitualForId(id));
|
||||
}
|
||||
|
||||
public static BiMap<String, ImperfectRitual> getRegistry() {
|
||||
return HashBiMap.create(registry);
|
||||
}
|
||||
|
||||
public static BiMap<ImperfectRitual, Boolean> getEnabledMap() {
|
||||
return HashBiMap.create(enabledRituals);
|
||||
}
|
||||
|
||||
public static ArrayList<String> getIds() {
|
||||
return new ArrayList<String>(registry.keySet());
|
||||
}
|
||||
|
||||
public static ArrayList<ImperfectRitual> getRituals() {
|
||||
return new ArrayList<ImperfectRitual>(registry.values());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.registry;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.apibutnotreally.recipe.LivingArmourDowngradeRecipe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class LivingArmourDowngradeRecipeRegistry {
|
||||
private static List<LivingArmourDowngradeRecipe> recipeList = new ArrayList<LivingArmourDowngradeRecipe>();
|
||||
private static Map<ItemStack, Map<Integer, List<ITextComponent>>> dialogueMap = new HashMap<ItemStack, Map<Integer, List<ITextComponent>>>();
|
||||
|
||||
public static void registerRecipe(LivingArmourDowngradeRecipe recipe) {
|
||||
recipeList.add(recipe);
|
||||
}
|
||||
|
||||
public static void registerDialog(ItemStack keyStack, Map<Integer, List<ITextComponent>> map) {
|
||||
dialogueMap.put(keyStack, map);
|
||||
}
|
||||
|
||||
public static List<ITextComponent> getDialogForProcessTick(ItemStack keyStack, int tick) {
|
||||
for (Entry<ItemStack, Map<Integer, List<ITextComponent>>> entry : dialogueMap.entrySet()) {
|
||||
ItemStack key = entry.getKey();
|
||||
if (OreDictionary.itemMatches(key, keyStack, false)) {
|
||||
Map<Integer, List<ITextComponent>> map = entry.getValue();
|
||||
if (map.containsKey(tick)) {
|
||||
return map.get(tick);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void registerRecipe(LivingArmourUpgrade upgrade, ItemStack keyStack, Object... recipe) {
|
||||
registerRecipe(new LivingArmourDowngradeRecipe(upgrade, keyStack, recipe));
|
||||
}
|
||||
|
||||
public static LivingArmourDowngradeRecipe getMatchingRecipe(ItemStack keyStack, List<ItemStack> itemList, World world, BlockPos pos) {
|
||||
for (LivingArmourDowngradeRecipe recipe : recipeList) {
|
||||
if (recipe.matches(keyStack, itemList, world, pos)) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<LivingArmourDowngradeRecipe> getRecipeList() {
|
||||
return new ArrayList<LivingArmourDowngradeRecipe>(recipeList);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.registry;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.altar.EnumAltarTier;
|
||||
import WayofTime.bloodmagic.apibutnotreally.orb.BloodOrb;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This is only for those who wish to add a basic {@link BloodOrb}. If you need
|
||||
* custom handling, you will need your own item class.
|
||||
*/
|
||||
@Deprecated
|
||||
public class OrbRegistry {
|
||||
@GameRegistry.ObjectHolder("bloodmagic:blood_orb")
|
||||
private static final Item ORB_ITEM = null;
|
||||
public static ArrayListMultimap<Integer, ItemStack> tierMap = ArrayListMultimap.create();
|
||||
private static List<BloodOrb> orbs = new ArrayList<BloodOrb>();
|
||||
|
||||
public static List<ItemStack> getOrbsForTier(int tier) {
|
||||
if (getTierMap().containsKey(tier))
|
||||
return getTierMap().get(tier);
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public static List<ItemStack> getOrbsUpToTier(int tier) {
|
||||
List<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
|
||||
for (int i = 1; i <= tier; i++)
|
||||
ret.addAll(getOrbsForTier(i));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static List<ItemStack> getOrbsDownToTier(int tier) {
|
||||
List<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
|
||||
for (int i = EnumAltarTier.MAXTIERS; i >= tier; i--)
|
||||
ret.addAll(getOrbsForTier(i));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static ItemStack getOrbStack(BloodOrb orb) {
|
||||
ItemStack ret = new ItemStack(ORB_ITEM);
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setString("orb", orb.getRegistryName().toString());
|
||||
ret.setTagCompound(tag);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static ArrayListMultimap<Integer, ItemStack> getTierMap() {
|
||||
return ArrayListMultimap.create(tierMap);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.registry;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.BloodMagicAPI;
|
||||
import WayofTime.bloodmagic.apibutnotreally.ritual.Ritual;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
public class RitualRegistry {
|
||||
public static final Map<Ritual, Boolean> enabledRituals = new HashMap<Ritual, Boolean>();
|
||||
private static final BiMap<String, Ritual> registry = HashBiMap.create();
|
||||
private static final List<String> lookupList = new ArrayList<String>();
|
||||
/**
|
||||
* Ordered list for actions that depend on the order that the rituals were
|
||||
* registered in
|
||||
*/
|
||||
private static final ArrayList<String> orderedIdList = new ArrayList<String>();
|
||||
|
||||
private static boolean locked;
|
||||
|
||||
/**
|
||||
* The safe way to register a new Ritual.
|
||||
*
|
||||
* @param ritual - The ritual to register.
|
||||
* @param id - The ID for the ritual. Cannot be duplicated.
|
||||
*/
|
||||
public static void registerRitual(Ritual ritual, String id, boolean enabled) {
|
||||
if (locked) {
|
||||
BloodMagicAPI.logger.error("This registry has been locked. Please register your ritual earlier.");
|
||||
BloodMagicAPI.logger.error("If you reflect this, I will hunt you down. - TehNut");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ritual != null) {
|
||||
if (registry.containsKey(id))
|
||||
BloodMagicAPI.logger.error("Duplicate ritual id: %s", id);
|
||||
else {
|
||||
registry.put(id, ritual);
|
||||
enabledRituals.put(ritual, enabled);
|
||||
orderedIdList.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerRitual(Ritual ritual, boolean enabled) {
|
||||
registerRitual(ritual, ritual.getName(), enabled);
|
||||
}
|
||||
|
||||
public static void registerRitual(Ritual ritual, String id) {
|
||||
registerRitual(ritual, id, true);
|
||||
}
|
||||
|
||||
public static void registerRitual(Ritual ritual) {
|
||||
registerRitual(ritual, ritual.getName());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Ritual getRitualForId(String id) {
|
||||
Ritual ritual = registry.get(id);
|
||||
return ritual != null ? ritual.getNewCopy() : null;
|
||||
}
|
||||
|
||||
public static String getIdForRitual(Ritual ritual) {
|
||||
return registry.inverse().get(ritual);
|
||||
}
|
||||
|
||||
public static boolean isMapEmpty() {
|
||||
return registry.isEmpty();
|
||||
}
|
||||
|
||||
public static int getMapSize() {
|
||||
return registry.size();
|
||||
}
|
||||
|
||||
public static boolean ritualEnabled(Ritual ritual) {
|
||||
try {
|
||||
return enabledRituals.get(ritual);
|
||||
} catch (NullPointerException e) {
|
||||
BloodMagicAPI.logger.error("Invalid Ritual was called");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean ritualEnabled(String id) {
|
||||
return ritualEnabled(getRitualForId(id));
|
||||
}
|
||||
|
||||
public static BiMap<String, Ritual> getRegistry() {
|
||||
return HashBiMap.create(registry);
|
||||
}
|
||||
|
||||
public static Map<Ritual, Boolean> getEnabledMap() {
|
||||
return new HashMap<Ritual, Boolean>(enabledRituals);
|
||||
}
|
||||
|
||||
public static ArrayList<String> getIds() {
|
||||
return new ArrayList<String>(lookupList);
|
||||
}
|
||||
|
||||
public static ArrayList<String> getOrderedIds() {
|
||||
return orderedIdList;
|
||||
}
|
||||
|
||||
public static ArrayList<Ritual> getRituals() {
|
||||
return new ArrayList<Ritual>(registry.values());
|
||||
}
|
||||
|
||||
public static void orderLookupList() {
|
||||
locked = true; // Lock registry so no no rituals can be registered
|
||||
lookupList.clear(); // Make sure it's empty
|
||||
lookupList.addAll(registry.keySet());
|
||||
Collections.sort(lookupList, new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
Ritual ritual1 = registry.get(o1);
|
||||
Ritual ritual2 = registry.get(o2);
|
||||
return ritual1.getComponents().size() > ritual2.getComponents().size() ? -1 : 0; // Put earlier if bigger
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.registry;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.recipe.TartaricForgeRecipe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TartaricForgeRecipeRegistry {
|
||||
private static List<TartaricForgeRecipe> recipeList = new ArrayList<TartaricForgeRecipe>();
|
||||
|
||||
public static void registerRecipe(TartaricForgeRecipe recipe) {
|
||||
recipeList.add(recipe);
|
||||
}
|
||||
|
||||
public static void registerRecipe(ItemStack outputStack, double minimulSouls, double drain, Object... objects) {
|
||||
registerRecipe(new TartaricForgeRecipe(outputStack, minimulSouls, drain, objects));
|
||||
}
|
||||
|
||||
public static void removeRecipe(TartaricForgeRecipe recipe) {
|
||||
recipeList.remove(recipe);
|
||||
}
|
||||
|
||||
public static TartaricForgeRecipe getMatchingRecipe(List<ItemStack> itemList, World world, BlockPos pos) {
|
||||
for (TartaricForgeRecipe recipe : recipeList) {
|
||||
if (recipe.matches(itemList, world, pos)) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<TartaricForgeRecipe> getRecipeList() {
|
||||
return new ArrayList<TartaricForgeRecipe>(recipeList);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,495 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.ritual;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.Constants;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.gen.structure.template.PlacementSettings;
|
||||
import net.minecraft.world.gen.structure.template.Template;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AreaDescriptor implements Iterator<BlockPos> {
|
||||
public List<BlockPos> getContainedPositions(BlockPos pos) {
|
||||
return new ArrayList<BlockPos>();
|
||||
}
|
||||
|
||||
public AxisAlignedBB getAABB(BlockPos pos) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract void resetCache();
|
||||
|
||||
public abstract boolean isWithinArea(BlockPos pos);
|
||||
|
||||
public abstract void resetIterator();
|
||||
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
|
||||
}
|
||||
|
||||
public abstract int getVolumeForOffsets(BlockPos offset1, BlockPos offset2);
|
||||
|
||||
public abstract boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit);
|
||||
|
||||
public abstract int getVolume();
|
||||
|
||||
public abstract boolean isWithinRange(int verticalLimit, int horizontalLimit);
|
||||
|
||||
/**
|
||||
* This method changes the area descriptor so that its range matches the two
|
||||
* blocks that are selected. When implementing this method, assume that
|
||||
* these positions are the blocks that are clicked by the player.
|
||||
*
|
||||
* @param pos1
|
||||
* @param pos2
|
||||
*/
|
||||
public abstract void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2);
|
||||
|
||||
public abstract boolean intersects(AreaDescriptor descriptor);
|
||||
|
||||
public abstract AreaDescriptor offset(BlockPos offset);
|
||||
|
||||
public abstract AreaDescriptor rotateDescriptor(PlacementSettings settings);
|
||||
|
||||
public static class Rectangle extends AreaDescriptor {
|
||||
protected BlockPos minimumOffset;
|
||||
protected BlockPos maximumOffset; // Non-inclusive maximum offset.
|
||||
private BlockPos currentPosition;
|
||||
|
||||
private ArrayList<BlockPos> blockPosCache;
|
||||
private BlockPos cachedPosition;
|
||||
|
||||
private boolean cache = true;
|
||||
|
||||
/**
|
||||
* This constructor takes in the minimum and maximum BlockPos. The
|
||||
* maximum offset is non-inclusive, meaning if you pass in (0,0,0) and
|
||||
* (1,1,1), calling getContainedPositions() will only give (0,0,0).
|
||||
*
|
||||
* @param minimumOffset -
|
||||
* @param maximumOffset -
|
||||
*/
|
||||
public Rectangle(BlockPos minimumOffset, BlockPos maximumOffset) {
|
||||
setOffsets(minimumOffset, maximumOffset);
|
||||
}
|
||||
|
||||
public Rectangle(BlockPos minimumOffset, int sizeX, int sizeY, int sizeZ) {
|
||||
this(minimumOffset, minimumOffset.add(sizeX, sizeY, sizeZ));
|
||||
}
|
||||
|
||||
public Rectangle(BlockPos minimumOffset, int size) {
|
||||
this(minimumOffset, size, size, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPos> getContainedPositions(BlockPos pos) {
|
||||
if (!cache || !pos.equals(cachedPosition) || blockPosCache.isEmpty()) {
|
||||
ArrayList<BlockPos> posList = new ArrayList<BlockPos>();
|
||||
|
||||
for (int j = minimumOffset.getY(); j < maximumOffset.getY(); j++) {
|
||||
for (int i = minimumOffset.getX(); i < maximumOffset.getX(); i++) {
|
||||
for (int k = minimumOffset.getZ(); k < maximumOffset.getZ(); k++) {
|
||||
posList.add(pos.add(i, j, k));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
blockPosCache = posList;
|
||||
cachedPosition = pos;
|
||||
}
|
||||
|
||||
return Collections.unmodifiableList(blockPosCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getAABB(BlockPos pos) {
|
||||
AxisAlignedBB tempAABB = new AxisAlignedBB(minimumOffset, maximumOffset);
|
||||
return tempAABB.offset(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the offsets of the AreaDescriptor in a safe way that will make
|
||||
* minimumOffset the lowest corner
|
||||
*
|
||||
* @param offset1 -
|
||||
* @param offset2 -
|
||||
*/
|
||||
public void setOffsets(BlockPos offset1, BlockPos offset2) {
|
||||
this.minimumOffset = new BlockPos(Math.min(offset1.getX(), offset2.getX()), Math.min(offset1.getY(), offset2.getY()), Math.min(offset1.getZ(), offset2.getZ()));
|
||||
this.maximumOffset = new BlockPos(Math.max(offset1.getX(), offset2.getX()), Math.max(offset1.getY(), offset2.getY()), Math.max(offset1.getZ(), offset2.getZ()));
|
||||
blockPosCache = new ArrayList<BlockPos>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetCache() {
|
||||
this.blockPosCache = new ArrayList<BlockPos>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinArea(BlockPos pos) {
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
return x >= minimumOffset.getX() && x < maximumOffset.getX() && y >= minimumOffset.getY() && y < maximumOffset.getY() && z >= minimumOffset.getZ() && z < maximumOffset.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return currentPosition == null || !(currentPosition.getX() + 1 == maximumOffset.getX() && currentPosition.getY() + 1 == maximumOffset.getY() && currentPosition.getZ() + 1 == maximumOffset.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos next() {
|
||||
if (currentPosition != null) {
|
||||
int nextX = currentPosition.getX() + 1 >= maximumOffset.getX() ? minimumOffset.getX() : currentPosition.getX() + 1;
|
||||
int nextZ = nextX != minimumOffset.getX() ? currentPosition.getZ() : (currentPosition.getZ() + 1 >= maximumOffset.getZ() ? minimumOffset.getZ() : currentPosition.getZ() + 1);
|
||||
int nextY = (nextZ != minimumOffset.getZ() || nextX != minimumOffset.getX()) ? currentPosition.getY() : (currentPosition.getY() + 1);
|
||||
currentPosition = new BlockPos(nextX, nextY, nextZ);
|
||||
} else {
|
||||
currentPosition = minimumOffset;
|
||||
}
|
||||
|
||||
return currentPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetIterator() {
|
||||
currentPosition = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2) {
|
||||
setOffsets(pos1, pos2);
|
||||
maximumOffset = maximumOffset.add(1, 1, 1);
|
||||
resetIterator();
|
||||
resetCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
minimumOffset = new BlockPos(tag.getInteger(Constants.NBT.X_COORD + "min"), tag.getInteger(Constants.NBT.Y_COORD + "min"), tag.getInteger(Constants.NBT.Z_COORD + "min"));
|
||||
maximumOffset = new BlockPos(tag.getInteger(Constants.NBT.X_COORD + "max"), tag.getInteger(Constants.NBT.Y_COORD + "max"), tag.getInteger(Constants.NBT.Z_COORD + "max"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
tag.setInteger(Constants.NBT.X_COORD + "min", minimumOffset.getX());
|
||||
tag.setInteger(Constants.NBT.Y_COORD + "min", minimumOffset.getY());
|
||||
tag.setInteger(Constants.NBT.Z_COORD + "min", minimumOffset.getZ());
|
||||
tag.setInteger(Constants.NBT.X_COORD + "max", maximumOffset.getX());
|
||||
tag.setInteger(Constants.NBT.Y_COORD + "max", maximumOffset.getY());
|
||||
tag.setInteger(Constants.NBT.Z_COORD + "max", maximumOffset.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVolumeForOffsets(BlockPos offset1, BlockPos offset2) {
|
||||
BlockPos minPos = new BlockPos(Math.min(offset1.getX(), offset2.getX()), Math.min(offset1.getY(), offset2.getY()), Math.min(offset1.getZ(), offset2.getZ()));
|
||||
BlockPos maxPos = new BlockPos(Math.max(offset1.getX(), offset2.getX()), Math.max(offset1.getY(), offset2.getY()), Math.max(offset1.getZ(), offset2.getZ()));
|
||||
|
||||
maxPos = maxPos.add(1, 1, 1);
|
||||
|
||||
return (maxPos.getX() - minPos.getX()) * (maxPos.getY() - minPos.getY()) * (maxPos.getZ() - minPos.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit) {
|
||||
BlockPos minPos = new BlockPos(Math.min(offset1.getX(), offset2.getX()), Math.min(offset1.getY(), offset2.getY()), Math.min(offset1.getZ(), offset2.getZ()));
|
||||
BlockPos maxPos = new BlockPos(Math.max(offset1.getX(), offset2.getX()), Math.max(offset1.getY(), offset2.getY()), Math.max(offset1.getZ(), offset2.getZ()));
|
||||
|
||||
return minPos.getY() >= -verticalLimit && maxPos.getY() <= verticalLimit && minPos.getX() >= -horizontalLimit && maxPos.getX() <= horizontalLimit && minPos.getZ() >= -horizontalLimit && maxPos.getZ() <= horizontalLimit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVolume() {
|
||||
return (maximumOffset.getX() - minimumOffset.getX()) * (maximumOffset.getY() - minimumOffset.getY()) * (maximumOffset.getZ() - minimumOffset.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinRange(int verticalLimit, int horizontalLimit) {
|
||||
return minimumOffset.getY() >= -verticalLimit && maximumOffset.getY() <= verticalLimit + 1 && minimumOffset.getX() >= -horizontalLimit && maximumOffset.getX() <= horizontalLimit + 1 && minimumOffset.getZ() >= -horizontalLimit && maximumOffset.getZ() <= horizontalLimit + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean intersects(AreaDescriptor descriptor) {
|
||||
if (descriptor instanceof AreaDescriptor.Rectangle) {
|
||||
AreaDescriptor.Rectangle rectangle = (AreaDescriptor.Rectangle) descriptor;
|
||||
|
||||
return !(minimumOffset.getX() >= rectangle.maximumOffset.getX() || minimumOffset.getY() >= rectangle.maximumOffset.getY() || minimumOffset.getZ() >= rectangle.maximumOffset.getZ() || rectangle.minimumOffset.getX() >= maximumOffset.getX() || rectangle.minimumOffset.getY() >= maximumOffset.getY() || rectangle.minimumOffset.getZ() >= maximumOffset.getZ());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AreaDescriptor offset(BlockPos offset) {
|
||||
return new AreaDescriptor.Rectangle(this.minimumOffset.add(offset), this.maximumOffset.add(offset));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AreaDescriptor rotateDescriptor(PlacementSettings settings) {
|
||||
BlockPos rotatePos1 = Template.transformedBlockPos(settings, minimumOffset);
|
||||
BlockPos rotatePos2 = Template.transformedBlockPos(settings, maximumOffset.add(-1, -1, -1)); //It works, shut up!
|
||||
|
||||
AreaDescriptor.Rectangle rectangle = new AreaDescriptor.Rectangle(this.minimumOffset, 1);
|
||||
rectangle.modifyAreaByBlockPositions(rotatePos1, rotatePos2);
|
||||
|
||||
return rectangle;
|
||||
}
|
||||
}
|
||||
|
||||
public static class HemiSphere extends AreaDescriptor {
|
||||
private BlockPos minimumOffset;
|
||||
private int radius;
|
||||
|
||||
private ArrayList<BlockPos> blockPosCache;
|
||||
private BlockPos cachedPosition;
|
||||
|
||||
private boolean cache = true;
|
||||
|
||||
public HemiSphere(BlockPos minimumOffset, int radius) {
|
||||
setRadius(minimumOffset, radius);
|
||||
}
|
||||
|
||||
public void setRadius(BlockPos minimumOffset, int radius) {
|
||||
this.minimumOffset = new BlockPos(Math.min(minimumOffset.getX(), minimumOffset.getX()), Math.min(minimumOffset.getY(), minimumOffset.getY()), Math.min(minimumOffset.getZ(), minimumOffset.getZ()));
|
||||
this.radius = radius;
|
||||
blockPosCache = new ArrayList<BlockPos>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPos> getContainedPositions(BlockPos pos) {
|
||||
if (!cache || !pos.equals(cachedPosition) || blockPosCache.isEmpty()) {
|
||||
ArrayList<BlockPos> posList = new ArrayList<BlockPos>();
|
||||
|
||||
int i = -radius;
|
||||
int j = minimumOffset.getY();
|
||||
int k = -radius;
|
||||
|
||||
//TODO For some reason the bottom of the hemisphere is not going up with the minOffset
|
||||
|
||||
while (i <= radius) {
|
||||
while (j <= radius) {
|
||||
while (k <= radius) {
|
||||
if (i * i + j * j + k * k >= (radius + 0.5F) * (radius + 0.5F)) {
|
||||
k++;
|
||||
continue;
|
||||
}
|
||||
|
||||
posList.add(pos.add(i, j, k));
|
||||
k++;
|
||||
}
|
||||
|
||||
k = -radius;
|
||||
j++;
|
||||
}
|
||||
|
||||
j = minimumOffset.getY();
|
||||
i++;
|
||||
}
|
||||
|
||||
blockPosCache = posList;
|
||||
cachedPosition = pos;
|
||||
}
|
||||
|
||||
return Collections.unmodifiableList(blockPosCache);
|
||||
}
|
||||
|
||||
/**
|
||||
* Since you can't make a box using a sphere, this returns null
|
||||
*/
|
||||
@Override
|
||||
public AxisAlignedBB getAABB(BlockPos pos) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetCache() {
|
||||
this.blockPosCache = new ArrayList<BlockPos>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinArea(BlockPos pos) {
|
||||
return blockPosCache.contains(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos next() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetIterator() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVolumeForOffsets(BlockPos pos1, BlockPos pos2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVolume() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinRange(int verticalLimit, int horizontalLimit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean intersects(AreaDescriptor descriptor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AreaDescriptor offset(BlockPos offset) {
|
||||
return new AreaDescriptor.HemiSphere(minimumOffset.add(offset), radius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AreaDescriptor rotateDescriptor(PlacementSettings settings) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Cross extends AreaDescriptor {
|
||||
|
||||
private ArrayList<BlockPos> blockPosCache;
|
||||
private BlockPos cachedPosition;
|
||||
|
||||
private BlockPos centerPos;
|
||||
private int size;
|
||||
|
||||
private boolean cache = true;
|
||||
|
||||
public Cross(BlockPos center, int size) {
|
||||
this.centerPos = center;
|
||||
this.size = size;
|
||||
this.blockPosCache = new ArrayList<BlockPos>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPos> getContainedPositions(BlockPos pos) {
|
||||
if (!cache || !pos.equals(cachedPosition) || blockPosCache.isEmpty()) {
|
||||
resetCache();
|
||||
|
||||
blockPosCache.add(centerPos.add(pos));
|
||||
for (int i = 1; i <= size; i++) {
|
||||
blockPosCache.add(centerPos.add(pos).add(i, 0, 0));
|
||||
blockPosCache.add(centerPos.add(pos).add(0, 0, i));
|
||||
blockPosCache.add(centerPos.add(pos).add(-i, 0, 0));
|
||||
blockPosCache.add(centerPos.add(pos).add(0, 0, -i));
|
||||
}
|
||||
}
|
||||
|
||||
cachedPosition = pos;
|
||||
|
||||
return Collections.unmodifiableList(blockPosCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetCache() {
|
||||
blockPosCache = new ArrayList<BlockPos>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinArea(BlockPos pos) {
|
||||
return blockPosCache.contains(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos next() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetIterator() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVolumeForOffsets(BlockPos pos1, BlockPos pos2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVolume() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinRange(int verticalLimit, int horizontalLimit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean intersects(AreaDescriptor descriptor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AreaDescriptor offset(BlockPos offset) {
|
||||
return new AreaDescriptor.Cross(centerPos.add(offset), size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AreaDescriptor rotateDescriptor(PlacementSettings settings) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.ritual;
|
||||
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagByte;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public final class CapabilityRuneType {
|
||||
public static class RuneTypeStorage implements Capability.IStorage<IRitualStone.Tile> {
|
||||
@Override
|
||||
public NBTBase writeNBT(Capability<IRitualStone.Tile> capability, IRitualStone.Tile instance, EnumFacing side) {
|
||||
return new NBTTagByte((byte) instance.getRuneType().ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(Capability<IRitualStone.Tile> capability, IRitualStone.Tile instance, EnumFacing side, NBTBase nbt) {
|
||||
instance.setRuneType(EnumRuneType.byMetadata(((NBTTagByte) nbt).getByte()));
|
||||
}
|
||||
}
|
||||
|
||||
public static class RuneTypeWrapper implements IRitualStone.Tile {
|
||||
private EnumRuneType type = EnumRuneType.BLANK;
|
||||
|
||||
@Override
|
||||
public boolean isRuneType(EnumRuneType runeType) {
|
||||
return type == runeType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRuneType getRuneType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setRuneType(EnumRuneType runeType) {
|
||||
type = runeType;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Factory implements Callable<IRitualStone.Tile> {
|
||||
@Override
|
||||
public IRitualStone.Tile call() throws Exception {
|
||||
return new RuneTypeWrapper();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.ritual;
|
||||
|
||||
public enum EnumRitualReaderState {
|
||||
SET_AREA,
|
||||
INFORMATION,
|
||||
SET_WILL_TYPES;
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.ritual;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumRuneType implements IStringSerializable {
|
||||
BLANK(TextFormatting.GRAY),
|
||||
WATER(TextFormatting.AQUA),
|
||||
FIRE(TextFormatting.RED),
|
||||
EARTH(TextFormatting.GREEN),
|
||||
AIR(TextFormatting.WHITE),
|
||||
DUSK(TextFormatting.DARK_GRAY),
|
||||
DAWN(TextFormatting.GOLD);
|
||||
|
||||
@GameRegistry.ObjectHolder("bloodmagic:inscription_tool")
|
||||
public static final Item INSCRIPTION_TOOL = Items.AIR;
|
||||
|
||||
public final TextFormatting colorCode;
|
||||
|
||||
EnumRuneType(TextFormatting colorCode) {
|
||||
this.colorCode = colorCode;
|
||||
}
|
||||
|
||||
public ItemStack getScribeStack() {
|
||||
return new ItemStack(INSCRIPTION_TOOL, 1, ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.toString();
|
||||
}
|
||||
|
||||
public static EnumRuneType byMetadata(int meta) {
|
||||
if (meta < 0 || meta >= values().length)
|
||||
meta = 0;
|
||||
|
||||
return values()[meta];
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.ritual;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.saving.SoulNetwork;
|
||||
import WayofTime.bloodmagic.apibutnotreally.soul.EnumDemonWillType;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This interface is for internal implementation only.
|
||||
* <p>
|
||||
* It is provided via the API for easy obtaining of basic data.
|
||||
*/
|
||||
public interface IMasterRitualStone {
|
||||
String getOwner();
|
||||
|
||||
SoulNetwork getOwnerNetwork();
|
||||
|
||||
boolean activateRitual(ItemStack activationCrystal, EntityPlayer activator, Ritual ritual);
|
||||
|
||||
void performRitual(World world, BlockPos pos);
|
||||
|
||||
void stopRitual(Ritual.BreakType breakType);
|
||||
|
||||
int getCooldown();
|
||||
|
||||
void setCooldown(int cooldown);
|
||||
|
||||
void setActive(boolean active);
|
||||
|
||||
EnumFacing getDirection();
|
||||
|
||||
boolean areTanksEmpty();
|
||||
|
||||
int getRunningTime();
|
||||
|
||||
World getWorldObj();
|
||||
|
||||
BlockPos getBlockPos();
|
||||
|
||||
String getNextBlockRange(String range);
|
||||
|
||||
void provideInformationOfRitualToPlayer(EntityPlayer player);
|
||||
|
||||
void provideInformationOfRangeToPlayer(EntityPlayer player, String range);
|
||||
|
||||
void provideInformationOfWillConfigToPlayer(EntityPlayer player, List<EnumDemonWillType> typeList);
|
||||
|
||||
void setActiveWillConfig(EntityPlayer player, List<EnumDemonWillType> typeList);
|
||||
|
||||
boolean setBlockRangeByBounds(EntityPlayer player, String range, BlockPos offset1, BlockPos offset2);
|
||||
|
||||
List<EnumDemonWillType> getActiveWillConfig();
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.ritual;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* This interface is for internal implementation only.
|
||||
* <p>
|
||||
* It is provided via the API for easy obtaining of basic data.
|
||||
*/
|
||||
public interface IRitualStone {
|
||||
boolean isRuneType(World world, BlockPos pos, EnumRuneType runeType);
|
||||
|
||||
void setRuneType(World world, BlockPos pos, EnumRuneType runeType);
|
||||
|
||||
interface Tile {
|
||||
boolean isRuneType(EnumRuneType runeType);
|
||||
|
||||
EnumRuneType getRuneType();
|
||||
|
||||
void setRuneType(EnumRuneType runeType);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,395 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.ritual;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.soul.DemonWillHolder;
|
||||
import WayofTime.bloodmagic.apibutnotreally.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* Abstract class for creating new rituals. Rituals need be registered with
|
||||
* {@link WayofTime.bloodmagic.apibutnotreally.registry.RitualRegistry#registerRitual(Ritual, String)}
|
||||
*/
|
||||
public abstract class Ritual {
|
||||
public final ArrayList<RitualComponent> ritualComponents = new ArrayList<RitualComponent>();
|
||||
protected final Map<String, AreaDescriptor> modableRangeMap = new HashMap<String, AreaDescriptor>();
|
||||
protected final Map<String, Integer> volumeRangeMap = new HashMap<String, Integer>();
|
||||
protected final Map<String, Integer> horizontalRangeMap = new HashMap<String, Integer>();
|
||||
protected final Map<String, Integer> verticalRangeMap = new HashMap<String, Integer>();
|
||||
private final String name;
|
||||
private final int crystalLevel;
|
||||
private final int activationCost;
|
||||
private final RitualRenderer renderer;
|
||||
private final String unlocalizedName;
|
||||
|
||||
public Ritual(String name, int crystalLevel, int activationCost, RitualRenderer renderer, String unlocalizedName) {
|
||||
this.name = name;
|
||||
this.crystalLevel = crystalLevel;
|
||||
this.activationCost = activationCost;
|
||||
this.renderer = renderer;
|
||||
this.unlocalizedName = unlocalizedName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name - The name of the ritual
|
||||
* @param crystalLevel - Required Activation Crystal tier
|
||||
* @param activationCost - Base LP cost for activating the ritual
|
||||
*/
|
||||
public Ritual(String name, int crystalLevel, int activationCost, String unlocalizedName) {
|
||||
this(name, crystalLevel, activationCost, null, unlocalizedName);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
NBTTagList tags = tag.getTagList("areas", 10);
|
||||
if (tags.hasNoTags()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < tags.tagCount(); i++) {
|
||||
NBTTagCompound newTag = tags.getCompoundTagAt(i);
|
||||
String rangeKey = newTag.getString("key");
|
||||
|
||||
NBTTagCompound storedTag = newTag.getCompoundTag("area");
|
||||
AreaDescriptor desc = this.getBlockRange(rangeKey);
|
||||
if (desc != null) {
|
||||
desc.readFromNBT(storedTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
NBTTagList tags = new NBTTagList();
|
||||
|
||||
for (Entry<String, AreaDescriptor> entry : modableRangeMap.entrySet()) {
|
||||
NBTTagCompound newTag = new NBTTagCompound();
|
||||
newTag.setString("key", entry.getKey());
|
||||
NBTTagCompound storedTag = new NBTTagCompound();
|
||||
|
||||
entry.getValue().writeToNBT(storedTag);
|
||||
|
||||
newTag.setTag("area", storedTag);
|
||||
|
||||
tags.appendTag(newTag);
|
||||
}
|
||||
|
||||
tag.setTag("areas", tags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the player attempts to activate the ritual.
|
||||
* <p>
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#activateRitual(ItemStack, EntityPlayer, Ritual)}
|
||||
*
|
||||
* @param masterRitualStone - The {@link IMasterRitualStone} that the ritual is bound to
|
||||
* @param player - The activating player
|
||||
* @param owner - Owner of the crystal activating this ritual, or the current
|
||||
* owner of the ritual if being reactivated.
|
||||
* @return - Whether activation was successful
|
||||
*/
|
||||
public boolean activateRitual(IMasterRitualStone masterRitualStone, EntityPlayer player, String owner) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called every {@link #getRefreshTime()} ticks while active.
|
||||
* <p>
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#performRitual(World, BlockPos)}
|
||||
*
|
||||
* @param masterRitualStone - The {@link IMasterRitualStone} that the ritual is bound to
|
||||
*/
|
||||
public abstract void performRitual(IMasterRitualStone masterRitualStone);
|
||||
|
||||
/**
|
||||
* Called when the ritual is stopped for a given {@link Ritual.BreakType}.
|
||||
* <p>
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(Ritual.BreakType)}
|
||||
*
|
||||
* @param masterRitualStone - The {@link IMasterRitualStone} that the ritual is bound to
|
||||
* @param breakType - The type of break that caused the stoppage.
|
||||
*/
|
||||
public void stopRitual(IMasterRitualStone masterRitualStone, BreakType breakType) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to set the amount of LP drained every {@link #getRefreshTime()}
|
||||
* ticks.
|
||||
*
|
||||
* @return - The amount of LP drained per refresh
|
||||
*/
|
||||
public abstract int getRefreshCost();
|
||||
|
||||
/**
|
||||
* Used to set the refresh rate of the ritual. (How often
|
||||
* {@link #performRitual(IMasterRitualStone)} is called.
|
||||
*
|
||||
* @return - How often to perform the effect in ticks.
|
||||
*/
|
||||
public int getRefreshTime() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
public void addBlockRange(String range, AreaDescriptor defaultRange) {
|
||||
modableRangeMap.put(range, defaultRange);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to grab the range of a ritual for a given effect.
|
||||
*
|
||||
* @param range - Range that needs to be pulled.
|
||||
* @return -
|
||||
*/
|
||||
public AreaDescriptor getBlockRange(String range) {
|
||||
if (modableRangeMap.containsKey(range)) {
|
||||
return modableRangeMap.get(range);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<String> getListOfRanges() {
|
||||
return new ArrayList<String>(modableRangeMap.keySet());
|
||||
}
|
||||
|
||||
public String getNextBlockRange(String range) {
|
||||
List<String> rangeList = getListOfRanges();
|
||||
|
||||
if (rangeList.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (!rangeList.contains(range)) {
|
||||
return rangeList.get(0);
|
||||
}
|
||||
|
||||
boolean hasMatch = false;
|
||||
|
||||
for (String rangeCheck : rangeList) {
|
||||
if (hasMatch) {
|
||||
return rangeCheck;
|
||||
} else if (rangeCheck.equals(range)) {
|
||||
hasMatch = true;
|
||||
}
|
||||
}
|
||||
|
||||
return rangeList.get(0);
|
||||
}
|
||||
|
||||
public boolean setBlockRangeByBounds(String range, IMasterRitualStone master, BlockPos offset1, BlockPos offset2) {
|
||||
AreaDescriptor descriptor = this.getBlockRange(range);
|
||||
World world = master.getWorldObj();
|
||||
BlockPos masterPos = master.getBlockPos();
|
||||
DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(world, masterPos);
|
||||
if (canBlockRangeBeModified(range, descriptor, master, offset1, offset2, holder)) {
|
||||
descriptor.modifyAreaByBlockPositions(offset1, offset2);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean canBlockRangeBeModified(String range, AreaDescriptor descriptor, IMasterRitualStone master, BlockPos offset1, BlockPos offset2, DemonWillHolder holder) {
|
||||
List<EnumDemonWillType> willConfig = master.getActiveWillConfig();
|
||||
int maxVolume = getMaxVolumeForRange(range, willConfig, holder);
|
||||
int maxVertical = getMaxVerticalRadiusForRange(range, willConfig, holder);
|
||||
int maxHorizontal = getMaxHorizontalRadiusForRange(range, willConfig, holder);
|
||||
|
||||
return (maxVolume <= 0 || descriptor.getVolumeForOffsets(offset1, offset2) <= maxVolume) && descriptor.isWithinRange(offset1, offset2, maxVertical, maxHorizontal);
|
||||
}
|
||||
|
||||
protected void setMaximumVolumeAndDistanceOfRange(String range, int volume, int horizontalRadius, int verticalRadius) {
|
||||
volumeRangeMap.put(range, volume);
|
||||
horizontalRangeMap.put(range, horizontalRadius);
|
||||
verticalRangeMap.put(range, verticalRadius);
|
||||
}
|
||||
|
||||
protected boolean checkDescriptorIsWithinRange(AreaDescriptor descriptor, int maxVolume, int maxHorizontal, int maxVertical) {
|
||||
return descriptor.getVolume() <= maxVolume && descriptor.isWithinRange(maxVertical, maxHorizontal);
|
||||
}
|
||||
|
||||
public int getMaxVolumeForRange(String range, List<EnumDemonWillType> activeTypes, DemonWillHolder holder) {
|
||||
return volumeRangeMap.get(range);
|
||||
}
|
||||
|
||||
public int getMaxVerticalRadiusForRange(String range, List<EnumDemonWillType> activeTypes, DemonWillHolder holder) {
|
||||
return verticalRangeMap.get(range);
|
||||
}
|
||||
|
||||
public int getMaxHorizontalRadiusForRange(String range, List<EnumDemonWillType> activeTypes, DemonWillHolder holder) {
|
||||
return horizontalRangeMap.get(range);
|
||||
}
|
||||
|
||||
public ITextComponent getErrorForBlockRangeOnFail(EntityPlayer player, String range, IMasterRitualStone master, BlockPos offset1, BlockPos offset2) {
|
||||
AreaDescriptor descriptor = this.getBlockRange(range);
|
||||
if (descriptor == null) {
|
||||
return new TextComponentTranslation("ritual.bloodmagic.blockRange.tooBig", "?");
|
||||
}
|
||||
|
||||
List<EnumDemonWillType> willConfig = master.getActiveWillConfig();
|
||||
DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(master.getWorldObj(), master.getBlockPos());
|
||||
|
||||
int maxVolume = this.getMaxVolumeForRange(range, willConfig, holder);
|
||||
int maxVertical = this.getMaxVerticalRadiusForRange(range, willConfig, holder);
|
||||
int maxHorizontal = this.getMaxHorizontalRadiusForRange(range, willConfig, holder);
|
||||
|
||||
if (maxVolume > 0 && descriptor.getVolumeForOffsets(offset1, offset2) > maxVolume) {
|
||||
return new TextComponentTranslation("ritual.bloodmagic.blockRange.tooBig", maxVolume);
|
||||
} else {
|
||||
return new TextComponentTranslation("ritual.bloodmagic.blockRange.tooFar", maxVertical, maxHorizontal);
|
||||
}
|
||||
}
|
||||
|
||||
public ITextComponent[] provideInformationOfRitualToPlayer(EntityPlayer player) {
|
||||
return new ITextComponent[]{new TextComponentTranslation(this.getUnlocalizedName() + ".info")};
|
||||
}
|
||||
|
||||
public ITextComponent provideInformationOfRangeToPlayer(EntityPlayer player, String range) {
|
||||
if (getListOfRanges().contains(range)) {
|
||||
return new TextComponentTranslation(this.getUnlocalizedName() + "." + range + ".info");
|
||||
} else {
|
||||
return new TextComponentTranslation("ritual.bloodmagic.blockRange.noRange");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list of {@link RitualComponent} for checking the ritual.
|
||||
*/
|
||||
public abstract ArrayList<RitualComponent> getComponents();
|
||||
|
||||
public void addRune(ArrayList<RitualComponent> components, int offset1, int y, int offset2, EnumRuneType rune) {
|
||||
components.add(new RitualComponent(new BlockPos(offset1, y, offset2), rune));
|
||||
}
|
||||
|
||||
public void addOffsetRunes(ArrayList<RitualComponent> components, int offset1, int offset2, int y, EnumRuneType rune) {
|
||||
addRune(components, offset1, y, offset2, rune);
|
||||
addRune(components, offset2, y, offset1, rune);
|
||||
addRune(components, offset1, y, -offset2, rune);
|
||||
addRune(components, -offset2, y, offset1, rune);
|
||||
addRune(components, -offset1, y, offset2, rune);
|
||||
addRune(components, offset2, y, -offset1, rune);
|
||||
addRune(components, -offset1, y, -offset2, rune);
|
||||
addRune(components, -offset2, y, -offset1, rune);
|
||||
}
|
||||
|
||||
public void addCornerRunes(ArrayList<RitualComponent> components, int offset, int y, EnumRuneType rune) {
|
||||
addRune(components, offset, y, offset, rune);
|
||||
addRune(components, offset, y, -offset, rune);
|
||||
addRune(components, -offset, y, -offset, rune);
|
||||
addRune(components, -offset, y, offset, rune);
|
||||
}
|
||||
|
||||
public void addParallelRunes(ArrayList<RitualComponent> components, int offset, int y, EnumRuneType rune) {
|
||||
addRune(components, offset, y, 0, rune);
|
||||
addRune(components, -offset, y, 0, rune);
|
||||
addRune(components, 0, y, -offset, rune);
|
||||
addRune(components, 0, y, offset, rune);
|
||||
}
|
||||
|
||||
public double getWillRespectingConfig(World world, BlockPos pos, EnumDemonWillType type, List<EnumDemonWillType> willConfig) {
|
||||
return willConfig.contains(type) ? WorldDemonWillHandler.getCurrentWill(world, pos, type) : 0;
|
||||
}
|
||||
|
||||
public abstract Ritual getNewCopy();
|
||||
|
||||
public ArrayList<RitualComponent> getRitualComponents() {
|
||||
return ritualComponents;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getCrystalLevel() {
|
||||
return crystalLevel;
|
||||
}
|
||||
|
||||
public int getActivationCost() {
|
||||
return activationCost;
|
||||
}
|
||||
|
||||
public RitualRenderer getRenderer() {
|
||||
return renderer;
|
||||
}
|
||||
|
||||
public String getUnlocalizedName() {
|
||||
return unlocalizedName;
|
||||
}
|
||||
|
||||
public Map<String, AreaDescriptor> getModableRangeMap() {
|
||||
return modableRangeMap;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getVolumeRangeMap() {
|
||||
return volumeRangeMap;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getHorizontalRangeMap() {
|
||||
return horizontalRangeMap;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getVerticalRangeMap() {
|
||||
return verticalRangeMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this)
|
||||
.append("ritualComponents", ritualComponents)
|
||||
.append("name", name)
|
||||
.append("crystalLevel", crystalLevel)
|
||||
.append("activationCost", activationCost)
|
||||
.append("renderer", renderer)
|
||||
.append("unlocalizedName", unlocalizedName)
|
||||
.append("modableRangeMap", modableRangeMap)
|
||||
.append("volumeRangeMap", volumeRangeMap)
|
||||
.append("horizontalRangeMap", horizontalRangeMap)
|
||||
.append("verticalRangeMap", verticalRangeMap)
|
||||
.append("refreshTime", getRefreshTime())
|
||||
.append("listOfRanges", getListOfRanges())
|
||||
.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Ritual)) return false;
|
||||
|
||||
Ritual ritual = (Ritual) o;
|
||||
|
||||
if (crystalLevel != ritual.crystalLevel) return false;
|
||||
if (activationCost != ritual.activationCost) return false;
|
||||
if (name != null ? !name.equals(ritual.name) : ritual.name != null) return false;
|
||||
return unlocalizedName != null ? unlocalizedName.equals(ritual.unlocalizedName) : ritual.unlocalizedName == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = name != null ? name.hashCode() : 0;
|
||||
result = 31 * result + crystalLevel;
|
||||
result = 31 * result + activationCost;
|
||||
result = 31 * result + (unlocalizedName != null ? unlocalizedName.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
public enum BreakType {
|
||||
REDSTONE,
|
||||
BREAK_MRS,
|
||||
BREAK_STONE,
|
||||
ACTIVATE,
|
||||
DEACTIVATE,
|
||||
EXPLOSION,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.ritual;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
* Used to set a {@link EnumRuneType} type to a given {@link BlockPos} for usage
|
||||
* in Ritual creation.
|
||||
*/
|
||||
public class RitualComponent {
|
||||
private final BlockPos offset;
|
||||
private final EnumRuneType runeType;
|
||||
|
||||
public RitualComponent(BlockPos offset, EnumRuneType runeType) {
|
||||
this.offset = offset;
|
||||
this.runeType = runeType;
|
||||
}
|
||||
|
||||
public int getX(EnumFacing direction) {
|
||||
switch (direction) {
|
||||
case EAST:
|
||||
return -this.getOffset().getZ();
|
||||
case SOUTH:
|
||||
return -this.getOffset().getX();
|
||||
case WEST:
|
||||
return this.getOffset().getZ();
|
||||
default:
|
||||
return this.getOffset().getX();
|
||||
}
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return this.getOffset().getY();
|
||||
}
|
||||
|
||||
public int getZ(EnumFacing direction) {
|
||||
switch (direction) {
|
||||
case EAST:
|
||||
return this.getOffset().getX();
|
||||
case SOUTH:
|
||||
return -this.getOffset().getZ();
|
||||
case WEST:
|
||||
return -this.getOffset().getX();
|
||||
default:
|
||||
return this.getOffset().getZ();
|
||||
}
|
||||
}
|
||||
|
||||
public BlockPos getOffset(EnumFacing direction) {
|
||||
return new BlockPos(getX(direction), offset.getY(), getZ(direction));
|
||||
}
|
||||
|
||||
public BlockPos getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public EnumRuneType getRuneType() {
|
||||
return runeType;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.ritual;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public abstract class RitualRenderer {
|
||||
public abstract void renderAt(IMasterRitualStone masterRitualStone, double x, double y, double z);
|
||||
|
||||
protected void bindTexture(ResourceLocation resourceLocation) {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.ritual.imperfect;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* This interface is for internal implementation only.
|
||||
* <p>
|
||||
* It is provided via the API for easy obtaining of basic data.
|
||||
*/
|
||||
public interface IImperfectRitualStone {
|
||||
|
||||
boolean performRitual(World world, BlockPos pos, ImperfectRitual imperfectRitual, EntityPlayer player);
|
||||
|
||||
World getRitualWorld();
|
||||
|
||||
BlockPos getRitualPos();
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.ritual.imperfect;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.BlockStack;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Abstract class for creating new imperfect rituals. ImperfectRituals need be
|
||||
* registered with
|
||||
* {@link WayofTime.bloodmagic.apibutnotreally.registry.ImperfectRitualRegistry#registerRitual(ImperfectRitual)}
|
||||
*/
|
||||
public abstract class ImperfectRitual {
|
||||
|
||||
private final String name;
|
||||
private final BlockStack requiredBlock;
|
||||
private final int activationCost;
|
||||
private final boolean lightshow;
|
||||
private final String unlocalizedName;
|
||||
|
||||
public ImperfectRitual(String name, BlockStack requiredBlock, int activationCost, boolean lightshow, String unlocalizedName) {
|
||||
this.name = name;
|
||||
this.requiredBlock = requiredBlock;
|
||||
this.activationCost = activationCost;
|
||||
this.lightshow = lightshow;
|
||||
this.unlocalizedName = unlocalizedName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name - The name of the ritual
|
||||
* @param requiredBlock - The block required above the ImperfectRitualStone
|
||||
* @param activationCost - Base LP cost for activating the ritual
|
||||
*/
|
||||
public ImperfectRitual(String name, BlockStack requiredBlock, int activationCost, String unlocalizedName) {
|
||||
this(name, requiredBlock, activationCost, false, unlocalizedName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the player activates the ritual
|
||||
* {@link WayofTime.bloodmagic.tile.TileImperfectRitualStone#performRitual(World, net.minecraft.util.math.BlockPos, ImperfectRitual, EntityPlayer)}
|
||||
*
|
||||
* @param imperfectRitualStone - The {@link IImperfectRitualStone} that the ritual is bound to
|
||||
* @param player - The player activating the ritual
|
||||
* @return - Whether activation was successful
|
||||
*/
|
||||
public abstract boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player);
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public BlockStack getRequiredBlock() {
|
||||
return requiredBlock;
|
||||
}
|
||||
|
||||
public int getActivationCost() {
|
||||
return activationCost;
|
||||
}
|
||||
|
||||
public boolean isLightshow() {
|
||||
return lightshow;
|
||||
}
|
||||
|
||||
public String getUnlocalizedName() {
|
||||
return unlocalizedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName() + ":" + getRequiredBlock().toString() + "@" + getActivationCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof ImperfectRitual)) return false;
|
||||
|
||||
ImperfectRitual that = (ImperfectRitual) o;
|
||||
|
||||
if (activationCost != that.activationCost) return false;
|
||||
if (lightshow != that.lightshow) return false;
|
||||
if (name != null ? !name.equals(that.name) : that.name != null) return false;
|
||||
if (requiredBlock != null ? !requiredBlock.equals(that.requiredBlock) : that.requiredBlock != null)
|
||||
return false;
|
||||
return unlocalizedName != null ? unlocalizedName.equals(that.unlocalizedName) : that.unlocalizedName == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = name != null ? name.hashCode() : 0;
|
||||
result = 31 * result + (requiredBlock != null ? requiredBlock.hashCode() : 0);
|
||||
result = 31 * result + activationCost;
|
||||
result = 31 * result + (lightshow ? 1 : 0);
|
||||
result = 31 * result + (unlocalizedName != null ? unlocalizedName.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package WayofTime.bloodmagic.apibutnotreally.ritual.imperfect;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
|
@ -0,0 +1,58 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.saving;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.util.helper.PlayerHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.storage.WorldSavedData;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BMWorldSavedData extends WorldSavedData {
|
||||
public static final String ID = "BloodMagic-SoulNetworks";
|
||||
|
||||
private Map<UUID, SoulNetwork> soulNetworks = new HashMap<UUID, SoulNetwork>();
|
||||
|
||||
public BMWorldSavedData(String id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public BMWorldSavedData() {
|
||||
this(ID);
|
||||
}
|
||||
|
||||
public SoulNetwork getNetwork(EntityPlayer player) {
|
||||
return getNetwork(PlayerHelper.getUUIDFromPlayer(player));
|
||||
}
|
||||
|
||||
public SoulNetwork getNetwork(UUID playerId) {
|
||||
if (!soulNetworks.containsKey(playerId))
|
||||
soulNetworks.put(playerId, SoulNetwork.newEmpty(playerId).setParent(this));
|
||||
return soulNetworks.get(playerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
NBTTagList networkData = tagCompound.getTagList("networkData", 10);
|
||||
|
||||
for (int i = 0; i < networkData.tagCount(); i++) {
|
||||
NBTTagCompound data = networkData.getCompoundTagAt(i);
|
||||
SoulNetwork network = SoulNetwork.fromNBT(data);
|
||||
network.setParent(this);
|
||||
soulNetworks.put(network.getPlayerId(), network);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
NBTTagList networkData = new NBTTagList();
|
||||
for (SoulNetwork soulNetwork : soulNetworks.values())
|
||||
networkData.appendTag(soulNetwork.serializeNBT());
|
||||
|
||||
tagCompound.setTag("networkData", networkData);
|
||||
|
||||
return tagCompound;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,211 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.saving;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.BloodMagicAPI;
|
||||
import WayofTime.bloodmagic.apibutnotreally.event.AddToNetworkEvent;
|
||||
import WayofTime.bloodmagic.apibutnotreally.event.SoulNetworkEvent;
|
||||
import WayofTime.bloodmagic.apibutnotreally.util.helper.PlayerHelper;
|
||||
import com.google.common.base.Strings;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.INBTSerializable;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SoulNetwork implements INBTSerializable<NBTTagCompound> {
|
||||
private BMWorldSavedData parent;
|
||||
private EntityPlayer cachedPlayer;
|
||||
private UUID playerId;
|
||||
private int currentEssence;
|
||||
private int orbTier;
|
||||
|
||||
private SoulNetwork() {
|
||||
// No-op - For creation via NBT only
|
||||
}
|
||||
|
||||
public int add(int toAdd, int maximum) {
|
||||
AddToNetworkEvent event = new AddToNetworkEvent(playerId.toString(), toAdd, maximum);
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
return 0;
|
||||
|
||||
if (FMLCommonHandler.instance().getMinecraftServerInstance() == null)
|
||||
return 0;
|
||||
|
||||
int currEss = getCurrentEssence();
|
||||
|
||||
if (currEss >= event.maximum)
|
||||
return 0;
|
||||
|
||||
int newEss = Math.min(event.maximum, currEss + event.addedAmount);
|
||||
if (event.getResult() != Event.Result.DENY)
|
||||
setCurrentEssence(newEss);
|
||||
|
||||
return newEss - currEss;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated - Please use {@link #add(int, int)}
|
||||
*/
|
||||
@Deprecated
|
||||
public int addLifeEssence(int toAdd, int maximum) {
|
||||
return add(toAdd, maximum);
|
||||
}
|
||||
|
||||
public int syphon(int syphon) {
|
||||
if (getCurrentEssence() >= syphon) {
|
||||
setCurrentEssence(getCurrentEssence() - syphon);
|
||||
return syphon;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean syphonAndDamage(EntityPlayer user, int toSyphon) {
|
||||
if (user != null) {
|
||||
if (user.getEntityWorld().isRemote)
|
||||
return false;
|
||||
|
||||
if (!Strings.isNullOrEmpty(playerId.toString())) {
|
||||
SoulNetworkEvent.ItemDrainNetworkEvent event = new SoulNetworkEvent.ItemDrainNetworkEvent(user, playerId.toString(), null, toSyphon);
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
return false;
|
||||
|
||||
int drainAmount = syphon(event.syphon);
|
||||
|
||||
if (drainAmount <= 0 || event.shouldDamage)
|
||||
hurtPlayer(user, event.syphon);
|
||||
|
||||
return event.getResult() != Event.Result.DENY;
|
||||
}
|
||||
|
||||
int amount = syphon(toSyphon);
|
||||
hurtPlayer(user, toSyphon - amount);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void causeNausea() {
|
||||
if (getPlayer() != null)
|
||||
getPlayer().addPotionEffect(new PotionEffect(MobEffects.NAUSEA, 99));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated - Please use {@link #causeNausea()}
|
||||
*/
|
||||
@Deprecated
|
||||
public void causeNauseaToPlayer() {
|
||||
causeNausea();
|
||||
}
|
||||
|
||||
public void hurtPlayer(EntityPlayer user, float syphon) {
|
||||
if (user != null) {
|
||||
if (syphon < 100 && syphon > 0) {
|
||||
if (!user.capabilities.isCreativeMode) {
|
||||
user.hurtResistantTime = 0;
|
||||
user.attackEntityFrom(BloodMagicAPI.damageSource, 1.0F);
|
||||
}
|
||||
|
||||
} else if (syphon >= 100) {
|
||||
if (!user.capabilities.isCreativeMode) {
|
||||
for (int i = 0; i < ((syphon + 99) / 100); i++) {
|
||||
user.hurtResistantTime = 0;
|
||||
user.attackEntityFrom(BloodMagicAPI.damageSource, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void markDirty() {
|
||||
if (getParent() != null)
|
||||
getParent().markDirty();
|
||||
else
|
||||
BloodMagicAPI.logger.error("A SoulNetwork was created, but a parent was not set to allow saving.");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EntityPlayer getPlayer() {
|
||||
if (cachedPlayer == null)
|
||||
cachedPlayer = PlayerHelper.getPlayerFromUUID(playerId);
|
||||
|
||||
return cachedPlayer;
|
||||
}
|
||||
|
||||
public BMWorldSavedData getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public SoulNetwork setParent(BMWorldSavedData parent) {
|
||||
this.parent = parent;
|
||||
markDirty();
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityPlayer getCachedPlayer() {
|
||||
return cachedPlayer;
|
||||
}
|
||||
|
||||
public UUID getPlayerId() {
|
||||
return playerId;
|
||||
}
|
||||
|
||||
public int getCurrentEssence() {
|
||||
return currentEssence;
|
||||
}
|
||||
|
||||
public SoulNetwork setCurrentEssence(int currentEssence) {
|
||||
this.currentEssence = currentEssence;
|
||||
markDirty();
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getOrbTier() {
|
||||
return orbTier;
|
||||
}
|
||||
|
||||
public SoulNetwork setOrbTier(int orbTier) {
|
||||
this.orbTier = orbTier;
|
||||
markDirty();
|
||||
return this;
|
||||
}
|
||||
|
||||
// INBTSerializable
|
||||
|
||||
@Override
|
||||
public NBTTagCompound serializeNBT() {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setString("playerId", getPlayerId().toString());
|
||||
tagCompound.setInteger("currentEssence", getCurrentEssence());
|
||||
tagCompound.setInteger("orbTier", getOrbTier());
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(NBTTagCompound nbt) {
|
||||
this.playerId = UUID.fromString(nbt.getString("playerId"));
|
||||
this.currentEssence = nbt.getInteger("currentEssence");
|
||||
this.orbTier = nbt.getInteger("orbTier");
|
||||
}
|
||||
|
||||
public static SoulNetwork fromNBT(NBTTagCompound tagCompound) {
|
||||
SoulNetwork soulNetwork = new SoulNetwork();
|
||||
soulNetwork.deserializeNBT(tagCompound);
|
||||
return soulNetwork;
|
||||
}
|
||||
|
||||
public static SoulNetwork newEmpty(UUID uuid) {
|
||||
SoulNetwork network = new SoulNetwork();
|
||||
network.playerId = uuid;
|
||||
return network;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.soul;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class DemonWillHolder {
|
||||
public HashMap<EnumDemonWillType, Double> willMap = new HashMap<EnumDemonWillType, Double>();
|
||||
|
||||
public double addWill(EnumDemonWillType type, double amount, double max) {
|
||||
double current = 0;
|
||||
if (willMap.containsKey(type)) {
|
||||
current = willMap.get(type);
|
||||
}
|
||||
|
||||
double added = Math.min(max - current, amount);
|
||||
addWill(type, amount);
|
||||
|
||||
return added;
|
||||
}
|
||||
|
||||
public void addWill(EnumDemonWillType type, double amount) {
|
||||
if (willMap.containsKey(type)) {
|
||||
willMap.put(type, amount + willMap.get(type));
|
||||
} else {
|
||||
willMap.put(type, amount);
|
||||
}
|
||||
}
|
||||
|
||||
public double drainWill(EnumDemonWillType type, double amount) {
|
||||
if (willMap.containsKey(type)) {
|
||||
double current = willMap.get(type);
|
||||
double reduced = Math.min(current, amount);
|
||||
|
||||
if (reduced >= current) {
|
||||
willMap.remove(type);
|
||||
} else {
|
||||
willMap.put(type, current - reduced);
|
||||
}
|
||||
|
||||
return reduced;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double getWill(EnumDemonWillType type) {
|
||||
if (willMap.containsKey(type)) {
|
||||
return willMap.get(type);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound tag, String key) {
|
||||
NBTTagCompound willTag = tag.getCompoundTag(key);
|
||||
|
||||
willMap.clear();
|
||||
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values()) {
|
||||
double amount = willTag.getDouble("EnumWill" + type.getName());
|
||||
if (amount > 0) {
|
||||
willMap.put(type, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound tag, String key) {
|
||||
NBTTagCompound willTag = new NBTTagCompound();
|
||||
for (Entry<EnumDemonWillType, Double> entry : willMap.entrySet()) {
|
||||
willTag.setDouble("EnumWill" + entry.getKey().getName(), entry.getValue());
|
||||
}
|
||||
|
||||
tag.setTag(key, willTag);
|
||||
}
|
||||
|
||||
public void clearWill() {
|
||||
willMap.clear();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.soul;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumDemonWillType implements IStringSerializable {
|
||||
DEFAULT("default"),
|
||||
CORROSIVE("corrosive"),
|
||||
DESTRUCTIVE("destructive"),
|
||||
VENGEFUL("vengeful"),
|
||||
STEADFAST("steadfast");
|
||||
|
||||
public final String name;
|
||||
|
||||
EnumDemonWillType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.soul;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IDemonWill {
|
||||
/**
|
||||
* Obtains the amount of Will an ItemStack contains.
|
||||
*
|
||||
* @param willStack - The stack to retrieve the Will from
|
||||
* @return - The amount of Will an ItemStack contains
|
||||
*/
|
||||
double getWill(EnumDemonWillType type, ItemStack willStack);
|
||||
|
||||
@Deprecated
|
||||
double getWill(ItemStack willStack);
|
||||
|
||||
/**
|
||||
* Sets the amount of Will in a given ItemStack.
|
||||
*
|
||||
* @param willStack - The ItemStack of the Will
|
||||
* @param will - The amount of will to set the stack to
|
||||
*/
|
||||
void setWill(EnumDemonWillType type, ItemStack willStack, double will);
|
||||
|
||||
@Deprecated
|
||||
void setWill(ItemStack willStack, double will);
|
||||
|
||||
/**
|
||||
* Drains the demonic will from the willStack. If all of the will is
|
||||
* drained, the willStack will be removed.
|
||||
*
|
||||
* @param willStack - The ItemStack of the will
|
||||
* @param drainAmount - The amount of Will to drain
|
||||
* @return The amount of will drained.
|
||||
*/
|
||||
double drainWill(EnumDemonWillType type, ItemStack willStack, double drainAmount);
|
||||
|
||||
@Deprecated
|
||||
double drainWill(ItemStack willStack, double drainAmount);
|
||||
|
||||
/**
|
||||
* Creates a new ItemStack with the specified number of will. Implementation
|
||||
* should respect the number requested.
|
||||
*
|
||||
* @param meta - The meta of the ItemStack to create
|
||||
* @param number - The amount of Will to create the Stack with.
|
||||
* @return - An ItemStack with the set amount of Will
|
||||
*/
|
||||
ItemStack createWill(int meta, double number);
|
||||
|
||||
EnumDemonWillType getType(ItemStack stack);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.soul;
|
||||
|
||||
/**
|
||||
* Implement this interface on a block that can accept and store Demonic Will.
|
||||
*/
|
||||
public interface IDemonWillConduit {
|
||||
int getWeight();
|
||||
|
||||
double fillDemonWill(EnumDemonWillType type, double amount, boolean doFill);
|
||||
|
||||
double drainDemonWill(EnumDemonWillType type, double amount, boolean doDrain);
|
||||
|
||||
boolean canFill(EnumDemonWillType type);
|
||||
|
||||
boolean canDrain(EnumDemonWillType type);
|
||||
|
||||
double getCurrentWill(EnumDemonWillType type);
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.soul;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IDemonWillGem {
|
||||
/**
|
||||
* @param willGemStack - The ItemStack for this demon will gem.
|
||||
* @param willStack - The ItemStack for the will. Item should extend IDemonWill
|
||||
* @return - The remainder willStack after the will has been absorbed into
|
||||
* the gem. Return null if there is no will left in the stack.
|
||||
*/
|
||||
ItemStack fillDemonWillGem(ItemStack willGemStack, ItemStack willStack);
|
||||
|
||||
/**
|
||||
* Returns the number of souls that are left in the soul gem. Returns a
|
||||
* double because souls can be fractionally drained.
|
||||
*/
|
||||
double getWill(EnumDemonWillType type, ItemStack willGemStack);
|
||||
|
||||
void setWill(EnumDemonWillType type, ItemStack willGemStack, double amount);
|
||||
|
||||
int getMaxWill(EnumDemonWillType type, ItemStack willGemStack);
|
||||
|
||||
double drainWill(EnumDemonWillType type, ItemStack stack, double drainAmount, boolean doDrain);
|
||||
|
||||
double fillWill(EnumDemonWillType type, ItemStack stack, double fillAmount, boolean doFill);
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.soul;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IDemonWillWeapon {
|
||||
List<ItemStack> getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting);
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.soul;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IDiscreteDemonWill {
|
||||
/**
|
||||
* Obtains the amount of Will an ItemStack contains.
|
||||
*
|
||||
* @param soulStack - The stack to retrieve the Will from
|
||||
* @return - The amount of Will an ItemStack contains
|
||||
*/
|
||||
double getWill(ItemStack soulStack);
|
||||
|
||||
/**
|
||||
* Drains the demonic will from the willStack. If all of the will is
|
||||
* drained, the willStack will be removed. Will only drain in discrete
|
||||
* amounts, determined by getDiscretization.
|
||||
*
|
||||
* @param willStack - The ItemStack of the will
|
||||
* @param drainAmount - The amount of Will to drain
|
||||
* @return The amount of will drained.
|
||||
*/
|
||||
double drainWill(ItemStack willStack, double drainAmount);
|
||||
|
||||
/**
|
||||
* Gets the discrete number for this demonic will.
|
||||
*
|
||||
* @param willStack - The ItemStack of the will
|
||||
* @return - The discrete number for the given stack.
|
||||
*/
|
||||
double getDiscretization(ItemStack willStack);
|
||||
|
||||
/**
|
||||
* Obtains the type of will this is.
|
||||
*
|
||||
* @param willStack - The ItemStack of the will
|
||||
* @return - The type of will this is.
|
||||
*/
|
||||
EnumDemonWillType getType(ItemStack willStack);
|
||||
}
|
|
@ -0,0 +1,175 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.soul;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
/**
|
||||
* This class provides several helper methods in order to handle soul
|
||||
* consumption and use for a player. This refers to the Soul System, meaning
|
||||
* Monster Souls and Soul Gems, etc. The Soul Network's helper methods are found
|
||||
* in {@link WayofTime.bloodmagic.apibutnotreally.util.helper.NetworkHelper}
|
||||
*/
|
||||
public class PlayerDemonWillHandler {
|
||||
/**
|
||||
* Gets the total amount of Will a player contains in their inventory
|
||||
*
|
||||
* @param type - The type of Will to check for
|
||||
* @param player - The player to check the will of
|
||||
* @return - The amount of will the player contains
|
||||
*/
|
||||
public static double getTotalDemonWill(EnumDemonWillType type, EntityPlayer player) {
|
||||
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
||||
double souls = 0;
|
||||
|
||||
for (ItemStack stack : inventory) {
|
||||
if (stack.getItem() instanceof IDemonWill && ((IDemonWill) stack.getItem()).getType(stack) == type) {
|
||||
souls += ((IDemonWill) stack.getItem()).getWill(type, stack);
|
||||
} else if (stack.getItem() instanceof IDemonWillGem) {
|
||||
souls += ((IDemonWillGem) stack.getItem()).getWill(type, stack);
|
||||
}
|
||||
}
|
||||
|
||||
return souls;
|
||||
}
|
||||
|
||||
public static EnumDemonWillType getLargestWillType(EntityPlayer player) {
|
||||
EnumDemonWillType type = EnumDemonWillType.DEFAULT;
|
||||
double max = getTotalDemonWill(type, player);
|
||||
|
||||
for (EnumDemonWillType testType : EnumDemonWillType.values()) {
|
||||
double value = getTotalDemonWill(testType, player);
|
||||
if (value > max) {
|
||||
type = testType;
|
||||
}
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player's Tartaric gems are completely full.
|
||||
*
|
||||
* @param type - The type of Will to check for
|
||||
* @param player - The player to check the Will of
|
||||
* @return - True if all Will containers are full, false if not.
|
||||
*/
|
||||
public static boolean isDemonWillFull(EnumDemonWillType type, EntityPlayer player) {
|
||||
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
||||
|
||||
boolean hasGem = false;
|
||||
for (ItemStack stack : inventory) {
|
||||
if (stack.getItem() instanceof IDemonWillGem) {
|
||||
hasGem = true;
|
||||
if (((IDemonWillGem) stack.getItem()).getWill(type, stack) < ((IDemonWillGem) stack.getItem()).getMaxWill(type, stack))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return hasGem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Consumes Will from the inventory of a given player
|
||||
*
|
||||
* @param player - The player to consume the will of
|
||||
* @param amount - The amount of will to consume
|
||||
* @return - The amount of will consumed.
|
||||
*/
|
||||
public static double consumeDemonWill(EnumDemonWillType type, EntityPlayer player, double amount) {
|
||||
double consumed = 0;
|
||||
|
||||
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
||||
|
||||
for (int i = 0; i < inventory.size(); i++) {
|
||||
if (consumed >= amount)
|
||||
return consumed;
|
||||
|
||||
ItemStack stack = inventory.get(i);
|
||||
if (stack.getItem() instanceof IDemonWill && ((IDemonWill) stack.getItem()).getType(stack) == type) {
|
||||
consumed += ((IDemonWill) stack.getItem()).drainWill(type, stack, amount - consumed);
|
||||
if (((IDemonWill) stack.getItem()).getWill(type, stack) <= 0)
|
||||
inventory.set(i, ItemStack.EMPTY);
|
||||
} else if (stack.getItem() instanceof IDemonWillGem) {
|
||||
consumed += ((IDemonWillGem) stack.getItem()).drainWill(type, stack, amount - consumed, true);
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an IDemonWill contained in an ItemStack to one of the Soul Gems in
|
||||
* the player's inventory.
|
||||
*
|
||||
* @param player - The player to add will to
|
||||
* @param willStack - ItemStack that contains an IDemonWill to be added
|
||||
* @return - The modified willStack
|
||||
*/
|
||||
public static ItemStack addDemonWill(EntityPlayer player, ItemStack willStack) {
|
||||
if (willStack.isEmpty())
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
||||
|
||||
for (ItemStack stack : inventory) {
|
||||
if (stack.getItem() instanceof IDemonWillGem) {
|
||||
ItemStack newStack = ((IDemonWillGem) stack.getItem()).fillDemonWillGem(stack, willStack);
|
||||
if (newStack.isEmpty())
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
return willStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an IDiscreteDemonWill contained in an ItemStack to one of the Soul
|
||||
* Gems in the player's inventory.
|
||||
*
|
||||
* @param type - The type of Will to add
|
||||
* @param player - The player to check the Will of
|
||||
* @param amount - The amount of will to add
|
||||
* @return - The amount of will added
|
||||
*/
|
||||
public static double addDemonWill(EnumDemonWillType type, EntityPlayer player, double amount) {
|
||||
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
||||
double remaining = amount;
|
||||
|
||||
for (ItemStack stack : inventory) {
|
||||
if (stack.getItem() instanceof IDemonWillGem) {
|
||||
remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining, true);
|
||||
if (remaining <= 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return amount - remaining;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an IDiscreteDemonWill contained in an ItemStack to one of the Soul
|
||||
* Gems in the player's inventory while ignoring a specified stack.
|
||||
*
|
||||
* @param type - The type of Will to add
|
||||
* @param player - The player to check the Will of
|
||||
* @param amount - The amount of will to add
|
||||
* @param ignored - A stack to ignore
|
||||
* @return - The amount of will added
|
||||
*/
|
||||
public static double addDemonWill(EnumDemonWillType type, EntityPlayer player, double amount, ItemStack ignored) {
|
||||
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
||||
double remaining = amount;
|
||||
|
||||
for (ItemStack stack : inventory) {
|
||||
if (!stack.equals(ignored) && stack.getItem() instanceof IDemonWillGem) {
|
||||
remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining, true);
|
||||
|
||||
if (remaining <= 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return amount - remaining;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.teleport;
|
||||
|
||||
public interface ITeleport {
|
||||
void teleport();
|
||||
|
||||
int getTeleportCost();
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.teleport;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.Constants;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class PortalLocation implements Serializable {
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private int dimension;
|
||||
|
||||
public PortalLocation(int x, int y, int z, int dimension) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.dimension = dimension;
|
||||
}
|
||||
|
||||
public PortalLocation(BlockPos blockPos, int dimension) {
|
||||
this(blockPos.getX(), blockPos.getY(), blockPos.getZ(), dimension);
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||
NBTTagCompound locationTag = new NBTTagCompound();
|
||||
|
||||
locationTag.setInteger(Constants.NBT.X_COORD, x);
|
||||
locationTag.setInteger(Constants.NBT.Y_COORD, y);
|
||||
locationTag.setInteger(Constants.NBT.Z_COORD, z);
|
||||
locationTag.setInteger(Constants.NBT.DIMENSION_ID, dimension);
|
||||
tag.setTag(Constants.NBT.PORTAL_LOCATION, locationTag);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
public BlockPos getBlockPos() {
|
||||
return new BlockPos(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
PortalLocation that = (PortalLocation) o;
|
||||
|
||||
if (x != that.x)
|
||||
return false;
|
||||
if (y != that.y)
|
||||
return false;
|
||||
return z == that.z;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = x;
|
||||
result = 31 * result + y;
|
||||
result = 31 * result + z;
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public int getDimension() {
|
||||
return dimension;
|
||||
}
|
||||
|
||||
public static PortalLocation readFromNBT(NBTTagCompound tag) {
|
||||
if (tag.hasKey(Constants.NBT.PORTAL_LOCATION)) {
|
||||
NBTTagCompound locationTag = tag.getCompoundTag(Constants.NBT.PORTAL_LOCATION);
|
||||
return new PortalLocation(locationTag.getInteger(Constants.NBT.X_COORD), locationTag.getInteger(Constants.NBT.Y_COORD), locationTag.getInteger(Constants.NBT.Z_COORD), locationTag.getInteger(Constants.NBT.DIMENSION_ID));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.teleport;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public abstract class Teleport implements ITeleport {
|
||||
protected int x;
|
||||
protected int y;
|
||||
protected int z;
|
||||
protected Entity entity;
|
||||
protected String networkToDrain;
|
||||
|
||||
public Teleport(int x, int y, int z, Entity entity, String networkToDrain) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.entity = entity;
|
||||
this.networkToDrain = networkToDrain;
|
||||
}
|
||||
|
||||
public Teleport(BlockPos blockPos, Entity entity, String networkToDrain) {
|
||||
this(blockPos.getX(), blockPos.getY(), blockPos.getZ(), entity, networkToDrain);
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public String getNetworkToDrain() {
|
||||
return networkToDrain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Teleport)) return false;
|
||||
|
||||
Teleport teleport = (Teleport) o;
|
||||
|
||||
if (x != teleport.x) return false;
|
||||
if (y != teleport.y) return false;
|
||||
if (z != teleport.z) return false;
|
||||
if (entity != null ? !entity.equals(teleport.entity) : teleport.entity != null) return false;
|
||||
return networkToDrain != null ? networkToDrain.equals(teleport.networkToDrain) : teleport.networkToDrain == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = x;
|
||||
result = 31 * result + y;
|
||||
result = 31 * result + z;
|
||||
result = 31 * result + (entity != null ? entity.hashCode() : 0);
|
||||
result = 31 * result + (networkToDrain != null ? networkToDrain.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.teleport;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TeleportQueue {
|
||||
private static TeleportQueue INSTANCE = new TeleportQueue();
|
||||
private static List<ITeleport> queue;
|
||||
|
||||
private TeleportQueue() {
|
||||
queue = new ArrayList<ITeleport>();
|
||||
}
|
||||
|
||||
public void addITeleport(ITeleport iTeleport) {
|
||||
queue.add(iTeleport);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverTick(TickEvent.ServerTickEvent event) {
|
||||
if (event.phase != TickEvent.Phase.END) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ITeleport iTeleport : queue) {
|
||||
iTeleport.teleport();
|
||||
}
|
||||
|
||||
queue.clear();
|
||||
}
|
||||
|
||||
public static TeleportQueue getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.teleport;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.Teleporter;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
public class TeleporterBloodMagic extends Teleporter {
|
||||
public TeleporterBloodMagic(WorldServer worldServer) {
|
||||
super(worldServer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean makePortal(Entity entity) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeStalePortalLocations(long worldTime) {
|
||||
;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeInExistingPortal(Entity entityIn, float rotationYaw) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeInPortal(Entity entity, float rotationYaw) {
|
||||
entity.setLocationAndAngles(MathHelper.floor(entity.posX), MathHelper.floor(entity.posY) + 2, MathHelper.floor(entity.posZ), entity.rotationYaw, entity.rotationPitch);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.util.helper;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.Constants;
|
||||
import WayofTime.bloodmagic.apibutnotreally.event.ItemBindEvent;
|
||||
import WayofTime.bloodmagic.apibutnotreally.iface.IBindable;
|
||||
import WayofTime.bloodmagic.util.handler.event.GenericHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BindableHelper {
|
||||
/**
|
||||
* Sets the Owner Name of the item without checking if it is already bound.
|
||||
* Also bypasses {@link ItemBindEvent}.
|
||||
*
|
||||
* @param stack - The ItemStack to bind
|
||||
* @param ownerName - The username to bind the ItemStack to
|
||||
*/
|
||||
public static void setItemOwnerName(ItemStack stack, String ownerName) {
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
stack.getTagCompound().setString(Constants.NBT.OWNER_NAME, ownerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Owner UUID of the item without checking if it is already bound.
|
||||
* Also bypasses {@link ItemBindEvent}.
|
||||
*
|
||||
* @param stack - The ItemStack to bind
|
||||
* @param ownerUUID - The UUID to bind the ItemStack to
|
||||
*/
|
||||
public static void setItemOwnerUUID(ItemStack stack, String ownerUUID) {
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
stack.getTagCompound().setString(Constants.NBT.OWNER_UUID, ownerUUID);
|
||||
}
|
||||
|
||||
// Everything below is to be removed.
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* <p>
|
||||
* Built into {@link IBindable} now.
|
||||
*
|
||||
* @param stack - The ItemStack to check the owner of
|
||||
* @return - The username of the ItemStack's owner
|
||||
*/
|
||||
@Deprecated
|
||||
public static String getOwnerName(ItemStack stack) {
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
return PlayerHelper.getUsernameFromStack(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* <p>
|
||||
* Built into {@link IBindable} now.
|
||||
*
|
||||
* @param stack - The ItemStack to check the owner of
|
||||
* @return - The UUID of the ItemStack's owner
|
||||
*/
|
||||
@Deprecated
|
||||
public static String getOwnerUUID(ItemStack stack) {
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
return stack.getTagCompound().getString(Constants.NBT.OWNER_UUID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* <p>
|
||||
* Now handled automatically with
|
||||
* {@link GenericHandler#onInteract(PlayerInteractEvent.RightClickItem)}
|
||||
*
|
||||
* @param stack - The ItemStack to bind
|
||||
* @param player - The Player to bind the ItemStack to
|
||||
* @return - Whether binding was successful
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean checkAndSetItemOwner(ItemStack stack, EntityPlayer player) {
|
||||
return !PlayerHelper.isFakePlayer(player) && checkAndSetItemOwner(stack, PlayerHelper.getUUIDFromPlayer(player), player.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* <p>
|
||||
* Now handled automatically with
|
||||
* {@link GenericHandler#onInteract(PlayerInteractEvent.RightClickItem)}
|
||||
*
|
||||
* @param stack - The ItemStack to bind
|
||||
* @param uuid - The username to bind the ItemStack to
|
||||
* @param currentUsername - The current name of the player.
|
||||
* @return - Whether the binding was successful
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean checkAndSetItemOwner(ItemStack stack, String uuid, String currentUsername) {
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
if (!(stack.getItem() instanceof IBindable))
|
||||
return false;
|
||||
|
||||
String currentOwner = stack.getTagCompound().getString(Constants.NBT.OWNER_UUID);
|
||||
|
||||
if (currentOwner == "") //The player has not been set yet, so set everything.
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new ItemBindEvent(PlayerHelper.getPlayerFromUUID(uuid), uuid, stack));
|
||||
((IBindable) stack.getItem()).onBind(PlayerHelper.getPlayerFromUUID(uuid), stack);
|
||||
stack.getTagCompound().setString(Constants.NBT.OWNER_UUID, uuid);
|
||||
stack.getTagCompound().setString(Constants.NBT.OWNER_NAME, currentUsername);
|
||||
return true;
|
||||
} else if (currentOwner.equals(uuid)) //The player has been set, so this will simply update the display name
|
||||
{
|
||||
stack.getTagCompound().setString(Constants.NBT.OWNER_NAME, currentUsername);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* <p>
|
||||
* Now handled automatically with
|
||||
* {@link GenericHandler#onInteract(PlayerInteractEvent.RightClickItem)}
|
||||
*
|
||||
* @param stack - ItemStack to check
|
||||
* @param uuid - UUID of the Player
|
||||
* @param currentUsername - The current name of the player.
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean checkAndSetItemOwner(ItemStack stack, UUID uuid, String currentUsername) {
|
||||
return checkAndSetItemOwner(stack, uuid.toString(), currentUsername);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* @param stack - The ItemStack to bind
|
||||
* @param ownerName - The username to bind the ItemStack to
|
||||
* @see #setItemOwnerName(ItemStack, String)
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setItemOwner(ItemStack stack, String ownerName) {
|
||||
setItemOwnerName(stack, ownerName);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.util.helper;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.Constants;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class IncenseHelper {
|
||||
public static double getCurrentIncense(EntityPlayer player) {
|
||||
NBTTagCompound data = player.getEntityData();
|
||||
if (data.hasKey(Constants.NBT.CURRENT_INCENSE)) {
|
||||
return data.getDouble(Constants.NBT.CURRENT_INCENSE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void setCurrentIncense(EntityPlayer player, double amount) {
|
||||
NBTTagCompound data = player.getEntityData();
|
||||
data.setDouble(Constants.NBT.CURRENT_INCENSE, amount);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.util.helper;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.altar.IBloodAltar;
|
||||
import WayofTime.bloodmagic.apibutnotreally.iface.IItemLPContainer;
|
||||
import WayofTime.bloodmagic.apibutnotreally.iface.IUpgradeTrainer;
|
||||
import WayofTime.bloodmagic.apibutnotreally.livingArmour.LivingArmourHandler;
|
||||
import WayofTime.bloodmagic.apibutnotreally.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.item.ItemUpgradeTome;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemHelper {
|
||||
// IItemLPContainer
|
||||
public static class LPContainer {
|
||||
/**
|
||||
* Attempts to fill an altar with the contained LP
|
||||
*
|
||||
* @param altar - The altar in question
|
||||
* @param itemStack - The {@link IItemLPContainer} ItemStack filling the altar
|
||||
* @param world - The world
|
||||
* @param altarPos - The position of the altar
|
||||
* @return Whether or not the altar was filled (or at least attempted)
|
||||
*/
|
||||
public static boolean tryAndFillAltar(IBloodAltar altar, ItemStack itemStack, World world, BlockPos altarPos) {
|
||||
if (itemStack.getItem() instanceof IItemLPContainer) {
|
||||
if (!altar.isActive()) {
|
||||
IItemLPContainer fillable = (IItemLPContainer) itemStack.getItem();
|
||||
int amount = fillable.getStoredLP(itemStack);
|
||||
|
||||
if (amount > 0) {
|
||||
int filledAmount = altar.fillMainTank(amount);
|
||||
amount -= filledAmount;
|
||||
fillable.setStoredLP(itemStack, amount);
|
||||
world.notifyBlockUpdate(altarPos, world.getBlockState(altarPos), world.getBlockState(altarPos), 3);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given LP into the {@link IItemLPContainer}'s storage
|
||||
*
|
||||
* @param stack - The item in question
|
||||
* @param toAdd - How much LP should be added to the item
|
||||
* @param maxCapacity - The item's maximum holding capacity
|
||||
* @return Whether or not LP was added to the item
|
||||
*/
|
||||
public static boolean addLPToItem(ItemStack stack, int toAdd, int maxCapacity) {
|
||||
if (stack.getItem() instanceof IItemLPContainer) {
|
||||
IItemLPContainer fillable = (IItemLPContainer) stack.getItem();
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
if (toAdd < 0)
|
||||
toAdd = 0;
|
||||
|
||||
if (toAdd > maxCapacity)
|
||||
toAdd = maxCapacity;
|
||||
|
||||
fillable.setStoredLP(stack, Math.min(fillable.getStoredLP(stack) + toAdd, maxCapacity));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static class LivingUpgrades {
|
||||
public static LivingArmourUpgrade getUpgrade(ItemStack stack) {
|
||||
if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) {
|
||||
String key = getKey(stack);
|
||||
int level = getLevel(stack);
|
||||
|
||||
return LivingArmourHandler.generateUpgradeFromKey(key, level);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void setUpgrade(ItemStack stack, LivingArmourUpgrade upgrade) {
|
||||
if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) {
|
||||
setKey(stack, upgrade.getUniqueIdentifier());
|
||||
setLevel(stack, upgrade.getUpgradeLevel());
|
||||
}
|
||||
}
|
||||
|
||||
public static void setKey(ItemStack stack, String key) {
|
||||
if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setString("key", key);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getKey(ItemStack stack) {
|
||||
if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
return tag.getString("key");
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void setLevel(ItemStack stack, int level) {
|
||||
if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setInteger("level", level);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getLevel(ItemStack stack) {
|
||||
if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
return tag.getInteger("level");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package WayofTime.bloodmagic.apibutnotreally.util.helper;
|
||||
|
||||
import WayofTime.bloodmagic.apibutnotreally.BloodMagicAPI;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class LogHelper {
|
||||
private Logger logger;
|
||||
|
||||
public LogHelper(String logger) {
|
||||
this.logger = LogManager.getLogger(logger);
|
||||
}
|
||||
|
||||
public void info(String info, Object... format) {
|
||||
if (BloodMagicAPI.loggingEnabled)
|
||||
logger.info(info, format);
|
||||
}
|
||||
|
||||
public void error(String error, Object... format) {
|
||||
if (BloodMagicAPI.loggingEnabled)
|
||||
logger.error(error, format);
|
||||
}
|
||||
|
||||
public void debug(String debug, Object... format) {
|
||||
if (BloodMagicAPI.loggingEnabled)
|
||||
logger.debug(debug, format);
|
||||
}
|
||||
|
||||
public void fatal(String fatal, Object... format) {
|
||||
logger.error(fatal, format);
|
||||
}
|
||||
|
||||
public Logger getLogger() {
|
||||
return logger;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue