BloodMagic/BM_src/WayofTime/alchemicalWizardry/common/tileEntity/TEHomHeart.java
Fenn e3644f2d2b Massive rework of configs, items and blocks.
I redone where the items/blocsks are stored and how the configs are
handled to clean up it and give space. You can change the config line to
AWWayofTime if you want to keep the compatibility with old configs. Now
you reference the blocks from the ModBlocks and Items from the ModItems.
2014-01-17 21:05:38 +00:00

166 lines
4.6 KiB
Java

package WayofTime.alchemicalWizardry.common.tileEntity;
import WayofTime.alchemicalWizardry.common.spell.simple.HomSpell;
import WayofTime.alchemicalWizardry.common.spell.simple.HomSpellRegistry;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntitySkull;
import net.minecraft.world.World;
public class TEHomHeart extends TileEntity {
public boolean canCastSpell(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
return true;
}
public int castSpell(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
HomSpell spell = getSpell();
if (spell != null)
{
switch (getModifiedParadigm())
{
case 0:
spell.onOffensiveRangedRightClick(par1ItemStack, par2World, par3EntityPlayer);
break;
case 1:
spell.onOffensiveMeleeRightClick(par1ItemStack, par2World, par3EntityPlayer);
break;
case 2:
spell.onDefensiveRightClick(par1ItemStack, par2World, par3EntityPlayer);
break;
case 3:
spell.onEnvironmentalRightClick(par1ItemStack, par2World, par3EntityPlayer);
break;
}
//spell.onOffensiveRangedRightClick(par1ItemStack, par2World, par3EntityPlayer);
}
return 0;
}
public HomSpell getSpell()
{
TileEntity tileEntity = worldObj.getBlockTileEntity(xCoord - 1, yCoord, zCoord);
if (tileEntity instanceof TEAltar)
{
ItemStack itemStack = ((TEAltar) tileEntity).getStackInSlot(0);
if (itemStack != null)
{
HomSpell spell = HomSpellRegistry.getSpellForItemStack(itemStack);
if (spell != null)
{
return spell;
}
}
}
tileEntity = worldObj.getBlockTileEntity(xCoord + 1, yCoord, zCoord);
if (tileEntity instanceof TEAltar)
{
ItemStack itemStack = ((TEAltar) tileEntity).getStackInSlot(0);
if (itemStack != null)
{
HomSpell spell = HomSpellRegistry.getSpellForItemStack(itemStack);
if (spell != null)
{
return spell;
}
}
}
tileEntity = worldObj.getBlockTileEntity(xCoord, yCoord, zCoord - 1);
if (tileEntity instanceof TEAltar)
{
ItemStack itemStack = ((TEAltar) tileEntity).getStackInSlot(0);
if (itemStack != null)
{
HomSpell spell = HomSpellRegistry.getSpellForItemStack(itemStack);
if (spell != null)
{
return spell;
}
}
}
tileEntity = worldObj.getBlockTileEntity(xCoord, yCoord, zCoord + 1);
if (tileEntity instanceof TEAltar)
{
ItemStack itemStack = ((TEAltar) tileEntity).getStackInSlot(0);
if (itemStack != null)
{
HomSpell spell = HomSpellRegistry.getSpellForItemStack(itemStack);
if (spell != null)
{
return spell;
}
}
}
return null;
}
public int getModifiedParadigm()
{
//TODO change so that it works with a Tile Entity for a custom head or whatnot
int blockID = worldObj.getBlockId(xCoord, yCoord + 1, zCoord);
if (blockID == Block.glowStone.blockID)
{
return 0;
} else if (blockID == Block.blockRedstone.blockID)
{
return 1;
} else if (blockID == Block.anvil.blockID)
{
return 2;
} else if (blockID == Block.glass.blockID)
{
return 3;
}
TileEntity tileEntity = worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord);
if (tileEntity instanceof TileEntitySkull)
{
int skullType = ((TileEntitySkull) tileEntity).getSkullType();
switch (skullType)
{
case 0:
return 0;
case 1:
return 1;
case 2:
return 2;
case 4:
return 3;
}
}
return -1;
}
}