Changed formatting to have bracing on a new line

This commit is contained in:
WayofTime 2015-12-30 15:34:40 -05:00
parent e5eddd6c45
commit e48eedb874
189 changed files with 6092 additions and 4041 deletions

View file

@ -30,7 +30,8 @@ import WayofTime.bloodmagic.util.handler.EventHandler;
@Mod(modid = Constants.Mod.MODID, name = Constants.Mod.NAME, version = Constants.Mod.VERSION, dependencies = Constants.Mod.DEPEND, acceptedMinecraftVersions = "[1.8.8,1.8.9]", guiFactory = "WayofTime.bloodmagic.client.gui.ConfigGuiFactory")
@Getter
public class BloodMagic {
public class BloodMagic
{
@SidedProxy(serverSide = "WayofTime.bloodmagic.proxy.CommonProxy", clientSide = "WayofTime.bloodmagic.proxy.ClientProxy")
public static CommonProxy proxy;
@ -38,9 +39,11 @@ public class BloodMagic {
@Mod.Instance(Constants.Mod.MODID)
public static BloodMagic instance;
public static CreativeTabs tabBloodMagic = new CreativeTabs(Constants.Mod.MODID + ".creativeTab") {
public static CreativeTabs tabBloodMagic = new CreativeTabs(Constants.Mod.MODID + ".creativeTab")
{
@Override
public Item getTabIconItem() {
public Item getTabIconItem()
{
return ModItems.bloodOrb;
}
};
@ -49,7 +52,8 @@ public class BloodMagic {
private File configDir;
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
public void preInit(FMLPreInitializationEvent event)
{
configDir = new File(event.getModConfigurationDirectory(), "BloodMagic");
ConfigHandler.init(new File(getConfigDir(), "BloodMagic.cfg"));
@ -64,7 +68,8 @@ public class BloodMagic {
}
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
public void init(FMLInitializationEvent event)
{
BloodMagicPacketHandler.init();
ModRecipes.init();
@ -77,7 +82,8 @@ public class BloodMagic {
}
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event) {
public void postInit(FMLPostInitializationEvent event)
{
ModRecipes.addCompressionHandlers();
proxy.postInit();

View file

@ -18,9 +18,11 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ConfigHandler {
public class ConfigHandler
{
@Getter @Setter
@Getter
@Setter
private static Configuration config;
// Teleposer
@ -89,12 +91,14 @@ public class ConfigHandler {
// Compat
public static void init(File file) {
public static void init(File file)
{
config = new Configuration(file);
syncConfig();
}
public static void syncConfig() {
public static void syncConfig()
{
String category;
category = "Item/Block Blacklisting";
@ -179,21 +183,26 @@ public class ConfigHandler {
config.save();
}
private static void buildTeleposerBlacklist() {
private static void buildTeleposerBlacklist()
{
// Make sure it's empty before setting the blacklist.
// Otherwise, reloading the config while in-game will duplicate the list.
// Otherwise, reloading the config while in-game will duplicate the
// list.
teleposerBlacklist.clear();
for (String blockSet : teleposerBlacklisting) {
for (String blockSet : teleposerBlacklisting)
{
String[] blockData = blockSet.split(":");
Block block = GameRegistry.findBlock(blockData[0], blockData[1]);
int meta = 0;
// If the block follows full syntax: modid:blockname:meta
if (blockData.length == 3) {
// Check if it's an int, if so, parse it. If not, set meta to 0 to avoid crashing.
if (blockData.length == 3)
{
// Check if it's an int, if so, parse it. If not, set meta to 0
// to avoid crashing.
if (Utils.isInteger(blockData[2]))
meta = Integer.parseInt(blockData[2]);
else if (blockData[2].equals("*"))
@ -206,7 +215,8 @@ public class ConfigHandler {
}
}
public static void checkRituals() {
public static void checkRituals()
{
RitualHelper.checkRituals(config, "WayofTime.bloodmagic.ritual", "Rituals");
RitualHelper.checkImperfectRituals(config, "WayofTime.bloodmagic.ritual.imperfect", "Rituals.imperfect");
config.save();

View file

@ -11,27 +11,34 @@ import net.minecraft.world.World;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting;
import WayofTime.bloodmagic.client.render.alchemyArray.BindingAlchemyCircleRenderer;
public class AlchemyArrayEffectBinding extends AlchemyArrayEffect {
public class AlchemyArrayEffectBinding extends AlchemyArrayEffect
{
@Getter
public final ItemStack outputStack;
public AlchemyArrayEffectBinding(ItemStack outputStack) {
public AlchemyArrayEffectBinding(ItemStack outputStack)
{
this.outputStack = outputStack;
}
@Override
public boolean update(TileEntity tile, int ticksActive) {
if(ticksActive >= 50 && ticksActive <= 250) {
//TODO: Find a way to spawn lightning from only the server side - does not render when just spawned on server, not client.
public boolean update(TileEntity tile, int ticksActive)
{
if (ticksActive >= 50 && ticksActive <= 250)
{
// TODO: Find a way to spawn lightning from only the server side -
// does not render when just spawned on server, not client.
this.spawnLightningOnCircle(tile.getWorld(), tile.getPos(), ticksActive);
}
if(tile.getWorld().isRemote) {
if (tile.getWorld().isRemote)
{
return false;
}
if(ticksActive >= 300){
if (ticksActive >= 300)
{
BlockPos pos = tile.getPos();
ItemStack output = outputStack.copy();
@ -45,8 +52,10 @@ public class AlchemyArrayEffectBinding extends AlchemyArrayEffect {
return false;
}
public void spawnLightningOnCircle(World world, BlockPos pos, int ticksActive) {
if(ticksActive % 50 == 0) {
public void spawnLightningOnCircle(World world, BlockPos pos, int ticksActive)
{
if (ticksActive % 50 == 0)
{
int circle = ticksActive / 50 - 1;
float distance = BindingAlchemyCircleRenderer.getDistanceOfCircle(circle, ticksActive);
float angle = BindingAlchemyCircleRenderer.getAngleOfCircle(circle, ticksActive);

View file

@ -31,7 +31,8 @@ import WayofTime.bloodmagic.util.Utils;
import com.google.common.base.Enums;
import com.google.common.base.Strings;
public class BloodAltar {
public class BloodAltar
{
private TileAltar tileAltar;
private int internalCounter = 0;
@ -71,7 +72,8 @@ public class BloodAltar {
this.tileAltar = tileAltar;
}
static {
static
{
EnumAltarTier.ONE.buildComponents();
EnumAltarTier.TWO.buildComponents();
EnumAltarTier.THREE.buildComponents();
@ -80,9 +82,12 @@ public class BloodAltar {
EnumAltarTier.SIX.buildComponents();
}
public static EnumAltarTier getAltarTier(World world, BlockPos pos) {
for (int i = EnumAltarTier.MAXTIERS - 1; i >= 1; i--) {
if (checkAltarIsValid(world, pos, i)) {
public static EnumAltarTier getAltarTier(World world, BlockPos pos)
{
for (int i = EnumAltarTier.MAXTIERS - 1; i >= 1; i--)
{
if (checkAltarIsValid(world, pos, i))
{
return EnumAltarTier.values()[i];
}
}
@ -90,22 +95,28 @@ public class BloodAltar {
return EnumAltarTier.ONE;
}
public static boolean checkAltarIsValid(World world, BlockPos worldPos, int altarTier) {
public static boolean checkAltarIsValid(World world, BlockPos worldPos, int altarTier)
{
for (AltarComponent altarComponent : EnumAltarTier.values()[altarTier].getAltarComponents()) {
for (AltarComponent altarComponent : EnumAltarTier.values()[altarTier].getAltarComponents())
{
BlockPos componentPos = worldPos.add(altarComponent.getOffset());
BlockStack worldBlock = new BlockStack(world.getBlockState(componentPos).getBlock(), world.getBlockState(componentPos).getBlock().getMetaFromState(world.getBlockState(componentPos)));
if (altarComponent.getComponent() != EnumAltarComponent.NOTAIR) {
if (worldBlock.getBlock() instanceof IAltarComponent) {
if (altarComponent.getComponent() != EnumAltarComponent.NOTAIR)
{
if (worldBlock.getBlock() instanceof IAltarComponent)
{
EnumAltarComponent component = ((IAltarComponent) worldBlock.getBlock()).getType(worldBlock.getMeta());
if (component != altarComponent.getComponent())
return false;
} else if (worldBlock.getBlock() != Utils.getBlockForComponent(altarComponent.getComponent())) {
} else if (worldBlock.getBlock() != Utils.getBlockForComponent(altarComponent.getComponent()))
{
return false;
}
} else {
} else
{
if (world.isAirBlock(componentPos))
return false;
}
@ -114,22 +125,28 @@ public class BloodAltar {
return true;
}
public static AltarUpgrade getUpgrades(World world, BlockPos pos, EnumAltarTier altarTier) {
if (world.isRemote) {
public static AltarUpgrade getUpgrades(World world, BlockPos pos, EnumAltarTier altarTier)
{
if (world.isRemote)
{
return null;
}
AltarUpgrade upgrades = new AltarUpgrade();
List<AltarComponent> list = altarTier.getAltarComponents();
for (AltarComponent altarComponent : list) {
for (AltarComponent altarComponent : list)
{
BlockPos componentPos = pos.add(altarComponent.getOffset());
if (altarComponent.isUpgradeSlot()) {
if (altarComponent.isUpgradeSlot())
{
BlockStack worldBlock = new BlockStack(world.getBlockState(componentPos).getBlock(), world.getBlockState(componentPos).getBlock().getMetaFromState(world.getBlockState(componentPos)));
if (worldBlock.getBlock() instanceof BlockBloodRune) {
switch (((BlockBloodRune) worldBlock.getBlock()).getRuneEffect(worldBlock.getMeta())) {
if (worldBlock.getBlock() instanceof BlockBloodRune)
{
switch (((BlockBloodRune) worldBlock.getBlock()).getRuneEffect(worldBlock.getMeta()))
{
case 1:
upgrades.addSpeed();
break;
@ -173,8 +190,10 @@ public class BloodAltar {
return upgrades;
}
public void readFromNBT(NBTTagCompound tagCompound) {
if (!tagCompound.hasKey(Constants.NBT.EMPTY)) {
public void readFromNBT(NBTTagCompound tagCompound)
{
if (!tagCompound.hasKey(Constants.NBT.EMPTY))
{
FluidStack fluid = FluidStack.loadFluidStackFromNBT(tagCompound);
if (fluid != null)
@ -212,7 +231,8 @@ public class BloodAltar {
cooldownAfterCrafting = tagCompound.getInteger(Constants.NBT.ALTAR_COOLDOWN_AFTER_CRAFTING);
}
public void writeToNBT(NBTTagCompound tagCompound) {
public void writeToNBT(NBTTagCompound tagCompound)
{
if (fluid != null)
fluid.writeToNBT(tagCompound);
@ -250,7 +270,8 @@ public class BloodAltar {
tagCompound.setInteger(Constants.NBT.ALTAR_COOLDOWN_AFTER_CRAFTING, cooldownAfterCrafting);
}
public void startCycle() {
public void startCycle()
{
if (tileAltar.getWorld() != null)
tileAltar.getWorld().markBlockForUpdate(tileAltar.getPos());
@ -262,10 +283,13 @@ public class BloodAltar {
if (!isActive)
progress = 0;
if (tileAltar.getStackInSlot(0) != null) {
if (tileAltar.getStackInSlot(0) != null)
{
// Do recipes
for (AltarRecipe recipe : AltarRecipeRegistry.getRecipes().values()) {
if (recipe.doesRequiredItemMatch(tileAltar.getStackInSlot(0), altarTier)) {
for (AltarRecipe recipe : AltarRecipeRegistry.getRecipes().values())
{
if (recipe.doesRequiredItemMatch(tileAltar.getStackInSlot(0), altarTier))
{
this.isActive = true;
this.result = new ItemStack(recipe.getOutput().getItem(), 1, recipe.getOutput().getMetadata());
this.liquidRequired = recipe.getSyphon();
@ -280,26 +304,31 @@ public class BloodAltar {
isActive = false;
}
public void update() {
public void update()
{
World world = tileAltar.getWorld();
BlockPos pos = tileAltar.getPos();
if (world.isRemote)
return;
internalCounter++; //Used instead of the world time for checks that do not happen every tick
internalCounter++; // Used instead of the world time for checks that do
// not happen every tick
if (lockdownDuration > 0)
lockdownDuration--;
if (internalCounter % 20 == 0) {
for(EnumFacing facing : EnumFacing.VALUES){
if (internalCounter % 20 == 0)
{
for (EnumFacing facing : EnumFacing.VALUES)
{
BlockPos newPos = pos.offset(facing);
IBlockState block = world.getBlockState(newPos);
block.getBlock().onNeighborBlockChange(world, newPos, block, block.getBlock());
}
}
if (internalCounter % (Math.max(20 - this.accelerationUpgrades, 1)) == 0) {
if (internalCounter % (Math.max(20 - this.accelerationUpgrades, 1)) == 0)
{
int syphonMax = (int) (20 * this.dislocationMultiplier);
int fluidInputted;
int fluidOutputted;
@ -319,8 +348,10 @@ public class BloodAltar {
updateAltar();
}
private void updateAltar() {
if (!isActive) {
private void updateAltar()
{
if (!isActive)
{
if (cooldownAfterCrafting > 0)
cooldownAfterCrafting--;
return;
@ -340,8 +371,10 @@ public class BloodAltar {
float f2 = f * f * 0.7F - 0.5F;
float f3 = f * f * 0.6F - 0.7F;
if (!canBeFilled) {
if (fluid != null && fluid.amount >= 1) {
if (!canBeFilled)
{
if (fluid != null && fluid.amount >= 1)
{
int stackSize = tileAltar.getStackInSlot(0).stackSize;
int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? consumptionRate * (1 + consumptionMultiplier) : consumptionRate), fluid.amount);
@ -354,7 +387,8 @@ public class BloodAltar {
if (internalCounter % 4 == 0)
world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + Math.random() - Math.random(), pos.getY() + Math.random() - Math.random(), pos.getZ() + Math.random() - Math.random(), f1, f2, f3);
if (progress >= liquidRequired * stackSize) {
if (progress >= liquidRequired * stackSize)
{
ItemStack result = this.result;
if (result != null)
@ -368,13 +402,15 @@ public class BloodAltar {
this.isActive = false;
}
} else if (progress > 0) {
} else if (progress > 0)
{
progress -= (int) (efficiencyMultiplier * drainRate);
if (internalCounter % 2 == 0)
world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + Math.random() - Math.random(), pos.getY() + Math.random() - Math.random(), pos.getZ() + Math.random() - Math.random(), f1, f2, f3);
}
} else {
} else
{
ItemStack returnedItem = tileAltar.getStackInSlot(0);
if (!(returnedItem.getItem() instanceof IBloodOrb))
@ -391,7 +427,8 @@ public class BloodAltar {
if (Strings.isNullOrEmpty(ownerUUID))
return;
if (fluid != null && fluid.amount >= 1) {
if (fluid != null && fluid.amount >= 1)
{
int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? consumptionRate * (1 + consumptionMultiplier) : consumptionRate), fluid.amount);
int drain = NetworkHelper.getSoulNetwork(ownerUUID, world).addLifeEssence(liquidDrained, (int) (item.getMaxEssence(returnedItem.getMetadata()) * this.orbCapacityMultiplier));
@ -406,13 +443,15 @@ public class BloodAltar {
world.markBlockForUpdate(pos);
}
public void checkTier() {
public void checkTier()
{
EnumAltarTier tier = BloodAltar.getAltarTier(tileAltar.getWorld(), tileAltar.getPos());
this.altarTier = tier;
upgrade = BloodAltar.getUpgrades(tileAltar.getWorld(), tileAltar.getPos(), tier);
if (tier.equals(EnumAltarTier.ONE)) {
if (tier.equals(EnumAltarTier.ONE))
{
upgrade = null;
isUpgraded = false;
this.consumptionMultiplier = 0;
@ -424,7 +463,8 @@ public class BloodAltar {
this.dislocationMultiplier = 1;
this.accelerationUpgrades = 0;
return;
} else if (!tier.equals(EnumAltarTier.ONE) && upgrade != null) {
} else if (!tier.equals(EnumAltarTier.ONE) && upgrade != null)
{
this.isUpgraded = true;
this.consumptionMultiplier = (float) (0.20 * upgrade.getSpeedCount());
this.efficiencyMultiplier = (float) Math.pow(0.85, upgrade.getEfficiencyCount());
@ -439,131 +479,165 @@ public class BloodAltar {
this.capacity = (int) (FluidContainerRegistry.BUCKET_VOLUME * 10 * capacityMultiplier);
this.bufferCapacity = (int) (FluidContainerRegistry.BUCKET_VOLUME * 1 * capacityMultiplier);
if (this.fluid.amount > this.capacity) this.fluid.amount = this.capacity;
if (this.fluidOutput.amount > this.bufferCapacity) this.fluidOutput.amount = this.bufferCapacity;
if (this.fluidInput.amount > this.bufferCapacity) this.fluidInput.amount = this.bufferCapacity;
if (this.fluid.amount > this.capacity)
this.fluid.amount = this.capacity;
if (this.fluidOutput.amount > this.bufferCapacity)
this.fluidOutput.amount = this.bufferCapacity;
if (this.fluidInput.amount > this.bufferCapacity)
this.fluidInput.amount = this.bufferCapacity;
tileAltar.getWorld().markBlockForUpdate(tileAltar.getPos());
}
public int fillMainTank(int amount) {
public int fillMainTank(int amount)
{
int filledAmount = Math.min(capacity - fluid.amount, amount);
fluid.amount += filledAmount;
return filledAmount;
}
public void sacrificialDaggerCall(int amount, boolean isSacrifice) {
if (this.lockdownDuration > 0) {
public void sacrificialDaggerCall(int amount, boolean isSacrifice)
{
if (this.lockdownDuration > 0)
{
int amt = (int) Math.min(bufferCapacity - fluidInput.amount, (isSacrifice ? 1 + sacrificeEfficiencyMultiplier : 1 + selfSacrificeEfficiencyMultiplier) * amount);
fluidInput.amount += amt;
} else {
} else
{
fluid.amount += Math.min(capacity - fluid.amount, (isSacrifice ? 1 + sacrificeEfficiencyMultiplier : 1 + selfSacrificeEfficiencyMultiplier) * amount);
}
}
public void setMainFluid(FluidStack fluid) {
public void setMainFluid(FluidStack fluid)
{
this.fluid = fluid;
}
public void setOutputFluid(FluidStack fluid) {
public void setOutputFluid(FluidStack fluid)
{
this.fluidOutput = fluid;
}
public void setInputFluid(FluidStack fluid) {
public void setInputFluid(FluidStack fluid)
{
this.fluidInput = fluid;
}
public AltarUpgrade getUpgrade() {
public AltarUpgrade getUpgrade()
{
return upgrade;
}
public void setUpgrade(AltarUpgrade upgrade) {
public void setUpgrade(AltarUpgrade upgrade)
{
this.upgrade = upgrade;
}
public int getCapacity() {
public int getCapacity()
{
return capacity;
}
public FluidStack getFluid() {
public FluidStack getFluid()
{
return fluid;
}
public int getFluidAmount() {
public int getFluidAmount()
{
return fluid.amount;
}
public int getCurrentBlood() {
public int getCurrentBlood()
{
return getFluidAmount();
}
public EnumAltarTier getTier() {
public EnumAltarTier getTier()
{
return altarTier;
}
public void setTier(EnumAltarTier tier) {
public void setTier(EnumAltarTier tier)
{
this.altarTier = tier;
}
public int getProgress() {
public int getProgress()
{
return progress;
}
public float getSacrificeMultiplier() {
public float getSacrificeMultiplier()
{
return sacrificeEfficiencyMultiplier;
}
public float getSelfSacrificeMultiplier() {
public float getSelfSacrificeMultiplier()
{
return selfSacrificeEfficiencyMultiplier;
}
public float getOrbMultiplier() {
public float getOrbMultiplier()
{
return orbCapacityMultiplier;
}
public float getDislocationMultiplier() {
public float getDislocationMultiplier()
{
return dislocationMultiplier;
}
public float getConsumptionMultiplier() {
public float getConsumptionMultiplier()
{
return consumptionMultiplier;
}
public float getConsumptionRate() {
public float getConsumptionRate()
{
return consumptionRate;
}
public int getLiquidRequired() {
public int getLiquidRequired()
{
return liquidRequired;
}
public int getBufferCapacity() {
public int getBufferCapacity()
{
return bufferCapacity;
}
public void addToDemonBloodDuration(int dur) {
public void addToDemonBloodDuration(int dur)
{
this.demonBloodDuration += dur;
}
public boolean hasDemonBlood() {
public boolean hasDemonBlood()
{
return this.demonBloodDuration > 0;
}
public void decrementDemonBlood() {
public void decrementDemonBlood()
{
this.demonBloodDuration = Math.max(0, this.demonBloodDuration - 1);
}
public void setActive() {
public void setActive()
{
isActive = false;
}
public boolean isActive() {
public boolean isActive()
{
return isActive;
}
public void requestPauseAfterCrafting(int amount) {
if (this.isActive) {
public void requestPauseAfterCrafting(int amount)
{
if (this.isActive)
{
this.cooldownAfterCrafting = amount;
}
}

View file

@ -7,22 +7,26 @@ import net.minecraftforge.fml.common.registry.GameData;
@Getter
@EqualsAndHashCode
public class BlockStack {
public class BlockStack
{
private final Block block;
private final int meta;
public BlockStack(Block block, int meta) {
public BlockStack(Block block, int meta)
{
this.block = block;
this.meta = meta;
}
public BlockStack(Block block) {
public BlockStack(Block block)
{
this(block, 0);
}
@Override
public String toString() {
public String toString()
{
return GameData.getBlockRegistry().getNameForObject(block) + ":" + meta;
}
}

View file

@ -8,12 +8,14 @@ import net.minecraft.util.DamageSource;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class BloodMagicAPI {
public class BloodMagicAPI
{
public static final String ORB = "ItemBloodOrb";
public static final String SCRIBE = "ItemInscriptionTool";
@Getter @Setter
@Getter
@Setter
private static boolean loggingEnabled;
@Getter
@ -23,16 +25,20 @@ public class BloodMagicAPI {
private static DamageSource damageSource = new DamageSourceBloodMagic();
/**
* Used to obtain Items from BloodMagic. Use the constants above for common items in case internal names
* change.
* Used to obtain Items from BloodMagic. Use the constants above for common
* items in case internal names change.
*
* @param name - The registered name of the item. Usually the same as the class name.
* @param name
* - The registered name of the item. Usually the same as the
* class name.
* @return - The requested Item
*/
public static Item getItem(String name) {
public static Item getItem(String name)
{
return GameRegistry.findItem(Constants.Mod.MODID, name);
}
@Getter @Setter
@Getter
@Setter
private static Fluid lifeEssence;
}

View file

@ -4,9 +4,11 @@ import net.minecraft.potion.Potion;
import java.util.Locale;
public class Constants {
public class Constants
{
public static class NBT {
public static class NBT
{
public static final String OWNER_UUID = "ownerUUID";
public static final String USES = "uses";
@ -62,7 +64,8 @@ public class Constants {
public static final String CONTAINED_BLOCK_META = "containedBlockMeta";
}
public static class Mod {
public static class Mod
{
public static final String MODID = "BloodMagic";
public static final String DOMAIN = MODID.toLowerCase(Locale.ENGLISH) + ":";
@ -71,13 +74,15 @@ public class Constants {
public static final String DEPEND = "";
}
public static class Compat {
public static class Compat
{
public static final String JEI_CATEGORY_ALTAR = Mod.MODID + ":altar";
public static final String JEI_CATEGORY_BINDING = Mod.MODID + ":binding";
public static final String JEI_CATEGORY_ALCHEMYARRAY = Mod.MODID + ":alchemyArray";
}
public static class Misc {
public static class Misc
{
public static final int POTION_ARRAY_SIZE = Potion.potionTypes.length;
}
}

View file

@ -6,9 +6,11 @@ import net.minecraft.util.ChatComponentText;
import net.minecraft.util.DamageSource;
import net.minecraft.util.IChatComponent;
public class DamageSourceBloodMagic extends DamageSource {
public class DamageSourceBloodMagic extends DamageSource
{
public DamageSourceBloodMagic() {
public DamageSourceBloodMagic()
{
super("bloodMagic");
setDamageBypassesArmor();
@ -16,7 +18,8 @@ public class DamageSourceBloodMagic extends DamageSource {
}
@Override
public IChatComponent getDeathMessage(EntityLivingBase livingBase) {
public IChatComponent getDeathMessage(EntityLivingBase livingBase)
{
return new ChatComponentText(TextHelper.localizeEffect("chat.BloodMagic.damageSource", livingBase.getName()));
}
}

View file

@ -10,7 +10,8 @@ import net.minecraft.nbt.NBTTagCompound;
@RequiredArgsConstructor
@EqualsAndHashCode
public class ItemStackWrapper {
public class ItemStackWrapper
{
public final Item item;
public final int stackSize;
@ -18,44 +19,54 @@ public class ItemStackWrapper {
@Setter
public NBTTagCompound nbtTag;
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 static ItemStackWrapper getHolder(ItemStack stack) {
public static ItemStackWrapper getHolder(ItemStack stack)
{
return new ItemStackWrapper(stack.getItem(), stack.stackSize, stack.getItemDamage());
}
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;

View file

@ -2,7 +2,8 @@ package WayofTime.bloodmagic.api.alchemyCrafting;
import net.minecraft.tileentity.TileEntity;
public abstract class AlchemyArrayEffect {
public abstract class AlchemyArrayEffect
{
public abstract boolean update(TileEntity tile, int ticksActive);

View file

@ -6,29 +6,35 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect {
public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect
{
@Getter
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 = 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();

View file

@ -9,56 +9,70 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
public class AlchemyCircleRenderer {
public class AlchemyCircleRenderer
{
public float offsetFromFace = -0.9f;
public final ResourceLocation arrayResource;
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) {
public void renderAt(TileEntity tile, double x, double y, double z, float craftTime)
{
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer wr = tessellator.getWorldRenderer();
@ -81,10 +95,10 @@ public class AlchemyCircleRenderer {
EnumFacing sideHit = EnumFacing.UP; // Specify which face this "circle"
// is located on
GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY()
* offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace);
GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace);
switch (sideHit) {
switch (sideHit)
{
case DOWN:
GlStateManager.translate(0, 0, 1);
GlStateManager.rotate(-90.0f, 1, 0, 0);

View file

@ -7,7 +7,8 @@ import net.minecraft.util.BlockPos;
* Used for building the altar structure.
*/
@Getter
public class AltarComponent {
public class AltarComponent
{
private BlockPos offset;
private boolean upgradeSlot;
@ -17,10 +18,13 @@ 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,7 +33,8 @@ public class AltarComponent {
* Use for setting a location at which there must be a block, but the type
* of block does not matter.
*/
public AltarComponent(BlockPos offset) {
public AltarComponent(BlockPos offset)
{
this(offset, EnumAltarComponent.NOTAIR);
}
@ -38,7 +43,8 @@ public class AltarComponent {
*
* @return the current instance for further use.
*/
public AltarComponent setUpgradeSlot() {
public AltarComponent setUpgradeSlot()
{
this.upgradeSlot = true;
return this;
}

View file

@ -7,7 +7,8 @@ import lombok.NoArgsConstructor;
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class AltarUpgrade {
public class AltarUpgrade
{
private int speedCount;
private int efficiencyCount;
@ -21,47 +22,56 @@ 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;
}

View file

@ -1,11 +1,7 @@
package WayofTime.bloodmagic.api.altar;
public enum EnumAltarComponent {
public enum EnumAltarComponent
{
GLOWSTONE,
BLOODSTONE,
BEACON,
BLOODRUNE,
CRYSTAL,
NOTAIR
GLOWSTONE, BLOODSTONE, BEACON, BLOODRUNE, CRYSTAL, NOTAIR
}

View file

@ -6,11 +6,13 @@ import net.minecraft.util.BlockPos;
import java.util.ArrayList;
@Getter
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));
@ -21,9 +23,11 @@ public enum EnumAltarTier {
altarComponents.add(new AltarComponent(new BlockPos(1, -1, 1), EnumAltarComponent.BLOODRUNE));
}
},
THREE() {
THREE()
{
@Override
public void buildComponents() {
public void buildComponents()
{
altarComponents.addAll(TWO.getAltarComponents());
altarComponents.add(new AltarComponent(new BlockPos(-1, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
altarComponents.add(new AltarComponent(new BlockPos(0, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
@ -46,7 +50,8 @@ 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());
@ -54,19 +59,23 @@ 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)));
@ -79,16 +88,19 @@ 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());
@ -96,12 +108,15 @@ 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)));
@ -113,7 +128,8 @@ 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());
@ -126,11 +142,13 @@ public enum EnumAltarTier {
ArrayList<AltarComponent> altarComponents = new ArrayList<AltarComponent>();
public void buildComponents() {
public void buildComponents()
{
}
public int toInt() {
public int toInt()
{
return ordinal() + 1;
}
}

View file

@ -1,6 +1,7 @@
package WayofTime.bloodmagic.api.altar;
public interface IAltarComponent {
public interface IAltarComponent
{
EnumAltarComponent getType(int meta);
}

View file

@ -1,8 +1,9 @@
package WayofTime.bloodmagic.api.altar;
/**
* Any item that implements this interface will not be pulled into the Altar
* on right click.
* Any item that implements this interface will not be pulled into the Altar on
* right click.
*/
public interface IAltarManipulator {
public interface IAltarManipulator
{
}

View file

@ -1,6 +1,7 @@
package WayofTime.bloodmagic.api.altar;
public interface IBloodAltar {
public interface IBloodAltar
{
int getCapacity();
@ -39,10 +40,12 @@ public interface IBloodAltar {
int fillMainTank(int amount);
/**
* Will set the altar to initiate a cooldown cycle after it crafts before starting to craft again, giving the user time to interact with the altar.
* 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);
}

View file

@ -3,11 +3,15 @@ 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
* Called to look at the inventory and syphons the required stack. Returns
* resultant stack if successful, and null if not.
*
* @param inv
* The inventory iterated through
* @return The result of the compression
*/
public abstract ItemStack compressInventory(ItemStack[] inv, World world);

View file

@ -9,31 +9,40 @@ import java.util.List;
import java.util.Map;
/**
* A registry aimed to help compress items in an inventory into its compressible form.
* 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;
}
}
@ -41,9 +50,12 @@ public class CompressionRegistry {
return null;
}
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();
}
}
@ -51,7 +63,8 @@ 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.getTagCompound() == null : stack.getTagCompound().equals(compressedStack.getTagCompound()));
}
}

View file

@ -2,21 +2,27 @@ package WayofTime.bloodmagic.api.event;
import net.minecraftforge.fml.common.eventhandler.Event;
public class AddToNetworkEvent extends Event {
public class AddToNetworkEvent extends Event
{
public String ownerNetwork;
public int addedAmount;
public int maximum;
/**
* This event is called whenever the network is added to. If cancelled, no LP will be drained from the source. If result is set to Result.DENY,
* the LP will still be drained but the soul network will not be added to.
* 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;

View file

@ -5,32 +5,38 @@ 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;
}
@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;
}
}
@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;

View file

@ -6,13 +6,15 @@ 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;
public ItemBindEvent(EntityPlayer player, String key, ItemStack itemStack) {
public ItemBindEvent(EntityPlayer player, String key, ItemStack itemStack)
{
super();
this.player = player;
this.key = key;

View file

@ -12,30 +12,35 @@ 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;
}
/**
* This event is called when a ritual is activated. If cancelled, it will not activate.
* This event is called when a ritual is activated. If cancelled, it will
* not activate.
*
* {@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;
@ -45,28 +50,34 @@ public class RitualEvent extends Event {
}
/**
* This event is called when a Ritual effect is performed. If cancelled, the effect will not happen.
* This event is called when a Ritual effect is performed. If cancelled, the
* effect will not happen.
*
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#performRitual(World, BlockPos)}
*/
@Cancelable
public static class RitualRunEvent extends RitualEvent {
public static class RitualRunEvent extends RitualEvent
{
public RitualRunEvent(IMasterRitualStone mrs, String owner, Ritual ritual) {
public RitualRunEvent(IMasterRitualStone mrs, String owner, Ritual ritual)
{
super(mrs, owner, ritual);
}
}
/**
* This event is called when a Ritual is stopped by a {@link Ritual.BreakType}.
* This event is called when a Ritual is stopped by a
* {@link Ritual.BreakType}.
*
* {@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;
@ -74,13 +85,15 @@ 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;

View file

@ -5,13 +5,15 @@ 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 boolean shouldDrainHealth;
public boolean shouldFillAltar;
public SacrificeKnifeUsedEvent(EntityPlayer player, boolean shouldDrainHealth, boolean shouldFillAltar, int hp) {
public SacrificeKnifeUsedEvent(EntityPlayer player, boolean shouldDrainHealth, boolean shouldFillAltar, int hp)
{
this.player = player;
this.shouldDrainHealth = shouldDrainHealth;
this.shouldFillAltar = shouldFillAltar;

View file

@ -5,34 +5,41 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
public class SoulNetworkEvent extends Event {
public class SoulNetworkEvent extends Event
{
public final String ownerName;
public int syphon;
public SoulNetworkEvent(String ownerName, int syphon) {
public SoulNetworkEvent(String ownerName, int syphon)
{
this.ownerName = ownerName;
this.syphon = syphon;
}
@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;
}
}
@Cancelable
public static class PlayerDrainNetworkEvent extends SoulNetworkEvent {
public static class PlayerDrainNetworkEvent extends SoulNetworkEvent
{
public final EntityPlayer player;
public boolean shouldDamage; //If true, will damage regardless of if the network had enough inside it
public boolean shouldDamage; // If true, will damage regardless of if
// the network had enough inside it
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;
@ -40,20 +47,28 @@ public class SoulNetworkEvent extends Event {
}
@Cancelable
public static class ItemDrainNetworkEvent extends PlayerDrainNetworkEvent {
public static class ItemDrainNetworkEvent extends PlayerDrainNetworkEvent
{
public final ItemStack itemStack;
public float damageAmount; //Amount of damage that would incur if the network could not drain properly
public float damageAmount; // Amount of damage that would incur if the
// network could not drain properly
/**
* Set result to deny the action i.e. damage/drain anyways. Cancelling event prevents action without penalties
* 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, ItemStack itemStack, int drainAmount) {
public ItemDrainNetworkEvent(EntityPlayer player, String ownerNetwork, ItemStack itemStack, int drainAmount)
{
super(player, ownerNetwork, drainAmount);
this.itemStack = itemStack;
this.damageAmount = (float) (drainAmount) / 100.0f;

View file

@ -1,5 +1,6 @@
package WayofTime.bloodmagic.api.iface;
public interface IAltarReader {
public interface IAltarReader
{
}

View file

@ -6,7 +6,8 @@ import net.minecraft.item.ItemStack;
/**
* Implement this interface on any Item that can be bound to a player.
*/
public interface IBindable {
public interface IBindable
{
/**
* Called when the player attempts to bind the item.

View file

@ -1,4 +1,5 @@
package WayofTime.bloodmagic.api.iface;
public interface ISigil {
public interface ISigil
{
}

View file

@ -7,12 +7,14 @@ import java.util.List;
import net.minecraft.nbt.NBTTagCompound;
public class LivingArmourHandler {
public class LivingArmourHandler
{
public static List<Class<? extends StatTracker>> trackers = new ArrayList();
public static HashMap<String, Class<? extends LivingArmourUpgrade>> upgradeMap = new HashMap();
public static HashMap<String, Constructor<? extends LivingArmourUpgrade>> upgradeConstructorMap = new HashMap();
public static void registerStatTracker(Class<? extends StatTracker> tracker) {
public static void registerStatTracker(Class<? extends StatTracker> tracker)
{
trackers.add(tracker);
}
@ -22,36 +24,47 @@ public class LivingArmourHandler {
*
* @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);
try {
try
{
Constructor<? extends LivingArmourUpgrade> ctor = clazz.getConstructor(int.class);
if (ctor == null) {
if (ctor == null)
{
// TODO: This is bad - add something to the log
} 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();
}
}

View file

@ -9,7 +9,8 @@ import WayofTime.bloodmagic.livingArmour.LivingArmour;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
public abstract class LivingArmourUpgrade {
public abstract class LivingArmourUpgrade
{
protected int level = 0; // Upgrade level 0 is the first upgrade. Upgrade
// goes from 0 to getMaxTier() - 1.
@ -22,7 +23,8 @@ public abstract class LivingArmourUpgrade {
* @param level
* The level of the upgrade
*/
public LivingArmourUpgrade(int level) {
public LivingArmourUpgrade(int level)
{
this.level = level;
}
@ -41,9 +43,12 @@ public abstract class LivingArmourUpgrade {
public abstract int getCostOfUpgrade();
public void onTick(World world, EntityPlayer player, LivingArmour livingArmour){}
public void onTick(World world, EntityPlayer player, LivingArmour livingArmour)
{
}
public Multimap<String, AttributeModifier> getAttributeModifiers() {
public Multimap<String, AttributeModifier> getAttributeModifiers()
{
return HashMultimap.<String, AttributeModifier> create();
}

View file

@ -5,7 +5,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import WayofTime.bloodmagic.livingArmour.LivingArmour;
public abstract class StatTracker {
public abstract class StatTracker
{
private boolean isDirty = false;
@ -37,15 +38,18 @@ public abstract class StatTracker {
public abstract LivingArmourUpgrade[] getUpgrades();
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;
}
}

View file

@ -22,14 +22,16 @@ import javax.annotation.Nullable;
@Getter
@Setter
public class SoulNetwork extends WorldSavedData {
public class SoulNetwork extends WorldSavedData
{
@Nullable
private final EntityPlayer player;
private int currentEssence;
private int orbTier;
public SoulNetwork(String name) {
public SoulNetwork(String name)
{
super(name);
currentEssence = 0;
@ -38,18 +40,21 @@ public class SoulNetwork extends WorldSavedData {
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
public void readFromNBT(NBTTagCompound nbttagcompound)
{
currentEssence = nbttagcompound.getInteger(Constants.NBT.CURRENT_ESSENCE);
orbTier = nbttagcompound.getInteger(Constants.NBT.ORB_TIER);
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
public void writeToNBT(NBTTagCompound nbttagcompound)
{
nbttagcompound.setInteger(Constants.NBT.CURRENT_ESSENCE, currentEssence);
nbttagcompound.setInteger(Constants.NBT.ORB_TIER, orbTier);
}
public int addLifeEssence(int toAdd, int maximum) {
public int addLifeEssence(int toAdd, int maximum)
{
AddToNetworkEvent event = new AddToNetworkEvent(mapName, toAdd, maximum);
if (MinecraftForge.EVENT_BUS.post(event))
@ -61,7 +66,8 @@ public class SoulNetwork extends WorldSavedData {
World world = MinecraftServer.getServer().worldServers[0];
SoulNetwork data = (SoulNetwork) world.loadItemData(SoulNetwork.class, event.ownerNetwork);
if (data == null) {
if (data == null)
{
data = new SoulNetwork(event.ownerNetwork);
world.setItemData(event.ownerNetwork, data);
}
@ -83,8 +89,10 @@ public class SoulNetwork extends WorldSavedData {
/**
* Used to syphon LP from the network
*/
public int syphon(int syphon) {
if (getCurrentEssence() >= syphon) {
public int syphon(int syphon)
{
if (getCurrentEssence() >= syphon)
{
setCurrentEssence(getCurrentEssence() - syphon);
markDirty();
return syphon;
@ -94,19 +102,22 @@ public class SoulNetwork extends WorldSavedData {
}
/**
* If the player exists on the server, syphon the given amount of LP from the player's LP network and
* damage for any remaining LP required.
* If the player exists on the server, syphon the given amount of LP from
* the player's LP network and damage for any remaining LP required.
*
* Always returns false on the client side.
*
* @return - Whether the action should be performed.
*/
public boolean syphonAndDamage(int toSyphon) {
if (getPlayer() != null) {
public boolean syphonAndDamage(int toSyphon)
{
if (getPlayer() != null)
{
if (getPlayer().worldObj.isRemote)
return false;
if (!Strings.isNullOrEmpty(mapName)) {
if (!Strings.isNullOrEmpty(mapName))
{
SoulNetworkEvent.ItemDrainNetworkEvent event = new SoulNetworkEvent.ItemDrainNetworkEvent(player, mapName, getPlayer().getHeldItem(), toSyphon);
if (MinecraftForge.EVENT_BUS.post(event))
@ -129,18 +140,25 @@ public class SoulNetwork extends WorldSavedData {
return false;
}
public void hurtPlayer(float syphon) {
if (getPlayer() != null) {
public void hurtPlayer(float syphon)
{
if (getPlayer() != null)
{
getPlayer().addPotionEffect(new PotionEffect(Potion.confusion.getId(), 20));
if (syphon < 100 && syphon > 0) {
if (!getPlayer().capabilities.isCreativeMode) {
if (syphon < 100 && syphon > 0)
{
if (!getPlayer().capabilities.isCreativeMode)
{
getPlayer().hurtResistantTime = 0;
getPlayer().attackEntityFrom(BloodMagicAPI.getDamageSource(), 1.0F);
}
} else if (syphon >= 100) {
if (!getPlayer().capabilities.isCreativeMode) {
for (int i = 0; i < ((syphon + 99) / 100); i++) {
} else if (syphon >= 100)
{
if (!getPlayer().capabilities.isCreativeMode)
{
for (int i = 0; i < ((syphon + 99) / 100); i++)
{
getPlayer().hurtResistantTime = 0;
getPlayer().attackEntityFrom(BloodMagicAPI.getDamageSource(), 1.0F);
}

View file

@ -5,11 +5,14 @@ import WayofTime.bloodmagic.api.registry.OrbRegistry;
/**
* Base object for all Blood Orbs. Makes Orb creation quite a bit easier.
*
* Just create a new BloodOrb instance then register it with {@link OrbRegistry#registerOrb(BloodOrb)}
* This will allow the use of just one item ID for all orbs. If an addon dev needs more control over the intricacies
* of their orb (custom right clicking, renderers, etc), they can just create their own item as normal.
* Just create a new BloodOrb instance then register it with
* {@link OrbRegistry#registerOrb(BloodOrb)} This will allow the use of just one
* item ID for all orbs. If an addon dev needs more control over the intricacies
* of their orb (custom right clicking, renderers, etc), they can just create
* their own item as normal.
*/
public class BloodOrb {
public class BloodOrb
{
private String name;
private int tier;
@ -17,52 +20,58 @@ public class BloodOrb {
private String owner = "BloodMagic";
/**
* A base object for BloodOrbs. A bit cleaner than the
* old way through EnergyItems.
* 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;
}
public String getOwner() {
public String getOwner()
{
return owner;
}
/**
* For setting the MODID of the mod that creates the Orb. Not required, but preferred.
* For setting the MODID of the mod that creates the Orb. Not required, but
* preferred.
*
* @return - The BloodOrb object for further use.
*/
public BloodOrb setOwner(String owner) {
public BloodOrb setOwner(String owner)
{
this.owner = owner;
return this;
}
@Override
public String toString() {
return "BloodOrb{" +
"name='" + name + '\'' +
", tier=" + tier +
", capacity=" + capacity +
", owner=" + owner +
'}';
public String toString()
{
return "BloodOrb{" + "name='" + name + '\'' + ", tier=" + tier + ", capacity=" + capacity + ", owner=" + owner + '}';
}
}

View file

@ -1,6 +1,7 @@
package WayofTime.bloodmagic.api.orb;
public interface IBloodOrb {
public interface IBloodOrb
{
BloodOrb getOrb(int meta);

View file

@ -19,7 +19,8 @@ import WayofTime.bloodmagic.api.orb.IBloodOrb;
/**
* Shaped Blood Orb Recipe Handler by joshie *
*/
public class ShapedBloodOrbRecipe implements IRecipe {
public class ShapedBloodOrbRecipe implements IRecipe
{
private static final int MAX_CRAFT_GRID_WIDTH = 3;
private static final int MAX_CRAFT_GRID_HEIGHT = 3;
@ -29,40 +30,50 @@ public class ShapedBloodOrbRecipe implements IRecipe {
public int height = 0;
private boolean mirrored = true;
public ShapedBloodOrbRecipe(Block result, Object... recipe) {
public ShapedBloodOrbRecipe(Block result, Object... recipe)
{
this(new ItemStack(result), recipe);
}
public ShapedBloodOrbRecipe(Item result, Object... recipe) {
public ShapedBloodOrbRecipe(Item result, Object... recipe)
{
this(new ItemStack(result), recipe);
}
public ShapedBloodOrbRecipe(ItemStack result, Object... recipe) {
public ShapedBloodOrbRecipe(ItemStack result, Object... recipe)
{
output = result.copy();
String shape = "";
int idx = 0;
if (recipe[idx] instanceof Boolean) {
if (recipe[idx] instanceof Boolean)
{
mirrored = (Boolean) recipe[idx];
if (recipe[idx + 1] instanceof Object[]) {
if (recipe[idx + 1] instanceof Object[])
{
recipe = (Object[]) recipe[idx + 1];
} else {
} else
{
idx = 1;
}
}
if (recipe[idx] instanceof String[]) {
if (recipe[idx] instanceof String[])
{
String[] parts = ((String[]) recipe[idx++]);
for (String s : parts) {
for (String s : parts)
{
width = s.length();
shape += s;
}
height = parts.length;
} else {
while (recipe[idx] instanceof String) {
} else
{
while (recipe[idx] instanceof String)
{
String s = (String) recipe[idx++];
shape += s;
width = s.length();
@ -70,9 +81,11 @@ public class ShapedBloodOrbRecipe implements IRecipe {
}
}
if (width * height != shape.length()) {
if (width * height != shape.length())
{
String ret = "Invalid shaped ore recipe: ";
for (Object tmp : recipe) {
for (Object tmp : recipe)
{
ret += tmp + ", ";
}
ret += output;
@ -81,27 +94,36 @@ public class ShapedBloodOrbRecipe implements IRecipe {
HashMap<Character, Object> itemMap = new HashMap<Character, Object>();
for (; idx < recipe.length; idx += 2) {
for (; idx < recipe.length; idx += 2)
{
Character chr = (Character) recipe[idx];
Object in = recipe[idx + 1];
if (in instanceof IBloodOrb || (in instanceof ItemStack && ((ItemStack) in).getItem() instanceof IBloodOrb)) {
// If the item is an instanceof IBloodOrb then save the level of the orb.
if (in instanceof IBloodOrb || (in instanceof ItemStack && ((ItemStack) in).getItem() instanceof IBloodOrb))
{
// If the item is an instanceof IBloodOrb then save the level of
// the orb.
if (in instanceof ItemStack)
itemMap.put(chr, ((IBloodOrb) ((ItemStack) in).getItem()).getOrbLevel(((ItemStack) in).getItemDamage()));
else
itemMap.put(chr, ((IBloodOrb) in).getOrbLevel(((ItemStack) in).getItemDamage()));
} else if (in instanceof ItemStack) {
} else if (in instanceof ItemStack)
{
itemMap.put(chr, ((ItemStack) in).copy());
} else if (in instanceof Item) {
} else if (in instanceof Item)
{
itemMap.put(chr, new ItemStack((Item) in));
} else if (in instanceof Block) {
} else if (in instanceof Block)
{
itemMap.put(chr, new ItemStack((Block) in, 1, OreDictionary.WILDCARD_VALUE));
} else if (in instanceof String) {
} else if (in instanceof String)
{
itemMap.put(chr, OreDictionary.getOres((String) in));
} else {
} else
{
String ret = "Invalid shaped orb recipe: ";
for (Object tmp : recipe) {
for (Object tmp : recipe)
{
ret += tmp + ", ";
}
ret += output;
@ -111,19 +133,22 @@ public class ShapedBloodOrbRecipe implements IRecipe {
input = new Object[width * height];
int x = 0;
for (char chr : shape.toCharArray()) {
for (char chr : shape.toCharArray())
{
input[x++] = itemMap.get(chr);
}
}
ShapedBloodOrbRecipe(ShapedRecipes recipe, Map<ItemStack, String> replacements) {
ShapedBloodOrbRecipe(ShapedRecipes recipe, Map<ItemStack, String> replacements)
{
output = recipe.getRecipeOutput();
width = recipe.recipeWidth;
height = recipe.recipeHeight;
input = new Object[recipe.recipeItems.length];
for (int i = 0; i < input.length; i++) {
for (int i = 0; i < input.length; i++)
{
ItemStack ingred = recipe.recipeItems[i];
if (ingred == null)
@ -131,8 +156,10 @@ public class ShapedBloodOrbRecipe implements IRecipe {
input[i] = recipe.recipeItems[i];
for (Entry<ItemStack, String> replace : replacements.entrySet()) {
if (OreDictionary.itemMatches(replace.getKey(), ingred, true)) {
for (Entry<ItemStack, String> replace : replacements.entrySet())
{
if (OreDictionary.itemMatches(replace.getKey(), ingred, true))
{
input[i] = OreDictionary.getOres(replace.getValue());
break;
}
@ -141,29 +168,37 @@ public class ShapedBloodOrbRecipe implements IRecipe {
}
@Override
public ItemStack getCraftingResult(InventoryCrafting var1) {
public ItemStack getCraftingResult(InventoryCrafting var1)
{
return output.copy();
}
@Override
public int getRecipeSize() {
public int getRecipeSize()
{
return input.length;
}
@Override
public ItemStack getRecipeOutput() {
public ItemStack getRecipeOutput()
{
return output;
}
@Override
public boolean matches(InventoryCrafting inv, World world) {
for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++) {
for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y) {
if (checkMatch(inv, x, y, false)) {
public boolean matches(InventoryCrafting inv, World world)
{
for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++)
{
for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y)
{
if (checkMatch(inv, x, y, false))
{
return true;
}
if (mirrored && checkMatch(inv, x, y, true)) {
if (mirrored && checkMatch(inv, x, y, true))
{
return true;
}
}
@ -173,17 +208,23 @@ public class ShapedBloodOrbRecipe implements IRecipe {
}
@SuppressWarnings("unchecked")
private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror) {
for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++) {
for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++) {
private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror)
{
for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++)
{
for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++)
{
int subX = x - startX;
int subY = y - startY;
Object target = null;
if (subX >= 0 && subY >= 0 && subX < width && subY < height) {
if (mirror) {
if (subX >= 0 && subY >= 0 && subX < width && subY < height)
{
if (mirror)
{
target = input[width - subX - 1 + subY * width];
} else {
} else
{
target = input[subX + subY * width];
}
}
@ -191,30 +232,39 @@ public class ShapedBloodOrbRecipe implements IRecipe {
ItemStack slot = inv.getStackInRowAndColumn(x, y);
// If target is integer, then we should be check the blood orb
// value of the item instead
if (target instanceof Integer) {
if (slot != null && slot.getItem() instanceof IBloodOrb) {
if (target instanceof Integer)
{
if (slot != null && slot.getItem() instanceof IBloodOrb)
{
IBloodOrb orb = (IBloodOrb) slot.getItem();
if (orb.getOrbLevel(slot.getItemDamage()) < (Integer) target) {
if (orb.getOrbLevel(slot.getItemDamage()) < (Integer) target)
{
return false;
}
} else
return false;
} else if (target instanceof ItemStack) {
if (!OreDictionary.itemMatches((ItemStack) target, slot, false)) {
} else if (target instanceof ItemStack)
{
if (!OreDictionary.itemMatches((ItemStack) target, slot, false))
{
return false;
}
} else if (target instanceof ArrayList) {
} else if (target instanceof ArrayList)
{
boolean matched = false;
Iterator<ItemStack> itr = ((ArrayList<ItemStack>) target).iterator();
while (itr.hasNext() && !matched) {
while (itr.hasNext() && !matched)
{
matched = OreDictionary.itemMatches(itr.next(), slot, false);
}
if (!matched) {
if (!matched)
{
return false;
}
} else if (target == null && slot != null) {
} else if (target == null && slot != null)
{
return false;
}
}
@ -223,19 +273,23 @@ public class ShapedBloodOrbRecipe implements IRecipe {
return true;
}
public ShapedBloodOrbRecipe setMirrored(boolean mirror) {
public ShapedBloodOrbRecipe setMirrored(boolean mirror)
{
mirrored = mirror;
return this;
}
public Object[] getInput() {
public Object[] getInput()
{
return this.input;
}
public ItemStack[] getRemainingItems(InventoryCrafting inv) {
public ItemStack[] getRemainingItems(InventoryCrafting inv)
{
ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()];
for (int i = 0; i < aitemstack.length; ++i) {
for (int i = 0; i < aitemstack.length; ++i)
{
ItemStack itemstack = inv.getStackInSlot(i);
aitemstack[i] = net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack);
}

View file

@ -19,35 +19,47 @@ import WayofTime.bloodmagic.api.orb.IBloodOrb;
/**
* Shapeless Blood Orb Recipe Handler by joshie *
*/
public class ShapelessBloodOrbRecipe implements IRecipe {
public class ShapelessBloodOrbRecipe implements IRecipe
{
private ItemStack output = null;
private ArrayList<Object> input = new ArrayList<Object>();
public ShapelessBloodOrbRecipe(Block result, Object... recipe) {
public ShapelessBloodOrbRecipe(Block result, Object... recipe)
{
this(new ItemStack(result), recipe);
}
public ShapelessBloodOrbRecipe(Item result, Object... recipe) {
public ShapelessBloodOrbRecipe(Item result, Object... recipe)
{
this(new ItemStack(result), recipe);
}
public ShapelessBloodOrbRecipe(ItemStack result, Object... recipe) {
public ShapelessBloodOrbRecipe(ItemStack result, Object... recipe)
{
output = result.copy();
for (Object in : recipe) {
if (in instanceof ItemStack) {
if (((ItemStack) in).getItem() instanceof IBloodOrb) {
for (Object in : recipe)
{
if (in instanceof ItemStack)
{
if (((ItemStack) in).getItem() instanceof IBloodOrb)
{
input.add(((IBloodOrb) ((ItemStack) in).getItem()).getOrbLevel(((ItemStack) in).getItemDamage()));
} else
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 shapeless ore recipe: ";
for (Object tmp : recipe) {
for (Object tmp : recipe)
{
ret += tmp + ", ";
}
ret += output;
@ -56,13 +68,17 @@ public class ShapelessBloodOrbRecipe implements IRecipe {
}
}
ShapelessBloodOrbRecipe(ShapelessRecipes recipe, Map<ItemStack, String> replacements) {
ShapelessBloodOrbRecipe(ShapelessRecipes recipe, Map<ItemStack, String> replacements)
{
output = recipe.getRecipeOutput();
for (ItemStack ingred : ((List<ItemStack>) recipe.recipeItems)) {
for (ItemStack ingred : ((List<ItemStack>) recipe.recipeItems))
{
Object finalObj = ingred;
for (Entry<ItemStack, String> replace : replacements.entrySet()) {
if (OreDictionary.itemMatches(replace.getKey(), ingred, false)) {
for (Entry<ItemStack, String> replace : replacements.entrySet())
{
if (OreDictionary.itemMatches(replace.getKey(), ingred, false))
{
finalObj = OreDictionary.getOres(replace.getValue());
break;
}
@ -72,65 +88,80 @@ public class ShapelessBloodOrbRecipe implements IRecipe {
}
@Override
public int getRecipeSize() {
public int getRecipeSize()
{
return input.size();
}
@Override
public ItemStack getRecipeOutput() {
public ItemStack getRecipeOutput()
{
return output;
}
@Override
public ItemStack getCraftingResult(InventoryCrafting var1) {
public ItemStack getCraftingResult(InventoryCrafting var1)
{
return output.copy();
}
@SuppressWarnings("unchecked")
@Override
public boolean matches(InventoryCrafting var1, World world) {
public boolean matches(InventoryCrafting var1, World world)
{
ArrayList<Object> required = new ArrayList<Object>(input);
for (int x = 0; x < var1.getSizeInventory(); x++) {
for (int x = 0; x < var1.getSizeInventory(); x++)
{
ItemStack slot = var1.getStackInSlot(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 target is integer, then we should be check the blood
// orb value of the item instead
if (next instanceof Integer) {
if (slot != null && slot.getItem() instanceof IBloodOrb) {
if (next instanceof Integer)
{
if (slot != null && slot.getItem() instanceof IBloodOrb)
{
IBloodOrb orb = (IBloodOrb) slot.getItem();
if (orb.getOrbLevel(slot.getItemDamage()) < (Integer) next) {
if (orb.getOrbLevel(slot.getItemDamage()) < (Integer) next)
{
return false;
}
} else
return false;
match = true;
} else if (next instanceof ItemStack) {
} else if (next instanceof ItemStack)
{
match = OreDictionary.itemMatches((ItemStack) next, slot, false);
} else if (next instanceof ArrayList) {
} else if (next instanceof ArrayList)
{
Iterator<ItemStack> itr = ((ArrayList<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;
}
}
@ -139,15 +170,18 @@ public class ShapelessBloodOrbRecipe implements IRecipe {
return required.isEmpty();
}
public ArrayList<Object> getInput() {
public ArrayList<Object> getInput()
{
return this.input;
}
@Override
public ItemStack[] getRemainingItems(InventoryCrafting inv) {
public ItemStack[] getRemainingItems(InventoryCrafting inv)
{
ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()];
for (int i = 0; i < aitemstack.length; ++i) {
for (int i = 0; i < aitemstack.length; ++i)
{
ItemStack itemstack = inv.getStackInSlot(i);
aitemstack[i] = net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack);
}

View file

@ -17,7 +17,8 @@ import com.google.common.collect.HashBiMap;
import javax.annotation.Nullable;
public class AlchemyArrayRecipeRegistry {
public class AlchemyArrayRecipeRegistry
{
public static final AlchemyCircleRenderer defaultRenderer = new AlchemyCircleRenderer(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png"));
@ -40,16 +41,22 @@ public class AlchemyArrayRecipeRegistry {
* - Circle rendered when the array is passive - can be
* substituted for a special renderer
*/
public static void registerRecipe(ItemStack inputStack, @Nullable ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) {
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet()) {
public static void registerRecipe(ItemStack inputStack, @Nullable ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer)
{
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet())
{
AlchemyArrayRecipe arrayRecipe = entry.getValue();
if (arrayRecipe.doesInputMatchRecipe(inputStack)) {
if (arrayRecipe.doesInputMatchRecipe(inputStack))
{
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 (circleRenderer != null)
{
arrayRecipe.circleRenderer = circleRenderer;
}
return;
@ -57,62 +64,79 @@ public class AlchemyArrayRecipeRegistry {
}
}
if (circleRenderer == null) {
if (circleRenderer == null)
{
recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, defaultRenderer));
} else {
} else
{
recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, circleRenderer));
}
recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, circleRenderer));
}
public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack, AlchemyCircleRenderer circleRenderer) {
public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack, AlchemyCircleRenderer circleRenderer)
{
registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack), circleRenderer);
}
public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource) {
public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource)
{
registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack), arrayResource);
}
public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack) {
public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack)
{
registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack));
}
public static void registerRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource) {
public static void registerRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource)
{
AlchemyCircleRenderer circleRenderer = null;
if (arrayResource == null) {
if (arrayResource == null)
{
circleRenderer = defaultRenderer;
} else {
} else
{
circleRenderer = new AlchemyCircleRenderer(arrayResource);
}
registerRecipe(inputStack, catalystStack, arrayEffect, circleRenderer);
}
public static void registerRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect) {
public static void registerRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect)
{
registerRecipe(inputStack, catalystStack, arrayEffect, (AlchemyCircleRenderer) null);
}
public static void replaceAlchemyCircle(ItemStack inputStack, AlchemyCircleRenderer circleRenderer) {
if (circleRenderer == null) {
public static void replaceAlchemyCircle(ItemStack inputStack, AlchemyCircleRenderer circleRenderer)
{
if (circleRenderer == null)
{
return;
}
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet()) {
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet())
{
AlchemyArrayRecipe arrayRecipe = entry.getValue();
if (arrayRecipe.doesInputMatchRecipe(inputStack)) {
if (arrayRecipe.doesInputMatchRecipe(inputStack))
{
arrayRecipe.circleRenderer = circleRenderer;
}
}
}
public static AlchemyArrayRecipe getRecipeForInput(ItemStack input) {
public static AlchemyArrayRecipe getRecipeForInput(ItemStack input)
{
return recipes.get(input);
}
public static AlchemyArrayEffect getAlchemyArrayEffect(ItemStack inputStack, @Nullable ItemStack catalystStack) {
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet()) {
public static AlchemyArrayEffect getAlchemyArrayEffect(ItemStack inputStack, @Nullable ItemStack catalystStack)
{
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet())
{
AlchemyArrayRecipe arrayRecipe = entry.getValue();
if (ItemStackWrapper.getHolder(arrayRecipe.getInputStack()).equals(ItemStackWrapper.getHolder(inputStack))) {
if (ItemStackWrapper.getHolder(arrayRecipe.getInputStack()).equals(ItemStackWrapper.getHolder(inputStack)))
{
AlchemyArrayEffect effect = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
return effect; // TODO: Decide if a copy should be returned.
@ -122,10 +146,13 @@ public class AlchemyArrayRecipeRegistry {
return null;
}
public static AlchemyCircleRenderer getAlchemyCircleRenderer(ItemStack inputStack) {
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet()) {
public static AlchemyCircleRenderer getAlchemyCircleRenderer(ItemStack inputStack)
{
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet())
{
AlchemyArrayRecipe arrayRecipe = entry.getValue();
if (arrayRecipe.doesInputMatchRecipe(inputStack)) {
if (arrayRecipe.doesInputMatchRecipe(inputStack))
{
return arrayRecipe.circleRenderer;
}
}
@ -136,13 +163,15 @@ public class AlchemyArrayRecipeRegistry {
@Getter
@ToString
@EqualsAndHashCode
public static class AlchemyArrayRecipe {
public static class AlchemyArrayRecipe
{
public AlchemyCircleRenderer circleRenderer;
public final ItemStack inputStack;
public final BiMap<ItemStackWrapper, AlchemyArrayEffect> catalystMap = HashBiMap.create();
public AlchemyArrayRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) {
public AlchemyArrayRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer)
{
this.inputStack = inputStack;
catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
@ -157,7 +186,8 @@ public class AlchemyArrayRecipeRegistry {
* @param comparedStack
* @return - true if the ItemStack is a compatible item
*/
public boolean doesInputMatchRecipe(ItemStack comparedStack) {
public boolean doesInputMatchRecipe(ItemStack comparedStack)
{
if (comparedStack == null || this.inputStack == null)
return false;
@ -171,18 +201,23 @@ public class AlchemyArrayRecipeRegistry {
* The catalyst that is being checked
* @return
*/
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) {
if (comparedStack == null && catalystStack == null)
{
return entry.getValue();
}
if (comparedStack == null || catalystStack == null) {
if (comparedStack == null || catalystStack == null)
{
continue;
}
if (catalystStack.isItemEqual(comparedStack)) {
if (catalystStack.isItemEqual(comparedStack))
{
return entry.getValue();
}
}

View file

@ -11,26 +11,29 @@ import net.minecraft.item.ItemStack;
import javax.annotation.Nullable;
public class AltarRecipeRegistry {
public class AltarRecipeRegistry
{
@Getter
private static BiMap<ItemStack, AltarRecipe> recipes = HashBiMap.create();
public static void registerRecipe(AltarRecipe recipe) {
public static void registerRecipe(AltarRecipe recipe)
{
if (!recipes.containsValue(recipe))
recipes.put(recipe.input, recipe);
else
BloodMagicAPI.getLogger().error("Error adding altar recipe for %s. Recipe already exists.", recipe.input.getDisplayName(), recipe.output == null ? "" : " -> ");
}
public static AltarRecipe getRecipeForInput(ItemStack input) {
public static AltarRecipe getRecipeForInput(ItemStack input)
{
return recipes.get(input);
}
@Getter
@ToString
@EqualsAndHashCode
public static class AltarRecipe {
public static class AltarRecipe
{
public final int syphon, consumeRate, drainRate;
public final boolean useTag;
@ -38,18 +41,29 @@ public class AltarRecipeRegistry {
public final EnumAltarTier minTier;
/**
* Allows creation of a recipe for the {@link WayofTime.bloodmagic.block.BlockAltar} / {@link WayofTime.bloodmagic.tile.TileAltar}.
* The output ItemStack is allowed to be null as some recipes do not contain an output. (Blood Orbs)
* Allows creation of a recipe for the
* {@link WayofTime.bloodmagic.block.BlockAltar} /
* {@link WayofTime.bloodmagic.tile.TileAltar}. The output ItemStack is
* allowed to be null as some recipes do not contain an output. (Blood
* Orbs)
*
* @param input - The input ItemStack
* @param output - The ItemStack obtained from the recipe
* @param minTier - The minimum tier of Altar required
* @param syphon - The amount of LP to syphon from the Altar
* @param consumeRate - The rate at which LP is consumed during crafting
* @param drainRate - The rate at which LP is drained during crafting
* @param useTag -
* @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 useTag
* -
*/
public AltarRecipe(ItemStack input, @Nullable ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean useTag) {
public AltarRecipe(ItemStack input, @Nullable ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean useTag)
{
this.input = input;
this.output = output;
this.minTier = minTier;
@ -59,19 +73,27 @@ public class AltarRecipeRegistry {
this.useTag = useTag;
}
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(input, output, minTier, syphon, consumeRate, drainRate, false);
}
public AltarRecipe(ItemStack input, EnumAltarTier minTier, int consumeRate, int drainRate) {
public AltarRecipe(ItemStack input, EnumAltarTier minTier, int consumeRate, int drainRate)
{
this(input, null, minTier, 0, consumeRate, drainRate);
}
public boolean doesRequiredItemMatch(ItemStack comparedStack, EnumAltarTier tierCheck) {
public boolean doesRequiredItemMatch(ItemStack comparedStack, EnumAltarTier tierCheck)
{
if (comparedStack == null || this.input == null)
return false;
return tierCheck.ordinal() >= minTier.ordinal() && this.input.isItemEqual(comparedStack);// && (this.useTag ? this.areRequiredTagsEqual(comparedStack) : true);
return tierCheck.ordinal() >= minTier.ordinal() && this.input.isItemEqual(comparedStack);// &&
// (this.useTag
// ?
// this.areRequiredTagsEqual(comparedStack)
// :
// true);
}
}
}

View file

@ -10,7 +10,8 @@ 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();
@ -18,11 +19,15 @@ public class ImperfectRitualRegistry {
/**
* 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) {
if (imperfectRitual != null) {
public static void registerRitual(ImperfectRitual imperfectRitual, String id)
{
if (imperfectRitual != null)
{
if (registry.containsKey(id))
BloodMagicAPI.getLogger().error("Duplicate imperfect ritual id: %s", id);
else
@ -30,11 +35,13 @@ public class ImperfectRitualRegistry {
}
}
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;
@ -42,44 +49,55 @@ 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.getLogger().error("Invalid Imperfect Ritual was called");
return false;
}
}
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());
}
}

View file

@ -14,15 +14,17 @@ import java.util.ArrayList;
import java.util.List;
/**
* This is only for those who wish to add a basic {@link BloodOrb}. If you need custom handling,
* you will need your own item class.
* This is only for those who wish to add a basic {@link BloodOrb}. If you need
* custom handling, you will need your own item class.
*/
public class OrbRegistry {
public class OrbRegistry
{
@Getter
private static List<BloodOrb> orbs = new ArrayList<BloodOrb>();
public static void registerOrb(BloodOrb orb) {
public static void registerOrb(BloodOrb orb)
{
if (!orbs.contains(orb))
orbs.add(orb);
else
@ -30,30 +32,36 @@ public class OrbRegistry {
}
@SideOnly(Side.CLIENT)
public static void registerOrbTexture(BloodOrb orb, String resourceLocation) {
public static void registerOrbTexture(BloodOrb orb, String resourceLocation)
{
int meta = getIndexOf(orb);
ModelBakery.addVariantName(BloodMagicAPI.getItem(BloodMagicAPI.ORB), resourceLocation);
ModelLoader.setCustomModelResourceLocation(BloodMagicAPI.getItem(BloodMagicAPI.ORB), meta, new ModelResourceLocation(resourceLocation, "inventory"));
}
public static BloodOrb getOrb(int index) {
public static BloodOrb getOrb(int index)
{
return orbs.get(index);
}
public static int getIndexOf(BloodOrb orb) {
public static int getIndexOf(BloodOrb orb)
{
return orbs.indexOf(orb);
}
public static boolean isEmpty() {
public static boolean isEmpty()
{
return orbs.isEmpty();
}
public static int getSize() {
public static int getSize()
{
return orbs.size();
}
public static ItemStack getOrbStack(BloodOrb orb) {
public static ItemStack getOrbStack(BloodOrb orb)
{
return new ItemStack(BloodMagicAPI.getItem(BloodMagicAPI.ORB), 1, getIndexOf(orb));
}
}

View file

@ -10,72 +10,91 @@ import WayofTime.bloodmagic.api.ritual.Ritual;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
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();
// Ordered list for actions that depend on the order that the rituals were registered in
// Ordered list for actions that depend on the order that the rituals were
// registered in
private static final ArrayList<String> orderedIdList = new ArrayList<String>();
/**
* 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) {
if (ritual != null) {
public static void registerRitual(Ritual ritual, String id)
{
if (ritual != null)
{
if (registry.containsKey(id))
BloodMagicAPI.getLogger().error("Duplicate ritual id: %s", id);
else {
else
{
registry.put(id, ritual);
orderedIdList.add(id);
}
}
}
public static Ritual getRitualForId(String id) {
public static Ritual getRitualForId(String id)
{
return registry.get(id);
}
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.getLogger().error("Invalid Ritual was called");
return false;
}
}
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>(registry.keySet());
}
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());
}
}

View file

@ -6,13 +6,16 @@ import java.util.List;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
public class AreaDescriptor {
public class AreaDescriptor
{
public List<BlockPos> getContainedPositions() {
public List<BlockPos> getContainedPositions()
{
return new ArrayList();
}
public AxisAlignedBB getAABB() {
public AxisAlignedBB getAABB()
{
return null;
}
}

View file

@ -6,34 +6,33 @@ import net.minecraft.util.IStringSerializable;
import java.util.Locale;
public enum EnumRuneType implements IStringSerializable {
public enum EnumRuneType implements IStringSerializable
{
BLANK,
WATER,
FIRE,
EARTH,
AIR,
DUSK,
DAWN;
BLANK, WATER, FIRE, EARTH, AIR, DUSK, DAWN;
public static EnumRuneType byMetadata(int meta) {
public static EnumRuneType byMetadata(int meta)
{
if (meta < 0 || meta >= values().length)
meta = 0;
return values()[meta];
}
public ItemStack getScribeStack() {
public ItemStack getScribeStack()
{
return new ItemStack(BloodMagicAPI.getItem(BloodMagicAPI.SCRIBE), 1, ordinal());
}
@Override
public String toString() {
public String toString()
{
return name().toLowerCase(Locale.ENGLISH);
}
@Override
public String getName() {
public String getName()
{
return this.toString();
}

View file

@ -11,7 +11,8 @@ import net.minecraft.world.World;
*
* It is provided via the API for easy obtaining of basic data.
*/
public interface IMasterRitualStone {
public interface IMasterRitualStone
{
String getOwner();

View file

@ -8,11 +8,13 @@ import net.minecraft.world.World;
*
* 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);
interface Tile {
interface Tile
{
boolean isRuneType(EnumRuneType runeType);
}
}

View file

@ -21,7 +21,8 @@ import net.minecraft.world.World;
@RequiredArgsConstructor
@EqualsAndHashCode(exclude = { "modableRangeMap" })
@ToString
public abstract class Ritual {
public abstract class Ritual
{
public final ArrayList<RitualComponent> ritualComponents = new ArrayList<RitualComponent>();
private final String name;
@ -40,7 +41,8 @@ public abstract class Ritual {
* @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);
}
@ -55,7 +57,8 @@ public abstract class Ritual {
* - The activating player
* @return - Whether activation was successful
*/
public boolean activateRitual(IMasterRitualStone masterRitualStone, EntityPlayer player) {
public boolean activateRitual(IMasterRitualStone masterRitualStone, EntityPlayer player)
{
return true;
}
@ -79,7 +82,8 @@ public abstract class Ritual {
* @param breakType
* - The type of break that caused the stoppage.
*/
public void stopRitual(IMasterRitualStone masterRitualStone, BreakType breakType) {
public void stopRitual(IMasterRitualStone masterRitualStone, BreakType breakType)
{
}
@ -97,11 +101,13 @@ public abstract class Ritual {
*
* @return - How often to perform the effect in ticks.
*/
public int getRefreshTime() {
public int getRefreshTime()
{
return 20;
}
public void addBlockRange(String range, BlockPos[] defaultRange) {
public void addBlockRange(String range, BlockPos[] defaultRange)
{
modableRangeMap.put(range, defaultRange);
}
@ -116,8 +122,10 @@ public abstract class Ritual {
* offset values and the second BlockPos having the higher offset
* values
*/
public BlockPos[] getBlockRange(String range) {
if (modableRangeMap.containsKey(range)) {
public BlockPos[] getBlockRange(String range)
{
if (modableRangeMap.containsKey(range))
{
return modableRangeMap.get(range);
}
@ -129,7 +137,8 @@ public abstract class Ritual {
*/
public abstract ArrayList<RitualComponent> getComponents();
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)
{
components.add(new RitualComponent(new BlockPos(offset1, y, offset2), rune));
components.add(new RitualComponent(new BlockPos(offset2, y, offset1), rune));
components.add(new RitualComponent(new BlockPos(offset1, y, -offset2), rune));
@ -140,21 +149,24 @@ public abstract class Ritual {
components.add(new RitualComponent(new BlockPos(-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)
{
components.add(new RitualComponent(new BlockPos(offset, y, offset), rune));
components.add(new RitualComponent(new BlockPos(offset, y, -offset), rune));
components.add(new RitualComponent(new BlockPos(-offset, y, -offset), rune));
components.add(new RitualComponent(new BlockPos(-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)
{
components.add(new RitualComponent(new BlockPos(offset, y, 0), rune));
components.add(new RitualComponent(new BlockPos(-offset, y, 0), rune));
components.add(new RitualComponent(new BlockPos(0, y, -offset), rune));
components.add(new RitualComponent(new BlockPos(0, y, offset), rune));
}
public enum BreakType {
public enum BreakType
{
REDSTONE, BREAK_MRS, BREAK_STONE, ACTIVATE, DEACTIVATE, EXPLOSION,
}
}

View file

@ -6,18 +6,21 @@ import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
/**
* Used to set a {@link EnumRuneType} type to a given {@link BlockPos}
* for usage in Ritual creation.
* Used to set a {@link EnumRuneType} type to a given {@link BlockPos} for usage
* in Ritual creation.
*/
@Getter
@RequiredArgsConstructor
public class RitualComponent {
public class RitualComponent
{
private final BlockPos offset;
private final EnumRuneType runeType;
public int getX(EnumFacing direction) {
switch (direction) {
public int getX(EnumFacing direction)
{
switch (direction)
{
case EAST:
return -this.getOffset().getZ();
case SOUTH:
@ -29,8 +32,10 @@ public class RitualComponent {
}
}
public int getZ(EnumFacing direction) {
switch (direction) {
public int getZ(EnumFacing direction)
{
switch (direction)
{
case EAST:
return this.getOffset().getX();
case SOUTH:
@ -42,7 +47,8 @@ public class RitualComponent {
}
}
public BlockPos getOffset(EnumFacing direction) {
public BlockPos getOffset(EnumFacing direction)
{
return new BlockPos(getX(direction), offset.getY(), getZ(direction));
}
}

View file

@ -3,11 +3,13 @@ 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);
}
}

View file

@ -9,7 +9,8 @@ import net.minecraft.world.World;
*
* 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);

View file

@ -9,13 +9,15 @@ import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
/**
* Abstract class for creating new imperfect rituals. ImperfectRituals need be registered with
* Abstract class for creating new imperfect rituals. ImperfectRituals need be
* registered with
* {@link WayofTime.bloodmagic.api.registry.ImperfectRitualRegistry#registerRitual(ImperfectRitual)}
*/
@RequiredArgsConstructor
@Getter
@EqualsAndHashCode
public abstract class ImperfectRitual {
public abstract class ImperfectRitual
{
private final String name;
private final BlockStack requiredBlock;
@ -23,11 +25,15 @@ public abstract class ImperfectRitual {
private final boolean lightshow;
/**
* @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) {
public ImperfectRitual(String name, BlockStack requiredBlock, int activationCost)
{
this(name, requiredBlock, activationCost, false);
}
@ -35,14 +41,18 @@ public abstract class ImperfectRitual {
* Called when the player activates the ritual
* {@link WayofTime.bloodmagic.tile.TileImperfectRitualStone#performRitual(World, 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);
@Override
public String toString() {
public String toString()
{
return getName() + ":" + getRequiredBlock().toString() + "@" + getActivationCost();
}
}

View file

@ -10,40 +10,50 @@ import net.minecraftforge.common.MinecraftForge;
import java.util.UUID;
public class BindableHelper {
public class BindableHelper
{
/**
* Bind an item to a player. Handles checking if the player was an instanceof
* {@link net.minecraftforge.common.util.FakePlayer} or other type of Fake Player.
* Bind an item to a player. Handles checking if the player was an
* instanceof {@link net.minecraftforge.common.util.FakePlayer} or other
* type of Fake Player.
*
* @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
*/
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));
}
/**
* Bind an item to a username.
*
* Requires the Item contained in the ItemStack to be an instanceof {@link IBindable}
* Requires the Item contained in the ItemStack to be an instanceof
* {@link IBindable}
*
* Fires {@link ItemBindEvent}.
*
* @param stack - The ItemStack to bind
* @param uuid - The username to bind the ItemStack to
* @param stack
* - The ItemStack to bind
* @param uuid
* - The username to bind the ItemStack to
*
* @return - Whether the binding was successful
*/
public static boolean checkAndSetItemOwner(ItemStack stack, String uuid) {
public static boolean checkAndSetItemOwner(ItemStack stack, String uuid)
{
stack = NBTHelper.checkNBT(stack);
if (!(stack.getItem() instanceof IBindable))
return false;
if (Strings.isNullOrEmpty(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID))) {
if (Strings.isNullOrEmpty(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID)))
{
MinecraftForge.EVENT_BUS.post(new ItemBindEvent(PlayerHelper.getPlayerFromUUID(uuid), uuid, stack));
((IBindable) stack.getItem()).onBind(PlayerHelper.getPlayerFromUUID(uuid), stack);
stack.getTagCompound().setString(Constants.NBT.OWNER_UUID, uuid);
@ -56,18 +66,22 @@ public class BindableHelper {
/**
* @see BindableHelper#checkAndSetItemOwner(ItemStack, String)
*/
public static boolean checkAndSetItemOwner(ItemStack stack, UUID uuid) {
public static boolean checkAndSetItemOwner(ItemStack stack, UUID uuid)
{
return checkAndSetItemOwner(stack, uuid.toString());
}
/**
* Sets the Owner of the item without checking if it is already bound.
* Also bypasses {@link ItemBindEvent}.
* Sets the Owner 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 setItemOwner(ItemStack stack, String ownerName) {
public static void setItemOwner(ItemStack stack, String ownerName)
{
stack = NBTHelper.checkNBT(stack);
stack.getTagCompound().setString(Constants.NBT.OWNER_UUID, ownerName);
@ -76,11 +90,13 @@ public class BindableHelper {
/**
* Used to safely obtain the username of the ItemStack's owner
*
* @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
*/
public static String getOwnerName(ItemStack stack) {
public static String getOwnerName(ItemStack stack)
{
stack = NBTHelper.checkNBT(stack);
return PlayerHelper.getUsernameFromStack(stack);
@ -89,11 +105,13 @@ public class BindableHelper {
/**
* Used to safely obtain the UUID of the ItemStack's owner
*
* @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
*/
public static String getOwnerUUID(ItemStack stack) {
public static String getOwnerUUID(ItemStack stack)
{
stack = NBTHelper.checkNBT(stack);
return stack.getTagCompound().getString(Constants.NBT.OWNER_UUID);

View file

@ -4,18 +4,22 @@ import WayofTime.bloodmagic.api.Constants;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
public class IncenseHelper {
public class IncenseHelper
{
public static float getCurrentIncense(EntityPlayer player) {
public static float getCurrentIncense(EntityPlayer player)
{
NBTTagCompound data = player.getEntityData();
if (data.hasKey(Constants.NBT.CURRENT_INCENSE)) {
if (data.hasKey(Constants.NBT.CURRENT_INCENSE))
{
return data.getFloat(Constants.NBT.CURRENT_INCENSE);
}
return 0;
}
public static void setCurrentIncense(EntityPlayer player, float amount) {
public static void setCurrentIncense(EntityPlayer player, float amount)
{
NBTTagCompound data = player.getEntityData();
data.setFloat(Constants.NBT.CURRENT_INCENSE, amount);
}

View file

@ -4,34 +4,41 @@ 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.isLoggingEnabled())
logger.info(info, format);
}
public void error(String error, Object ... format) {
public void error(String error, Object... format)
{
if (BloodMagicAPI.isLoggingEnabled())
logger.info(error, format);
}
public void debug(String debug, Object ... format) {
public void debug(String debug, Object... format)
{
if (BloodMagicAPI.isLoggingEnabled())
logger.info(debug, format);
}
public void fatal(String fatal, Object ... format) {
public void fatal(String fatal, Object... format)
{
logger.fatal(fatal, format);
}
public Logger getLogger() {
public Logger getLogger()
{
return logger;
}
}

View file

@ -3,9 +3,11 @@ package WayofTime.bloodmagic.api.util.helper;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class NBTHelper {
public class NBTHelper
{
public static ItemStack checkNBT(ItemStack stack) {
public static ItemStack checkNBT(ItemStack stack)
{
if (stack.getTagCompound() == null)
stack.setTagCompound(new NBTTagCompound());

View file

@ -15,22 +15,27 @@ 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 name - The username of the SoulNetwork owner
* @param world - The world
* @param name
* - The username of the SoulNetwork owner
* @param world
* - The world
*
* @return - The SoulNetwork for the given name.
*/
public static SoulNetwork getSoulNetwork(String name, World world) {
public static SoulNetwork getSoulNetwork(String name, World world)
{
SoulNetwork network = (SoulNetwork) world.getMapStorage().loadData(SoulNetwork.class, name);
if (network == null) {
if (network == null)
{
network = new SoulNetwork(name);
world.getMapStorage().setData(name, network);
}
@ -41,42 +46,51 @@ public class NetworkHelper {
/**
* @see NetworkHelper#getSoulNetwork(String, World)
*/
public static SoulNetwork getSoulNetwork(UUID uuid, World world) {
public static SoulNetwork getSoulNetwork(UUID uuid, World world)
{
return getSoulNetwork(PlayerHelper.getUsernameFromUUID(uuid), world);
}
/**
* @see NetworkHelper#getSoulNetwork(String, World)
*/
public static SoulNetwork getSoulNetwork(EntityPlayer player, World world) {
public static SoulNetwork getSoulNetwork(EntityPlayer player, World world)
{
return getSoulNetwork(PlayerHelper.getUUIDFromPlayer(player), world);
}
/**
* 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();
}
// Syphon
/**
* Syphons from the player and damages them if there was not enough stored LP.
* Syphons from the player and damages them if there was not enough stored
* LP.
*
* Handles null-checking the player for you.
*
* @param soulNetwork - SoulNetwork to syphon from
* @param toSyphon - Amount of LP to syphon
* @param soulNetwork
* - SoulNetwork to syphon from
* @param toSyphon
* - Amount of LP to syphon
*
* @return - Whether the action should be performed.
*/
public static boolean syphonAndDamage(SoulNetwork soulNetwork, int toSyphon) {
if (soulNetwork.getPlayer() == null) {
public static boolean syphonAndDamage(SoulNetwork soulNetwork, int toSyphon)
{
if (soulNetwork.getPlayer() == null)
{
soulNetwork.syphon(toSyphon);
return true;
}
@ -87,13 +101,17 @@ public class NetworkHelper {
/**
* Syphons a player from within a container.
*
* @param stack - ItemStack in the Container.
* @param world - The world the Container is in
* @param toSyphon - Amount of LP to syphon
* @param stack
* - ItemStack in the Container.
* @param world
* - The world the Container is in
* @param toSyphon
* - Amount of LP to syphon
*
* @return - If the syphon was successful.
*/
public static boolean syphonFromContainer(ItemStack stack, World world, int toSyphon) {
public static boolean syphonFromContainer(ItemStack stack, World world, int toSyphon)
{
stack = NBTHelper.checkNBT(stack);
String ownerName = stack.getTagCompound().getString(Constants.NBT.OWNER_UUID);
@ -110,13 +128,16 @@ public class NetworkHelper {
// Set
/**
* Sets the orb tier of the SoulNetwork to the given orb. Will not set
* if the given tier is lower than the current tier.
* 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()));
soulNetwork.markDirty();
}
@ -124,23 +145,29 @@ public class NetworkHelper {
// TODO - Remove everything below. It is deprecated and should not be used.
/**
* Master method used to syphon from the player's network, and will damage them accordingly if they do not have enough LP.
* Does not drain on the client side.
* Master method used to syphon from the player's network, and will damage
* them accordingly if they do not have enough LP. Does not drain on the
* client side.
*
* @param stack Owned itemStack
* @param player Player using the item
* @param stack
* Owned itemStack
* @param player
* Player using the item
*
* @return True if the action should be executed and false if it should not. Always returns false if client-sided.
* @return True if the action should be executed and false if it should not.
* Always returns false if client-sided.
*/
@Deprecated
public static boolean syphonAndDamageFromNetwork(ItemStack stack, EntityPlayer player, int syphon) {
public static boolean syphonAndDamageFromNetwork(ItemStack stack, EntityPlayer player, int syphon)
{
if (player.worldObj.isRemote)
return false;
stack = NBTHelper.checkNBT(stack);
String ownerName = stack.getTagCompound().getString(Constants.NBT.OWNER_UUID);
if (!Strings.isNullOrEmpty(ownerName)) {
if (!Strings.isNullOrEmpty(ownerName))
{
SoulNetworkEvent.ItemDrainNetworkEvent event = new SoulNetworkEvent.ItemDrainNetworkEvent(player, ownerName, stack, syphon);
if (MinecraftForge.EVENT_BUS.post(event))
@ -151,7 +178,8 @@ public class NetworkHelper {
if (drainAmount == 0 || event.shouldDamage)
hurtPlayer(player, event.syphon);
//The event has been told to prevent the action but allow all repercussions of using the item.
// The event has been told to prevent the action but allow all
// repercussions of using the item.
return event.getResult() != Event.Result.DENY;
}
@ -163,7 +191,8 @@ public class NetworkHelper {
}
@Deprecated
public static boolean syphonFromNetworkWhileInContainer(ItemStack stack, int syphon) {
public static boolean syphonFromNetworkWhileInContainer(ItemStack stack, int syphon)
{
stack = NBTHelper.checkNBT(stack);
String ownerName = stack.getTagCompound().getString(Constants.NBT.OWNER_UUID);
@ -179,7 +208,8 @@ public class NetworkHelper {
}
@Deprecated
public static int syphonFromNetwork(ItemStack stack, int syphon) {
public static int syphonFromNetwork(ItemStack stack, int syphon)
{
stack = NBTHelper.checkNBT(stack);
String ownerName = stack.getTagCompound().getString(Constants.NBT.OWNER_UUID);
if (!Strings.isNullOrEmpty(ownerName))
@ -189,19 +219,22 @@ public class NetworkHelper {
}
@Deprecated
public static int syphonFromNetwork(String ownerName, int syphon) {
public static int syphonFromNetwork(String ownerName, int syphon)
{
if (MinecraftServer.getServer() == null)
return 0;
World world = MinecraftServer.getServer().worldServers[0];
SoulNetwork network = (SoulNetwork) world.loadItemData(SoulNetwork.class, ownerName);
if (network == null) {
if (network == null)
{
network = new SoulNetwork(ownerName);
world.setItemData(ownerName, network);
}
if (network.getCurrentEssence() >= syphon) {
if (network.getCurrentEssence() >= syphon)
{
network.setCurrentEssence(network.getCurrentEssence() - syphon);
network.markDirty();
return syphon;
@ -218,7 +251,8 @@ public class NetworkHelper {
* @return amount added to the network
*/
@Deprecated
public static int addCurrentEssenceToMaximum(String ownerName, int addedEssence, int maximum) {
public static int addCurrentEssenceToMaximum(String ownerName, int addedEssence, int maximum)
{
AddToNetworkEvent event = new AddToNetworkEvent(ownerName, addedEssence, maximum);
if (MinecraftForge.EVENT_BUS.post(event))
@ -230,7 +264,8 @@ public class NetworkHelper {
World world = MinecraftServer.getServer().worldServers[0];
SoulNetwork data = (SoulNetwork) world.loadItemData(SoulNetwork.class, event.ownerNetwork);
if (data == null) {
if (data == null)
{
data = new SoulNetwork(event.ownerNetwork);
world.setItemData(event.ownerNetwork, data);
}
@ -250,14 +285,16 @@ public class NetworkHelper {
// Get
@Deprecated
public static int getCurrentEssence(String ownerName) {
public static int getCurrentEssence(String ownerName)
{
if (MinecraftServer.getServer() == null)
return 0;
World world = MinecraftServer.getServer().worldServers[0];
SoulNetwork network = (SoulNetwork) world.loadItemData(SoulNetwork.class, ownerName);
if (network == null) {
if (network == null)
{
network = new SoulNetwork(ownerName);
world.setItemData(ownerName, network);
}
@ -268,20 +305,27 @@ public class NetworkHelper {
// Do damage
@Deprecated
public static void hurtPlayer(EntityPlayer user, int energySyphoned) {
if (energySyphoned < 100 && energySyphoned > 0) {
if (!user.capabilities.isCreativeMode) {
public static void hurtPlayer(EntityPlayer user, int energySyphoned)
{
if (energySyphoned < 100 && energySyphoned > 0)
{
if (!user.capabilities.isCreativeMode)
{
user.setHealth((user.getHealth() - 1));
if (user.getHealth() <= 0.0005f)
user.onDeath(BloodMagicAPI.getDamageSource());
}
} else if (energySyphoned >= 100) {
if (!user.capabilities.isCreativeMode) {
for (int i = 0; i < ((energySyphoned + 99) / 100); i++) {
} else if (energySyphoned >= 100)
{
if (!user.capabilities.isCreativeMode)
{
for (int i = 0; i < ((energySyphoned + 99) / 100); i++)
{
user.setHealth((user.getHealth() - 1));
if (user.getHealth() <= 0.0005f) {
if (user.getHealth() <= 0.0005f)
{
user.onDeath(BloodMagicAPI.getDamageSource());
break;
}
@ -291,8 +335,10 @@ public class NetworkHelper {
}
@Deprecated
public static void hurtPlayer(EntityPlayer user, float damage) {
if (!user.capabilities.isCreativeMode) {
public static void hurtPlayer(EntityPlayer user, float damage)
{
if (!user.capabilities.isCreativeMode)
{
user.attackEntityFrom(BloodMagicAPI.getDamageSource(), 0F);
user.setHealth((user.getHealth() - damage));
}

View file

@ -13,59 +13,71 @@ import net.minecraftforge.common.util.FakePlayer;
import java.util.UUID;
import java.util.regex.Pattern;
public class PlayerHelper {
public class PlayerHelper
{
private static final Pattern FAKE_PLAYER_PATTERN = Pattern.compile("^(?:\\[.*\\])|(?:ComputerCraft)$");
public static String getUsernameFromPlayer(EntityPlayer player) {
public static String getUsernameFromPlayer(EntityPlayer player)
{
return UsernameCache.getLastKnownUsername(getUUIDFromPlayer(player));
}
public static EntityPlayer getPlayerFromUsername(String username) {
public static EntityPlayer getPlayerFromUsername(String username)
{
if (MinecraftServer.getServer() == null)
return null;
return MinecraftServer.getServer().getConfigurationManager().getPlayerByUsername(username);
}
public static EntityPlayer getPlayerFromUUID(String uuid) {
public static EntityPlayer getPlayerFromUUID(String uuid)
{
return getPlayerFromUsername(getUsernameFromUUID(uuid));
}
public static EntityPlayer getPlayerFromUUID(UUID uuid) {
public static EntityPlayer getPlayerFromUUID(UUID uuid)
{
return getPlayerFromUsername(getUsernameFromUUID(uuid));
}
public static UUID getUUIDFromPlayer(EntityPlayer player) {
public static UUID getUUIDFromPlayer(EntityPlayer player)
{
return player.getGameProfile().getId();
}
public static String getUsernameFromUUID(String uuid) {
public static String getUsernameFromUUID(String uuid)
{
return UsernameCache.getLastKnownUsername(UUID.fromString(uuid));
}
public static String getUsernameFromUUID(UUID uuid) {
public static String getUsernameFromUUID(UUID uuid)
{
return UsernameCache.getLastKnownUsername(uuid);
}
public static String getUsernameFromStack(ItemStack stack) {
public static String getUsernameFromStack(ItemStack stack)
{
stack = NBTHelper.checkNBT(stack);
return PlayerHelper.getUsernameFromUUID(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID));
}
public static boolean isFakePlayer(EntityPlayer player) {
public static boolean isFakePlayer(EntityPlayer player)
{
return player instanceof FakePlayer || FAKE_PLAYER_PATTERN.matcher(getUsernameFromPlayer(player)).matches();
}
public static void causeNauseaToPlayer(ItemStack stack) {
public static void causeNauseaToPlayer(ItemStack stack)
{
stack = NBTHelper.checkNBT(stack);
if (!Strings.isNullOrEmpty(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID)))
causeNauseaToPlayer(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID));
}
public static void causeNauseaToPlayer(String ownerName) {
public static void causeNauseaToPlayer(String ownerName)
{
EntityPlayer player = getPlayerFromUsername(ownerName);
if (player == null)

View file

@ -8,48 +8,59 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public class PlayerSacrificeHelper {
public class PlayerSacrificeHelper
{
public static float scalingOfSacrifice = 0.001f;
public static int soulFrayDuration = 400;
public static Potion soulFrayId;
public static float getPlayerIncense(EntityPlayer player) {
public static float getPlayerIncense(EntityPlayer player)
{
return IncenseHelper.getCurrentIncense(player);
}
public static void setPlayerIncense(EntityPlayer player, float amount) {
public static void setPlayerIncense(EntityPlayer player, float amount)
{
IncenseHelper.setCurrentIncense(player, amount);
}
public static boolean incrementIncense(EntityPlayer player, float min, float max, float increment) {
public static boolean incrementIncense(EntityPlayer player, float min, float max, float increment)
{
float amount = getPlayerIncense(player);
if (amount < min || amount >= max) {
if (amount < min || amount >= max)
{
return false;
}
amount = amount + Math.min(increment, max - amount);
setPlayerIncense(player, amount);
// System.out.println("Amount of incense: " + amount + ", Increment: " + increment);
// System.out.println("Amount of incense: " + amount + ", Increment: " +
// increment);
return true;
}
public static boolean sacrificePlayerHealth(EntityPlayer player) {
if (player.isPotionActive(soulFrayId)) {
public static boolean sacrificePlayerHealth(EntityPlayer player)
{
if (player.isPotionActive(soulFrayId))
{
return false;
}
float amount = getPlayerIncense(player);
if (amount >= 0) {
if (amount >= 0)
{
float health = player.getHealth();
float maxHealth = player.getMaxHealth();
if (health > maxHealth / 10.0) {
if (health > maxHealth / 10.0)
{
float sacrificedHealth = health - maxHealth / 10.0f;
if (findAndFillAltar(player.getEntityWorld(), player, (int) (sacrificedHealth * 100f * getModifier(amount)))) {
if (findAndFillAltar(player.getEntityWorld(), player, (int) (sacrificedHealth * 100f * getModifier(amount))))
{
player.setHealth(maxHealth / 10.0f);
setPlayerIncense(player, 0);
player.addPotionEffect(new PotionEffect(soulFrayId.id, soulFrayDuration));
@ -62,17 +73,20 @@ public class PlayerSacrificeHelper {
return false;
}
public static float getModifier(float amount) {
public static float getModifier(float amount)
{
return 1 + amount * scalingOfSacrifice;
}
public static boolean findAndFillAltar(World world, EntityPlayer player, int amount) {
public static boolean findAndFillAltar(World world, EntityPlayer player, int amount)
{
int posX = (int) Math.round(player.posX - 0.5f);
int posY = (int) player.posY;
int posZ = (int) Math.round(player.posZ - 0.5f);
IBloodAltar altarEntity = getAltar(world, new BlockPos(posX, posY, posZ));
if (altarEntity == null) {
if (altarEntity == null)
{
return false;
}
@ -82,15 +96,20 @@ public class PlayerSacrificeHelper {
return true;
}
public static IBloodAltar getAltar(World world, BlockPos blockPos) {
public static IBloodAltar getAltar(World world, BlockPos blockPos)
{
TileEntity tileEntity;
for (int i = -2; i <= 2; i++) {
for (int j = -2; j <= 2; j++) {
for (int k = -2; k <= 1; k++) {
for (int i = -2; i <= 2; i++)
{
for (int j = -2; j <= 2; j++)
{
for (int k = -2; k <= 1; k++)
{
tileEntity = world.getTileEntity(new BlockPos(i + blockPos.getX(), k + blockPos.getY(), j + blockPos.getZ()));
if (tileEntity instanceof IBloodAltar) {
if (tileEntity instanceof IBloodAltar)
{
return (IBloodAltar) tileEntity;
}
}

View file

@ -19,20 +19,24 @@ import WayofTime.bloodmagic.api.ritual.Ritual;
import WayofTime.bloodmagic.api.ritual.RitualComponent;
import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual;
public class RitualHelper {
public class RitualHelper
{
public static boolean canCrystalActivate(Ritual ritual, int crystalLevel) {
public static boolean canCrystalActivate(Ritual ritual, int crystalLevel)
{
return ritual.getCrystalLevel() <= crystalLevel && RitualRegistry.ritualEnabled(ritual);
}
public static String getNextRitualKey(String currentKey) {
public static String getNextRitualKey(String currentKey)
{
int currentIndex = RitualRegistry.getIds().indexOf(currentKey);
int nextIndex = RitualRegistry.getRituals().listIterator(currentIndex).nextIndex();
return RitualRegistry.getIds().get(nextIndex);
}
public static String getPrevRitualKey(String currentKey) {
public static String getPrevRitualKey(String currentKey)
{
int currentIndex = RitualRegistry.getIds().indexOf(currentKey);
int previousIndex = RitualRegistry.getIds().listIterator(currentIndex).previousIndex();
@ -40,16 +44,20 @@ public class RitualHelper {
}
/**
* Checks the RitualRegistry to see if the configuration of the ritual stones in the world is valid
* for the given EnumFacing.
* Checks the RitualRegistry to see if the configuration of the ritual
* stones in the world is valid for the given EnumFacing.
*
* @return The ID of the valid ritual
*/
public static String getValidRitual(World world, BlockPos pos) {
for(String key : RitualRegistry.getIds()) {
for(EnumFacing direction : EnumFacing.HORIZONTALS) {
public static String getValidRitual(World world, BlockPos pos)
{
for (String key : RitualRegistry.getIds())
{
for (EnumFacing direction : EnumFacing.HORIZONTALS)
{
boolean test = checkValidRitual(world, pos, key, direction);
if(test) {
if (test)
{
return key;
}
}
@ -58,10 +66,13 @@ public class RitualHelper {
return "";
}
public static EnumFacing getDirectionOfRitual(World world, BlockPos pos, String key) {
for(EnumFacing direction : EnumFacing.HORIZONTALS) {
public static EnumFacing getDirectionOfRitual(World world, BlockPos pos, String key)
{
for (EnumFacing direction : EnumFacing.HORIZONTALS)
{
boolean test = checkValidRitual(world, pos, key, direction);
if(test) {
if (test)
{
return direction;
}
}
@ -69,9 +80,11 @@ public class RitualHelper {
return null;
}
public static boolean checkValidRitual(World world, BlockPos pos, String ritualId, EnumFacing direction) {
public static boolean checkValidRitual(World world, BlockPos pos, String ritualId, EnumFacing direction)
{
Ritual ritual = RitualRegistry.getRitualForId(ritualId);
if(ritual == null) {
if (ritual == null)
{
return false;
}
@ -80,15 +93,19 @@ public class RitualHelper {
if (components == null)
return false;
for (RitualComponent component : components) {
for (RitualComponent component : components)
{
BlockPos newPos = pos.add(component.getOffset(direction));
IBlockState worldState = world.getBlockState(newPos);
Block block = worldState.getBlock();
if (block instanceof IRitualStone) {
if(!((IRitualStone)block).isRuneType(world, newPos, component.getRuneType())) {
if (block instanceof IRitualStone)
{
if (!((IRitualStone) block).isRuneType(world, newPos, component.getRuneType()))
{
return false;
}
}else {
} else
{
return false;
}
}
@ -96,31 +113,37 @@ public class RitualHelper {
return true;
}
public static void checkImperfectRituals(Configuration config, String packageName, String category) {
public static void checkImperfectRituals(Configuration config, String packageName, String category)
{
checkRituals(config, packageName, category, ImperfectRitual.class, ImperfectRitualRegistry.enabledRituals);
}
public static void checkRituals(Configuration config, String packageName, String category) {
public static void checkRituals(Configuration config, String packageName, String category)
{
checkRituals(config, packageName, category, Ritual.class, RitualRegistry.enabledRituals);
}
/**
* Adds your Ritual to the {@link RitualRegistry#enabledRituals} Map.
* This is used to determine whether your effect is enabled or not.
* Adds your Ritual to the {@link RitualRegistry#enabledRituals} Map. This
* is used to determine whether your effect is enabled or not.
*
* The config option will be created as {@code B:ClassName=true} with a comment of
* {@code Enables the ClassName ritual}.
* The config option will be created as {@code B:ClassName=true} with a
* comment of {@code Enables the ClassName ritual}.
*
* Use {@link #}
*
* Should be safe to modify at any point.
*
* @param config - Your mod's Forge {@link Configuration} object.
* @param packageName - The package your Rituals are located in.
* @param category - The config category to write to.
* @param config
* - Your mod's Forge {@link Configuration} object.
* @param packageName
* - The package your Rituals are located in.
* @param category
* - The config category to write to.
*/
@SuppressWarnings("unchecked")
private static void checkRituals(Configuration config, String packageName, String category, Class ritualClass, Map enabledMap) {
private static void checkRituals(Configuration config, String packageName, String category, Class ritualClass, Map enabledMap)
{
String name = packageName;
if (!name.startsWith("/"))
name = "/" + name;
@ -129,24 +152,31 @@ public class RitualHelper {
URL url = BloodMagic.class.getResource(name);
File directory = new File(url.getFile());
if (directory.exists()) {
if (directory.exists())
{
String[] files = directory.list();
for (String file : files) {
if (file.endsWith(".class")) {
for (String file : files)
{
if (file.endsWith(".class"))
{
String className = file.substring(0, file.length() - 6);
try {
try
{
Object o = Class.forName(packageName + "." + className).newInstance();
if (ritualClass.isInstance(o))
enabledMap.put(ritualClass.cast(o), config.get(category, className, true).getBoolean());
} catch (ClassNotFoundException e) {
} catch (ClassNotFoundException e)
{
e.printStackTrace();
} catch (InstantiationException e) {
} catch (InstantiationException e)
{
e.printStackTrace();
} catch (IllegalAccessException e) {
} catch (IllegalAccessException e)
{
e.printStackTrace();
}
}

View file

@ -23,9 +23,11 @@ import WayofTime.bloodmagic.tile.TileAlchemyArray;
import WayofTime.bloodmagic.tile.TileAlchemyArray;
import WayofTime.bloodmagic.util.Utils;
public class BlockAlchemyArray extends BlockContainer {
public class BlockAlchemyArray extends BlockContainer
{
public BlockAlchemyArray() {
public BlockAlchemyArray()
{
super(Material.cloth);
setUnlocalizedName(Constants.Mod.MODID + ".alchemyArray");
@ -34,28 +36,33 @@ public class BlockAlchemyArray extends BlockContainer {
}
@Override
public boolean isOpaqueCube() {
public boolean isOpaqueCube()
{
return false;
}
@Override
@SideOnly(Side.CLIENT)
public EnumWorldBlockLayer getBlockLayer() {
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
@Override
public boolean isFullCube() {
public boolean isFullCube()
{
return false;
}
@Override
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity) {
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity)
{
this.setBlockBounds(0, 0, 0, 1, 0.1f, 1);
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
{
TileAlchemyArray array = (TileAlchemyArray) world.getTileEntity(pos);
if (array == null || player.isSneaking())
@ -63,10 +70,13 @@ public class BlockAlchemyArray extends BlockContainer {
ItemStack playerItem = player.getCurrentEquippedItem();
if (playerItem != null) {
if (array.getStackInSlot(0) == null) {
if (playerItem != null)
{
if (array.getStackInSlot(0) == null)
{
Utils.insertItemToTile(array, player, 0);
} else {
} else
{
Utils.insertItemToTile(array, player, 1);
array.attemptCraft();
}
@ -77,22 +87,26 @@ public class BlockAlchemyArray extends BlockContainer {
}
@Override
public int quantityDropped(Random random) {
public int quantityDropped(Random random)
{
return 0;
}
@Override
public int getRenderType() {
public int getRenderType()
{
return -1;
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new TileAlchemyArray();
}
@Override
public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) {
public void breakBlock(World world, BlockPos blockPos, IBlockState blockState)
{
TileAlchemyArray alchemyArray = (TileAlchemyArray) world.getTileEntity(blockPos);
if (alchemyArray != null)
alchemyArray.dropItems();

View file

@ -16,9 +16,11 @@ import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
public class BlockAltar extends BlockContainer {
public class BlockAltar extends BlockContainer
{
public BlockAltar() {
public BlockAltar()
{
super(Material.rock);
setUnlocalizedName(Constants.Mod.MODID + ".altar");
@ -26,32 +28,38 @@ public class BlockAltar extends BlockContainer {
}
@Override
public boolean isOpaqueCube() {
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean isFullCube() {
public boolean isFullCube()
{
return false;
}
@Override
public boolean isVisuallyOpaque() {
public boolean isVisuallyOpaque()
{
return false;
}
@Override
public int getRenderType() {
public int getRenderType()
{
return 3;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
public TileEntity createNewTileEntity(World world, int meta)
{
return new TileAltar();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
{
TileAltar altar = (TileAltar) world.getTileEntity(pos);
if (altar == null || player.isSneaking())
@ -59,8 +67,10 @@ public class BlockAltar extends BlockContainer {
ItemStack playerItem = player.getCurrentEquippedItem();
if (playerItem != null) {
if (playerItem.getItem() instanceof IAltarReader || playerItem.getItem() instanceof IAltarManipulator) {
if (playerItem != null)
{
if (playerItem.getItem() instanceof IAltarReader || playerItem.getItem() instanceof IAltarManipulator)
{
playerItem.getItem().onItemRightClick(playerItem, world, player);
return true;
}
@ -76,7 +86,8 @@ public class BlockAltar extends BlockContainer {
}
@Override
public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) {
public void breakBlock(World world, BlockPos blockPos, IBlockState blockState)
{
TileAltar tileAltar = (TileAltar) world.getTileEntity(blockPos);
if (tileAltar != null)
tileAltar.dropItems();

View file

@ -17,9 +17,11 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
import java.util.Random;
public class BlockBloodLight extends Block {
public class BlockBloodLight extends Block
{
public BlockBloodLight() {
public BlockBloodLight()
{
super(Material.cloth);
setUnlocalizedName(Constants.Mod.MODID + ".bloodLight");
@ -27,30 +29,36 @@ public class BlockBloodLight extends Block {
}
@Override
public boolean isOpaqueCube() {
public boolean isOpaqueCube()
{
return false;
}
@Override
@SideOnly(Side.CLIENT)
public EnumWorldBlockLayer getBlockLayer() {
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
@Override
public boolean isFullCube() {
public boolean isFullCube()
{
return false;
}
@Override
public int getLightValue() {
public int getLightValue()
{
return 15;
}
@Override
@SideOnly(Side.CLIENT)
public boolean addDestroyEffects(World world, BlockPos pos, net.minecraft.client.particle.EffectRenderer effectRenderer) {
if (world.getBlockState(pos).getBlock() == this) {
public boolean addDestroyEffects(World world, BlockPos pos, net.minecraft.client.particle.EffectRenderer effectRenderer)
{
if (world.getBlockState(pos).getBlock() == this)
{
Random random = new Random();
float f = 1.0F;
float f1 = f * 0.6F + 0.4F;
@ -63,8 +71,10 @@ public class BlockBloodLight extends Block {
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
if (rand.nextInt(3) != 0) {
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (rand.nextInt(3) != 0)
{
float f = 1.0F;
float f1 = f * 0.6F + 0.4F;
float f2 = f * f * 0.7F - 0.5F;
@ -74,12 +84,14 @@ public class BlockBloodLight extends Block {
}
@Override
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity) {
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity)
{
this.setBlockBounds(0.35F, 0.35F, 0.35F, 0.65F, 0.65F, 0.65F);
}
@Override
public int quantityDropped(Random par1Random) {
public int quantityDropped(Random par1Random)
{
return 0;
}
}

View file

@ -5,11 +5,13 @@ import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.block.base.BlockString;
import net.minecraft.block.material.Material;
public class BlockBloodRune extends BlockString {
public class BlockBloodRune extends BlockString
{
public static final String[] names = { "blank", "speed", "efficiency", "sacrifice", "selfSacrifice", "displacement", "capacity", "augCapacity", "orb", "acceleration" };
public BlockBloodRune() {
public BlockBloodRune()
{
super(Material.rock, names);
setUnlocalizedName(Constants.Mod.MODID + ".rune.");
@ -20,7 +22,8 @@ public class BlockBloodRune extends BlockString {
setHarvestLevel("pickaxe", 2);
}
public int getRuneEffect(int meta) {
public int getRuneEffect(int meta)
{
return meta;
}
}

View file

@ -5,11 +5,13 @@ import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.block.base.BlockString;
import net.minecraft.block.material.Material;
public class BlockBloodStoneBrick extends BlockString {
public class BlockBloodStoneBrick extends BlockString
{
public static final String[] names = { "normal", "large" };
public BlockBloodStoneBrick() {
public BlockBloodStoneBrick()
{
super(Material.rock, names);
setUnlocalizedName(Constants.Mod.MODID + ".bloodstonebrick.");

View file

@ -5,10 +5,12 @@ import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.block.base.BlockString;
import net.minecraft.block.material.Material;
public class BlockCrystal extends BlockString {
public class BlockCrystal extends BlockString
{
public static final String[] names = { "normal", "brick" };
public BlockCrystal() {
public BlockCrystal()
{
super(Material.rock, names);
setUnlocalizedName(Constants.Mod.MODID + ".crystal.");

View file

@ -15,12 +15,14 @@ import net.minecraftforge.fluids.FluidStack;
import java.awt.*;
public class BlockLifeEssence extends BlockFluidClassic {
public class BlockLifeEssence extends BlockFluidClassic
{
@Getter
private static Fluid lifeEssence = new FluidLifeEssence();
public BlockLifeEssence() {
public BlockLifeEssence()
{
super(lifeEssence, Material.water);
setUnlocalizedName(Constants.Mod.MODID + ".fluid.lifeEssence");
@ -30,18 +32,22 @@ public class BlockLifeEssence extends BlockFluidClassic {
}
@Override
public boolean canDisplace(IBlockAccess world, BlockPos blockPos) {
public boolean canDisplace(IBlockAccess world, BlockPos blockPos)
{
return !world.getBlockState(blockPos).getBlock().getMaterial().isLiquid() && super.canDisplace(world, blockPos);
}
@Override
public boolean displaceIfPossible(World world, BlockPos blockPos) {
public boolean displaceIfPossible(World world, BlockPos blockPos)
{
return !world.getBlockState(blockPos).getBlock().getMaterial().isLiquid() && super.displaceIfPossible(world, blockPos);
}
public static class FluidLifeEssence extends Fluid {
public static class FluidLifeEssence extends Fluid
{
public FluidLifeEssence() {
public FluidLifeEssence()
{
super("lifeEssence", new ResourceLocation(Constants.Mod.DOMAIN + "blocks/lifeEssenceStill"), new ResourceLocation(Constants.Mod.DOMAIN + "blocks/lifeEssenceFlowing"));
setDensity(2000);
@ -49,12 +55,14 @@ public class BlockLifeEssence extends BlockFluidClassic {
}
@Override
public int getColor() {
public int getColor()
{
return Color.WHITE.getRGB();
}
@Override
public String getLocalizedName(FluidStack fluidStack) {
public String getLocalizedName(FluidStack fluidStack)
{
return StatCollector.translateToLocal("tile.BloodMagic.fluid.lifeEssence.name");
}
}

View file

@ -14,11 +14,13 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockPedestal extends BlockStringContainer {
public class BlockPedestal extends BlockStringContainer
{
public static String[] names = { "pedestal", "plinth" };
public BlockPedestal() {
public BlockPedestal()
{
super(Material.rock, names);
setUnlocalizedName(Constants.Mod.MODID + ".");
@ -28,9 +30,12 @@ public class BlockPedestal extends BlockStringContainer {
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) {
switch (getMetaFromState(state)) {
case 0: {
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
{
switch (getMetaFromState(state))
{
case 0:
{
// TileEntity plinth = world.getTileEntity(pos);
//
// if (plinth!= null && plinth instanceof TilePlinth) {
@ -38,13 +43,15 @@ public class BlockPedestal extends BlockStringContainer {
// }
}
case 1: {
case 1:
{
TileEntity plinth = world.getTileEntity(pos);
if (plinth == null || player.isSneaking())
return false;
if (plinth instanceof TilePlinth) {
if (plinth instanceof TilePlinth)
{
Utils.insertItemToTile((TilePlinth) plinth, player);
return true;
}
@ -56,7 +63,8 @@ public class BlockPedestal extends BlockStringContainer {
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, BlockPos pos) {
public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, BlockPos pos)
{
IBlockState state = blockAccess.getBlockState(pos);
if (getMetaFromState(state) == 0)
@ -67,17 +75,20 @@ public class BlockPedestal extends BlockStringContainer {
}
@Override
public boolean isOpaqueCube() {
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean isFullCube() {
public boolean isFullCube()
{
return false;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
public TileEntity createNewTileEntity(World world, int meta)
{
return meta == 0 ? null : new TilePlinth();
}
}

View file

@ -17,21 +17,25 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.Random;
public class BlockPhantom extends BlockContainer {
public class BlockPhantom extends BlockContainer
{
public BlockPhantom() {
public BlockPhantom()
{
super(Material.cloth);
setUnlocalizedName(Constants.Mod.MODID + ".phantom");
}
@Override
public boolean isOpaqueCube() {
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean isFullCube() {
public boolean isFullCube()
{
return false;
}
@ -44,17 +48,20 @@ public class BlockPhantom extends BlockContainer {
@Override
@SideOnly(Side.CLIENT)
public EnumWorldBlockLayer getBlockLayer() {
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.TRANSLUCENT;
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side) {
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
if (worldIn.getBlockState(pos.offset(side.getOpposite())) != iblockstate) {
if (worldIn.getBlockState(pos.offset(side.getOpposite())) != iblockstate)
{
return true;
}
@ -62,12 +69,14 @@ public class BlockPhantom extends BlockContainer {
}
@Override
public int quantityDropped(Random par1Random) {
public int quantityDropped(Random par1Random)
{
return 0;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
public TileEntity createNewTileEntity(World world, int meta)
{
return new TilePhantomBlock();
}
}

View file

@ -20,11 +20,13 @@ import WayofTime.bloodmagic.registry.ModItems;
import WayofTime.bloodmagic.tile.TileImperfectRitualStone;
import WayofTime.bloodmagic.tile.TileMasterRitualStone;
public class BlockRitualController extends BlockStringContainer {
public class BlockRitualController extends BlockStringContainer
{
public static final String[] names = { "master", "imperfect" };
public BlockRitualController() {
public BlockRitualController()
{
super(Material.rock, names);
setUnlocalizedName(Constants.Mod.MODID + ".stone.ritual.");
@ -36,21 +38,28 @@ public class BlockRitualController extends BlockStringContainer {
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
{
TileEntity tile = world.getTileEntity(pos);
if (getMetaFromState(state) == 0 && tile instanceof TileMasterRitualStone) {
if (player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.activationCrystal) {
if (getMetaFromState(state) == 0 && tile instanceof TileMasterRitualStone)
{
if (player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.activationCrystal)
{
String key = RitualHelper.getValidRitual(world, pos);
EnumFacing direction = RitualHelper.getDirectionOfRitual(world, pos, key);
//TODO: Give a message stating that this ritual is not a valid ritual.
if (!key.isEmpty() && direction != null && RitualHelper.checkValidRitual(world, pos, key, direction)) {
if(((TileMasterRitualStone) tile).activateRitual(player.getHeldItem(), player, RitualRegistry.getRitualForId(key))) {
// TODO: Give a message stating that this ritual is not a valid
// ritual.
if (!key.isEmpty() && direction != null && RitualHelper.checkValidRitual(world, pos, key, direction))
{
if (((TileMasterRitualStone) tile).activateRitual(player.getHeldItem(), player, RitualRegistry.getRitualForId(key)))
{
((TileMasterRitualStone) tile).setDirection(direction);
}
}
}
} else if (getMetaFromState(state) == 1 && tile instanceof TileImperfectRitualStone) {
} else if (getMetaFromState(state) == 1 && tile instanceof TileImperfectRitualStone)
{
IBlockState determinerState = world.getBlockState(pos.up());
BlockStack determiner = new BlockStack(determinerState.getBlock(), determinerState.getBlock().getMetaFromState(determinerState));
@ -62,7 +71,8 @@ public class BlockRitualController extends BlockStringContainer {
}
@Override
public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player)
{
TileEntity tile = world.getTileEntity(pos);
if (getMetaFromState(state) == 0 && tile instanceof TileMasterRitualStone)
@ -70,7 +80,8 @@ public class BlockRitualController extends BlockStringContainer {
}
@Override
public void onBlockDestroyedByExplosion(World world, BlockPos pos, Explosion explosion) {
public void onBlockDestroyedByExplosion(World world, BlockPos pos, Explosion explosion)
{
TileEntity tile = world.getTileEntity(pos);
IBlockState state = world.getBlockState(pos);
@ -79,7 +90,8 @@ public class BlockRitualController extends BlockStringContainer {
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
public TileEntity createNewTileEntity(World world, int meta)
{
return meta == 0 ? (new TileMasterRitualStone()) : (new TileImperfectRitualStone());
}
}

View file

@ -9,11 +9,13 @@ import net.minecraft.block.material.Material;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public class BlockRitualStone extends BlockString implements IRitualStone {
public class BlockRitualStone extends BlockString implements IRitualStone
{
public static final String[] names = { "blank", "water", "fire", "earth", "air", "dusk", "dawn" };
public BlockRitualStone() {
public BlockRitualStone()
{
super(Material.iron, names);
setUnlocalizedName(Constants.Mod.MODID + ".ritualStone.");
@ -25,7 +27,8 @@ public class BlockRitualStone extends BlockString implements IRitualStone {
}
@Override
public boolean isRuneType(World world, BlockPos pos, EnumRuneType runeType) {
public boolean isRuneType(World world, BlockPos pos, EnumRuneType runeType)
{
return runeType.toString().equals(names[getMetaFromState(world.getBlockState(pos))]);
}
}

View file

@ -10,9 +10,11 @@ import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
public class BlockSoulForge extends Block {
public class BlockSoulForge extends Block
{
public BlockSoulForge() {
public BlockSoulForge()
{
super(Material.iron);
setUnlocalizedName(Constants.Mod.MODID + ".soulforge.");
@ -24,11 +26,11 @@ public class BlockSoulForge extends Block {
}
@Override
public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (world.isRemote)
return false;
return false;
}
}

View file

@ -18,9 +18,11 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
import java.util.Random;
public class BlockSpectral extends BlockContainer {
public class BlockSpectral extends BlockContainer
{
public BlockSpectral() {
public BlockSpectral()
{
super(Material.cloth);
setUnlocalizedName(Constants.Mod.MODID + ".spectral");
@ -28,42 +30,50 @@ public class BlockSpectral extends BlockContainer {
}
@Override
public boolean isOpaqueCube() {
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean isFullCube() {
public boolean isFullCube()
{
return false;
}
@Override
@SideOnly(Side.CLIENT)
public EnumWorldBlockLayer getBlockLayer() {
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
@Override
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity) {
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity)
{
}
@Override
public int quantityDropped(Random par1Random) {
public int quantityDropped(Random par1Random)
{
return 0;
}
@Override
public boolean isReplaceable(World world, BlockPos blockPos) {
public boolean isReplaceable(World world, BlockPos blockPos)
{
return true;
}
@Override
public boolean isAir(IBlockAccess world, BlockPos blockPos) {
public boolean isAir(IBlockAccess world, BlockPos blockPos)
{
return true;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
public TileEntity createNewTileEntity(World world, int meta)
{
return new TileSpectralBlock();
}
}

View file

@ -14,9 +14,11 @@ import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
public class BlockTeleposer extends BlockContainer {
public class BlockTeleposer extends BlockContainer
{
public BlockTeleposer() {
public BlockTeleposer()
{
super(Material.rock);
setCreativeTab(BloodMagic.tabBloodMagic);
@ -26,27 +28,32 @@ public class BlockTeleposer extends BlockContainer {
}
@Override
public int getRenderType() {
public int getRenderType()
{
return 3;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
{
ItemStack playerItem = player.getCurrentEquippedItem();
if (playerItem != null && playerItem.getItem() instanceof ItemTelepositionFocus) {
if (playerItem != null && playerItem.getItem() instanceof ItemTelepositionFocus)
{
BindableHelper.checkAndSetItemOwner(playerItem, player);
((ItemTelepositionFocus) playerItem.getItem()).setBlockPos(playerItem, world, pos);
return true;
}
// player.openGui(AlchemicalWizardry.instance, 1, world, pos.getX(), pos.getY(), pos.getZ());
// player.openGui(AlchemicalWizardry.instance, 1, world, pos.getX(),
// pos.getY(), pos.getZ());
return true;
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return null;
}
}

View file

@ -12,57 +12,61 @@ import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
public class BlockTestSpellBlock extends Block {
public static final PropertyDirection INPUT = PropertyDirection
.create("input");
public static final PropertyDirection OUTPUT = PropertyDirection
.create("output");
public class BlockTestSpellBlock extends Block
{
public static final PropertyDirection INPUT = PropertyDirection.create("input");
public static final PropertyDirection OUTPUT = PropertyDirection.create("output");
public BlockTestSpellBlock() {
public BlockTestSpellBlock()
{
super(Material.rock);
setHardness(2.0F);
setResistance(5.0F);
setUnlocalizedName(Constants.Mod.MODID + ".testSpellBlock");
setCreativeTab(BloodMagic.tabBloodMagic);
this.setDefaultState(this.blockState.getBaseState()
.withProperty(INPUT, EnumFacing.DOWN)
.withProperty(OUTPUT, EnumFacing.UP));
this.setDefaultState(this.blockState.getBaseState().withProperty(INPUT, EnumFacing.DOWN).withProperty(OUTPUT, EnumFacing.UP));
}
@Override
public IBlockState getStateFromMeta(int meta) {
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState();
}
@Override
public int getMetaFromState(IBlockState state) {
public int getMetaFromState(IBlockState state)
{
return 0;
}
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
return state.withProperty(INPUT, EnumFacing.DOWN)
.withProperty(OUTPUT, EnumFacing.UP);
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
return state.withProperty(INPUT, EnumFacing.DOWN).withProperty(OUTPUT, EnumFacing.UP);
}
@Override
protected BlockState createBlockState() {
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] { INPUT, OUTPUT });
}
@Override
public boolean isOpaqueCube() {
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean isFullCube() {
public boolean isFullCube()
{
return false;
}
@Override
public boolean isPassable(IBlockAccess blockAccess, BlockPos pos) {
public boolean isPassable(IBlockAccess blockAccess, BlockPos pos)
{
return false;
}
}

View file

@ -29,17 +29,20 @@ import java.util.List;
*
* These states will be numbered 0 through {@code maxMeta}.
*
* For {@link net.minecraft.tileentity.TileEntity}'s, use {@link BlockIntegerContainer}.
* For {@link net.minecraft.tileentity.TileEntity}'s, use
* {@link BlockIntegerContainer}.
*/
@Getter
public class BlockInteger extends Block {
public class BlockInteger extends Block
{
private final int maxMeta;
private final PropertyInteger metaProp;
private final IUnlistedProperty unlistedMetaProp;
private final BlockState realBlockState;
public BlockInteger(Material material, int maxMeta, String propName) {
public BlockInteger(Material material, int maxMeta, String propName)
{
super(material);
this.maxMeta = maxMeta;
@ -50,60 +53,72 @@ public class BlockInteger extends Block {
setupStates();
}
public BlockInteger(Material material, int maxMeta) {
public BlockInteger(Material material, int maxMeta)
{
this(material, maxMeta, "meta");
}
@Override
public IBlockState getStateFromMeta(int meta) {
public IBlockState getStateFromMeta(int meta)
{
return getBlockState().getBaseState().withProperty(metaProp, meta);
}
@Override
public int getMetaFromState(IBlockState state) {
public int getMetaFromState(IBlockState state)
{
return (Integer) state.getValue(metaProp);
}
@Override
public int damageDropped(IBlockState state) {
public int damageDropped(IBlockState state)
{
return getMetaFromState(state);
}
@Override
public BlockState getBlockState() {
public BlockState getBlockState()
{
return this.realBlockState;
}
@Override
public BlockState createBlockState() {
public BlockState createBlockState()
{
return Blocks.air.getBlockState();
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) {
public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player)
{
return new ItemStack(this, 1, this.getMetaFromState(world.getBlockState(pos)));
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List<ItemStack> list) {
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List<ItemStack> list)
{
for (int i = 0; i < maxMeta + 1; i++)
list.add(new ItemStack(this, 1, i));
}
private void setupStates() {
private void setupStates()
{
this.setDefaultState(getExtendedBlockState().withProperty(unlistedMetaProp, 0).withProperty(metaProp, 0));
}
public ExtendedBlockState getBaseExtendedState() {
public ExtendedBlockState getBaseExtendedState()
{
return (ExtendedBlockState) this.getBlockState();
}
public IExtendedBlockState getExtendedBlockState() {
public IExtendedBlockState getExtendedBlockState()
{
return (IExtendedBlockState) this.getBaseExtendedState().getBaseState();
}
private BlockState createRealBlockState() {
private BlockState createRealBlockState()
{
return new ExtendedBlockState(this, new IProperty[] { metaProp }, new IUnlistedProperty[] { unlistedMetaProp });
}
}

View file

@ -7,26 +7,31 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public abstract class BlockIntegerContainer extends BlockInteger implements ITileEntityProvider {
public abstract class BlockIntegerContainer extends BlockInteger implements ITileEntityProvider
{
public BlockIntegerContainer(Material material, int maxMeta, String propName) {
public BlockIntegerContainer(Material material, int maxMeta, String propName)
{
super(material, maxMeta, propName);
this.isBlockContainer = true;
}
public BlockIntegerContainer(Material material, int maxMeta) {
public BlockIntegerContainer(Material material, int maxMeta)
{
this(material, maxMeta, "meta");
}
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
super.breakBlock(worldIn, pos, state);
worldIn.removeTileEntity(pos);
}
@Override
public boolean onBlockEventReceived(World worldIn, BlockPos pos, IBlockState state, int eventID, int eventParam) {
public boolean onBlockEventReceived(World worldIn, BlockPos pos, IBlockState state, int eventID, int eventParam)
{
super.onBlockEventReceived(worldIn, pos, state, eventID, eventParam);
TileEntity tileentity = worldIn.getTileEntity(pos);
return tileentity != null && tileentity.receiveClientEvent(eventID, eventParam);

View file

@ -28,13 +28,16 @@ import java.util.List;
/**
* Creates a block that has multiple meta-based states.
*
* These states will be named after the given string array. Somewhere along the way, each
* value is {@code toLowerCase()}'ed, so the blockstate JSON needs all values to be lowercase.
* These states will be named after the given string array. Somewhere along the
* way, each value is {@code toLowerCase()}'ed, so the blockstate JSON needs all
* values to be lowercase.
*
* For {@link net.minecraft.tileentity.TileEntity}'s, use {@link BlockStringContainer}.
* For {@link net.minecraft.tileentity.TileEntity}'s, use
* {@link BlockStringContainer}.
*/
@Getter
public class BlockString extends Block {
public class BlockString extends Block
{
private final int maxMeta;
private final List<String> values;
@ -42,7 +45,8 @@ public class BlockString extends Block {
private final IUnlistedProperty unlistedStringProp;
private final BlockState realBlockState;
public BlockString(Material material, String[] values, String propName) {
public BlockString(Material material, String[] values, String propName)
{
super(material);
this.maxMeta = values.length - 1;
@ -54,60 +58,72 @@ public class BlockString extends Block {
setupStates();
}
public BlockString(Material material, String[] values) {
public BlockString(Material material, String[] values)
{
this(material, values, "type");
}
@Override
public IBlockState getStateFromMeta(int meta) {
public IBlockState getStateFromMeta(int meta)
{
return getBlockState().getBaseState().withProperty(stringProp, values.get(meta));
}
@Override
public int getMetaFromState(IBlockState state) {
public int getMetaFromState(IBlockState state)
{
return values.indexOf(String.valueOf(state.getValue(stringProp)));
}
@Override
public int damageDropped(IBlockState state) {
public int damageDropped(IBlockState state)
{
return getMetaFromState(state);
}
@Override
public BlockState getBlockState() {
public BlockState getBlockState()
{
return this.realBlockState;
}
@Override
public BlockState createBlockState() {
public BlockState createBlockState()
{
return Blocks.air.getBlockState();
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) {
public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player)
{
return new ItemStack(this, 1, this.getMetaFromState(world.getBlockState(pos)));
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List<ItemStack> list) {
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List<ItemStack> list)
{
for (int i = 0; i < maxMeta + 1; i++)
list.add(new ItemStack(this, 1, i));
}
private void setupStates() {
private void setupStates()
{
this.setDefaultState(getExtendedBlockState().withProperty(unlistedStringProp, values.get(0)).withProperty(stringProp, values.get(0)));
}
public ExtendedBlockState getBaseExtendedState() {
public ExtendedBlockState getBaseExtendedState()
{
return (ExtendedBlockState) this.getBlockState();
}
public IExtendedBlockState getExtendedBlockState() {
public IExtendedBlockState getExtendedBlockState()
{
return (IExtendedBlockState) this.getBaseExtendedState().getBaseState();
}
private BlockState createRealBlockState() {
private BlockState createRealBlockState()
{
return new ExtendedBlockState(this, new IProperty[] { stringProp }, new IUnlistedProperty[] { unlistedStringProp });
}
}

View file

@ -7,26 +7,31 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public abstract class BlockStringContainer extends BlockString implements ITileEntityProvider {
public abstract class BlockStringContainer extends BlockString implements ITileEntityProvider
{
public BlockStringContainer(Material material, String[] values, String propName) {
public BlockStringContainer(Material material, String[] values, String propName)
{
super(material, values, propName);
this.isBlockContainer = true;
}
public BlockStringContainer(Material material, String[] values) {
public BlockStringContainer(Material material, String[] values)
{
this(material, values, "type");
}
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
super.breakBlock(worldIn, pos, state);
worldIn.removeTileEntity(pos);
}
@Override
public boolean onBlockEventReceived(World worldIn, BlockPos pos, IBlockState state, int eventID, int eventParam) {
public boolean onBlockEventReceived(World worldIn, BlockPos pos, IBlockState state, int eventID, int eventParam)
{
super.onBlockEventReceived(worldIn, pos, state, eventID, eventParam);
TileEntity tileentity = worldIn.getTileEntity(pos);
return tileentity != null && tileentity.receiveClientEvent(eventID, eventParam);

View file

@ -8,11 +8,13 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
public class PropertyString extends PropertyHelper {
public class PropertyString extends PropertyHelper
{
private final ImmutableSet allowedValues;
protected PropertyString(String name, String[] values) {
protected PropertyString(String name, String[] values)
{
super(name, String.class);
HashSet<String> hashSet = Sets.newHashSet();
@ -20,21 +22,25 @@ public class PropertyString extends PropertyHelper {
allowedValues = ImmutableSet.copyOf(hashSet);
}
public static PropertyString create(String name, String[] values) {
public static PropertyString create(String name, String[] values)
{
return new PropertyString(name, values);
}
@Override
public Collection getAllowedValues() {
public Collection getAllowedValues()
{
return allowedValues;
}
public String getName0(String value) {
public String getName0(String value)
{
return value;
}
@Override
public String getName(Comparable value) {
public String getName(Comparable value)
{
return this.getName0(value.toString());
}
}

View file

@ -2,33 +2,39 @@ package WayofTime.bloodmagic.block.property;
import net.minecraftforge.common.property.IUnlistedProperty;
public class UnlistedPropertyInteger implements IUnlistedProperty<Integer> {
public class UnlistedPropertyInteger implements IUnlistedProperty<Integer>
{
private int maxMeta;
private String propName;
public UnlistedPropertyInteger(int maxMeta, String propName) {
public UnlistedPropertyInteger(int maxMeta, String propName)
{
this.maxMeta = maxMeta;
this.propName = propName;
}
@Override
public String getName() {
public String getName()
{
return propName;
}
@Override
public boolean isValid(Integer value) {
public boolean isValid(Integer value)
{
return value <= maxMeta;
}
@Override
public Class<Integer> getType() {
public Class<Integer> getType()
{
return Integer.class;
}
@Override
public String valueToString(Integer value) {
public String valueToString(Integer value)
{
return value.toString();
}
}

View file

@ -5,33 +5,39 @@ import net.minecraftforge.common.property.IUnlistedProperty;
import java.util.Arrays;
import java.util.List;
public class UnlistedPropertyString implements IUnlistedProperty<String> {
public class UnlistedPropertyString implements IUnlistedProperty<String>
{
private List values;
private String propName;
public UnlistedPropertyString(String[] values, String propName) {
public UnlistedPropertyString(String[] values, String propName)
{
this.values = Arrays.asList(values);
this.propName = propName;
}
@Override
public String getName() {
public String getName()
{
return propName;
}
@Override
public boolean isValid(String value) {
public boolean isValid(String value)
{
return values.contains(value);
}
@Override
public Class<String> getType() {
public Class<String> getType()
{
return String.class;
}
@Override
public String valueToString(String value) {
public String valueToString(String value)
{
return value;
}
}

View file

@ -10,17 +10,21 @@ import net.minecraftforge.fml.client.config.IConfigElement;
import java.util.ArrayList;
import java.util.List;
public class ConfigGui extends GuiConfig {
public class ConfigGui extends GuiConfig
{
public ConfigGui(GuiScreen parentScreen) {
public ConfigGui(GuiScreen parentScreen)
{
super(parentScreen, getConfigElements(parentScreen), Constants.Mod.MODID, false, false, "BloodMagic Configuration");
}
@SuppressWarnings("rawtypes")
private static List<IConfigElement> getConfigElements(GuiScreen parent) {
private static List<IConfigElement> getConfigElements(GuiScreen parent)
{
List<IConfigElement> list = new ArrayList<IConfigElement>();
// adds sections declared in ConfigHandler. toLowerCase() is used because the configuration class automatically does this, so must we.
// adds sections declared in ConfigHandler. toLowerCase() is used
// because the configuration class automatically does this, so must we.
list.add(new ConfigElement(ConfigHandler.getConfig().getCategory("Potions".toLowerCase())));
list.add(new ConfigElement(ConfigHandler.getConfig().getCategory("Teleposer Blacklist".toLowerCase())));
list.add(new ConfigElement(ConfigHandler.getConfig().getCategory("Item/Block Blacklisting".toLowerCase())));

View file

@ -6,25 +6,30 @@ import net.minecraftforge.fml.client.IModGuiFactory;
import java.util.Set;
public class ConfigGuiFactory implements IModGuiFactory {
public class ConfigGuiFactory implements IModGuiFactory
{
@Override
public void initialize(Minecraft minecraftInstance) {
public void initialize(Minecraft minecraftInstance)
{
}
@Override
public Class<? extends GuiScreen> mainConfigGuiClass() {
public Class<? extends GuiScreen> mainConfigGuiClass()
{
return ConfigGui.class;
}
@Override
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories()
{
return null;
}
@Override
public RuntimeOptionGuiHandler getHandlerFor(IModGuiFactory.RuntimeOptionCategoryElement element) {
public RuntimeOptionGuiHandler getHandlerFor(IModGuiFactory.RuntimeOptionCategoryElement element)
{
return null;
}
}

View file

@ -6,10 +6,12 @@ import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer;
import WayofTime.bloodmagic.api.registry.AlchemyArrayRecipeRegistry;
import WayofTime.bloodmagic.tile.TileAlchemyArray;
public class RenderAlchemyArray extends TileEntitySpecialRenderer<TileAlchemyArray> {
public class RenderAlchemyArray extends TileEntitySpecialRenderer<TileAlchemyArray>
{
@Override
public void renderTileEntityAt(TileAlchemyArray alchemyArray, double x, double y, double z, float partialTicks, int destroyStage) {
public void renderTileEntityAt(TileAlchemyArray alchemyArray, double x, double y, double z, float partialTicks, int destroyStage)
{
ItemStack inputStack = alchemyArray.getStackInSlot(0);
int craftTime = alchemyArray.activeCounter;
AlchemyCircleRenderer renderer = AlchemyArrayRecipeRegistry.getAlchemyCircleRenderer(inputStack);

View file

@ -10,7 +10,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyCircleRenderer;
public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer {
public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer
{
public float offsetFromFace = -0.9f;
public final ResourceLocation arrayResource;
@ -27,7 +28,8 @@ public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer {
public static final int endTime = 300;
public BindingAlchemyCircleRenderer() {
public BindingAlchemyCircleRenderer()
{
this.arrayResource = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingArray.png");
arraysResources = new ResourceLocation[5];
arraysResources[0] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png");
@ -37,12 +39,15 @@ public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer {
arraysResources[4] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png");
}
public static float getAngleOfCircle(int circle, float craftTime) {
if (circle >= 0 && circle <= 4) {
public static float getAngleOfCircle(int circle, float craftTime)
{
if (circle >= 0 && circle <= 4)
{
float originalAngle = (float) (circle * 2 * Math.PI / 5d);
double sweep = (craftTime - startTime) / sweepTime;
if(sweep >= 0 && sweep < numberOfSweeps) {
if (sweep >= 0 && sweep < numberOfSweeps)
{
float offset = ((int) sweep) * sweepTime + startTime;
originalAngle += 2 * Math.PI * 2 / 5 * (int) sweep + getAngle(craftTime - offset, (int) sweep);
} else if (sweep >= numberOfSweeps)
@ -56,7 +61,8 @@ public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer {
return 0;
}
public static float getAngle(float craftTime, int sweep) {
public static float getAngle(float craftTime, int sweep)
{
float rDP = craftTime / sweepTime * arcLength;
float rEnd = (float) Math.sqrt(rDP * rDP + 2 * 2 - 2 * rDP * 2 * Math.cos(theta2));
return (float) (Math.acos((2 * 2 + rEnd * rEnd - rDP * rDP) / (2 * rEnd * 2)));
@ -65,51 +71,65 @@ public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer {
/**
* Returns the center-to-center distance of this circle.
*/
public static float getDistanceOfCircle(int circle, float craftTime) { //TODO Change this so it doesn't use angle, since it is a constant speed.
public static float getDistanceOfCircle(int circle, float craftTime)
{ // TODO Change this so it doesn't use angle, since it is a constant speed.
double sweep = (craftTime - startTime) / sweepTime;
if(sweep >= 0 && sweep < numberOfSweeps) {
if (sweep >= 0 && sweep < numberOfSweeps)
{
float offset = ((int) sweep) * sweepTime + startTime;
float angle = getAngle(craftTime - offset, (int) sweep);
float thetaPrime = (float) (Math.PI - theta2 - angle);
// if(thetaPrime > 0 && thetaPrime < Math.PI) {
return (float) (2 * Math.sin(theta2) / Math.sin(thetaPrime));
// }
} else if(sweep >= numberOfSweeps && craftTime < endTime) {
} else if (sweep >= numberOfSweeps && craftTime < endTime)
{
return 2 - 2 * (craftTime - startTime - numberOfSweeps * sweepTime) / (endTime - startTime - numberOfSweeps * sweepTime);
} else if(craftTime >= endTime) {
} else if (craftTime >= endTime)
{
return 0;
}
return 2;
}
public float getRotation(int circle, float craftTime) {
public float getRotation(int circle, float craftTime)
{
float offset = 2;
if(circle == -1) {
if (circle == -1)
{
return (float) (craftTime * 360 * 2 / 5 / sweepTime);
}
if (craftTime >= offset) {
if (craftTime >= offset)
{
float modifier = (float) Math.pow(craftTime - offset, 1.5);
return modifier * 0.5f;
}
return 0;
}
public float getSecondaryRotation(int circle, float craftTime) {
public float getSecondaryRotation(int circle, 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 getVerticalOffset(int circle, float craftTime) {
if (circle >= 0 && circle <= 4) {
if (craftTime >= 5) {
if (craftTime <= 40) {
public float getVerticalOffset(int circle, float craftTime)
{
if (circle >= 0 && circle <= 4)
{
if (craftTime >= 5)
{
if (craftTime <= 40)
{
return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3));
} else {
} else
{
return -0.4f;
}
}
@ -117,22 +137,29 @@ public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer {
return 0;
}
if (craftTime >= 5) {
if (craftTime <= 40) {
if (craftTime >= 5)
{
if (craftTime <= 40)
{
return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3));
} else {
} else
{
return -0.4f;
}
}
return 0;
}
public float getInwardRotation(int circle, float craftTime) {
public float getInwardRotation(int circle, float craftTime)
{
float offset = startTime + numberOfSweeps * sweepTime;
if(craftTime >= offset) {
if(craftTime <= offset + inwardRotationTime) {
if (craftTime >= offset)
{
if (craftTime <= offset + inwardRotationTime)
{
return 90f / inwardRotationTime * (craftTime - offset);
} else {
} else
{
return 90;
}
}
@ -140,7 +167,8 @@ public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer {
return 0;
}
public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) {
public void renderAt(TileEntity tile, double x, double y, double z, float craftTime)
{
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer wr = tessellator.getWorldRenderer();
@ -163,7 +191,8 @@ public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer {
// is located on
GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace);
switch (sideHit) {
switch (sideHit)
{
case DOWN:
GlStateManager.translate(0, 0, 1);
GlStateManager.rotate(-90.0f, 1, 0, 0);
@ -209,7 +238,8 @@ public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer {
tessellator.draw();
GlStateManager.popMatrix();
for (int i = 0; i < 5; i++) {
for (int i = 0; i < 5; i++)
{
GlStateManager.pushMatrix();
Minecraft.getMinecraft().renderEngine.bindTexture(arraysResources[i]);
float newSize = 1;

View file

@ -3,7 +3,8 @@ package WayofTime.bloodmagic.compat;
/**
* Implement on all primary compatibility classes.
*/
public interface ICompatibility {
public interface ICompatibility
{
/**
* Called after the given {@code modid} has been verified as loaded.
@ -16,7 +17,8 @@ public interface ICompatibility {
String getModId();
/**
* Whether or not compatibility should be loaded even if the mod were to be found.
* Whether or not compatibility should be loaded even if the mod were to be
* found.
*
* Generally a determined by a config option.
*/

View file

@ -18,28 +18,23 @@ import net.minecraft.item.ItemStack;
import java.util.Collections;
@JEIPlugin
public class BloodMagicPlugin implements IModPlugin {
public class BloodMagicPlugin implements IModPlugin
{
public static IJeiHelpers jeiHelper;
@Override
public boolean isModLoaded() {
public boolean isModLoaded()
{
return true;
}
@Override
public void register(IModRegistry registry) {
registry.addRecipeCategories(
new AltarRecipeCategory(),
new BindingRecipeCategory(),
new AlchemyArrayCraftingCategory()
);
public void register(IModRegistry registry)
{
registry.addRecipeCategories(new AltarRecipeCategory(), new BindingRecipeCategory(), new AlchemyArrayCraftingCategory());
registry.addRecipeHandlers(
new AltarRecipeHandler(),
new BindingRecipeHandler(),
new AlchemyArrayCraftingRecipeHandler()
);
registry.addRecipeHandlers(new AltarRecipeHandler(), new BindingRecipeHandler(), new AlchemyArrayCraftingRecipeHandler());
registry.addRecipes(AltarRecipeMaker.getRecipes());
registry.addRecipes(BindingRecipeMaker.getRecipes());
@ -49,19 +44,22 @@ public class BloodMagicPlugin implements IModPlugin {
}
@Override
public void onJeiHelpersAvailable(IJeiHelpers jeiHelpers) {
public void onJeiHelpersAvailable(IJeiHelpers jeiHelpers)
{
jeiHelper = jeiHelpers;
jeiHelpers.getItemBlacklist().addItemToBlacklist(new ItemStack(ModBlocks.bloodLight));
}
@Override
public void onItemRegistryAvailable(IItemRegistry itemRegistry) {
public void onItemRegistryAvailable(IItemRegistry itemRegistry)
{
}
@Override
public void onRecipeRegistryAvailable(IRecipeRegistry recipeRegistry) {
public void onRecipeRegistryAvailable(IRecipeRegistry recipeRegistry)
{
}
}

View file

@ -6,15 +6,18 @@ import net.minecraftforge.fluids.FluidStack;
import java.util.Collections;
import java.util.List;
public abstract class BloodMagicRecipeWrapper implements IRecipeWrapper {
public abstract class BloodMagicRecipeWrapper implements IRecipeWrapper
{
@Override
public List<FluidStack> getFluidInputs() {
public List<FluidStack> getFluidInputs()
{
return Collections.emptyList();
}
@Override
public List<FluidStack> getFluidOutputs() {
public List<FluidStack> getFluidOutputs()
{
return Collections.emptyList();
}
}

View file

@ -2,20 +2,24 @@ package WayofTime.bloodmagic.compat.jei;
import WayofTime.bloodmagic.compat.ICompatibility;
public class CompatibilityJustEnoughItems implements ICompatibility {
public class CompatibilityJustEnoughItems implements ICompatibility
{
@Override
public void loadCompatibility() {
public void loadCompatibility()
{
}
@Override
public String getModId() {
public String getModId()
{
return "JEI";
}
@Override
public boolean enableCompat() {
public boolean enableCompat()
{
return true;
}
}

View file

@ -13,7 +13,8 @@ import net.minecraft.util.ResourceLocation;
import javax.annotation.Nonnull;
public class AlchemyArrayCraftingCategory implements IRecipeCategory {
public class AlchemyArrayCraftingCategory implements IRecipeCategory
{
private static final int INPUT_SLOT = 0;
private static final int CATALYST_SLOT = 1;
@ -26,41 +27,48 @@ public class AlchemyArrayCraftingCategory implements IRecipeCategory {
@Nonnull
@Override
public String getUid() {
public String getUid()
{
return Constants.Compat.JEI_CATEGORY_ALCHEMYARRAY;
}
@Nonnull
@Override
public String getTitle() {
public String getTitle()
{
return localizedName;
}
@Nonnull
@Override
public IDrawable getBackground() {
public IDrawable getBackground()
{
return background;
}
@Override
public void drawExtras(Minecraft minecraft) {
public void drawExtras(Minecraft minecraft)
{
}
@Override
public void drawAnimations(Minecraft minecraft) {
public void drawAnimations(Minecraft minecraft)
{
}
@Override
@SuppressWarnings("unchecked")
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper)
{
recipeLayout.getItemStacks().init(INPUT_SLOT, true, 0, 5);
recipeLayout.getItemStacks().init(CATALYST_SLOT, true, 50, 5);
recipeLayout.getItemStacks().init(OUTPUT_SLOT, false, 73, 5);
if (recipeWrapper instanceof AlchemyArrayCraftingRecipeJEI) {
if (recipeWrapper instanceof AlchemyArrayCraftingRecipeJEI)
{
AlchemyArrayCraftingRecipeJEI alchemyArrayWrapper = (AlchemyArrayCraftingRecipeJEI) recipeWrapper;
recipeLayout.getItemStacks().set(INPUT_SLOT, (ItemStack) alchemyArrayWrapper.getInputs().get(0));
recipeLayout.getItemStacks().set(CATALYST_SLOT, (ItemStack) alchemyArrayWrapper.getInputs().get(1));
@ -68,4 +76,3 @@ public class AlchemyArrayCraftingCategory implements IRecipeCategory {
}
}
}

View file

@ -6,28 +6,33 @@ import mezz.jei.api.recipe.IRecipeWrapper;
import javax.annotation.Nonnull;
public class AlchemyArrayCraftingRecipeHandler implements IRecipeHandler<AlchemyArrayCraftingRecipeJEI> {
public class AlchemyArrayCraftingRecipeHandler implements IRecipeHandler<AlchemyArrayCraftingRecipeJEI>
{
@Nonnull
@Override
public Class<AlchemyArrayCraftingRecipeJEI> getRecipeClass() {
public Class<AlchemyArrayCraftingRecipeJEI> getRecipeClass()
{
return AlchemyArrayCraftingRecipeJEI.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() {
public String getRecipeCategoryUid()
{
return Constants.Compat.JEI_CATEGORY_ALCHEMYARRAY;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull AlchemyArrayCraftingRecipeJEI recipe) {
public IRecipeWrapper getRecipeWrapper(@Nonnull AlchemyArrayCraftingRecipeJEI recipe)
{
return recipe;
}
@Override
public boolean isRecipeValid(@Nonnull AlchemyArrayCraftingRecipeJEI recipe) {
public boolean isRecipeValid(@Nonnull AlchemyArrayCraftingRecipeJEI recipe)
{
return recipe.getInputs().size() > 0 && recipe.getOutputs().size() > 0;
}
}

View file

@ -10,7 +10,8 @@ import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
public class AlchemyArrayCraftingRecipeJEI extends BloodMagicRecipeWrapper {
public class AlchemyArrayCraftingRecipeJEI extends BloodMagicRecipeWrapper
{
@Nonnull
private final List<ItemStack> inputs;
@ -19,28 +20,33 @@ public class AlchemyArrayCraftingRecipeJEI extends BloodMagicRecipeWrapper {
private final ItemStack output;
@SuppressWarnings("unchecked")
public AlchemyArrayCraftingRecipeJEI(@Nonnull ItemStack input, @Nullable ItemStack catalyst, @Nonnull ItemStack output) {
public AlchemyArrayCraftingRecipeJEI(@Nonnull ItemStack input, @Nullable ItemStack catalyst, @Nonnull ItemStack output)
{
this.inputs = Arrays.asList(new ItemStack[] { input, catalyst });
this.output = output;
}
@Override
public List getInputs() {
public List getInputs()
{
return inputs;
}
@Override
public List getOutputs() {
public List getOutputs()
{
return Collections.singletonList(output);
}
@Override
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight)
{
}
@Override
public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {
public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight)
{
}
}

View file

@ -12,21 +12,26 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class AlchemyArrayCraftingRecipeMaker {
public class AlchemyArrayCraftingRecipeMaker
{
@Nonnull
public static List<AlchemyArrayCraftingRecipeJEI> getRecipes() {
public static List<AlchemyArrayCraftingRecipeJEI> getRecipes()
{
Map<ItemStackWrapper, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> alchemyArrayRecipeMap = AlchemyArrayRecipeRegistry.getRecipes();
ArrayList<AlchemyArrayCraftingRecipeJEI> recipes = new ArrayList<AlchemyArrayCraftingRecipeJEI>();
for (Map.Entry<ItemStackWrapper, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> itemStackAlchemyArrayRecipeEntry : alchemyArrayRecipeMap.entrySet()) {
for (Map.Entry<ItemStackWrapper, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> itemStackAlchemyArrayRecipeEntry : alchemyArrayRecipeMap.entrySet())
{
ItemStack input = itemStackAlchemyArrayRecipeEntry.getValue().getInputStack();
BiMap<ItemStackWrapper, AlchemyArrayEffect> catalystMap = itemStackAlchemyArrayRecipeEntry.getValue().catalystMap;
for(Map.Entry<ItemStackWrapper, AlchemyArrayEffect> entry : catalystMap.entrySet()) {
for (Map.Entry<ItemStackWrapper, AlchemyArrayEffect> entry : catalystMap.entrySet())
{
ItemStack catalyst = entry.getKey().toStack();
if (AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(input, catalyst) instanceof AlchemyArrayEffectCrafting) {
if (AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(input, catalyst) instanceof AlchemyArrayEffectCrafting)
{
ItemStack output = ((AlchemyArrayEffectCrafting) itemStackAlchemyArrayRecipeEntry.getValue().getAlchemyArrayEffectForCatalyst(catalyst)).getOutputStack();
AlchemyArrayCraftingRecipeJEI recipe = new AlchemyArrayCraftingRecipeJEI(input, catalyst, output);

View file

@ -13,7 +13,8 @@ import net.minecraft.util.ResourceLocation;
import javax.annotation.Nonnull;
public class AltarRecipeCategory implements IRecipeCategory {
public class AltarRecipeCategory implements IRecipeCategory
{
private static final int INPUT_SLOT = 0;
private static final int OUTPUT_SLOT = 1;
@ -25,40 +26,47 @@ public class AltarRecipeCategory implements IRecipeCategory {
@Nonnull
@Override
public String getUid() {
public String getUid()
{
return Constants.Compat.JEI_CATEGORY_ALTAR;
}
@Nonnull
@Override
public String getTitle() {
public String getTitle()
{
return localizedName;
}
@Nonnull
@Override
public IDrawable getBackground() {
public IDrawable getBackground()
{
return background;
}
@Override
public void drawExtras(Minecraft minecraft) {
public void drawExtras(Minecraft minecraft)
{
}
@Override
public void drawAnimations(Minecraft minecraft) {
public void drawAnimations(Minecraft minecraft)
{
}
@Override
@SuppressWarnings("unchecked")
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper)
{
recipeLayout.getItemStacks().init(INPUT_SLOT, true, 31, 0);
recipeLayout.getItemStacks().init(OUTPUT_SLOT, false, 125, 30);
if (recipeWrapper instanceof AltarRecipeJEI) {
if (recipeWrapper instanceof AltarRecipeJEI)
{
AltarRecipeJEI altarRecipeWrapper = (AltarRecipeJEI) recipeWrapper;
recipeLayout.getItemStacks().set(INPUT_SLOT, altarRecipeWrapper.getInputs());
recipeLayout.getItemStacks().set(OUTPUT_SLOT, altarRecipeWrapper.getOutputs());

View file

@ -6,28 +6,33 @@ import mezz.jei.api.recipe.IRecipeWrapper;
import javax.annotation.Nonnull;
public class AltarRecipeHandler implements IRecipeHandler<AltarRecipeJEI> {
public class AltarRecipeHandler implements IRecipeHandler<AltarRecipeJEI>
{
@Nonnull
@Override
public Class<AltarRecipeJEI> getRecipeClass() {
public Class<AltarRecipeJEI> getRecipeClass()
{
return AltarRecipeJEI.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() {
public String getRecipeCategoryUid()
{
return Constants.Compat.JEI_CATEGORY_ALTAR;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull AltarRecipeJEI recipe) {
public IRecipeWrapper getRecipeWrapper(@Nonnull AltarRecipeJEI recipe)
{
return recipe;
}
@Override
public boolean isRecipeValid(@Nonnull AltarRecipeJEI recipe) {
public boolean isRecipeValid(@Nonnull AltarRecipeJEI recipe)
{
return recipe.getInputs().size() > 0 && recipe.getOutputs().size() > 0;
}
}

View file

@ -10,7 +10,8 @@ import java.awt.*;
import java.util.Collections;
import java.util.List;
public class AltarRecipeJEI extends BloodMagicRecipeWrapper {
public class AltarRecipeJEI extends BloodMagicRecipeWrapper
{
@Nonnull
private final ItemStack input;
@ -20,7 +21,8 @@ public class AltarRecipeJEI extends BloodMagicRecipeWrapper {
private final String[] infoString;
public AltarRecipeJEI(@Nonnull ItemStack input, @Nonnull ItemStack output, int tier, int requiredLP) {
public AltarRecipeJEI(@Nonnull ItemStack input, @Nonnull ItemStack output, int tier, int requiredLP)
{
this.input = input;
this.output = output;
@ -28,23 +30,27 @@ public class AltarRecipeJEI extends BloodMagicRecipeWrapper {
}
@Override
public List getInputs() {
public List getInputs()
{
return Collections.singletonList(input);
}
@Override
public List getOutputs() {
public List getOutputs()
{
return Collections.singletonList(output);
}
@Override
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight)
{
minecraft.fontRendererObj.drawString(infoString[0], 90 - minecraft.fontRendererObj.getStringWidth(infoString[0]) / 2, 0, Color.gray.getRGB());
minecraft.fontRendererObj.drawString(infoString[1], 90 - minecraft.fontRendererObj.getStringWidth(infoString[1]) / 2, 10, Color.gray.getRGB());
}
@Override
public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {
public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight)
{
}
}

View file

@ -8,16 +8,21 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class AltarRecipeMaker {
public class AltarRecipeMaker
{
@Nonnull
public static List<AltarRecipeJEI> getRecipes() {
public static List<AltarRecipeJEI> getRecipes()
{
Map<ItemStack, AltarRecipeRegistry.AltarRecipe> altarMap = AltarRecipeRegistry.getRecipes();
ArrayList<AltarRecipeJEI> recipes = new ArrayList<AltarRecipeJEI>();
for (Map.Entry<ItemStack, AltarRecipeRegistry.AltarRecipe> itemStackAltarRecipeEntry : altarMap.entrySet()) {
if (itemStackAltarRecipeEntry.getValue().getOutput() != null) { // Make sure output is not null. If it is, the recipe is for a filling orb, and we don't want that.
for (Map.Entry<ItemStack, AltarRecipeRegistry.AltarRecipe> itemStackAltarRecipeEntry : altarMap.entrySet())
{
if (itemStackAltarRecipeEntry.getValue().getOutput() != null)
{ // Make sure output is not null. If it is, the recipe is for a
// filling orb, and we don't want that.
ItemStack input = itemStackAltarRecipeEntry.getKey();
ItemStack output = itemStackAltarRecipeEntry.getValue().getOutput();
int requiredTier = itemStackAltarRecipeEntry.getValue().getMinTier().toInt();

View file

@ -13,7 +13,8 @@ import net.minecraft.util.ResourceLocation;
import javax.annotation.Nonnull;
public class BindingRecipeCategory implements IRecipeCategory {
public class BindingRecipeCategory implements IRecipeCategory
{
private static final int INPUT_SLOT = 0;
private static final int CATALYST_SLOT = 1;
@ -26,41 +27,48 @@ public class BindingRecipeCategory implements IRecipeCategory {
@Nonnull
@Override
public String getUid() {
public String getUid()
{
return Constants.Compat.JEI_CATEGORY_BINDING;
}
@Nonnull
@Override
public String getTitle() {
public String getTitle()
{
return localizedName;
}
@Nonnull
@Override
public IDrawable getBackground() {
public IDrawable getBackground()
{
return background;
}
@Override
public void drawExtras(Minecraft minecraft) {
public void drawExtras(Minecraft minecraft)
{
}
@Override
public void drawAnimations(Minecraft minecraft) {
public void drawAnimations(Minecraft minecraft)
{
}
@Override
@SuppressWarnings("unchecked")
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper)
{
recipeLayout.getItemStacks().init(INPUT_SLOT, true, 0, 5);
recipeLayout.getItemStacks().init(CATALYST_SLOT, true, 50, 5);
recipeLayout.getItemStacks().init(OUTPUT_SLOT, false, 73, 5);
if (recipeWrapper instanceof BindingRecipeJEI) {
if (recipeWrapper instanceof BindingRecipeJEI)
{
BindingRecipeJEI bindingRecipe = (BindingRecipeJEI) recipeWrapper;
recipeLayout.getItemStacks().set(INPUT_SLOT, (ItemStack) bindingRecipe.getInputs().get(0));
recipeLayout.getItemStacks().set(CATALYST_SLOT, (ItemStack) bindingRecipe.getInputs().get(1));

View file

@ -6,28 +6,33 @@ import mezz.jei.api.recipe.IRecipeWrapper;
import javax.annotation.Nonnull;
public class BindingRecipeHandler implements IRecipeHandler<BindingRecipeJEI> {
public class BindingRecipeHandler implements IRecipeHandler<BindingRecipeJEI>
{
@Nonnull
@Override
public Class<BindingRecipeJEI> getRecipeClass() {
public Class<BindingRecipeJEI> getRecipeClass()
{
return BindingRecipeJEI.class;
}
@Nonnull
@Override
public String getRecipeCategoryUid() {
public String getRecipeCategoryUid()
{
return Constants.Compat.JEI_CATEGORY_BINDING;
}
@Nonnull
@Override
public IRecipeWrapper getRecipeWrapper(@Nonnull BindingRecipeJEI recipe) {
public IRecipeWrapper getRecipeWrapper(@Nonnull BindingRecipeJEI recipe)
{
return recipe;
}
@Override
public boolean isRecipeValid(@Nonnull BindingRecipeJEI recipe) {
public boolean isRecipeValid(@Nonnull BindingRecipeJEI recipe)
{
return recipe.getInputs().size() > 0 && recipe.getOutputs().size() > 0;
}
}

Some files were not shown because too many files have changed in this diff Show more