2014-06-27 19:43:09 -04:00
|
|
|
package WayofTime.alchemicalWizardry.common.block;
|
|
|
|
|
2014-10-13 22:33:20 +02:00
|
|
|
import WayofTime.alchemicalWizardry.api.rituals.IRitualStone;
|
|
|
|
import WayofTime.alchemicalWizardry.common.items.ScribeTool;
|
2014-06-27 19:43:09 -04:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.material.Material;
|
2015-07-29 14:35:00 -04:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
2014-06-27 19:43:09 -04:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2015-07-29 14:35:00 -04:00
|
|
|
import net.minecraft.util.BlockPos;
|
|
|
|
import net.minecraft.util.EnumFacing;
|
2014-06-27 19:43:09 -04:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2015-07-29 11:30:24 -04:00
|
|
|
public class BlockRitualStone extends Block implements IRitualStone
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
2015-07-29 11:30:24 -04:00
|
|
|
public BlockRitualStone()
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
|
|
|
super(Material.iron);
|
|
|
|
setHardness(2.0F);
|
|
|
|
setResistance(5.0F);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-07-29 14:35:00 -04:00
|
|
|
public int damageDropped(IBlockState blockState)
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-07-29 14:35:00 -04:00
|
|
|
public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
|
|
|
ItemStack playerItem = player.getCurrentEquippedItem();
|
|
|
|
|
|
|
|
if (playerItem == null)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Item item = playerItem.getItem();
|
|
|
|
|
|
|
|
if (!(item instanceof ScribeTool))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (playerItem.getMaxDamage() <= playerItem.getItemDamage() && !(playerItem.getMaxDamage() == 0))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScribeTool scribeTool = (ScribeTool) item;
|
|
|
|
|
|
|
|
if (!player.capabilities.isCreativeMode)
|
|
|
|
{
|
|
|
|
playerItem.setItemDamage(playerItem.getItemDamage() + 1);
|
|
|
|
}
|
|
|
|
|
2015-07-29 14:35:00 -04:00
|
|
|
world.setBlockState(blockPos, state.getBlock().getStateFromMeta(scribeTool.getType()), 3);
|
|
|
|
world.markBlockForUpdate(blockPos);
|
2014-06-27 19:43:09 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-07 13:45:02 -05:00
|
|
|
@Override
|
2015-07-29 14:35:00 -04:00
|
|
|
public boolean isRuneType(World world, BlockPos blockPos, IBlockState blockState, int runeType)
|
2014-11-07 13:45:02 -05:00
|
|
|
{
|
2015-07-29 14:35:00 -04:00
|
|
|
return blockState.getBlock().getMetaFromState(blockState) == runeType;
|
2014-11-07 13:45:02 -05:00
|
|
|
}
|
2014-06-27 19:43:09 -04:00
|
|
|
}
|