Run formatter
This commit is contained in:
parent
61c44a831b
commit
08258fd6ef
606 changed files with 13464 additions and 22975 deletions
|
@ -6,32 +6,22 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockStack
|
||||
{
|
||||
public class BlockStack {
|
||||
private final Block block;
|
||||
private final int meta;
|
||||
private final IBlockState state;
|
||||
|
||||
public BlockStack(Block block, int meta)
|
||||
{
|
||||
public BlockStack(Block block, int meta) {
|
||||
this.block = block;
|
||||
this.meta = meta;
|
||||
this.state = block.getStateFromMeta(meta);
|
||||
}
|
||||
|
||||
public BlockStack(Block block)
|
||||
{
|
||||
public BlockStack(Block block) {
|
||||
this(block, 0);
|
||||
}
|
||||
|
||||
public static BlockStack getStackFromPos(World world, BlockPos pos)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
return new BlockStack(state.getBlock(), state.getBlock().getMetaFromState(state));
|
||||
}
|
||||
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
public ItemStack getItemStack() {
|
||||
return new ItemStack(block, 1, meta);
|
||||
}
|
||||
|
||||
|
@ -66,8 +56,12 @@ public class BlockStack
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,12 +5,11 @@ 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 class BloodMagicAPI {
|
||||
public static boolean loggingEnabled;
|
||||
|
||||
public static LogHelper logger = new LogHelper("BloodMagic|API");
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
package WayofTime.bloodmagic.api;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
public class Constants
|
||||
{
|
||||
public static class NBT
|
||||
{
|
||||
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";
|
||||
|
@ -129,13 +127,11 @@ public class Constants
|
|||
public static final String TANK = "tank";
|
||||
}
|
||||
|
||||
public static class Mod
|
||||
{
|
||||
public static class Mod {
|
||||
public static final String DOMAIN = BloodMagic.MODID.toLowerCase(Locale.ENGLISH) + ":";
|
||||
}
|
||||
|
||||
public static final class Gui
|
||||
{
|
||||
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;
|
||||
|
@ -144,8 +140,7 @@ public class Constants
|
|||
public static final int SIGIL_HOLDING_GUI = 5;
|
||||
}
|
||||
|
||||
public static class Compat
|
||||
{
|
||||
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";
|
||||
|
@ -163,8 +158,7 @@ public class Constants
|
|||
public static final Item THAUMCRAFT_GOGGLES = ForgeRegistries.ITEMS.getValue(new ResourceLocation("Thaumcraft", "goggles"));
|
||||
}
|
||||
|
||||
public static class Misc
|
||||
{
|
||||
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;
|
||||
|
|
|
@ -6,10 +6,8 @@ import net.minecraft.util.DamageSource;
|
|||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
|
||||
public class DamageSourceBloodMagic extends DamageSource
|
||||
{
|
||||
public DamageSourceBloodMagic()
|
||||
{
|
||||
public class DamageSourceBloodMagic extends DamageSource {
|
||||
public DamageSourceBloodMagic() {
|
||||
super("bloodMagic");
|
||||
|
||||
setDamageBypassesArmor();
|
||||
|
@ -17,8 +15,7 @@ public class DamageSourceBloodMagic extends DamageSource
|
|||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDeathMessage(EntityLivingBase livingBase)
|
||||
{
|
||||
public ITextComponent getDeathMessage(EntityLivingBase livingBase) {
|
||||
return new TextComponentString(TextHelper.localizeEffect("chat.bloodmagic.damageSource", livingBase.getName()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,7 @@ import javax.annotation.Nullable;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemStackWrapper
|
||||
{
|
||||
public class ItemStackWrapper {
|
||||
public final Item item;
|
||||
public final int stackSize;
|
||||
public final int meta;
|
||||
|
@ -22,88 +21,49 @@ public class ItemStackWrapper
|
|||
this.meta = meta;
|
||||
}
|
||||
|
||||
public ItemStackWrapper(Item item, int stackSize)
|
||||
{
|
||||
public ItemStackWrapper(Item item, int stackSize) {
|
||||
this(item, stackSize, 0);
|
||||
}
|
||||
|
||||
public ItemStackWrapper(Item item)
|
||||
{
|
||||
public ItemStackWrapper(Item item) {
|
||||
this(item, 1, 0);
|
||||
}
|
||||
|
||||
public ItemStackWrapper(Block block, int stackSize, int meta)
|
||||
{
|
||||
public ItemStackWrapper(Block block, int stackSize, int meta) {
|
||||
this(Item.getItemFromBlock(block), stackSize, meta);
|
||||
}
|
||||
|
||||
public ItemStackWrapper(Block block, int stackSize)
|
||||
{
|
||||
public ItemStackWrapper(Block block, int stackSize) {
|
||||
this(block, stackSize, 0);
|
||||
}
|
||||
|
||||
public ItemStackWrapper(Block block)
|
||||
{
|
||||
public ItemStackWrapper(Block block) {
|
||||
this(block, 1, 0);
|
||||
}
|
||||
|
||||
public ItemStackWrapper(BlockStack blockStack)
|
||||
{
|
||||
public ItemStackWrapper(BlockStack blockStack) {
|
||||
this(blockStack.getBlock(), 1, blockStack.getMeta());
|
||||
}
|
||||
|
||||
@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 ItemStack toStack()
|
||||
{
|
||||
public ItemStack toStack() {
|
||||
return new ItemStack(item, stackSize, meta);
|
||||
}
|
||||
|
||||
public String getDisplayName()
|
||||
{
|
||||
public String getDisplayName() {
|
||||
return toStack().getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
public String toString() {
|
||||
return stackSize + "x" + item.getUnlocalizedName() + "@" + this.meta;
|
||||
}
|
||||
|
||||
public ItemStack toStack(int count)
|
||||
{
|
||||
public ItemStack toStack(int count) {
|
||||
ItemStack result = new ItemStack(item, count, meta);
|
||||
result.setTagCompound(nbtTag);
|
||||
return result;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public Item getItem() {
|
||||
return item;
|
||||
}
|
||||
|
@ -123,4 +83,30 @@ public class ItemStackWrapper
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
package WayofTime.bloodmagic.api.alchemyCrafting;
|
||||
|
||||
import WayofTime.bloodmagic.api.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;
|
||||
import WayofTime.bloodmagic.api.iface.IAlchemyArray;
|
||||
|
||||
public abstract class AlchemyArrayEffect
|
||||
{
|
||||
public abstract class AlchemyArrayEffect {
|
||||
public final String key;
|
||||
|
||||
public AlchemyArrayEffect(String key) {
|
||||
|
@ -24,8 +23,7 @@ public abstract class AlchemyArrayEffect
|
|||
|
||||
public abstract AlchemyArrayEffect getNewCopy();
|
||||
|
||||
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity)
|
||||
{
|
||||
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -6,39 +6,32 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect
|
||||
{
|
||||
public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect {
|
||||
public final ItemStack outputStack;
|
||||
public int tickLimit;
|
||||
|
||||
public AlchemyArrayEffectCrafting(ItemStack outputStack)
|
||||
{
|
||||
public AlchemyArrayEffectCrafting(ItemStack outputStack) {
|
||||
this(outputStack, 200);
|
||||
}
|
||||
|
||||
public AlchemyArrayEffectCrafting(ItemStack outputStack, int tickLimit)
|
||||
{
|
||||
public AlchemyArrayEffectCrafting(ItemStack outputStack, int tickLimit) {
|
||||
this(outputStack.toString() + tickLimit, outputStack, tickLimit);
|
||||
}
|
||||
|
||||
public AlchemyArrayEffectCrafting(String key, ItemStack outputStack, int 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)
|
||||
{
|
||||
public boolean update(TileEntity tile, int ticksActive) {
|
||||
// TODO: Add recipe rechecking to verify nothing screwy is going on.
|
||||
if (tile.getWorld().isRemote)
|
||||
{
|
||||
if (tile.getWorld().isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ticksActive >= tickLimit)
|
||||
{
|
||||
if (ticksActive >= tickLimit) {
|
||||
BlockPos pos = tile.getPos();
|
||||
|
||||
ItemStack output = outputStack.copy();
|
||||
|
@ -54,20 +47,17 @@ public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlchemyArrayEffect getNewCopy()
|
||||
{
|
||||
public AlchemyArrayEffect getNewCopy() {
|
||||
return new AlchemyArrayEffectCrafting(key, outputStack, tickLimit);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package WayofTime.bloodmagic.api.alchemyCrafting;
|
||||
|
||||
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
@ -8,73 +9,57 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
||||
|
||||
public class AlchemyCircleRenderer
|
||||
{
|
||||
public float offsetFromFace = -0.9f;
|
||||
public class AlchemyCircleRenderer {
|
||||
public final ResourceLocation arrayResource;
|
||||
public float offsetFromFace = -0.9f;
|
||||
|
||||
public AlchemyCircleRenderer()
|
||||
{
|
||||
public AlchemyCircleRenderer() {
|
||||
this(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png"));
|
||||
}
|
||||
|
||||
public AlchemyCircleRenderer(ResourceLocation arrayResource)
|
||||
{
|
||||
public AlchemyCircleRenderer(ResourceLocation arrayResource) {
|
||||
this.arrayResource = arrayResource;
|
||||
}
|
||||
|
||||
public float getRotation(float craftTime)
|
||||
{
|
||||
public float getRotation(float craftTime) {
|
||||
float offset = 2;
|
||||
if (craftTime >= offset)
|
||||
{
|
||||
if (craftTime >= offset) {
|
||||
float modifier = (float) Math.pow(craftTime - offset, 1.5);
|
||||
return modifier * 1f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getSecondaryRotation(float craftTime)
|
||||
{
|
||||
public float getSecondaryRotation(float craftTime) {
|
||||
float offset = 50;
|
||||
if (craftTime >= offset)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
public float getVerticalOffset(float craftTime) {
|
||||
if (craftTime >= 5) {
|
||||
if (craftTime <= 40) {
|
||||
return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3));
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return -0.4f;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void renderAt(TileEntity tile, double x, double y, double z, float craftTime)
|
||||
{
|
||||
if (!(tile instanceof TileAlchemyArray))
|
||||
{
|
||||
public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) {
|
||||
if (!(tile instanceof TileAlchemyArray)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -106,30 +91,29 @@ public class AlchemyCircleRenderer
|
|||
|
||||
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;
|
||||
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();
|
||||
|
|
|
@ -5,8 +5,7 @@ import net.minecraft.util.math.BlockPos;
|
|||
/**
|
||||
* Used for building the altar structure.
|
||||
*/
|
||||
public class AltarComponent
|
||||
{
|
||||
public class AltarComponent {
|
||||
private BlockPos offset;
|
||||
private boolean upgradeSlot;
|
||||
|
||||
|
@ -14,14 +13,11 @@ public class AltarComponent
|
|||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
public AltarComponent(BlockPos offset, EnumAltarComponent component) {
|
||||
this.offset = offset;
|
||||
this.component = component;
|
||||
}
|
||||
|
@ -29,22 +25,19 @@ public class AltarComponent
|
|||
/**
|
||||
* 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
|
||||
*
|
||||
* @param offset - Where the block should be in relation to the Altar
|
||||
*/
|
||||
public AltarComponent(BlockPos offset)
|
||||
{
|
||||
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()
|
||||
{
|
||||
public AltarComponent setUpgradeSlot() {
|
||||
this.upgradeSlot = true;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package WayofTime.bloodmagic.api.altar;
|
||||
|
||||
public class AltarUpgrade
|
||||
{
|
||||
public class AltarUpgrade {
|
||||
private int speedCount;
|
||||
private int efficiencyCount;
|
||||
private int sacrificeCount;
|
||||
|
@ -31,62 +30,52 @@ public class AltarUpgrade
|
|||
|
||||
// Adders
|
||||
|
||||
public AltarUpgrade addSpeed()
|
||||
{
|
||||
public AltarUpgrade addSpeed() {
|
||||
speedCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addEfficiency()
|
||||
{
|
||||
public AltarUpgrade addEfficiency() {
|
||||
efficiencyCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addSacrifice()
|
||||
{
|
||||
public AltarUpgrade addSacrifice() {
|
||||
sacrificeCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addSelfSacrifice()
|
||||
{
|
||||
public AltarUpgrade addSelfSacrifice() {
|
||||
selfSacrificeCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addDisplacement()
|
||||
{
|
||||
public AltarUpgrade addDisplacement() {
|
||||
displacementCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addCapacity()
|
||||
{
|
||||
public AltarUpgrade addCapacity() {
|
||||
capacityCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addOrbCapacity()
|
||||
{
|
||||
public AltarUpgrade addOrbCapacity() {
|
||||
orbCapacityCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addBetterCapacity()
|
||||
{
|
||||
public AltarUpgrade addBetterCapacity() {
|
||||
betterCapacityCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addAcceleration()
|
||||
{
|
||||
public AltarUpgrade addAcceleration() {
|
||||
accelerationCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addCharging()
|
||||
{
|
||||
public AltarUpgrade addCharging() {
|
||||
chargingCount++;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -5,8 +5,7 @@ import java.util.Locale;
|
|||
/**
|
||||
* List of different components used to construct different tiers of altars.
|
||||
*/
|
||||
public enum EnumAltarComponent
|
||||
{
|
||||
public enum EnumAltarComponent {
|
||||
GLOWSTONE,
|
||||
BLOODSTONE,
|
||||
BEACON,
|
||||
|
@ -18,8 +17,7 @@ public enum EnumAltarComponent
|
|||
private static final String BASE = "chat.bloodmagic.altar.comp.";
|
||||
private String key;
|
||||
|
||||
EnumAltarComponent()
|
||||
{
|
||||
EnumAltarComponent() {
|
||||
this.key = BASE + name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,13 +5,10 @@ import net.minecraft.util.math.BlockPos;
|
|||
import java.util.ArrayList;
|
||||
|
||||
//@formatter:off
|
||||
public enum EnumAltarTier
|
||||
{
|
||||
ONE(), TWO()
|
||||
{
|
||||
public enum EnumAltarTier {
|
||||
ONE(), TWO() {
|
||||
@Override
|
||||
public void buildComponents()
|
||||
{
|
||||
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));
|
||||
|
@ -22,11 +19,9 @@ public enum EnumAltarTier
|
|||
altarComponents.add(new AltarComponent(new BlockPos(1, -1, 1), EnumAltarComponent.BLOODRUNE));
|
||||
}
|
||||
},
|
||||
THREE()
|
||||
{
|
||||
THREE() {
|
||||
@Override
|
||||
public void buildComponents()
|
||||
{
|
||||
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());
|
||||
|
@ -48,8 +43,7 @@ public enum EnumAltarTier
|
|||
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++)
|
||||
{
|
||||
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());
|
||||
|
@ -57,23 +51,19 @@ public enum EnumAltarTier
|
|||
}
|
||||
}
|
||||
},
|
||||
FOUR()
|
||||
{
|
||||
FOUR() {
|
||||
@Override
|
||||
public void buildComponents()
|
||||
{
|
||||
public void buildComponents() {
|
||||
altarComponents.addAll(THREE.getAltarComponents());
|
||||
|
||||
for (int i = -3; i <= 3; i++)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
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)));
|
||||
|
@ -86,19 +76,16 @@ public enum EnumAltarTier
|
|||
altarComponents.add(new AltarComponent(new BlockPos(-5, 2, 5), EnumAltarComponent.BLOODSTONE));
|
||||
}
|
||||
},
|
||||
FIVE()
|
||||
{
|
||||
FIVE() {
|
||||
@Override
|
||||
public void buildComponents()
|
||||
{
|
||||
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++)
|
||||
{
|
||||
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());
|
||||
|
@ -106,15 +93,12 @@ public enum EnumAltarTier
|
|||
}
|
||||
}
|
||||
},
|
||||
SIX()
|
||||
{
|
||||
SIX() {
|
||||
@Override
|
||||
public void buildComponents()
|
||||
{
|
||||
public void buildComponents() {
|
||||
altarComponents.addAll(FIVE.getAltarComponents());
|
||||
|
||||
for (int i = -4; i <= 2; i++)
|
||||
{
|
||||
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)));
|
||||
|
@ -126,8 +110,7 @@ public enum EnumAltarTier
|
|||
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++)
|
||||
{
|
||||
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());
|
||||
|
@ -141,13 +124,11 @@ public enum EnumAltarTier
|
|||
|
||||
ArrayList<AltarComponent> altarComponents = new ArrayList<AltarComponent>();
|
||||
|
||||
public void buildComponents()
|
||||
{
|
||||
public void buildComponents() {
|
||||
|
||||
}
|
||||
|
||||
public int toInt()
|
||||
{
|
||||
public int toInt() {
|
||||
return ordinal() + 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,7 @@ import net.minecraft.world.World;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface IAltarComponent
|
||||
{
|
||||
public interface IAltarComponent {
|
||||
@Nullable
|
||||
EnumAltarComponent getType(World world, IBlockState state, BlockPos pos);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,5 @@ package WayofTime.bloodmagic.api.altar;
|
|||
* Any item that implements this interface will not be pulled into the Altar on
|
||||
* right click.
|
||||
*/
|
||||
public interface IAltarManipulator
|
||||
{
|
||||
public interface IAltarManipulator {
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package WayofTime.bloodmagic.api.altar;
|
||||
|
||||
public interface IBloodAltar
|
||||
{
|
||||
public interface IBloodAltar {
|
||||
int getCapacity();
|
||||
|
||||
int getCurrentBlood();
|
||||
|
@ -48,9 +47,8 @@ public interface IBloodAltar
|
|||
* 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
|
||||
*
|
||||
* @param cooldown - How long the cooldown should last
|
||||
*/
|
||||
void requestPauseAfterCrafting(int cooldown);
|
||||
}
|
||||
|
|
|
@ -3,14 +3,12 @@ package WayofTime.bloodmagic.api.compress;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class CompressionHandler
|
||||
{
|
||||
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
|
||||
*
|
||||
* @param inv The inventory iterated through
|
||||
* @return The result of the compression
|
||||
*/
|
||||
public abstract ItemStack compressInventory(ItemStack[] inv, World world);
|
||||
|
|
|
@ -1,54 +1,44 @@
|
|||
package WayofTime.bloodmagic.api.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;
|
||||
|
||||
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 WayofTime.bloodmagic.util.Utils;
|
||||
|
||||
/**
|
||||
* A registry aimed to help compress items in an inventory into its compressible
|
||||
* form.
|
||||
*/
|
||||
public class CompressionRegistry
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
*
|
||||
* @param stack item/block to be compressed
|
||||
* @param threshold amount that is to be compressed
|
||||
*/
|
||||
public static void registerItemThreshold(ItemStack stack, int threshold)
|
||||
{
|
||||
public static void registerItemThreshold(ItemStack stack, int threshold) {
|
||||
thresholdMap.put(stack, threshold);
|
||||
}
|
||||
|
||||
public static ItemStack compressInventory(ItemStack[] inv, World world)
|
||||
{
|
||||
for (CompressionHandler handler : compressionRegistry)
|
||||
{
|
||||
public static ItemStack compressInventory(ItemStack[] inv, World world) {
|
||||
for (CompressionHandler handler : compressionRegistry) {
|
||||
ItemStack stack = handler.compressInventory(inv, world);
|
||||
if (stack != null)
|
||||
{
|
||||
if (stack != null) {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
@ -56,32 +46,24 @@ public class CompressionRegistry
|
|||
return null;
|
||||
}
|
||||
|
||||
public static Pair<ItemStack, Boolean> compressInventory(TileEntity tile, World world)
|
||||
{
|
||||
if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, 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++)
|
||||
{
|
||||
for (int slot = 0; slot < itemHandler.getSlots(); slot++) {
|
||||
inventory[slot] = itemHandler.extractItem(slot, 64, true);
|
||||
copyInventory[slot] = inventory[slot].copy();
|
||||
}
|
||||
|
||||
for (CompressionHandler handler : compressionRegistry)
|
||||
{
|
||||
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]))
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (copyInventory[slot] != null) {
|
||||
itemHandler.insertItem(slot, copyInventory[slot], false);
|
||||
}
|
||||
}
|
||||
|
@ -95,12 +77,9 @@ public class CompressionRegistry
|
|||
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))
|
||||
{
|
||||
public static int getItemThreshold(ItemStack stack) {
|
||||
for (Map.Entry<ItemStack, Integer> entry : thresholdMap.entrySet()) {
|
||||
if (areItemStacksEqual(entry.getKey(), stack)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
@ -108,8 +87,7 @@ public class CompressionRegistry
|
|||
return 0;
|
||||
}
|
||||
|
||||
public static boolean areItemStacksEqual(ItemStack stack, ItemStack compressedStack)
|
||||
{
|
||||
public static boolean areItemStacksEqual(ItemStack stack, ItemStack compressedStack) {
|
||||
return stack.isItemEqual(compressedStack) && (stack.getTagCompound() == null ? !compressedStack.hasTagCompound() : stack.getTagCompound().equals(compressedStack.getTagCompound()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,7 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
|||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
@Cancelable
|
||||
public class AddToNetworkEvent extends Event
|
||||
{
|
||||
public class AddToNetworkEvent extends Event {
|
||||
public final String ownerNetwork;
|
||||
public int addedAmount;
|
||||
public int maximum;
|
||||
|
@ -14,16 +13,12 @@ public class AddToNetworkEvent extends Event
|
|||
* 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
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
public AddToNetworkEvent(String ownerNetwork, int addedAmount, int maximum) {
|
||||
this.ownerNetwork = ownerNetwork;
|
||||
this.addedAmount = addedAmount;
|
||||
this.maximum = maximum;
|
||||
|
|
|
@ -6,23 +6,19 @@ 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
|
||||
{
|
||||
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
|
||||
* @param altarRecipe - The recipe that was crafted.
|
||||
* @param output - The item obtained from the recipe
|
||||
*/
|
||||
public AltarCraftedEvent(AltarRecipeRegistry.AltarRecipe altarRecipe, ItemStack output)
|
||||
{
|
||||
public AltarCraftedEvent(AltarRecipeRegistry.AltarRecipe altarRecipe, ItemStack output) {
|
||||
this.altarRecipe = altarRecipe;
|
||||
this.output = output;
|
||||
}
|
||||
|
|
|
@ -5,29 +5,25 @@ 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 class BoundToolEvent extends Event {
|
||||
public EntityPlayer player;
|
||||
|
||||
public BoundToolEvent(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 static class Charge extends BoundToolEvent {
|
||||
public ItemStack result;
|
||||
|
||||
public Charge(EntityPlayer player, ItemStack result)
|
||||
{
|
||||
public Charge(EntityPlayer player, ItemStack result) {
|
||||
super(player);
|
||||
this.result = result;
|
||||
}
|
||||
|
@ -36,18 +32,16 @@ public class BoundToolEvent extends Event
|
|||
/**
|
||||
* 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 static class Release extends BoundToolEvent {
|
||||
public final ItemStack boundTool;
|
||||
public int charge;
|
||||
|
||||
public Release(EntityPlayer player, ItemStack boundTool, int charge)
|
||||
{
|
||||
public Release(EntityPlayer player, ItemStack boundTool, int charge) {
|
||||
super(player);
|
||||
this.boundTool = boundTool;
|
||||
this.charge = charge;
|
||||
|
|
|
@ -6,8 +6,7 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
|||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
@Cancelable
|
||||
public class ItemBindEvent extends Event
|
||||
{
|
||||
public class ItemBindEvent extends Event {
|
||||
public final EntityPlayer player;
|
||||
public String key;
|
||||
public ItemStack itemStack;
|
||||
|
@ -15,18 +14,14 @@ public class ItemBindEvent extends Event
|
|||
/**
|
||||
* This event is called whenever a player attempts to bind a
|
||||
* {@link WayofTime.bloodmagic.api.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
|
||||
*
|
||||
* This event is {@link Cancelable}.<br>
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
public ItemBindEvent(EntityPlayer player, String key, ItemStack itemStack) {
|
||||
super();
|
||||
this.player = player;
|
||||
this.key = key;
|
||||
|
|
|
@ -10,14 +10,12 @@ 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 class RitualEvent extends Event {
|
||||
public final IMasterRitualStone mrs;
|
||||
public final String ownerName;
|
||||
public final Ritual ritual;
|
||||
|
||||
private RitualEvent(IMasterRitualStone mrs, String ownerName, Ritual ritual)
|
||||
{
|
||||
private RitualEvent(IMasterRitualStone mrs, String ownerName, Ritual ritual) {
|
||||
this.mrs = mrs;
|
||||
this.ownerName = ownerName;
|
||||
this.ritual = ritual;
|
||||
|
@ -26,18 +24,16 @@ public class RitualEvent extends Event
|
|||
/**
|
||||
* 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 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)
|
||||
{
|
||||
public RitualActivatedEvent(IMasterRitualStone mrs, String owner, Ritual ritual, EntityPlayer player, ItemStack activationCrystal, int crystalTier) {
|
||||
super(mrs, owner, ritual);
|
||||
|
||||
this.player = player;
|
||||
|
@ -49,14 +45,12 @@ public class RitualEvent extends Event
|
|||
/**
|
||||
* 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)
|
||||
{
|
||||
public static class RitualRunEvent extends RitualEvent {
|
||||
public RitualRunEvent(IMasterRitualStone mrs, String owner, Ritual ritual) {
|
||||
super(mrs, owner, ritual);
|
||||
}
|
||||
}
|
||||
|
@ -64,16 +58,14 @@ public class RitualEvent extends Event
|
|||
/**
|
||||
* 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 static class RitualStopEvent extends RitualEvent {
|
||||
|
||||
public final Ritual.BreakType method;
|
||||
|
||||
public RitualStopEvent(IMasterRitualStone mrs, String owner, Ritual ritual, Ritual.BreakType method)
|
||||
{
|
||||
public RitualStopEvent(IMasterRitualStone mrs, String owner, Ritual ritual, Ritual.BreakType method) {
|
||||
super(mrs, owner, ritual);
|
||||
|
||||
this.method = method;
|
||||
|
@ -81,15 +73,13 @@ public class RitualEvent extends Event
|
|||
}
|
||||
|
||||
@Cancelable
|
||||
public static class ImperfectRitualActivatedEvent extends Event
|
||||
{
|
||||
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)
|
||||
{
|
||||
public ImperfectRitualActivatedEvent(IImperfectRitualStone ims, String ownerName, ImperfectRitual imperfectRitual) {
|
||||
this.ims = ims;
|
||||
this.ownerName = ownerName;
|
||||
this.imperfectRitual = imperfectRitual;
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
package WayofTime.bloodmagic.api.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 SacrificeKnifeUsedEvent extends Event
|
||||
{
|
||||
public class SacrificeKnifeUsedEvent extends Event {
|
||||
public final EntityPlayer player;
|
||||
public final int healthDrained;
|
||||
public int lpAdded;
|
||||
|
@ -18,22 +16,16 @@ public class SacrificeKnifeUsedEvent extends Event
|
|||
* 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
|
||||
*
|
||||
* This event is {@link Cancelable}.<br>
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
public SacrificeKnifeUsedEvent(EntityPlayer player, boolean shouldDrainHealth, boolean shouldFillAltar, int hp, int lpAdded) {
|
||||
this.player = player;
|
||||
this.shouldDrainHealth = shouldDrainHealth;
|
||||
this.shouldFillAltar = shouldFillAltar;
|
||||
|
|
|
@ -9,17 +9,15 @@ 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 class SoulNetworkEvent extends Event {
|
||||
public final String ownerUUID;
|
||||
public int syphon;
|
||||
|
||||
public SoulNetworkEvent(String ownerUUID, int syphon)
|
||||
{
|
||||
public SoulNetworkEvent(String ownerUUID, int syphon) {
|
||||
this.ownerUUID = ownerUUID;
|
||||
this.syphon = syphon;
|
||||
}
|
||||
|
@ -28,16 +26,14 @@ public class SoulNetworkEvent extends Event
|
|||
* This event is called when an
|
||||
* {@link WayofTime.bloodmagic.api.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 static class ItemDrainInContainerEvent extends SoulNetworkEvent {
|
||||
public ItemStack stack;
|
||||
|
||||
public ItemDrainInContainerEvent(ItemStack stack, String ownerName, int syphon)
|
||||
{
|
||||
public ItemDrainInContainerEvent(ItemStack stack, String ownerName, int syphon) {
|
||||
super(ownerName, syphon);
|
||||
this.stack = stack;
|
||||
}
|
||||
|
@ -45,18 +41,16 @@ public class SoulNetworkEvent extends Event
|
|||
|
||||
/**
|
||||
* 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 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)
|
||||
{
|
||||
public PlayerDrainNetworkEvent(EntityPlayer player, String ownerNetwork, int drainAmount) {
|
||||
super(ownerNetwork, drainAmount);
|
||||
this.shouldDamage = false;
|
||||
this.player = player;
|
||||
|
@ -64,8 +58,7 @@ public class SoulNetworkEvent extends Event
|
|||
}
|
||||
|
||||
@Cancelable
|
||||
public static class ItemDrainNetworkEvent extends PlayerDrainNetworkEvent
|
||||
{
|
||||
public static class ItemDrainNetworkEvent extends PlayerDrainNetworkEvent {
|
||||
@Nullable
|
||||
public final ItemStack itemStack;
|
||||
/**
|
||||
|
@ -77,18 +70,13 @@ public class SoulNetworkEvent extends Event
|
|||
/**
|
||||
* 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
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
public ItemDrainNetworkEvent(EntityPlayer player, String ownerNetwork, @Nullable ItemStack itemStack, int drainAmount) {
|
||||
super(player, ownerNetwork, drainAmount);
|
||||
this.itemStack = itemStack;
|
||||
this.damageAmount = (float) (drainAmount) / 100.0f;
|
||||
|
|
|
@ -14,8 +14,7 @@ import net.minecraftforge.fml.common.eventhandler.Event;
|
|||
* transposition.
|
||||
*/
|
||||
@Cancelable
|
||||
public class TeleposeEvent extends Event
|
||||
{
|
||||
public class TeleposeEvent extends Event {
|
||||
public final World initalWorld;
|
||||
public final BlockPos initialBlockPos;
|
||||
public final IBlockState initialState;
|
||||
|
@ -24,8 +23,7 @@ public class TeleposeEvent extends Event
|
|||
public final BlockPos finalBlockPos;
|
||||
public final IBlockState finalState;
|
||||
|
||||
public TeleposeEvent(World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos)
|
||||
{
|
||||
public TeleposeEvent(World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos) {
|
||||
this.initalWorld = initialWorld;
|
||||
this.initialBlockPos = initialBlockPos;
|
||||
this.initialState = initialWorld.getBlockState(initialBlockPos);
|
||||
|
@ -35,13 +33,11 @@ public class TeleposeEvent extends Event
|
|||
this.finalState = finalWorld.getBlockState(finalBlockPos);
|
||||
}
|
||||
|
||||
public TileEntity getInitialTile()
|
||||
{
|
||||
public TileEntity getInitialTile() {
|
||||
return initalWorld.getTileEntity(initialBlockPos);
|
||||
}
|
||||
|
||||
public TileEntity getFinalTile()
|
||||
{
|
||||
public TileEntity getFinalTile() {
|
||||
return finalWorld.getTileEntity(finalBlockPos);
|
||||
}
|
||||
|
||||
|
@ -50,37 +46,31 @@ public class TeleposeEvent extends Event
|
|||
* be cancelled to stop transposition.
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Ent extends TeleposeEvent
|
||||
{
|
||||
public static class Ent extends TeleposeEvent {
|
||||
public final Entity entity;
|
||||
|
||||
public Ent(Entity entity, World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos)
|
||||
{
|
||||
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
|
||||
{
|
||||
public TileEntity getInitialTile() throws IllegalArgumentException {
|
||||
throw new IllegalArgumentException("Attempted to get a TileEntity from an Entity Telepose Event.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getFinalTile() throws IllegalArgumentException
|
||||
{
|
||||
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 static class Post extends Ent {
|
||||
|
||||
public Post(Entity entity, World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos)
|
||||
{
|
||||
public Post(Entity entity, World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos) {
|
||||
super(entity, initialWorld, initialBlockPos, finalWorld, finalBlockPos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,7 @@ package WayofTime.bloodmagic.api.iface;
|
|||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IActivatable
|
||||
{
|
||||
public interface IActivatable {
|
||||
boolean getActivated(ItemStack stack);
|
||||
|
||||
ItemStack setActivatedState(ItemStack stack, boolean activated);
|
||||
|
|
|
@ -2,7 +2,6 @@ package WayofTime.bloodmagic.api.iface;
|
|||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public interface IAlchemyArray
|
||||
{
|
||||
public interface IAlchemyArray {
|
||||
EnumFacing getRotation();
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ package WayofTime.bloodmagic.api.iface;
|
|||
* Any item that implements this interface will not be pulled into the Altar on
|
||||
* right click.
|
||||
*/
|
||||
public interface IAltarReader
|
||||
{
|
||||
public interface IAltarReader {
|
||||
|
||||
}
|
||||
|
|
|
@ -6,41 +6,33 @@ import net.minecraft.item.ItemStack;
|
|||
/**
|
||||
* Implement this interface on any Item that can be bound to a player.
|
||||
*/
|
||||
public interface IBindable
|
||||
{
|
||||
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
|
||||
*
|
||||
*
|
||||
* @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
|
||||
*
|
||||
*
|
||||
* @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
|
||||
*
|
||||
*
|
||||
* @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);
|
||||
|
|
|
@ -6,7 +6,6 @@ import net.minecraft.item.ItemStack;
|
|||
* An interface for items that have custom drainage behaviour when used in
|
||||
* certain alchemy recipes.
|
||||
*/
|
||||
public interface ICustomAlchemyConsumable
|
||||
{
|
||||
public interface ICustomAlchemyConsumable {
|
||||
ItemStack drainUseOnAlchemyCraft(ItemStack stack);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IDemonWillViewer
|
||||
{
|
||||
public interface IDemonWillViewer {
|
||||
boolean canSeeDemonWillAura(World world, ItemStack stack, EntityPlayer player);
|
||||
|
||||
int getDemonWillAuraResolution(World world, ItemStack stack, EntityPlayer player);
|
||||
|
|
|
@ -11,27 +11,21 @@ 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
|
||||
{
|
||||
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.
|
||||
*
|
||||
*
|
||||
* @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.
|
||||
* Provide an empty list if there is no available documentation.
|
||||
*/
|
||||
@Nonnull
|
||||
List<ITextComponent> getDocumentation(EntityPlayer player, World world, BlockPos pos, IBlockState state);
|
||||
|
|
|
@ -7,23 +7,18 @@ import net.minecraft.world.World;
|
|||
/**
|
||||
* Used to define a HarvestHandler for the Harvest Ritual.
|
||||
*/
|
||||
public interface IHarvestHandler
|
||||
{
|
||||
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.api.ritual.IMasterRitualStone} is in.
|
||||
* @param pos
|
||||
* - The position of the Block being checked
|
||||
* @param blockStack
|
||||
* - The Block being checked
|
||||
*
|
||||
*
|
||||
* @param world - The world the
|
||||
* {@link WayofTime.bloodmagic.api.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);
|
||||
|
|
|
@ -5,8 +5,7 @@ import net.minecraft.item.ItemStack;
|
|||
/**
|
||||
* Interface used for any item that can store LP in itself
|
||||
*/
|
||||
public interface IItemLPContainer
|
||||
{
|
||||
public interface IItemLPContainer {
|
||||
int getCapacity();
|
||||
|
||||
void setStoredLP(ItemStack stack, int lp);
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package WayofTime.bloodmagic.api.iface;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IMultiWillTool
|
||||
{
|
||||
public interface IMultiWillTool {
|
||||
EnumDemonWillType getCurrentType(ItemStack stack);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,5 @@ package WayofTime.bloodmagic.api.iface;
|
|||
* Held items that implement this will cause the beams between routing nodes to
|
||||
* render.
|
||||
*/
|
||||
public interface INodeRenderer
|
||||
{
|
||||
public interface INodeRenderer {
|
||||
}
|
||||
|
|
|
@ -2,8 +2,7 @@ package WayofTime.bloodmagic.api.iface;
|
|||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IPurificationAsh
|
||||
{
|
||||
public interface IPurificationAsh {
|
||||
double getTotalPurity(ItemStack stack);
|
||||
|
||||
double getMaxPurity(ItemStack stack);
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package WayofTime.bloodmagic.api.iface;
|
||||
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
|
||||
public interface ISentientSwordEffectProvider
|
||||
{
|
||||
public interface ISentientSwordEffectProvider {
|
||||
boolean applyOnHitEffect(EnumDemonWillType type, ItemStack swordStack, ItemStack providerStack, EntityLivingBase attacker, EntityLivingBase target);
|
||||
|
||||
boolean providesEffectForWill(EnumDemonWillType type);
|
||||
|
|
|
@ -3,7 +3,6 @@ package WayofTime.bloodmagic.api.iface;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ISentientTool
|
||||
{
|
||||
public interface ISentientTool {
|
||||
boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player);
|
||||
}
|
||||
|
|
|
@ -11,14 +11,12 @@ import javax.annotation.Nonnull;
|
|||
* Used for all {@link WayofTime.bloodmagic.api.impl.ItemSigil} <b>EXCEPT</b>
|
||||
* Sigils of Holdings.
|
||||
*/
|
||||
public interface ISigil
|
||||
{
|
||||
public interface ISigil {
|
||||
boolean performArrayEffect(World world, BlockPos pos);
|
||||
|
||||
boolean hasArrayEffect();
|
||||
|
||||
interface Holding
|
||||
{
|
||||
interface Holding {
|
||||
@Nonnull
|
||||
ItemStack getHeldItem(ItemStack holdingStack, EntityPlayer player);
|
||||
}
|
||||
|
|
|
@ -8,8 +8,7 @@ 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
|
||||
{
|
||||
public interface IUpgradeTrainer {
|
||||
List<String> getTrainedUpgrades(ItemStack stack);
|
||||
|
||||
boolean setTrainedUpgrades(ItemStack stack, List<String> keys);
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
package WayofTime.bloodmagic.api.impl;
|
||||
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IBindable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IBindable;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
|
||||
/**
|
||||
* Base class for all bindable items.
|
||||
*/
|
||||
public class ItemBindable extends Item implements IBindable
|
||||
{
|
||||
public ItemBindable()
|
||||
{
|
||||
public class ItemBindable extends Item implements IBindable {
|
||||
public ItemBindable() {
|
||||
super();
|
||||
|
||||
setMaxStackSize(1);
|
||||
|
@ -22,20 +19,17 @@ public class ItemBindable extends Item implements IBindable
|
|||
// IBindable
|
||||
|
||||
@Override
|
||||
public boolean onBind(EntityPlayer player, ItemStack stack)
|
||||
{
|
||||
public boolean onBind(EntityPlayer player, ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwnerName(ItemStack stack)
|
||||
{
|
||||
public String getOwnerName(ItemStack stack) {
|
||||
return !stack.isEmpty() ? stack.getTagCompound().getString(Constants.NBT.OWNER_NAME) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwnerUUID(ItemStack stack)
|
||||
{
|
||||
public String getOwnerUUID(ItemStack stack) {
|
||||
return !stack.isEmpty() ? stack.getTagCompound().getString(Constants.NBT.OWNER_UUID) : null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,26 +10,22 @@ import net.minecraft.world.World;
|
|||
/**
|
||||
* Base class for all (static) sigils.
|
||||
*/
|
||||
public class ItemSigil extends ItemBindable implements ISigil
|
||||
{
|
||||
public class ItemSigil extends ItemBindable implements ISigil {
|
||||
private int lpUsed;
|
||||
|
||||
public ItemSigil(int lpUsed)
|
||||
{
|
||||
public ItemSigil(int lpUsed) {
|
||||
super();
|
||||
|
||||
this.lpUsed = lpUsed;
|
||||
}
|
||||
|
||||
public boolean isUnusable(ItemStack stack)
|
||||
{
|
||||
public boolean isUnusable(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
return stack.getTagCompound().getBoolean(Constants.NBT.UNUSABLE);
|
||||
}
|
||||
|
||||
public ItemStack setUnusable(ItemStack stack, boolean unusable)
|
||||
{
|
||||
public ItemStack setUnusable(ItemStack stack, boolean unusable) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
stack.getTagCompound().setBoolean(Constants.NBT.UNUSABLE, unusable);
|
||||
|
@ -37,14 +33,12 @@ public class ItemSigil extends ItemBindable implements ISigil
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean performArrayEffect(World world, BlockPos pos)
|
||||
{
|
||||
public boolean performArrayEffect(World world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasArrayEffect()
|
||||
{
|
||||
public boolean hasArrayEffect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,24 +21,19 @@ import net.minecraft.world.World;
|
|||
/**
|
||||
* Base class for all toggleable sigils.
|
||||
*/
|
||||
public class ItemSigilToggleable extends ItemSigil implements IActivatable
|
||||
{
|
||||
public ItemSigilToggleable(int lpUsed)
|
||||
{
|
||||
public class ItemSigilToggleable extends ItemSigil implements IActivatable {
|
||||
public ItemSigilToggleable(int lpUsed) {
|
||||
super(lpUsed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActivated(ItemStack stack)
|
||||
{
|
||||
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())
|
||||
{
|
||||
public ItemStack setActivatedState(ItemStack stack, boolean activated) {
|
||||
if (!stack.isEmpty()) {
|
||||
NBTHelper.checkNBT(stack).getTagCompound().setBoolean(Constants.NBT.ACTIVATED, activated);
|
||||
return stack;
|
||||
}
|
||||
|
@ -47,16 +42,14 @@ public class ItemSigilToggleable extends ItemSigil implements IActivatable
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
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 (!world.isRemote && !isUnusable(stack)) {
|
||||
if (player.isSneaking())
|
||||
setActivatedState(stack, !getActivated(stack));
|
||||
if (getActivated(stack) && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()))
|
||||
|
@ -67,8 +60,7 @@ public class ItemSigilToggleable extends ItemSigil implements IActivatable
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
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);
|
||||
|
@ -78,20 +70,15 @@ public class ItemSigilToggleable extends ItemSigil implements IActivatable
|
|||
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)
|
||||
{
|
||||
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()))
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +87,6 @@ public class ItemSigilToggleable extends ItemSigil implements IActivatable
|
|||
}
|
||||
}
|
||||
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package WayofTime.bloodmagic.api.incense;
|
||||
|
||||
public enum EnumTranquilityType
|
||||
{
|
||||
public enum EnumTranquilityType {
|
||||
PLANT(),
|
||||
CROP(),
|
||||
TREE(),
|
||||
|
|
|
@ -4,8 +4,7 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IIncensePath
|
||||
{
|
||||
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
|
||||
|
|
|
@ -5,7 +5,6 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface ITranquilityHandler
|
||||
{
|
||||
public interface ITranquilityHandler {
|
||||
TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state);
|
||||
}
|
||||
|
|
|
@ -8,22 +8,17 @@ import net.minecraft.world.World;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class IncenseTranquilityRegistry
|
||||
{
|
||||
public class IncenseTranquilityRegistry {
|
||||
public static List<ITranquilityHandler> handlerList = new ArrayList<ITranquilityHandler>();
|
||||
|
||||
public static void registerTranquilityHandler(ITranquilityHandler handler)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (tranq != null) {
|
||||
return tranq;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package WayofTime.bloodmagic.api.incense;
|
||||
|
||||
public class TranquilityStack
|
||||
{
|
||||
public class TranquilityStack {
|
||||
public final EnumTranquilityType type;
|
||||
public double value;
|
||||
|
||||
public TranquilityStack(EnumTranquilityType type, double value)
|
||||
{
|
||||
public TranquilityStack(EnumTranquilityType type, double value) {
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package WayofTime.bloodmagic.api.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;
|
||||
|
@ -9,12 +8,10 @@ import net.minecraft.world.World;
|
|||
|
||||
/**
|
||||
* An interface this is used purely for internal implementation.
|
||||
*
|
||||
*
|
||||
* @author WayofTime
|
||||
*
|
||||
*/
|
||||
public interface ILivingArmour
|
||||
{
|
||||
public interface ILivingArmour {
|
||||
Multimap<String, AttributeModifier> getAttributeModifiers();
|
||||
|
||||
boolean canApplyUpgrade(EntityPlayer user, LivingArmourUpgrade upgrade);
|
||||
|
@ -28,11 +25,9 @@ public interface ILivingArmour
|
|||
/**
|
||||
* 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
|
||||
*
|
||||
* @param world - The World
|
||||
* @param player - The player wearing the Armour
|
||||
*/
|
||||
void onTick(World world, EntityPlayer player);
|
||||
|
||||
|
@ -43,9 +38,8 @@ public interface ILivingArmour
|
|||
/**
|
||||
* Writes the LivingArmour to the NBTTag. This will only write the trackers
|
||||
* that are dirty.
|
||||
*
|
||||
* @param tag
|
||||
* - The NBT tag to write to
|
||||
*
|
||||
* @param tag - The NBT tag to write to
|
||||
*/
|
||||
void writeDirtyToNBT(NBTTagCompound tag);
|
||||
|
||||
|
|
|
@ -8,66 +8,53 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class LivingArmourHandler
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
public static void registerArmourUpgrade(LivingArmourUpgrade upgrade) {
|
||||
Class<? extends LivingArmourUpgrade> clazz = upgrade.getClass();
|
||||
upgradeMap.put(upgrade.getUniqueIdentifier(), clazz);
|
||||
upgradeMaxLevelMap.put(upgrade.getUniqueIdentifier(), upgrade.getMaxTier());
|
||||
try
|
||||
{
|
||||
try {
|
||||
Constructor<? extends LivingArmourUpgrade> ctor = clazz.getConstructor(int.class);
|
||||
if (ctor == null)
|
||||
{
|
||||
if (ctor == null) {
|
||||
BloodMagicAPI.logger.error("Error adding living armour upgrade {} as it doesn't have a valid constructor.", upgrade.getUniqueIdentifier());
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
upgradeConstructorMap.put(upgrade.getUniqueIdentifier(), ctor);
|
||||
}
|
||||
} catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level)
|
||||
{
|
||||
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level) {
|
||||
return generateUpgradeFromKey(key, level, null);
|
||||
}
|
||||
|
||||
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level, NBTTagCompound tag)
|
||||
{
|
||||
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level, NBTTagCompound tag) {
|
||||
Constructor<? extends LivingArmourUpgrade> ctor = upgradeConstructorMap.get(key);
|
||||
if (ctor != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ctor != null) {
|
||||
try {
|
||||
LivingArmourUpgrade upgrade = ctor.newInstance(level);
|
||||
if (upgrade != null && tag != null)
|
||||
{
|
||||
if (upgrade != null && tag != null) {
|
||||
upgrade.readFromNBT(tag);
|
||||
}
|
||||
return upgrade;
|
||||
} catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package WayofTime.bloodmagic.api.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;
|
||||
|
@ -11,8 +10,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class LivingArmourUpgrade
|
||||
{
|
||||
public abstract class LivingArmourUpgrade {
|
||||
public static String chatBase = "chat.bloodmagic.livingArmour.upgrade.";
|
||||
public static String tooltipBase = "tooltip.bloodmagic.livingArmour.upgrade.";
|
||||
|
||||
|
@ -26,38 +24,32 @@ public abstract class LivingArmourUpgrade
|
|||
* 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
|
||||
*
|
||||
* @param level The level of the upgrade
|
||||
*/
|
||||
public LivingArmourUpgrade(int level)
|
||||
{
|
||||
public LivingArmourUpgrade(int level) {
|
||||
this.level = Math.min(level, getMaxTier() - 1);
|
||||
}
|
||||
|
||||
public double getAdditionalDamageOnHit(double damage, EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon)
|
||||
{
|
||||
public double getAdditionalDamageOnHit(double damage, EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double getKnockbackOnHit(EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon)
|
||||
{
|
||||
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)
|
||||
{
|
||||
public double getArmourProtection(EntityLivingBase wearer, DamageSource source) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getUpgradeLevel()
|
||||
{
|
||||
public int getUpgradeLevel() {
|
||||
return this.level;
|
||||
}
|
||||
|
||||
|
@ -69,17 +61,14 @@ public abstract class LivingArmourUpgrade
|
|||
|
||||
public abstract int getCostOfUpgrade();
|
||||
|
||||
public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour)
|
||||
{
|
||||
public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) {
|
||||
}
|
||||
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers()
|
||||
{
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers() {
|
||||
return HashMultimap.create();
|
||||
}
|
||||
|
||||
public double getMiningSpeedModifier(EntityPlayer player)
|
||||
{
|
||||
public double getMiningSpeedModifier(EntityPlayer player) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -87,18 +76,15 @@ public abstract class LivingArmourUpgrade
|
|||
|
||||
public abstract void readFromNBT(NBTTagCompound tag);
|
||||
|
||||
public int getRunicShielding()
|
||||
{
|
||||
public int getRunicShielding() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean runOnClient()
|
||||
{
|
||||
public boolean runOnClient() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isDowngrade()
|
||||
{
|
||||
public boolean isDowngrade() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package WayofTime.bloodmagic.api.livingArmour;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
|
||||
public abstract class StatTracker
|
||||
{
|
||||
import java.util.List;
|
||||
|
||||
public abstract class StatTracker {
|
||||
private boolean isDirty = false;
|
||||
|
||||
public abstract String getUniqueIdentifier();
|
||||
|
@ -26,13 +25,10 @@ public abstract class StatTracker
|
|||
/**
|
||||
* 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
|
||||
*
|
||||
* @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);
|
||||
|
@ -43,30 +39,25 @@ public abstract class StatTracker
|
|||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @param livingArmour The equipped LivingArmour
|
||||
* @return the progress from the current level to the next level.
|
||||
*/
|
||||
public double getProgress(LivingArmour livingArmour, int currentLevel)
|
||||
{
|
||||
public double getProgress(LivingArmour livingArmour, int currentLevel) {
|
||||
return 1.0D;
|
||||
}
|
||||
|
||||
public final boolean isDirty()
|
||||
{
|
||||
public final boolean isDirty() {
|
||||
return isDirty;
|
||||
}
|
||||
|
||||
public final void markDirty()
|
||||
{
|
||||
public final void markDirty() {
|
||||
this.isDirty = true;
|
||||
}
|
||||
|
||||
public final void resetDirty()
|
||||
{
|
||||
public final void resetDirty() {
|
||||
this.isDirty = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,11 +8,10 @@ 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>
|
||||
{
|
||||
public class BloodOrb extends IForgeRegistryEntry.Impl<BloodOrb> {
|
||||
private final String name;
|
||||
private final int tier;
|
||||
private final int capacity;
|
||||
|
@ -22,33 +21,26 @@ public class BloodOrb extends IForgeRegistryEntry.Impl<BloodOrb>
|
|||
/**
|
||||
* 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.
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
public BloodOrb(String name, int tier, int capacity) {
|
||||
this.name = name;
|
||||
this.tier = tier;
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getTier()
|
||||
{
|
||||
public int getTier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
public int getCapacity()
|
||||
{
|
||||
public int getCapacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
|
@ -63,8 +55,7 @@ public class BloodOrb extends IForgeRegistryEntry.Impl<BloodOrb>
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
public String toString() {
|
||||
return "BloodOrb{" + "name='" + name + '\'' + ", tier=" + tier + ", capacity=" + capacity + ", owner=" + getRegistryName() + '}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,7 @@ import net.minecraft.item.ItemStack;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface IBloodOrb
|
||||
{
|
||||
public interface IBloodOrb {
|
||||
@Nullable
|
||||
BloodOrb getOrb(ItemStack stack);
|
||||
}
|
||||
|
|
|
@ -1,50 +1,41 @@
|
|||
package WayofTime.bloodmagic.api.recipe;
|
||||
|
||||
import WayofTime.bloodmagic.api.iface.ICustomAlchemyConsumable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import WayofTime.bloodmagic.api.iface.ICustomAlchemyConsumable;
|
||||
|
||||
public class AlchemyTableCustomRecipe extends AlchemyTableRecipe
|
||||
{
|
||||
public AlchemyTableCustomRecipe(Block result, int lpDrained, int ticksRequired, int tierRequired, Object... recipe)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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())
|
||||
{
|
||||
protected ItemStack getContainerItem(ItemStack stack) {
|
||||
if (stack.isEmpty()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
ItemStack copyStack = stack.copy();
|
||||
|
||||
if (copyStack.getItem() instanceof ICustomAlchemyConsumable)
|
||||
{
|
||||
if (copyStack.getItem() instanceof ICustomAlchemyConsumable) {
|
||||
return ((ICustomAlchemyConsumable) copyStack.getItem()).drainUseOnAlchemyCraft(copyStack);
|
||||
}
|
||||
|
||||
if (copyStack.getItem().hasContainerItem(stack))
|
||||
{
|
||||
if (copyStack.getItem().hasContainerItem(stack)) {
|
||||
return copyStack.getItem().getContainerItem(copyStack);
|
||||
}
|
||||
|
||||
copyStack.shrink(1);
|
||||
if (copyStack.isEmpty())
|
||||
{
|
||||
if (copyStack.isEmpty()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package WayofTime.bloodmagic.api.recipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -13,49 +9,42 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
public class AlchemyTableRecipe
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
for (Object in : recipe) {
|
||||
if (in instanceof ItemStack) {
|
||||
input.add(((ItemStack) in).copy());
|
||||
} else if (in instanceof Item)
|
||||
{
|
||||
} else if (in instanceof Item) {
|
||||
input.add(new ItemStack((Item) in));
|
||||
} else if (in instanceof Block)
|
||||
{
|
||||
} else if (in instanceof Block) {
|
||||
input.add(new ItemStack((Block) in));
|
||||
} else if (in instanceof String)
|
||||
{
|
||||
} else if (in instanceof String) {
|
||||
input.add(OreDictionary.getOres((String) in));
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
String ret = "Invalid alchemy recipe: ";
|
||||
for (Object tmp : recipe)
|
||||
{
|
||||
for (Object tmp : recipe) {
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += output;
|
||||
|
@ -67,8 +56,7 @@ public class AlchemyTableRecipe
|
|||
/**
|
||||
* Returns the size of the recipe area
|
||||
*/
|
||||
public int getRecipeSize()
|
||||
{
|
||||
public int getRecipeSize() {
|
||||
return input.size();
|
||||
}
|
||||
|
||||
|
@ -76,12 +64,11 @@ public class AlchemyTableRecipe
|
|||
* 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)
|
||||
{
|
||||
public ItemStack getRecipeOutput(List<ItemStack> inputList) {
|
||||
return output.copy();
|
||||
}
|
||||
|
||||
|
@ -90,42 +77,33 @@ public class AlchemyTableRecipe
|
|||
* BlockPos are for future-proofing
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean matches(List<ItemStack> checkedList, World world, BlockPos pos)
|
||||
{
|
||||
public boolean matches(List<ItemStack> checkedList, World world, BlockPos pos) {
|
||||
ArrayList<Object> required = new ArrayList<Object>(input);
|
||||
|
||||
for (ItemStack slot : checkedList)
|
||||
{
|
||||
if (!slot.isEmpty())
|
||||
{
|
||||
for (ItemStack slot : checkedList) {
|
||||
if (!slot.isEmpty()) {
|
||||
boolean inRecipe = false;
|
||||
|
||||
for (Object aRequired : required)
|
||||
{
|
||||
for (Object aRequired : required) {
|
||||
boolean match = false;
|
||||
|
||||
if (aRequired instanceof ItemStack)
|
||||
{
|
||||
if (aRequired instanceof ItemStack) {
|
||||
match = OreDictionary.itemMatches((ItemStack) aRequired, slot, false);
|
||||
} else if (aRequired instanceof List)
|
||||
{
|
||||
} else if (aRequired instanceof List) {
|
||||
Iterator<ItemStack> itr = ((List<ItemStack>) aRequired).iterator();
|
||||
while (itr.hasNext() && !match)
|
||||
{
|
||||
while (itr.hasNext() && !match) {
|
||||
match = OreDictionary.itemMatches(itr.next(), slot, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (match)
|
||||
{
|
||||
if (match) {
|
||||
inRecipe = true;
|
||||
required.remove(aRequired);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!inRecipe)
|
||||
{
|
||||
if (!inRecipe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -138,42 +116,35 @@ public class AlchemyTableRecipe
|
|||
* 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()
|
||||
{
|
||||
public List<Object> getInput() {
|
||||
return ImmutableList.copyOf(input);
|
||||
}
|
||||
|
||||
public ItemStack[] getRemainingItems(ItemStack[] inventory)
|
||||
{
|
||||
public ItemStack[] getRemainingItems(ItemStack[] inventory) {
|
||||
ItemStack[] ret = inventory.clone();
|
||||
for (int i = 0; i < ret.length; i++)
|
||||
{
|
||||
for (int i = 0; i < ret.length; i++) {
|
||||
ret[i] = getContainerItem(inventory[i]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
protected ItemStack getContainerItem(ItemStack stack)
|
||||
{
|
||||
if (stack.isEmpty())
|
||||
{
|
||||
protected ItemStack getContainerItem(ItemStack stack) {
|
||||
if (stack.isEmpty()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
ItemStack copyStack = stack.copy();
|
||||
|
||||
if (copyStack.getItem().hasContainerItem(stack))
|
||||
{
|
||||
if (copyStack.getItem().hasContainerItem(stack)) {
|
||||
return copyStack.getItem().getContainerItem(copyStack);
|
||||
}
|
||||
|
||||
copyStack.shrink(1);
|
||||
if (copyStack.isEmpty())
|
||||
{
|
||||
if (copyStack.isEmpty()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package WayofTime.bloodmagic.api.recipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -12,37 +9,31 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
|
||||
public class LivingArmourDowngradeRecipe
|
||||
{
|
||||
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)
|
||||
{
|
||||
public LivingArmourDowngradeRecipe(LivingArmourUpgrade upgrade, ItemStack keyStack, Object... recipe) {
|
||||
this.upgrade = upgrade;
|
||||
this.keyStack = keyStack;
|
||||
for (Object in : recipe)
|
||||
{
|
||||
if (in instanceof ItemStack)
|
||||
{
|
||||
for (Object in : recipe) {
|
||||
if (in instanceof ItemStack) {
|
||||
input.add(((ItemStack) in).copy());
|
||||
} else if (in instanceof Item)
|
||||
{
|
||||
} else if (in instanceof Item) {
|
||||
input.add(new ItemStack((Item) in));
|
||||
} else if (in instanceof Block)
|
||||
{
|
||||
} else if (in instanceof Block) {
|
||||
input.add(new ItemStack((Block) in));
|
||||
} else if (in instanceof String)
|
||||
{
|
||||
} else if (in instanceof String) {
|
||||
input.add(OreDictionary.getOres((String) in));
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
String ret = "Invalid living armour downgrade recipe: ";
|
||||
for (Object tmp : recipe)
|
||||
{
|
||||
for (Object tmp : recipe) {
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += upgrade.toString();
|
||||
|
@ -54,13 +45,11 @@ public class LivingArmourDowngradeRecipe
|
|||
/**
|
||||
* Returns the size of the recipe area
|
||||
*/
|
||||
public int getRecipeSize()
|
||||
{
|
||||
public int getRecipeSize() {
|
||||
return input.size();
|
||||
}
|
||||
|
||||
public LivingArmourUpgrade getRecipeOutput()
|
||||
{
|
||||
public LivingArmourUpgrade getRecipeOutput() {
|
||||
return upgrade;
|
||||
}
|
||||
|
||||
|
@ -69,49 +58,39 @@ public class LivingArmourDowngradeRecipe
|
|||
* 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))
|
||||
{
|
||||
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)
|
||||
{
|
||||
for (ItemStack slot : checkedList) {
|
||||
if (slot != null) {
|
||||
boolean inRecipe = false;
|
||||
|
||||
for (Object aRequired : required)
|
||||
{
|
||||
for (Object aRequired : required) {
|
||||
boolean match = false;
|
||||
|
||||
Object next = aRequired;
|
||||
|
||||
if (next instanceof ItemStack)
|
||||
{
|
||||
if (next instanceof ItemStack) {
|
||||
match = OreDictionary.itemMatches((ItemStack) next, slot, false);
|
||||
} else if (next instanceof List)
|
||||
{
|
||||
} else if (next instanceof List) {
|
||||
Iterator<ItemStack> itr = ((List<ItemStack>) next).iterator();
|
||||
while (itr.hasNext() && !match)
|
||||
{
|
||||
while (itr.hasNext() && !match) {
|
||||
match = OreDictionary.itemMatches(itr.next(), slot, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (match)
|
||||
{
|
||||
if (match) {
|
||||
inRecipe = true;
|
||||
required.remove(next);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!inRecipe)
|
||||
{
|
||||
if (!inRecipe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -124,57 +103,46 @@ public class LivingArmourDowngradeRecipe
|
|||
* 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()
|
||||
{
|
||||
public List<Object> getInput() {
|
||||
return ImmutableList.copyOf(input);
|
||||
}
|
||||
|
||||
public ItemStack getKey()
|
||||
{
|
||||
public ItemStack getKey() {
|
||||
return this.keyStack;
|
||||
}
|
||||
|
||||
public void consumeInventory(IItemHandler inv)
|
||||
{
|
||||
for (int i = 0; i < inv.getSlots(); i++)
|
||||
{
|
||||
public void consumeInventory(IItemHandler inv) {
|
||||
for (int i = 0; i < inv.getSlots(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if (stack.isEmpty())
|
||||
{
|
||||
if (stack.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (stack.getItem().hasContainerItem(stack))
|
||||
{
|
||||
if (stack.getItem().hasContainerItem(stack)) {
|
||||
inv.extractItem(i, stack.getCount(), false);
|
||||
inv.insertItem(i, stack.getItem().getContainerItem(stack), false);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
inv.extractItem(i, 1, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected ItemStack getContainerItem(ItemStack stack)
|
||||
{
|
||||
if (stack.isEmpty())
|
||||
{
|
||||
protected ItemStack getContainerItem(ItemStack stack) {
|
||||
if (stack.isEmpty()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
ItemStack copyStack = stack.copy();
|
||||
|
||||
if (copyStack.getItem().hasContainerItem(stack))
|
||||
{
|
||||
if (copyStack.getItem().hasContainerItem(stack)) {
|
||||
return copyStack.getItem().getContainerItem(copyStack);
|
||||
}
|
||||
|
||||
copyStack.shrink(1);
|
||||
if (copyStack.isEmpty())
|
||||
{
|
||||
if (copyStack.isEmpty()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,47 +12,36 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class TartaricForgeRecipe
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
for (Object in : recipe) {
|
||||
if (in instanceof ItemStack) {
|
||||
input.add(((ItemStack) in).copy());
|
||||
} else if (in instanceof Item)
|
||||
{
|
||||
} else if (in instanceof Item) {
|
||||
input.add(new ItemStack((Item) in));
|
||||
} else if (in instanceof Block)
|
||||
{
|
||||
} else if (in instanceof Block) {
|
||||
input.add(new ItemStack((Block) in));
|
||||
} else if (in instanceof String)
|
||||
{
|
||||
} else if (in instanceof String) {
|
||||
input.add(OreDictionary.getOres((String) in));
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
String ret = "Invalid soul forge recipe: ";
|
||||
for (Object tmp : recipe)
|
||||
{
|
||||
for (Object tmp : recipe) {
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += output;
|
||||
|
@ -64,13 +53,11 @@ public class TartaricForgeRecipe
|
|||
/**
|
||||
* Returns the size of the recipe area
|
||||
*/
|
||||
public int getRecipeSize()
|
||||
{
|
||||
public int getRecipeSize() {
|
||||
return input.size();
|
||||
}
|
||||
|
||||
public ItemStack getRecipeOutput()
|
||||
{
|
||||
public ItemStack getRecipeOutput() {
|
||||
return output.copy();
|
||||
}
|
||||
|
||||
|
@ -79,47 +66,38 @@ public class TartaricForgeRecipe
|
|||
* BlockPos are for future-proofing
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean matches(List<ItemStack> checkedList, World world, BlockPos pos)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
for (int x = 0; x < checkedList.size(); x++) {
|
||||
ItemStack slot = checkedList.get(x);
|
||||
|
||||
if (slot != null)
|
||||
{
|
||||
if (slot != null) {
|
||||
boolean inRecipe = false;
|
||||
Iterator<Object> req = required.iterator();
|
||||
|
||||
while (req.hasNext())
|
||||
{
|
||||
while (req.hasNext()) {
|
||||
boolean match = false;
|
||||
|
||||
Object next = req.next();
|
||||
|
||||
if (next instanceof ItemStack)
|
||||
{
|
||||
if (next instanceof ItemStack) {
|
||||
match = OreDictionary.itemMatches((ItemStack) next, slot, false);
|
||||
} else if (next instanceof List)
|
||||
{
|
||||
} else if (next instanceof List) {
|
||||
Iterator<ItemStack> itr = ((List<ItemStack>) next).iterator();
|
||||
while (itr.hasNext() && !match)
|
||||
{
|
||||
while (itr.hasNext() && !match) {
|
||||
match = OreDictionary.itemMatches(itr.next(), slot, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (match)
|
||||
{
|
||||
if (match) {
|
||||
inRecipe = true;
|
||||
required.remove(next);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!inRecipe)
|
||||
{
|
||||
if (!inRecipe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -132,11 +110,10 @@ public class TartaricForgeRecipe
|
|||
* 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()
|
||||
{
|
||||
public List<Object> getInput() {
|
||||
return this.input;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,25 +1,22 @@
|
|||
package WayofTime.bloodmagic.api.registry;
|
||||
|
||||
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting;
|
||||
import WayofTime.bloodmagic.api.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;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting;
|
||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
|
||||
public class AlchemyArrayRecipeRegistry
|
||||
{
|
||||
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();
|
||||
|
@ -27,42 +24,30 @@ public class AlchemyArrayRecipeRegistry
|
|||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
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())
|
||||
{
|
||||
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(input))
|
||||
{
|
||||
if (arrayRecipe.doesInputMatchRecipe(input)) {
|
||||
AlchemyArrayEffect eff = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
||||
if (eff != null)
|
||||
{
|
||||
if (eff != null) {
|
||||
return; // Recipe already exists!
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
arrayRecipe.catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
|
||||
if (circleRenderer != null)
|
||||
{
|
||||
if (arrayRecipe.defaultCircleRenderer == null)
|
||||
{
|
||||
if (circleRenderer != null) {
|
||||
if (arrayRecipe.defaultCircleRenderer == null) {
|
||||
arrayRecipe.defaultCircleRenderer = circleRenderer;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
arrayRecipe.circleMap.put(ItemStackWrapper.getHolder(catalystStack), circleRenderer);
|
||||
}
|
||||
}
|
||||
|
@ -74,63 +59,48 @@ public class AlchemyArrayRecipeRegistry
|
|||
recipes.put(input, new AlchemyArrayRecipe(input, catalystStack, arrayEffect, circleRenderer == null ? defaultRenderer : circleRenderer));
|
||||
}
|
||||
|
||||
public static AlchemyArrayEffect getAlchemyArrayEffect(String key)
|
||||
{
|
||||
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.
|
||||
* 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())
|
||||
{
|
||||
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() };
|
||||
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 };
|
||||
return new ItemStack[]{null, null};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param stack
|
||||
* of the recipe
|
||||
* @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.
|
||||
* 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())
|
||||
{
|
||||
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)
|
||||
{
|
||||
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() };
|
||||
if (!resultStack.isEmpty()) {
|
||||
if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage()) {
|
||||
return new ItemStack[]{entry.getKey().get(0), effectEntry.getKey().toStack()};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -138,123 +108,97 @@ public class AlchemyArrayRecipeRegistry
|
|||
}
|
||||
}
|
||||
|
||||
return new ItemStack[] { null, null };
|
||||
return new ItemStack[]{null, null};
|
||||
}
|
||||
|
||||
public static void registerCraftingRecipe(ItemStack input, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
public static void replaceAlchemyCircle(List<ItemStack> input, AlchemyCircleRenderer circleRenderer) {
|
||||
if (circleRenderer == null)
|
||||
return;
|
||||
|
||||
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet())
|
||||
{
|
||||
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)
|
||||
{
|
||||
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())
|
||||
{
|
||||
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))))
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (effect != null) {
|
||||
return effect.getNewCopy();
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (input.equals(arrayRecipe.getInput()))
|
||||
{
|
||||
} else {
|
||||
if (input.equals(arrayRecipe.getInput())) {
|
||||
AlchemyArrayEffect effect = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
||||
if (effect != null)
|
||||
{
|
||||
if (effect != null) {
|
||||
return effect.getNewCopy();
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -264,18 +208,14 @@ public class AlchemyArrayRecipeRegistry
|
|||
return null;
|
||||
}
|
||||
|
||||
public static AlchemyArrayEffect getAlchemyArrayEffect(ItemStack input, @Nullable ItemStack catalystStack)
|
||||
{
|
||||
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())
|
||||
{
|
||||
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))
|
||||
{
|
||||
if (arrayRecipe.doesInputMatchRecipe(input)) {
|
||||
return arrayRecipe.getAlchemyArrayRendererForCatalyst(catalystStack);
|
||||
}
|
||||
}
|
||||
|
@ -283,20 +223,21 @@ public class AlchemyArrayRecipeRegistry
|
|||
return defaultRenderer;
|
||||
}
|
||||
|
||||
public static AlchemyCircleRenderer getAlchemyCircleRenderer(ItemStack itemStack, @Nullable ItemStack catalystStack)
|
||||
{
|
||||
public static AlchemyCircleRenderer getAlchemyCircleRenderer(ItemStack itemStack, @Nullable ItemStack catalystStack) {
|
||||
return getAlchemyCircleRenderer(Collections.singletonList(itemStack), catalystStack);
|
||||
}
|
||||
|
||||
public static class AlchemyArrayRecipe
|
||||
{
|
||||
public AlchemyCircleRenderer defaultCircleRenderer;
|
||||
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)
|
||||
{
|
||||
private AlchemyArrayRecipe(List<ItemStack> input, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer, boolean useless) {
|
||||
this.input = input;
|
||||
|
||||
catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
|
||||
|
@ -304,47 +245,37 @@ public class AlchemyArrayRecipeRegistry
|
|||
this.defaultCircleRenderer = circleRenderer;
|
||||
}
|
||||
|
||||
public AlchemyArrayRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer 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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
*
|
||||
*
|
||||
* @param comparedList - The list to compare with
|
||||
* @return - True if the ItemStack(s) is a compatible item
|
||||
*/
|
||||
public boolean doesInputMatchRecipe(List<ItemStack> comparedList)
|
||||
{
|
||||
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
|
||||
*
|
||||
*
|
||||
* @param comparedStack The catalyst that is being checked
|
||||
* @return - The effect
|
||||
*/
|
||||
public AlchemyArrayEffect getAlchemyArrayEffectForCatalyst(@Nullable ItemStack comparedStack)
|
||||
{
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayEffect> entry : catalystMap.entrySet())
|
||||
{
|
||||
public AlchemyArrayEffect getAlchemyArrayEffectForCatalyst(@Nullable ItemStack comparedStack) {
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayEffect> entry : catalystMap.entrySet()) {
|
||||
ItemStack catalystStack = entry.getKey().toStack();
|
||||
|
||||
if (comparedStack == null && catalystStack == null)
|
||||
|
@ -360,10 +291,8 @@ public class AlchemyArrayRecipeRegistry
|
|||
return null;
|
||||
}
|
||||
|
||||
public AlchemyCircleRenderer getAlchemyArrayRendererForCatalyst(@Nullable ItemStack comparedStack)
|
||||
{
|
||||
for (Entry<ItemStackWrapper, AlchemyCircleRenderer> entry : circleMap.entrySet())
|
||||
{
|
||||
public AlchemyCircleRenderer getAlchemyArrayRendererForCatalyst(@Nullable ItemStack comparedStack) {
|
||||
for (Entry<ItemStackWrapper, AlchemyCircleRenderer> entry : circleMap.entrySet()) {
|
||||
ItemStack catalystStack = entry.getKey().toStack();
|
||||
|
||||
if (comparedStack == null && catalystStack == null)
|
||||
|
@ -418,9 +347,4 @@ public class AlchemyArrayRecipeRegistry
|
|||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public static BiMap<List<ItemStack>, AlchemyArrayRecipe> getRecipes()
|
||||
{
|
||||
return HashBiMap.create(recipes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,38 +1,31 @@
|
|||
package WayofTime.bloodmagic.api.registry;
|
||||
|
||||
import WayofTime.bloodmagic.api.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;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe;
|
||||
|
||||
public class AlchemyTableRecipeRegistry
|
||||
{
|
||||
public class AlchemyTableRecipeRegistry {
|
||||
private static List<AlchemyTableRecipe> recipeList = new ArrayList<AlchemyTableRecipe>();
|
||||
|
||||
public static void registerRecipe(AlchemyTableRecipe recipe)
|
||||
{
|
||||
public static void registerRecipe(AlchemyTableRecipe recipe) {
|
||||
recipeList.add(recipe);
|
||||
}
|
||||
|
||||
public static void registerRecipe(ItemStack outputStack, int lpDrained, int ticksRequired, int tierRequired, Object... objects)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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))
|
||||
{
|
||||
public static AlchemyTableRecipe getMatchingRecipe(List<ItemStack> itemList, World world, BlockPos pos) {
|
||||
for (AlchemyTableRecipe recipe : recipeList) {
|
||||
if (recipe.matches(itemList, world, pos)) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
|
@ -40,8 +33,7 @@ public class AlchemyTableRecipeRegistry
|
|||
return null;
|
||||
}
|
||||
|
||||
public static List<AlchemyTableRecipe> getRecipeList()
|
||||
{
|
||||
public static List<AlchemyTableRecipe> getRecipeList() {
|
||||
return new ArrayList<AlchemyTableRecipe>(recipeList);
|
||||
}
|
||||
}
|
|
@ -12,48 +12,41 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class AltarRecipeRegistry
|
||||
{
|
||||
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
|
||||
*
|
||||
* @param altarRecipe - The AltarRecipe to register
|
||||
*/
|
||||
public static void registerRecipe(AltarRecipe altarRecipe)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
public static AltarRecipe getRecipeForInput(List<ItemStack> input) {
|
||||
List<ItemStackWrapper> wrapperList = ItemStackWrapper.toWrapperList(input);
|
||||
if (recipes.keySet().contains(wrapperList))
|
||||
return recipes.get(wrapperList);
|
||||
|
@ -62,12 +55,9 @@ public class AltarRecipeRegistry
|
|||
}
|
||||
|
||||
//TODO: Determine a more time-effective method
|
||||
public static AltarRecipe getRecipeForInput(ItemStack input)
|
||||
{
|
||||
for (AltarRecipe recipe : recipes.values())
|
||||
{
|
||||
if (recipe.doesRequiredItemMatch(input, recipe.getMinTier()))
|
||||
{
|
||||
public static AltarRecipe getRecipeForInput(ItemStack input) {
|
||||
for (AltarRecipe recipe : recipes.values()) {
|
||||
if (recipe.doesRequiredItemMatch(input, recipe.getMinTier())) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
|
@ -75,18 +65,15 @@ public class AltarRecipeRegistry
|
|||
return null;
|
||||
}
|
||||
|
||||
public static AltarRecipe getRecipeForInput(String input)
|
||||
{
|
||||
public static AltarRecipe getRecipeForInput(String input) {
|
||||
return getRecipeForInput(OreDictionary.getOres(input));
|
||||
}
|
||||
|
||||
public static BiMap<List<ItemStackWrapper>, AltarRecipe> getRecipes()
|
||||
{
|
||||
public static BiMap<List<ItemStackWrapper>, AltarRecipe> getRecipes() {
|
||||
return HashBiMap.create(recipes);
|
||||
}
|
||||
|
||||
public static class AltarRecipe
|
||||
{
|
||||
public static class AltarRecipe {
|
||||
private final List<ItemStackWrapper> input;
|
||||
private final ItemStack output;
|
||||
private final EnumAltarTier minTier;
|
||||
|
@ -99,24 +86,16 @@ public class AltarRecipeRegistry
|
|||
* {@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
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
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;
|
||||
|
@ -126,33 +105,27 @@ public class AltarRecipeRegistry
|
|||
this.fillable = fillable;
|
||||
}
|
||||
|
||||
public AltarRecipe(List<ItemStack> input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
public boolean doesRequiredItemMatch(ItemStack comparedStack, EnumAltarTier tierCheck) {
|
||||
if (comparedStack == null || this.input == null)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -7,8 +7,7 @@ import net.minecraft.block.BlockStem;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
public class HarvestRegistry
|
||||
{
|
||||
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>();
|
||||
|
@ -17,12 +16,10 @@ public class HarvestRegistry
|
|||
|
||||
/**
|
||||
* Registers a handler for the Harvest Ritual to call.
|
||||
*
|
||||
* @param handler
|
||||
* - The custom handler to register
|
||||
*
|
||||
* @param handler - The custom handler to register
|
||||
*/
|
||||
public static void registerHandler(IHarvestHandler handler)
|
||||
{
|
||||
public static void registerHandler(IHarvestHandler handler) {
|
||||
if (!handlerList.contains(handler))
|
||||
handlerList.add(handler);
|
||||
}
|
||||
|
@ -32,15 +29,12 @@ public class HarvestRegistry
|
|||
* 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.
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
public static void registerStandardCrop(Block crop, int matureMeta) {
|
||||
if (!standardCrops.containsKey(crop))
|
||||
standardCrops.put(crop, matureMeta);
|
||||
}
|
||||
|
@ -49,12 +43,10 @@ public class HarvestRegistry
|
|||
* 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.
|
||||
*
|
||||
* @param crop - The crop block to handle.
|
||||
*/
|
||||
public static void registerTallCrop(BlockStack crop)
|
||||
{
|
||||
public static void registerTallCrop(BlockStack crop) {
|
||||
if (!tallCrops.contains(crop))
|
||||
tallCrops.add(crop);
|
||||
}
|
||||
|
@ -63,59 +55,48 @@ public class HarvestRegistry
|
|||
* 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
|
||||
*
|
||||
* @param crop - The crop block to handle.
|
||||
* @param stem - The stem of the crop
|
||||
*/
|
||||
public static void registerStemCrop(BlockStack crop, BlockStack stem)
|
||||
{
|
||||
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.
|
||||
*
|
||||
* @param blockStack - The block for the amplifier.
|
||||
* @param range - The range the amplifier provides.
|
||||
*/
|
||||
public static void registerRangeAmplifier(BlockStack blockStack, int range)
|
||||
{
|
||||
public static void registerRangeAmplifier(BlockStack blockStack, int range) {
|
||||
if (!amplifierMap.containsKey(blockStack))
|
||||
amplifierMap.put(blockStack, range);
|
||||
}
|
||||
|
||||
public static List<IHarvestHandler> getHandlerList()
|
||||
{
|
||||
public static List<IHarvestHandler> getHandlerList() {
|
||||
return new ArrayList<IHarvestHandler>(handlerList);
|
||||
}
|
||||
|
||||
public static Map<Block, Integer> getStandardCrops()
|
||||
{
|
||||
public static Map<Block, Integer> getStandardCrops() {
|
||||
return new HashMap<Block, Integer>(standardCrops);
|
||||
}
|
||||
|
||||
public static Set<BlockStack> getTallCrops()
|
||||
{
|
||||
public static Set<BlockStack> getTallCrops() {
|
||||
return new HashSet<BlockStack>(tallCrops);
|
||||
}
|
||||
|
||||
public static Map<BlockStack, BlockStack> getStemCrops()
|
||||
{
|
||||
public static Map<BlockStack, BlockStack> getStemCrops() {
|
||||
return new HashMap<BlockStack, BlockStack>(stemCrops);
|
||||
}
|
||||
|
||||
public static Map<BlockStack, Integer> getAmplifierMap()
|
||||
{
|
||||
public static Map<BlockStack, Integer> getAmplifierMap() {
|
||||
return new HashMap<BlockStack, Integer>(amplifierMap);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,50 +10,40 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ImperfectRitualRegistry
|
||||
{
|
||||
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.
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
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
|
||||
{
|
||||
else {
|
||||
registry.put(id, imperfectRitual);
|
||||
enabledRituals.put(imperfectRitual, enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerRitual(ImperfectRitual imperfectRitual, String id)
|
||||
{
|
||||
public static void registerRitual(ImperfectRitual imperfectRitual, String id) {
|
||||
registerRitual(imperfectRitual, id, true);
|
||||
}
|
||||
|
||||
public static void registerRitual(ImperfectRitual imperfectRitual, boolean enabled)
|
||||
{
|
||||
public static void registerRitual(ImperfectRitual imperfectRitual, boolean enabled) {
|
||||
registerRitual(imperfectRitual, imperfectRitual.getName(), enabled);
|
||||
}
|
||||
|
||||
public static void registerRitual(ImperfectRitual imperfectRitual)
|
||||
{
|
||||
public static void registerRitual(ImperfectRitual imperfectRitual) {
|
||||
registerRitual(imperfectRitual, imperfectRitual.getName());
|
||||
}
|
||||
|
||||
public static ImperfectRitual getRitualForBlock(BlockStack blockStack)
|
||||
{
|
||||
public static ImperfectRitual getRitualForBlock(BlockStack blockStack) {
|
||||
for (ImperfectRitual imperfectRitual : getRegistry().values())
|
||||
if (imperfectRitual.getRequiredBlock().equals(blockStack))
|
||||
return imperfectRitual;
|
||||
|
@ -61,60 +51,48 @@ public class ImperfectRitualRegistry
|
|||
return null;
|
||||
}
|
||||
|
||||
public static ImperfectRitual getRitualForId(String id)
|
||||
{
|
||||
public static ImperfectRitual getRitualForId(String id) {
|
||||
return registry.get(id);
|
||||
}
|
||||
|
||||
public static String getIdForRitual(ImperfectRitual imperfectRitual)
|
||||
{
|
||||
public static String getIdForRitual(ImperfectRitual imperfectRitual) {
|
||||
return registry.inverse().get(imperfectRitual);
|
||||
}
|
||||
|
||||
public static boolean isMapEmpty()
|
||||
{
|
||||
public static boolean isMapEmpty() {
|
||||
return registry.isEmpty();
|
||||
}
|
||||
|
||||
public static int getMapSize()
|
||||
{
|
||||
public static int getMapSize() {
|
||||
return registry.size();
|
||||
}
|
||||
|
||||
public static boolean ritualEnabled(ImperfectRitual imperfectRitual)
|
||||
{
|
||||
try
|
||||
{
|
||||
public static boolean ritualEnabled(ImperfectRitual imperfectRitual) {
|
||||
try {
|
||||
return enabledRituals.get(imperfectRitual);
|
||||
} catch (NullPointerException e)
|
||||
{
|
||||
} catch (NullPointerException e) {
|
||||
BloodMagicAPI.logger.error("Invalid Imperfect Ritual was called");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean ritualEnabled(String id)
|
||||
{
|
||||
public static boolean ritualEnabled(String id) {
|
||||
return ritualEnabled(getRitualForId(id));
|
||||
}
|
||||
|
||||
public static BiMap<String, ImperfectRitual> getRegistry()
|
||||
{
|
||||
public static BiMap<String, ImperfectRitual> getRegistry() {
|
||||
return HashBiMap.create(registry);
|
||||
}
|
||||
|
||||
public static BiMap<ImperfectRitual, Boolean> getEnabledMap()
|
||||
{
|
||||
public static BiMap<ImperfectRitual, Boolean> getEnabledMap() {
|
||||
return HashBiMap.create(enabledRituals);
|
||||
}
|
||||
|
||||
public static ArrayList<String> getIds()
|
||||
{
|
||||
public static ArrayList<String> getIds() {
|
||||
return new ArrayList<String>(registry.keySet());
|
||||
}
|
||||
|
||||
public static ArrayList<ImperfectRitual> getRituals()
|
||||
{
|
||||
public static ArrayList<ImperfectRitual> getRituals() {
|
||||
return new ArrayList<ImperfectRitual>(registry.values());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,44 +1,37 @@
|
|||
package WayofTime.bloodmagic.api.registry;
|
||||
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.api.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;
|
||||
|
||||
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 WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.api.recipe.LivingArmourDowngradeRecipe;
|
||||
|
||||
public class LivingArmourDowngradeRecipeRegistry
|
||||
{
|
||||
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)
|
||||
{
|
||||
public static void registerRecipe(LivingArmourDowngradeRecipe recipe) {
|
||||
recipeList.add(recipe);
|
||||
}
|
||||
|
||||
public static void registerDialog(ItemStack keyStack, Map<Integer, List<ITextComponent>> map)
|
||||
{
|
||||
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())
|
||||
{
|
||||
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))
|
||||
{
|
||||
if (OreDictionary.itemMatches(key, keyStack, false)) {
|
||||
Map<Integer, List<ITextComponent>> map = entry.getValue();
|
||||
if (map.containsKey(tick))
|
||||
{
|
||||
if (map.containsKey(tick)) {
|
||||
return map.get(tick);
|
||||
}
|
||||
}
|
||||
|
@ -47,17 +40,13 @@ public class LivingArmourDowngradeRecipeRegistry
|
|||
return null;
|
||||
}
|
||||
|
||||
public static void registerRecipe(LivingArmourUpgrade upgrade, ItemStack keyStack, Object... recipe)
|
||||
{
|
||||
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))
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -65,8 +54,7 @@ public class LivingArmourDowngradeRecipeRegistry
|
|||
return null;
|
||||
}
|
||||
|
||||
public static List<LivingArmourDowngradeRecipe> getRecipeList()
|
||||
{
|
||||
public static List<LivingArmourDowngradeRecipe> getRecipeList() {
|
||||
return new ArrayList<LivingArmourDowngradeRecipe>(recipeList);
|
||||
}
|
||||
}
|
|
@ -17,24 +17,20 @@ import java.util.List;
|
|||
* custom handling, you will need your own item class.
|
||||
*/
|
||||
@Deprecated
|
||||
public class OrbRegistry
|
||||
{
|
||||
private static List<BloodOrb> orbs = new ArrayList<BloodOrb>();
|
||||
public static ArrayListMultimap<Integer, ItemStack> tierMap = ArrayListMultimap.create();
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
public static List<ItemStack> getOrbsUpToTier(int tier) {
|
||||
List<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
|
||||
for (int i = 1; i <= tier; i++)
|
||||
|
@ -43,8 +39,7 @@ public class OrbRegistry
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static List<ItemStack> getOrbsDownToTier(int tier)
|
||||
{
|
||||
public static List<ItemStack> getOrbsDownToTier(int tier) {
|
||||
List<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
|
||||
for (int i = EnumAltarTier.MAXTIERS; i >= tier; i--)
|
||||
|
@ -53,8 +48,7 @@ public class OrbRegistry
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static ItemStack getOrbStack(BloodOrb orb)
|
||||
{
|
||||
public static ItemStack getOrbStack(BloodOrb orb) {
|
||||
ItemStack ret = new ItemStack(ORB_ITEM);
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setString("orb", orb.getRegistryName().toString());
|
||||
|
@ -62,8 +56,7 @@ public class OrbRegistry
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static ArrayListMultimap<Integer, ItemStack> getTierMap()
|
||||
{
|
||||
public static ArrayListMultimap<Integer, ItemStack> getTierMap() {
|
||||
return ArrayListMultimap.create(tierMap);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,7 @@ import com.google.common.collect.HashBiMap;
|
|||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
public class RitualRegistry
|
||||
{
|
||||
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>();
|
||||
|
@ -23,27 +22,21 @@ public class RitualRegistry
|
|||
|
||||
/**
|
||||
* The safe way to register a new Ritual.
|
||||
*
|
||||
* @param ritual
|
||||
* - The ritual to register.
|
||||
* @param id
|
||||
* - The ID for the ritual. Cannot be duplicated.
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
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 (ritual != null) {
|
||||
if (registry.containsKey(id))
|
||||
BloodMagicAPI.logger.error("Duplicate ritual id: %s", id);
|
||||
else
|
||||
{
|
||||
else {
|
||||
registry.put(id, ritual);
|
||||
enabledRituals.put(ritual, enabled);
|
||||
orderedIdList.add(id);
|
||||
|
@ -51,95 +44,76 @@ public class RitualRegistry
|
|||
}
|
||||
}
|
||||
|
||||
public static void registerRitual(Ritual ritual, boolean enabled)
|
||||
{
|
||||
public static void registerRitual(Ritual ritual, boolean enabled) {
|
||||
registerRitual(ritual, ritual.getName(), enabled);
|
||||
}
|
||||
|
||||
public static void registerRitual(Ritual ritual, String id)
|
||||
{
|
||||
public static void registerRitual(Ritual ritual, String id) {
|
||||
registerRitual(ritual, id, true);
|
||||
}
|
||||
|
||||
public static void registerRitual(Ritual ritual)
|
||||
{
|
||||
public static void registerRitual(Ritual ritual) {
|
||||
registerRitual(ritual, ritual.getName());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Ritual getRitualForId(String id)
|
||||
{
|
||||
public static Ritual getRitualForId(String id) {
|
||||
Ritual ritual = registry.get(id);
|
||||
return ritual != null ? ritual.getNewCopy() : null;
|
||||
}
|
||||
|
||||
public static String getIdForRitual(Ritual ritual)
|
||||
{
|
||||
public static String getIdForRitual(Ritual ritual) {
|
||||
return registry.inverse().get(ritual);
|
||||
}
|
||||
|
||||
public static boolean isMapEmpty()
|
||||
{
|
||||
public static boolean isMapEmpty() {
|
||||
return registry.isEmpty();
|
||||
}
|
||||
|
||||
public static int getMapSize()
|
||||
{
|
||||
public static int getMapSize() {
|
||||
return registry.size();
|
||||
}
|
||||
|
||||
public static boolean ritualEnabled(Ritual ritual)
|
||||
{
|
||||
try
|
||||
{
|
||||
public static boolean ritualEnabled(Ritual ritual) {
|
||||
try {
|
||||
return enabledRituals.get(ritual);
|
||||
} catch (NullPointerException e)
|
||||
{
|
||||
} catch (NullPointerException e) {
|
||||
BloodMagicAPI.logger.error("Invalid Ritual was called");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean ritualEnabled(String id)
|
||||
{
|
||||
public static boolean ritualEnabled(String id) {
|
||||
return ritualEnabled(getRitualForId(id));
|
||||
}
|
||||
|
||||
public static BiMap<String, Ritual> getRegistry()
|
||||
{
|
||||
public static BiMap<String, Ritual> getRegistry() {
|
||||
return HashBiMap.create(registry);
|
||||
}
|
||||
|
||||
public static Map<Ritual, Boolean> getEnabledMap()
|
||||
{
|
||||
public static Map<Ritual, Boolean> getEnabledMap() {
|
||||
return new HashMap<Ritual, Boolean>(enabledRituals);
|
||||
}
|
||||
|
||||
public static ArrayList<String> getIds()
|
||||
{
|
||||
public static ArrayList<String> getIds() {
|
||||
return new ArrayList<String>(lookupList);
|
||||
}
|
||||
|
||||
public static ArrayList<String> getOrderedIds()
|
||||
{
|
||||
public static ArrayList<String> getOrderedIds() {
|
||||
return orderedIdList;
|
||||
}
|
||||
|
||||
public static ArrayList<Ritual> getRituals()
|
||||
{
|
||||
public static ArrayList<Ritual> getRituals() {
|
||||
return new ArrayList<Ritual>(registry.values());
|
||||
}
|
||||
|
||||
public static void orderLookupList()
|
||||
{
|
||||
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>()
|
||||
{
|
||||
Collections.sort(lookupList, new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String o1, String o2)
|
||||
{
|
||||
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
|
||||
|
|
|
@ -8,31 +8,24 @@ import net.minecraft.world.World;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TartaricForgeRecipeRegistry
|
||||
{
|
||||
public class TartaricForgeRecipeRegistry {
|
||||
private static List<TartaricForgeRecipe> recipeList = new ArrayList<TartaricForgeRecipe>();
|
||||
|
||||
public static void registerRecipe(TartaricForgeRecipe recipe)
|
||||
{
|
||||
public static void registerRecipe(TartaricForgeRecipe recipe) {
|
||||
recipeList.add(recipe);
|
||||
}
|
||||
|
||||
public static void registerRecipe(ItemStack outputStack, double minimulSouls, double drain, Object... objects)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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))
|
||||
{
|
||||
public static TartaricForgeRecipe getMatchingRecipe(List<ItemStack> itemList, World world, BlockPos pos) {
|
||||
for (TartaricForgeRecipe recipe : recipeList) {
|
||||
if (recipe.matches(itemList, world, pos)) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
|
@ -40,8 +33,7 @@ public class TartaricForgeRecipeRegistry
|
|||
return null;
|
||||
}
|
||||
|
||||
public static List<TartaricForgeRecipe> getRecipeList()
|
||||
{
|
||||
public static List<TartaricForgeRecipe> getRecipeList() {
|
||||
return new ArrayList<TartaricForgeRecipe>(recipeList);
|
||||
}
|
||||
}
|
|
@ -1,26 +1,23 @@
|
|||
package WayofTime.bloodmagic.api.ritual;
|
||||
|
||||
import WayofTime.bloodmagic.api.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;
|
||||
|
||||
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 WayofTime.bloodmagic.api.Constants;
|
||||
|
||||
public abstract class AreaDescriptor implements Iterator<BlockPos>
|
||||
{
|
||||
public List<BlockPos> getContainedPositions(BlockPos pos)
|
||||
{
|
||||
public abstract class AreaDescriptor implements Iterator<BlockPos> {
|
||||
public List<BlockPos> getContainedPositions(BlockPos pos) {
|
||||
return new ArrayList<BlockPos>();
|
||||
}
|
||||
|
||||
public AxisAlignedBB getAABB(BlockPos pos)
|
||||
{
|
||||
public AxisAlignedBB getAABB(BlockPos pos) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -30,13 +27,11 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
|
||||
public abstract void resetIterator();
|
||||
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -52,7 +47,7 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
* 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
|
||||
*/
|
||||
|
@ -64,8 +59,7 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
|
||||
public abstract AreaDescriptor rotateDescriptor(PlacementSettings settings);
|
||||
|
||||
public static class Rectangle extends AreaDescriptor
|
||||
{
|
||||
public static class Rectangle extends AreaDescriptor {
|
||||
protected BlockPos minimumOffset;
|
||||
protected BlockPos maximumOffset; // Non-inclusive maximum offset.
|
||||
private BlockPos currentPosition;
|
||||
|
@ -79,40 +73,30 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
* 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
|
||||
* -
|
||||
*
|
||||
* @param minimumOffset -
|
||||
* @param maximumOffset -
|
||||
*/
|
||||
public Rectangle(BlockPos minimumOffset, BlockPos maximumOffset)
|
||||
{
|
||||
public Rectangle(BlockPos minimumOffset, BlockPos maximumOffset) {
|
||||
setOffsets(minimumOffset, maximumOffset);
|
||||
}
|
||||
|
||||
public Rectangle(BlockPos minimumOffset, int sizeX, int sizeY, int sizeZ)
|
||||
{
|
||||
public Rectangle(BlockPos minimumOffset, int sizeX, int sizeY, int sizeZ) {
|
||||
this(minimumOffset, minimumOffset.add(sizeX, sizeY, sizeZ));
|
||||
}
|
||||
|
||||
public Rectangle(BlockPos minimumOffset, int size)
|
||||
{
|
||||
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())
|
||||
{
|
||||
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++)
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -126,8 +110,7 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getAABB(BlockPos pos)
|
||||
{
|
||||
public AxisAlignedBB getAABB(BlockPos pos) {
|
||||
AxisAlignedBB tempAABB = new AxisAlignedBB(minimumOffset, maximumOffset);
|
||||
return tempAABB.offset(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
@ -135,28 +118,23 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
/**
|
||||
* Sets the offsets of the AreaDescriptor in a safe way that will make
|
||||
* minimumOffset the lowest corner
|
||||
*
|
||||
* @param offset1
|
||||
* -
|
||||
* @param offset2
|
||||
* -
|
||||
*
|
||||
* @param offset1 -
|
||||
* @param offset2 -
|
||||
*/
|
||||
public void setOffsets(BlockPos offset1, BlockPos 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()
|
||||
{
|
||||
public void resetCache() {
|
||||
this.blockPosCache = new ArrayList<BlockPos>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinArea(BlockPos pos)
|
||||
{
|
||||
public boolean isWithinArea(BlockPos pos) {
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
@ -165,22 +143,18 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
} else {
|
||||
currentPosition = minimumOffset;
|
||||
}
|
||||
|
||||
|
@ -188,20 +162,17 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
public void remove() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetIterator()
|
||||
{
|
||||
public void resetIterator() {
|
||||
currentPosition = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2)
|
||||
{
|
||||
public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2) {
|
||||
setOffsets(pos1, pos2);
|
||||
maximumOffset = maximumOffset.add(1, 1, 1);
|
||||
resetIterator();
|
||||
|
@ -209,15 +180,13 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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());
|
||||
|
@ -227,8 +196,7 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getVolumeForOffsets(BlockPos offset1, BlockPos offset2)
|
||||
{
|
||||
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()));
|
||||
|
||||
|
@ -238,8 +206,7 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit)
|
||||
{
|
||||
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()));
|
||||
|
||||
|
@ -247,22 +214,18 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getVolume()
|
||||
{
|
||||
public int getVolume() {
|
||||
return (maximumOffset.getX() - minimumOffset.getX()) * (maximumOffset.getY() - minimumOffset.getY()) * (maximumOffset.getZ() - minimumOffset.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinRange(int verticalLimit, int horizontalLimit)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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());
|
||||
|
@ -272,14 +235,12 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
}
|
||||
|
||||
@Override
|
||||
public AreaDescriptor offset(BlockPos offset)
|
||||
{
|
||||
public AreaDescriptor offset(BlockPos offset) {
|
||||
return new AreaDescriptor.Rectangle(this.minimumOffset.add(offset), this.maximumOffset.add(offset));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AreaDescriptor rotateDescriptor(PlacementSettings settings)
|
||||
{
|
||||
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!
|
||||
|
||||
|
@ -290,8 +251,7 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
}
|
||||
}
|
||||
|
||||
public static class HemiSphere extends AreaDescriptor
|
||||
{
|
||||
public static class HemiSphere extends AreaDescriptor {
|
||||
private BlockPos minimumOffset;
|
||||
private int radius;
|
||||
|
||||
|
@ -300,23 +260,19 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
|
||||
private boolean cache = true;
|
||||
|
||||
public HemiSphere(BlockPos minimumOffset, int radius)
|
||||
{
|
||||
public HemiSphere(BlockPos minimumOffset, int radius) {
|
||||
setRadius(minimumOffset, radius);
|
||||
}
|
||||
|
||||
public void setRadius(BlockPos minimumOffset, int 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())
|
||||
{
|
||||
public List<BlockPos> getContainedPositions(BlockPos pos) {
|
||||
if (!cache || !pos.equals(cachedPosition) || blockPosCache.isEmpty()) {
|
||||
ArrayList<BlockPos> posList = new ArrayList<BlockPos>();
|
||||
|
||||
int i = -radius;
|
||||
|
@ -325,14 +281,10 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
|
||||
//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))
|
||||
{
|
||||
while (i <= radius) {
|
||||
while (j <= radius) {
|
||||
while (k <= radius) {
|
||||
if (i * i + j * j + k * k >= (radius + 0.5F) * (radius + 0.5F)) {
|
||||
k++;
|
||||
continue;
|
||||
}
|
||||
|
@ -360,98 +312,82 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
* Since you can't make a box using a sphere, this returns null
|
||||
*/
|
||||
@Override
|
||||
public AxisAlignedBB getAABB(BlockPos pos)
|
||||
{
|
||||
public AxisAlignedBB getAABB(BlockPos pos) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetCache()
|
||||
{
|
||||
public void resetCache() {
|
||||
this.blockPosCache = new ArrayList<BlockPos>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinArea(BlockPos pos)
|
||||
{
|
||||
public boolean isWithinArea(BlockPos pos) {
|
||||
return blockPosCache.contains(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
public boolean hasNext() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos next()
|
||||
{
|
||||
public BlockPos next() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
public void remove() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetIterator()
|
||||
{
|
||||
public void resetIterator() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2)
|
||||
{
|
||||
public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVolumeForOffsets(BlockPos pos1, BlockPos pos2)
|
||||
{
|
||||
public int getVolumeForOffsets(BlockPos pos1, BlockPos pos2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit)
|
||||
{
|
||||
public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVolume()
|
||||
{
|
||||
public int getVolume() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinRange(int verticalLimit, int horizontalLimit)
|
||||
{
|
||||
public boolean isWithinRange(int verticalLimit, int horizontalLimit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean intersects(AreaDescriptor descriptor)
|
||||
{
|
||||
public boolean intersects(AreaDescriptor descriptor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AreaDescriptor offset(BlockPos offset)
|
||||
{
|
||||
public AreaDescriptor offset(BlockPos offset) {
|
||||
return new AreaDescriptor.HemiSphere(minimumOffset.add(offset), radius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AreaDescriptor rotateDescriptor(PlacementSettings settings)
|
||||
{
|
||||
public AreaDescriptor rotateDescriptor(PlacementSettings settings) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Cross extends AreaDescriptor
|
||||
{
|
||||
public static class Cross extends AreaDescriptor {
|
||||
|
||||
private ArrayList<BlockPos> blockPosCache;
|
||||
private BlockPos cachedPosition;
|
||||
|
@ -461,23 +397,19 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
|
||||
private boolean cache = true;
|
||||
|
||||
public Cross(BlockPos center, int size)
|
||||
{
|
||||
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())
|
||||
{
|
||||
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++)
|
||||
{
|
||||
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));
|
||||
|
@ -491,86 +423,72 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void resetCache()
|
||||
{
|
||||
public void resetCache() {
|
||||
blockPosCache = new ArrayList<BlockPos>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinArea(BlockPos pos)
|
||||
{
|
||||
public boolean isWithinArea(BlockPos pos) {
|
||||
return blockPosCache.contains(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
public boolean hasNext() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos next()
|
||||
{
|
||||
public BlockPos next() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
public void remove() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetIterator()
|
||||
{
|
||||
public void resetIterator() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2)
|
||||
{
|
||||
public void modifyAreaByBlockPositions(BlockPos pos1, BlockPos pos2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVolumeForOffsets(BlockPos pos1, BlockPos pos2)
|
||||
{
|
||||
public int getVolumeForOffsets(BlockPos pos1, BlockPos pos2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit)
|
||||
{
|
||||
public boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVolume()
|
||||
{
|
||||
public int getVolume() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWithinRange(int verticalLimit, int horizontalLimit)
|
||||
{
|
||||
public boolean isWithinRange(int verticalLimit, int horizontalLimit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean intersects(AreaDescriptor descriptor)
|
||||
{
|
||||
public boolean intersects(AreaDescriptor descriptor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AreaDescriptor offset(BlockPos offset)
|
||||
{
|
||||
public AreaDescriptor offset(BlockPos offset) {
|
||||
return new AreaDescriptor.Cross(centerPos.add(offset), size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AreaDescriptor rotateDescriptor(PlacementSettings settings)
|
||||
{
|
||||
public AreaDescriptor rotateDescriptor(PlacementSettings settings) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,50 +7,40 @@ import net.minecraftforge.common.capabilities.Capability;
|
|||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public final class CapabilityRuneType
|
||||
{
|
||||
public static class RuneTypeStorage implements Capability.IStorage<IRitualStone.Tile>
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
public static class RuneTypeWrapper implements IRitualStone.Tile {
|
||||
private EnumRuneType type = EnumRuneType.BLANK;
|
||||
|
||||
@Override
|
||||
public boolean isRuneType(EnumRuneType runeType)
|
||||
{
|
||||
public boolean isRuneType(EnumRuneType runeType) {
|
||||
return type == runeType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRuneType getRuneType()
|
||||
{
|
||||
public EnumRuneType getRuneType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setRuneType(EnumRuneType runeType)
|
||||
{
|
||||
public void setRuneType(EnumRuneType runeType) {
|
||||
type = runeType;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Factory implements Callable<IRitualStone.Tile>
|
||||
{
|
||||
public static class Factory implements Callable<IRitualStone.Tile> {
|
||||
@Override
|
||||
public IRitualStone.Tile call() throws Exception
|
||||
{
|
||||
public IRitualStone.Tile call() throws Exception {
|
||||
return new RuneTypeWrapper();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package WayofTime.bloodmagic.api.ritual;
|
||||
|
||||
public enum EnumRitualReaderState
|
||||
{
|
||||
public enum EnumRitualReaderState {
|
||||
SET_AREA,
|
||||
INFORMATION,
|
||||
SET_WILL_TYPES;
|
||||
|
|
|
@ -9,8 +9,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
|||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumRuneType implements IStringSerializable
|
||||
{
|
||||
public enum EnumRuneType implements IStringSerializable {
|
||||
BLANK(TextFormatting.GRAY),
|
||||
WATER(TextFormatting.AQUA),
|
||||
FIRE(TextFormatting.RED),
|
||||
|
@ -24,34 +23,29 @@ public enum EnumRuneType implements IStringSerializable
|
|||
|
||||
public final TextFormatting colorCode;
|
||||
|
||||
EnumRuneType(TextFormatting colorCode)
|
||||
{
|
||||
EnumRuneType(TextFormatting colorCode) {
|
||||
this.colorCode = colorCode;
|
||||
}
|
||||
|
||||
public static EnumRuneType byMetadata(int meta)
|
||||
{
|
||||
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];
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,22 +1,21 @@
|
|||
package WayofTime.bloodmagic.api.ritual;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.api.saving.SoulNetwork;
|
||||
import WayofTime.bloodmagic.api.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 WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
|
||||
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
|
||||
{
|
||||
public interface IMasterRitualStone {
|
||||
String getOwner();
|
||||
|
||||
SoulNetwork getOwnerNetwork();
|
||||
|
|
|
@ -5,17 +5,15 @@ 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
|
||||
{
|
||||
public interface IRitualStone {
|
||||
boolean isRuneType(World world, BlockPos pos, EnumRuneType runeType);
|
||||
|
||||
void setRuneType(World world, BlockPos pos, EnumRuneType runeType);
|
||||
|
||||
interface Tile
|
||||
{
|
||||
interface Tile {
|
||||
boolean isRuneType(EnumRuneType runeType);
|
||||
|
||||
EnumRuneType getRuneType();
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package WayofTime.bloodmagic.api.ritual;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import WayofTime.bloodmagic.api.soul.DemonWillHolder;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -14,29 +11,30 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.soul.DemonWillHolder;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
||||
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.api.registry.RitualRegistry#registerRitual(Ritual, String)}
|
||||
*/
|
||||
public abstract class Ritual
|
||||
{
|
||||
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;
|
||||
|
||||
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>();
|
||||
|
||||
public Ritual(String name, int crystalLevel, int activationCost, RitualRenderer renderer, String unlocalizedName) {
|
||||
this.name = name;
|
||||
this.crystalLevel = crystalLevel;
|
||||
|
@ -46,46 +44,36 @@ public abstract class Ritual
|
|||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* - The name of the ritual
|
||||
* @param crystalLevel
|
||||
* - Required Activation Crystal tier
|
||||
* @param activationCost
|
||||
* - Base LP cost for activating the ritual
|
||||
* @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)
|
||||
{
|
||||
public Ritual(String name, int crystalLevel, int activationCost, String unlocalizedName) {
|
||||
this(name, crystalLevel, activationCost, null, unlocalizedName);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
NBTTagList tags = tag.getTagList("areas", 10);
|
||||
if (tags.hasNoTags())
|
||||
{
|
||||
if (tags.hasNoTags()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < tags.tagCount(); i++)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (desc != null) {
|
||||
desc.readFromNBT(storedTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
NBTTagList tags = new NBTTagList();
|
||||
|
||||
for (Entry<String, AreaDescriptor> entry : modableRangeMap.entrySet())
|
||||
{
|
||||
for (Entry<String, AreaDescriptor> entry : modableRangeMap.entrySet()) {
|
||||
NBTTagCompound newTag = new NBTTagCompound();
|
||||
newTag.setString("key", entry.getKey());
|
||||
NBTTagCompound storedTag = new NBTTagCompound();
|
||||
|
@ -102,52 +90,44 @@ public abstract class Ritual
|
|||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
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
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
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();
|
||||
|
@ -155,64 +135,52 @@ public abstract class Ritual
|
|||
/**
|
||||
* 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()
|
||||
{
|
||||
public int getRefreshTime() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
public void addBlockRange(String range, AreaDescriptor defaultRange)
|
||||
{
|
||||
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.
|
||||
*
|
||||
* @param range - Range that needs to be pulled.
|
||||
* @return -
|
||||
*/
|
||||
public AreaDescriptor getBlockRange(String range)
|
||||
{
|
||||
if (modableRangeMap.containsKey(range))
|
||||
{
|
||||
public AreaDescriptor getBlockRange(String range) {
|
||||
if (modableRangeMap.containsKey(range)) {
|
||||
return modableRangeMap.get(range);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<String> getListOfRanges()
|
||||
{
|
||||
public List<String> getListOfRanges() {
|
||||
return new ArrayList<String>(modableRangeMap.keySet());
|
||||
}
|
||||
|
||||
public String getNextBlockRange(String range)
|
||||
{
|
||||
public String getNextBlockRange(String range) {
|
||||
List<String> rangeList = getListOfRanges();
|
||||
|
||||
if (rangeList.isEmpty())
|
||||
{
|
||||
if (rangeList.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (!rangeList.contains(range))
|
||||
{
|
||||
if (!rangeList.contains(range)) {
|
||||
return rangeList.get(0);
|
||||
}
|
||||
|
||||
boolean hasMatch = false;
|
||||
|
||||
for (String rangeCheck : rangeList)
|
||||
{
|
||||
if (hasMatch)
|
||||
{
|
||||
for (String rangeCheck : rangeList) {
|
||||
if (hasMatch) {
|
||||
return rangeCheck;
|
||||
} else if (rangeCheck.equals(range))
|
||||
{
|
||||
} else if (rangeCheck.equals(range)) {
|
||||
hasMatch = true;
|
||||
}
|
||||
}
|
||||
|
@ -220,14 +188,12 @@ public abstract class Ritual
|
|||
return rangeList.get(0);
|
||||
}
|
||||
|
||||
public boolean setBlockRangeByBounds(String range, IMasterRitualStone master, BlockPos offset1, BlockPos offset2)
|
||||
{
|
||||
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))
|
||||
{
|
||||
if (canBlockRangeBeModified(range, descriptor, master, offset1, offset2, holder)) {
|
||||
descriptor.modifyAreaByBlockPositions(offset1, offset2);
|
||||
return true;
|
||||
}
|
||||
|
@ -235,8 +201,7 @@ public abstract class Ritual
|
|||
return false;
|
||||
}
|
||||
|
||||
protected boolean canBlockRangeBeModified(String range, AreaDescriptor descriptor, IMasterRitualStone master, BlockPos offset1, BlockPos offset2, DemonWillHolder holder)
|
||||
{
|
||||
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);
|
||||
|
@ -245,38 +210,31 @@ public abstract class Ritual
|
|||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
public int getMaxVolumeForRange(String range, List<EnumDemonWillType> activeTypes, DemonWillHolder holder) {
|
||||
return volumeRangeMap.get(range);
|
||||
}
|
||||
|
||||
public int getMaxVerticalRadiusForRange(String range, List<EnumDemonWillType> activeTypes, DemonWillHolder holder)
|
||||
{
|
||||
public int getMaxVerticalRadiusForRange(String range, List<EnumDemonWillType> activeTypes, DemonWillHolder holder) {
|
||||
return verticalRangeMap.get(range);
|
||||
}
|
||||
|
||||
public int getMaxHorizontalRadiusForRange(String range, List<EnumDemonWillType> activeTypes, DemonWillHolder holder)
|
||||
{
|
||||
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)
|
||||
{
|
||||
public ITextComponent getErrorForBlockRangeOnFail(EntityPlayer player, String range, IMasterRitualStone master, BlockPos offset1, BlockPos offset2) {
|
||||
AreaDescriptor descriptor = this.getBlockRange(range);
|
||||
if (descriptor == null)
|
||||
{
|
||||
if (descriptor == null) {
|
||||
return new TextComponentTranslation("ritual.bloodmagic.blockRange.tooBig", "?");
|
||||
}
|
||||
|
||||
|
@ -287,27 +245,21 @@ public abstract class Ritual
|
|||
int maxVertical = this.getMaxVerticalRadiusForRange(range, willConfig, holder);
|
||||
int maxHorizontal = this.getMaxHorizontalRadiusForRange(range, willConfig, holder);
|
||||
|
||||
if (maxVolume > 0 && descriptor.getVolumeForOffsets(offset1, offset2) > maxVolume)
|
||||
{
|
||||
if (maxVolume > 0 && descriptor.getVolumeForOffsets(offset1, offset2) > maxVolume) {
|
||||
return new TextComponentTranslation("ritual.bloodmagic.blockRange.tooBig", maxVolume);
|
||||
} else
|
||||
{
|
||||
} 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[] provideInformationOfRitualToPlayer(EntityPlayer player) {
|
||||
return new ITextComponent[]{new TextComponentTranslation(this.getUnlocalizedName() + ".info")};
|
||||
}
|
||||
|
||||
public ITextComponent provideInformationOfRangeToPlayer(EntityPlayer player, String range)
|
||||
{
|
||||
if (getListOfRanges().contains(range))
|
||||
{
|
||||
public ITextComponent provideInformationOfRangeToPlayer(EntityPlayer player, String range) {
|
||||
if (getListOfRanges().contains(range)) {
|
||||
return new TextComponentTranslation(this.getUnlocalizedName() + "." + range + ".info");
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return new TextComponentTranslation("ritual.bloodmagic.blockRange.noRange");
|
||||
}
|
||||
}
|
||||
|
@ -317,13 +269,11 @@ public abstract class Ritual
|
|||
*/
|
||||
public abstract ArrayList<RitualComponent> getComponents();
|
||||
|
||||
public void addRune(ArrayList<RitualComponent> components, int offset1, int y, int offset2, EnumRuneType rune)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
|
@ -334,34 +284,21 @@ public abstract class Ritual
|
|||
addRune(components, -offset2, y, -offset1, rune);
|
||||
}
|
||||
|
||||
public void addCornerRunes(ArrayList<RitualComponent> components, int offset, int y, EnumRuneType 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)
|
||||
{
|
||||
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 enum BreakType
|
||||
{
|
||||
REDSTONE,
|
||||
BREAK_MRS,
|
||||
BREAK_STONE,
|
||||
ACTIVATE,
|
||||
DEACTIVATE,
|
||||
EXPLOSION,
|
||||
}
|
||||
|
||||
public double getWillRespectingConfig(World world, BlockPos pos, EnumDemonWillType type, List<EnumDemonWillType> willConfig)
|
||||
{
|
||||
public double getWillRespectingConfig(World world, BlockPos pos, EnumDemonWillType type, List<EnumDemonWillType> willConfig) {
|
||||
return willConfig.contains(type) ? WorldDemonWillHandler.getCurrentWill(world, pos, type) : 0;
|
||||
}
|
||||
|
||||
|
@ -446,4 +383,13 @@ public abstract class Ritual
|
|||
result = 31 * result + (unlocalizedName != null ? unlocalizedName.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
public enum BreakType {
|
||||
REDSTONE,
|
||||
BREAK_MRS,
|
||||
BREAK_STONE,
|
||||
ACTIVATE,
|
||||
DEACTIVATE,
|
||||
EXPLOSION,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,7 @@ 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
|
||||
{
|
||||
public class RitualComponent {
|
||||
private final BlockPos offset;
|
||||
private final EnumRuneType runeType;
|
||||
|
||||
|
@ -17,43 +16,37 @@ public class RitualComponent
|
|||
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 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()
|
||||
{
|
||||
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 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)
|
||||
{
|
||||
public BlockPos getOffset(EnumFacing direction) {
|
||||
return new BlockPos(getX(direction), offset.getY(), getZ(direction));
|
||||
}
|
||||
|
||||
|
|
|
@ -3,12 +3,10 @@ package WayofTime.bloodmagic.api.ritual;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public abstract class RitualRenderer
|
||||
{
|
||||
public abstract class RitualRenderer {
|
||||
public abstract void renderAt(IMasterRitualStone masterRitualStone, double x, double y, double z);
|
||||
|
||||
protected void bindTexture(ResourceLocation resourceLocation)
|
||||
{
|
||||
protected void bindTexture(ResourceLocation resourceLocation) {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,10 @@ 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
|
||||
{
|
||||
public interface IImperfectRitualStone {
|
||||
|
||||
boolean performRitual(World world, BlockPos pos, ImperfectRitual imperfectRitual, EntityPlayer player);
|
||||
|
||||
|
|
|
@ -9,8 +9,7 @@ import net.minecraft.world.World;
|
|||
* registered with
|
||||
* {@link WayofTime.bloodmagic.api.registry.ImperfectRitualRegistry#registerRitual(ImperfectRitual)}
|
||||
*/
|
||||
public abstract class ImperfectRitual
|
||||
{
|
||||
public abstract class ImperfectRitual {
|
||||
|
||||
private final String name;
|
||||
private final BlockStack requiredBlock;
|
||||
|
@ -27,26 +26,20 @@ public abstract class ImperfectRitual
|
|||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* - The name of the ritual
|
||||
* @param requiredBlock
|
||||
* - The block required above the ImperfectRitualStone
|
||||
* @param activationCost
|
||||
* - Base LP cost for activating the ritual
|
||||
* @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)
|
||||
{
|
||||
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
|
||||
*
|
||||
* @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);
|
||||
|
@ -72,8 +65,7 @@ public abstract class ImperfectRitual
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
public String toString() {
|
||||
return getName() + ":" + getRequiredBlock().toString() + "@" + getActivationCost();
|
||||
}
|
||||
|
||||
|
|
|
@ -6,43 +6,38 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.storage.WorldSavedData;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BMWorldSavedData extends WorldSavedData
|
||||
{
|
||||
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)
|
||||
{
|
||||
public BMWorldSavedData(String id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public BMWorldSavedData()
|
||||
{
|
||||
public BMWorldSavedData() {
|
||||
this(ID);
|
||||
}
|
||||
|
||||
public SoulNetwork getNetwork(EntityPlayer player)
|
||||
{
|
||||
public SoulNetwork getNetwork(EntityPlayer player) {
|
||||
return getNetwork(PlayerHelper.getUUIDFromPlayer(player));
|
||||
}
|
||||
|
||||
public SoulNetwork getNetwork(UUID playerId)
|
||||
{
|
||||
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)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
NBTTagList networkData = tagCompound.getTagList("networkData", 10);
|
||||
|
||||
for (int i = 0; i < networkData.tagCount(); i++)
|
||||
{
|
||||
for (int i = 0; i < networkData.tagCount(); i++) {
|
||||
NBTTagCompound data = networkData.getCompoundTagAt(i);
|
||||
SoulNetwork network = SoulNetwork.fromNBT(data);
|
||||
network.setParent(this);
|
||||
|
@ -51,8 +46,7 @@ public class BMWorldSavedData extends WorldSavedData
|
|||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
|
||||
NBTTagList networkData = new NBTTagList();
|
||||
for (SoulNetwork soulNetwork : soulNetworks.values())
|
||||
networkData.appendTag(soulNetwork.serializeNBT());
|
||||
|
|
|
@ -17,21 +17,18 @@ import net.minecraftforge.fml.common.eventhandler.Event;
|
|||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SoulNetwork implements INBTSerializable<NBTTagCompound>
|
||||
{
|
||||
public class SoulNetwork implements INBTSerializable<NBTTagCompound> {
|
||||
private BMWorldSavedData parent;
|
||||
private EntityPlayer cachedPlayer;
|
||||
private UUID playerId;
|
||||
private int currentEssence;
|
||||
private int orbTier;
|
||||
|
||||
private SoulNetwork()
|
||||
{
|
||||
private SoulNetwork() {
|
||||
// No-op - For creation via NBT only
|
||||
}
|
||||
|
||||
public int add(int toAdd, int maximum)
|
||||
{
|
||||
public int add(int toAdd, int maximum) {
|
||||
AddToNetworkEvent event = new AddToNetworkEvent(playerId.toString(), toAdd, maximum);
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
|
@ -56,15 +53,12 @@ public class SoulNetwork implements INBTSerializable<NBTTagCompound>
|
|||
* @deprecated - Please use {@link #add(int, int)}
|
||||
*/
|
||||
@Deprecated
|
||||
public int addLifeEssence(int toAdd, int maximum)
|
||||
{
|
||||
public int addLifeEssence(int toAdd, int maximum) {
|
||||
return add(toAdd, maximum);
|
||||
}
|
||||
|
||||
public int syphon(int syphon)
|
||||
{
|
||||
if (getCurrentEssence() >= syphon)
|
||||
{
|
||||
public int syphon(int syphon) {
|
||||
if (getCurrentEssence() >= syphon) {
|
||||
setCurrentEssence(getCurrentEssence() - syphon);
|
||||
return syphon;
|
||||
}
|
||||
|
@ -72,15 +66,12 @@ public class SoulNetwork implements INBTSerializable<NBTTagCompound>
|
|||
return 0;
|
||||
}
|
||||
|
||||
public boolean syphonAndDamage(EntityPlayer user, int toSyphon)
|
||||
{
|
||||
if (user != null)
|
||||
{
|
||||
public boolean syphonAndDamage(EntityPlayer user, int toSyphon) {
|
||||
if (user != null) {
|
||||
if (user.getEntityWorld().isRemote)
|
||||
return false;
|
||||
|
||||
if (!Strings.isNullOrEmpty(playerId.toString()))
|
||||
{
|
||||
if (!Strings.isNullOrEmpty(playerId.toString())) {
|
||||
SoulNetworkEvent.ItemDrainNetworkEvent event = new SoulNetworkEvent.ItemDrainNetworkEvent(user, playerId.toString(), null, toSyphon);
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
|
@ -103,8 +94,7 @@ public class SoulNetwork implements INBTSerializable<NBTTagCompound>
|
|||
return false;
|
||||
}
|
||||
|
||||
public void causeNausea()
|
||||
{
|
||||
public void causeNausea() {
|
||||
if (getPlayer() != null)
|
||||
getPlayer().addPotionEffect(new PotionEffect(MobEffects.NAUSEA, 99));
|
||||
}
|
||||
|
@ -113,29 +103,21 @@ public class SoulNetwork implements INBTSerializable<NBTTagCompound>
|
|||
* @deprecated - Please use {@link #causeNausea()}
|
||||
*/
|
||||
@Deprecated
|
||||
public void causeNauseaToPlayer()
|
||||
{
|
||||
public void causeNauseaToPlayer() {
|
||||
causeNausea();
|
||||
}
|
||||
|
||||
public void hurtPlayer(EntityPlayer user, float syphon)
|
||||
{
|
||||
if (user != null)
|
||||
{
|
||||
if (syphon < 100 && syphon > 0)
|
||||
{
|
||||
if (!user.capabilities.isCreativeMode)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
} 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);
|
||||
}
|
||||
|
@ -144,8 +126,7 @@ public class SoulNetwork implements INBTSerializable<NBTTagCompound>
|
|||
}
|
||||
}
|
||||
|
||||
private void markDirty()
|
||||
{
|
||||
private void markDirty() {
|
||||
if (getParent() != null)
|
||||
getParent().markDirty();
|
||||
else
|
||||
|
@ -153,39 +134,23 @@ public class SoulNetwork implements INBTSerializable<NBTTagCompound>
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public EntityPlayer getPlayer()
|
||||
{
|
||||
public EntityPlayer getPlayer() {
|
||||
if (cachedPlayer == null)
|
||||
cachedPlayer = PlayerHelper.getPlayerFromUUID(playerId);
|
||||
|
||||
return cachedPlayer;
|
||||
}
|
||||
|
||||
public SoulNetwork setCurrentEssence(int currentEssence)
|
||||
{
|
||||
this.currentEssence = currentEssence;
|
||||
markDirty();
|
||||
return this;
|
||||
public BMWorldSavedData getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public SoulNetwork setOrbTier(int orbTier)
|
||||
{
|
||||
this.orbTier = orbTier;
|
||||
markDirty();
|
||||
return this;
|
||||
}
|
||||
|
||||
public SoulNetwork setParent(BMWorldSavedData parent)
|
||||
{
|
||||
public SoulNetwork setParent(BMWorldSavedData parent) {
|
||||
this.parent = parent;
|
||||
markDirty();
|
||||
return this;
|
||||
}
|
||||
|
||||
public BMWorldSavedData getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public EntityPlayer getCachedPlayer() {
|
||||
return cachedPlayer;
|
||||
}
|
||||
|
@ -198,15 +163,26 @@ public class SoulNetwork implements INBTSerializable<NBTTagCompound>
|
|||
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()
|
||||
{
|
||||
public NBTTagCompound serializeNBT() {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setString("playerId", getPlayerId().toString());
|
||||
tagCompound.setInteger("currentEssence", getCurrentEssence());
|
||||
|
@ -215,22 +191,19 @@ public class SoulNetwork implements INBTSerializable<NBTTagCompound>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(NBTTagCompound nbt)
|
||||
{
|
||||
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)
|
||||
{
|
||||
public static SoulNetwork fromNBT(NBTTagCompound tagCompound) {
|
||||
SoulNetwork soulNetwork = new SoulNetwork();
|
||||
soulNetwork.deserializeNBT(tagCompound);
|
||||
return soulNetwork;
|
||||
}
|
||||
|
||||
public static SoulNetwork newEmpty(UUID uuid)
|
||||
{
|
||||
public static SoulNetwork newEmpty(UUID uuid) {
|
||||
SoulNetwork network = new SoulNetwork();
|
||||
network.playerId = uuid;
|
||||
return network;
|
||||
|
|
|
@ -5,15 +5,12 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class DemonWillHolder
|
||||
{
|
||||
public class DemonWillHolder {
|
||||
public HashMap<EnumDemonWillType, Double> willMap = new HashMap<EnumDemonWillType, Double>();
|
||||
|
||||
public double addWill(EnumDemonWillType type, double amount, double max)
|
||||
{
|
||||
public double addWill(EnumDemonWillType type, double amount, double max) {
|
||||
double current = 0;
|
||||
if (willMap.containsKey(type))
|
||||
{
|
||||
if (willMap.containsKey(type)) {
|
||||
current = willMap.get(type);
|
||||
}
|
||||
|
||||
|
@ -23,29 +20,22 @@ public class DemonWillHolder
|
|||
return added;
|
||||
}
|
||||
|
||||
public void addWill(EnumDemonWillType type, double amount)
|
||||
{
|
||||
if (willMap.containsKey(type))
|
||||
{
|
||||
public void addWill(EnumDemonWillType type, double amount) {
|
||||
if (willMap.containsKey(type)) {
|
||||
willMap.put(type, amount + willMap.get(type));
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
willMap.put(type, amount);
|
||||
}
|
||||
}
|
||||
|
||||
public double drainWill(EnumDemonWillType type, double amount)
|
||||
{
|
||||
if (willMap.containsKey(type))
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (reduced >= current) {
|
||||
willMap.remove(type);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
willMap.put(type, current - reduced);
|
||||
}
|
||||
|
||||
|
@ -55,45 +45,37 @@ public class DemonWillHolder
|
|||
return 0;
|
||||
}
|
||||
|
||||
public double getWill(EnumDemonWillType type)
|
||||
{
|
||||
if (willMap.containsKey(type))
|
||||
{
|
||||
public double getWill(EnumDemonWillType type) {
|
||||
if (willMap.containsKey(type)) {
|
||||
return willMap.get(type);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound tag, String key)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tag, String key) {
|
||||
NBTTagCompound willTag = tag.getCompoundTag(key);
|
||||
|
||||
willMap.clear();
|
||||
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values())
|
||||
{
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values()) {
|
||||
double amount = willTag.getDouble("EnumWill" + type.getName());
|
||||
if (amount > 0)
|
||||
{
|
||||
if (amount > 0) {
|
||||
willMap.put(type, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound tag, String key)
|
||||
{
|
||||
public void writeToNBT(NBTTagCompound tag, String key) {
|
||||
NBTTagCompound willTag = new NBTTagCompound();
|
||||
for (Entry<EnumDemonWillType, Double> entry : willMap.entrySet())
|
||||
{
|
||||
for (Entry<EnumDemonWillType, Double> entry : willMap.entrySet()) {
|
||||
willTag.setDouble("EnumWill" + entry.getKey().getName(), entry.getValue());
|
||||
}
|
||||
|
||||
tag.setTag(key, willTag);
|
||||
}
|
||||
|
||||
public void clearWill()
|
||||
{
|
||||
public void clearWill() {
|
||||
willMap.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package WayofTime.bloodmagic.api.soul;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public enum EnumDemonWillType implements IStringSerializable
|
||||
{
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumDemonWillType implements IStringSerializable {
|
||||
DEFAULT("default"),
|
||||
CORROSIVE("corrosive"),
|
||||
DESTRUCTIVE("destructive"),
|
||||
|
@ -14,20 +13,17 @@ public enum EnumDemonWillType implements IStringSerializable
|
|||
|
||||
public final String name;
|
||||
|
||||
EnumDemonWillType(String name)
|
||||
{
|
||||
EnumDemonWillType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
public String toString() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
public String getName() {
|
||||
return this.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,14 +2,11 @@ package WayofTime.bloodmagic.api.soul;
|
|||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IDemonWill
|
||||
{
|
||||
public interface IDemonWill {
|
||||
/**
|
||||
* Obtains the amount of Will an ItemStack contains.
|
||||
*
|
||||
* @param willStack
|
||||
* - The stack to retrieve the Will from
|
||||
*
|
||||
*
|
||||
* @param willStack - The stack to retrieve the Will from
|
||||
* @return - The amount of Will an ItemStack contains
|
||||
*/
|
||||
double getWill(EnumDemonWillType type, ItemStack willStack);
|
||||
|
@ -19,11 +16,9 @@ public interface IDemonWill
|
|||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @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);
|
||||
|
||||
|
@ -33,12 +28,9 @@ public interface IDemonWill
|
|||
/**
|
||||
* 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
|
||||
*
|
||||
*
|
||||
* @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);
|
||||
|
@ -49,12 +41,9 @@ public interface IDemonWill
|
|||
/**
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* @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);
|
||||
|
|
|
@ -2,10 +2,8 @@ package WayofTime.bloodmagic.api.soul;
|
|||
|
||||
/**
|
||||
* Implement this interface on a block that can accept and store Demonic Will.
|
||||
*
|
||||
*/
|
||||
public interface IDemonWillConduit
|
||||
{
|
||||
public interface IDemonWillConduit {
|
||||
int getWeight();
|
||||
|
||||
double fillDemonWill(EnumDemonWillType type, double amount, boolean doFill);
|
||||
|
|
|
@ -2,23 +2,18 @@ package WayofTime.bloodmagic.api.soul;
|
|||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IDemonWillGem
|
||||
{
|
||||
public interface IDemonWillGem {
|
||||
/**
|
||||
*
|
||||
* @param willGemStack
|
||||
* - The ItemStack for this demon will gem.
|
||||
* @param willStack
|
||||
* - The ItemStack for the will. Item should extend IDemonWill
|
||||
* @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.
|
||||
* 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);
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import net.minecraft.item.ItemStack;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public interface IDemonWillWeapon
|
||||
{
|
||||
public interface IDemonWillWeapon {
|
||||
List<ItemStack> getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting);
|
||||
}
|
||||
|
|
|
@ -2,14 +2,11 @@ package WayofTime.bloodmagic.api.soul;
|
|||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IDiscreteDemonWill
|
||||
{
|
||||
public interface IDiscreteDemonWill {
|
||||
/**
|
||||
* Obtains the amount of Will an ItemStack contains.
|
||||
*
|
||||
* @param soulStack
|
||||
* - The stack to retrieve the Will from
|
||||
*
|
||||
*
|
||||
* @param soulStack - The stack to retrieve the Will from
|
||||
* @return - The amount of Will an ItemStack contains
|
||||
*/
|
||||
double getWill(ItemStack soulStack);
|
||||
|
@ -18,32 +15,25 @@ public interface IDiscreteDemonWill
|
|||
* 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
|
||||
*
|
||||
*
|
||||
* @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
|
||||
*
|
||||
*
|
||||
* @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
|
||||
*
|
||||
*
|
||||
* @param willStack - The ItemStack of the will
|
||||
* @return - The type of will this is.
|
||||
*/
|
||||
EnumDemonWillType getType(ItemStack willStack);
|
||||
|
|
|
@ -10,30 +10,22 @@ import net.minecraft.util.NonNullList;
|
|||
* Monster Souls and Soul Gems, etc. The Soul Network's helper methods are found
|
||||
* in {@link WayofTime.bloodmagic.api.util.helper.NetworkHelper}
|
||||
*/
|
||||
public class PlayerDemonWillHandler
|
||||
{
|
||||
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
|
||||
*
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
} else if (stack.getItem() instanceof IDemonWillGem) {
|
||||
souls += ((IDemonWillGem) stack.getItem()).getWill(type, stack);
|
||||
}
|
||||
}
|
||||
|
@ -41,16 +33,13 @@ public class PlayerDemonWillHandler
|
|||
return souls;
|
||||
}
|
||||
|
||||
public static EnumDemonWillType getLargestWillType(EntityPlayer player)
|
||||
{
|
||||
public static EnumDemonWillType getLargestWillType(EntityPlayer player) {
|
||||
EnumDemonWillType type = EnumDemonWillType.DEFAULT;
|
||||
double max = getTotalDemonWill(type, player);
|
||||
|
||||
for (EnumDemonWillType testType : EnumDemonWillType.values())
|
||||
{
|
||||
for (EnumDemonWillType testType : EnumDemonWillType.values()) {
|
||||
double value = getTotalDemonWill(testType, player);
|
||||
if (value > max)
|
||||
{
|
||||
if (value > max) {
|
||||
type = testType;
|
||||
}
|
||||
}
|
||||
|
@ -60,23 +49,17 @@ public class PlayerDemonWillHandler
|
|||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
|
@ -88,33 +71,26 @@ public class PlayerDemonWillHandler
|
|||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
} else if (stack.getItem() instanceof IDemonWillGem) {
|
||||
consumed += ((IDemonWillGem) stack.getItem()).drainWill(type, stack, amount - consumed, true);
|
||||
}
|
||||
}
|
||||
|
@ -125,25 +101,19 @@ public class PlayerDemonWillHandler
|
|||
/**
|
||||
* 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
|
||||
*
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
for (ItemStack stack : inventory) {
|
||||
if (stack.getItem() instanceof IDemonWillGem) {
|
||||
ItemStack newStack = ((IDemonWillGem) stack.getItem()).fillDemonWillGem(stack, willStack);
|
||||
if (newStack.isEmpty())
|
||||
return ItemStack.EMPTY;
|
||||
|
@ -156,25 +126,18 @@ public class PlayerDemonWillHandler
|
|||
/**
|
||||
* 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
|
||||
*
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
for (ItemStack stack : inventory) {
|
||||
if (stack.getItem() instanceof IDemonWillGem) {
|
||||
remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining, true);
|
||||
if (remaining <= 0)
|
||||
break;
|
||||
|
@ -187,27 +150,19 @@ public class PlayerDemonWillHandler
|
|||
/**
|
||||
* 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
|
||||
*
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
for (ItemStack stack : inventory) {
|
||||
if (!stack.equals(ignored) && stack.getItem() instanceof IDemonWillGem) {
|
||||
remaining -= ((IDemonWillGem) stack.getItem()).fillWill(type, stack, remaining, true);
|
||||
|
||||
if (remaining <= 0)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package WayofTime.bloodmagic.api.teleport;
|
||||
|
||||
public interface ITeleport
|
||||
{
|
||||
public interface ITeleport {
|
||||
void teleport();
|
||||
|
||||
int getTeleportCost();
|
||||
|
|
|
@ -6,38 +6,24 @@ import net.minecraft.util.math.BlockPos;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class PortalLocation implements 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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
public PortalLocation(BlockPos blockPos, int dimension) {
|
||||
this(blockPos.getX(), blockPos.getY(), blockPos.getZ(), 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;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||
NBTTagCompound locationTag = new NBTTagCompound();
|
||||
|
||||
locationTag.setInteger(Constants.NBT.X_COORD, x);
|
||||
|
@ -49,14 +35,12 @@ public class PortalLocation implements Serializable
|
|||
return tag;
|
||||
}
|
||||
|
||||
public BlockPos getBlockPos()
|
||||
{
|
||||
public BlockPos getBlockPos() {
|
||||
return new BlockPos(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
|
@ -73,8 +57,7 @@ public class PortalLocation implements Serializable
|
|||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
public int hashCode() {
|
||||
int result = x;
|
||||
result = 31 * result + y;
|
||||
result = 31 * result + z;
|
||||
|
@ -96,4 +79,12 @@ public class PortalLocation implements Serializable
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,16 +3,14 @@ package WayofTime.bloodmagic.api.teleport;
|
|||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public abstract class Teleport implements ITeleport
|
||||
{
|
||||
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)
|
||||
{
|
||||
public Teleport(int x, int y, int z, Entity entity, String networkToDrain) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
@ -20,8 +18,7 @@ public abstract class Teleport implements ITeleport
|
|||
this.networkToDrain = networkToDrain;
|
||||
}
|
||||
|
||||
public Teleport(BlockPos blockPos, Entity entity, String networkToDrain)
|
||||
{
|
||||
public Teleport(BlockPos blockPos, Entity entity, String networkToDrain) {
|
||||
this(blockPos.getX(), blockPos.getY(), blockPos.getZ(), entity, networkToDrain);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,39 +6,32 @@ import net.minecraftforge.fml.common.gameevent.TickEvent;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TeleportQueue
|
||||
{
|
||||
public class TeleportQueue {
|
||||
private static TeleportQueue INSTANCE = new TeleportQueue();
|
||||
private static List<ITeleport> queue;
|
||||
|
||||
public static TeleportQueue getInstance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private TeleportQueue()
|
||||
{
|
||||
private TeleportQueue() {
|
||||
queue = new ArrayList<ITeleport>();
|
||||
}
|
||||
|
||||
public void addITeleport(ITeleport iTeleport)
|
||||
{
|
||||
public void addITeleport(ITeleport iTeleport) {
|
||||
queue.add(iTeleport);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverTick(TickEvent.ServerTickEvent event)
|
||||
{
|
||||
if (event.phase != TickEvent.Phase.END)
|
||||
{
|
||||
public void serverTick(TickEvent.ServerTickEvent event) {
|
||||
if (event.phase != TickEvent.Phase.END) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ITeleport iTeleport : queue)
|
||||
{
|
||||
for (ITeleport iTeleport : queue) {
|
||||
iTeleport.teleport();
|
||||
}
|
||||
|
||||
queue.clear();
|
||||
}
|
||||
|
||||
public static TeleportQueue getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,34 +5,28 @@ 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)
|
||||
{
|
||||
public class TeleporterBloodMagic extends Teleporter {
|
||||
public TeleporterBloodMagic(WorldServer worldServer) {
|
||||
super(worldServer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean makePortal(Entity entity)
|
||||
{
|
||||
public boolean makePortal(Entity entity) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeStalePortalLocations(long worldTime)
|
||||
{
|
||||
public void removeStalePortalLocations(long worldTime) {
|
||||
;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeInExistingPortal(Entity entityIn, float rotationYaw)
|
||||
{
|
||||
public boolean placeInExistingPortal(Entity entityIn, float rotationYaw) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeInPortal(Entity entity, float rotationYaw)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,19 +11,15 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BindableHelper
|
||||
{
|
||||
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
|
||||
*
|
||||
* @param stack - The ItemStack to bind
|
||||
* @param ownerName - The username to bind the ItemStack to
|
||||
*/
|
||||
public static void setItemOwnerName(ItemStack stack, String ownerName)
|
||||
{
|
||||
public static void setItemOwnerName(ItemStack stack, String ownerName) {
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
stack.getTagCompound().setString(Constants.NBT.OWNER_NAME, ownerName);
|
||||
|
@ -32,14 +28,11 @@ public class BindableHelper
|
|||
/**
|
||||
* 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
|
||||
*
|
||||
* @param stack - The ItemStack to bind
|
||||
* @param ownerUUID - The UUID to bind the ItemStack to
|
||||
*/
|
||||
public static void setItemOwnerUUID(ItemStack stack, String ownerUUID)
|
||||
{
|
||||
public static void setItemOwnerUUID(ItemStack stack, String ownerUUID) {
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
stack.getTagCompound().setString(Constants.NBT.OWNER_UUID, ownerUUID);
|
||||
|
@ -49,17 +42,14 @@ public class BindableHelper
|
|||
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* <p>
|
||||
* Built into {@link IBindable} now.
|
||||
*
|
||||
* @param stack
|
||||
* - The ItemStack to check the owner of
|
||||
*
|
||||
*
|
||||
* @param stack - The ItemStack to check the owner of
|
||||
* @return - The username of the ItemStack's owner
|
||||
*/
|
||||
@Deprecated
|
||||
public static String getOwnerName(ItemStack stack)
|
||||
{
|
||||
public static String getOwnerName(ItemStack stack) {
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
return PlayerHelper.getUsernameFromStack(stack);
|
||||
|
@ -67,17 +57,14 @@ public class BindableHelper
|
|||
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* <p>
|
||||
* Built into {@link IBindable} now.
|
||||
*
|
||||
* @param stack
|
||||
* - The ItemStack to check the owner of
|
||||
*
|
||||
*
|
||||
* @param stack - The ItemStack to check the owner of
|
||||
* @return - The UUID of the ItemStack's owner
|
||||
*/
|
||||
@Deprecated
|
||||
public static String getOwnerUUID(ItemStack stack)
|
||||
{
|
||||
public static String getOwnerUUID(ItemStack stack) {
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
return stack.getTagCompound().getString(Constants.NBT.OWNER_UUID);
|
||||
|
@ -85,41 +72,32 @@ public class BindableHelper
|
|||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
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.
|
||||
*
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
public static boolean checkAndSetItemOwner(ItemStack stack, String uuid, String currentUsername) {
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
if (!(stack.getItem() instanceof IBindable))
|
||||
|
@ -144,36 +122,28 @@ public class BindableHelper
|
|||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
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)
|
||||
*
|
||||
* @param stack
|
||||
* - The ItemStack to bind
|
||||
* @param ownerName
|
||||
* - The username to bind the ItemStack to
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setItemOwner(ItemStack stack, String ownerName)
|
||||
{
|
||||
public static void setItemOwner(ItemStack stack, String ownerName) {
|
||||
setItemOwnerName(stack, ownerName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,21 +4,17 @@ import WayofTime.bloodmagic.api.Constants;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class IncenseHelper
|
||||
{
|
||||
public static double getCurrentIncense(EntityPlayer player)
|
||||
{
|
||||
public class IncenseHelper {
|
||||
public static double getCurrentIncense(EntityPlayer player) {
|
||||
NBTTagCompound data = player.getEntityData();
|
||||
if (data.hasKey(Constants.NBT.CURRENT_INCENSE))
|
||||
{
|
||||
if (data.hasKey(Constants.NBT.CURRENT_INCENSE)) {
|
||||
return data.getDouble(Constants.NBT.CURRENT_INCENSE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void setCurrentIncense(EntityPlayer player, double amount)
|
||||
{
|
||||
public static void setCurrentIncense(EntityPlayer player, double amount) {
|
||||
NBTTagCompound data = player.getEntityData();
|
||||
data.setDouble(Constants.NBT.CURRENT_INCENSE, amount);
|
||||
}
|
||||
|
|
|
@ -11,36 +11,25 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemHelper
|
||||
{
|
||||
public class ItemHelper {
|
||||
// IItemLPContainer
|
||||
public static class LPContainer
|
||||
{
|
||||
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
|
||||
*
|
||||
*
|
||||
* @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())
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (amount > 0) {
|
||||
int filledAmount = altar.fillMainTank(amount);
|
||||
amount -= filledAmount;
|
||||
fillable.setStoredLP(itemStack, amount);
|
||||
|
@ -55,20 +44,14 @@ public class ItemHelper
|
|||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
public static boolean addLPToItem(ItemStack stack, int toAdd, int maxCapacity) {
|
||||
if (stack.getItem() instanceof IItemLPContainer) {
|
||||
IItemLPContainer fillable = (IItemLPContainer) stack.getItem();
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
|
@ -86,12 +69,9 @@ public class ItemHelper
|
|||
}
|
||||
}
|
||||
|
||||
public static class LivingUpgrades
|
||||
{
|
||||
public static LivingArmourUpgrade getUpgrade(ItemStack stack)
|
||||
{
|
||||
if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer)
|
||||
{
|
||||
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);
|
||||
|
||||
|
@ -101,19 +81,15 @@ public class ItemHelper
|
|||
return null;
|
||||
}
|
||||
|
||||
public static void setUpgrade(ItemStack stack, LivingArmourUpgrade upgrade)
|
||||
{
|
||||
if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer)
|
||||
{
|
||||
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)
|
||||
{
|
||||
public static void setKey(ItemStack stack, String key) {
|
||||
if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
|
@ -121,10 +97,8 @@ public class ItemHelper
|
|||
}
|
||||
}
|
||||
|
||||
public static String getKey(ItemStack stack)
|
||||
{
|
||||
if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer)
|
||||
{
|
||||
public static String getKey(ItemStack stack) {
|
||||
if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
|
@ -134,10 +108,8 @@ public class ItemHelper
|
|||
return "";
|
||||
}
|
||||
|
||||
public static void setLevel(ItemStack stack, int level)
|
||||
{
|
||||
if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer)
|
||||
{
|
||||
public static void setLevel(ItemStack stack, int level) {
|
||||
if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
|
@ -145,10 +117,8 @@ public class ItemHelper
|
|||
}
|
||||
}
|
||||
|
||||
public static int getLevel(ItemStack stack)
|
||||
{
|
||||
if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer)
|
||||
{
|
||||
public static int getLevel(ItemStack stack) {
|
||||
if (stack.getItem() instanceof ItemUpgradeTome || stack.getItem() instanceof IUpgradeTrainer) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
|
|
|
@ -4,40 +4,33 @@ import WayofTime.bloodmagic.api.BloodMagicAPI;
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class LogHelper
|
||||
{
|
||||
public class LogHelper {
|
||||
private Logger logger;
|
||||
|
||||
public LogHelper(String logger)
|
||||
{
|
||||
public LogHelper(String logger) {
|
||||
this.logger = LogManager.getLogger(logger);
|
||||
}
|
||||
|
||||
public void info(String info, Object... format)
|
||||
{
|
||||
public void info(String info, Object... format) {
|
||||
if (BloodMagicAPI.loggingEnabled)
|
||||
logger.info(info, format);
|
||||
}
|
||||
|
||||
public void error(String error, Object... format)
|
||||
{
|
||||
public void error(String error, Object... format) {
|
||||
if (BloodMagicAPI.loggingEnabled)
|
||||
logger.error(error, format);
|
||||
}
|
||||
|
||||
public void debug(String debug, Object... format)
|
||||
{
|
||||
public void debug(String debug, Object... format) {
|
||||
if (BloodMagicAPI.loggingEnabled)
|
||||
logger.debug(debug, format);
|
||||
}
|
||||
|
||||
public void fatal(String fatal, Object... format)
|
||||
{
|
||||
public void fatal(String fatal, Object... format) {
|
||||
logger.error(fatal, format);
|
||||
}
|
||||
|
||||
public Logger getLogger()
|
||||
{
|
||||
public Logger getLogger() {
|
||||
return logger;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,8 @@ package WayofTime.bloodmagic.api.util.helper;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class NBTHelper
|
||||
{
|
||||
public static ItemStack checkNBT(ItemStack stack)
|
||||
{
|
||||
public class NBTHelper {
|
||||
public static ItemStack checkNBT(ItemStack stack) {
|
||||
if (stack.getTagCompound() == null)
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
|
|
|
@ -17,28 +17,23 @@ import net.minecraftforge.fml.common.eventhandler.Event;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
public class NetworkHelper
|
||||
{
|
||||
public class NetworkHelper {
|
||||
// Get
|
||||
|
||||
/**
|
||||
* Gets the SoulNetwork for the player.
|
||||
*
|
||||
* @param uuid
|
||||
* - The UUID of the SoulNetwork owner - this is UUID.toString().
|
||||
*
|
||||
*
|
||||
* @param uuid - The UUID of the SoulNetwork owner - this is UUID.toString().
|
||||
* @return - The SoulNetwork for the given name.
|
||||
*/
|
||||
public static SoulNetwork getSoulNetwork(String uuid)
|
||||
{
|
||||
public static SoulNetwork getSoulNetwork(String uuid) {
|
||||
World world = DimensionManager.getWorld(0);
|
||||
if (world == null || world.getMapStorage() == null) //Hack-ish way to fix the lava crystal.
|
||||
return new BMWorldSavedData().getNetwork(UUID.fromString(uuid));
|
||||
|
||||
BMWorldSavedData saveData = (BMWorldSavedData) world.getMapStorage().getOrLoadData(BMWorldSavedData.class, BMWorldSavedData.ID);
|
||||
|
||||
if (saveData == null)
|
||||
{
|
||||
if (saveData == null) {
|
||||
saveData = new BMWorldSavedData();
|
||||
world.getMapStorage().setData(BMWorldSavedData.ID, saveData);
|
||||
}
|
||||
|
@ -47,42 +42,32 @@ public class NetworkHelper
|
|||
}
|
||||
|
||||
/**
|
||||
* @param uuid - The Player's Mojang UUID
|
||||
* @see NetworkHelper#getSoulNetwork(String)
|
||||
*
|
||||
* @param uuid
|
||||
* - The Player's Mojang UUID
|
||||
*/
|
||||
public static SoulNetwork getSoulNetwork(UUID uuid)
|
||||
{
|
||||
public static SoulNetwork getSoulNetwork(UUID uuid) {
|
||||
return getSoulNetwork(uuid.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player - The Player
|
||||
* @see NetworkHelper#getSoulNetwork(String)
|
||||
*
|
||||
* @param player
|
||||
* - The Player
|
||||
*/
|
||||
public static SoulNetwork getSoulNetwork(EntityPlayer player)
|
||||
{
|
||||
public static SoulNetwork getSoulNetwork(EntityPlayer player) {
|
||||
return getSoulNetwork(PlayerHelper.getUUIDFromPlayer(player));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current orb tier of the SoulNetwork.
|
||||
*
|
||||
* @param soulNetwork
|
||||
* - SoulNetwork to get the tier of.
|
||||
*
|
||||
*
|
||||
* @param soulNetwork - SoulNetwork to get the tier of.
|
||||
* @return - The Orb tier of the given SoulNetwork
|
||||
*/
|
||||
public static int getCurrentMaxOrb(SoulNetwork soulNetwork)
|
||||
{
|
||||
public static int getCurrentMaxOrb(SoulNetwork soulNetwork) {
|
||||
return soulNetwork.getOrbTier();
|
||||
}
|
||||
|
||||
public static int getMaximumForTier(int tier)
|
||||
{
|
||||
public static int getMaximumForTier(int tier) {
|
||||
int ret = 0;
|
||||
|
||||
if (tier > OrbRegistry.getTierMap().size() || tier < 0)
|
||||
|
@ -102,22 +87,17 @@ public class NetworkHelper
|
|||
/**
|
||||
* Syphons from the player and damages them if there was not enough stored
|
||||
* LP.
|
||||
*
|
||||
* <p>
|
||||
* Handles null-checking the player for you.
|
||||
*
|
||||
* @param soulNetwork
|
||||
* - SoulNetwork to syphon from
|
||||
* @param user
|
||||
* - User of the item.
|
||||
* @param toSyphon
|
||||
* - Amount of LP to syphon
|
||||
*
|
||||
*
|
||||
* @param soulNetwork - SoulNetwork to syphon from
|
||||
* @param user - User of the item.
|
||||
* @param toSyphon - Amount of LP to syphon
|
||||
* @return - Whether the action should be performed.
|
||||
* @deprecated Use {@link #getSoulNetwork(EntityPlayer)} and {@link SoulNetwork#syphonAndDamage(EntityPlayer, int)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean syphonAndDamage(SoulNetwork soulNetwork, EntityPlayer user, int toSyphon)
|
||||
{
|
||||
public static boolean syphonAndDamage(SoulNetwork soulNetwork, EntityPlayer user, int toSyphon) {
|
||||
|
||||
// if (soulNetwork.getPlayer() == null)
|
||||
// {
|
||||
|
@ -130,12 +110,9 @@ public class NetworkHelper
|
|||
|
||||
/**
|
||||
* Syphons a player from within a container.
|
||||
*
|
||||
* @param stack
|
||||
* - ItemStack in the Container.
|
||||
* @param toSyphon
|
||||
* - Amount of LP to syphon
|
||||
*
|
||||
*
|
||||
* @param stack - ItemStack in the Container.
|
||||
* @param toSyphon - Amount of LP to syphon
|
||||
* @return - If the syphon was successful.
|
||||
*/
|
||||
public static boolean syphonFromContainer(ItemStack stack, int toSyphon) //TODO: Change to a String, int?
|
||||
|
@ -155,16 +132,12 @@ public class NetworkHelper
|
|||
|
||||
/**
|
||||
* Checks if the ItemStack has a user to be syphoned from.
|
||||
*
|
||||
* @param stack
|
||||
* - ItemStack to check
|
||||
* @param toSyphon
|
||||
* - Amount of LP to syphon
|
||||
*
|
||||
*
|
||||
* @param stack - ItemStack to check
|
||||
* @param toSyphon - Amount of LP to syphon
|
||||
* @return - If syphoning is possible
|
||||
*/
|
||||
public static boolean canSyphonFromContainer(ItemStack stack, int toSyphon)
|
||||
{
|
||||
public static boolean canSyphonFromContainer(ItemStack stack, int toSyphon) {
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
String ownerName = stack.getTagCompound().getString(Constants.NBT.OWNER_UUID);
|
||||
|
||||
|
@ -180,14 +153,11 @@ public class NetworkHelper
|
|||
/**
|
||||
* Sets the orb tier of the SoulNetwork to the given orb. Will not set if
|
||||
* the given tier is lower than the current tier.
|
||||
*
|
||||
* @param soulNetwork
|
||||
* - SoulNetwork to set the orb tier of
|
||||
* @param maxOrb
|
||||
* - Tier of orb to set to
|
||||
*
|
||||
* @param soulNetwork - SoulNetwork to set the orb tier of
|
||||
* @param maxOrb - Tier of orb to set to
|
||||
*/
|
||||
public static void setMaxOrb(SoulNetwork soulNetwork, int maxOrb)
|
||||
{
|
||||
public static void setMaxOrb(SoulNetwork soulNetwork, int maxOrb) {
|
||||
soulNetwork.setOrbTier(Math.max(maxOrb, soulNetwork.getOrbTier()));
|
||||
}
|
||||
}
|
||||
|
|
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