Changed formatting to have bracing on a new line
This commit is contained in:
parent
e5eddd6c45
commit
e48eedb874
|
@ -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();
|
||||
|
|
|
@ -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,23 +91,25 @@ 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";
|
||||
config.addCustomCategoryComment(category, "Allows disabling of specific Blocks/Items.\nNote that using this may result in crashes. Use is not supported.");
|
||||
config.setCategoryRequiresMcRestart(category, true);
|
||||
itemBlacklist = Arrays.asList(config.getStringList("itemBlacklist", category, new String[]{}, "Items to not be registered. This requires their mapping name. Usually the same as the class name. Can be found in F3+H mode."));
|
||||
blockBlacklist = Arrays.asList(config.getStringList("blockBlacklist", category, new String[]{}, "Blocks to not be registered. This requires their mapping name. Usually the same as the class name. Can be found in F3+H mode."));
|
||||
itemBlacklist = Arrays.asList(config.getStringList("itemBlacklist", category, new String[] {}, "Items to not be registered. This requires their mapping name. Usually the same as the class name. Can be found in F3+H mode."));
|
||||
blockBlacklist = Arrays.asList(config.getStringList("blockBlacklist", category, new String[] {}, "Blocks to not be registered. This requires their mapping name. Usually the same as the class name. Can be found in F3+H mode."));
|
||||
|
||||
category = "Teleposer Blacklist";
|
||||
config.addCustomCategoryComment(category, "Block blacklisting");
|
||||
teleposerBlacklisting = config.getStringList("teleposerBlacklist", category, new String[]{"minecraft:bedrock"}, "Stops specified blocks from being teleposed. Put entries on new lines. Valid syntax is:\nmodid:blockname:meta");
|
||||
teleposerBlacklisting = config.getStringList("teleposerBlacklist", category, new String[] { "minecraft:bedrock" }, "Stops specified blocks from being teleposed. Put entries on new lines. Valid syntax is:\nmodid:blockname:meta");
|
||||
buildTeleposerBlacklist();
|
||||
|
||||
category = "Potions";
|
||||
|
@ -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();
|
||||
|
|
|
@ -11,51 +11,60 @@ 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;
|
||||
@Getter
|
||||
public final ItemStack outputStack;
|
||||
|
||||
public AlchemyArrayEffectBinding(ItemStack outputStack) {
|
||||
this.outputStack = 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.
|
||||
this.spawnLightningOnCircle(tile.getWorld(), tile.getPos(), ticksActive);
|
||||
}
|
||||
@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.
|
||||
this.spawnLightningOnCircle(tile.getWorld(), tile.getPos(), ticksActive);
|
||||
}
|
||||
|
||||
if(tile.getWorld().isRemote) {
|
||||
return false;
|
||||
}
|
||||
if (tile.getWorld().isRemote)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(ticksActive >= 300){
|
||||
BlockPos pos = tile.getPos();
|
||||
if (ticksActive >= 300)
|
||||
{
|
||||
BlockPos pos = tile.getPos();
|
||||
|
||||
ItemStack output = outputStack.copy();
|
||||
EntityItem outputEntity = new EntityItem(tile.getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output);
|
||||
ItemStack output = outputStack.copy();
|
||||
EntityItem outputEntity = new EntityItem(tile.getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output);
|
||||
|
||||
tile.getWorld().spawnEntityInWorld(outputEntity);
|
||||
tile.getWorld().spawnEntityInWorld(outputEntity);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
double dispX = distance * Math.sin(angle);
|
||||
double dispZ = -distance * Math.cos(angle);
|
||||
double dispX = distance * Math.sin(angle);
|
||||
double dispZ = -distance * Math.cos(angle);
|
||||
|
||||
EntityLightningBolt lightning = new EntityLightningBolt(world, pos.getX() + dispX, pos.getY(), pos.getZ() + dispZ);
|
||||
world.spawnEntityInWorld(lightning);
|
||||
}
|
||||
}
|
||||
EntityLightningBolt lightning = new EntityLightningBolt(world, pos.getX() + dispX, pos.getY(), pos.getZ() + dispZ);
|
||||
world.spawnEntityInWorld(lightning);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,19 +31,20 @@ 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;
|
||||
private TileAltar tileAltar;
|
||||
private int internalCounter = 0;
|
||||
|
||||
public boolean isActive;
|
||||
public boolean isActive;
|
||||
protected FluidStack fluidOutput = new FluidStack(BlockLifeEssence.getLifeEssence(), 0);
|
||||
protected FluidStack fluidInput = new FluidStack(BlockLifeEssence.getLifeEssence(), 0);
|
||||
private EnumAltarTier altarTier = EnumAltarTier.ONE;
|
||||
private AltarUpgrade upgrade;
|
||||
private int capacity = FluidContainerRegistry.BUCKET_VOLUME * 10;
|
||||
private FluidStack fluid = new FluidStack(BloodMagicAPI.getLifeEssence(), 0);
|
||||
private int liquidRequired; //mB
|
||||
private int liquidRequired; // mB
|
||||
private boolean canBeFilled;
|
||||
private int consumptionRate;
|
||||
private int drainRate;
|
||||
|
@ -66,12 +67,13 @@ public class BloodAltar {
|
|||
|
||||
private ItemStack result;
|
||||
|
||||
public BloodAltar(TileAltar tileAltar)
|
||||
{
|
||||
this.tileAltar = tileAltar;
|
||||
}
|
||||
public BloodAltar(TileAltar tileAltar)
|
||||
{
|
||||
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,57 +125,63 @@ 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())) {
|
||||
case 1:
|
||||
upgrades.addSpeed();
|
||||
break;
|
||||
if (worldBlock.getBlock() instanceof BlockBloodRune)
|
||||
{
|
||||
switch (((BlockBloodRune) worldBlock.getBlock()).getRuneEffect(worldBlock.getMeta()))
|
||||
{
|
||||
case 1:
|
||||
upgrades.addSpeed();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
upgrades.addEfficiency();
|
||||
break;
|
||||
case 2:
|
||||
upgrades.addEfficiency();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
upgrades.addSacrifice();
|
||||
break;
|
||||
case 3:
|
||||
upgrades.addSacrifice();
|
||||
break;
|
||||
|
||||
case 4:
|
||||
upgrades.addSelfSacrifice();
|
||||
break;
|
||||
case 4:
|
||||
upgrades.addSelfSacrifice();
|
||||
break;
|
||||
|
||||
case 5:
|
||||
upgrades.addDisplacement();
|
||||
break;
|
||||
case 5:
|
||||
upgrades.addDisplacement();
|
||||
break;
|
||||
|
||||
case 6:
|
||||
upgrades.addCapacity();
|
||||
break;
|
||||
case 6:
|
||||
upgrades.addCapacity();
|
||||
break;
|
||||
|
||||
case 7:
|
||||
upgrades.addBetterCapacity();
|
||||
break;
|
||||
case 7:
|
||||
upgrades.addBetterCapacity();
|
||||
break;
|
||||
|
||||
case 8:
|
||||
upgrades.addOrbCapacity();
|
||||
break;
|
||||
case 8:
|
||||
upgrades.addOrbCapacity();
|
||||
break;
|
||||
|
||||
case 9:
|
||||
upgrades.addAcceleration();
|
||||
break;
|
||||
case 9:
|
||||
upgrades.addAcceleration();
|
||||
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,9 +270,10 @@ 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());
|
||||
tileAltar.getWorld().markBlockForUpdate(tileAltar.getPos());
|
||||
|
||||
checkTier();
|
||||
|
||||
|
@ -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() {
|
||||
World world = tileAltar.getWorld();
|
||||
public void update()
|
||||
{
|
||||
World world = tileAltar.getWorld();
|
||||
BlockPos pos = tileAltar.getPos();
|
||||
|
||||
if (world.isRemote)
|
||||
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){
|
||||
BlockPos newPos = pos.offset(facing);
|
||||
IBlockState block = world.getBlockState(newPos);
|
||||
block.getBlock().onNeighborBlockChange(world, newPos, block, block.getBlock());
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -2,8 +2,9 @@ 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);
|
||||
public abstract boolean update(TileEntity tile, int ticksActive);
|
||||
|
||||
}
|
||||
|
|
|
@ -6,39 +6,45 @@ 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;
|
||||
@Getter
|
||||
public final ItemStack outputStack;
|
||||
public int tickLimit;
|
||||
|
||||
public AlchemyArrayEffectCrafting(ItemStack outputStack) {
|
||||
this(outputStack, 200);
|
||||
}
|
||||
public AlchemyArrayEffectCrafting(ItemStack outputStack)
|
||||
{
|
||||
this(outputStack, 200);
|
||||
}
|
||||
|
||||
public AlchemyArrayEffectCrafting(ItemStack outputStack, int tickLimit) {
|
||||
this.outputStack = outputStack;
|
||||
this.tickLimit = tickLimit;
|
||||
}
|
||||
public AlchemyArrayEffectCrafting(ItemStack outputStack, int tickLimit)
|
||||
{
|
||||
this.outputStack = outputStack;
|
||||
this.tickLimit = tickLimit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TileEntity tile, int ticksActive) {
|
||||
//TODO: Add recipe rechecking to verify nothing screwy is going on.
|
||||
if(tile.getWorld().isRemote) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean update(TileEntity tile, int ticksActive)
|
||||
{
|
||||
// TODO: Add recipe rechecking to verify nothing screwy is going on.
|
||||
if (tile.getWorld().isRemote)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(ticksActive >= tickLimit){
|
||||
BlockPos pos = tile.getPos();
|
||||
if (ticksActive >= tickLimit)
|
||||
{
|
||||
BlockPos pos = tile.getPos();
|
||||
|
||||
ItemStack output = outputStack.copy();
|
||||
EntityItem outputEntity = new EntityItem(tile.getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output);
|
||||
ItemStack output = outputStack.copy();
|
||||
EntityItem outputEntity = new EntityItem(tile.getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output);
|
||||
|
||||
tile.getWorld().spawnEntityInWorld(outputEntity);
|
||||
tile.getWorld().spawnEntityInWorld(outputEntity);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,132 +9,146 @@ 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 float offsetFromFace = -0.9f;
|
||||
public final ResourceLocation arrayResource;
|
||||
|
||||
public AlchemyCircleRenderer() {
|
||||
this(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png"));
|
||||
}
|
||||
public AlchemyCircleRenderer()
|
||||
{
|
||||
this(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png"));
|
||||
}
|
||||
|
||||
public AlchemyCircleRenderer(ResourceLocation arrayResource) {
|
||||
this.arrayResource = arrayResource;
|
||||
}
|
||||
public AlchemyCircleRenderer(ResourceLocation arrayResource)
|
||||
{
|
||||
this.arrayResource = arrayResource;
|
||||
}
|
||||
|
||||
public float getRotation(float craftTime) {
|
||||
float offset = 2;
|
||||
if (craftTime >= offset) {
|
||||
float modifier = (float) Math.pow(craftTime - offset, 1.5);
|
||||
return modifier * 1f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public float getRotation(float craftTime)
|
||||
{
|
||||
float offset = 2;
|
||||
if (craftTime >= offset)
|
||||
{
|
||||
float modifier = (float) Math.pow(craftTime - offset, 1.5);
|
||||
return modifier * 1f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getSecondaryRotation(float craftTime) {
|
||||
float offset = 50;
|
||||
if (craftTime >= offset) {
|
||||
float modifier = (float) Math.pow(craftTime - offset, 1.7);
|
||||
return modifier * 0.5f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public float getSecondaryRotation(float craftTime)
|
||||
{
|
||||
float offset = 50;
|
||||
if (craftTime >= offset)
|
||||
{
|
||||
float modifier = (float) Math.pow(craftTime - offset, 1.7);
|
||||
return modifier * 0.5f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getSizeModifier(float craftTime) {
|
||||
if (craftTime >= 150 && craftTime <= 250) {
|
||||
return (200 - craftTime) / 50f;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
public float getSizeModifier(float craftTime)
|
||||
{
|
||||
if (craftTime >= 150 && craftTime <= 250)
|
||||
{
|
||||
return (200 - craftTime) / 50f;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public float getVerticalOffset(float craftTime) {
|
||||
if (craftTime >= 5) {
|
||||
if (craftTime <= 40) {
|
||||
return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3));
|
||||
} else {
|
||||
return -0.4f;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public float getVerticalOffset(float craftTime)
|
||||
{
|
||||
if (craftTime >= 5)
|
||||
{
|
||||
if (craftTime <= 40)
|
||||
{
|
||||
return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3));
|
||||
} else
|
||||
{
|
||||
return -0.4f;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) {
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer wr = tessellator.getWorldRenderer();
|
||||
public void renderAt(TileEntity tile, double x, double y, double z, float craftTime)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer wr = tessellator.getWorldRenderer();
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
// float rot = (float)(this.worldObj.provider.getWorldTime() % (360 /
|
||||
// this.rotationspeed) * this.rotationspeed) + this.rotationspeed * f;
|
||||
float rot = getRotation(craftTime);
|
||||
float secondaryRot = getSecondaryRotation(craftTime);
|
||||
GlStateManager.pushMatrix();
|
||||
// float rot = (float)(this.worldObj.provider.getWorldTime() % (360 /
|
||||
// this.rotationspeed) * this.rotationspeed) + this.rotationspeed * f;
|
||||
float rot = getRotation(craftTime);
|
||||
float secondaryRot = getSecondaryRotation(craftTime);
|
||||
|
||||
float size = 1.0F * getSizeModifier(craftTime);
|
||||
float size = 1.0F * getSizeModifier(craftTime);
|
||||
|
||||
// Bind the texture to the circle
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(arrayResource);
|
||||
// Bind the texture to the circle
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(arrayResource);
|
||||
|
||||
GlStateManager.disableCull();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(770, 1);
|
||||
GlStateManager.disableCull();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(770, 1);
|
||||
|
||||
GlStateManager.translate(x, y, z);
|
||||
GlStateManager.translate(x, y, z);
|
||||
|
||||
EnumFacing sideHit = EnumFacing.UP; // Specify which face this "circle"
|
||||
// is located on
|
||||
GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY()
|
||||
* offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace);
|
||||
EnumFacing sideHit = EnumFacing.UP; // Specify which face this "circle"
|
||||
// is located on
|
||||
GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace);
|
||||
|
||||
switch (sideHit) {
|
||||
case DOWN:
|
||||
GlStateManager.translate(0, 0, 1);
|
||||
GlStateManager.rotate(-90.0f, 1, 0, 0);
|
||||
break;
|
||||
case EAST:
|
||||
GlStateManager.rotate(-90.0f, 0, 1, 0);
|
||||
GlStateManager.translate(0, 0, -1);
|
||||
break;
|
||||
case NORTH:
|
||||
break;
|
||||
case SOUTH:
|
||||
GlStateManager.rotate(180.0f, 0, 1, 0);
|
||||
GlStateManager.translate(-1, 0, -1);
|
||||
break;
|
||||
case UP:
|
||||
GlStateManager.translate(0, 1, 0);
|
||||
GlStateManager.rotate(90.0f, 1, 0, 0);
|
||||
break;
|
||||
case WEST:
|
||||
GlStateManager.translate(0, 0, 1);
|
||||
GlStateManager.rotate(90.0f, 0, 1, 0);
|
||||
break;
|
||||
}
|
||||
switch (sideHit)
|
||||
{
|
||||
case DOWN:
|
||||
GlStateManager.translate(0, 0, 1);
|
||||
GlStateManager.rotate(-90.0f, 1, 0, 0);
|
||||
break;
|
||||
case EAST:
|
||||
GlStateManager.rotate(-90.0f, 0, 1, 0);
|
||||
GlStateManager.translate(0, 0, -1);
|
||||
break;
|
||||
case NORTH:
|
||||
break;
|
||||
case SOUTH:
|
||||
GlStateManager.rotate(180.0f, 0, 1, 0);
|
||||
GlStateManager.translate(-1, 0, -1);
|
||||
break;
|
||||
case UP:
|
||||
GlStateManager.translate(0, 1, 0);
|
||||
GlStateManager.rotate(90.0f, 1, 0, 0);
|
||||
break;
|
||||
case WEST:
|
||||
GlStateManager.translate(0, 0, 1);
|
||||
GlStateManager.rotate(90.0f, 0, 1, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(0.5f, 0.5f, getVerticalOffset(craftTime));
|
||||
GlStateManager.rotate(rot, 0, 0, 1);
|
||||
GlStateManager.rotate(secondaryRot, 1, 0, 0);
|
||||
GlStateManager.rotate(secondaryRot * 0.45812f, 0, 0, 1);
|
||||
double var31 = 0.0D;
|
||||
double var33 = 1.0D;
|
||||
double var35 = 0;
|
||||
double var37 = 1;
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(0.5f, 0.5f, getVerticalOffset(craftTime));
|
||||
GlStateManager.rotate(rot, 0, 0, 1);
|
||||
GlStateManager.rotate(secondaryRot, 1, 0, 0);
|
||||
GlStateManager.rotate(secondaryRot * 0.45812f, 0, 0, 1);
|
||||
double var31 = 0.0D;
|
||||
double var33 = 1.0D;
|
||||
double var35 = 0;
|
||||
double var37 = 1;
|
||||
|
||||
GlStateManager.color(0.5f, 1f, 1f, 1f);
|
||||
wr.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||
// wr.setBrightness(200);
|
||||
wr.pos(size / 2f, size / 2f, 0.0D).tex(var33, var37).endVertex();
|
||||
wr.pos(size / 2f, -size / 2f, 0.0D).tex(var33, var35).endVertex();
|
||||
wr.pos(-size / 2f, -size / 2f, 0.0D).tex(var31, var35).endVertex();
|
||||
wr.pos(-size / 2f, size / 2f, 0.0D).tex(var31, var37).endVertex();
|
||||
tessellator.draw();
|
||||
GlStateManager.color(0.5f, 1f, 1f, 1f);
|
||||
wr.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||
// wr.setBrightness(200);
|
||||
wr.pos(size / 2f, size / 2f, 0.0D).tex(var33, var37).endVertex();
|
||||
wr.pos(size / 2f, -size / 2f, 0.0D).tex(var33, var35).endVertex();
|
||||
wr.pos(-size / 2f, -size / 2f, 0.0D).tex(var31, var35).endVertex();
|
||||
wr.pos(-size / 2f, size / 2f, 0.0D).tex(var31, var37).endVertex();
|
||||
tessellator.draw();
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
// GlStateManager.depthMask(true);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableCull();
|
||||
// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
// GlStateManager.depthMask(true);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableCull();
|
||||
// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package WayofTime.bloodmagic.api.altar;
|
||||
|
||||
public interface IAltarComponent {
|
||||
public interface IAltarComponent
|
||||
{
|
||||
|
||||
EnumAltarComponent getType(int meta);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -3,12 +3,16 @@ 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
|
||||
* @return The result of the compression
|
||||
* 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);
|
||||
}
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package WayofTime.bloodmagic.api.iface;
|
||||
|
||||
public interface IAltarReader {
|
||||
public interface IAltarReader
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
package WayofTime.bloodmagic.api.iface;
|
||||
|
||||
public interface ISigil {
|
||||
public interface ISigil
|
||||
{
|
||||
}
|
||||
|
|
|
@ -7,55 +7,68 @@ import java.util.List;
|
|||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
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 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) {
|
||||
trackers.add(tracker);
|
||||
}
|
||||
public static void registerStatTracker(Class<? extends StatTracker> tracker)
|
||||
{
|
||||
trackers.add(tracker);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a LivingArmourUpgrade using its unique identifier and class.
|
||||
* This is done to more easily load upgrades
|
||||
*
|
||||
* @param upgrade
|
||||
*/
|
||||
public static void registerArmourUpgrade(LivingArmourUpgrade upgrade) {
|
||||
Class<? extends LivingArmourUpgrade> clazz = upgrade.getClass();
|
||||
upgradeMap.put(upgrade.getUniqueIdentifier(), clazz);
|
||||
try {
|
||||
Constructor<? extends LivingArmourUpgrade> ctor = clazz.getConstructor(int.class);
|
||||
if (ctor == null) {
|
||||
// TODO: This is bad - add something to the log
|
||||
} else {
|
||||
upgradeConstructorMap.put(upgrade.getUniqueIdentifier(), ctor);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
/**
|
||||
* Registers a LivingArmourUpgrade using its unique identifier and class.
|
||||
* This is done to more easily load upgrades
|
||||
*
|
||||
* @param upgrade
|
||||
*/
|
||||
public static void registerArmourUpgrade(LivingArmourUpgrade upgrade)
|
||||
{
|
||||
Class<? extends LivingArmourUpgrade> clazz = upgrade.getClass();
|
||||
upgradeMap.put(upgrade.getUniqueIdentifier(), clazz);
|
||||
try
|
||||
{
|
||||
Constructor<? extends LivingArmourUpgrade> ctor = clazz.getConstructor(int.class);
|
||||
if (ctor == null)
|
||||
{
|
||||
// TODO: This is bad - add something to the log
|
||||
} else
|
||||
{
|
||||
upgradeConstructorMap.put(upgrade.getUniqueIdentifier(), ctor);
|
||||
}
|
||||
} catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level) {
|
||||
return generateUpgradeFromKey(key, level, null);
|
||||
}
|
||||
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level)
|
||||
{
|
||||
return generateUpgradeFromKey(key, level, null);
|
||||
}
|
||||
|
||||
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level, NBTTagCompound tag) {
|
||||
Constructor<? extends LivingArmourUpgrade> ctor = upgradeConstructorMap.get(key);
|
||||
if (ctor != null) {
|
||||
try {
|
||||
LivingArmourUpgrade upgrade = ctor.newInstance(level);
|
||||
if (upgrade != null && tag != null) {
|
||||
upgrade.readFromNBT(tag);
|
||||
}
|
||||
return upgrade;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level, NBTTagCompound tag)
|
||||
{
|
||||
Constructor<? extends LivingArmourUpgrade> ctor = upgradeConstructorMap.get(key);
|
||||
if (ctor != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
LivingArmourUpgrade upgrade = ctor.newInstance(level);
|
||||
if (upgrade != null && tag != null)
|
||||
{
|
||||
upgrade.readFromNBT(tag);
|
||||
}
|
||||
return upgrade;
|
||||
} catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,45 +9,50 @@ 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.
|
||||
protected int level = 0; // Upgrade level 0 is the first upgrade. Upgrade
|
||||
// goes from 0 to getMaxTier() - 1.
|
||||
|
||||
/**
|
||||
* The LivingArmourUpgrade must have a constructor that has a single integer
|
||||
* parameter. Upgrades may have other constructors, but must have one of
|
||||
* these.
|
||||
*
|
||||
* @param level
|
||||
* The level of the upgrade
|
||||
*/
|
||||
public LivingArmourUpgrade(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
/**
|
||||
* The LivingArmourUpgrade must have a constructor that has a single integer
|
||||
* parameter. Upgrades may have other constructors, but must have one of
|
||||
* these.
|
||||
*
|
||||
* @param level
|
||||
* The level of the upgrade
|
||||
*/
|
||||
public LivingArmourUpgrade(int level)
|
||||
{
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public int getUpgradeLevel()
|
||||
{
|
||||
return this.level;
|
||||
}
|
||||
public int getUpgradeLevel()
|
||||
{
|
||||
return this.level;
|
||||
}
|
||||
|
||||
public abstract String getUniqueIdentifier();
|
||||
public abstract String getUniqueIdentifier();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract int getMaxTier();
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract int getMaxTier();
|
||||
|
||||
public abstract int getCostOfUpgrade();
|
||||
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() {
|
||||
return HashMultimap.<String, AttributeModifier> create();
|
||||
}
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers()
|
||||
{
|
||||
return HashMultimap.<String, AttributeModifier> create();
|
||||
}
|
||||
|
||||
public abstract void writeToNBT(NBTTagCompound tag);
|
||||
public abstract void writeToNBT(NBTTagCompound tag);
|
||||
|
||||
public abstract void readFromNBT(NBTTagCompound tag);
|
||||
public abstract void readFromNBT(NBTTagCompound tag);
|
||||
}
|
||||
|
|
|
@ -5,47 +5,51 @@ 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;
|
||||
private boolean isDirty = false;
|
||||
|
||||
public abstract String getUniqueIdentifier();
|
||||
public abstract String getUniqueIdentifier();
|
||||
|
||||
/**
|
||||
* When called the StatTracker should reset all of its data, including
|
||||
* upgrades.
|
||||
*/
|
||||
public abstract void resetTracker();
|
||||
/**
|
||||
* When called the StatTracker should reset all of its data, including
|
||||
* upgrades.
|
||||
*/
|
||||
public abstract void resetTracker();
|
||||
|
||||
public abstract void readFromNBT(NBTTagCompound tag);
|
||||
public abstract void readFromNBT(NBTTagCompound tag);
|
||||
|
||||
public abstract void writeToNBT(NBTTagCompound tag);
|
||||
public abstract void writeToNBT(NBTTagCompound tag);
|
||||
|
||||
/**
|
||||
* Called each tick to update the tracker's information. Called in
|
||||
* LivingArmour
|
||||
*
|
||||
* @param world
|
||||
* World the player is in
|
||||
* @param player
|
||||
* The player that has the armour equipped
|
||||
* @param livingArmour
|
||||
* The equipped LivingArmour
|
||||
* @return True if there is a new upgrade unlocked this tick.
|
||||
*/
|
||||
public abstract boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour);
|
||||
/**
|
||||
* Called each tick to update the tracker's information. Called in
|
||||
* LivingArmour
|
||||
*
|
||||
* @param world
|
||||
* World the player is in
|
||||
* @param player
|
||||
* The player that has the armour equipped
|
||||
* @param livingArmour
|
||||
* The equipped LivingArmour
|
||||
* @return True if there is a new upgrade unlocked this tick.
|
||||
*/
|
||||
public abstract boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour);
|
||||
|
||||
public abstract LivingArmourUpgrade[] getUpgrades();
|
||||
public abstract LivingArmourUpgrade[] getUpgrades();
|
||||
|
||||
public final boolean isDirty() {
|
||||
return isDirty;
|
||||
}
|
||||
public final boolean isDirty()
|
||||
{
|
||||
return isDirty;
|
||||
}
|
||||
|
||||
public final void markDirty() {
|
||||
this.isDirty = true;
|
||||
}
|
||||
public final void markDirty()
|
||||
{
|
||||
this.isDirty = true;
|
||||
}
|
||||
|
||||
public final void resetDirty() {
|
||||
this.isDirty = false;
|
||||
}
|
||||
public final void resetDirty()
|
||||
{
|
||||
this.isDirty = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 + '}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package WayofTime.bloodmagic.api.orb;
|
||||
|
||||
public interface IBloodOrb {
|
||||
public interface IBloodOrb
|
||||
{
|
||||
|
||||
BloodOrb getOrb(int meta);
|
||||
|
||||
|
|
|
@ -19,227 +19,281 @@ import WayofTime.bloodmagic.api.orb.IBloodOrb;
|
|||
/**
|
||||
* Shaped Blood Orb Recipe Handler by joshie *
|
||||
*/
|
||||
public class ShapedBloodOrbRecipe implements IRecipe {
|
||||
private static final int MAX_CRAFT_GRID_WIDTH = 3;
|
||||
private static final int MAX_CRAFT_GRID_HEIGHT = 3;
|
||||
public class ShapedBloodOrbRecipe implements IRecipe
|
||||
{
|
||||
private static final int MAX_CRAFT_GRID_WIDTH = 3;
|
||||
private static final int MAX_CRAFT_GRID_HEIGHT = 3;
|
||||
|
||||
private ItemStack output = null;
|
||||
private Object[] input = null;
|
||||
public int width = 0;
|
||||
public int height = 0;
|
||||
private boolean mirrored = true;
|
||||
private ItemStack output = null;
|
||||
private Object[] input = null;
|
||||
public int width = 0;
|
||||
public int height = 0;
|
||||
private boolean mirrored = true;
|
||||
|
||||
public ShapedBloodOrbRecipe(Block result, Object... recipe) {
|
||||
this(new ItemStack(result), recipe);
|
||||
}
|
||||
public ShapedBloodOrbRecipe(Block result, Object... recipe)
|
||||
{
|
||||
this(new ItemStack(result), recipe);
|
||||
}
|
||||
|
||||
public ShapedBloodOrbRecipe(Item result, Object... recipe) {
|
||||
this(new ItemStack(result), recipe);
|
||||
}
|
||||
public ShapedBloodOrbRecipe(Item result, Object... recipe)
|
||||
{
|
||||
this(new ItemStack(result), recipe);
|
||||
}
|
||||
|
||||
public ShapedBloodOrbRecipe(ItemStack result, Object... recipe) {
|
||||
output = result.copy();
|
||||
public ShapedBloodOrbRecipe(ItemStack result, Object... recipe)
|
||||
{
|
||||
output = result.copy();
|
||||
|
||||
String shape = "";
|
||||
int idx = 0;
|
||||
String shape = "";
|
||||
int idx = 0;
|
||||
|
||||
if (recipe[idx] instanceof Boolean) {
|
||||
mirrored = (Boolean) recipe[idx];
|
||||
if (recipe[idx + 1] instanceof Object[]) {
|
||||
recipe = (Object[]) recipe[idx + 1];
|
||||
} else {
|
||||
idx = 1;
|
||||
}
|
||||
}
|
||||
if (recipe[idx] instanceof Boolean)
|
||||
{
|
||||
mirrored = (Boolean) recipe[idx];
|
||||
if (recipe[idx + 1] instanceof Object[])
|
||||
{
|
||||
recipe = (Object[]) recipe[idx + 1];
|
||||
} else
|
||||
{
|
||||
idx = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (recipe[idx] instanceof String[]) {
|
||||
String[] parts = ((String[]) recipe[idx++]);
|
||||
if (recipe[idx] instanceof String[])
|
||||
{
|
||||
String[] parts = ((String[]) recipe[idx++]);
|
||||
|
||||
for (String s : parts) {
|
||||
width = s.length();
|
||||
shape += s;
|
||||
}
|
||||
for (String s : parts)
|
||||
{
|
||||
width = s.length();
|
||||
shape += s;
|
||||
}
|
||||
|
||||
height = parts.length;
|
||||
} else {
|
||||
while (recipe[idx] instanceof String) {
|
||||
String s = (String) recipe[idx++];
|
||||
shape += s;
|
||||
width = s.length();
|
||||
height++;
|
||||
}
|
||||
}
|
||||
height = parts.length;
|
||||
} else
|
||||
{
|
||||
while (recipe[idx] instanceof String)
|
||||
{
|
||||
String s = (String) recipe[idx++];
|
||||
shape += s;
|
||||
width = s.length();
|
||||
height++;
|
||||
}
|
||||
}
|
||||
|
||||
if (width * height != shape.length()) {
|
||||
String ret = "Invalid shaped ore recipe: ";
|
||||
for (Object tmp : recipe) {
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += output;
|
||||
throw new RuntimeException(ret);
|
||||
}
|
||||
if (width * height != shape.length())
|
||||
{
|
||||
String ret = "Invalid shaped ore recipe: ";
|
||||
for (Object tmp : recipe)
|
||||
{
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += output;
|
||||
throw new RuntimeException(ret);
|
||||
}
|
||||
|
||||
HashMap<Character, Object> itemMap = new HashMap<Character, Object>();
|
||||
HashMap<Character, Object> itemMap = new HashMap<Character, Object>();
|
||||
|
||||
for (; idx < recipe.length; idx += 2) {
|
||||
Character chr = (Character) recipe[idx];
|
||||
Object in = recipe[idx + 1];
|
||||
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 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) {
|
||||
itemMap.put(chr, ((ItemStack) in).copy());
|
||||
} else if (in instanceof Item) {
|
||||
itemMap.put(chr, new ItemStack((Item) in));
|
||||
} else if (in instanceof Block) {
|
||||
itemMap.put(chr, new ItemStack((Block) in, 1, OreDictionary.WILDCARD_VALUE));
|
||||
} else if (in instanceof String) {
|
||||
itemMap.put(chr, OreDictionary.getOres((String) in));
|
||||
} else {
|
||||
String ret = "Invalid shaped orb recipe: ";
|
||||
for (Object tmp : recipe) {
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += output;
|
||||
throw new RuntimeException(ret);
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
itemMap.put(chr, ((ItemStack) in).copy());
|
||||
} else if (in instanceof Item)
|
||||
{
|
||||
itemMap.put(chr, new ItemStack((Item) in));
|
||||
} else if (in instanceof Block)
|
||||
{
|
||||
itemMap.put(chr, new ItemStack((Block) in, 1, OreDictionary.WILDCARD_VALUE));
|
||||
} else if (in instanceof String)
|
||||
{
|
||||
itemMap.put(chr, OreDictionary.getOres((String) in));
|
||||
} else
|
||||
{
|
||||
String ret = "Invalid shaped orb recipe: ";
|
||||
for (Object tmp : recipe)
|
||||
{
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += output;
|
||||
throw new RuntimeException(ret);
|
||||
}
|
||||
}
|
||||
|
||||
input = new Object[width * height];
|
||||
int x = 0;
|
||||
for (char chr : shape.toCharArray()) {
|
||||
input[x++] = itemMap.get(chr);
|
||||
}
|
||||
}
|
||||
input = new Object[width * height];
|
||||
int x = 0;
|
||||
for (char chr : shape.toCharArray())
|
||||
{
|
||||
input[x++] = itemMap.get(chr);
|
||||
}
|
||||
}
|
||||
|
||||
ShapedBloodOrbRecipe(ShapedRecipes recipe, Map<ItemStack, String> replacements) {
|
||||
output = recipe.getRecipeOutput();
|
||||
width = recipe.recipeWidth;
|
||||
height = recipe.recipeHeight;
|
||||
ShapedBloodOrbRecipe(ShapedRecipes recipe, Map<ItemStack, String> replacements)
|
||||
{
|
||||
output = recipe.getRecipeOutput();
|
||||
width = recipe.recipeWidth;
|
||||
height = recipe.recipeHeight;
|
||||
|
||||
input = new Object[recipe.recipeItems.length];
|
||||
input = new Object[recipe.recipeItems.length];
|
||||
|
||||
for (int i = 0; i < input.length; i++) {
|
||||
ItemStack ingred = recipe.recipeItems[i];
|
||||
for (int i = 0; i < input.length; i++)
|
||||
{
|
||||
ItemStack ingred = recipe.recipeItems[i];
|
||||
|
||||
if (ingred == null)
|
||||
continue;
|
||||
if (ingred == null)
|
||||
continue;
|
||||
|
||||
input[i] = recipe.recipeItems[i];
|
||||
input[i] = recipe.recipeItems[i];
|
||||
|
||||
for (Entry<ItemStack, String> replace : replacements.entrySet()) {
|
||||
if (OreDictionary.itemMatches(replace.getKey(), ingred, true)) {
|
||||
input[i] = OreDictionary.getOres(replace.getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Entry<ItemStack, String> replace : replacements.entrySet())
|
||||
{
|
||||
if (OreDictionary.itemMatches(replace.getKey(), ingred, true))
|
||||
{
|
||||
input[i] = OreDictionary.getOres(replace.getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting var1) {
|
||||
return output.copy();
|
||||
}
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting var1)
|
||||
{
|
||||
return output.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return input.length;
|
||||
}
|
||||
@Override
|
||||
public int getRecipeSize()
|
||||
{
|
||||
return input.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return output;
|
||||
}
|
||||
@Override
|
||||
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)) {
|
||||
return true;
|
||||
}
|
||||
@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))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mirrored && checkMatch(inv, x, y, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mirrored && checkMatch(inv, x, y, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@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++) {
|
||||
int subX = x - startX;
|
||||
int subY = y - startY;
|
||||
Object target = null;
|
||||
@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++)
|
||||
{
|
||||
int subX = x - startX;
|
||||
int subY = y - startY;
|
||||
Object target = null;
|
||||
|
||||
if (subX >= 0 && subY >= 0 && subX < width && subY < height) {
|
||||
if (mirror) {
|
||||
target = input[width - subX - 1 + subY * width];
|
||||
} else {
|
||||
target = input[subX + subY * width];
|
||||
}
|
||||
}
|
||||
if (subX >= 0 && subY >= 0 && subX < width && subY < height)
|
||||
{
|
||||
if (mirror)
|
||||
{
|
||||
target = input[width - subX - 1 + subY * width];
|
||||
} else
|
||||
{
|
||||
target = input[subX + subY * width];
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
IBloodOrb orb = (IBloodOrb) slot.getItem();
|
||||
if (orb.getOrbLevel(slot.getItemDamage()) < (Integer) target) {
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
return false;
|
||||
} else if (target instanceof ItemStack) {
|
||||
if (!OreDictionary.itemMatches((ItemStack) target, slot, false)) {
|
||||
return false;
|
||||
}
|
||||
} else if (target instanceof ArrayList) {
|
||||
boolean matched = false;
|
||||
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)
|
||||
{
|
||||
IBloodOrb orb = (IBloodOrb) slot.getItem();
|
||||
if (orb.getOrbLevel(slot.getItemDamage()) < (Integer) target)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
return false;
|
||||
} else if (target instanceof ItemStack)
|
||||
{
|
||||
if (!OreDictionary.itemMatches((ItemStack) target, slot, false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} else if (target instanceof ArrayList)
|
||||
{
|
||||
boolean matched = false;
|
||||
|
||||
Iterator<ItemStack> itr = ((ArrayList<ItemStack>) target).iterator();
|
||||
while (itr.hasNext() && !matched) {
|
||||
matched = OreDictionary.itemMatches(itr.next(), slot, false);
|
||||
}
|
||||
Iterator<ItemStack> itr = ((ArrayList<ItemStack>) target).iterator();
|
||||
while (itr.hasNext() && !matched)
|
||||
{
|
||||
matched = OreDictionary.itemMatches(itr.next(), slot, false);
|
||||
}
|
||||
|
||||
if (!matched) {
|
||||
return false;
|
||||
}
|
||||
} else if (target == null && slot != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!matched)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} else if (target == null && slot != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ShapedBloodOrbRecipe setMirrored(boolean mirror) {
|
||||
mirrored = mirror;
|
||||
return this;
|
||||
}
|
||||
public ShapedBloodOrbRecipe setMirrored(boolean mirror)
|
||||
{
|
||||
mirrored = mirror;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Object[] getInput() {
|
||||
return this.input;
|
||||
}
|
||||
public Object[] getInput()
|
||||
{
|
||||
return this.input;
|
||||
}
|
||||
|
||||
public ItemStack[] getRemainingItems(InventoryCrafting inv) {
|
||||
ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()];
|
||||
public ItemStack[] getRemainingItems(InventoryCrafting inv)
|
||||
{
|
||||
ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()];
|
||||
|
||||
for (int i = 0; i < aitemstack.length; ++i) {
|
||||
ItemStack itemstack = inv.getStackInSlot(i);
|
||||
aitemstack[i] = net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack);
|
||||
}
|
||||
for (int i = 0; i < aitemstack.length; ++i)
|
||||
{
|
||||
ItemStack itemstack = inv.getStackInSlot(i);
|
||||
aitemstack[i] = net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack);
|
||||
}
|
||||
|
||||
return aitemstack;
|
||||
}
|
||||
return aitemstack;
|
||||
}
|
||||
}
|
|
@ -19,139 +19,173 @@ import WayofTime.bloodmagic.api.orb.IBloodOrb;
|
|||
/**
|
||||
* Shapeless Blood Orb Recipe Handler by joshie *
|
||||
*/
|
||||
public class ShapelessBloodOrbRecipe implements IRecipe {
|
||||
private ItemStack output = null;
|
||||
private ArrayList<Object> input = new ArrayList<Object>();
|
||||
public class ShapelessBloodOrbRecipe implements IRecipe
|
||||
{
|
||||
private ItemStack output = null;
|
||||
private ArrayList<Object> input = new ArrayList<Object>();
|
||||
|
||||
public ShapelessBloodOrbRecipe(Block result, Object... recipe) {
|
||||
this(new ItemStack(result), recipe);
|
||||
}
|
||||
public ShapelessBloodOrbRecipe(Block result, Object... recipe)
|
||||
{
|
||||
this(new ItemStack(result), recipe);
|
||||
}
|
||||
|
||||
public ShapelessBloodOrbRecipe(Item result, Object... recipe) {
|
||||
this(new ItemStack(result), recipe);
|
||||
}
|
||||
public ShapelessBloodOrbRecipe(Item result, Object... recipe)
|
||||
{
|
||||
this(new ItemStack(result), recipe);
|
||||
}
|
||||
|
||||
public ShapelessBloodOrbRecipe(ItemStack result, Object... recipe) {
|
||||
output = result.copy();
|
||||
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) {
|
||||
input.add(new ItemStack((Item) in));
|
||||
} else if (in instanceof Block) {
|
||||
input.add(new ItemStack((Block) in));
|
||||
} else if (in instanceof String) {
|
||||
input.add(OreDictionary.getOres((String) in));
|
||||
} else {
|
||||
String ret = "Invalid shapeless ore recipe: ";
|
||||
for (Object tmp : recipe) {
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += output;
|
||||
throw new RuntimeException(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
public ShapelessBloodOrbRecipe(ItemStack result, Object... recipe)
|
||||
{
|
||||
output = result.copy();
|
||||
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)
|
||||
{
|
||||
input.add(new ItemStack((Item) in));
|
||||
} else if (in instanceof Block)
|
||||
{
|
||||
input.add(new ItemStack((Block) in));
|
||||
} else if (in instanceof String)
|
||||
{
|
||||
input.add(OreDictionary.getOres((String) in));
|
||||
} else
|
||||
{
|
||||
String ret = "Invalid shapeless ore recipe: ";
|
||||
for (Object tmp : recipe)
|
||||
{
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += output;
|
||||
throw new RuntimeException(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShapelessBloodOrbRecipe(ShapelessRecipes recipe, Map<ItemStack, String> replacements) {
|
||||
output = recipe.getRecipeOutput();
|
||||
ShapelessBloodOrbRecipe(ShapelessRecipes recipe, Map<ItemStack, String> replacements)
|
||||
{
|
||||
output = recipe.getRecipeOutput();
|
||||
|
||||
for (ItemStack ingred : ((List<ItemStack>) recipe.recipeItems)) {
|
||||
Object finalObj = ingred;
|
||||
for (Entry<ItemStack, String> replace : replacements.entrySet()) {
|
||||
if (OreDictionary.itemMatches(replace.getKey(), ingred, false)) {
|
||||
finalObj = OreDictionary.getOres(replace.getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
input.add(finalObj);
|
||||
}
|
||||
}
|
||||
for (ItemStack ingred : ((List<ItemStack>) recipe.recipeItems))
|
||||
{
|
||||
Object finalObj = ingred;
|
||||
for (Entry<ItemStack, String> replace : replacements.entrySet())
|
||||
{
|
||||
if (OreDictionary.itemMatches(replace.getKey(), ingred, false))
|
||||
{
|
||||
finalObj = OreDictionary.getOres(replace.getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
input.add(finalObj);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return input.size();
|
||||
}
|
||||
@Override
|
||||
public int getRecipeSize()
|
||||
{
|
||||
return input.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return output;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getRecipeOutput()
|
||||
{
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting var1) {
|
||||
return output.copy();
|
||||
}
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting var1)
|
||||
{
|
||||
return output.copy();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting var1, World world) {
|
||||
ArrayList<Object> required = new ArrayList<Object>(input);
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting var1, World world)
|
||||
{
|
||||
ArrayList<Object> required = new ArrayList<Object>(input);
|
||||
|
||||
for (int x = 0; x < var1.getSizeInventory(); x++) {
|
||||
ItemStack slot = var1.getStackInSlot(x);
|
||||
for (int x = 0; x < var1.getSizeInventory(); x++)
|
||||
{
|
||||
ItemStack slot = var1.getStackInSlot(x);
|
||||
|
||||
if (slot != null) {
|
||||
boolean inRecipe = false;
|
||||
Iterator<Object> req = required.iterator();
|
||||
if (slot != null)
|
||||
{
|
||||
boolean inRecipe = false;
|
||||
Iterator<Object> req = required.iterator();
|
||||
|
||||
while (req.hasNext()) {
|
||||
boolean match = false;
|
||||
while (req.hasNext())
|
||||
{
|
||||
boolean match = false;
|
||||
|
||||
Object next = req.next();
|
||||
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) {
|
||||
IBloodOrb orb = (IBloodOrb) slot.getItem();
|
||||
if (orb.getOrbLevel(slot.getItemDamage()) < (Integer) next) {
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
return false;
|
||||
match = true;
|
||||
} else if (next instanceof ItemStack) {
|
||||
match = OreDictionary.itemMatches((ItemStack) next, slot, false);
|
||||
} else if (next instanceof ArrayList) {
|
||||
Iterator<ItemStack> itr = ((ArrayList<ItemStack>) next).iterator();
|
||||
while (itr.hasNext() && !match) {
|
||||
match = OreDictionary.itemMatches(itr.next(), slot, false);
|
||||
}
|
||||
}
|
||||
// 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)
|
||||
{
|
||||
IBloodOrb orb = (IBloodOrb) slot.getItem();
|
||||
if (orb.getOrbLevel(slot.getItemDamage()) < (Integer) next)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
return false;
|
||||
match = true;
|
||||
} else if (next instanceof ItemStack)
|
||||
{
|
||||
match = OreDictionary.itemMatches((ItemStack) next, slot, false);
|
||||
} else if (next instanceof ArrayList)
|
||||
{
|
||||
Iterator<ItemStack> itr = ((ArrayList<ItemStack>) next).iterator();
|
||||
while (itr.hasNext() && !match)
|
||||
{
|
||||
match = OreDictionary.itemMatches(itr.next(), slot, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
inRecipe = true;
|
||||
required.remove(next);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match)
|
||||
{
|
||||
inRecipe = true;
|
||||
required.remove(next);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!inRecipe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!inRecipe)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return required.isEmpty();
|
||||
}
|
||||
return required.isEmpty();
|
||||
}
|
||||
|
||||
public ArrayList<Object> getInput() {
|
||||
return this.input;
|
||||
}
|
||||
public ArrayList<Object> getInput()
|
||||
{
|
||||
return this.input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getRemainingItems(InventoryCrafting inv) {
|
||||
ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()];
|
||||
@Override
|
||||
public ItemStack[] getRemainingItems(InventoryCrafting inv)
|
||||
{
|
||||
ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()];
|
||||
|
||||
for (int i = 0; i < aitemstack.length; ++i) {
|
||||
ItemStack itemstack = inv.getStackInSlot(i);
|
||||
aitemstack[i] = net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack);
|
||||
}
|
||||
for (int i = 0; i < aitemstack.length; ++i)
|
||||
{
|
||||
ItemStack itemstack = inv.getStackInSlot(i);
|
||||
aitemstack[i] = net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack);
|
||||
}
|
||||
|
||||
return aitemstack;
|
||||
}
|
||||
return aitemstack;
|
||||
}
|
||||
}
|
|
@ -17,177 +17,212 @@ 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"));
|
||||
public static final AlchemyCircleRenderer defaultRenderer = new AlchemyCircleRenderer(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png"));
|
||||
|
||||
@Getter
|
||||
private static BiMap<ItemStackWrapper, AlchemyArrayRecipe> recipes = HashBiMap.create();
|
||||
@Getter
|
||||
private static BiMap<ItemStackWrapper, AlchemyArrayRecipe> recipes = HashBiMap.create();
|
||||
|
||||
/**
|
||||
* General case for creating an AlchemyArrayEffect for a given input.
|
||||
*
|
||||
* @param inputStack
|
||||
* - Input item that is used to change the Alchemy Circle into
|
||||
* the circle that you are making
|
||||
* @param catalystStack
|
||||
* - Catalyst item that, when right-clicked onto the array, will
|
||||
* cause an effect
|
||||
* @param arrayEffect
|
||||
* - The effect that will be activated once the array is
|
||||
* activated
|
||||
* @param circleRenderer
|
||||
* - Circle rendered when the array is passive - can be
|
||||
* substituted for a special renderer
|
||||
*/
|
||||
public static void registerRecipe(ItemStack inputStack, @Nullable ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) {
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(inputStack)) {
|
||||
AlchemyArrayEffect eff = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
||||
if (eff != null) {
|
||||
return; // Recipe already exists!
|
||||
} else {
|
||||
arrayRecipe.catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
|
||||
if (circleRenderer != null) {
|
||||
arrayRecipe.circleRenderer = circleRenderer;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* General case for creating an AlchemyArrayEffect for a given input.
|
||||
*
|
||||
* @param inputStack
|
||||
* - Input item that is used to change the Alchemy Circle into
|
||||
* the circle that you are making
|
||||
* @param catalystStack
|
||||
* - Catalyst item that, when right-clicked onto the array, will
|
||||
* cause an effect
|
||||
* @param arrayEffect
|
||||
* - The effect that will be activated once the array is
|
||||
* activated
|
||||
* @param circleRenderer
|
||||
* - Circle rendered when the array is passive - can be
|
||||
* substituted for a special renderer
|
||||
*/
|
||||
public static void registerRecipe(ItemStack inputStack, @Nullable ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer)
|
||||
{
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet())
|
||||
{
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(inputStack))
|
||||
{
|
||||
AlchemyArrayEffect eff = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
||||
if (eff != null)
|
||||
{
|
||||
return; // Recipe already exists!
|
||||
} else
|
||||
{
|
||||
arrayRecipe.catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
|
||||
if (circleRenderer != null)
|
||||
{
|
||||
arrayRecipe.circleRenderer = circleRenderer;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (circleRenderer == null) {
|
||||
recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, defaultRenderer));
|
||||
} else {
|
||||
recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, circleRenderer));
|
||||
}
|
||||
if (circleRenderer == null)
|
||||
{
|
||||
recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, defaultRenderer));
|
||||
} else
|
||||
{
|
||||
recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, circleRenderer));
|
||||
}
|
||||
|
||||
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) {
|
||||
registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack), 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) {
|
||||
registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack), 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) {
|
||||
registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(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) {
|
||||
AlchemyCircleRenderer circleRenderer = null;
|
||||
if (arrayResource == null) {
|
||||
circleRenderer = defaultRenderer;
|
||||
} else {
|
||||
circleRenderer = new AlchemyCircleRenderer(arrayResource);
|
||||
}
|
||||
public static void registerRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource)
|
||||
{
|
||||
AlchemyCircleRenderer circleRenderer = null;
|
||||
if (arrayResource == null)
|
||||
{
|
||||
circleRenderer = defaultRenderer;
|
||||
} else
|
||||
{
|
||||
circleRenderer = new AlchemyCircleRenderer(arrayResource);
|
||||
}
|
||||
|
||||
registerRecipe(inputStack, catalystStack, arrayEffect, circleRenderer);
|
||||
}
|
||||
registerRecipe(inputStack, catalystStack, arrayEffect, circleRenderer);
|
||||
}
|
||||
|
||||
public static void registerRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect) {
|
||||
registerRecipe(inputStack, catalystStack, arrayEffect, (AlchemyCircleRenderer) null);
|
||||
}
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(inputStack)) {
|
||||
arrayRecipe.circleRenderer = circleRenderer;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void replaceAlchemyCircle(ItemStack inputStack, AlchemyCircleRenderer circleRenderer)
|
||||
{
|
||||
if (circleRenderer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet())
|
||||
{
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(inputStack))
|
||||
{
|
||||
arrayRecipe.circleRenderer = circleRenderer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static AlchemyArrayRecipe getRecipeForInput(ItemStack input) {
|
||||
return recipes.get(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()) {
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (ItemStackWrapper.getHolder(arrayRecipe.getInputStack()).equals(ItemStackWrapper.getHolder(inputStack))) {
|
||||
AlchemyArrayEffect effect = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
||||
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)))
|
||||
{
|
||||
AlchemyArrayEffect effect = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
||||
|
||||
return effect; // TODO: Decide if a copy should be returned.
|
||||
}
|
||||
}
|
||||
return effect; // TODO: Decide if a copy should be returned.
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static AlchemyCircleRenderer getAlchemyCircleRenderer(ItemStack inputStack) {
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(inputStack)) {
|
||||
return arrayRecipe.circleRenderer;
|
||||
}
|
||||
}
|
||||
public static AlchemyCircleRenderer getAlchemyCircleRenderer(ItemStack inputStack)
|
||||
{
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet())
|
||||
{
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(inputStack))
|
||||
{
|
||||
return arrayRecipe.circleRenderer;
|
||||
}
|
||||
}
|
||||
|
||||
return defaultRenderer;
|
||||
}
|
||||
return defaultRenderer;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
public static class AlchemyArrayRecipe {
|
||||
@Getter
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
public static class AlchemyArrayRecipe
|
||||
{
|
||||
|
||||
public AlchemyCircleRenderer circleRenderer;
|
||||
public final ItemStack inputStack;
|
||||
public final BiMap<ItemStackWrapper, AlchemyArrayEffect> catalystMap = HashBiMap.create();
|
||||
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) {
|
||||
this.inputStack = inputStack;
|
||||
public AlchemyArrayRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer)
|
||||
{
|
||||
this.inputStack = inputStack;
|
||||
|
||||
catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
|
||||
catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
|
||||
|
||||
this.circleRenderer = circleRenderer;
|
||||
}
|
||||
this.circleRenderer = circleRenderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the inputed ItemStack to see if it matches with the recipe's
|
||||
* inputStack.
|
||||
*
|
||||
* @param comparedStack
|
||||
* @return - true if the ItemStack is a compatible item
|
||||
*/
|
||||
public boolean doesInputMatchRecipe(ItemStack comparedStack) {
|
||||
if (comparedStack == null || this.inputStack == null)
|
||||
return false;
|
||||
/**
|
||||
* Compares the inputed ItemStack to see if it matches with the recipe's
|
||||
* inputStack.
|
||||
*
|
||||
* @param comparedStack
|
||||
* @return - true if the ItemStack is a compatible item
|
||||
*/
|
||||
public boolean doesInputMatchRecipe(ItemStack comparedStack)
|
||||
{
|
||||
if (comparedStack == null || this.inputStack == null)
|
||||
return false;
|
||||
|
||||
return this.inputStack.isItemEqual(comparedStack);
|
||||
}
|
||||
return this.inputStack.isItemEqual(comparedStack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the actual AlchemyArrayEffect for the given catalyst.
|
||||
*
|
||||
* @param comparedStack
|
||||
* The catalyst that is being checked
|
||||
* @return
|
||||
*/
|
||||
public AlchemyArrayEffect getAlchemyArrayEffectForCatalyst(@Nullable ItemStack comparedStack) {
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayEffect> entry : catalystMap.entrySet()) {
|
||||
ItemStack catalystStack = entry.getKey().toStack();
|
||||
if (comparedStack == null && catalystStack == null) {
|
||||
return entry.getValue();
|
||||
}
|
||||
/**
|
||||
* Gets the actual AlchemyArrayEffect for the given catalyst.
|
||||
*
|
||||
* @param comparedStack
|
||||
* The catalyst that is being checked
|
||||
* @return
|
||||
*/
|
||||
public AlchemyArrayEffect getAlchemyArrayEffectForCatalyst(@Nullable ItemStack comparedStack)
|
||||
{
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayEffect> entry : catalystMap.entrySet())
|
||||
{
|
||||
ItemStack catalystStack = entry.getKey().toStack();
|
||||
if (comparedStack == null && catalystStack == null)
|
||||
{
|
||||
return entry.getValue();
|
||||
}
|
||||
|
||||
if (comparedStack == null || catalystStack == null) {
|
||||
continue;
|
||||
}
|
||||
if (comparedStack == null || catalystStack == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (catalystStack.isItemEqual(comparedStack)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
if (catalystStack.isItemEqual(comparedStack))
|
||||
{
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 ? "" : " -> " );
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
return orderedIdList;
|
||||
public static ArrayList<String> getOrderedIds()
|
||||
{
|
||||
return orderedIdList;
|
||||
}
|
||||
|
||||
public static ArrayList<Ritual> getRituals() {
|
||||
public static ArrayList<Ritual> getRituals()
|
||||
{
|
||||
return new ArrayList<Ritual>(registry.values());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
return new ArrayList();
|
||||
}
|
||||
public List<BlockPos> getContainedPositions()
|
||||
{
|
||||
return new ArrayList();
|
||||
}
|
||||
|
||||
public AxisAlignedBB getAABB() {
|
||||
return null;
|
||||
}
|
||||
public AxisAlignedBB getAABB()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,140 +21,152 @@ 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;
|
||||
private final int crystalLevel;
|
||||
private final int activationCost;
|
||||
private final RitualRenderer renderer;
|
||||
private final String unlocalizedName;
|
||||
public final ArrayList<RitualComponent> ritualComponents = new ArrayList<RitualComponent>();
|
||||
private final String name;
|
||||
private final int crystalLevel;
|
||||
private final int activationCost;
|
||||
private final RitualRenderer renderer;
|
||||
private final String unlocalizedName;
|
||||
|
||||
private final Map<String, BlockPos[]> modableRangeMap = new HashMap<String, BlockPos[]>();
|
||||
private final Map<String, BlockPos[]> modableRangeMap = new HashMap<String, BlockPos[]>();
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* - The name of the ritual
|
||||
* @param crystalLevel
|
||||
* - Required Activation Crystal tier
|
||||
* @param activationCost
|
||||
* - Base LP cost for activating the ritual
|
||||
*/
|
||||
public Ritual(String name, int crystalLevel, int activationCost, String unlocalizedName) {
|
||||
this(name, crystalLevel, activationCost, null, unlocalizedName);
|
||||
}
|
||||
/**
|
||||
* @param name
|
||||
* - The name of the ritual
|
||||
* @param crystalLevel
|
||||
* - Required Activation Crystal tier
|
||||
* @param activationCost
|
||||
* - Base LP cost for activating the ritual
|
||||
*/
|
||||
public Ritual(String name, int crystalLevel, int activationCost, String unlocalizedName)
|
||||
{
|
||||
this(name, crystalLevel, activationCost, null, unlocalizedName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the player attempts to activate the ritual.
|
||||
*
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#activateRitual(ItemStack, EntityPlayer, Ritual)}
|
||||
*
|
||||
* @param masterRitualStone
|
||||
* - The {@link IMasterRitualStone} that the ritual is bound to
|
||||
* @param player
|
||||
* - The activating player
|
||||
* @return - Whether activation was successful
|
||||
*/
|
||||
public boolean activateRitual(IMasterRitualStone masterRitualStone, EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Called when the player attempts to activate the ritual.
|
||||
*
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#activateRitual(ItemStack, EntityPlayer, Ritual)}
|
||||
*
|
||||
* @param masterRitualStone
|
||||
* - The {@link IMasterRitualStone} that the ritual is bound to
|
||||
* @param player
|
||||
* - The activating player
|
||||
* @return - Whether activation was successful
|
||||
*/
|
||||
public boolean activateRitual(IMasterRitualStone masterRitualStone, EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called every {@link #getRefreshTime()} ticks while active.
|
||||
*
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#performRitual(World, BlockPos)}
|
||||
*
|
||||
* @param masterRitualStone
|
||||
* - The {@link IMasterRitualStone} that the ritual is bound to
|
||||
*/
|
||||
public abstract void performRitual(IMasterRitualStone masterRitualStone);
|
||||
/**
|
||||
* Called every {@link #getRefreshTime()} ticks while active.
|
||||
*
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#performRitual(World, BlockPos)}
|
||||
*
|
||||
* @param masterRitualStone
|
||||
* - The {@link IMasterRitualStone} that the ritual is bound to
|
||||
*/
|
||||
public abstract void performRitual(IMasterRitualStone masterRitualStone);
|
||||
|
||||
/**
|
||||
* Called when the ritual is stopped for a given {@link BreakType}.
|
||||
*
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(BreakType)}
|
||||
*
|
||||
* @param masterRitualStone
|
||||
* - The {@link IMasterRitualStone} that the ritual is bound to
|
||||
* @param breakType
|
||||
* - The type of break that caused the stoppage.
|
||||
*/
|
||||
public void stopRitual(IMasterRitualStone masterRitualStone, BreakType breakType) {
|
||||
/**
|
||||
* Called when the ritual is stopped for a given {@link BreakType}.
|
||||
*
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(BreakType)}
|
||||
*
|
||||
* @param masterRitualStone
|
||||
* - The {@link IMasterRitualStone} that the ritual is bound to
|
||||
* @param breakType
|
||||
* - The type of break that caused the stoppage.
|
||||
*/
|
||||
public void stopRitual(IMasterRitualStone masterRitualStone, BreakType breakType)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to set the amount of LP drained every {@link #getRefreshTime()}
|
||||
* ticks.
|
||||
*
|
||||
* @return - The amount of LP drained per refresh
|
||||
*/
|
||||
public abstract int getRefreshCost();
|
||||
/**
|
||||
* Used to set the amount of LP drained every {@link #getRefreshTime()}
|
||||
* ticks.
|
||||
*
|
||||
* @return - The amount of LP drained per refresh
|
||||
*/
|
||||
public abstract int getRefreshCost();
|
||||
|
||||
/**
|
||||
* Used to set the refresh rate of the ritual. (How often
|
||||
* {@link #performRitual(IMasterRitualStone)} is called.
|
||||
*
|
||||
* @return - How often to perform the effect in ticks.
|
||||
*/
|
||||
public int getRefreshTime() {
|
||||
return 20;
|
||||
}
|
||||
/**
|
||||
* Used to set the refresh rate of the ritual. (How often
|
||||
* {@link #performRitual(IMasterRitualStone)} is called.
|
||||
*
|
||||
* @return - How often to perform the effect in ticks.
|
||||
*/
|
||||
public int getRefreshTime()
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
public void addBlockRange(String range, BlockPos[] defaultRange) {
|
||||
modableRangeMap.put(range, defaultRange);
|
||||
}
|
||||
public void addBlockRange(String range, BlockPos[] defaultRange)
|
||||
{
|
||||
modableRangeMap.put(range, defaultRange);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to grab the range of a ritual for a given effect. The order of the
|
||||
* blockPos array is: bottom corner, top corner.
|
||||
*
|
||||
* @param range
|
||||
* - Range that needs to be pulled.
|
||||
* @return - The range of the ritual effect. Array must be of size 2 and
|
||||
* have non-null values, with the first BlockPos having the lower
|
||||
* offset values and the second BlockPos having the higher offset
|
||||
* values
|
||||
*/
|
||||
public BlockPos[] getBlockRange(String range) {
|
||||
if (modableRangeMap.containsKey(range)) {
|
||||
return modableRangeMap.get(range);
|
||||
}
|
||||
/**
|
||||
* Used to grab the range of a ritual for a given effect. The order of the
|
||||
* blockPos array is: bottom corner, top corner.
|
||||
*
|
||||
* @param range
|
||||
* - Range that needs to be pulled.
|
||||
* @return - The range of the ritual effect. Array must be of size 2 and
|
||||
* have non-null values, with the first BlockPos having the lower
|
||||
* offset values and the second BlockPos having the higher offset
|
||||
* values
|
||||
*/
|
||||
public BlockPos[] getBlockRange(String range)
|
||||
{
|
||||
if (modableRangeMap.containsKey(range))
|
||||
{
|
||||
return modableRangeMap.get(range);
|
||||
}
|
||||
|
||||
return new BlockPos[] { new BlockPos(0, 0, 0), new BlockPos(0, 0, 0) };
|
||||
}
|
||||
return new BlockPos[] { new BlockPos(0, 0, 0), new BlockPos(0, 0, 0) };
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list of {@link RitualComponent} for checking the ritual.
|
||||
*/
|
||||
public abstract ArrayList<RitualComponent> getComponents();
|
||||
/**
|
||||
* @return a list of {@link RitualComponent} for checking the ritual.
|
||||
*/
|
||||
public abstract ArrayList<RitualComponent> getComponents();
|
||||
|
||||
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));
|
||||
components.add(new RitualComponent(new BlockPos(-offset2, y, offset1), 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));
|
||||
components.add(new RitualComponent(new BlockPos(-offset2, y, -offset1), 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));
|
||||
components.add(new RitualComponent(new BlockPos(-offset2, y, offset1), 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));
|
||||
components.add(new RitualComponent(new BlockPos(-offset2, y, -offset1), 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 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) {
|
||||
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 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 {
|
||||
REDSTONE, BREAK_MRS, BREAK_STONE, ACTIVATE, DEACTIVATE, EXPLOSION,
|
||||
}
|
||||
public enum BreakType
|
||||
{
|
||||
REDSTONE, BREAK_MRS, BREAK_STONE, ACTIVATE, DEACTIVATE, EXPLOSION,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,43 +6,49 @@ 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) {
|
||||
case EAST:
|
||||
return -this.getOffset().getZ();
|
||||
case SOUTH:
|
||||
return -this.getOffset().getX();
|
||||
case WEST:
|
||||
return this.getOffset().getZ();
|
||||
default:
|
||||
return this.getOffset().getX();
|
||||
public int getX(EnumFacing direction)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case EAST:
|
||||
return -this.getOffset().getZ();
|
||||
case SOUTH:
|
||||
return -this.getOffset().getX();
|
||||
case WEST:
|
||||
return this.getOffset().getZ();
|
||||
default:
|
||||
return this.getOffset().getX();
|
||||
}
|
||||
}
|
||||
|
||||
public int getZ(EnumFacing direction) {
|
||||
switch (direction) {
|
||||
case EAST:
|
||||
return this.getOffset().getX();
|
||||
case SOUTH:
|
||||
return -this.getOffset().getZ();
|
||||
case WEST:
|
||||
return -this.getOffset().getX();
|
||||
default:
|
||||
return this.getOffset().getZ();
|
||||
public int getZ(EnumFacing direction)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case EAST:
|
||||
return this.getOffset().getX();
|
||||
case SOUTH:
|
||||
return -this.getOffset().getZ();
|
||||
case WEST:
|
||||
return -this.getOffset().getX();
|
||||
default:
|
||||
return this.getOffset().getZ();
|
||||
}
|
||||
}
|
||||
|
||||
public BlockPos getOffset(EnumFacing direction) {
|
||||
return new BlockPos(getX(direction), offset.getY(), getZ(direction));
|
||||
public BlockPos getOffset(EnumFacing direction)
|
||||
{
|
||||
return new BlockPos(getX(direction), offset.getY(), getZ(direction));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,87 +44,106 @@ 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) {
|
||||
boolean test = checkValidRitual(world, pos, key, direction);
|
||||
if(test) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
return "";
|
||||
}
|
||||
|
||||
public static EnumFacing getDirectionOfRitual(World world, BlockPos pos, String key) {
|
||||
for(EnumFacing direction : EnumFacing.HORIZONTALS) {
|
||||
boolean test = checkValidRitual(world, pos, key, direction);
|
||||
if(test) {
|
||||
return direction;
|
||||
}
|
||||
}
|
||||
public static EnumFacing getDirectionOfRitual(World world, BlockPos pos, String key)
|
||||
{
|
||||
for (EnumFacing direction : EnumFacing.HORIZONTALS)
|
||||
{
|
||||
boolean test = checkValidRitual(world, pos, key, direction);
|
||||
if (test)
|
||||
{
|
||||
return direction;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean checkValidRitual(World world, BlockPos pos, String ritualId, EnumFacing direction) {
|
||||
Ritual ritual = RitualRegistry.getRitualForId(ritualId);
|
||||
if(ritual == null) {
|
||||
return false;
|
||||
}
|
||||
public static boolean checkValidRitual(World world, BlockPos pos, String ritualId, EnumFacing direction)
|
||||
{
|
||||
Ritual ritual = RitualRegistry.getRitualForId(ritualId);
|
||||
if (ritual == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ArrayList<RitualComponent> components = ritual.getComponents();
|
||||
|
||||
if (components == null)
|
||||
return false;
|
||||
|
||||
for (RitualComponent component : components) {
|
||||
BlockPos newPos = pos.add(component.getOffset(direction));
|
||||
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())) {
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
return false;
|
||||
if (block instanceof IRitualStone)
|
||||
{
|
||||
if (!((IRitualStone) block).isRuneType(world, newPos, component.getRuneType()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,76 +23,90 @@ 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() {
|
||||
super(Material.cloth);
|
||||
public BlockAlchemyArray()
|
||||
{
|
||||
super(Material.cloth);
|
||||
|
||||
setUnlocalizedName(Constants.Mod.MODID + ".alchemyArray");
|
||||
setCreativeTab(BloodMagic.tabBloodMagic);
|
||||
this.setHardness(0.1f);
|
||||
}
|
||||
setUnlocalizedName(Constants.Mod.MODID + ".alchemyArray");
|
||||
setCreativeTab(BloodMagic.tabBloodMagic);
|
||||
this.setHardness(0.1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public EnumWorldBlockLayer getBlockLayer() {
|
||||
return EnumWorldBlockLayer.CUTOUT;
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public EnumWorldBlockLayer getBlockLayer()
|
||||
{
|
||||
return EnumWorldBlockLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isFullCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
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 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) {
|
||||
TileAlchemyArray array = (TileAlchemyArray) world.getTileEntity(pos);
|
||||
@Override
|
||||
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())
|
||||
return false;
|
||||
if (array == null || player.isSneaking())
|
||||
return false;
|
||||
|
||||
ItemStack playerItem = player.getCurrentEquippedItem();
|
||||
ItemStack playerItem = player.getCurrentEquippedItem();
|
||||
|
||||
if (playerItem != null) {
|
||||
if (array.getStackInSlot(0) == null) {
|
||||
Utils.insertItemToTile(array, player, 0);
|
||||
} else {
|
||||
Utils.insertItemToTile(array, player, 1);
|
||||
array.attemptCraft();
|
||||
}
|
||||
}
|
||||
if (playerItem != null)
|
||||
{
|
||||
if (array.getStackInSlot(0) == null)
|
||||
{
|
||||
Utils.insertItemToTile(array, player, 0);
|
||||
} else
|
||||
{
|
||||
Utils.insertItemToTile(array, player, 1);
|
||||
array.attemptCraft();
|
||||
}
|
||||
}
|
||||
|
||||
world.markBlockForUpdate(pos);
|
||||
return true;
|
||||
}
|
||||
world.markBlockForUpdate(pos);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random random) {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int quantityDropped(Random random)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return -1;
|
||||
}
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
||||
return new TileAlchemyArray();
|
||||
}
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||
{
|
||||
return new TileAlchemyArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) {
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos blockPos, IBlockState blockState)
|
||||
{
|
||||
TileAlchemyArray alchemyArray = (TileAlchemyArray) world.getTileEntity(blockPos);
|
||||
if (alchemyArray != null)
|
||||
alchemyArray.dropItems();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 static final String[] names = { "normal", "large" };
|
||||
|
||||
public BlockBloodStoneBrick() {
|
||||
public BlockBloodStoneBrick()
|
||||
{
|
||||
super(Material.rock, names);
|
||||
|
||||
setUnlocalizedName(Constants.Mod.MODID + ".bloodstonebrick.");
|
||||
|
|
|
@ -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 static final String[] names = {"normal", "brick"};
|
||||
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.");
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 static String[] names = { "pedestal", "plinth" };
|
||||
|
||||
public BlockPedestal() {
|
||||
public BlockPedestal()
|
||||
{
|
||||
super(Material.rock, names);
|
||||
|
||||
setUnlocalizedName(Constants.Mod.MODID + ".");
|
||||
|
@ -28,35 +30,41 @@ 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: {
|
||||
// TileEntity plinth = world.getTileEntity(pos);
|
||||
//
|
||||
// if (plinth!= null && plinth instanceof TilePlinth) {
|
||||
// Utils.insertItemToTile((TilePlinth) plinth, player);
|
||||
// }
|
||||
}
|
||||
|
||||
case 1: {
|
||||
TileEntity plinth = world.getTileEntity(pos);
|
||||
|
||||
if (plinth == null || player.isSneaking())
|
||||
return false;
|
||||
|
||||
if (plinth instanceof TilePlinth) {
|
||||
Utils.insertItemToTile((TilePlinth) plinth, player);
|
||||
return true;
|
||||
}
|
||||
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) {
|
||||
// Utils.insertItemToTile((TilePlinth) plinth, player);
|
||||
// }
|
||||
}
|
||||
|
||||
case 1:
|
||||
{
|
||||
TileEntity plinth = world.getTileEntity(pos);
|
||||
|
||||
if (plinth == null || player.isSneaking())
|
||||
return false;
|
||||
|
||||
if (plinth instanceof TilePlinth)
|
||||
{
|
||||
Utils.insertItemToTile((TilePlinth) plinth, player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
world.markBlockForUpdate(pos);
|
||||
return false;
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 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) {
|
||||
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))) {
|
||||
((TileMasterRitualStone) tile).setDirection(direction);
|
||||
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)))
|
||||
{
|
||||
((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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 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))]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
return new BlockState(this, new IProperty[]{INPUT, OUTPUT});
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
return new ExtendedBlockState(this, new IProperty[]{metaProp}, new IUnlistedProperty[]{unlistedMetaProp});
|
||||
private BlockState createRealBlockState()
|
||||
{
|
||||
return new ExtendedBlockState(this, new IProperty[] { metaProp }, new IUnlistedProperty[] { unlistedMetaProp });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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() {
|
||||
return new ExtendedBlockState(this, new IProperty[]{stringProp}, new IUnlistedProperty[]{unlistedStringProp});
|
||||
private BlockState createRealBlockState()
|
||||
{
|
||||
return new ExtendedBlockState(this, new IProperty[] { stringProp }, new IUnlistedProperty[] { unlistedStringProp });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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())));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,14 +6,16 @@ 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) {
|
||||
ItemStack inputStack = alchemyArray.getStackInSlot(0);
|
||||
int craftTime = alchemyArray.activeCounter;
|
||||
AlchemyCircleRenderer renderer = AlchemyArrayRecipeRegistry.getAlchemyCircleRenderer(inputStack);
|
||||
@Override
|
||||
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);
|
||||
|
||||
renderer.renderAt(alchemyArray, x, y, z, (craftTime > 0 ? craftTime + partialTicks : 0));
|
||||
}
|
||||
renderer.renderAt(alchemyArray, x, y, z, (craftTime > 0 ? craftTime + partialTicks : 0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,234 +10,264 @@ 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;
|
||||
public final ResourceLocation[] arraysResources;
|
||||
public float offsetFromFace = -0.9f;
|
||||
public final ResourceLocation arrayResource;
|
||||
public final ResourceLocation[] arraysResources;
|
||||
|
||||
public static final int numberOfSweeps = 5;
|
||||
public static final int startTime = 50;
|
||||
public static final int sweepTime = 40;
|
||||
public static final int numberOfSweeps = 5;
|
||||
public static final int startTime = 50;
|
||||
public static final int sweepTime = 40;
|
||||
|
||||
public static final int inwardRotationTime = 50;
|
||||
public static final int inwardRotationTime = 50;
|
||||
|
||||
public static final float arcLength = (float) Math.sqrt(2*(2*2) - 2*2*2*Math.cos(2*Math.PI*2/5));
|
||||
public static final float theta2 = (float) (18f * Math.PI / 180f);
|
||||
public static final float arcLength = (float) Math.sqrt(2 * (2 * 2) - 2 * 2 * 2 * Math.cos(2 * Math.PI * 2 / 5));
|
||||
public static final float theta2 = (float) (18f * Math.PI / 180f);
|
||||
|
||||
public static final int endTime = 300;
|
||||
public static final int endTime = 300;
|
||||
|
||||
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");
|
||||
arraysResources[1] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png");
|
||||
arraysResources[2] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png");
|
||||
arraysResources[3] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png");
|
||||
arraysResources[4] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png");
|
||||
}
|
||||
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");
|
||||
arraysResources[1] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png");
|
||||
arraysResources[2] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png");
|
||||
arraysResources[3] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png");
|
||||
arraysResources[4] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png");
|
||||
}
|
||||
|
||||
public static float getAngleOfCircle(int circle, float craftTime) {
|
||||
if (circle >= 0 && circle <= 4) {
|
||||
float originalAngle = (float) (circle * 2 * Math.PI / 5d);
|
||||
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) {
|
||||
float offset = ((int)sweep)*sweepTime + startTime;
|
||||
originalAngle += 2*Math.PI*2/5*(int)sweep + getAngle(craftTime - offset, (int)sweep);
|
||||
}else if(sweep >= numberOfSweeps)
|
||||
{
|
||||
originalAngle += 2*Math.PI*2/5*numberOfSweeps + (craftTime - 5*sweepTime - startTime)*2*Math.PI*2/5/sweepTime;
|
||||
}
|
||||
double sweep = (craftTime - startTime) / sweepTime;
|
||||
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)
|
||||
{
|
||||
originalAngle += 2 * Math.PI * 2 / 5 * numberOfSweeps + (craftTime - 5 * sweepTime - startTime) * 2 * Math.PI * 2 / 5 / sweepTime;
|
||||
}
|
||||
|
||||
return originalAngle;
|
||||
}
|
||||
return originalAngle;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
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)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
double sweep = (craftTime - startTime)/sweepTime;
|
||||
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) {
|
||||
return 2 - 2 * (craftTime - startTime - numberOfSweeps * sweepTime) / (endTime - startTime - numberOfSweeps * sweepTime);
|
||||
} else if(craftTime >= endTime) {
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
double sweep = (craftTime - startTime) / sweepTime;
|
||||
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)
|
||||
{
|
||||
return 2 - 2 * (craftTime - startTime - numberOfSweeps * sweepTime) / (endTime - startTime - numberOfSweeps * sweepTime);
|
||||
} else if (craftTime >= endTime)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 2;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
public float getRotation(int circle, float craftTime) {
|
||||
float offset = 2;
|
||||
if(circle == -1) {
|
||||
return (float) (craftTime * 360 * 2/5/sweepTime);
|
||||
}
|
||||
if (craftTime >= offset) {
|
||||
float modifier = (float) Math.pow(craftTime - offset, 1.5);
|
||||
return modifier * 0.5f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public float getRotation(int circle, float craftTime)
|
||||
{
|
||||
float offset = 2;
|
||||
if (circle == -1)
|
||||
{
|
||||
return (float) (craftTime * 360 * 2 / 5 / sweepTime);
|
||||
}
|
||||
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) {
|
||||
float offset = 50;
|
||||
if (craftTime >= offset) {
|
||||
float modifier = (float) Math.pow(craftTime - offset, 1.7);
|
||||
return modifier * 0.5f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public float getSecondaryRotation(int circle, float craftTime)
|
||||
{
|
||||
float offset = 50;
|
||||
if (craftTime >= offset)
|
||||
{
|
||||
float modifier = (float) Math.pow(craftTime - offset, 1.7);
|
||||
return modifier * 0.5f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float 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 {
|
||||
return -0.4f;
|
||||
}
|
||||
}
|
||||
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
|
||||
{
|
||||
return -0.4f;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (craftTime >= 5) {
|
||||
if (craftTime <= 40) {
|
||||
return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3));
|
||||
} else {
|
||||
return -0.4f;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (craftTime >= 5)
|
||||
{
|
||||
if (craftTime <= 40)
|
||||
{
|
||||
return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3));
|
||||
} else
|
||||
{
|
||||
return -0.4f;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getInwardRotation(int circle, float craftTime) {
|
||||
float offset = startTime + numberOfSweeps * sweepTime;
|
||||
if(craftTime >= offset) {
|
||||
if(craftTime <= offset + inwardRotationTime) {
|
||||
return 90f / inwardRotationTime * (craftTime - offset);
|
||||
} else {
|
||||
return 90;
|
||||
}
|
||||
}
|
||||
public float getInwardRotation(int circle, float craftTime)
|
||||
{
|
||||
float offset = startTime + numberOfSweeps * sweepTime;
|
||||
if (craftTime >= offset)
|
||||
{
|
||||
if (craftTime <= offset + inwardRotationTime)
|
||||
{
|
||||
return 90f / inwardRotationTime * (craftTime - offset);
|
||||
} else
|
||||
{
|
||||
return 90;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) {
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer wr = tessellator.getWorldRenderer();
|
||||
public void renderAt(TileEntity tile, double x, double y, double z, float craftTime)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer wr = tessellator.getWorldRenderer();
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
float rot = getRotation(-1, craftTime);
|
||||
float rot = getRotation(-1, craftTime);
|
||||
|
||||
float size = 3.0F;
|
||||
float size = 3.0F;
|
||||
|
||||
// Bind the texture to the circle
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(arrayResource);
|
||||
// Bind the texture to the circle
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(arrayResource);
|
||||
|
||||
GlStateManager.disableCull();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(770, 1);
|
||||
GlStateManager.disableCull();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(770, 1);
|
||||
|
||||
GlStateManager.translate(x, y, z);
|
||||
GlStateManager.translate(x, y, z);
|
||||
|
||||
EnumFacing sideHit = EnumFacing.UP; // Specify which face this "circle"
|
||||
// is located on
|
||||
GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace);
|
||||
EnumFacing sideHit = EnumFacing.UP; // Specify which face this "circle"
|
||||
// is located on
|
||||
GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace);
|
||||
|
||||
switch (sideHit) {
|
||||
case DOWN:
|
||||
GlStateManager.translate(0, 0, 1);
|
||||
GlStateManager.rotate(-90.0f, 1, 0, 0);
|
||||
break;
|
||||
case EAST:
|
||||
GlStateManager.rotate(-90.0f, 0, 1, 0);
|
||||
GlStateManager.translate(0, 0, -1);
|
||||
break;
|
||||
case NORTH:
|
||||
break;
|
||||
case SOUTH:
|
||||
GlStateManager.rotate(180.0f, 0, 1, 0);
|
||||
GlStateManager.translate(-1, 0, -1);
|
||||
break;
|
||||
case UP:
|
||||
GlStateManager.translate(0, 1, 0);
|
||||
GlStateManager.rotate(90.0f, 1, 0, 0);
|
||||
break;
|
||||
case WEST:
|
||||
GlStateManager.translate(0, 0, 1);
|
||||
GlStateManager.rotate(90.0f, 0, 1, 0);
|
||||
break;
|
||||
}
|
||||
switch (sideHit)
|
||||
{
|
||||
case DOWN:
|
||||
GlStateManager.translate(0, 0, 1);
|
||||
GlStateManager.rotate(-90.0f, 1, 0, 0);
|
||||
break;
|
||||
case EAST:
|
||||
GlStateManager.rotate(-90.0f, 0, 1, 0);
|
||||
GlStateManager.translate(0, 0, -1);
|
||||
break;
|
||||
case NORTH:
|
||||
break;
|
||||
case SOUTH:
|
||||
GlStateManager.rotate(180.0f, 0, 1, 0);
|
||||
GlStateManager.translate(-1, 0, -1);
|
||||
break;
|
||||
case UP:
|
||||
GlStateManager.translate(0, 1, 0);
|
||||
GlStateManager.rotate(90.0f, 1, 0, 0);
|
||||
break;
|
||||
case WEST:
|
||||
GlStateManager.translate(0, 0, 1);
|
||||
GlStateManager.rotate(90.0f, 0, 1, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(0.5f, 0.5f, getVerticalOffset(craftTime));
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(0.5f, 0.5f, getVerticalOffset(craftTime));
|
||||
|
||||
double var31 = 0.0D;
|
||||
double var33 = 1.0D;
|
||||
double var35 = 0;
|
||||
double var37 = 1;
|
||||
double var31 = 0.0D;
|
||||
double var33 = 1.0D;
|
||||
double var35 = 0;
|
||||
double var37 = 1;
|
||||
|
||||
// GlStateManager.color(0.5f, 1f, 1f, 1f);
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.rotate(rot, 0, 0, 1);
|
||||
// GlStateManager.color(0.5f, 1f, 1f, 1f);
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.rotate(rot, 0, 0, 1);
|
||||
|
||||
wr.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||
// wr.setBrightness(200);
|
||||
wr.pos(size / 2f, size / 2f, 0.0D).tex(var33, var37).endVertex();
|
||||
wr.pos(size / 2f, -size / 2f, 0.0D).tex(var33, var35).endVertex();
|
||||
wr.pos(-size / 2f, -size / 2f, 0.0D).tex(var31, var35).endVertex();
|
||||
wr.pos(-size / 2f, size / 2f, 0.0D).tex(var31, var37).endVertex();
|
||||
tessellator.draw();
|
||||
GlStateManager.popMatrix();
|
||||
wr.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||
// wr.setBrightness(200);
|
||||
wr.pos(size / 2f, size / 2f, 0.0D).tex(var33, var37).endVertex();
|
||||
wr.pos(size / 2f, -size / 2f, 0.0D).tex(var33, var35).endVertex();
|
||||
wr.pos(-size / 2f, -size / 2f, 0.0D).tex(var31, var35).endVertex();
|
||||
wr.pos(-size / 2f, size / 2f, 0.0D).tex(var31, var37).endVertex();
|
||||
tessellator.draw();
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
GlStateManager.pushMatrix();
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(arraysResources[i]);
|
||||
float newSize = 1;
|
||||
float distance = this.getDistanceOfCircle(i, craftTime);
|
||||
float angle = this.getAngleOfCircle(i, craftTime);
|
||||
float rotation = this.getRotation(i, craftTime);
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
GlStateManager.pushMatrix();
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(arraysResources[i]);
|
||||
float newSize = 1;
|
||||
float distance = this.getDistanceOfCircle(i, craftTime);
|
||||
float angle = this.getAngleOfCircle(i, craftTime);
|
||||
float rotation = this.getRotation(i, craftTime);
|
||||
|
||||
GlStateManager.translate(distance * Math.sin(angle), -distance * Math.cos(angle), this.getVerticalOffset(i, craftTime));
|
||||
GlStateManager.rotate(i * 360/5, 0, 0, 1);
|
||||
GlStateManager.rotate(getInwardRotation(i, craftTime), 1, 0, 0);
|
||||
GlStateManager.rotate(rotation, 0, 0, 1);
|
||||
wr.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||
wr.pos(newSize / 2f, newSize / 2f, 0.0D).tex(var33, var37).endVertex();
|
||||
wr.pos(newSize / 2f, -newSize / 2f, 0.0D).tex(var33, var35).endVertex();
|
||||
wr.pos(-newSize / 2f, -newSize / 2f, 0.0D).tex(var31, var35).endVertex();
|
||||
wr.pos(-newSize / 2f, newSize / 2f, 0.0D).tex(var31, var37).endVertex();
|
||||
tessellator.draw();
|
||||
GlStateManager.translate(distance * Math.sin(angle), -distance * Math.cos(angle), this.getVerticalOffset(i, craftTime));
|
||||
GlStateManager.rotate(i * 360 / 5, 0, 0, 1);
|
||||
GlStateManager.rotate(getInwardRotation(i, craftTime), 1, 0, 0);
|
||||
GlStateManager.rotate(rotation, 0, 0, 1);
|
||||
wr.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||
wr.pos(newSize / 2f, newSize / 2f, 0.0D).tex(var33, var37).endVertex();
|
||||
wr.pos(newSize / 2f, -newSize / 2f, 0.0D).tex(var33, var35).endVertex();
|
||||
wr.pos(-newSize / 2f, -newSize / 2f, 0.0D).tex(var31, var35).endVertex();
|
||||
wr.pos(-newSize / 2f, newSize / 2f, 0.0D).tex(var31, var37).endVertex();
|
||||
tessellator.draw();
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
// GlStateManager.depthMask(true);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableCull();
|
||||
// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
// GlStateManager.depthMask(true);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableCull();
|
||||
// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
this.inputs = Arrays.asList(new ItemStack[] {input, catalyst});
|
||||
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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,31 +21,36 @@ 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;
|
||||
|
||||
this.infoString = new String[]{TextHelper.localize("jei.BloodMagic.recipe.requiredTier", tier), TextHelper.localize("jei.BloodMagic.recipe.requiredLP", requiredLP)};
|
||||
this.infoString = new String[] { TextHelper.localize("jei.BloodMagic.recipe.requiredTier", tier), TextHelper.localize("jei.BloodMagic.recipe.requiredLP", requiredLP) };
|
||||
}
|
||||
|
||||
@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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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
Loading…
Reference in a new issue